summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCurtis Dunham <Curtis.Dunham@arm.com>2014-08-12 17:35:28 -0500
committerCurtis Dunham <Curtis.Dunham@arm.com>2014-08-12 17:35:28 -0500
commitf7c6a2cbed3fa0653e3badfcdbc48f7c3792ba53 (patch)
treefc3689dfe0e55fc1bcd6967d12767df145c9a6c6 /src
parentf780e85dc396f68c73a1dcc376868b59a3fc2f15 (diff)
downloadgem5-f7c6a2cbed3fa0653e3badfcdbc48f7c3792ba53.tar.xz
scons: Generate a single debug flag C++ file
Reduces target count/compiler invocations by ~180.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/SConscript63
1 files changed, 32 insertions, 31 deletions
diff --git a/src/SConscript b/src/SConscript
index 5bd1fc811..3737ef51b 100755
--- a/src/SConscript
+++ b/src/SConscript
@@ -743,40 +743,42 @@ elif ProtoBuf.all:
def makeDebugFlagCC(target, source, env):
assert(len(target) == 1 and len(source) == 1)
- val = eval(source[0].get_contents())
- name, compound, desc = val
- compound = list(sorted(compound))
-
code = code_formatter()
+ # delay definition of CompoundFlags until after all the definition
+ # of all constituent SimpleFlags
+ comp_code = code_formatter()
+
# file header
code('''
/*
- * DO NOT EDIT THIS FILE! Automatically generated
+ * DO NOT EDIT THIS FILE! Automatically generated by SCons.
*/
#include "base/debug.hh"
-''')
- for flag in compound:
- code('#include "debug/$flag.hh"')
- code()
- code('namespace Debug {')
- code()
+namespace Debug {
- if not compound:
- code('SimpleFlag $name("$name", "$desc");')
- else:
- code('CompoundFlag $name("$name", "$desc",')
- code.indent()
- last = len(compound) - 1
- for i,flag in enumerate(compound):
- if i != last:
- code('$flag,')
- else:
- code('$flag);')
- code.dedent()
+''')
+
+ for name, flag in sorted(source[0].read().iteritems()):
+ n, compound, desc = flag
+ assert n == name
+ if not compound:
+ code('SimpleFlag $name("$name", "$desc");')
+ else:
+ comp_code('CompoundFlag $name("$name", "$desc",')
+ comp_code.indent()
+ last = len(compound) - 1
+ for i,flag in enumerate(compound):
+ if i != last:
+ comp_code('$flag,')
+ else:
+ comp_code('$flag);')
+ comp_code.dedent()
+
+ code.append(comp_code)
code()
code('} // namespace Debug')
@@ -793,9 +795,7 @@ def makeDebugFlagHH(target, source, env):
# file header boilerplate
code('''\
/*
- * DO NOT EDIT THIS FILE!
- *
- * Automatically generated by SCons
+ * DO NOT EDIT THIS FILE! Automatically generated by SCons.
*/
#ifndef __DEBUG_${name}_HH__
@@ -828,13 +828,14 @@ for name,flag in sorted(debug_flags.iteritems()):
assert n == name
hh_file = 'debug/%s.hh' % name
- cc_file = 'debug/%s.cc' % name
env.Command(hh_file, Value(flag),
MakeAction(makeDebugFlagHH, Transform("TRACING", 0)))
- env.Command(cc_file, Value(flag),
- MakeAction(makeDebugFlagCC, Transform("TRACING", 0)))
- env.Depends(SWIG, [hh_file, cc_file])
- Source('debug/%s.cc' % name)
+ env.Depends(SWIG, hh_file)
+
+env.Command('debug/flags.cc', Value(debug_flags),
+ MakeAction(makeDebugFlagCC, Transform("TRACING", 0)))
+env.Depends(SWIG, 'debug/flags.cc')
+Source('debug/flags.cc')
# Embed python files. All .py files that have been indicated by a
# PySource() call in a SConscript need to be embedded into the M5