summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Script
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Script')
-rw-r--r--src/engine/SCons/Script/Interactive.py4
-rw-r--r--src/engine/SCons/Script/Main.py25
-rw-r--r--src/engine/SCons/Script/Main.xml2
-rw-r--r--src/engine/SCons/Script/MainTests.py13
-rw-r--r--src/engine/SCons/Script/SConsOptions.py18
-rw-r--r--src/engine/SCons/Script/SConscript.py83
-rw-r--r--src/engine/SCons/Script/SConscript.xml25
-rw-r--r--src/engine/SCons/Script/SConscriptTests.py4
-rw-r--r--src/engine/SCons/Script/__init__.py27
9 files changed, 150 insertions, 51 deletions
diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py
index dee770c..35e32c2 100644
--- a/src/engine/SCons/Script/Interactive.py
+++ b/src/engine/SCons/Script/Interactive.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Script/Interactive.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Script/Interactive.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
__doc__ = """
SCons interactive mode
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 076c30b..0d626cb 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -17,7 +17,7 @@ unsupported_python_version = (2, 6, 0)
deprecated_python_version = (2, 7, 0)
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@ deprecated_python_version = (2, 7, 0)
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Script/Main.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Script/Main.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
import SCons.compat
@@ -48,6 +48,7 @@ import sys
import time
import traceback
import sysconfig
+import platform
import SCons.CacheDir
import SCons.Debug
@@ -58,6 +59,7 @@ import SCons.Job
import SCons.Node
import SCons.Node.FS
import SCons.Platform
+import SCons.Platform.virtualenv
import SCons.SConf
import SCons.Script
import SCons.Taskmaster
@@ -622,7 +624,7 @@ def _SConstruct_exists(dirname='', repositories=[], filelist=None):
current directory.
"""
if not filelist:
- filelist = ['SConstruct', 'Sconstruct', 'sconstruct']
+ filelist = ['SConstruct', 'Sconstruct', 'sconstruct', 'SConstruct.py', 'Sconstruct.py', 'sconstruct.py']
for file in filelist:
sfile = os.path.join(dirname, file)
if os.path.isfile(sfile):
@@ -862,6 +864,13 @@ def _main(parser):
for warning_type, message in delayed_warnings:
SCons.Warnings.warn(warning_type, message)
+ if not SCons.Platform.virtualenv.virtualenv_enabled_by_default:
+ if options.enable_virtualenv:
+ SCons.Platform.virtualenv.enable_virtualenv = True
+
+ if options.ignore_virtualenv:
+ SCons.Platform.virtualenv.ignore_virtualenv = True
+
if options.diskcheck:
SCons.Node.FS.set_diskcheck(options.diskcheck)
@@ -1253,7 +1262,11 @@ def _build_targets(fs, options, targets, target_top):
BuildTask.options = options
- python_has_threads = sysconfig.get_config_var('WITH_THREAD')
+ is_pypy = platform.python_implementation() == 'PyPy'
+ # As of 3.7, python removed support for threadless platforms.
+ # See https://www.python.org/dev/peps/pep-0011/
+ is_37_or_later = sys.version_info >= (3, 7)
+ python_has_threads = sysconfig.get_config_var('WITH_THREAD') or is_pypy or is_37_or_later
# to check if python configured with threads.
global num_jobs
num_jobs = options.num_jobs
@@ -1347,7 +1360,7 @@ def main():
pass
parts.append(version_string("engine", SCons))
parts.append(path_string("engine", SCons))
- parts.append("Copyright (c) 2001 - 2017 The SCons Foundation")
+ parts.append("Copyright (c) 2001 - 2019 The SCons Foundation")
version = ''.join(parts)
from . import SConsOptions
@@ -1363,7 +1376,7 @@ def main():
revert_io()
except SystemExit as s:
if s:
- exit_status = s
+ exit_status = s.code
except KeyboardInterrupt:
print("scons: Build interrupted.")
sys.exit(2)
diff --git a/src/engine/SCons/Script/Main.xml b/src/engine/SCons/Script/Main.xml
index 73db83e..c1c4bde 100644
--- a/src/engine/SCons/Script/Main.xml
+++ b/src/engine/SCons/Script/Main.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-Copyright (c) 2001 - 2017 The SCons Foundation
+Copyright (c) 2001 - 2019 The SCons Foundation
This file is processed by the bin/SConsDoc.py module.
See its __doc__ string for a discussion of the format.
diff --git a/src/engine/SCons/Script/MainTests.py b/src/engine/SCons/Script/MainTests.py
index f5660b0..64d3e0f 100644
--- a/src/engine/SCons/Script/MainTests.py
+++ b/src/engine/SCons/Script/MainTests.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -21,12 +21,10 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/MainTests.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Script/MainTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
import unittest
-import TestUnit
-
import SCons.Errors
import SCons.Script.Main
@@ -41,12 +39,7 @@ import SCons.Script.Main
# of private functionality.
if __name__ == "__main__":
- suite = unittest.TestSuite()
- tclasses = []
- for tclass in tclasses:
- names = unittest.getTestCaseNames(tclass, 'test_')
- suite.addTests(list(map(tclass, names)))
- TestUnit.run(suite)
+ unittest.main()
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py
index 5515c7d..8f31fd8 100644
--- a/src/engine/SCons/Script/SConsOptions.py
+++ b/src/engine/SCons/Script/SConsOptions.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/SConsOptions.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Script/SConsOptions.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
import optparse
import re
@@ -38,6 +38,7 @@ except ImportError:
_ = gettext
import SCons.Node.FS
+import SCons.Platform.virtualenv
import SCons.Warnings
OptionValueError = optparse.OptionValueError
@@ -706,6 +707,12 @@ def Parser(version):
action="callback", callback=opt_duplicate,
help=opt_duplicate_help)
+ if not SCons.Platform.virtualenv.virtualenv_enabled_by_default:
+ op.add_option('--enable-virtualenv',
+ dest="enable_virtualenv",
+ action="store_true",
+ help="Import certain virtualenv variables to SCons")
+
op.add_option('-f', '--file', '--makefile', '--sconstruct',
nargs=1, type="string",
dest="file", default=[],
@@ -733,6 +740,11 @@ def Parser(version):
help="Search DIR for imported Python modules.",
metavar="DIR")
+ op.add_option('--ignore-virtualenv',
+ dest="ignore_virtualenv",
+ action="store_true",
+ help="Do not import virtualenv variables to SCons")
+
op.add_option('--implicit-cache',
dest='implicit_cache', default=False,
action="store_true",
@@ -906,6 +918,7 @@ def Parser(version):
action="append",
help="Search REPOSITORY for source and target files.")
+
# Options from Make and Cons classic that we do not yet support,
# but which we may support someday and whose (potential) meanings
# we don't want to change. These all get a "the -X option is not
@@ -978,7 +991,6 @@ def Parser(version):
action="callback", callback=opt_not_yet,
# help="Warn when an undefined variable is referenced."
help=SUPPRESS_HELP)
-
return op
# Local Variables:
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 350772e..ea239e0 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -5,10 +5,8 @@ files.
"""
-from __future__ import print_function
-
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -29,7 +27,7 @@ from __future__ import print_function
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Script/SConscript.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Script/SConscript.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
import SCons
import SCons.Action
@@ -46,12 +44,15 @@ import SCons.Script.Main
import SCons.Tool
import SCons.Util
+from . import Main
+
import collections
import os
import os.path
import re
import sys
import traceback
+import time
class SConscriptReturn(Exception):
pass
@@ -152,6 +153,35 @@ def Return(*vars, **kw):
stack_bottom = '% Stack boTTom %' # hard to define a variable w/this name :)
+def handle_missing_SConscript(f, must_exist=None):
+ """Take appropriate action on missing file in SConscript() call.
+
+ Print a warning or raise an exception on missing file.
+ On first warning, print a deprecation message.
+
+ Args:
+ f (str): path of missing configuration file
+ must_exist (bool): raise exception if file does not exist
+
+ Raises:
+ UserError if 'must_exist' is True or if global
+ SCons.Script._no_missing_sconscript is True.
+ """
+
+ if must_exist or (SCons.Script._no_missing_sconscript and must_exist is not False):
+ msg = "Fatal: missing SConscript '%s'" % f.get_internal_path()
+ raise SCons.Errors.UserError(msg)
+
+ if SCons.Script._warn_missing_sconscript_deprecated:
+ msg = "Calling missing SConscript without error is deprecated.\n" + \
+ "Transition by adding must_exist=0 to SConscript calls.\n" + \
+ "Missing SConscript '%s'" % f.get_internal_path()
+ SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg)
+ SCons.Script._warn_missing_sconscript_deprecated = False
+ else:
+ msg = "Ignoring missing SConscript '%s'" % f.get_internal_path()
+ SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg)
+
def _SConscript(fs, *files, **kw):
top = fs.Top
sd = fs.SConstruct_dir.rdir()
@@ -248,17 +278,23 @@ def _SConscript(fs, *files, **kw):
pass
try:
try:
-# _file_ = SCons.Util.to_str(_file_)
- exec(compile(_file_.read(), _file_.name, 'exec'),
- call_stack[-1].globals)
+ if Main.print_time:
+ time1 = time.time()
+ scriptdata = _file_.read()
+ scriptname = _file_.name
+ _file_.close()
+ exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
except SConscriptReturn:
pass
finally:
+ if Main.print_time:
+ time2 = time.time()
+ print('SConscript:%s took %0.3f ms' % (f.get_abspath(), (time2 - time1) * 1000.0))
+
if old_file is not None:
call_stack[-1].globals.update({__file__:old_file})
else:
- SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning,
- "Ignoring missing SConscript '%s'" % f.get_internal_path())
+ handle_missing_SConscript(f, kw.get('must_exist', None))
finally:
SCons.Script.sconscript_reading = SCons.Script.sconscript_reading - 1
@@ -362,9 +398,9 @@ class SConsEnvironment(SCons.Environment.Base):
something like 3.2b1."""
version = version_string.split(' ')[0].split('.')
v_major = int(version[0])
- v_minor = int(re.match('\d+', version[1]).group())
+ v_minor = int(re.match(r'\d+', version[1]).group())
if len(version) >= 3:
- v_revision = int(re.match('\d+', version[2]).group())
+ v_revision = int(re.match(r'\d+', version[2]).group())
else:
v_revision = 0
return v_major, v_minor, v_revision
@@ -516,6 +552,31 @@ class SConsEnvironment(SCons.Environment.Base):
raise SCons.Errors.UserError("Import of non-existent variable '%s'"%x)
def SConscript(self, *ls, **kw):
+ """Execute SCons configuration files.
+
+ Parameters:
+ *ls (str or list): configuration file(s) to execute.
+
+ Keyword arguments:
+ dirs (list): execute SConscript in each listed directory.
+ name (str): execute script 'name' (used only with 'dirs').
+ exports (list or dict): locally export variables the
+ called script(s) can import.
+ variant_dir (str): mirror sources needed for the build in
+ a variant directory to allow building in it.
+ duplicate (bool): physically duplicate sources instead of just
+ adjusting paths of derived files (used only with 'variant_dir')
+ (default is True).
+ must_exist (bool): fail if a requested script is missing
+ (default is False, default is deprecated).
+
+ Returns:
+ list of variables returned by the called script
+
+ Raises:
+ UserError: a script is not found and such exceptions are enabled.
+ """
+
if 'build_dir' in kw:
msg = """The build_dir keyword has been deprecated; use the variant_dir keyword instead."""
SCons.Warnings.warn(SCons.Warnings.DeprecatedBuildDirWarning, msg)
diff --git a/src/engine/SCons/Script/SConscript.xml b/src/engine/SCons/Script/SConscript.xml
index e6be6d2..2d77aa3 100644
--- a/src/engine/SCons/Script/SConscript.xml
+++ b/src/engine/SCons/Script/SConscript.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-Copyright (c) 2001 - 2017 The SCons Foundation
+Copyright (c) 2001 - 2019 The SCons Foundation
This file is processed by the bin/SConsDoc.py module.
See its __doc__ string for a discussion of the format.
@@ -38,6 +38,10 @@ Multiple calls to
&f-Default;
are legal,
and add to the list of default targets.
+As noted above, both forms of this call affect the
+same global list of default targets; the
+construction environment method applies
+construction variable expansion to the targets.
</para>
<para>
@@ -357,12 +361,12 @@ Return('val1 val2')
<scons_function name="SConscript">
<arguments>
-(scripts, [exports, variant_dir, duplicate])
-<!-- (scripts, [exports, variant_dir, src_dir, duplicate]) -->
+(scripts, [exports, variant_dir, duplicate, must_exist])
+<!-- (scripts, [exports, variant_dir, src_dir, duplicate, must_exist]) -->
</arguments>
<arguments>
-(dirs=subdirs, [name=script, exports, variant_dir, duplicate])
-<!-- (dirs=subdirs, [name=script, exports, variant_dir, src_dir, duplicate]) -->
+(dirs=subdirs, [name=script, exports, variant_dir, duplicate, must_exist])
+<!-- (dirs=subdirs, [name=script, exports, variant_dir, src_dir, duplicate, must_exist]) -->
</arguments>
<summary>
<para>
@@ -564,6 +568,17 @@ TODO??? SConscript('build/SConscript', src_dir='src')
</para>
<para>
+The optional
+<varname>must_exist</varname>
+argument, if true, causes an exception to be raised if a requested
+&SConscript; file is not found. The current default is false,
+causing only a warning to be omitted, but this behavior is deprecated.
+For scripts which truly intend to be optional, transition to
+explicty supplying
+<literal>must_exist=False</literal> to the call.
+</para>
+
+<para>
Here are some composite examples:
</para>
diff --git a/src/engine/SCons/Script/SConscriptTests.py b/src/engine/SCons/Script/SConscriptTests.py
index 2b10446..fb06ac4 100644
--- a/src/engine/SCons/Script/SConscriptTests.py
+++ b/src/engine/SCons/Script/SConscriptTests.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/SConscriptTests.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Script/SConscriptTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
import SCons.Script.SConscript
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index ffafadf..834c70d 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -12,7 +12,7 @@ it goes here.
"""
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -34,7 +34,7 @@ it goes here.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/__init__.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Script/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
import time
start_time = time.time()
@@ -81,8 +81,8 @@ import SCons.Action
import SCons.Builder
import SCons.Environment
import SCons.Node.FS
-import SCons.Options
import SCons.Platform
+import SCons.Platform.virtualenv
import SCons.Scanner
import SCons.SConf
import SCons.Subst
@@ -150,6 +150,7 @@ Environment = SCons.Environment.Environment
#OptParser = SCons.SConsOptions.OptParser
FindPathDirs = SCons.Scanner.FindPathDirs
Platform = SCons.Platform.Platform
+Virtualenv = SCons.Platform.virtualenv.Virtualenv
Return = _SConscript.Return
Scanner = SCons.Scanner.Base
Tool = SCons.Tool.Tool
@@ -162,12 +163,6 @@ ListVariable = SCons.Variables.ListVariable
PackageVariable = SCons.Variables.PackageVariable
PathVariable = SCons.Variables.PathVariable
-# Deprecated names that will go away some day.
-BoolOption = SCons.Options.BoolOption
-EnumOption = SCons.Options.EnumOption
-ListOption = SCons.Options.ListOption
-PackageOption = SCons.Options.PackageOption
-PathOption = SCons.Options.PathOption
# Action factories.
Chmod = SCons.Defaults.Chmod
@@ -283,12 +278,20 @@ def HelpFunction(text, append=False):
# Will be non-zero if we are reading an SConscript file.
sconscript_reading = 0
+_no_missing_sconscript = False
+_warn_missing_sconscript_deprecated = True
+
+def set_missing_sconscript_error(flag=1):
+ """Set behavior on missing file in SConscript() call. Returns previous value"""
+ global _no_missing_sconscript
+ old = _no_missing_sconscript
+ _no_missing_sconscript = flag
+ return old
+
#
def Variables(files=[], args=ARGUMENTS):
return SCons.Variables.Variables(files, args)
-def Options(files=[], args=ARGUMENTS):
- return SCons.Options.Options(files, args)
# The list of global functions to add to the SConscript name space
# that end up calling corresponding methods or Builders in the
@@ -374,7 +377,9 @@ GlobalDefaultBuilders = [
'SharedObject',
'StaticLibrary',
'StaticObject',
+ 'Substfile',
'Tar',
+ 'Textfile',
'TypeLibrary',
'Zip',
'Package',