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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With