Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/40972 )
Change subject: scons: Update comments in SConstruct.
......................................................................
scons: Update comments in SConstruct.
Make them consistently styled, gramatically and factually correct, and
try to make sure they're reasonably clear.
Change-Id: I3566734b0ac386113ef45ac7fd24c9fb1f2007d3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40972
Reviewed-by: Gabe Black <[email protected]>
Reviewed-by: Bobby R. Bruce <[email protected]>
Maintainer: Gabe Black <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
Tested-by: kokoro <[email protected]>
---
M SConstruct
1 file changed, 71 insertions(+), 30 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
Bobby R. Bruce: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/SConstruct b/SConstruct
index 31332cd..9cb494d 100755
--- a/SConstruct
+++ b/SConstruct
@@ -47,7 +47,7 @@
# While in this directory ('gem5'), just type 'scons' to build the default
# configuration (see below), or type 'scons build/<CONFIG>/<binary>'
# to build some other configuration (e.g., 'build/X86/gem5.opt' for
-# the optimized full-system version).
+# the optimized X86 version).
#
# You can build gem5 in a different directory as long as there is a
# 'build/<CONFIG>' somewhere along the target path. The build system
@@ -75,7 +75,7 @@
#
###################################################
-# Global Python includes
+# Global Python imports
import atexit
import os
import sys
@@ -85,7 +85,7 @@
from os.path import isdir, isfile
from os.path import join, split
-# SCons includes
+# SCons imports
import SCons
import SCons.Node
import SCons.Node.FS
@@ -93,6 +93,13 @@
from m5.util import compareVersions, readCommand
+
+########################################################################
+#
+# Command line options.
+#
+########################################################################
+
AddOption('--no-colors', dest='use_colors', action='store_false',
help="Don't add color to abbreviated scons output")
AddOption('--with-cxx-config', action='store_true',
@@ -119,9 +126,10 @@
AddOption('--with-systemc-tests', action='store_true',
help='Build systemc tests')
-from gem5_scons import Transform, error, warning, summarize_warnings
-from gem5_scons import TempFileSpawn, parse_build_path, EnvDefaults
-from gem5_scons import MakeAction, MakeActionTool
+# Imports of gem5_scons happen here since it depends on some options which
are
+# declared above.
+from gem5_scons import error, warning, summarize_warnings, parse_build_path
+from gem5_scons import TempFileSpawn, EnvDefaults, MakeAction,
MakeActionTool
import gem5_scons
from gem5_scons.builders import ConfigFile, AddLocalRPATH, SwitchingHeaders
@@ -141,6 +149,8 @@
main.Tool(SCons.Tool.FindTool(['gcc', 'clang'], main))
main.Tool(SCons.Tool.FindTool(['g++', 'clang++'], main))
+Export('main')
+
from gem5_scons.util import get_termcap
termcap = get_termcap()
@@ -148,15 +158,16 @@
if not ('CC' in main and 'CXX' in main):
error("No C++ compiler installed (package g++ on Ubuntu and RedHat)")
-###################################################
+# Find default configuration & binary.
+Default(environ.get('M5_DEFAULT_BINARY', 'build/ARM/gem5.debug'))
+
+
+########################################################################
#
# Figure out which configurations to set up based on the path(s) of
# the target(s).
#
-###################################################
-
-# Find default configuration & binary.
-Default(environ.get('M5_DEFAULT_BINARY', 'build/ARM/gem5.debug'))
+########################################################################
# helper function: find last occurrence of element in list
def rfind(l, elt, offs = -1):
@@ -205,14 +216,15 @@
mkdir(build_root)
main['BUILDROOT'] = build_root
-Export('main')
-
main.SConsignFile(os.path.join(build_root, "sconsign"))
+
+########################################################################
#
# Set up global sticky variables... these are common to an entire build
# tree (not specific to a particular build like X86)
#
+########################################################################
global_vars_file = os.path.join(build_root, 'variables.global')
@@ -245,6 +257,13 @@
# Save sticky variable settings back to current variables file
global_vars.Save(global_vars_file, main)
+
+########################################################################
+#
+# Set up various paths.
+#
+########################################################################
+
# Parse EXTRAS variable to build list of all directories where we're
# look for sources etc. This list is exported as extras_dir_list.
base_dir = Dir('#src').abspath
@@ -262,6 +281,14 @@
# Add shared top-level headers
main.Prepend(CPPPATH=Dir('include'))
+
+########################################################################
+#
+# Set command line options based on the configuration of the host and
+# build settings.
+#
+########################################################################
+
# Initialize the Link-Time Optimization (LTO) flags
main['LTO_CCFLAGS'] = []
main['LTO_LDFLAGS'] = []
@@ -414,10 +441,6 @@
main.Append(CCFLAGS=["-Wno-uninitialized"])
-main['HAVE_PKG_CONFIG'] = main.Detect('pkg-config')
-
-
-
# Cache build files in the supplied directory.
if main['M5_BUILD_CACHE']:
print('Using build cache located at', main['M5_BUILD_CACHE'])
@@ -430,6 +453,13 @@
if not conf.CheckLinkFlag('-gz'):
warning("Can't enable executable debug section compression")
+
+########################################################################
+#
+# Detect and configure external dependencies.
+#
+########################################################################
+
main['USE_PYTHON'] = not GetOption('without_python')
if main['USE_PYTHON']:
# Find Python include and library directories for embedding the
@@ -492,36 +522,37 @@
warning('Embedded python library too new. '
'Python 3 expected, found %s.' % ver_string)
+main['HAVE_PKG_CONFIG'] = main.Detect('pkg-config')
+
with gem5_scons.Configure(main) as conf:
# On Solaris you need to use libsocket for socket ops
if not conf.CheckLibWithHeader(
[None, 'socket'], 'sys/socket.h', 'C++', 'accept(0,0,0);'):
error("Can't find library with socket calls (e.g. accept()).")
- # Check for zlib. If the check passes, libz will be automatically
- # added to the LIBS environment variable.
if not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
error('Did not find needed zlib compression library '
'and/or zlib.h header file.\n'
'Please install zlib and try again.')
-
if not GetOption('without_tcmalloc'):
with gem5_scons.Configure(main) as conf:
if conf.CheckLib('tcmalloc'):
- conf.env.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
+ conf.env.Append(CCFLAGS=conf.env['TCMALLOC_CCFLAGS'])
elif conf.CheckLib('tcmalloc_minimal'):
- conf.env.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
+ conf.env.Append(CCFLAGS=conf.env['TCMALLOC_CCFLAGS'])
else:
warning("You can get a 12% performance improvement by "
"installing tcmalloc (libgoogle-perftools-dev package "
"on Ubuntu or RedHat).")
-######################################################################
+########################################################################
#
-# Collect all non-global variables
+# Read and process SConsopts files. These can add new settings which
+# affect each variant directory independently.
#
+########################################################################
# Register a callback which is called after all SConsopts files have been
read.
after_sconsopts_callbacks = []
@@ -553,13 +584,22 @@
print("Reading", os.path.join(root, 'SConsopts'))
SConscript(os.path.join(root, 'SConsopts'))
+# Call any callbacks which the SConsopts files registered.
for cb in after_sconsopts_callbacks:
cb()
+# Add any generic sticky variables here.
sticky_vars.Add(BoolVariable('USE_EFENCE',
'Link with Electric Fence malloc debugger', False))
-# builds in ext are shared across all configs in the build root.
+
+########################################################################
+#
+# Find and process all the SConscript files in ext. These are shared by
+# all variants in a build root.
+#
+########################################################################
+
ext_dir = Dir('#ext').abspath
ext_build_dirs = []
for root, dirs, files in os.walk(ext_dir):
@@ -572,11 +612,12 @@
gdb_xml_dir = os.path.join(ext_dir, 'gdb-xml')
Export('gdb_xml_dir')
-###################################################
+
+########################################################################
#
-# Define build environments for selected configurations.
+# Define build environments for required variants.
#
-###################################################
+########################################################################
for variant_path in variant_paths:
if not GetOption('silent'):
@@ -604,9 +645,9 @@
# Things in ext are built without a variant directory.
continue
else:
- # Build dir-specific variables file doesn't exist.
+ # Variant specific variables file doesn't exist.
- # Make sure the directory is there so we can create it later
+ # Make sure the directory is there so we can create the file later.
opt_dir = dirname(current_vars_file)
if not isdir(opt_dir):
mkdir(opt_dir)
20 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40972
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: I3566734b0ac386113ef45ac7fd24c9fb1f2007d3
Gerrit-Change-Number: 40972
Gerrit-PatchSet: 23
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s