Reputation: 597
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?
Upvotes: 6
Views: 2562
Reputation: 10357
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)
Upvotes: 8