scons,debug: Implement the "All" flag in C++ and not scons.
Create an AllFlagsFlag class which inherits from the CompoundFlag class. This class is a singleton, and the SimpleFlags install themselves in it instead of having SCons collect them. The allFlagsVersion global variable was supposed to be for debugging according to a comment, but was actually an important part of the "All" flags inner workings. It was not exposed in the header, but was redefined/pulled through in src/python/pybind11/debug.cc. The AllFlagsFlag class now tracks that value, and it can be accessed without reaching behind the curtain. This also somewhat decentralizes the debug flag building process in SCons. The debug/flags.cc still includes all flags at once which centralizes them, but at least now the "All" flag won't also. Change-Id: I8430e0fe9022846aade028fb46c80777169a2007 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48370 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Nathanael Premillieu <nathanael.premillieu@huawei.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
@@ -594,13 +594,17 @@ Export('GTest')
|
||||
#
|
||||
debug_flags = {}
|
||||
def DebugFlag(name, desc=None, fmt=False):
|
||||
if name == "All":
|
||||
raise AttributeError('The "All" flag name is reserved')
|
||||
if name in debug_flags:
|
||||
raise AttributeError("Flag {} already specified".format(name))
|
||||
raise AttributeError('Flag {} already specified'.format(name))
|
||||
debug_flags[name] = (name, (), desc, fmt)
|
||||
|
||||
def CompoundFlag(name, flags, desc=None):
|
||||
if name == "All":
|
||||
raise AttributeError('The "All" flag name is reserved')
|
||||
if name in debug_flags:
|
||||
raise AttributeError("Flag {} already specified".format(name))
|
||||
raise AttributeError('Flag {} already specified'.format(name))
|
||||
|
||||
compound = tuple(flags)
|
||||
debug_flags[name] = (name, compound, desc, False)
|
||||
@@ -608,19 +612,6 @@ def CompoundFlag(name, flags, desc=None):
|
||||
def DebugFormatFlag(name, desc=None):
|
||||
DebugFlag(name, desc, True)
|
||||
|
||||
# Create a compound debug flag that encapsulates all flags: "All". This
|
||||
# flag should not be used within C++ code - it is a compound meta flag
|
||||
def _createAllDebugFlag():
|
||||
simple_flags = []
|
||||
for name,flag in sorted(debug_flags.items()):
|
||||
n, compound, desc, fmt = flag
|
||||
assert n == name
|
||||
if not compound and not fmt:
|
||||
simple_flags.append(n)
|
||||
|
||||
CompoundFlag("All", simple_flags,
|
||||
"Controls all debug flags. It should not be used within C++ code.")
|
||||
|
||||
Export('DebugFlag')
|
||||
Export('CompoundFlag')
|
||||
Export('DebugFormatFlag')
|
||||
@@ -1156,7 +1147,6 @@ namespace debug
|
||||
code.write(str(target[0]))
|
||||
|
||||
# Generate the files for the debug and debug-format flags
|
||||
_createAllDebugFlag()
|
||||
for name,flag in sorted(debug_flags.items()):
|
||||
n, compound, desc, fmt = flag
|
||||
assert n == name
|
||||
|
||||
Reference in New Issue
Block a user