From: Gabe Black Date: Thu, 21 Feb 2019 00:08:50 +0000 (-0800) Subject: systemc: Make the verify.py script work when run from different dirs. X-Git-Tag: v19.0.0.0~1114 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84a9094ef7fd8e322c2e532a54a37d8fae332724;p=gem5.git systemc: Make the verify.py script work when run from different dirs. The verify.py script ran scons from the CWD, and that would fail if there wasn't a SConstruct in that directory, ie if it wasn't from the source of the checkout. This change makes verify.py use scons' --directory option to run from where the SConstruct is, or at least the SConstruct which was checked out alongside that copy of verify.py. That location can be overridden using the new -C or --scons-dir options. Change-Id: I9f033d6dd30e0c2992b7f3102c573b34ea9c49e0 Reviewed-on: https://gem5-review.googlesource.com/c/16562 Reviewed-by: Andreas Sandberg Maintainer: Gabe Black --- diff --git a/src/systemc/tests/verify.py b/src/systemc/tests/verify.py index 503c11d8b..2bb6d3357 100755 --- a/src/systemc/tests/verify.py +++ b/src/systemc/tests/verify.py @@ -45,6 +45,10 @@ import sys script_path = os.path.abspath(inspect.getfile(inspect.currentframe())) script_dir = os.path.dirname(script_path) config_path = os.path.join(script_dir, 'config.py') +# Parent directories if checked out as part of gem5. +systemc_dir = os.path.dirname(script_dir) +src_dir = os.path.dirname(systemc_dir) +checkout_dir = os.path.dirname(src_dir) systemc_rel_path = 'systemc' tests_rel_path = os.path.join(systemc_rel_path, 'tests') @@ -131,7 +135,8 @@ class CompilePhase(TestPhaseBase): if args.j == 0: self.args = ('-j', str(self.main_args.j)) + self.args - scons_args = [ 'USE_SYSTEMC=1' ] + list(self.args) + targets + scons_args = [ '--directory', self.main_args.scons_dir, + 'USE_SYSTEMC=1' ] + list(self.args) + targets scons(*scons_args) class RunPhase(TestPhaseBase): @@ -512,6 +517,10 @@ parser.add_argument('-j', type=int, default=1, help='Default level of parallelism, can be overriden ' 'for individual stages') +parser.add_argument('-C', '--scons-dir', metavar='SCONS_DIR', + default=checkout_dir, + help='Directory to run scons from') + filter_opts = parser.add_mutually_exclusive_group() filter_opts.add_argument('--filter', default='True', help='Python expression which filters tests based ' @@ -549,7 +558,7 @@ if len(phases) == 0: json_path = os.path.join(main_args.build_dir, json_rel_path) if main_args.update_json: - scons(os.path.join(json_path)) + scons('--directory', main_args.scons_dir, os.path.join(json_path)) with open(json_path) as f: test_data = json.load(f)