我正在尝试在自动编译后将生成的程序文件复制到父目录。
我尝试了这个,但这不起作用。
env.Program( "program_name", [ "file1.cc", "file2.cc" ] )
Copy( "../program_name", "program_name" )
如何使用SCons执行此操作?
答案 0 :(得分:8)
更好的方法是使用目标和Command()构建器,如下所示:
prgTarget = env.Program( "program_name", [ "file1.cc", "file2.cc" ] )
Command(target = "../program_name",
source = prgTarget,
action = Copy("$TARGET", "$SOURCE"))
或者根据具体情况,使用Install() builder,如下所示:
prgTarget = env.Program( "program_name", [ "file1.cc", "file2.cc" ] )
Install("../program_name", source = prgTarget)