scons: Generate a single debug flag C++ file
Reduces target count/compiler invocations by ~180.
This commit is contained in:
parent
f780e85dc3
commit
f7c6a2cbed
1 changed files with 31 additions and 30 deletions
|
@ -743,40 +743,42 @@ elif ProtoBuf.all:
|
||||||
def makeDebugFlagCC(target, source, env):
|
def makeDebugFlagCC(target, source, env):
|
||||||
assert(len(target) == 1 and len(source) == 1)
|
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()
|
code = code_formatter()
|
||||||
|
|
||||||
|
# delay definition of CompoundFlags until after all the definition
|
||||||
|
# of all constituent SimpleFlags
|
||||||
|
comp_code = code_formatter()
|
||||||
|
|
||||||
# file header
|
# file header
|
||||||
code('''
|
code('''
|
||||||
/*
|
/*
|
||||||
* DO NOT EDIT THIS FILE! Automatically generated
|
* DO NOT EDIT THIS FILE! Automatically generated by SCons.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base/debug.hh"
|
#include "base/debug.hh"
|
||||||
|
|
||||||
|
namespace Debug {
|
||||||
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
for flag in compound:
|
for name, flag in sorted(source[0].read().iteritems()):
|
||||||
code('#include "debug/$flag.hh"')
|
n, compound, desc = flag
|
||||||
code()
|
assert n == name
|
||||||
code('namespace Debug {')
|
|
||||||
code()
|
|
||||||
|
|
||||||
if not compound:
|
if not compound:
|
||||||
code('SimpleFlag $name("$name", "$desc");')
|
code('SimpleFlag $name("$name", "$desc");')
|
||||||
else:
|
else:
|
||||||
code('CompoundFlag $name("$name", "$desc",')
|
comp_code('CompoundFlag $name("$name", "$desc",')
|
||||||
code.indent()
|
comp_code.indent()
|
||||||
last = len(compound) - 1
|
last = len(compound) - 1
|
||||||
for i,flag in enumerate(compound):
|
for i,flag in enumerate(compound):
|
||||||
if i != last:
|
if i != last:
|
||||||
code('$flag,')
|
comp_code('$flag,')
|
||||||
else:
|
else:
|
||||||
code('$flag);')
|
comp_code('$flag);')
|
||||||
code.dedent()
|
comp_code.dedent()
|
||||||
|
|
||||||
|
code.append(comp_code)
|
||||||
code()
|
code()
|
||||||
code('} // namespace Debug')
|
code('} // namespace Debug')
|
||||||
|
|
||||||
|
@ -793,9 +795,7 @@ def makeDebugFlagHH(target, source, env):
|
||||||
# file header boilerplate
|
# file header boilerplate
|
||||||
code('''\
|
code('''\
|
||||||
/*
|
/*
|
||||||
* DO NOT EDIT THIS FILE!
|
* DO NOT EDIT THIS FILE! Automatically generated by SCons.
|
||||||
*
|
|
||||||
* Automatically generated by SCons
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __DEBUG_${name}_HH__
|
#ifndef __DEBUG_${name}_HH__
|
||||||
|
@ -828,13 +828,14 @@ for name,flag in sorted(debug_flags.iteritems()):
|
||||||
assert n == name
|
assert n == name
|
||||||
|
|
||||||
hh_file = 'debug/%s.hh' % name
|
hh_file = 'debug/%s.hh' % name
|
||||||
cc_file = 'debug/%s.cc' % name
|
|
||||||
env.Command(hh_file, Value(flag),
|
env.Command(hh_file, Value(flag),
|
||||||
MakeAction(makeDebugFlagHH, Transform("TRACING", 0)))
|
MakeAction(makeDebugFlagHH, Transform("TRACING", 0)))
|
||||||
env.Command(cc_file, Value(flag),
|
env.Depends(SWIG, hh_file)
|
||||||
|
|
||||||
|
env.Command('debug/flags.cc', Value(debug_flags),
|
||||||
MakeAction(makeDebugFlagCC, Transform("TRACING", 0)))
|
MakeAction(makeDebugFlagCC, Transform("TRACING", 0)))
|
||||||
env.Depends(SWIG, [hh_file, cc_file])
|
env.Depends(SWIG, 'debug/flags.cc')
|
||||||
Source('debug/%s.cc' % name)
|
Source('debug/flags.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
|
||||||
# PySource() call in a SConscript need to be embedded into the M5
|
# PySource() call in a SConscript need to be embedded into the M5
|
||||||
|
|
Loading…
Reference in a new issue