6

我试图在自动编译后将生成的程序文件复制到父目录。

我试过这个,但这不起作用。

env.Program( "program_name", [ "file1.cc", "file2.cc" ] )
Copy( "../program_name", "program_name" )

我怎样才能用 SCons 做到这一点?

4

1 回答 1

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)
于 2012-06-13T13:02:01.077 回答