SCons copying program after compilation to parent directory

build, c++, makefile, scons

Solution

A better approach would be to use the target and the Command() builder, like this:

prgTarget = env.Program( "program_name", [ "file1.cc", "file2.cc" ] )
Command(target = "../program_name",
        source = prgTarget,
        action = Copy("$TARGET", "$SOURCE"))

Or depending on the situation, use the Install() builder, like this:

prgTarget = env.Program( "program_name", [ "file1.cc", "file2.cc" ] )
Install("../program_name", source = prgTarget)

Problem

I am trying to copy the generated program file to the parent directory after compilation automatically. I tried this, but this doesn't work. ``` env.Program( "program_name", [ "file1.cc", "file2.cc" ] ) Copy( "../program_name", "program_name" ) ``` How can I do this with SCons?

Original source