From 6e0f211046fed6d55eba17cc1cdf0c9ad4c29fb2 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 22 Oct 2020 20:00:50 -0700 Subject: [PATCH] util: Add a --verbose flag to the m5 util's scons. Like gem5's own verbose scons flag, when this isn't provided, the output is very brief and just shows what is being built and by what type of process. When it is provided, the full command lines are printed. This is less fancy than the version gem5 has, but I didn't want to duplicate all that code. We should find a way to share that and other functionality between different sets of scons scripts. Change-Id: Id9973b57a1270ec8b364efd2aa67d49b0fb82a9d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27756 Reviewed-by: Gabe Black Maintainer: Gabe Black Tested-by: kokoro --- util/m5/README.md | 1 + util/m5/SConstruct | 37 ++++++++++++++++++++++++++++++++++++- util/m5/src/SConscript | 7 +++++-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/util/m5/README.md b/util/m5/README.md index cfa2fbd8f..5314f9be4 100644 --- a/util/m5/README.md +++ b/util/m5/README.md @@ -176,6 +176,7 @@ some other prefix corresponding to that host. --debug-build: Compile with the -g option, and -O0. --no-test-xml: Exclude the test result XML files from the build. +--verbose: Show build command lines and full command output. ## External dependency detection diff --git a/util/m5/SConstruct b/util/m5/SConstruct index 64bb543e4..79fb1fa2f 100644 --- a/util/m5/SConstruct +++ b/util/m5/SConstruct @@ -46,6 +46,7 @@ AddOption('--debug-build', dest='debug_build', action='store_true', help='Build with debug info, and disable optimizations.') AddOption('--no-test-xml', dest='no_tests', action='store_true', help='Omit test output xml files from the build.') +AddOption('--verbose', dest='verbose', action='store_true') # Universal settings. if GetOption('debug_build'): @@ -56,6 +57,36 @@ else: main.Append(CCFLAGS=[ '-O2' ]) main.Append(CPPPATH=[ common_include ]) +if not GetOption('verbose'): + # A functor which returns a shorter summary string to replace the normal + # scons output when running a command. + class ComStr(object): + def __init__(self, cmd): + self.cmd = cmd + + def __call__(self, target, source, env, for_signature=None): + tgts = list([str(t).strip() for t in target]) + return self.cmd + ' ' + ', '.join(tgts) + main['CXXCOMSTR'] = ComStr('CXX') + main['SHCXXCOMSTR'] = ComStr('SHCXX') + main['CCCOMSTR'] = ComStr('CC') + main['SHCCCOMSTR'] = ComStr('SHCC') + main['LINKCOMSTR'] = ComStr('LINK') + main['SHLINKCOMSTR'] = ComStr('SHLINK') + main['ASCOMSTR'] = ComStr('AS') + main['ASPPCOMSTR'] = ComStr('ASPP') + main['ARCOMSTR'] = ComStr('AR') + main['RANLIBCOMSTR'] = ComStr('RANLIB') + + def MakeAction(action, string, *args, **kwargs): + def func(target, source, env, executor): + tgts = list([str(t).strip() for t in target]) + return string + ' ' + ', '.join(tgts) + return Action(action, func, *args, **kwargs) +else: + def MakeAction(action, string, *args, **kwargs): + return Action(action, *args, **kwargs) + # Propogate the environment's PATH setting. main['ENV']['PATH'] = os.environ['PATH'] # Pass through terminal information to, for instance, enable color output. @@ -93,10 +124,14 @@ def GTest(env, name, *srcs, **kwargs): xml = Dir('test').Dir('result').File('%s.xml' % name) # The basic command line for the test. cmd = '${SOURCES[0]} --gtest_output=xml:${TARGETS[0]}' + cmd_str = 'TEST' if need_qemu_to_run: # A prefix that runs it in QEMU if necessary. cmd = '${QEMU} -L ${QEMU_SYSROOT} -- ' + cmd - AlwaysBuild(env.Command(xml, test_bin, cmd)) + cmd_str = 'QEMU_TEST' + AlwaysBuild(env.Command(xml, test_bin, MakeAction(cmd, cmd_str))) + +Export('MakeAction') main.AddMethod(GTest) diff --git a/util/m5/src/SConscript b/util/m5/src/SConscript index c5e51911b..0f4749438 100644 --- a/util/m5/src/SConscript +++ b/util/m5/src/SConscript @@ -103,8 +103,11 @@ if env['HAVE_JAVA']: # around this, we set up our own builder which does the "right thing" here. java_env.Command([ 'jni_gem5Op.h', 'out/gem5OpJni.jar' ], 'jni/gem5Op.java', - [ '${JAVAC} ${JAVACFLAGS} -d ${OUT} ${SOURCES} -h ${CWD}', - '${JAR} cvf ${TARGETS[1]} ${JNI_DIR}/*.class' ], + MakeAction([ + '${JAVAC} ${JAVACFLAGS} -d ${OUT} ' + '${SOURCES} -h ${CWD}', + '${JAR} cvf ${TARGETS[1]} ${JNI_DIR}/*.class' ], + 'JAVA'), JNI_DIR=Dir('out').Dir('jni'), OUT=Dir('out'), CWD=Dir('.')) # Set include paths to the C headers from the JDK which scons found for us. -- 2.30.2