SCons: Cleanup SCons output during compile

This commit is contained in:
Ali Saidi 2010-11-15 14:04:04 -06:00
parent c370866331
commit d4767f440a
5 changed files with 82 additions and 38 deletions

View file

@ -272,6 +272,7 @@ for t in abs_targets:
# Make sure build_root exists (might not if this is the first build there) # Make sure build_root exists (might not if this is the first build there)
if not isdir(build_root): if not isdir(build_root):
mkdir(build_root) mkdir(build_root)
main['BUILDROOT'] = build_root
Export('main') Export('main')
@ -306,6 +307,7 @@ def PathListAllExist(key, val, env):
global_sticky_vars_file = joinpath(build_root, 'variables.global') global_sticky_vars_file = joinpath(build_root, 'variables.global')
global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS) global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS)
global_nonsticky_vars = Variables(args=ARGUMENTS)
global_sticky_vars.AddVariables( global_sticky_vars.AddVariables(
('CC', 'C compiler', environ.get('CC', main['CC'])), ('CC', 'C compiler', environ.get('CC', main['CC'])),
@ -317,6 +319,12 @@ global_sticky_vars.AddVariables(
PathListAllExist, PathListMakeAbsolute), PathListAllExist, PathListMakeAbsolute),
) )
global_nonsticky_vars.AddVariables(
('VERBOSE', 'Print full tool command lines', False),
('update_ref', 'Update test reference outputs', False)
)
# base help text # base help text
help_text = ''' help_text = '''
Usage: scons [scons options] [build options] [target(s)] 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 # Update main environment with values from ARGUMENTS & global_sticky_vars_file
global_sticky_vars.Update(main) global_sticky_vars.Update(main)
global_nonsticky_vars.Update(main)
help_text += global_sticky_vars.GenerateHelpText(main) help_text += global_sticky_vars.GenerateHelpText(main)
help_text += global_nonsticky_vars.GenerateHelpText(main)
# Save sticky variable settings back to current variables file # Save sticky variable settings back to current variables file
global_sticky_vars.Save(global_sticky_vars_file, main) 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 # the ext directory should be on the #includes path
main.Append(CPPPATH=[Dir('ext')]) 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_version = readCommand([main['CXX'],'--version'], exception=False)
CXX_V = readCommand([main['CXX'],'-V'], exception=False) CXX_V = readCommand([main['CXX'],'-V'], exception=False)
@ -666,10 +710,6 @@ Export('sticky_vars')
export_vars = [] export_vars = []
Export('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 # Walk the tree and execute all SConsopts scripts that wil add to the
# above variables # above variables
for bdir in [ base_dir ] + extras_dir_list: for bdir in [ base_dir ] + extras_dir_list:
@ -706,10 +746,6 @@ sticky_vars.AddVariables(
BoolVariable('RUBY', 'Build with Ruby', False), 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). # These variables get exported to #defines in config/*.hh (see src/SConscript).
export_vars += ['FULL_SYSTEM', 'USE_FENV', 'USE_MYSQL', export_vars += ['FULL_SYSTEM', 'USE_FENV', 'USE_MYSQL',
'NO_FAST_ALLOC', 'FAST_ALLOC_DEBUG', 'FAST_ALLOC_STATS', '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)) print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname))
f.close() 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 # Build SCons Action object. 'varlist' specifies env vars that this
# action depends on; when env['ALL_ISA_LIST'] changes these actions # action depends on; when env['ALL_ISA_LIST'] changes these actions
# should get re-executed. # should get re-executed.
switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string, switch_hdr_action = MakeAction(gen_switch_hdr,
varlist=['ALL_ISA_LIST']) " [GENERATE] $STRIP_TARGET", varlist=['ALL_ISA_LIST'])
# Instantiate actions for each header # Instantiate actions for each header
for hdr in switch_headers: for hdr in switch_headers:
@ -852,12 +884,9 @@ for variant_path in variant_paths:
# Apply current variable settings to env # Apply current variable settings to env
sticky_vars.Update(env) sticky_vars.Update(env)
nonsticky_vars.Update(env)
help_text += "\nSticky variables for %s:\n" % variant_dir \ help_text += "\nSticky variables for %s:\n" % variant_dir \
+ sticky_vars.GenerateHelpText(env) \ + sticky_vars.GenerateHelpText(env)
+ "\nNon-sticky variables for %s:\n" % variant_dir \
+ nonsticky_vars.GenerateHelpText(env)
# Process variable settings. # Process variable settings.

View file

@ -289,7 +289,8 @@ def makeTheISA(source, target, env):
code.write(str(target[0])) 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']) ] defines_info = [ Value(build_env), Value(env['HG_INFO']) ]
# Generate a file with all of the compile options in it # 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') PySource('m5', 'python/m5/defines.py')
# Generate python file containing info about the M5 source code # 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 # Generate a file that wraps the basic top level files
env.Command('python/m5/info.py', env.Command('python/m5/info.py',
[ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ], [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
makeInfoPyFile) MakeAction(makeInfoPyFile, " [ INFO] $STRIP_TARGET"))
PySource('m5', 'python/m5/info.py') 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) hh_file = File('params/%s.hh' % name)
params_hh_files.append(hh_file) 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) env.Depends(hh_file, depends + extra_deps)
# Generate any parameter header files needed # Generate any parameter header files needed
@ -528,7 +531,8 @@ params_i_files = []
for name,param in all_params.iteritems(): for name,param in all_params.iteritems():
i_file = File('python/m5/internal/%s_%s.i' % (param.file_ext, name)) i_file = File('python/m5/internal/%s_%s.i' % (param.file_ext, name))
params_i_files.append(i_file) 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) env.Depends(i_file, depends)
SwigSource('m5.internal', i_file) SwigSource('m5.internal', i_file)
@ -538,16 +542,19 @@ for name,enum in sorted(all_enums.iteritems()):
extra_deps = [ py_source.tnode ] extra_deps = [ py_source.tnode ]
cc_file = File('enums/%s.cc' % name) 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) env.Depends(cc_file, depends + extra_deps)
Source(cc_file) Source(cc_file)
hh_file = File('enums/%s.hh' % name) 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) env.Depends(hh_file, depends + extra_deps)
i_file = File('python/m5/internal/enum_%s.i' % name) 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) env.Depends(i_file, depends + extra_deps)
SwigSource('m5.internal', i_file) SwigSource('m5.internal', i_file)
@ -586,7 +593,8 @@ def buildParam(target, source, env):
for name in sim_objects.iterkeys(): for name in sim_objects.iterkeys():
params_file = File('python/m5/internal/param_%s.i' % name) 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) env.Depends(params_file, depends)
SwigSource('m5.internal', params_file) SwigSource('m5.internal', params_file)
@ -608,10 +616,11 @@ EmbeddedSwig embed_swig_${module}(init_${module});
# Build all swig modules # Build all swig modules
for swig in SwigSource.all: for swig in SwigSource.all:
env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode, env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode,
'$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
'-o ${TARGETS[0]} $SOURCES') '-o ${TARGETS[0]} $SOURCES', " [ SWIG] $STRIP_TARGET"))
init_file = 'python/swig/init_%s.cc' % swig.module 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) Source(init_file)
env.Depends(swig.py_source.tnode, swig.tnode) env.Depends(swig.py_source.tnode, swig.tnode)
env.Depends(swig.cc_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])) code.write(str(target[0]))
flags = map(Value, trace_flags.values()) 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') PySource('m5', 'base/traceflags.py')
env.Command('base/traceflags.hh', flags, traceFlagsHH) env.Command('base/traceflags.hh', flags,
env.Command('base/traceflags.cc', flags, traceFlagsCC) MakeAction(traceFlagsHH, " [ TRACING] $STRIP_TARGET"))
env.Command('base/traceflags.cc', flags,
MakeAction(traceFlagsCC, " [ TRACING] $STRIP_TARGET"))
Source('base/traceflags.cc') Source('base/traceflags.cc')
# Embed python files. All .py files that have been indicated by a # Embed python files. All .py files that have been indicated by a
@ -897,7 +909,8 @@ EmbeddedPython embedded_${sym}(
code.write(str(target[0])) code.write(str(target[0]))
for source in PySource.all: 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) Source(source.cpp)
######################################################################## ########################################################################
@ -988,7 +1001,8 @@ def makeEnv(label, objsfx, strip = False, **kwargs):
cmd = 'cp $SOURCE $TARGET; strip $TARGET' cmd = 'cp $SOURCE $TARGET; strip $TARGET'
else: else:
cmd = 'strip $SOURCE -o $TARGET' 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] new_env.M5Binary = targets[0]
envList.append(new_env) envList.append(new_env)

