From 25bfa81ea8f8590f49fe799f2dbd88c47f1225c0 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 16 Aug 2021 09:28:20 -0700 Subject: [PATCH] scons: When importing SimObjects, use a copy of globals(). Use a copy of globals when importing SimObjects, instead of the real deal that the SConscript runs under. This avoids polluting the SConscript namespace. Change-Id: I689d693d93cc8998be0967ec2b0c58f5851d39cf Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49407 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/SConscript | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SConscript b/src/SConscript index 9cbfbdfb60..c514fc752d 100644 --- a/src/SConscript +++ b/src/SConscript @@ -594,12 +594,13 @@ m5.params.clear() importer = M5MetaPathFinder(PySource.modules) sys.meta_path[0:0] = [ importer ] +import_globals = globals().copy() # import all sim objects so we can populate the all_objects list # make sure that we're working with a list, then let's sort it gem5_lib_simobjects = SimObject.all.with_tag(env, 'gem5 lib') gem5_lib_modnames = sorted(map(lambda so: so.modname, gem5_lib_simobjects)) for modname in gem5_lib_modnames: - exec('from m5.objects import %s' % modname) + exec('from m5.objects import %s' % modname, import_globals) # we need to unload all of the currently imported modules so that they # will be re-imported the next time the sconscript is run