开发者

redirecting scons builder output to a file

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?

  1. 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.

  2. 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.

  3. 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>
    


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