View file

@ -109,7 +109,7 @@ ARCH_DIR = Dir('.')
# import ply here because SCons screws with sys.path when performing actions. # import ply here because SCons screws with sys.path when performing actions.
import ply 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 # Add the current directory to the system path so we can import files
sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ]
import isa_parser import isa_parser
@ -118,6 +118,7 @@ def isa_desc_action(target, source, env):
cpu_models = [CpuModel.dict[cpu] for cpu in models] cpu_models = [CpuModel.dict[cpu] for cpu in models]
parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models)
parser.parse_isa_desc(source[0].abspath) 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 # Also include the CheckerCPU as one of the models if it is being
# enabled via command line. # enabled via command line.

View file

@ -1945,7 +1945,7 @@ StaticInstPtr
else: else:
print 'File', file, 'is unchanged' print 'File', file, 'is unchanged'
else: else:
print 'Generating', file print ' [GENERATE]', file
update = True update = True
if update: if update:
f = open(file, 'w') f = open(file, 'w')

View file

@ -87,7 +87,7 @@ def gen_cpu_exec_signatures(target, source, env):
# Generate string that gets printed when header is rebuilt # Generate string that gets printed when header is rebuilt
def gen_sigs_string(target, source, env): 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) + ', '.join(temp_cpu_list)
# Add command to generate header to environment. # Add command to generate header to environment.