将 scons 构建器输出重定向到文件
我正在使用 scons 来构建一个项目。效果很好。但是我们的构建命令只是将结果输出到标准输出,我需要让它对我们的软件团队更有用一点。
以下是我想要的行为,按优先顺序排列。有人可以帮助我实施它们吗?
没有真正的改进:
scons > build-summary.txt
——这只是将标准输出重定向到一个文件。是的,如果我记得我的系统 (WinXP) 上的适当语法,我也可以重定向 stderr,但它不能帮助我将详细的构建输出与正在构建的文件的重要摘要分开。摘要+详细构建信息的分离:获取所有构建命令的stdout + stderr以重定向到指定的输出文件(例如build-summary.txt),但将scons本身的输出保留到stdout/stderr。
使用 XML 的结构化构建输出:获取所有构建命令的 stdout + stderr 以重定向到指定的输出文件,并以 XML 格式执行此操作,如下所示。输出已经足够详细了,我不在乎是否有 XML 开销。显然,stdout 和 stderr 的内容需要转义才能包含在 XML 中。
<输出>c:/foo/someFile.obj <输入>c:/foo/someFile.cpp c:/foo/someFile.h <命令>cc someFile.cpp -l someLib.lib ... 备注:您应该使用 lint 警告:变量 foo 已声明但从未引用 <输出>c:/foo/someFile.exe <输入>c:/foo/someFile.obj c:/foo/otherFile.obj <命令>cc -o someFile.exe someFile.obj otherFile.obj <标准输出>成功!万岁!
I'm using scons to build a project. Works pretty well. But our build commands just spew out results to stdout, and I need to make this a little more useful for our software team.
Here are the behaviors I would like, in order of precedence. Could anyone help me implement them?
No real improvement:
scons > build-summary.txt
-- this just redirects stdout to a file. Yeah, I can redirect stderr as well if I remember the appropriate syntax on my system (WinXP), but it doesn't help me separate detailed build output from important summaries of which files are being built.Separation of summary + detailed build info: get stdout + stderr of all build commands to redirect to a designated output file (e.g. build-summary.txt), but leave output from scons itself going to stdout/stderr.
Structured build output using XML: get stdout + stderr of all build commands to redirect to a designated output file, and do so in an XML format, e.g. as below. The output is verbose enough already that I don't care if there's XML overhead. Contents of stdout and stderr would need to be escaped for inclusion in XML, obviously.
<build-step builder="Compiler"> <output>c:/foo/someFile.obj</output> <input>c:/foo/someFile.cpp c:/foo/someFile.h</input> <command>cc someFile.cpp -l someLib.lib ...</command> <stdout>Remark: you should be using lint</stdout> <stderr>Warning: variable foo was declared but never referenced</stderr> </build-step> <build-step builder="Compiler"> <output>c:/foo/someFile.exe</output> <input>c:/foo/someFile.obj c:/foo/otherFile.obj</input> <command>cc -o someFile.exe someFile.obj otherFile.obj</command> <stdout>Success! Hurray!</stdout> <stderr></stderr> </build-step>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须自己做一些工作才能获得正确的格式,但 SCons wiki 上有关于如何控制 scons 运行的命令的命令行输出。
为了将编译器的输出获取到日志文件中,您可以执行类似于 BuildLog 维基页面。您可以将它们全部写入您自己的日志文件,而不是打印命令字符串并重复 stdout 和 stderr。
很抱歉让您自己了解详细信息,但这也许足以让您开始。
You'll have to do some work yourself to get the right formatting, but there's a description on the SCons wiki on how to control command line output for the commands that scons runs.
In order to get the output from your compiler into the log file, you could do something like the Buffered Output snippet in the middle of the BuildLog wiki page. Instead of printing the command string and repeating stdout and stderr, you can write them all to your own log file.
Sorry to leave you on your own with the details, but perhaps that's enough for you to get started.