[Scons-users] How to capture the compiler output
Mats Wichmann
mats at wichmann.us
Mon Jul 29 11:15:02 EDT 2024
On 7/29/24 08:19, 于 wrote:
> Hi Guys,
>
> I want to capture the compiler output, to get the warning and error
> counter.
> I think I can redefinite the sys.write.stdout. So I did. And I can
> capture the scons command line, but I can't get compiler
> output(warning&error).
> Then I find that compiler warning and error are print via
> sys.write.stderr, so I modify compiler argument, print all of compiler
> output via sys.write.stdout. But I can't get warning and error also.
> I know scons call compiler via subprocess, subprocess can get compiler
> output. But scons don't save compiler output.
> How can I capture compiler warning and error output via scons.
Your best bet today is to capture this *outside* of SCons. On a Linux
system, for example, you can use the "script" command to capture a
session, or you can redirect the SCons command itself, like:
script -c "scons target" BUILD.LOG
scons target 2>&1 | tee BUILD.LOG
Neither has a *direct* equivalent on Windows though you can still
capture the two output streams.
There have been several requests for this over the years - you can hunt
in the issue tracker on GitHub and see a few of them - but the fact is,
SCons itself doesn't listen (1), so it doesn't *know* what the output
from external build commands are.
(1) there are a few exception... while running Configure() checks, SCons
uses a special setup to capture everything from those builds which it
uses in a special way, but in normal running, no.
More information about the Scons-users
mailing list