Revision 1 as of 2006-07-28 21:25:05
converted to 1.6 markup
|No differences found!|
Hiding Command Lines in SCons Output
Q: I want scons to only show a summary of the build commands rather than the full things with all the millions of options I pass.
A: No problem. First, make sure you have 0.96.92 or later. Then there are two ways to do it.
Use CCCOMSTR etc.
Define env['CCCOMSTR'] to whatever you want (like "Compiling $SOURCE ..."); that just overrides the C compiler message. All standard commands have a ...STR variable that is used instead of the actual command line if it's defined.
The other takes a little more work but is more flexible; define a PRINT_CMD_LINE_FUNC that takes over the printing of the command lines. You can do basically any transformation of the command line output this way.
def print_cmd_line(s, target, src, env): """s is the original command line, target and src are lists of target and source nodes respectively, and env is the environment.""" sys.stdout.write(" Making %s...\n"%\ (' and '.join([str(x) for x in target]))) env=Environment() env['PRINT_CMD_LINE_FUNC'] = print_cmd_line
I like to use this to print a short version to stdout, while logging the full command to a log file. That looks like this:
def print_cmd_line(s, target, src, env): if config.quiet: sys.stdout.write(" %s...\n"%(' and '.join([str(x) for x in target]))) # Save real cmd to log file open(env['CMD_LOGFILE'], 'a').write("%s\n"%s); else: sys.stdout.write("%s\n"%s); env['PRINT_CMD_LINE_FUNC'] = print_cmd_line env['CMD_LOGFILE'] = 'build-log.txt'
You can set config.quiet to 1 however you like; parse from cmdline option, use env['CMDLINE_QUIET'] instead, whatever. Notice it's not a full build-logging solution because the output from the commands doesn't go into the build-log file. But it's still better than clogging up your shell.