summaryrefslogtreecommitdiffstats
path: root/SCons/Script
diff options
context:
space:
mode:
Diffstat (limited to 'SCons/Script')
-rw-r--r--SCons/Script/Interactive.py8
-rw-r--r--SCons/Script/Main.py59
-rw-r--r--SCons/Script/Main.xml234
-rw-r--r--SCons/Script/MainTests.py6
-rw-r--r--SCons/Script/SConsOptions.py17
-rw-r--r--SCons/Script/SConscript.py13
-rw-r--r--SCons/Script/SConscript.xml2
-rw-r--r--SCons/Script/SConscriptTests.py6
-rw-r--r--SCons/Script/__init__.py40
9 files changed, 181 insertions, 204 deletions
diff --git a/SCons/Script/Interactive.py b/SCons/Script/Interactive.py
index a414b4e..26a8bcd 100644
--- a/SCons/Script/Interactive.py
+++ b/SCons/Script/Interactive.py
@@ -1,5 +1,6 @@
+# MIT License
#
-# __COPYRIGHT__
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -19,11 +20,8 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# 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__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-__doc__ = """
-SCons interactive mode
-"""
+"""SCons interactive mode. """
# TODO:
#
diff --git a/SCons/Script/Main.py b/SCons/Script/Main.py
index 66222ae..1f2a455 100644
--- a/SCons/Script/Main.py
+++ b/SCons/Script/Main.py
@@ -1,20 +1,6 @@
-"""SCons.Script
-
-This file implements the main() function used by the scons script.
-
-Architecturally, this *is* the scons script, and will likely only be
-called from the external "scons" wrapper. Consequently, anything here
-should not be, or be considered, part of the build engine. If it's
-something that we expect other software to want to use, it should go in
-some other module. If it's specific to the "scons" script invocation,
-it goes here.
-"""
-
-unsupported_python_version = (3, 4, 0)
-deprecated_python_version = (3, 4, 0)
-
-
-# __COPYRIGHT__
+# MIT License
+#
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -35,8 +21,19 @@ deprecated_python_version = (3, 4, 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__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""The main() function used by the scons script.
+
+Architecturally, this *is* the scons script, and will likely only be
+called from the external "scons" wrapper. Consequently, anything here
+should not be, or be considered, part of the build engine. If it's
+something that we expect other software to want to use, it should go in
+some other module. If it's specific to the "scons" script invocation,
+it goes here.
+"""
+# these define the range of versions SCons supports
+unsupported_python_version = (3, 4, 0)
+deprecated_python_version = (3, 4, 0)
import SCons.compat
@@ -49,6 +46,7 @@ import time
import traceback
import sysconfig
import platform
+import threading
import SCons.CacheDir
import SCons.Debug
@@ -83,17 +81,6 @@ num_jobs = None
delayed_warnings = []
-def fetch_win32_parallel_msg():
- # A subsidiary function that exists solely to isolate this import
- # so we don't have to pull it in on all platforms, and so that an
- # in-line "import" statement in the _main() function below doesn't
- # cause warnings about local names shadowing use of the 'SCons'
- # global in nest scopes and UnboundLocalErrors and the like in some
- # versions (2.1) of Python.
- import SCons.Platform.win32
- return SCons.Platform.win32.parallel_msg
-
-
def revert_io():
# This call is added to revert stderr and stdout to the original
# ones just in case some build rule or something else in the system
@@ -1284,16 +1271,19 @@ def _build_targets(fs, options, targets, target_top):
# 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
+ # python_has_threads = sysconfig.get_config_var('WITH_THREAD') or is_pypy or is_37_or_later
+
+ # As of python 3.4 threading has a dummy_threading module for use when there is no threading
+ # it's get_ident() will allways return -1, while real threading modules get_ident() will
+ # always return a positive integer
+ python_has_threads = threading.get_ident() != -1
# to check if python configured with threads.
global num_jobs
num_jobs = options.num_jobs
jobs = SCons.Job.Jobs(num_jobs, taskmaster)
if num_jobs > 1:
msg = None
- if sys.platform == 'win32':
- msg = fetch_win32_parallel_msg()
- elif jobs.num_jobs == 1 or not python_has_threads:
+ if jobs.num_jobs == 1 or not python_has_threads:
msg = "parallel builds are unsupported by this version of Python;\n" + \
"\tignoring -j or num_jobs option.\n"
if msg:
@@ -1343,8 +1333,7 @@ def _exec_main(parser, values):
import pdb
pdb.Pdb().runcall(_main, parser)
elif options.profile_file:
- # compat layer imports "cProfile" for us if it's available.
- from profile import Profile
+ from cProfile import Profile
prof = Profile()
try:
diff --git a/SCons/Script/Main.xml b/SCons/Script/Main.xml
index f65ffca..ff1165c 100644
--- a/SCons/Script/Main.xml
+++ b/SCons/Script/Main.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
-__COPYRIGHT__
+Copyright The SCons Foundation
This file is processed by the bin/SConsDoc.py module.
See its __doc__ string for a discussion of the format.
@@ -80,10 +80,10 @@ it will recognize <option>--device</option>,
and so forth as long as there is no other option
which could also match to the same abbreviation.
Options added via
-<function>AddOption</function> do not support
+&f-AddOption; do not support
the automatic recognition of abbreviations.
Instead, to allow specific abbreviations,
-include them in the &f-AddOption; call.
+include them as synonyms in the &f-AddOption; call itself.
</para>
<para>
@@ -99,7 +99,7 @@ options added with &f-AddOption;.
The value may also be set using
&f-SetOption;
or
-<function>env.SetOption</function>(),
+&f-env.SetOption;,
if conditions in a
&SConscript;
require overriding any default value.
@@ -765,123 +765,135 @@ Multiple targets can be passed in to a single call to
</arguments>
<summary>
<para>
-This function provides a way to set a select subset of the scons command
-line options from a SConscript file. The options supported are:
-</para>
-
-<para>
-<variablelist>
-<varlistentry>
-<term><literal>clean</literal></term>
-<listitem>
-<para>
-which corresponds to <option>-c</option>, <option>--clean</option>
-and <option>--remove</option>;
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>duplicate</literal></term>
-<listitem>
-<para>
-which corresponds to <option>--duplicate</option>;
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>help</literal></term>
-<listitem>
-<para>
-which corresponds to <option>-h</option> and <option>--help</option>;
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>implicit_cache</literal></term>
-<listitem>
-<para>
-which corresponds to <option>--implicit-cache</option>;
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>max_drift</literal></term>
-<listitem>
-<para>
-which corresponds to <option>--max-drift</option>;
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>no_exec</literal></term>
-<listitem>
-<para>
-which corresponds to <option>-n</option>, <option>--no-exec</option>,
-<option>--just-print</option>, <option>--dry-run</option>
-and <option>--recon</option>;
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>num_jobs</literal></term>
-<listitem>
-<para>
-which corresponds to <option>-j</option> and <option>--jobs</option>;
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>random</literal></term>
-<listitem>
-<para>
-which corresponds to <option>--random</option>; and
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>silent</literal></term>
-<listitem>
-<para>
-which corresponds to <option>--silent</option>.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>no_progress</literal></term>
-<listitem>
-<para>
-which corresponds to -Q.
-</para>
-<para>
- Note: The initial progress output will still be output as this is done before the SConstruct/SConscript which contains the SetOption is processed
- <literal>scons: Reading SConscript files ...</literal>
-</para>
-<para><emphasis>Available since &scons; 4.0.</emphasis></para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><literal>stack_size</literal></term>
-<listitem>
-<para>
-which corresponds to --stack-size.
-</para>
-</listitem>
-</varlistentry>
-</variablelist>
+Sets &scons; option variable <parameter>name</parameter>
+to <parameter>value</parameter>.
+These options are all also settable via
+&scons; command-line options but the variable name
+may differ from the command-line option name (see table).
+A value set via command-line option will take
+precedence over one set with &f-SetOption;, which
+allows setting a project default in the scripts and
+temporarily overriding it via command line.
+Options which affect the reading and processing of SConscript files
+are not settable this way, since those files must
+be read in order to find the &f-SetOption; call.
+</para>
+
+<para>
+The settable variables with their associated command-line options are:
+</para>
+
+<!-- UPDATE_SETOPTION_DOCS -->
+<!-- This list comes directly from SConsValues.settable. Keep in sync. -->
+
+<informaltable rowsep="1" colsep="1" frame="topbot">
+<tgroup cols="2">
+<thead>
+<row><entry>Variable</entry><entry>Command-line options</entry></row>
+</thead>
+<tbody>
+<row><entry>
+<varname>clean</varname>
+</entry><entry>
+<option>-c</option>, <option>--clean</option>, <option>--remove</option>
+</entry></row>
+<row><entry>
+<varname>diskcheck</varname>
+</entry><entry>
+<option>--diskcheck</option>
+</entry></row>
+<row><entry>
+<varname>duplicate</varname>
+</entry><entry>
+<option>--duplicate</option>
+</entry></row>
+<row><entry>
+<varname>help</varname>
+</entry><entry>
+<option>-h</option>, <option>--help</option>
+</entry></row>
+<row><entry>
+<varname>implicit_cache</varname>
+</entry><entry>
+<option>--implicit-cache</option>
+</entry></row>
+<!--TODO: add implicit-deps-changed, implicit-deps-unchanged ? -->
+<row><entry>
+<varname>max_drift</varname>
+</entry><entry>
+<option>--max-drift</option>
+</entry></row>
+<row><entry>
+<varname>md5_chunksize</varname>
+</entry><entry>
+<option>--md5-chunksize</option>
+</entry></row>
+<row><entry>
+<varname>no_exec</varname>
+</entry><entry>
+<option>-n</option>, <option>--no-exec</option>,
+<option>--just-print</option>, <option>--dry-run</option>,
+<option>--recon</option>
+</entry></row>
+<row><entry>
+<varname>no_progress</varname>
+</entry><entry>
+<option>-Q</option>
+</entry></row>
+<row><entry>
+<varname>num_jobs</varname>
+</entry><entry>
+<option>-j</option>, <option>--jobs</option>
+</entry></row>
+<row><entry>
+<varname>random</varname>
+</entry><entry>
+<option>--random</option>
+</entry></row>
+<row><entry>
+<varname>silent</varname>
+</entry><entry>
+<option>--silent</option>.
+</entry></row>
+<row><entry>
+<varname>stack_size</varname>
+</entry><entry>
+<option>--stack-size</option>
+</entry></row>
+<row><entry>
+<varname>warn</varname>
+</entry><entry>
+<option>--warn</option>.
+</entry></row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+See the documentation in the manpage for the
+corresponding command line option for information about each specific option.
+Option values which are boolean in nature (that is, they are
+either on or off) should be set to a true value (<constant>True</constant>,
+<constant>1</constant>) or a false value (<constant>False</constant>,
+<constant>0</constant>).
</para>
+<note>
<para>
-See the documentation for the
-corresponding command line option for information about each specific
-option.
+If <varname>no_progress</varname> is set via &f-SetOption;
+there will still be initial progress output as &SCons; has
+to start reading SConscript files before it can see the
+&f-SetOption; in an SConscript file:
+<computeroutput>scons: Reading SConscript files ...</computeroutput>
</para>
+</note>
<para>
Example:
</para>
<example_commands>
-SetOption('max_drift', 1)
+SetOption('max_drift', True)
</example_commands>
</summary>
</scons_function>
diff --git a/SCons/Script/MainTests.py b/SCons/Script/MainTests.py
index aa6bfac..232a8a2 100644
--- a/SCons/Script/MainTests.py
+++ b/SCons/Script/MainTests.py
@@ -1,5 +1,6 @@
+# MIT License
#
-# __COPYRIGHT__
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -19,9 +20,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# 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__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import unittest
diff --git a/SCons/Script/SConsOptions.py b/SCons/Script/SConsOptions.py
index aa31635..7b79292 100644
--- a/SCons/Script/SConsOptions.py
+++ b/SCons/Script/SConsOptions.py
@@ -1,5 +1,6 @@
+# MIT License
#
-# __COPYRIGHT__
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -19,9 +20,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# 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__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import optparse
import re
@@ -30,12 +28,8 @@ import textwrap
no_hyphen_re = re.compile(r'(\s+|(?<=[\w!\"\'&.,?])-{2,}(?=\w))')
-try:
- from gettext import gettext
-except ImportError:
- def gettext(message):
- return message
-_ = gettext
+import gettext
+_ = gettext.gettext
import SCons.Node.FS
import SCons.Platform.virtualenv
@@ -126,7 +120,8 @@ class SConsValues(optparse.Values):
# is not available.
raise AttributeError(attr)
-
+ # keep this list in sync with the SetOption doc in SCons/Script/Main.xml
+ # search for UPDATE_SETOPTION_DOCS there.
settable = [
'clean',
'diskcheck',
diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py
index e7f53f5..b8dfd93 100644
--- a/SCons/Script/SConscript.py
+++ b/SCons/Script/SConscript.py
@@ -1,12 +1,6 @@
-"""SCons.Script.SConscript
-
-This module defines the Python API provided to SConscript and SConstruct
-files.
-
-"""
-
+# MIT License
#
-# __COPYRIGHT__
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -27,7 +21,7 @@ files.
# 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__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""This module defines the Python API provided to SConscript files."""
import SCons
import SCons.Action
@@ -46,7 +40,6 @@ from SCons.Util import is_List, is_String, is_Dict, flatten
from SCons.Node import SConscriptNodes
from . import Main
-import collections
import os
import os.path
import re
diff --git a/SCons/Script/SConscript.xml b/SCons/Script/SConscript.xml
index 03efcfb..dc6e7a6 100644
--- a/SCons/Script/SConscript.xml
+++ b/SCons/Script/SConscript.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
-__COPYRIGHT__
+Copyright 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/SCons/Script/SConscriptTests.py b/SCons/Script/SConscriptTests.py
index 8b2521d..bb88dfa 100644
--- a/SCons/Script/SConscriptTests.py
+++ b/SCons/Script/SConscriptTests.py
@@ -1,5 +1,6 @@
+# MIT License
#
-# __COPYRIGHT__
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -19,9 +20,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# 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__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.Script.SConscript
diff --git a/SCons/Script/__init__.py b/SCons/Script/__init__.py
index ee9b382..dff1567 100644
--- a/SCons/Script/__init__.py
+++ b/SCons/Script/__init__.py
@@ -1,18 +1,6 @@
-"""SCons.Script
-
-This file implements the main() function used by the scons script.
-
-Architecturally, this *is* the scons script, and will likely only be
-called from the external "scons" wrapper. Consequently, anything here
-should not be, or be considered, part of the build engine. If it's
-something that we expect other software to want to use, it should go in
-some other module. If it's specific to the "scons" script invocation,
-it goes here.
-
-"""
-
+# MIT License
#
-# __COPYRIGHT__
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -32,20 +20,23 @@ it goes here.
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# 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__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""The main() function used by the scons script.
+
+Architecturally, this *is* the scons script, and will likely only be
+called from the external "scons" wrapper. Consequently, anything here
+should not be, or be considered, part of the build engine. If it's
+something that we expect other software to want to use, it should go in
+some other module. If it's specific to the "scons" script invocation,
+it goes here.
+"""
import time
start_time = time.time()
import collections
import os
-
-try:
- from StringIO import StringIO
-except ImportError:
- from io import StringIO
+from io import StringIO
import sys
@@ -134,7 +125,6 @@ GetBuildFailures = Main.GetBuildFailures
#profiling = Main.profiling
#repositories = Main.repositories
-#
from . import SConscript
_SConscript = SConscript
@@ -282,7 +272,11 @@ _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"""
+ """Set behavior on missing file in SConscript() call.
+
+ Returns:
+ previous value
+ """
global _no_missing_sconscript
old = _no_missing_sconscript
_no_missing_sconscript = flag