Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/40970 )
Change subject: scons: Create a small helper function for disecting a build
target path.
......................................................................
scons: Create a small helper function for disecting a build target path.
This function does about half of the work of the loop which determines
the build root and the list of variants.
Change-Id: I4f44d1e2643244a4be889c677b25b83d41a39b19
---
M SConstruct
M site_scons/gem5_scons/__init__.py
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/SConstruct b/SConstruct
index c1801f6..6f7c353 100755
--- a/SConstruct
+++ b/SConstruct
@@ -119,7 +119,7 @@
AddOption('--with-systemc-tests', action='store_true',
help='Build systemc tests')
-from gem5_scons import Transform, error, warning, summarize_warnings
+from gem5_scons import error, warning, summarize_warnings, parse_build_path
from gem5_scons import EnvDefaults, MakeAction, MakeActionTool
import gem5_scons
from gem5_scons.builders import ConfigFile, AddLocalRPATH, SwitchingHeaders
@@ -177,21 +177,9 @@
variant_paths = set()
build_root = None
for t in BUILD_TARGETS:
- path_dirs = t.split('/')
-
- # Pop off the target file.
- path_dirs.pop()
-
- # Search backwards for the "build" directory. Whatever was just before
it
- # was the name of the variant.
- variant_dir = path_dirs.pop()
- while path_dirs and path_dirs[-1] != 'build':
- variant_dir = path_dirs.pop()
- if not path_dirs:
- error("No non-leaf 'build' dir found on target path.", t)
+ this_build_root, variant = parse_build_path(t)
# Make sure all targets use the same build root.
- this_build_root = os.path.join('/', *path_dirs)
if not build_root:
build_root = this_build_root
elif this_build_root != build_root:
@@ -199,7 +187,7 @@
(build_root, this_build_root))
# Collect all the variants into a set.
- variant_paths.add(os.path.join('/', *path_dirs, variant_dir))
+ variant_paths.add(os.path.join('/', build_root, variant))
# Make sure build_root exists (might not if this is the first build there)
if not isdir(build_root):
diff --git a/site_scons/gem5_scons/__init__.py
b/site_scons/gem5_scons/__init__.py
index c16ab76..6afe585 100644
--- a/site_scons/gem5_scons/__init__.py
+++ b/site_scons/gem5_scons/__init__.py
@@ -224,5 +224,21 @@
env['SHCCCOMSTR'] = Transform("SHCC")
env['SHCXXCOMSTR'] = Transform("SHCXX")
+def parse_build_path(target):
+ path_dirs = target.split('/')
+
+ # Pop off the target file.
+ path_dirs.pop()
+
+ # Search backwards for the "build" directory. Whatever was just before
it
+ # was the name of the variant.
+ variant_dir = path_dirs.pop()
+ while path_dirs and path_dirs[-1] != 'build':
+ variant_dir = path_dirs.pop()
+ if not path_dirs:
+ error("No non-leaf 'build' dir found on target path.", t)
+
+ return os.path.join('/', *path_dirs), variant_dir
+
__all__ = ['Configure', 'EnvDefaults', 'Transform', 'warning', 'error',
- 'MakeAction', 'MakeActionTool']
+ 'MakeAction', 'MakeActionTool', 'parse_build_dir']
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40970
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: I4f44d1e2643244a4be889c677b25b83d41a39b19
Gerrit-Change-Number: 40970
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