Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/40874 )
Change subject: scons: Delete unnecessary imports from SConstruct.
......................................................................
scons: Delete unnecessary imports from SConstruct.
Also get rid of the joinpath and splitpath aliases for os.path.join and
os.path.split. The aliases are only slightly shorter, and obscure these
extremely common python methods.
Change-Id: I0784e2d8dbaacb0690a59e9fa8c8258c1df0e6c3
---
M SConstruct
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/SConstruct b/SConstruct
index 41ea6d7..7444f83 100755
--- a/SConstruct
+++ b/SConstruct
@@ -77,18 +77,14 @@
# Global Python includes
import atexit
-import collections
-import itertools
import os
import re
-import shutil
-import subprocess
import sys
from os import mkdir, environ
-from os.path import abspath, basename, dirname, expanduser, normpath
-from os.path import exists, isdir, isfile
-from os.path import join as joinpath, split as splitpath
+from os.path import abspath, dirname, expanduser
+from os.path import isdir, isfile
+from os.path import join, split
from re import match
# SCons includes
@@ -160,7 +156,7 @@
# paths made absolute and ~-expanded. Paths will be interpreted
# relative to the launch directory unless a different root is provided
def makePathListAbsolute(path_list, root=GetLaunchDir()):
- return [abspath(joinpath(root, expanduser(str(p))))
+ return [abspath(os.path.join(root, expanduser(str(p))))
for p in path_list]
# Each target must have 'build' in the interior of the path; the
@@ -193,7 +189,7 @@
error("No non-leaf 'build' dir found on target path.", t)
# Make sure all targets use the same build root.
- this_build_root = joinpath('/', *path_dirs)
+ this_build_root = os.path.join('/', *path_dirs)
if not build_root:
build_root = this_build_root
elif this_build_root != build_root:
@@ -201,7 +197,7 @@
(build_root, this_build_root))
# Collect all the variants into a set.
- variant_paths.add(joinpath('/', *path_dirs, variant_dir))
+ variant_paths.add(os.path.join('/', *path_dirs, variant_dir))
# Make sure build_root exists (might not if this is the first build there)
if not isdir(build_root):
@@ -210,7 +206,7 @@
Export('main')
-main.SConsignFile(joinpath(build_root, "sconsign"))
+main.SConsignFile(os.path.join(build_root, "sconsign"))
# Default duplicate option is to use hard links, but this messes up
# when you use emacs to edit a file in the target dir, as emacs moves
@@ -223,7 +219,7 @@
# tree (not specific to a particular build like X86)
#
-global_vars_file = joinpath(build_root, 'variables.global')
+global_vars_file = os.path.join(build_root, 'variables.global')
global_vars = Variables(global_vars_file, args=ARGUMENTS)
@@ -626,8 +622,8 @@
for root, dirs, files in os.walk(bdir):
if 'SConsopts' in files:
if GetOption('verbose'):
- print("Reading", joinpath(root, 'SConsopts'))
- SConscript(joinpath(root, 'SConsopts'))
+ print("Reading", os.path.join(root, 'SConsopts'))
+ SConscript(os.path.join(root, 'SConsopts'))
for cb in after_sconsopts_callbacks:
cb()
@@ -710,10 +706,10 @@
if 'SConscript' in files:
build_dir = os.path.relpath(root, ext_dir)
ext_build_dirs.append(build_dir)
- main.SConscript(joinpath(root, 'SConscript'),
- variant_dir=joinpath(build_root, build_dir))
+ main.SConscript(os.path.join(root, 'SConscript'),
+ variant_dir=os.path.join(build_root, build_dir))
-gdb_xml_dir = joinpath(ext_dir, 'gdb-xml')
+gdb_xml_dir = os.path.join(ext_dir, 'gdb-xml')
Export('gdb_xml_dir')
###################################################
@@ -765,14 +761,14 @@
# variant_dir is the tail component of build path, and is used to
# determine the build parameters (e.g., 'X86')
- (build_root, variant_dir) = splitpath(variant_path)
+ (build_root, variant_dir) = os.path.split(variant_path)
# Set env variables according to the build directory config.
sticky_vars.files = []
# Variables for $BUILD_ROOT/$VARIANT_DIR are stored in
# $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke
# $BUILD_ROOT/$VARIANT_DIR without losing your variables settings.
- current_vars_file = joinpath(build_root, 'variables', variant_dir)
+ current_vars_file = os.path.join(build_root, 'variables', variant_dir)
if isfile(current_vars_file):
sticky_vars.files.append(current_vars_file)
if not GetOption('silent'):
@@ -794,10 +790,12 @@
default = GetOption('default')
opts_dir = Dir('#build_opts').abspath
if default:
- default_vars_files = [joinpath(build_root, 'variables',
default),
- joinpath(opts_dir, default)]
+ default_vars_files = [
+ os.path.join(build_root, 'variables', default),
+ os.path.join(opts_dir, default)
+ ]
else:
- default_vars_files = [joinpath(opts_dir, variant_dir)]
+ default_vars_files = [os.path.join(opts_dir, variant_dir)]
existing_files = list(filter(isfile, default_vars_files))
if existing_files:
default_vars_file = existing_files[0]
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40874
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: I0784e2d8dbaacb0690a59e9fa8c8258c1df0e6c3
Gerrit-Change-Number: 40874
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