scons - 编译后运行程序
scons - running program after compilation
我想在编译后直接运行构建的程序,这样我就可以用scons
构建和启动我的程序。
我认为这个SConstruct-File会在重建程序时启动程序。
main = Program( "main", [ "main.cc" ] )
test = Command( None, None, "./main >testoutput" )
Depends( test, main )
每次我运行时,这都会启动它scons
main = Program( "main", [ "main.cc" ] )
test = Command( None, None, "./main >testoutput" )
Requires( test, main )
但是两者都不起作用,我的程序从未执行过。我做错了什么?
这应该更好地工作,以便仅在构建程序时运行程序。
main = Program( "main", [ "main.cc" ] )
test = Command( target = "testoutput",
source = "./main",
action = "./main > $TARGET" )
Depends( test, main )
并且每次都使用 AlwaysBuild() 运行它,如@doublep所述:
main = Program( "main", [ "main.cc" ] )
test = Command( target = "testoutput",
source = "./main",
action = "./main > $TARGET" )
AlwaysBuild( test )
如果你想看到测试输出的内容,你可以这样做:
(假设Linux。用一些 Python 代码打印文件会更便携)
main = Program( "main", [ "main.cc" ] )
test = Command( target = "testoutput",
source = "./main",
action = ["./main > $TARGET",
"cat $TARGET"] )
AlwaysBuild( test )
每次
运行 SCons 时都会运行ls
:
ls = Command ('ls', None, 'ls')
AlwaysBuild ('ls')
Default ('ls')
你从来没有告诉SCons为什么以及何时应该运行你的命令。 例如,您应该将其作为依赖项添加到其他目标或使其成为默认目标。
如果你想真正始终运行命令,即无论正在构建什么目标,你可能应该使用标准的Python工具来运行它来启动外部程序。
相关文章:
- 运行程序时出现问题
- 分段错误当我试图运行程序时出错
- C++ 每次运行程序时我都会"nan"输出的问题
- 通过 g++ 运行程序时没有这样的文件或目录
- 重新运行程序和字符串流?
- 无法在 VS Code 上使用代码运行程序运行C++文件
- 使用有限的 RAM 运行 c++ 程序
- 继续运行程序而无需任何干预,直到要求退出为止
- 如何在每次运行程序时写入文件的下一行?
- 控制台在运行C ++程序后立即关闭(无需调试)
- 运行程序时找不到共享对象库,但在编译过程中链接了它
- 远程运行程序
- 在 Heroku 上运行 C++ 程序
- 如何在Powershell中运行C++程序,就像CMD一样?
- 为什么与Java和Python相比,使用Cmake运行C++程序每次都需要这么长时间?
- C++随机数生成器通常在 Visual Studio 中运行程序时在 2 次后停止生成数字
- 崇高文本 3 - 在终端中编译并运行 C++ 程序(路径包含空格)
- 我收到阻止我运行程序的警告,但不确定如何解决
- C++ Visual Studio 无法完全运行程序
- 在SIGABRT c ++信号之后继续运行程序