From d4767f440a7a8bfefa0851726b729b8d30a654a5 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Mon, 15 Nov 2010 14:04:04 -0600 Subject: [PATCH] SCons: Cleanup SCons output during compile --- SConstruct | 65 ++++++++++++++++++++++++++++++------------ src/SConscript | 48 ++++++++++++++++++++----------- src/arch/SConscript | 3 +- src/arch/isa_parser.py | 2 +- src/cpu/SConscript | 2 +- 5 files changed, 82 insertions(+), 38 deletions(-) diff --git a/SConstruct b/SConstruct index 518806c83..c3b5b7b35 100644 --- a/SConstruct +++ b/SConstruct @@ -272,6 +272,7 @@ for t in abs_targets: # Make sure build_root exists (might not if this is the first build there) if not isdir(build_root): mkdir(build_root) +main['BUILDROOT'] = build_root Export('main') @@ -306,6 +307,7 @@ def PathListAllExist(key, val, env): global_sticky_vars_file = joinpath(build_root, 'variables.global') global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS) +global_nonsticky_vars = Variables(args=ARGUMENTS) global_sticky_vars.AddVariables( ('CC', 'C compiler', environ.get('CC', main['CC'])), @@ -317,6 +319,12 @@ global_sticky_vars.AddVariables( PathListAllExist, PathListMakeAbsolute), ) +global_nonsticky_vars.AddVariables( + ('VERBOSE', 'Print full tool command lines', False), + ('update_ref', 'Update test reference outputs', False) + ) + + # base help text help_text = ''' Usage: scons [scons options] [build options] [target(s)] @@ -326,8 +334,10 @@ Global sticky options: # Update main environment with values from ARGUMENTS & global_sticky_vars_file global_sticky_vars.Update(main) +global_nonsticky_vars.Update(main) help_text += global_sticky_vars.GenerateHelpText(main) +help_text += global_nonsticky_vars.GenerateHelpText(main) # Save sticky variable settings back to current variables file global_sticky_vars.Save(global_sticky_vars_file, main) @@ -346,6 +356,40 @@ Export('extras_dir_list') # the ext directory should be on the #includes path main.Append(CPPPATH=[Dir('ext')]) +def _STRIP(path, env): + path = str(path) + variant_base = env['BUILDROOT'] + os.path.sep + if path.startswith(variant_base): + path = path[len(variant_base):] + elif path.startswith('build/'): + path = path[6:] + return path + +def _STRIP_SOURCE(target, source, env, for_signature): + return _STRIP(source[0], env) +main['STRIP_SOURCE'] = _STRIP_SOURCE + +def _STRIP_TARGET(target, source, env, for_signature): + return _STRIP(target[0], env) +main['STRIP_TARGET'] = _STRIP_TARGET + +if main['VERBOSE']: + def MakeAction(action, string, *args, **kwargs): + return Action(action, *args, **kwargs) +else: + MakeAction = Action + main['CCCOMSTR'] = ' [ CC] $STRIP_SOURCE' + main['CXXCOMSTR'] = ' [ CXX] $STRIP_SOURCE' + main['ASCOMSTR'] = ' [ AS] $STRIP_SOURCE' + main['SWIGCOMSTR'] = ' [ SWIG] $STRIP_SOURCE' + main['ARCOMSTR'] = ' [ AR] $STRIP_TARGET' + main['LINKCOMSTR'] = ' [ LINK] $STRIP_TARGET' + main['RANLIBCOMSTR'] = ' [ RANLIB] $STRIP_TARGET' + main['M4COMSTR'] = ' [ M4] $STRIP_TARGET' + main['SHCCCOMSTR'] = ' [ SHCC] $STRIP_TARGET' + main['SHCXXCOMSTR'] = ' [ SHCXX] $STRIP_TARGET' +Export('MakeAction') + CXX_version = readCommand([main['CXX'],'--version'], exception=False) CXX_V = readCommand([main['CXX'],'-V'], exception=False) @@ -666,10 +710,6 @@ Export('sticky_vars') export_vars = [] Export('export_vars') -# Non-sticky variables only apply to the current build. -nonsticky_vars = Variables(args=ARGUMENTS) -Export('nonsticky_vars') - # Walk the tree and execute all SConsopts scripts that wil add to the # above variables for bdir in [ base_dir ] + extras_dir_list: @@ -706,10 +746,6 @@ sticky_vars.AddVariables( BoolVariable('RUBY', 'Build with Ruby', False), ) -nonsticky_vars.AddVariables( - BoolVariable('update_ref', 'Update test reference outputs', False) - ) - # These variables get exported to #defines in config/*.hh (see src/SConscript). export_vars += ['FULL_SYSTEM', 'USE_FENV', 'USE_MYSQL', 'NO_FAST_ALLOC', 'FAST_ALLOC_DEBUG', 'FAST_ALLOC_STATS', @@ -787,15 +823,11 @@ def make_switching_dir(dname, switch_headers, env): print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname)) f.close() - # String to print when generating header - def gen_switch_hdr_string(target, source, env): - return "Generating switch header " + str(target[0]) - # Build SCons Action object. 'varlist' specifies env vars that this # action depends on; when env['ALL_ISA_LIST'] changes these actions # should get re-executed. - switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string, - varlist=['ALL_ISA_LIST']) + switch_hdr_action = MakeAction(gen_switch_hdr, + " [GENERATE] $STRIP_TARGET", varlist=['ALL_ISA_LIST']) # Instantiate actions for each header for hdr in switch_headers: @@ -852,12 +884,9 @@ for variant_path in variant_paths: # Apply current variable settings to env sticky_vars.Update(env) - nonsticky_vars.Update(env) help_text += "\nSticky variables for %s:\n" % variant_dir \ - + sticky_vars.GenerateHelpText(env) \ - + "\nNon-sticky variables for %s:\n" % variant_dir \ - + nonsticky_vars.GenerateHelpText(env) + + sticky_vars.GenerateHelpText(env) # Process variable settings. diff --git a/src/SConscript b/src/SConscript index c0718c66b..524841d75 100644 --- a/src/SConscript +++ b/src/SConscript @@ -289,7 +289,8 @@ def makeTheISA(source, target, env): code.write(str(target[0])) -env.Command('config/the_isa.hh', map(Value, all_isa_list), makeTheISA) +env.Command('config/the_isa.hh', map(Value, all_isa_list), + MakeAction(makeTheISA, " [ CFG ISA] $STRIP_TARGET")) ######################################################################## # @@ -431,7 +432,8 @@ del _globals defines_info = [ Value(build_env), Value(env['HG_INFO']) ] # Generate a file with all of the compile options in it -env.Command('python/m5/defines.py', defines_info, makeDefinesPyFile) +env.Command('python/m5/defines.py', defines_info, + MakeAction(makeDefinesPyFile, " [ DEFINES] $STRIP_TARGET")) PySource('m5', 'python/m5/defines.py') # Generate python file containing info about the M5 source code @@ -445,7 +447,7 @@ def makeInfoPyFile(target, source, env): # Generate a file that wraps the basic top level files env.Command('python/m5/info.py', [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ], - makeInfoPyFile) + MakeAction(makeInfoPyFile, " [ INFO] $STRIP_TARGET")) PySource('m5', 'python/m5/info.py') ######################################################################## @@ -520,7 +522,8 @@ for name,simobj in sorted(sim_objects.iteritems()): hh_file = File('params/%s.hh' % name) params_hh_files.append(hh_file) - env.Command(hh_file, Value(name), createSimObjectParam) + env.Command(hh_file, Value(name), + MakeAction(createSimObjectParam, " [SO PARAM] $STRIP_TARGET")) env.Depends(hh_file, depends + extra_deps) # Generate any parameter header files needed @@ -528,7 +531,8 @@ params_i_files = [] for name,param in all_params.iteritems(): i_file = File('python/m5/internal/%s_%s.i' % (param.file_ext, name)) params_i_files.append(i_file) - env.Command(i_file, Value(name), createSwigParam) + env.Command(i_file, Value(name), + MakeAction(createSwigParam, " [SW PARAM] $STRIP_TARGET")) env.Depends(i_file, depends) SwigSource('m5.internal', i_file) @@ -538,16 +542,19 @@ for name,enum in sorted(all_enums.iteritems()): extra_deps = [ py_source.tnode ] cc_file = File('enums/%s.cc' % name) - env.Command(cc_file, Value(name), createEnumStrings) + env.Command(cc_file, Value(name), + MakeAction(createEnumStrings, " [ENUM STR] $STRIP_TARGET")) env.Depends(cc_file, depends + extra_deps) Source(cc_file) hh_file = File('enums/%s.hh' % name) - env.Command(hh_file, Value(name), createEnumParam) + env.Command(hh_file, Value(name), + MakeAction(createEnumParam, " [EN PARAM] $STRIP_TARGET")) env.Depends(hh_file, depends + extra_deps) i_file = File('python/m5/internal/enum_%s.i' % name) - env.Command(i_file, Value(name), createEnumSwig) + env.Command(i_file, Value(name), + MakeAction(createEnumSwig, " [ENUMSWIG] $STRIP_TARGET")) env.Depends(i_file, depends + extra_deps) SwigSource('m5.internal', i_file) @@ -586,7 +593,8 @@ def buildParam(target, source, env): for name in sim_objects.iterkeys(): params_file = File('python/m5/internal/param_%s.i' % name) - env.Command(params_file, Value(name), buildParam) + env.Command(params_file, Value(name), + MakeAction(buildParam, " [BLDPARAM] $STRIP_TARGET")) env.Depends(params_file, depends) SwigSource('m5.internal', params_file) @@ -608,10 +616,11 @@ EmbeddedSwig embed_swig_${module}(init_${module}); # Build all swig modules for swig in SwigSource.all: env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode, - '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' - '-o ${TARGETS[0]} $SOURCES') + MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' + '-o ${TARGETS[0]} $SOURCES', " [ SWIG] $STRIP_TARGET")) init_file = 'python/swig/init_%s.cc' % swig.module - env.Command(init_file, Value(swig.module), makeEmbeddedSwigInit) + env.Command(init_file, Value(swig.module), + MakeAction(makeEmbeddedSwigInit, " [EMBED SW] $STRIP_TARGET")) Source(init_file) env.Depends(swig.py_source.tnode, swig.tnode) env.Depends(swig.cc_source.tnode, swig.tnode) @@ -836,11 +845,14 @@ extern const Flags *compoundFlags[]; code.write(str(target[0])) flags = map(Value, trace_flags.values()) -env.Command('base/traceflags.py', flags, traceFlagsPy) +env.Command('base/traceflags.py', flags, + MakeAction(traceFlagsPy, " [ TRACING] $STRIP_TARGET")) PySource('m5', 'base/traceflags.py') -env.Command('base/traceflags.hh', flags, traceFlagsHH) -env.Command('base/traceflags.cc', flags, traceFlagsCC) +env.Command('base/traceflags.hh', flags, + MakeAction(traceFlagsHH, " [ TRACING] $STRIP_TARGET")) +env.Command('base/traceflags.cc', flags, + MakeAction(traceFlagsCC, " [ TRACING] $STRIP_TARGET")) Source('base/traceflags.cc') # Embed python files. All .py files that have been indicated by a @@ -897,7 +909,8 @@ EmbeddedPython embedded_${sym}( code.write(str(target[0])) for source in PySource.all: - env.Command(source.cpp, source.tnode, embedPyFile) + env.Command(source.cpp, source.tnode, + MakeAction(embedPyFile, " [EMBED PY] $STRIP_TARGET")) Source(source.cpp) ######################################################################## @@ -988,7 +1001,8 @@ def makeEnv(label, objsfx, strip = False, **kwargs): cmd = 'cp $SOURCE $TARGET; strip $TARGET' else: cmd = 'strip $SOURCE -o $TARGET' - targets = new_env.Command(exename, progname, cmd) + targets = new_env.Command(exename, progname, + MakeAction(cmd, " [ STRIP] $STRIP_TARGET")) new_env.M5Binary = targets[0] envList.append(new_env) diff --git a/src/arch/SConscript b/src/arch/SConscript index 9ebc6986b..dd337b1b7 100644 --- a/src/arch/SConscript +++ b/src/arch/SConscript @@ -109,7 +109,7 @@ ARCH_DIR = Dir('.') # import ply here because SCons screws with sys.path when performing actions. import ply -def isa_desc_action(target, source, env): +def isa_desc_action_func(target, source, env): # Add the current directory to the system path so we can import files sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] import isa_parser @@ -118,6 +118,7 @@ def isa_desc_action(target, source, env): cpu_models = [CpuModel.dict[cpu] for cpu in models] parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) parser.parse_isa_desc(source[0].abspath) +isa_desc_action = MakeAction(isa_desc_action_func, " [ISA DESC] $STRIP_SOURCE") # Also include the CheckerCPU as one of the models if it is being # enabled via command line. diff --git a/src/arch/isa_parser.py b/src/arch/isa_parser.py index 8e13b6a6a..4c23529f0 100755 --- a/src/arch/isa_parser.py +++ b/src/arch/isa_parser.py @@ -1945,7 +1945,7 @@ StaticInstPtr else: print 'File', file, 'is unchanged' else: - print 'Generating', file + print ' [GENERATE]', file update = True if update: f = open(file, 'w') diff --git a/src/cpu/SConscript b/src/cpu/SConscript index 6b4c43dc0..35e92a1b6 100644 --- a/src/cpu/SConscript +++ b/src/cpu/SConscript @@ -87,7 +87,7 @@ def gen_cpu_exec_signatures(target, source, env): # Generate string that gets printed when header is rebuilt def gen_sigs_string(target, source, env): - return "Generating static_inst_exec_sigs.hh: " \ + return " [GENERATE] static_inst_exec_sigs.hh: " \ + ', '.join(temp_cpu_list) # Add command to generate header to environment.