Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/49383 )

Change subject: scons: Accumulate debug flags in a construction variable.
......................................................................

scons: Accumulate debug flags in a construction variable.

Do this instead of putting them in a dictionary side channel.

Change-Id: I52319f2d42c87ef8e7861e7dc700ba45b8e1629e
---
M src/SConscript
1 file changed, 16 insertions(+), 15 deletions(-)



diff --git a/src/SConscript b/src/SConscript
index 83feae9..4ec1f16 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -436,30 +436,31 @@

     code.write(str(target[0]))

-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))
+    debug_flags = env.get('DEBUG_FLAGS', [])
+    if any(name == flag[0] for flag in debug_flags):
+        raise AttributeError(f'Flag {name} already specified')

     flag = (name, (), desc, fmt)
-    debug_flags[name] = flag
+    env.Append(DEBUG_FLAGS=[flag])

-    hh_file = Dir(env['BUILDDIR']).Dir('debug').File('%s.hh' % name)
+    hh_file = Dir(env['BUILDDIR']).Dir('debug').File(f'{name}.hh')
     env.Command(hh_file, ToValue(flag),
             MakeAction(makeDebugFlagHH, Transform("TRACING", 0)))

 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))
+    debug_flags = env.get('DEBUG_FLAGS', [])
+    if any(name == flag[0] for flag in debug_flags):
+        raise AttributeError(f'Flag {name} already specified')

     flag = (name, flags, desc, False)
-    debug_flags[name] = flag
+    env.Append(DEBUG_FLAGS=[flag])

-    env.Command(Dir(env['BUILDDIR']).Dir('debug').File('%s.hh' % name),
+    env.Command(Dir(env['BUILDDIR']).Dir('debug').File(f'{name}.hh'),
             ToValue(flag),
             MakeAction(makeDebugFlagHH, Transform("TRACING", 0)))

@@ -891,7 +892,7 @@
 # Handle debug flags
 #
 def makeDebugFlagCC(target, source, env):
-    assert(len(target) == 1 and len(source) == 1)
+    assert(len(target) == 1)

     code = code_formatter()

@@ -913,9 +914,8 @@

 ''')

-    for name, flag in sorted(source[0].read().items()):
-        n, compound, desc, fmt = flag
-        assert n == name
+    for flag in sorted(env.get('DEBUG_FLAGS', [])):
+        name, compound, desc, fmt = flag

# We intentionally make flag a reference to a heap allocated object so
         # (1) It has a similar interface to a global object like before
@@ -952,8 +952,9 @@
     code.write(str(target[0]))

 # Generate the files for the debug and debug-format flags
-env.Command('debug/flags.cc', Value(debug_flags),
-            MakeAction(makeDebugFlagCC, Transform("TRACING", 0)))
+env.Command('debug/flags.cc', [],
+            MakeAction(makeDebugFlagCC, Transform("TRACING", 0),
+                varlist=['DEBUG_FLAGS']))
 Source('debug/flags.cc', add_tags='gem5 trace')

 # version tags

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49383
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I52319f2d42c87ef8e7861e7dc700ba45b8e1629e
Gerrit-Change-Number: 49383
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to