scons: Update enum output when not using python

This changeset brings the enum_cc.py file in line with how the
sim_object_param_struct_cc.py file works and updates the SConscript to
correctly tag the created source files.

Change-Id: I4635a4f46de7d62a6c38e71ace121c06e139d486
Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/59609
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Jason Lowe-Power
2022-05-11 13:53:58 -07:00
committed by Jason Lowe-Power
parent e8e0a2ed06
commit 8e8c1ded15
2 changed files with 38 additions and 30 deletions

View File

@@ -48,11 +48,20 @@ from code_formatter import code_formatter
parser = argparse.ArgumentParser()
parser.add_argument('modpath', help='module the enum belongs to')
parser.add_argument('enum_cc', help='enum cc file to generate')
parser.add_argument('--use-python', action="store_true",
help='python is enabled in gem5')
parser.add_argument('use_python',
help='whether python is enabled in gem5 (True or False)')
args = parser.parse_args()
use_python = args.use_python.lower()
if use_python == 'true':
use_python = True
elif use_python == 'false':
use_python = False
else:
print(f'Unrecognized "use_python" value {use_python}', file=sys.stderr)
sys.exit(1)
basename = os.path.basename(args.enum_cc)
enum_name = os.path.splitext(basename)[0]
@@ -103,10 +112,7 @@ if not enum.wrapper_is_struct and not enum.is_class:
code('} // namespace gem5')
if not args.use_python:
code.write(args.enum_cc)
exit(0)
if use_python:
name = enum.__name__
enum_name = enum.__name__ if enum.enum_name is None else enum.enum_name

View File

@@ -186,7 +186,8 @@ class SimObject(PySource):
SIMOBJ=simobj,
PARAMS_CC=cc_file,
USE_PYTHON=env['USE_PYTHON'])
Source(cc_file, tags=self.tags, add_tags='python')
Source(cc_file, tags=self.tags,
add_tags=('python' if env['USE_PYTHON'] else None))
# CXX config header.
gem5py_env.Command([ "${CXXCONFIG_HH}" ], srcs,
@@ -230,8 +231,9 @@ class SimObject(PySource):
ENUM=enum,
ENUM_CC=cc_file,
ENUMCC_PY=build_tools.File('enum_cc.py'),
USE_PYTHON='--use-python' if env['USE_PYTHON'] else '')
Source(cc_file, tags=self.tags, add_tags='python')
USE_PYTHON=env['USE_PYTHON'])
Source(cc_file, tags=self.tags,
add_tags=('python' if env['USE_PYTHON'] else None))
# This regular expression is simplistic and assumes that the import takes up
# the entire line, doesn't have the keyword "public", uses double quotes, has