summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Tool
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:54:23 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:54:23 +0200
commitc2d9eaeffe9d77d8d5087fb21a3256fde32047d4 (patch)
tree144aeb4702d258b0cfaf99cffb9f21e94b026459 /src/engine/SCons/Tool
parent6ca68f29862bc7cbe5428426eee600cb1f3c05c1 (diff)
parentefdf3fdbcd2f7654cb8d1209a8b040914437bacd (diff)
Update upstream source from tag 'upstream/3.1.0'
Update to upstream version '3.1.0' with Debian dir e69b7671114411c368722827d87d86b44ed7cd40
Diffstat (limited to 'src/engine/SCons/Tool')
-rw-r--r--src/engine/SCons/Tool/386asm.py2
-rw-r--r--src/engine/SCons/Tool/DCommon.py2
-rw-r--r--src/engine/SCons/Tool/FortranCommon.py5
-rw-r--r--src/engine/SCons/Tool/FortranCommonTests.py125
-rw-r--r--src/engine/SCons/Tool/GettextCommon.py58
-rw-r--r--src/engine/SCons/Tool/JavaCommon.py140
-rw-r--r--src/engine/SCons/Tool/JavaCommonTests.py74
-rw-r--r--src/engine/SCons/Tool/MSCommon/__init__.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/arch.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/common.py5
-rw-r--r--src/engine/SCons/Tool/MSCommon/netframework.py4
-rw-r--r--src/engine/SCons/Tool/MSCommon/sdk.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py145
-rw-r--r--src/engine/SCons/Tool/MSCommon/vcTests.py180
-rw-r--r--src/engine/SCons/Tool/MSCommon/vs.py15
-rw-r--r--src/engine/SCons/Tool/PharLapCommon.py5
-rw-r--r--src/engine/SCons/Tool/ToolTests.py86
-rw-r--r--src/engine/SCons/Tool/__init__.py96
-rw-r--r--src/engine/SCons/Tool/aixc++.py2
-rw-r--r--src/engine/SCons/Tool/aixcc.py2
-rw-r--r--src/engine/SCons/Tool/aixcxx.py2
-rw-r--r--src/engine/SCons/Tool/aixf77.py2
-rw-r--r--src/engine/SCons/Tool/aixlink.py2
-rw-r--r--src/engine/SCons/Tool/applelink.py2
-rw-r--r--src/engine/SCons/Tool/ar.py2
-rw-r--r--src/engine/SCons/Tool/as.py2
-rw-r--r--src/engine/SCons/Tool/bcc32.py2
-rw-r--r--src/engine/SCons/Tool/c++.py2
-rw-r--r--src/engine/SCons/Tool/cc.py2
-rw-r--r--src/engine/SCons/Tool/clang.py5
-rw-r--r--src/engine/SCons/Tool/clangxx.py5
-rw-r--r--src/engine/SCons/Tool/cvf.py2
-rw-r--r--src/engine/SCons/Tool/cxx.py2
-rw-r--r--src/engine/SCons/Tool/cyglink.py2
-rw-r--r--src/engine/SCons/Tool/default.py2
-rw-r--r--src/engine/SCons/Tool/dmd.py2
-rw-r--r--src/engine/SCons/Tool/docbook/__init__.py182
-rw-r--r--src/engine/SCons/Tool/dvi.py2
-rw-r--r--src/engine/SCons/Tool/dvipdf.py2
-rw-r--r--src/engine/SCons/Tool/dvips.py2
-rw-r--r--src/engine/SCons/Tool/f03.py2
-rw-r--r--src/engine/SCons/Tool/f08.py2
-rw-r--r--src/engine/SCons/Tool/f77.py2
-rw-r--r--src/engine/SCons/Tool/f90.py2
-rw-r--r--src/engine/SCons/Tool/f95.py2
-rw-r--r--src/engine/SCons/Tool/filesystem.py2
-rw-r--r--src/engine/SCons/Tool/fortran.py2
-rw-r--r--src/engine/SCons/Tool/g++.py2
-rw-r--r--src/engine/SCons/Tool/g77.py2
-rw-r--r--src/engine/SCons/Tool/gas.py2
-rw-r--r--src/engine/SCons/Tool/gcc.py2
-rw-r--r--src/engine/SCons/Tool/gdc.py2
-rw-r--r--src/engine/SCons/Tool/gettext_tool.py2
-rw-r--r--src/engine/SCons/Tool/gfortran.py2
-rw-r--r--src/engine/SCons/Tool/gnulink.py2
-rw-r--r--src/engine/SCons/Tool/gs.py2
-rw-r--r--src/engine/SCons/Tool/gxx.py2
-rw-r--r--src/engine/SCons/Tool/hpc++.py2
-rw-r--r--src/engine/SCons/Tool/hpcc.py2
-rw-r--r--src/engine/SCons/Tool/hpcxx.py5
-rw-r--r--src/engine/SCons/Tool/hplink.py2
-rw-r--r--src/engine/SCons/Tool/icc.py2
-rw-r--r--src/engine/SCons/Tool/icl.py2
-rw-r--r--src/engine/SCons/Tool/ifl.py2
-rw-r--r--src/engine/SCons/Tool/ifort.py2
-rw-r--r--src/engine/SCons/Tool/ilink.py2
-rw-r--r--src/engine/SCons/Tool/ilink32.py2
-rw-r--r--src/engine/SCons/Tool/install.py2
-rw-r--r--src/engine/SCons/Tool/intelc.py15
-rw-r--r--src/engine/SCons/Tool/ipkg.py8
-rw-r--r--src/engine/SCons/Tool/jar.py16
-rw-r--r--src/engine/SCons/Tool/javac.py10
-rw-r--r--src/engine/SCons/Tool/javah.py8
-rw-r--r--src/engine/SCons/Tool/latex.py2
-rw-r--r--src/engine/SCons/Tool/ldc.py2
-rw-r--r--src/engine/SCons/Tool/lex.py40
-rw-r--r--src/engine/SCons/Tool/link.py2
-rw-r--r--src/engine/SCons/Tool/linkloc.py2
-rw-r--r--src/engine/SCons/Tool/m4.py2
-rw-r--r--src/engine/SCons/Tool/masm.py2
-rw-r--r--src/engine/SCons/Tool/midl.py2
-rw-r--r--src/engine/SCons/Tool/mingw.py6
-rw-r--r--src/engine/SCons/Tool/msgfmt.py2
-rw-r--r--src/engine/SCons/Tool/msginit.py2
-rw-r--r--src/engine/SCons/Tool/msgmerge.py2
-rw-r--r--src/engine/SCons/Tool/mslib.py11
-rw-r--r--src/engine/SCons/Tool/mslink.py15
-rw-r--r--src/engine/SCons/Tool/mssdk.py2
-rw-r--r--src/engine/SCons/Tool/msvc.py13
-rw-r--r--src/engine/SCons/Tool/msvc.xml1
-rw-r--r--src/engine/SCons/Tool/msvs.py195
-rw-r--r--src/engine/SCons/Tool/msvs.xml38
-rw-r--r--src/engine/SCons/Tool/msvsTests.py181
-rw-r--r--src/engine/SCons/Tool/mwcc.py2
-rw-r--r--src/engine/SCons/Tool/mwld.py2
-rw-r--r--src/engine/SCons/Tool/nasm.py2
-rw-r--r--src/engine/SCons/Tool/packaging/__init__.py16
-rw-r--r--src/engine/SCons/Tool/packaging/ipk.py16
-rw-r--r--src/engine/SCons/Tool/packaging/msi.py23
-rw-r--r--src/engine/SCons/Tool/packaging/rpm.py10
-rw-r--r--src/engine/SCons/Tool/packaging/src_tarbz2.py2
-rw-r--r--src/engine/SCons/Tool/packaging/src_targz.py2
-rw-r--r--src/engine/SCons/Tool/packaging/src_tarxz.py2
-rw-r--r--src/engine/SCons/Tool/packaging/src_zip.py2
-rw-r--r--src/engine/SCons/Tool/packaging/tarbz2.py2
-rw-r--r--src/engine/SCons/Tool/packaging/targz.py2
-rw-r--r--src/engine/SCons/Tool/packaging/tarxz.py2
-rw-r--r--src/engine/SCons/Tool/packaging/zip.py2
-rw-r--r--src/engine/SCons/Tool/pdf.py2
-rw-r--r--src/engine/SCons/Tool/pdflatex.py2
-rw-r--r--src/engine/SCons/Tool/pdftex.py2
-rw-r--r--src/engine/SCons/Tool/qt.py35
-rw-r--r--src/engine/SCons/Tool/rmic.py8
-rw-r--r--src/engine/SCons/Tool/rpcgen.py2
-rw-r--r--src/engine/SCons/Tool/rpm.py25
-rw-r--r--src/engine/SCons/Tool/rpmutils.py41
-rw-r--r--src/engine/SCons/Tool/sgiar.py2
-rw-r--r--src/engine/SCons/Tool/sgic++.py2
-rw-r--r--src/engine/SCons/Tool/sgicc.py2
-rw-r--r--src/engine/SCons/Tool/sgicxx.py2
-rw-r--r--src/engine/SCons/Tool/sgilink.py2
-rw-r--r--src/engine/SCons/Tool/sunar.py2
-rw-r--r--src/engine/SCons/Tool/sunc++.py2
-rw-r--r--src/engine/SCons/Tool/suncc.py2
-rw-r--r--src/engine/SCons/Tool/suncxx.py18
-rw-r--r--src/engine/SCons/Tool/sunf77.py2
-rw-r--r--src/engine/SCons/Tool/sunf90.py2
-rw-r--r--src/engine/SCons/Tool/sunf95.py2
-rw-r--r--src/engine/SCons/Tool/sunlink.py2
-rw-r--r--src/engine/SCons/Tool/swig.py5
-rw-r--r--src/engine/SCons/Tool/tar.py2
-rw-r--r--src/engine/SCons/Tool/tex.py4
-rw-r--r--src/engine/SCons/Tool/textfile.py2
-rw-r--r--src/engine/SCons/Tool/tlib.py2
-rw-r--r--src/engine/SCons/Tool/wix.py2
-rw-r--r--src/engine/SCons/Tool/wixTests.py2
-rw-r--r--src/engine/SCons/Tool/xgettext.py55
-rw-r--r--src/engine/SCons/Tool/yacc.py56
-rw-r--r--src/engine/SCons/Tool/zip.py2
139 files changed, 1466 insertions, 728 deletions
diff --git a/src/engine/SCons/Tool/386asm.py b/src/engine/SCons/Tool/386asm.py
index 930b431..1121c3d 100644
--- a/src/engine/SCons/Tool/386asm.py
+++ b/src/engine/SCons/Tool/386asm.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/386asm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/386asm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.PharLapCommon import addPharLapPaths
import SCons.Util
diff --git a/src/engine/SCons/Tool/DCommon.py b/src/engine/SCons/Tool/DCommon.py
index 169f95d..f6b6000 100644
--- a/src/engine/SCons/Tool/DCommon.py
+++ b/src/engine/SCons/Tool/DCommon.py
@@ -31,7 +31,7 @@ Coded by Russel Winder (russel@winder.org.uk)
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/DCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/DCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py
index 27646f0..11f1eb7 100644
--- a/src/engine/SCons/Tool/FortranCommon.py
+++ b/src/engine/SCons/Tool/FortranCommon.py
@@ -28,7 +28,7 @@ Stuff for processing Fortran, common to all fortran dialects.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/FortranCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/FortranCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import re
import os.path
@@ -64,7 +64,8 @@ def _fortranEmitter(target, source, env):
if not node.exists() and not node.is_derived():
print("Could not locate " + str(node.name))
return ([], [])
- mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+ # This has to match the def_regex in the Fortran scanner
+ mod_regex = r"""(?i)^\s*MODULE\s+(?!PROCEDURE|SUBROUTINE|FUNCTION|PURE|ELEMENTAL)(\w+)"""
cre = re.compile(mod_regex,re.M)
# Retrieve all USE'd module names
modules = cre.findall(node.get_text_contents())
diff --git a/src/engine/SCons/Tool/FortranCommonTests.py b/src/engine/SCons/Tool/FortranCommonTests.py
new file mode 100644
index 0000000..9cca9b0
--- /dev/null
+++ b/src/engine/SCons/Tool/FortranCommonTests.py
@@ -0,0 +1,125 @@
+#
+# 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
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# 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.
+#
+# from typing import Dict, Any
+
+__revision__ = "src/engine/SCons/Tool/FortranCommonTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+
+import os
+import os.path
+import unittest
+
+import SCons.Node.FS
+import SCons.Warnings
+import SCons.Tool.FortranCommon
+
+import TestCmd
+
+original = os.getcwd()
+
+test = TestCmd.TestCmd(workdir='')
+
+os.chdir(test.workpath(''))
+
+
+class DummyEnvironment(object):
+ dictionary = None # type: Dict[Any, Any]
+
+ def __init__(self, list_cpp_path):
+ self.path = list_cpp_path
+ self.fs = SCons.Node.FS.FS(test.workpath(''))
+ self.dictionary = {}
+
+ def has_key(self, key):
+ return key in self.dictionary
+
+ def __getitem__(self, key):
+ return self.dictionary[key]
+
+ def __setitem__(self, key, value):
+ self.dictionary[key] = value
+
+ def __delitem__(self, key):
+ del self.dictionary[key]
+
+ def subst(self, arg, target=None, source=None, conv=None):
+ if arg[0] == '$':
+ return self[arg[1:]]
+ return arg
+
+ def subst_path(self, path, target=None, source=None, conv=None):
+ if not isinstance(path, list):
+ path = [path]
+ return list(map(self.subst, path))
+
+ def get_calculator(self):
+ return None
+
+ def get_factory(self, factory):
+ return factory or self.fs.File
+
+ def Dir(self, filename):
+ return self.fs.Dir(filename)
+
+ def File(self, filename):
+ return self.fs.File(filename)
+
+
+class FortranScannerSubmodulesTestCase(unittest.TestCase):
+ def runTest(self):
+ """
+ Check that test_1.f90 and test_2.f90 which have interface specifications
+ Don't generate targets for those modules listed in the interface section
+ """
+
+ test.dir_fixture('fortran_unittests')
+ env = DummyEnvironment([test.workpath('modules')])
+ env['FORTRANMODDIR'] = 'modules'
+ env['FORTRANMODSUFFIX'] = '.mod'
+ emitter = SCons.Tool.FortranCommon._fortranEmitter
+ # path = s.path(env)
+
+ for fort in ['test_1.f90', 'test_2.f90']:
+ file_base, _ = os.path.splitext(fort)
+ file_mod = '%s.mod' % file_base
+ f = env.File(fort)
+ (target, source) = emitter([], [f, ], env)
+
+ # print("Targets:%s\nSources:%s"%([str(a) for a in target], [str(a) for a in source]))
+
+ # should only be 1 target and 1 source
+ self.assertEqual(len(target), 1,
+ msg="More than 1 target: %d [%s]" % (len(target), [str(t) for t in target]))
+ self.assertEqual(len(source), 1,
+ msg="More than 1 source: %d [%s]" % (len(source), [str(t) for t in source]))
+
+ # target should be file_base.mod
+ self.assertEqual(str(target[0]).endswith(file_mod), True,
+ msg="Target[0]=%s doesn't end with '%s'" % (str(target[0]), file_mod))
+
+ # source should be file_base .f90
+ self.assertEqual(str(source[0]).endswith(fort), True,
+ msg="Source[0]=%s doesn't end with '%s'" % (str(source[0]), fort))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/src/engine/SCons/Tool/GettextCommon.py b/src/engine/SCons/Tool/GettextCommon.py
index 8c2163e..79912b6 100644
--- a/src/engine/SCons/Tool/GettextCommon.py
+++ b/src/engine/SCons/Tool/GettextCommon.py
@@ -4,7 +4,7 @@ Used by several tools of `gettext` toolset.
"""
# 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
# "Software"), to deal in the Software without restriction, including
@@ -12,10 +12,10 @@ Used by several tools of `gettext` toolset.
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -24,7 +24,7 @@ Used by several tools of `gettext` toolset.
# 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/Tool/GettextCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/GettextCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Warnings
import re
@@ -71,7 +71,7 @@ SCons.Warnings.enableWarningClass(MsgfmtNotFound)
#############################################################################
class _POTargetFactory(object):
""" A factory of `PO` target files.
-
+
Factory defaults differ from these of `SCons.Node.FS.FS`. We set `precious`
(this is required by builders and actions gettext) and `noclean` flags by
default for all produced nodes.
@@ -80,9 +80,9 @@ class _POTargetFactory(object):
def __init__(self, env, nodefault=True, alias=None, precious=True
, noclean=True):
""" Object constructor.
-
+
**Arguments**
-
+
- *env* (`SCons.Environment.Environment`)
- *nodefault* (`boolean`) - if `True`, produced nodes will be ignored
from default target `'.'`
@@ -160,13 +160,13 @@ from SCons.Builder import BuilderBase
#############################################################################
class _POFileBuilder(BuilderBase):
""" `PO` file builder.
-
+
This is multi-target single-source builder. In typical situation the source
is single `POT` file, e.g. `messages.pot`, and there are multiple `PO`
targets to be updated from this `POT`. We must run
`SCons.Builder.BuilderBase._execute()` separatelly for each target to track
dependencies separatelly for each target file.
-
+
**NOTE**: if we call `SCons.Builder.BuilderBase._execute(.., target, ...)`
with target being list of all targets, all targets would be rebuilt each time
one of the targets from this list is missing. This would happen, for example,
@@ -198,29 +198,29 @@ class _POFileBuilder(BuilderBase):
# After that it calls emitter (which is quite too late). The emitter is
# also called in each iteration, what makes things yet worse.
def __init__(self, env, **kw):
- if not 'suffix' in kw:
+ if 'suffix' not in kw:
kw['suffix'] = '$POSUFFIX'
- if not 'src_suffix' in kw:
+ if 'src_suffix' not in kw:
kw['src_suffix'] = '$POTSUFFIX'
- if not 'src_builder' in kw:
+ if 'src_builder' not in kw:
kw['src_builder'] = '_POTUpdateBuilder'
- if not 'single_source' in kw:
+ if 'single_source' not in kw:
kw['single_source'] = True
alias = None
if 'target_alias' in kw:
alias = kw['target_alias']
del kw['target_alias']
- if not 'target_factory' in kw:
+ if 'target_factory' not in kw:
kw['target_factory'] = _POTargetFactory(env, alias=alias).File
BuilderBase.__init__(self, **kw)
def _execute(self, env, target, source, *args, **kw):
""" Execute builder's actions.
-
- Here we append to `target` the languages read from `$LINGUAS_FILE` and
+
+ Here we append to `target` the languages read from `$LINGUAS_FILE` and
apply `SCons.Builder.BuilderBase._execute()` separatelly to each target.
The arguments and return value are same as for
- `SCons.Builder.BuilderBase._execute()`.
+ `SCons.Builder.BuilderBase._execute()`.
"""
import SCons.Util
import SCons.Node
@@ -272,7 +272,7 @@ def _translate(env, target=None, source=SCons.Environment._null, *args, **kw):
class RPaths(object):
""" Callable object, which returns pathnames relative to SCons current
working directory.
-
+
It seems like `SCons.Node.FS.Base.get_path()` returns absolute paths
for nodes that are outside of current working directory (`env.fs.getcwd()`).
Here, we often have `SConscript`, `POT` and `PO` files within `po/`
@@ -285,17 +285,17 @@ class RPaths(object):
the references would be correct only on the machine, where `POT` file was
recently re-created. For such reason, we need a function, which always
returns relative paths. This is the purpose of `RPaths` callable object.
-
+
The `__call__` method returns paths relative to current working directory, but
we assume, that *xgettext(1)* is run from the directory, where target file is
going to be created.
-
+
Note, that this may not work for files distributed over several hosts or
across different drives on windows. We assume here, that single local
filesystem holds both source files and target `POT` templates.
-
+
Intended use of `RPaths` - in `xgettext.py`::
-
+
def generate(env):
from GettextCommon import RPaths
...
@@ -318,9 +318,9 @@ class RPaths(object):
def __init__(self, env):
""" Initialize `RPaths` callable object.
-
+
**Arguments**:
-
+
- *env* - a `SCons.Environment.Environment` object, defines *current
working dir*.
"""
@@ -329,16 +329,16 @@ class RPaths(object):
# FIXME: I'm not sure, how it should be implemented (what the *args are in
# general, what is **kw).
def __call__(self, nodes, *args, **kw):
- """ Return nodes' paths (strings) relative to current working directory.
-
+ """ Return nodes' paths (strings) relative to current working directory.
+
**Arguments**:
-
+
- *nodes* ([`SCons.Node.FS.Base`]) - list of nodes.
- *args* - currently unused.
- *kw* - currently unused.
-
+
**Returns**:
-
+
- Tuple of strings, which represent paths relative to current working
directory (for given environment).
"""
diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py
index 2683f03..1e58af6 100644
--- a/src/engine/SCons/Tool/JavaCommon.py
+++ b/src/engine/SCons/Tool/JavaCommon.py
@@ -27,7 +27,7 @@ Stuff for processing Java.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/JavaCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/JavaCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -42,6 +42,33 @@ default_java_version = '1.4'
# anonymous inner class parsing.
scopeStateVersions = ('1.8')
+# Glob patterns for use in finding where the JDK is.
+# These are pairs, *dir_glob used in the general case,
+# *version_dir_glob if matching only a specific version.
+# For now only used for Windows.
+java_win32_dir_glob = 'C:/Program Files*/Java/jdk*/bin'
+# On windows, since Java 9, there is a dash between 'jdk' and the version
+# string that wasn't there before. this glob should catch either way.
+java_win32_version_dir_glob = 'C:/Program Files*/Java/jdk*%s*/bin'
+
+# Glob patterns for use in finding where the JDK headers are.
+# These are pairs, *dir_glob used in the general case,
+# *version_dir_glob if matching only a specific version.
+java_macos_include_dir_glob = '/System/Library/Frameworks/JavaVM.framework/Headers/'
+java_macos_version_include_dir_glob = '/System/Library/Frameworks/JavaVM.framework/Versions/%s*/Headers/'
+
+java_linux_include_dirs_glob = [
+ '/usr/lib/jvm/default-java/include',
+ '/usr/lib/jvm/java-*/include'
+]
+# Need to match path like below (from Centos 7)
+# /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/include/
+java_linux_version_include_dirs_glob = [
+ '/usr/lib/jvm/java-*-sun-%s*/include',
+ '/usr/lib/jvm/java-%s*-openjdk*/include',
+ '/usr/java/jdk%s*/include'
+]
+
if java_parsing:
# Parse Java files for class names.
#
@@ -64,14 +91,15 @@ if java_parsing:
r'\d*\.\d*|[A-Za-z_][\w\$\.]*|<[A-Za-z_]\w+>|' +
r'/\*|\*/|\[\])')
+
class OuterState(object):
"""The initial state for parsing a Java file for classes,
interfaces, and anonymous inner classes."""
- def __init__(self, version=default_java_version):
- if not version in ('1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7',
- '1.8', '5', '6', '9.0', '10.0', '11.0'):
+ def __init__(self, version=default_java_version):
+ if version not in ('1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7',
+ '1.8', '5', '6', '9.0', '10.0', '11.0', '12.0'):
msg = "Java version %s not supported" % version
raise NotImplementedError(msg)
@@ -131,15 +159,15 @@ if java_parsing:
def closeBracket(self):
self.brackets = self.brackets - 1
if len(self.stackBrackets) and \
- self.brackets == self.stackBrackets[-1]:
+ self.brackets == self.stackBrackets[-1]:
self.listOutputs.append('$'.join(self.listClasses))
self.localClasses.pop()
self.listClasses.pop()
self.anonStacksStack.pop()
self.stackBrackets.pop()
if len(self.stackAnonClassBrackets) and \
- self.brackets == self.stackAnonClassBrackets[-1] and \
- self.version not in scopeStateVersions:
+ self.brackets == self.stackAnonClassBrackets[-1] and \
+ self.version not in scopeStateVersions:
self._getAnonStack().pop()
self.stackAnonClassBrackets.pop()
@@ -152,13 +180,13 @@ if java_parsing:
self.openBracket()
elif token == '}':
self.closeBracket()
- elif token in [ '"', "'" ]:
+ elif token in ['"', "'"]:
return IgnoreState(token, self)
elif token == "new":
# anonymous inner class
if len(self.listClasses) > 0:
return self.__getAnonClassState()
- return self.__getSkipState() # Skip the class name
+ return self.__getSkipState() # Skip the class name
elif token in ['class', 'interface', 'enum']:
if len(self.listClasses) == 0:
self.nextAnon = 1
@@ -178,7 +206,7 @@ if java_parsing:
if self.version in ('1.1', '1.2', '1.3', '1.4'):
clazz = self.listClasses[0]
self.listOutputs.append('%s$%d' % (clazz, self.nextAnon))
- elif self.version in ('1.5', '1.6', '1.7', '1.8', '5', '6', '9.0', '10.0', '11.0'):
+ elif self.version in ('1.5', '1.6', '1.7', '1.8', '5', '6', '9.0', '10.0', '11.0', '12.0'):
self.stackAnonClassBrackets.append(self.brackets)
className = []
className.extend(self.listClasses)
@@ -193,11 +221,13 @@ if java_parsing:
def setPackage(self, package):
self.package = package
+
class ScopeState(object):
"""
A state that parses code within a scope normally,
within the confines of a scope.
"""
+
def __init__(self, old_state):
self.outer_state = old_state.outer_state
self.old_state = old_state
@@ -259,13 +289,16 @@ if java_parsing:
return self.__getSkipState()
return self
+
class AnonClassState(object):
"""A state that looks for anonymous inner classes."""
+
def __init__(self, old_state):
# outer_state is always an instance of OuterState
self.outer_state = old_state.outer_state
self.old_state = old_state
self.brace_level = 0
+
def parseToken(self, token):
# This is an anonymous class if and only if the next
# non-whitespace token is a bracket. Everything between
@@ -293,26 +326,32 @@ if java_parsing:
if token == '{':
self.outer_state.addAnonClass()
if self.outer_state.version in scopeStateVersions:
- return ScopeState(old_state = self.old_state).parseToken(token)
+ return ScopeState(old_state=self.old_state).parseToken(token)
return self.old_state.parseToken(token)
+
class SkipState(object):
"""A state that will skip a specified number of tokens before
reverting to the previous state."""
+
def __init__(self, tokens_to_skip, old_state):
self.tokens_to_skip = tokens_to_skip
self.old_state = old_state
+
def parseToken(self, token):
self.tokens_to_skip = self.tokens_to_skip - 1
if self.tokens_to_skip < 1:
return self.old_state
return self
+
class ClassState(object):
"""A state we go into when we hit a class or interface keyword."""
+
def __init__(self, outer_state):
# outer_state is always an instance of OuterState
self.outer_state = outer_state
+
def parseToken(self, token):
# the next non-whitespace token should be the name of the class
if token == '\n':
@@ -322,12 +361,12 @@ if java_parsing:
# 'Foo$1Inner'
# https://github.com/SCons/scons/issues/2087
if self.outer_state.localClasses and \
- self.outer_state.stackBrackets[-1] > \
- self.outer_state.stackBrackets[-2]+1:
+ self.outer_state.stackBrackets[-1] > \
+ self.outer_state.stackBrackets[-2] + 1:
locals = self.outer_state.localClasses[-1]
try:
idx = locals[token]
- locals[token] = locals[token]+1
+ locals[token] = locals[token] + 1
except KeyError:
locals[token] = 1
token = str(locals[token]) + token
@@ -336,32 +375,40 @@ if java_parsing:
self.outer_state.anonStacksStack.append([0])
return self.outer_state
+
class IgnoreState(object):
"""A state that will ignore all tokens until it gets to a
specified token."""
+
def __init__(self, ignore_until, old_state):
self.ignore_until = ignore_until
self.old_state = old_state
+
def parseToken(self, token):
if self.ignore_until == token:
return self.old_state
return self
+
class PackageState(object):
"""The state we enter when we encounter the package keyword.
We assume the next token will be the package name."""
+
def __init__(self, outer_state):
# outer_state is always an instance of OuterState
self.outer_state = outer_state
+
def parseToken(self, token):
self.outer_state.setPackage(token)
return self.outer_state
+
def parse_java_file(fn, version=default_java_version):
with open(fn, 'r') as f:
data = f.read()
return parse_java(data, version)
+
def parse_java(contents, version=default_java_version, trace=None):
"""Parse a .java file and return a double of package directory,
plus a list of .class files that compiling that .java file will
@@ -395,81 +442,68 @@ else:
return os.path.split(fn)
-
-java_win32_version_dir_glob = 'C:/Program Files*/Java/jdk%s*/bin'
-java_win32_dir_glob = 'C:/Program Files*/Java/jdk*/bin'
-
-java_macos_include_dir = '/System/Library/Frameworks/JavaVM.framework/Headers/'
-java_macos_version_include_dir = '/System/Library/Frameworks/JavaVM.framework/Versions/%s*/Headers/'
-
-java_linux_include_dirs = ['/usr/lib/jvm/default-java/include',
- '/usr/lib/jvm/java-*/include']
-# Need to match path like below (from Centos 7)
-# /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/include/
-java_linux_version_include_dirs = ['/usr/lib/jvm/java-*-sun-%s*/include',
- '/usr/lib/jvm/java-%s*-openjdk*/include',
- '/usr/java/jdk%s*/include']
-
-
-
def get_java_install_dirs(platform, version=None):
"""
- Using patterns above find the java jdk install dir
- :param platform:
+ Find the java jdk installation directories.
+
+ This list is intended to supply as "default paths" for use when looking
+ up actual java binaries.
+
+ :param platform: selector for search algorithm.
:param version: If specified, only look for java sdk's of this version
:return: list of default paths for java.
"""
+
paths = []
if platform == 'win32':
if version:
- paths = glob.glob(java_win32_version_dir_glob%version)
+ paths = glob.glob(java_win32_version_dir_glob % version)
else:
paths = glob.glob(java_win32_dir_glob)
else:
- # do nothing for now
+ # other platforms, do nothing for now
pass
- paths=sorted(paths)
+ return sorted(paths)
- return paths
def get_java_include_paths(env, javac, version):
"""
- Return java include paths
- :param platform:
- :param javac:
- :return:
+ Find java include paths for JNI building.
+
+ :param env: construction environment, used to extract platform.
+ :param javac: path to detected javac.
+ :return: list of paths.
"""
+
paths = []
if not javac:
# there are no paths if we've not detected javac.
pass
elif env['PLATFORM'] == 'win32':
+ # on Windows, we have the right path to javac, so look locally
javac_bin_dir = os.path.dirname(javac)
java_inc_dir = os.path.normpath(os.path.join(javac_bin_dir, '..', 'include'))
paths = [java_inc_dir, os.path.join(java_inc_dir, 'win32')]
elif env['PLATFORM'] == 'darwin':
if not version:
- paths = [java_macos_include_dir]
+ paths = [java_macos_include_dir_glob]
else:
- paths = sorted(glob.glob(java_macos_version_include_dir%version))
+ paths = sorted(glob.glob(java_macos_version_include_dir_glob % version))
else:
- base_paths=[]
+ base_paths = []
if not version:
- for p in java_linux_include_dirs:
+ for p in java_linux_include_dirs_glob:
base_paths.extend(glob.glob(p))
else:
- for p in java_linux_version_include_dirs:
- base_paths.extend(glob.glob(p%version))
+ for p in java_linux_version_include_dirs_glob:
+ base_paths.extend(glob.glob(p % version))
for p in base_paths:
- paths.extend([p, os.path.join(p,'linux')])
-
- #print("PATHS:%s"%paths)
- return paths
-
-
+ paths.extend([p, os.path.join(p, 'linux')])
+ # print("PATHS:%s"%paths)
+ return paths
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py
index c70e445..45a8a0b 100644
--- a/src/engine/SCons/Tool/JavaCommonTests.py
+++ b/src/engine/SCons/Tool/JavaCommonTests.py
@@ -21,15 +21,17 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/JavaCommonTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/JavaCommonTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
import unittest
+import fnmatch
import SCons.Scanner.IDL
import SCons.Tool.JavaCommon
+import TestSCons
# Adding trace=trace to any of the parse_jave() calls below will cause
# the parser to spit out trace messages of the tokens it sees and the
@@ -607,6 +609,76 @@ public class AnonDemo {
pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '1.8')
assert expect == classes, (expect, classes)
+ def test_jdk_globs(self):
+ """
+ Verify that the java path globs work with specific examples.
+ :return:
+ """
+ from SCons.Tool.JavaCommon import java_linux_include_dirs_glob, java_linux_version_include_dirs_glob, java_win32_dir_glob, java_win32_version_dir_glob, java_macos_include_dir_glob, java_macos_version_include_dir_glob
+
+ # Test windows globs
+ win_java_dirs = [
+ ('C:/Program Files/Java/jdk1.8.0_201/bin', '1.8.0'),
+ ('C:/Program Files/Java/jdk-11.0.2/bin', '11.0.2'),
+ ('C:/Program Files/Java/jdk1.7.0_80/bin', '1.7.0')
+ ]
+
+ for (wjd, version) in win_java_dirs:
+ if not fnmatch.fnmatch(wjd, java_win32_dir_glob):
+ self.fail("Didn't properly match %s with pattern %s" % (wjd, java_win32_dir_glob))
+ if not fnmatch.fnmatch(wjd, java_win32_version_dir_glob % version):
+ self.fail("Didn't properly match %s with version (%s) specific pattern %s" % (
+ wjd, version, java_win32_version_dir_glob % version))
+
+ non_win_java_include_dirs = [
+ ('/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/include', '1.8.0'),
+ ('/usr/lib/jvm/java-1.8.0-openjdk-amd64/include', '1.8.0'),
+ ('/usr/lib/jvm/java-8-openjdk-amd64/include', '8'),
+ ]
+
+ # Test non-windows/non-macos globs
+ for (wjd, version) in non_win_java_include_dirs:
+ match = False
+ globs_tried =[]
+ for jlig in java_linux_include_dirs_glob:
+ globs_tried.append(jlig)
+
+ if fnmatch.fnmatch(wjd, jlig):
+ match = True
+ break
+
+ if not match:
+ self.fail("Didn't properly match %s with pattern %s" % (wjd, globs_tried))
+
+ match = False
+ globs_tried = []
+ for jlvig in java_linux_version_include_dirs_glob:
+ globs_tried.append(jlvig%version)
+ if fnmatch.fnmatch(wjd, jlvig % version):
+ match = True
+ break
+
+ if not match:
+ self.fail("Didn't properly match %s with version (%s) specific pattern %s" % (
+ wjd, version, globs_tried))
+
+ # Test macos globs
+ # Test windows globs
+ macos_java_dirs = [
+ # ('/System/Library/Frameworks/JavaVM.framework/Headers/', None),
+ ('/System/Library/Frameworks/JavaVM.framework/Versions/11.0.2/Headers/', '11.0.2'),
+ ]
+
+ if not fnmatch.fnmatch('/System/Library/Frameworks/JavaVM.framework/Headers/', java_macos_include_dir_glob):
+ self.fail("Didn't properly match %s with pattern %s" % ('/System/Library/Frameworks/JavaVM.framework/Headers/', java_macos_include_dir_glob))
+
+ for (wjd, version) in macos_java_dirs:
+ if not fnmatch.fnmatch(wjd, java_macos_version_include_dir_glob % version):
+ self.fail("Didn't properly match %s with version (%s) specific pattern %s" % (
+ wjd, version, java_macos_version_include_dir_glob % version))
+
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/src/engine/SCons/Tool/MSCommon/__init__.py b/src/engine/SCons/Tool/MSCommon/__init__.py
index 7faff33..e3c4471 100644
--- a/src/engine/SCons/Tool/MSCommon/__init__.py
+++ b/src/engine/SCons/Tool/MSCommon/__init__.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/MSCommon/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """
Common functions for Microsoft Visual Studio and Visual C/C++.
diff --git a/src/engine/SCons/Tool/MSCommon/arch.py b/src/engine/SCons/Tool/MSCommon/arch.py
index 6965fbf..6312541 100644
--- a/src/engine/SCons/Tool/MSCommon/arch.py
+++ b/src/engine/SCons/Tool/MSCommon/arch.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/MSCommon/arch.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/arch.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Module to define supported Windows chip architectures.
"""
diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py
index c8db141..8353944 100644
--- a/src/engine/SCons/Tool/MSCommon/common.py
+++ b/src/engine/SCons/Tool/MSCommon/common.py
@@ -25,7 +25,7 @@ Common helper functions for working with the Microsoft tool chain.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/MSCommon/common.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/common.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import copy
import os
@@ -34,7 +34,6 @@ import re
import SCons.Util
-
LOGFILE = os.environ.get('SCONS_MSCOMMON_DEBUG')
if LOGFILE == '-':
def debug(message):
@@ -117,7 +116,7 @@ def normalize_env(env, keys, force=False):
normenv[k] = copy.deepcopy(env[k])
for k in keys:
- if k in os.environ and (force or not k in normenv):
+ if k in os.environ and (force or k not in normenv):
normenv[k] = os.environ[k]
# This shouldn't be necessary, since the default environment should include system32,
diff --git a/src/engine/SCons/Tool/MSCommon/netframework.py b/src/engine/SCons/Tool/MSCommon/netframework.py
index 01bb5b7..edd9fd9 100644
--- a/src/engine/SCons/Tool/MSCommon/netframework.py
+++ b/src/engine/SCons/Tool/MSCommon/netframework.py
@@ -20,7 +20,7 @@
# 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/Tool/MSCommon/netframework.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/netframework.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """
"""
@@ -68,7 +68,7 @@ def query_versions():
# sequence comparison in python is lexicographical
# which is exactly what we want.
# Note we sort backwards so the highest version is first.
- return cmp(bbl,aal)
+ return (aal > bbl) - (aal < bbl)
versions.sort(versrt)
else:
diff --git a/src/engine/SCons/Tool/MSCommon/sdk.py b/src/engine/SCons/Tool/MSCommon/sdk.py
index 2814d97..e664a30 100644
--- a/src/engine/SCons/Tool/MSCommon/sdk.py
+++ b/src/engine/SCons/Tool/MSCommon/sdk.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/MSCommon/sdk.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/sdk.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Module to detect the Platform/Windows SDK
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 5de85d6..fa7be96 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -30,7 +30,7 @@
# * test on 64 bits XP + VS 2005 (and VS 6 if possible)
# * SDK
# * Assembly
-__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Module for Visual C/C++ detection and configuration.
"""
@@ -60,7 +60,10 @@ class VisualCException(Exception):
class UnsupportedVersion(VisualCException):
pass
-class UnsupportedArch(VisualCException):
+class MSVCUnsupportedHostArch(VisualCException):
+ pass
+
+class MSVCUnsupportedTargetArch(VisualCException):
pass
class MissingConfiguration(VisualCException):
@@ -89,17 +92,15 @@ _ARCH_TO_CANONICAL = {
"aarch64" : "arm64",
}
-# get path to the cl.exe dir for newer VS versions
-# based off a tuple of (host, target) platforms
_HOST_TARGET_TO_CL_DIR_GREATER_THAN_14 = {
- ("amd64","amd64") : "Hostx64\\x64",
- ("amd64","x86") : "Hostx64\\x86",
- ("amd64","arm") : "Hostx64\\arm",
- ("amd64","arm64") : "Hostx64\\arm64",
- ("x86","amd64") : "Hostx86\\x64",
- ("x86","x86") : "Hostx86\\x86",
- ("x86","arm") : "Hostx86\\arm",
- ("x86","arm64") : "Hostx86\\arm64",
+ ("amd64","amd64") : ("Hostx64","x64"),
+ ("amd64","x86") : ("Hostx64","x86"),
+ ("amd64","arm") : ("Hostx64","arm"),
+ ("amd64","arm64") : ("Hostx64","arm64"),
+ ("x86","amd64") : ("Hostx86","x64"),
+ ("x86","x86") : ("Hostx86","x86"),
+ ("x86","arm") : ("Hostx86","arm"),
+ ("x86","arm64") : ("Hostx86","arm64"),
}
# get path to the cl.exe dir for older VS versions
@@ -174,25 +175,33 @@ def get_host_target(env):
try:
host = _ARCH_TO_CANONICAL[host_platform.lower()]
- except KeyError as e:
+ except KeyError:
msg = "Unrecognized host architecture %s"
- raise ValueError(msg % repr(host_platform))
+ raise MSVCUnsupportedHostArch(msg % repr(host_platform))
try:
target = _ARCH_TO_CANONICAL[target_platform.lower()]
- except KeyError as e:
+ except KeyError:
all_archs = str(list(_ARCH_TO_CANONICAL.keys()))
- raise ValueError("Unrecognized target architecture %s\n\tValid architectures: %s" % (target_platform, all_archs))
+ raise MSVCUnsupportedTargetArch("Unrecognized target architecture %s\n\tValid architectures: %s" % (target_platform, all_archs))
return (host, target,req_target_platform)
# If you update this, update SupportedVSList in Tool/MSCommon/vs.py, and the
# MSVC_VERSION documentation in Tool/msvc.xml.
-_VCVER = ["14.1", "14.0", "14.0Exp", "12.0", "12.0Exp", "11.0", "11.0Exp", "10.0", "10.0Exp", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"]
+_VCVER = ["14.2", "14.1", "14.0", "14.0Exp", "12.0", "12.0Exp", "11.0", "11.0Exp", "10.0", "10.0Exp", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"]
+
+# if using vswhere, a further mapping is needed
+_VCVER_TO_VSWHERE_VER = {
+ '14.2' : '[16.0, 17.0)',
+ '14.1' : '[15.0, 16.0)',
+}
_VCVER_TO_PRODUCT_DIR = {
+ '14.2' : [
+ (SCons.Util.HKEY_LOCAL_MACHINE, r'')], # VS 2019 doesn't set this key
'14.1' : [
- (SCons.Util.HKEY_LOCAL_MACHINE, r'')], # Visual Studio 2017 doesn't set this registry key anymore
+ (SCons.Util.HKEY_LOCAL_MACHINE, r'')], # VS 2017 doesn't set this key
'14.0' : [
(SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\14.0\Setup\VC\ProductDir')],
'14.0Exp' : [
@@ -253,42 +262,40 @@ def msvc_version_to_maj_min(msvc_version):
raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric))
def is_host_target_supported(host_target, msvc_version):
- """Check if the given (host, target) tuple is supported for given version.
+ """Check if (host, target) pair is supported for a VC version.
- Args:
- host_target: tuple
- tuple of (canonalized) host-targets, e.g. ("x86", "amd64")
- for cross compilation from 32 bit Windows to 64 bits.
- msvc_version: str
- msvc version (major.minor, e.g. 10.0)
-
- Returns:
- bool:
-
- Note:
- This only checks whether a given version *may* support the given (host,
+ :note: only checks whether a given version *may* support the given (host,
target), not that the toolchain is actually present on the machine.
+ :param tuple host_target: canonalized host-targets pair, e.g.
+ ("x86", "amd64") for cross compilation from 32 bit Windows to 64 bits.
+ :param str msvc_version: Visual C++ version (major.minor), e.g. "10.0"
+ :returns: True or False
"""
# We assume that any Visual Studio version supports x86 as a target
if host_target[1] != "x86":
maj, min = msvc_version_to_maj_min(msvc_version)
if maj < 8:
return False
-
return True
def find_vc_pdir_vswhere(msvc_version):
"""
- Find the MSVC product directory using vswhere.exe.
+ Find the MSVC product directory using the vswhere program.
- Run it asking for specified version and get MSVS install location
- :param msvc_version:
+ :param msvc_version: MSVC version to search for
:return: MSVC install dir or None
+ :raises UnsupportedVersion: if the version is not known by this file
"""
+ try:
+ vswhere_version = _VCVER_TO_VSWHERE_VER[msvc_version]
+ except KeyError:
+ debug("Unknown version of MSVC: %s" % msvc_version)
+ raise UnsupportedVersion("Unknown version %s" % msvc_version)
+
# For bug 3333 - support default location of vswhere for both 64 and 32 bit windows
- # installs.
+ # installs.
for pf in ['Program Files (x86)', 'Program Files']:
vswhere_path = os.path.join(
'C:\\',
@@ -300,31 +307,36 @@ def find_vc_pdir_vswhere(msvc_version):
if os.path.exists(vswhere_path):
# If we found vswhere, then use it.
break
+ else:
+ # No vswhere on system, no install info available
+ return None
- vswhere_cmd = [vswhere_path, '-products', '*', '-version', msvc_version, '-property', 'installationPath']
-
- if os.path.exists(vswhere_path):
- #TODO PY27 cannot use Popen as context manager
- # try putting it back to the old way for now
- sp = subprocess.Popen(vswhere_cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- vsdir, err = sp.communicate()
- if vsdir:
- vsdir = vsdir.decode("mbcs").splitlines()
- # vswhere could easily return multiple lines
- # we could define a way to pick the one we prefer, but since
- # this data is currently only used to make a check for existence,
- # returning the first hit should be good enough for now.
- vc_pdir = os.path.join(vsdir[0], 'VC')
- return vc_pdir
+ vswhere_cmd = [vswhere_path,
+ '-products', '*',
+ '-version', vswhere_version,
+ '-property', 'installationPath']
+
+ #TODO PY27 cannot use Popen as context manager
+ # try putting it back to the old way for now
+ sp = subprocess.Popen(vswhere_cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ vsdir, err = sp.communicate()
+ if vsdir:
+ vsdir = vsdir.decode("mbcs").splitlines()
+ # vswhere could easily return multiple lines
+ # we could define a way to pick the one we prefer, but since
+ # this data is currently only used to make a check for existence,
+ # returning the first hit should be good enough for now.
+ vc_pdir = os.path.join(vsdir[0], 'VC')
+ return vc_pdir
else:
# No vswhere on system, no install info available
return None
def find_vc_pdir(msvc_version):
- """Find the product directory for the given version.
+ """Find the MSVC product directory for the given version.
Tries to look up the path using a registry key from the table
_VCVER_TO_PRODUCT_DIR; if there is no key, calls find_vc_pdir_wshere
@@ -425,6 +437,8 @@ def find_batch_file(env,msvc_version,host_arch,target_arch):
__INSTALLED_VCS_RUN = None
+_VC_TOOLS_VERSION_FILE_PATH = ['Auxiliary', 'Build', 'Microsoft.VCToolsVersion.default.txt']
+_VC_TOOLS_VERSION_FILE = os.sep.join(_VC_TOOLS_VERSION_FILE_PATH)
def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
"""Find the cl.exe on the filesystem in the vc_dir depending on
@@ -459,7 +473,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
host_platform = _ARCH_TO_CANONICAL[host_platform]
target_platform = _ARCH_TO_CANONICAL[target_platform]
- debug('_check_cl_exists_in_vc_dir(): host platform %s, target platform %s' % (host_platform, target_platform))
+ debug('_check_cl_exists_in_vc_dir(): host platform %s, target platform %s for version %s' % (host_platform, target_platform, msvc_version))
ver_num = float(get_msvc_version_numeric(msvc_version))
@@ -468,7 +482,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
# 2017 and newer allowed multiple versions of the VC toolset to be installed at the same time.
# Just get the default tool version for now
#TODO: support setting a specific minor VC version
- default_toolset_file = os.path.join(vc_dir, r'Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')
+ default_toolset_file = os.path.join(vc_dir, _VC_TOOLS_VERSION_FILE)
try:
with open(default_toolset_file) as f:
vc_specific_version = f.readlines()[0].strip()
@@ -480,11 +494,11 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
return False
host_trgt_dir = _HOST_TARGET_TO_CL_DIR_GREATER_THAN_14.get((host_platform, target_platform), None)
- if not host_trgt_dir:
- debug('_check_cl_exists_in_vc_dir(): unsupported host/target platform combo')
+ if host_trgt_dir is None:
+ debug('_check_cl_exists_in_vc_dir(): unsupported host/target platform combo: (%s,%s)'%(host_platform, target_platform))
return False
- cl_path = os.path.join(vc_dir, r'Tools\MSVC', vc_specific_version, 'bin', host_trgt_dir, _CL_EXE_NAME)
+ cl_path = os.path.join(vc_dir, 'Tools','MSVC', vc_specific_version, 'bin', host_trgt_dir[0], host_trgt_dir[1], _CL_EXE_NAME)
debug('_check_cl_exists_in_vc_dir(): checking for ' + _CL_EXE_NAME + ' at ' + cl_path)
if os.path.exists(cl_path):
debug('_check_cl_exists_in_vc_dir(): found ' + _CL_EXE_NAME + '!')
@@ -492,8 +506,10 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
elif ver_num <= 14 and ver_num >= 8:
+ # Set default value to be -1 as "" which is the value for x86/x86 yields true when tested
+ # if not host_trgt_dir
host_trgt_dir = _HOST_TARGET_TO_CL_DIR.get((host_platform, target_platform), None)
- if not host_trgt_dir:
+ if host_trgt_dir is None:
debug('_check_cl_exists_in_vc_dir(): unsupported host/target platform combo')
return False
@@ -505,8 +521,11 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
# older versions of visual studio only had x86 binaries,
# so if the host platform is amd64, we need to check cross
# compile options (x86 binary compiles some other target on a 64 bit os)
+
+ # Set default value to be -1 as "" which is the value for x86/x86 yields true when tested
+ # if not host_trgt_dir
host_trgt_dir = _HOST_TARGET_TO_CL_DIR.get(('x86', target_platform), None)
- if not host_trgt_dir:
+ if host_trgt_dir is None:
return False
cl_path = os.path.join(vc_dir, 'bin', host_trgt_dir, _CL_EXE_NAME)
@@ -554,6 +573,10 @@ def get_installed_vcs(env=None):
debug('find_vc_pdir no compiler found %s' % ver)
else:
debug('find_vc_pdir return None for ver %s' % ver)
+ except (MSVCUnsupportedTargetArch, MSVCUnsupportedHostArch):
+ # Allow this exception to propagate further as it should cause
+ # SCons to exit with an error code
+ raise
except VisualCException as e:
debug('did not find VC %s: caught exception %s' % (ver, str(e)))
return installed_versions
diff --git a/src/engine/SCons/Tool/MSCommon/vcTests.py b/src/engine/SCons/Tool/MSCommon/vcTests.py
new file mode 100644
index 0000000..25537f3
--- /dev/null
+++ b/src/engine/SCons/Tool/MSCommon/vcTests.py
@@ -0,0 +1,180 @@
+#
+# 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
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# 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.
+#
+# from typing import Dict, Any
+
+__revision__ = "src/engine/SCons/Tool/MSCommon/vcTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+
+import os
+import os.path
+import unittest
+
+import SCons.Node.FS
+import SCons.Warnings
+import SCons.Tool.MSCommon.vc
+
+import TestCmd
+
+original = os.getcwd()
+
+test = TestCmd.TestCmd(workdir='')
+
+os.chdir(test.workpath(''))
+
+MSVCUnsupportedHostArch = SCons.Tool.MSCommon.vc.MSVCUnsupportedHostArch
+MSVCUnsupportedTargetArch = SCons.Tool.MSCommon.vc.MSVCUnsupportedTargetArch
+
+MS_TOOLS_VERSION='1.1.1'
+
+class MSVcTestCase(unittest.TestCase):
+
+ @staticmethod
+ def _createDummyCl(path, add_bin=True):
+ """
+ Creates a dummy cl.ex in the correct directory.
+ It will create all missing parent directories as well
+
+ Args:
+ path: Relative path to cl.exe for the version about to be tested.
+ """
+
+ # print("PATH:%s"%path)
+
+ path = path.replace('\\', os.sep)
+ if add_bin:
+ create_path = os.path.join(path,'bin')
+ else:
+ create_path = path
+ if create_path and not os.path.isdir(create_path):
+ os.makedirs(create_path)
+
+ create_this = os.path.join(create_path,'cl.exe')
+
+ # print("Creating: %s"%create_this)
+ with open(create_this,'w') as ct:
+ ct.write('created')
+
+
+
+
+ def runTest(self):
+ """
+ Check that all proper HOST_PLATFORM and TARGET_PLATFORM are handled.
+ Verify that improper HOST_PLATFORM and/or TARGET_PLATFORM are properly handled.
+ by SCons.Tool.MSCommon.vc._check_cl_exists_in_vc_dir()
+ """
+
+ check = SCons.Tool.MSCommon.vc._check_cl_exists_in_vc_dir
+
+ env={'TARGET_ARCH':'x86'}
+ p = SCons.Tool.MSCommon.vc._HOST_TARGET_TO_CL_DIR[('x86','x86')]
+ MSVcTestCase._createDummyCl(p)
+
+ # print("retval:%s"%check(env, '.', '8.0'))
+
+
+ # Setup for VC 14+ tests
+
+ # Create the VC minor/major version file
+ tools_version_file = SCons.Tool.MSCommon.vc._VC_TOOLS_VERSION_FILE
+ tools_dir = os.path.dirname(tools_version_file)
+ if not os.path.isdir(tools_dir):
+ os.makedirs(tools_dir)
+ try:
+ with open(tools_version_file, 'w') as tf:
+ tf.write(MS_TOOLS_VERSION)
+ except IOError as e:
+ print("Failed trying to write :%s :%s"%(tools_version_file, e))
+
+
+ # Now walk all the valid combinations of host/target for VC 14 +
+ vc_gt_14_map = SCons.Tool.MSCommon.vc._HOST_TARGET_TO_CL_DIR_GREATER_THAN_14
+
+ for key, value in vc_gt_14_map.items():
+ # print("GT 14 Got: %s -> %s"%(key,value))
+
+ env={'TARGET_ARCH':key[1], 'HOST_ARCH':key[0]}
+ path = os.path.join('.','Tools','MSVC', MS_TOOLS_VERSION, 'bin', value[0], value[1])
+ MSVcTestCase._createDummyCl(path, add_bin=False)
+ result=check(env, '.', '14.1')
+ # print("for:%s got :%s"%(key[1], result))
+ self.assertTrue(result, "Checking host: %s target: %s"%(value[0], value[1]))
+
+ # Now test bogus value for HOST_ARCH
+ env={'TARGET_ARCH':'x86', 'HOST_ARCH':'GARBAGE'}
+ try:
+ result=check(env, '.', '14.1')
+ # print("for:%s got :%s"%(env, result))
+ self.assertFalse(result, "Did not fail with bogus HOST_ARCH host: %s target: %s"%(value[0], value[1]))
+ except MSVCUnsupportedHostArch:
+ pass
+ else:
+ self.fail('Did not fail when HOST_ARCH specified as: %s'%env['HOST_ARCH'])
+
+ # Now test bogus value for TARGET_ARCH
+ env={'TARGET_ARCH':'GARBAGE', 'HOST_ARCH':'x86'}
+ try:
+ result=check(env, '.', '14.1')
+ # print("for:%s got :%s"%(env, result))
+ self.assertFalse(result, "Did not fail with bogus TARGET_ARCH host: %s target: %s"%(value[0], value[1]))
+ except MSVCUnsupportedTargetArch:
+ pass
+ else:
+ self.fail('Did not fail when HOST_ARCH specified as: %s'%env['TARGET_ARCH'])
+
+ # Test >8 < 14 VC versions
+ vc_map = SCons.Tool.MSCommon.vc._HOST_TARGET_TO_CL_DIR
+ for key,value in vc_map.items():
+ # print("LT 14 Got: %s -> %s"%(key,value))
+ env={'TARGET_ARCH':key[1], 'HOST_ARCH':key[0]}
+ path = os.path.join('.', 'bin', value )
+ MSVcTestCase._createDummyCl(path, add_bin=False)
+ result=check(env, '.', '9.0')
+ # print("for:%s got :%s"%(key[1], result))
+ self.assertTrue(result, "Checking host: %s target: %s"%(key[0], key[1]))
+
+ # Now test bogus value for HOST_ARCH
+ env={'TARGET_ARCH':'x86', 'HOST_ARCH':'GARBAGE'}
+ try:
+ result=check(env, '.', '9.0')
+ # print("for:%s got :%s"%(env, result))
+ self.assertFalse(result, "Did not fail with bogus HOST_ARCH host: %s target: %s"%(env['HOST_ARCH'], env['TARGET_ARCH']))
+ except MSVCUnsupportedHostArch:
+ pass
+ else:
+ self.fail('Did not fail when HOST_ARCH specified as: %s'%env['HOST_ARCH'])
+
+ # Now test bogus value for TARGET_ARCH
+ env={'TARGET_ARCH':'GARBAGE', 'HOST_ARCH':'x86'}
+ try:
+ result=check(env, '.', '9.0')
+ # print("for:%s got :%s"%(env, result))
+ self.assertFalse(result, "Did not fail with bogus TARGET_ARCH host: %s target: %s"%(env['HOST_ARCH'], env['TARGET_ARCH']))
+ except MSVCUnsupportedTargetArch:
+ pass
+ else:
+ self.fail('Did not fail when HOST_ARCH specified as: %s'%env['TARGET_ARCH'])
+
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py
index 72d4421..731f328 100644
--- a/src/engine/SCons/Tool/MSCommon/vs.py
+++ b/src/engine/SCons/Tool/MSCommon/vs.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/MSCommon/vs.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/vs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Module to detect Visual Studio and/or Visual C/C++
"""
@@ -198,6 +198,17 @@ class VisualStudio(object):
# Tool/MSCommon/vc.py, and the MSVC_VERSION documentation in Tool/msvc.xml.
SupportedVSList = [
+ # Visual Studio 2019
+ VisualStudio('14.2',
+ vc_version='14.2',
+ sdk_version='10.0A',
+ hkeys=[],
+ common_tools_var='VS160COMNTOOLS',
+ executable_path=r'Common7\IDE\devenv.com',
+ batch_file_path=r'VC\Auxiliary\Build\vsvars32.bat',
+ supported_arch=['x86', 'amd64', "arm"],
+ ),
+
# Visual Studio 2017
VisualStudio('14.1',
vc_version='14.1',
@@ -520,7 +531,7 @@ def get_default_arch(env):
if not msvs:
arch = 'x86'
- elif not arch in msvs.get_supported_arch():
+ elif arch not in msvs.get_supported_arch():
fmt = "Visual Studio version %s does not support architecture %s"
raise SCons.Errors.UserError(fmt % (env['MSVS_VERSION'], arch))
diff --git a/src/engine/SCons/Tool/PharLapCommon.py b/src/engine/SCons/Tool/PharLapCommon.py
index 103e21c..623f2a8 100644
--- a/src/engine/SCons/Tool/PharLapCommon.py
+++ b/src/engine/SCons/Tool/PharLapCommon.py
@@ -29,7 +29,7 @@ Phar Lap ETS tool chain. Right now, this is linkloc and
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/PharLapCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/PharLapCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -79,7 +79,8 @@ def getPharLapVersion():
include_path = os.path.join(getPharLapPath(), os.path.normpath("include/embkern.h"))
if not os.path.exists(include_path):
raise SCons.Errors.UserError("Cannot find embkern.h in ETS include directory.\nIs Phar Lap ETS installed properly?")
- mo = REGEX_ETS_VER.search(open(include_path, 'r').read())
+ with open(include_path, 'r') as f:
+ mo = REGEX_ETS_VER.search(f.read())
if mo:
return int(mo.group(1))
# Default return for Phar Lap 9.1
diff --git a/src/engine/SCons/Tool/ToolTests.py b/src/engine/SCons/Tool/ToolTests.py
index 81b6491..25e9b2d 100644
--- a/src/engine/SCons/Tool/ToolTests.py
+++ b/src/engine/SCons/Tool/ToolTests.py
@@ -21,8 +21,9 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ToolTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ToolTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+import os
import sys
import unittest
@@ -31,29 +32,49 @@ import TestUnit
import SCons.Errors
import SCons.Tool
+
+class DummyEnvironment(object):
+ def __init__(self):
+ self.dict = {}
+ def Detect(self, progs):
+ if not SCons.Util.is_List(progs):
+ progs = [ progs ]
+ return progs[0]
+ def Append(self, **kw):
+ self.dict.update(kw)
+ def __getitem__(self, key):
+ return self.dict[key]
+ def __setitem__(self, key, val):
+ self.dict[key] = val
+ def __contains__(self, key):
+ return self.dict.__contains__(key)
+ def has_key(self, key):
+ return key in self.dict
+ def subst(self, string, *args, **kwargs):
+ return string
+
+ PHONY_PATH = "/usr/phony/bin"
+ def WhereIs(self, key_program):
+ # for pathfind test for Issue #3336:
+ # need to fake the case where extra paths are searched, and
+ # if one has a "hit" after some fails, the fails are left in
+ # the environment's PATH. So construct a positive answer if
+ # we see a magic known path component in PATH; answer in
+ # the negative otherwise.
+ paths = self['ENV']['PATH']
+ if self.PHONY_PATH in paths:
+ return os.path.join(self.PHONY_PATH, key_program)
+ return None
+ def AppendENVPath(self, pathvar, path):
+ # signature matches how called from find_program_path()
+ self['ENV'][pathvar] = self['ENV'][pathvar] + os.pathsep + path
+
+
class ToolTestCase(unittest.TestCase):
def test_Tool(self):
"""Test the Tool() function"""
- class Environment(object):
- def __init__(self):
- self.dict = {}
- def Detect(self, progs):
- if not SCons.Util.is_List(progs):
- progs = [ progs ]
- return progs[0]
- def Append(self, **kw):
- self.dict.update(kw)
- def __getitem__(self, key):
- return self.dict[key]
- def __setitem__(self, key, val):
- self.dict[key] = val
- def __contains__(self, key):
- return self.dict.__contains__(key)
- def has_key(self, key):
- return key in self.dict
- def subst(self, string, *args, **kwargs):
- return string
- env = Environment()
+
+ env = DummyEnvironment()
env['BUILDERS'] = {}
env['ENV'] = {}
env['PLATFORM'] = 'test'
@@ -67,17 +88,34 @@ class ToolTestCase(unittest.TestCase):
SCons.Tool.Tool()
except TypeError:
pass
- else:
+ else: # TODO pylint E0704: bare raise not inside except
raise
try:
p = SCons.Tool.Tool('_does_not_exist_')
- except SCons.Errors.EnvironmentError:
+ except SCons.Errors.SConsEnvironmentError:
pass
- else:
+ else: # TODO pylint E0704: bare raise not inside except
raise
+ def test_pathfind(self):
+ """Test that find_program_path() does not alter PATH"""
+
+ env = DummyEnvironment()
+ PHONY_PATHS = [
+ r'C:\cygwin64\bin',
+ r'C:\cygwin\bin',
+ '/usr/local/dummy/bin',
+ env.PHONY_PATH, # will be recognized by dummy WhereIs
+ ]
+ env['ENV'] = {}
+ env['ENV']['PATH'] = '/usr/local/bin:/opt/bin:/bin:/usr/bin'
+ pre_path = env['ENV']['PATH']
+ _ = SCons.Tool.find_program_path(env, 'no_tool', default_paths=PHONY_PATHS)
+ assert env['ENV']['PATH'] == pre_path, env['ENV']['PATH']
+
+
if __name__ == "__main__":
suite = unittest.makeSuite(ToolTestCase, 'test_')
TestUnit.run(suite)
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index b7d5dcc..271f214 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -35,10 +35,8 @@ tool definition.
# 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/Tool/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
-import imp
-import importlib
import sys
import re
import os
@@ -53,7 +51,12 @@ import SCons.Scanner.D
import SCons.Scanner.LaTeX
import SCons.Scanner.Prog
import SCons.Scanner.SWIG
-import collections
+try:
+ # Python 3
+ from collections.abc import Callable
+except ImportError:
+ # Python 2.7
+ from collections import Callable
DefaultToolpath = []
@@ -106,7 +109,9 @@ TOOL_ALIASES = {
class Tool(object):
- def __init__(self, name, toolpath=[], **kw):
+ def __init__(self, name, toolpath=None, **kw):
+ if toolpath is None:
+ toolpath = []
# Rename if there's a TOOL_ALIAS for this tool
self.name = TOOL_ALIASES.get(name, name)
@@ -121,6 +126,8 @@ class Tool(object):
self.options = module.options
def _load_dotted_module_py2(self, short_name, full_name, searchpaths=None):
+ import imp
+
splitname = short_name.split('.')
index = 0
srchpths = searchpaths
@@ -149,7 +156,7 @@ class Tool(object):
except ImportError as e:
splitname = self.name.split('.')
if str(e) != "No module named %s" % splitname[0]:
- raise SCons.Errors.EnvironmentError(e)
+ raise SCons.Errors.SConsEnvironmentError(e)
try:
import zipimport
except ImportError:
@@ -211,13 +218,13 @@ class Tool(object):
if spec is None:
error_string = "No module named %s" % self.name
- raise SCons.Errors.EnvironmentError(error_string)
+ raise SCons.Errors.SConsEnvironmentError(error_string)
module = importlib.util.module_from_spec(spec)
if module is None:
if debug: print("MODULE IS NONE:%s" % self.name)
error_string = "No module named %s" % self.name
- raise SCons.Errors.EnvironmentError(error_string)
+ raise SCons.Errors.SConsEnvironmentError(error_string)
# Don't reload a tool we already loaded.
sys_modules_value = sys.modules.get(found_name, False)
@@ -258,7 +265,7 @@ class Tool(object):
return module
except ImportError as e:
if str(e) != "No module named %s" % self.name:
- raise SCons.Errors.EnvironmentError(e)
+ raise SCons.Errors.SConsEnvironmentError(e)
try:
import zipimport
importer = zipimport.zipimporter(sys.modules['SCons.Tool'].__path__[0])
@@ -267,10 +274,10 @@ class Tool(object):
return module
except ImportError as e:
m = "No tool named '%s': %s" % (self.name, e)
- raise SCons.Errors.EnvironmentError(m)
+ raise SCons.Errors.SConsEnvironmentError(m)
except ImportError as e:
m = "No tool named '%s': %s" % (self.name, e)
- raise SCons.Errors.EnvironmentError(m)
+ raise SCons.Errors.SConsEnvironmentError(m)
def __call__(self, env, *args, **kw):
if self.init_kw is not None:
@@ -376,7 +383,7 @@ def _call_linker_cb(env, callback, args, result=None):
if Verbose:
print('_call_linker_cb: env["LINKCALLBACKS"][%r] found' % callback)
print('_call_linker_cb: env["LINKCALLBACKS"][%r]=%r' % (callback, cbfun))
- if isinstance(cbfun, collections.Callable):
+ if isinstance(cbfun, Callable):
if Verbose:
print('_call_linker_cb: env["LINKCALLBACKS"][%r] is callable' % callback)
result = cbfun(env, *args)
@@ -394,7 +401,8 @@ def _call_env_subst(env, string, *args, **kw):
class _ShLibInfoSupport(object):
- def get_libtype(self):
+ @property
+ def libtype(self):
return 'ShLib'
def get_lib_prefix(self, env, *args, **kw):
@@ -411,7 +419,8 @@ class _ShLibInfoSupport(object):
class _LdModInfoSupport(object):
- def get_libtype(self):
+ @property
+ def libtype(self):
return 'LdMod'
def get_lib_prefix(self, env, *args, **kw):
@@ -428,7 +437,8 @@ class _LdModInfoSupport(object):
class _ImpLibInfoSupport(object):
- def get_libtype(self):
+ @property
+ def libtype(self):
return 'ImpLib'
def get_lib_prefix(self, env, *args, **kw):
@@ -480,25 +490,21 @@ class _LibInfoGeneratorBase(object):
'ImpLib': _ImpLibInfoSupport}
def __init__(self, libtype, infoname):
- self.set_libtype(libtype)
- self.set_infoname(infoname)
+ self.libtype = libtype
+ self.infoname = infoname
+
+ @property
+ def libtype(self):
+ return self._support.libtype
- def set_libtype(self, libtype):
+ @libtype.setter
+ def libtype(self, libtype):
try:
support_class = self._support_classes[libtype]
except KeyError:
raise ValueError('unsupported libtype %r' % libtype)
self._support = support_class()
- def get_libtype(self):
- return self._support.get_libtype()
-
- def set_infoname(self, infoname):
- self.infoname = infoname
-
- def get_infoname(self):
- return self.infoname
-
def get_lib_prefix(self, env, *args, **kw):
return self._support.get_lib_prefix(env, *args, **kw)
@@ -518,9 +524,8 @@ class _LibInfoGeneratorBase(object):
try:
libtype = kw['generator_libtype']
except KeyError:
- libtype = self.get_libtype()
- infoname = self.get_infoname()
- return 'Versioned%s%s' % (libtype, infoname)
+ libtype = self.libtype
+ return 'Versioned%s%s' % (libtype, self.infoname)
def generate_versioned_lib_info(self, env, args, result=None, **kw):
callback = self.get_versioned_lib_info_generator(**kw)
@@ -730,7 +735,7 @@ class _LibSonameGenerator(_LibInfoGeneratorBase):
if not soname:
# fallback to library name (as returned by appropriate _LibNameGenerator)
- soname = _LibNameGenerator(self.get_libtype())(env, libnode)
+ soname = _LibNameGenerator(self.libtype)(env, libnode)
if Verbose:
print("_LibSonameGenerator: FALLBACK: soname=%r" % soname)
@@ -1316,30 +1321,35 @@ def tool_list(platform, env):
return [x for x in tools if x]
-def find_program_path(env, key_program, default_paths=[]):
+def find_program_path(env, key_program, default_paths=None):
"""
- Find the location of key_program and then return the path it was located at.
- Checking the default install locations.
- Mainly for windows where tools aren't all installed in /usr/bin,etc
- :param env: Current Environment()
- :param key_program: Program we're using to locate the directory to add to PATH.
+ Find the location of a tool using various means.
+
+ Mainly for windows where tools aren't all installed in /usr/bin, etc.
+
+ :param env: Current Construction Environment.
+ :param key_program: Tool to locate.
+ :param default_paths: List of additional paths this tool might be found in.
"""
# First search in the SCons path
path = env.WhereIs(key_program)
- if (path):
+ if path:
return path
- # then the OS path:
+
+ # Then in the OS path
path = SCons.Util.WhereIs(key_program)
- if (path):
+ if path:
return path
- # If that doesn't work try default location for mingw
+ # Finally, add the defaults and check again. Do not change
+ # ['ENV']['PATH'] permananetly, the caller can do that if needed.
+ if default_paths is None:
+ return path
save_path = env['ENV']['PATH']
for p in default_paths:
env.AppendENVPath('PATH', p)
path = env.WhereIs(key_program)
- if not path:
- env['ENV']['PATH'] = save_path
+ env['ENV']['PATH'] = save_path
return path
# Local Variables:
diff --git a/src/engine/SCons/Tool/aixc++.py b/src/engine/SCons/Tool/aixc++.py
index be14abc..bafaea4 100644
--- a/src/engine/SCons/Tool/aixc++.py
+++ b/src/engine/SCons/Tool/aixc++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixc++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixc++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
from SCons.Tool.aixcxx import *
diff --git a/src/engine/SCons/Tool/aixcc.py b/src/engine/SCons/Tool/aixcc.py
index a1fe216..349a40a 100644
--- a/src/engine/SCons/Tool/aixcc.py
+++ b/src/engine/SCons/Tool/aixcc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixcc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/aixcxx.py b/src/engine/SCons/Tool/aixcxx.py
index ec2af1a..0830e33 100644
--- a/src/engine/SCons/Tool/aixcxx.py
+++ b/src/engine/SCons/Tool/aixcxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixcxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixcxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/aixf77.py b/src/engine/SCons/Tool/aixf77.py
index 6281b13..d2c619a 100644
--- a/src/engine/SCons/Tool/aixf77.py
+++ b/src/engine/SCons/Tool/aixf77.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixf77.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixf77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py
index ddb4281..ea2949f 100644
--- a/src/engine/SCons/Tool/aixlink.py
+++ b/src/engine/SCons/Tool/aixlink.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixlink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixlink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/applelink.py b/src/engine/SCons/Tool/applelink.py
index 5981d19..011b29d 100644
--- a/src/engine/SCons/Tool/applelink.py
+++ b/src/engine/SCons/Tool/applelink.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/applelink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/applelink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py
index bef719f..459fb55 100644
--- a/src/engine/SCons/Tool/ar.py
+++ b/src/engine/SCons/Tool/ar.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/as.py b/src/engine/SCons/Tool/as.py
index 8deea59..02139c5 100644
--- a/src/engine/SCons/Tool/as.py
+++ b/src/engine/SCons/Tool/as.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/as.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/as.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/bcc32.py b/src/engine/SCons/Tool/bcc32.py
index 1cb0a38..e8ffbbf 100644
--- a/src/engine/SCons/Tool/bcc32.py
+++ b/src/engine/SCons/Tool/bcc32.py
@@ -27,7 +27,7 @@ XXX
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/bcc32.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/bcc32.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/c++.py b/src/engine/SCons/Tool/c++.py
index e670d0d..8819f82 100644
--- a/src/engine/SCons/Tool/c++.py
+++ b/src/engine/SCons/Tool/c++.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/c++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/c++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
diff --git a/src/engine/SCons/Tool/cc.py b/src/engine/SCons/Tool/cc.py
index 9b604c4..698d725 100644
--- a/src/engine/SCons/Tool/cc.py
+++ b/src/engine/SCons/Tool/cc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/cc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/cc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
import SCons.Defaults
diff --git a/src/engine/SCons/Tool/clang.py b/src/engine/SCons/Tool/clang.py
index 69cbbb6..f48afbf 100644
--- a/src/engine/SCons/Tool/clang.py
+++ b/src/engine/SCons/Tool/clang.py
@@ -33,7 +33,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-# __revision__ = "src/engine/SCons/Tool/clang.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+# __revision__ = "src/engine/SCons/Tool/clang.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
# Based on SCons/Tool/gcc.py by Paweł Tomulik 2014 as a separate tool.
# Brought into the SCons mainline by Russel Winder 2017.
@@ -77,7 +77,8 @@ def generate(env):
stdout=subprocess.PIPE)
if pipe.wait() != 0: return
# clang -dumpversion is of no use
- line = pipe.stdout.readline()
+ with pipe.stdout:
+ line = pipe.stdout.readline()
if sys.version_info[0] > 2:
line = line.decode()
match = re.search(r'clang +version +([0-9]+(?:\.[0-9]+)+)', line)
diff --git a/src/engine/SCons/Tool/clangxx.py b/src/engine/SCons/Tool/clangxx.py
index 7899228..d88874e 100644
--- a/src/engine/SCons/Tool/clangxx.py
+++ b/src/engine/SCons/Tool/clangxx.py
@@ -33,7 +33,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-# __revision__ = "src/engine/SCons/Tool/clangxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+# __revision__ = "src/engine/SCons/Tool/clangxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
# Based on SCons/Tool/g++.py by Paweł Tomulik 2014 as a separate tool.
# Brought into the SCons mainline by Russel Winder 2017.
@@ -85,7 +85,8 @@ def generate(env):
return
# clang -dumpversion is of no use
- line = pipe.stdout.readline()
+ with pipe.stdout:
+ line = pipe.stdout.readline()
if sys.version_info[0] > 2:
line = line.decode()
match = re.search(r'clang +version +([0-9]+(?:\.[0-9]+)+)', line)
diff --git a/src/engine/SCons/Tool/cvf.py b/src/engine/SCons/Tool/cvf.py
index bc1e888..aa24d69 100644
--- a/src/engine/SCons/Tool/cvf.py
+++ b/src/engine/SCons/Tool/cvf.py
@@ -27,7 +27,7 @@ Tool-specific initialization for the Compaq Visual Fortran compiler.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/cvf.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/cvf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import fortran
diff --git a/src/engine/SCons/Tool/cxx.py b/src/engine/SCons/Tool/cxx.py
index 81a67c7..2ac278e 100644
--- a/src/engine/SCons/Tool/cxx.py
+++ b/src/engine/SCons/Tool/cxx.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/cxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/cxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py
index f69b886..c3d78de 100644
--- a/src/engine/SCons/Tool/cyglink.py
+++ b/src/engine/SCons/Tool/cyglink.py
@@ -133,7 +133,7 @@ def _versioned_lib_suffix(env, suffix, version):
if Verbose:
print("_versioned_lib_suffix: suffix= ", suffix)
print("_versioned_lib_suffix: version= ", version)
- cygversion = re.sub('\.', '-', version)
+ cygversion = re.sub(r'\.', '-', version)
if not suffix.startswith('-' + cygversion):
suffix = '-' + cygversion + suffix
if Verbose:
diff --git a/src/engine/SCons/Tool/default.py b/src/engine/SCons/Tool/default.py
index e8aa11b..866b823 100644
--- a/src/engine/SCons/Tool/default.py
+++ b/src/engine/SCons/Tool/default.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/default.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/default.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py
index b281e1c..befcd22 100644
--- a/src/engine/SCons/Tool/dmd.py
+++ b/src/engine/SCons/Tool/dmd.py
@@ -53,7 +53,7 @@ Lib tool variables:
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/dmd.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/dmd.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import subprocess
diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py
index d7d10c0..147556d 100644
--- a/src/engine/SCons/Tool/docbook/__init__.py
+++ b/src/engine/SCons/Tool/docbook/__init__.py
@@ -84,7 +84,7 @@ def __extend_targets_sources(target, source):
source = [source]
if len(target) < len(source):
target.extend(source[len(target):])
-
+
return target, source
def __init_xsl_stylesheet(kw, env, user_xsl_var, default_path):
@@ -94,12 +94,12 @@ def __init_xsl_stylesheet(kw, env, user_xsl_var, default_path):
path_args = [scriptpath, db_xsl_folder] + default_path
xsl_style = os.path.join(*path_args)
kw['DOCBOOK_XSL'] = xsl_style
-
+
def __select_builder(lxml_builder, libxml2_builder, cmdline_builder):
""" Selects a builder, based on which Python modules are present. """
if prefer_xsltproc:
return cmdline_builder
-
+
if not has_libxml2:
# At the moment we prefer libxml2 over lxml, the latter can lead
# to conflicts when installed together with libxml2.
@@ -115,7 +115,7 @@ def __ensure_suffix(t, suffix):
tpath = str(t)
if not tpath.endswith(suffix):
return tpath+suffix
-
+
return t
def __ensure_suffix_stem(t, suffix):
@@ -124,11 +124,11 @@ def __ensure_suffix_stem(t, suffix):
if not tpath.endswith(suffix):
stem = tpath
tpath += suffix
-
+
return tpath, stem
else:
stem, ext = os.path.splitext(tpath)
-
+
return t, stem
def __get_xml_text(root):
@@ -151,7 +151,7 @@ def __create_output_dir(base_dir):
else:
if base_dir.endswith('/'):
dir = base_dir
-
+
if dir and not os.path.isdir(dir):
os.makedirs(dir)
@@ -203,10 +203,10 @@ def _detect(env):
the requested output formats.
"""
global prefer_xsltproc
-
+
if env.get('DOCBOOK_PREFER_XSLTPROC',''):
prefer_xsltproc = True
-
+
if ((not has_libxml2 and not has_lxml) or (prefer_xsltproc)):
# Try to find the XSLT processors
__detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com, xsltproc_com_priority)
@@ -219,15 +219,15 @@ def _detect(env):
#
include_re = re.compile('fileref\\s*=\\s*["|\']([^\\n]*)["|\']')
sentity_re = re.compile('<!ENTITY\\s+%*\\s*[^\\s]+\\s+SYSTEM\\s+["|\']([^\\n]*)["|\']>')
-
+
def __xml_scan(node, env, path, arg):
""" Simple XML file scanner, detecting local images and XIncludes as implicit dependencies. """
# Does the node exist yet?
if not os.path.isfile(str(node)):
return []
-
+
if env.get('DOCBOOK_SCANENT',''):
- # Use simple pattern matching for system entities..., no support
+ # Use simple pattern matching for system entities..., no support
# for recursion yet.
contents = node.get_text_contents()
return sentity_re.findall(contents)
@@ -235,9 +235,9 @@ def __xml_scan(node, env, path, arg):
xsl_file = os.path.join(scriptpath,'utils','xmldepend.xsl')
if not has_libxml2 or prefer_xsltproc:
if has_lxml and not prefer_xsltproc:
-
+
from lxml import etree
-
+
xsl_tree = etree.parse(xsl_file)
doc = etree.parse(str(node))
result = doc.xslt(xsl_tree)
@@ -266,7 +266,7 @@ def __xml_scan(node, env, path, arg):
for x in str(result).splitlines():
if x.strip() != "" and not x.startswith("<?xml "):
depfiles.extend(x.strip().split())
-
+
style.freeStylesheet()
doc.freeDoc()
result.freeDoc()
@@ -282,7 +282,7 @@ docbook_xml_scanner = SCons.Script.Scanner(function = __xml_scan,
# Action generators
#
def __generate_xsltproc_action(source, target, env, for_signature):
- cmd = env['DOCBOOK_XSLTPROCCOM']
+ cmd = env['DOCBOOK_XSLTPROCCOM']
# Does the environment have a base_dir defined?
base_dir = env.subst('$base_dir')
if base_dir:
@@ -300,7 +300,7 @@ def __emit_xsl_basedir(target, source, env):
if base_dir:
# Yes, so prepend it to each target
return [os.path.join(base_dir, str(t)) for t in target], source
-
+
# No, so simply pass target and source names through
return target, source
@@ -334,11 +334,11 @@ def __build_lxml(target, source, env):
General XSLT builder (HTML/FO), using the lxml module.
"""
from lxml import etree
-
- xslt_ac = etree.XSLTAccessControl(read_file=True,
- write_file=True,
- create_dir=True,
- read_network=False,
+
+ xslt_ac = etree.XSLTAccessControl(read_file=True,
+ write_file=True,
+ create_dir=True,
+ read_network=False,
write_network=False)
xsl_style = env.subst('$DOCBOOK_XSL')
xsl_tree = etree.parse(xsl_style)
@@ -350,11 +350,10 @@ def __build_lxml(target, source, env):
result = transform(doc, **parampass)
else:
result = transform(doc)
-
+
try:
- of = open(str(target[0]), "wb")
- of.write(of.write(etree.tostring(result, pretty_print=True)))
- of.close()
+ with open(str(target[0]), "wb") as of:
+ of.write(etree.tostring(result, pretty_print=True))
except:
pass
@@ -376,11 +375,11 @@ def __xinclude_lxml(target, source, env):
Resolving XIncludes, using the lxml module.
"""
from lxml import etree
-
+
doc = etree.parse(str(source[0]))
doc.xinclude()
try:
- doc.write(str(target[0]), xml_declaration=True,
+ doc.write(str(target[0]), xml_declaration=True,
encoding="UTF-8", pretty_print=True)
except:
pass
@@ -432,33 +431,31 @@ def DocbookEpub(env, target, source=None, *args, **kw):
"""
import zipfile
import shutil
-
+
def build_open_container(target, source, env):
"""Generate the *.epub file from intermediate outputs
- Constructs the epub file according to the Open Container Format. This
+ Constructs the epub file according to the Open Container Format. This
function could be replaced by a call to the SCons Zip builder if support
was added for different compression formats for separate source nodes.
"""
- zf = zipfile.ZipFile(str(target[0]), 'w')
- mime_file = open('mimetype', 'w')
- mime_file.write('application/epub+zip')
- mime_file.close()
- zf.write(mime_file.name, compress_type = zipfile.ZIP_STORED)
- for s in source:
- if os.path.isfile(str(s)):
- head, tail = os.path.split(str(s))
- if not head:
- continue
- s = head
- for dirpath, dirnames, filenames in os.walk(str(s)):
- for fname in filenames:
- path = os.path.join(dirpath, fname)
- if os.path.isfile(path):
- zf.write(path, os.path.relpath(path, str(env.get('ZIPROOT', ''))),
- zipfile.ZIP_DEFLATED)
- zf.close()
-
+ with zipfile.ZipFile(str(target[0]), 'w') as zf:
+ with open('mimetype', 'w') as mime_file:
+ mime_file.write('application/epub+zip')
+ zf.write(mime_file.name, compress_type = zipfile.ZIP_STORED)
+ for s in source:
+ if os.path.isfile(str(s)):
+ head, tail = os.path.split(str(s))
+ if not head:
+ continue
+ s = head
+ for dirpath, dirnames, filenames in os.walk(str(s)):
+ for fname in filenames:
+ path = os.path.join(dirpath, fname)
+ if os.path.isfile(path):
+ zf.write(path, os.path.relpath(path, str(env.get('ZIPROOT', ''))),
+ zipfile.ZIP_DEFLATED)
+
def add_resources(target, source, env):
"""Add missing resources to the OEBPS directory
@@ -468,7 +465,7 @@ def DocbookEpub(env, target, source=None, *args, **kw):
content_file = os.path.join(source[0].get_abspath(), 'content.opf')
if not os.path.isfile(content_file):
return
-
+
hrefs = []
if has_libxml2:
nsmap = {'opf' : 'http://www.idpf.org/2007/opf'}
@@ -495,51 +492,51 @@ def DocbookEpub(env, target, source=None, *args, **kw):
hrefs.append(item.attrib['href'])
doc.freeDoc()
- xpath_context.xpathFreeContext()
+ xpath_context.xpathFreeContext()
elif has_lxml:
from lxml import etree
-
+
opf = etree.parse(content_file)
# All the opf:item elements are resources
- for item in opf.xpath('//opf:item',
+ for item in opf.xpath('//opf:item',
namespaces= { 'opf': 'http://www.idpf.org/2007/opf' }):
hrefs.append(item.attrib['href'])
-
+
for href in hrefs:
- # If the resource was not already created by DocBook XSL itself,
+ # If the resource was not already created by DocBook XSL itself,
# copy it into the OEBPS folder
referenced_file = os.path.join(source[0].get_abspath(), href)
if not os.path.exists(referenced_file):
shutil.copy(href, os.path.join(source[0].get_abspath(), href))
-
+
# Init list of targets/sources
target, source = __extend_targets_sources(target, source)
-
+
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_EPUB', ['epub','docbook.xsl'])
# Setup builder
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
-
+
# Create targets
result = []
- if not env.GetOption('clean'):
+ if not env.GetOption('clean'):
# Ensure that the folders OEBPS and META-INF exist
__create_output_dir('OEBPS/')
__create_output_dir('META-INF/')
dirs = env.Dir(['OEBPS', 'META-INF'])
-
+
# Set the fixed base_dir
kw['base_dir'] = 'OEBPS/'
tocncx = __builder.__call__(env, 'toc.ncx', source[0], **kw)
cxml = env.File('META-INF/container.xml')
env.SideEffect(cxml, tocncx)
-
+
env.Depends(tocncx, kw['DOCBOOK_XSL'])
result.extend(tocncx+[cxml])
- container = env.Command(__ensure_suffix(str(target[0]), '.epub'),
- tocncx+[cxml], [add_resources, build_open_container])
+ container = env.Command(__ensure_suffix(str(target[0]), '.epub'),
+ tocncx+[cxml], [add_resources, build_open_container])
mimetype = env.File('mimetype')
env.SideEffect(mimetype, container)
@@ -555,13 +552,13 @@ def DocbookHtml(env, target, source=None, *args, **kw):
"""
# Init list of targets/sources
target, source = __extend_targets_sources(target, source)
-
+
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTML', ['html','docbook.xsl'])
# Setup builder
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
-
+
# Create targets
result = []
for t,s in zip(target,source):
@@ -583,18 +580,18 @@ def DocbookHtmlChunked(env, target, source=None, *args, **kw):
target = ['index.html']
elif not SCons.Util.is_List(source):
source = [source]
-
+
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTMLCHUNKED', ['html','chunkfast.xsl'])
# Setup builder
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
-
+
# Detect base dir
base_dir = kw.get('base_dir', '')
if base_dir:
__create_output_dir(base_dir)
-
+
# Create targets
result = []
r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw)
@@ -617,8 +614,8 @@ def DocbookHtmlhelp(env, target, source=None, *args, **kw):
source = target
target = ['index.html']
elif not SCons.Util.is_List(source):
- source = [source]
-
+ source = [source]
+
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTMLHELP', ['htmlhelp','htmlhelp.xsl'])
@@ -629,7 +626,7 @@ def DocbookHtmlhelp(env, target, source=None, *args, **kw):
base_dir = kw.get('base_dir', '')
if base_dir:
__create_output_dir(base_dir)
-
+
# Create targets
result = []
r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw)
@@ -687,30 +684,29 @@ def DocbookMan(env, target, source=None, *args, **kw):
if os.path.isfile(srcfile):
try:
import xml.dom.minidom
-
+
dom = xml.dom.minidom.parse(__ensure_suffix(str(s),'.xml'))
# Extract volume number, default is 1
for node in dom.getElementsByTagName('refmeta'):
for vol in node.getElementsByTagName('manvolnum'):
volnum = __get_xml_text(vol)
-
+
# Extract output filenames
for node in dom.getElementsByTagName('refnamediv'):
for ref in node.getElementsByTagName('refname'):
outfiles.append(__get_xml_text(ref)+'.'+volnum)
-
+
except:
- # Use simple regex parsing
- f = open(__ensure_suffix(str(s),'.xml'), 'r')
- content = f.read()
- f.close()
-
+ # Use simple regex parsing
+ with open(__ensure_suffix(str(s),'.xml'), 'r') as f:
+ content = f.read()
+
for m in re_manvolnum.finditer(content):
volnum = m.group(1)
-
+
for m in re_refname.finditer(content):
outfiles.append(m.group(1)+'.'+volnum)
-
+
if not outfiles:
# Use stem of the source file
spath = str(s)
@@ -722,14 +718,14 @@ def DocbookMan(env, target, source=None, *args, **kw):
else:
# We have to completely rely on the given target name
outfiles.append(t)
-
+
__builder.__call__(env, outfiles[0], s, **kw)
env.Depends(outfiles[0], kw['DOCBOOK_XSL'])
result.append(outfiles[0])
if len(outfiles) > 1:
env.Clean(outfiles[0], outfiles[1:])
-
+
return result
def DocbookSlidesPdf(env, target, source=None, *args, **kw):
@@ -750,7 +746,7 @@ def DocbookSlidesPdf(env, target, source=None, *args, **kw):
for t,s in zip(target,source):
t, stem = __ensure_suffix_stem(t, '.pdf')
xsl = __builder.__call__(env, stem+'.fo', s, **kw)
- env.Depends(xsl, kw['DOCBOOK_XSL'])
+ env.Depends(xsl, kw['DOCBOOK_XSL'])
result.extend(xsl)
result.extend(__fop_builder.__call__(env, t, xsl, **kw))
@@ -767,7 +763,7 @@ def DocbookSlidesHtml(env, target, source=None, *args, **kw):
source = target
target = ['index.html']
elif not SCons.Util.is_List(source):
- source = [source]
+ source = [source]
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_SLIDESHTML', ['slides','html','plain.xsl'])
@@ -800,12 +796,12 @@ def DocbookXInclude(env, target, source, *args, **kw):
# Setup builder
__builder = __select_builder(__xinclude_lxml_builder,__xinclude_libxml2_builder,__xmllint_builder)
-
+
# Create targets
result = []
for t,s in zip(target,source):
result.extend(__builder.__call__(env, t, s, **kw))
-
+
return result
def DocbookXslt(env, target, source=None, *args, **kw):
@@ -814,13 +810,13 @@ def DocbookXslt(env, target, source=None, *args, **kw):
"""
# Init list of targets/sources
target, source = __extend_targets_sources(target, source)
-
+
# Init XSL stylesheet
kw['DOCBOOK_XSL'] = kw.get('xsl', 'transform.xsl')
# Setup builder
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
-
+
# Create targets
result = []
for t,s in zip(target,source):
@@ -844,18 +840,18 @@ def generate(env):
DOCBOOK_DEFAULT_XSL_MAN = '',
DOCBOOK_DEFAULT_XSL_SLIDESPDF = '',
DOCBOOK_DEFAULT_XSL_SLIDESHTML = '',
-
+
# Paths to the detected executables
DOCBOOK_XSLTPROC = '',
DOCBOOK_XMLLINT = '',
DOCBOOK_FOP = '',
-
+
# Additional flags for the text processors
DOCBOOK_XSLTPROCFLAGS = SCons.Util.CLVar(''),
DOCBOOK_XMLLINTFLAGS = SCons.Util.CLVar(''),
DOCBOOK_FOPFLAGS = SCons.Util.CLVar(''),
DOCBOOK_XSLTPROCPARAMS = SCons.Util.CLVar(''),
-
+
# Default command lines for the detected executables
DOCBOOK_XSLTPROCCOM = xsltproc_com['xsltproc'],
DOCBOOK_XMLLINTCOM = xmllint_com['xmllint'],
@@ -865,7 +861,7 @@ def generate(env):
DOCBOOK_XSLTPROCCOMSTR = None,
DOCBOOK_XMLLINTCOMSTR = None,
DOCBOOK_FOPCOMSTR = None,
-
+
)
_detect(env)
diff --git a/src/engine/SCons/Tool/dvi.py b/src/engine/SCons/Tool/dvi.py
index 9844e37..5cd85ed 100644
--- a/src/engine/SCons/Tool/dvi.py
+++ b/src/engine/SCons/Tool/dvi.py
@@ -27,7 +27,7 @@ Common DVI Builder definition for various other Tool modules that use it.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/dvi.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/dvi.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Builder
import SCons.Tool
diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py
index a4d7d93..32f57e6 100644
--- a/src/engine/SCons/Tool/dvipdf.py
+++ b/src/engine/SCons/Tool/dvipdf.py
@@ -30,7 +30,7 @@ selection method.
# 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/Tool/dvipdf.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/dvipdf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Defaults
diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py
index 30a79ba..988ecd3 100644
--- a/src/engine/SCons/Tool/dvips.py
+++ b/src/engine/SCons/Tool/dvips.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/dvips.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/dvips.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/f03.py b/src/engine/SCons/Tool/f03.py
index 64b67bf..541ec88 100644
--- a/src/engine/SCons/Tool/f03.py
+++ b/src/engine/SCons/Tool/f03.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f03.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f03.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/f08.py b/src/engine/SCons/Tool/f08.py
index 3c317f5..5dc49da 100644
--- a/src/engine/SCons/Tool/f08.py
+++ b/src/engine/SCons/Tool/f08.py
@@ -33,7 +33,7 @@ from __future__ import absolute_import
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f08.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f08.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/f77.py b/src/engine/SCons/Tool/f77.py
index 8ff5f5c..6d60edf 100644
--- a/src/engine/SCons/Tool/f77.py
+++ b/src/engine/SCons/Tool/f77.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f77.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Scanner.Fortran
diff --git a/src/engine/SCons/Tool/f90.py b/src/engine/SCons/Tool/f90.py
index 6f80821..e0b5fae 100644
--- a/src/engine/SCons/Tool/f90.py
+++ b/src/engine/SCons/Tool/f90.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f90.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f90.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Scanner.Fortran
diff --git a/src/engine/SCons/Tool/f95.py b/src/engine/SCons/Tool/f95.py
index 363245c..9a1afdf 100644
--- a/src/engine/SCons/Tool/f95.py
+++ b/src/engine/SCons/Tool/f95.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f95.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f95.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/filesystem.py b/src/engine/SCons/Tool/filesystem.py
index c3c79ce..a625714 100644
--- a/src/engine/SCons/Tool/filesystem.py
+++ b/src/engine/SCons/Tool/filesystem.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/filesystem.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/filesystem.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons
from SCons.Tool.install import copyFunc
diff --git a/src/engine/SCons/Tool/fortran.py b/src/engine/SCons/Tool/fortran.py
index c090b00..1b09880 100644
--- a/src/engine/SCons/Tool/fortran.py
+++ b/src/engine/SCons/Tool/fortran.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/fortran.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/fortran.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import re
diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py
index 7b3bc50..8cf881f 100644
--- a/src/engine/SCons/Tool/g++.py
+++ b/src/engine/SCons/Tool/g++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/g++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/g++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
diff --git a/src/engine/SCons/Tool/g77.py b/src/engine/SCons/Tool/g77.py
index fac9794..fc0bcba 100644
--- a/src/engine/SCons/Tool/g77.py
+++ b/src/engine/SCons/Tool/g77.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/g77.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/g77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
from SCons.Tool.FortranCommon import add_all_to_env, add_f77_to_env
diff --git a/src/engine/SCons/Tool/gas.py b/src/engine/SCons/Tool/gas.py
index d6b3886..c104e34 100644
--- a/src/engine/SCons/Tool/gas.py
+++ b/src/engine/SCons/Tool/gas.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gas.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gas.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
try:
as_module = __import__('as', globals(), locals(), [])
diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py
index 3b4be6d..2532427 100644
--- a/src/engine/SCons/Tool/gcc.py
+++ b/src/engine/SCons/Tool/gcc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gcc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import cc
import os
diff --git a/src/engine/SCons/Tool/gdc.py b/src/engine/SCons/Tool/gdc.py
index d12a7cf..46a910c 100644
--- a/src/engine/SCons/Tool/gdc.py
+++ b/src/engine/SCons/Tool/gdc.py
@@ -48,7 +48,7 @@ Lib tool variables:
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gdc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gdc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Defaults
diff --git a/src/engine/SCons/Tool/gettext_tool.py b/src/engine/SCons/Tool/gettext_tool.py
index c33de28..5fc0158 100644
--- a/src/engine/SCons/Tool/gettext_tool.py
+++ b/src/engine/SCons/Tool/gettext_tool.py
@@ -23,7 +23,7 @@
# 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/Tool/gettext_tool.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gettext_tool.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#############################################################################
def generate(env,**kw):
diff --git a/src/engine/SCons/Tool/gfortran.py b/src/engine/SCons/Tool/gfortran.py
index 37a697e..8d02daa 100644
--- a/src/engine/SCons/Tool/gfortran.py
+++ b/src/engine/SCons/Tool/gfortran.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gfortran.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gfortran.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py
index 7634772..53f5081 100644
--- a/src/engine/SCons/Tool/gnulink.py
+++ b/src/engine/SCons/Tool/gnulink.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gnulink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gnulink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
import SCons.Tool
diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py
index 8ff9065..371b810 100644
--- a/src/engine/SCons/Tool/gs.py
+++ b/src/engine/SCons/Tool/gs.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gs.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/gxx.py b/src/engine/SCons/Tool/gxx.py
index 20445ba..d956c9f 100644
--- a/src/engine/SCons/Tool/gxx.py
+++ b/src/engine/SCons/Tool/gxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
diff --git a/src/engine/SCons/Tool/hpc++.py b/src/engine/SCons/Tool/hpc++.py
index 1528066..4ec2fe3 100644
--- a/src/engine/SCons/Tool/hpc++.py
+++ b/src/engine/SCons/Tool/hpc++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/hpc++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/hpc++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
diff --git a/src/engine/SCons/Tool/hpcc.py b/src/engine/SCons/Tool/hpcc.py
index 2734006..6a564b9 100644
--- a/src/engine/SCons/Tool/hpcc.py
+++ b/src/engine/SCons/Tool/hpcc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/hpcc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/hpcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/hpcxx.py b/src/engine/SCons/Tool/hpcxx.py
index 196777a..8ee888f 100644
--- a/src/engine/SCons/Tool/hpcxx.py
+++ b/src/engine/SCons/Tool/hpcxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/hpcxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/hpcxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
@@ -68,7 +68,8 @@ def generate(env):
env['CXX'] = acc or 'aCC'
env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z')
# determine version of aCC
- line = os.popen(acc + ' -V 2>&1').readline().rstrip()
+ with os.popen(acc + ' -V 2>&1') as p:
+ line = p.readline().rstrip()
if line.find('aCC: HP ANSI C++') == 0:
env['CXXVERSION'] = line.split()[-1]
diff --git a/src/engine/SCons/Tool/hplink.py b/src/engine/SCons/Tool/hplink.py
index 9f38a3b..1afa95e 100644
--- a/src/engine/SCons/Tool/hplink.py
+++ b/src/engine/SCons/Tool/hplink.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/hplink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/hplink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/icc.py b/src/engine/SCons/Tool/icc.py
index 1923c60..8110a60 100644
--- a/src/engine/SCons/Tool/icc.py
+++ b/src/engine/SCons/Tool/icc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/icc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/icc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import cc
diff --git a/src/engine/SCons/Tool/icl.py b/src/engine/SCons/Tool/icl.py
index 26490f0..29d5862 100644
--- a/src/engine/SCons/Tool/icl.py
+++ b/src/engine/SCons/Tool/icl.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/icl.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/icl.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool.intelc
diff --git a/src/engine/SCons/Tool/ifl.py b/src/engine/SCons/Tool/ifl.py
index e438c44..0eb7cda 100644
--- a/src/engine/SCons/Tool/ifl.py
+++ b/src/engine/SCons/Tool/ifl.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ifl.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ifl.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
from SCons.Scanner.Fortran import FortranScan
diff --git a/src/engine/SCons/Tool/ifort.py b/src/engine/SCons/Tool/ifort.py
index d69bd14..730e778 100644
--- a/src/engine/SCons/Tool/ifort.py
+++ b/src/engine/SCons/Tool/ifort.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ifort.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ifort.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
from SCons.Scanner.Fortran import FortranScan
diff --git a/src/engine/SCons/Tool/ilink.py b/src/engine/SCons/Tool/ilink.py
index 6c3a072..7c69e72 100644
--- a/src/engine/SCons/Tool/ilink.py
+++ b/src/engine/SCons/Tool/ilink.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ilink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ilink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/ilink32.py b/src/engine/SCons/Tool/ilink32.py
index 7c7e983..a1e12a6 100644
--- a/src/engine/SCons/Tool/ilink32.py
+++ b/src/engine/SCons/Tool/ilink32.py
@@ -27,7 +27,7 @@ XXX
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ilink32.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ilink32.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
import SCons.Tool.bcc32
diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py
index 6b5a741..c0a8917 100644
--- a/src/engine/SCons/Tool/install.py
+++ b/src/engine/SCons/Tool/install.py
@@ -31,7 +31,7 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/install.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/install.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import re
diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py
index 3429145..fdd9730 100644
--- a/src/engine/SCons/Tool/intelc.py
+++ b/src/engine/SCons/Tool/intelc.py
@@ -32,12 +32,12 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import division, print_function
-__revision__ = "src/engine/SCons/Tool/intelc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/intelc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import math, sys, os.path, glob, string, re
is_windows = sys.platform == 'win32'
-is_win64 = is_windows and (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or
+is_win64 = is_windows and (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or
('PROCESSOR_ARCHITEW6432' in os.environ and
os.environ['PROCESSOR_ARCHITEW6432'] == 'AMD64'))
is_linux = sys.platform.startswith('linux')
@@ -113,11 +113,6 @@ def check_abi(abi):
(abi, list(valid_abis.keys())))
return abi
-def vercmp(a, b):
- """Compare strings as floats,
- but Intel changed Linux naming convention at 9.0"""
- return cmp(linux_ver_normalize(b), linux_ver_normalize(a))
-
def get_version_from_list(v, vlist):
"""See if we can match v (string) in vlist (list of strings)
Linux has to match in a fuzzy way."""
@@ -221,7 +216,7 @@ def get_all_compiler_versions():
versions = []
try:
while i < 100:
- subkey = SCons.Util.RegEnumKey(k, i) # raises EnvironmentError
+ subkey = SCons.Util.RegEnumKey(k, i) # raises SConsEnvironmentError
# Check that this refers to an existing dir.
# This is not 100% perfect but should catch common
# installation issues like when the compiler was installed
@@ -293,7 +288,7 @@ def get_all_compiler_versions():
m = re.search(r'([0-9]{0,4})(?:_sp\d*)?\.([0-9][0-9.]*)$', d)
if m:
versions.append("%s.%s"%(m.group(1), m.group(2)))
-
+
def keyfunc(str):
"""Given a dot-separated version string, return a tuple of ints representing it."""
return [int(x) for x in str.split('.')]
@@ -383,7 +378,7 @@ def get_intel_compiler_top(version, abi):
top = d
break
return top
-
+
top = find_in_2016style_dir(version) or find_in_2011style_dir(version) or find_in_2010style_dir(version) or find_in_2008style_dir(version)
# print "INTELC: top=",top
if not top:
diff --git a/src/engine/SCons/Tool/ipkg.py b/src/engine/SCons/Tool/ipkg.py
index 5685abb..664c3a6 100644
--- a/src/engine/SCons/Tool/ipkg.py
+++ b/src/engine/SCons/Tool/ipkg.py
@@ -33,7 +33,7 @@ packages fake_root.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ipkg.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ipkg.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
@@ -55,8 +55,10 @@ def generate(env):
env['IPKGCOM'] = '$IPKG $IPKGFLAGS ${SOURCE}'
if env.WhereIs('id'):
- env['IPKGUSER'] = os.popen('id -un').read().strip()
- env['IPKGGROUP'] = os.popen('id -gn').read().strip()
+ with os.popen('id -un') as p:
+ env['IPKGUSER'] = p.read().strip()
+ with os.popen('id -gn') as p:
+ env['IPKGGROUP'] = p.read().strip()
env['IPKGFLAGS'] = SCons.Util.CLVar('-o $IPKGUSER -g $IPKGGROUP')
env['IPKGSUFFIX'] = '.ipk'
diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py
index 5858b2c..98be08f 100644
--- a/src/engine/SCons/Tool/jar.py
+++ b/src/engine/SCons/Tool/jar.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/jar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/jar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import SCons.Subst
@@ -86,7 +86,7 @@ def jarFlags(target, source, env, for_signature):
for src in source:
contents = src.get_text_contents()
if contents.startswith("Manifest-Version"):
- if not 'm' in jarflags:
+ if 'm' not in jarflags:
return jarflags + 'm'
break
return jarflags
@@ -106,7 +106,7 @@ def Jar(env, target = None, source = [], *args, **kw):
source = target
target = None
- # mutiple targets pass so build each target the same from the
+ # mutiple targets pass so build each target the same from the
# same source
#TODO Maybe this should only be done once, and the result copied
# for each target since it should result in the same?
@@ -184,7 +184,7 @@ def Jar(env, target = None, source = [], *args, **kw):
continue
except:
pass
-
+
try:
# source is string try to covnert it to dir
target_nodes.extend(dir_to_class(env.fs.Dir(s)))
@@ -193,7 +193,7 @@ def Jar(env, target = None, source = [], *args, **kw):
pass
SCons.Warnings.Warning("File: " + str(s) + " could not be identified as File or Directory, skipping.")
-
+
# at this point all our sources have been converted to classes or directories of class
# so pass it to the Jar builder
return env.JarFile(target = target, source = target_nodes, *args, **kw)
@@ -209,9 +209,9 @@ def generate(env):
env.AddMethod(Jar)
if env['PLATFORM'] == 'win32':
- # Ensure that we have a proper path for clang
- jar = SCons.Tool.find_program_path(env, 'jar',
- default_paths=get_java_install_dirs(env['PLATFORM']))
+ # Ensure that we have a proper path for jar
+ paths = get_java_install_dirs('win32')
+ jar = SCons.Tool.find_program_path(env, 'jar', default_paths=paths)
if jar:
jar_bin_dir = os.path.dirname(jar)
env.AppendENVPath('PATH', jar_bin_dir)
diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py
index b5e4aaa..387afdb 100644
--- a/src/engine/SCons/Tool/javac.py
+++ b/src/engine/SCons/Tool/javac.py
@@ -30,7 +30,7 @@ selection method.
# 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/Tool/javac.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/javac.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -210,15 +210,15 @@ def generate(env):
version = env.get('JAVAVERSION', None)
- javac = SCons.Tool.find_program_path(env, 'javac')
if env['PLATFORM'] == 'win32':
# Ensure that we have a proper path for javac
- paths=get_java_install_dirs(env['PLATFORM'], version=version)
- javac = SCons.Tool.find_program_path(env, 'javac',
- default_paths=paths)
+ paths = get_java_install_dirs('win32', version=version)
+ javac = SCons.Tool.find_program_path(env, 'javac', default_paths=paths)
if javac:
javac_bin_dir = os.path.dirname(javac)
env.AppendENVPath('PATH', javac_bin_dir)
+ else:
+ javac = SCons.Tool.find_program_path(env, 'javac')
env['JAVAINCLUDES'] = get_java_include_paths(env, javac, version)
diff --git a/src/engine/SCons/Tool/javah.py b/src/engine/SCons/Tool/javah.py
index 84183cb..251778d 100644
--- a/src/engine/SCons/Tool/javah.py
+++ b/src/engine/SCons/Tool/javah.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/javah.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/javah.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
@@ -123,9 +123,9 @@ def generate(env):
java_javah.emitter = emit_java_headers
if env['PLATFORM'] == 'win32':
- # Ensure that we have a proper path for clang
- javah = SCons.Tool.find_program_path(env, 'javah',
- default_paths=get_java_install_dirs(env['PLATFORM']))
+ # Ensure that we have a proper path for javah
+ paths = get_java_install_dirs('win32')
+ javah = SCons.Tool.find_program_path(env, 'javah', default_paths=paths)
if javah:
javah_bin_dir = os.path.dirname(javah)
env.AppendENVPath('PATH', javah_bin_dir)
diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py
index 9626693..3f1af08 100644
--- a/src/engine/SCons/Tool/latex.py
+++ b/src/engine/SCons/Tool/latex.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/latex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/latex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Defaults
diff --git a/src/engine/SCons/Tool/ldc.py b/src/engine/SCons/Tool/ldc.py
index fe3df1f..dda1a5e 100644
--- a/src/engine/SCons/Tool/ldc.py
+++ b/src/engine/SCons/Tool/ldc.py
@@ -48,7 +48,7 @@ Lib tool variables:
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ldc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ldc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import subprocess
diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py
index affb52c..4831776 100644
--- a/src/engine/SCons/Tool/lex.py
+++ b/src/engine/SCons/Tool/lex.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/lex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/lex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
@@ -45,6 +45,11 @@ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
LexAction = SCons.Action.Action("$LEXCOM", "$LEXCOMSTR")
+if sys.platform == 'win32':
+ BINS = ['flex', 'lex', 'win_flex']
+else:
+ BINS = ["flex", "lex"]
+
def lexEmitter(target, source, env):
sourceBase, sourceExt = os.path.splitext(SCons.Util.to_String(source[0]))
@@ -70,22 +75,22 @@ def lexEmitter(target, source, env):
def get_lex_path(env, append_paths=False):
"""
- Find the a path containing the lex or flex binaries. If a construction
- environment is passed in then append the path to the ENV PATH.
- """
- # save existing path to reset if we don't want to append any paths
- envPath = env['ENV']['PATH']
- bins = ['flex', 'lex', 'win_flex']
+ Find the path to the lex tool, searching several possible names
- for prog in bins:
+ Only called in the Windows case, so the default_path
+ can be Windows-specific
+
+ :param env: current construction environment
+ :param append_paths: if set, add the path to the tool to PATH
+ :return: path to lex tool, if found
+ """
+ for prog in BINS:
bin_path = SCons.Tool.find_program_path(
- env,
- prog,
+ env,
+ prog,
default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
if bin_path:
- if not append_paths:
- env['ENV']['PATH'] = envPath
- else:
+ if append_paths:
env.AppendENVPath('PATH', os.path.dirname(bin_path))
return bin_path
SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH')
@@ -113,20 +118,21 @@ def generate(env):
env["LEXFLAGS"] = SCons.Util.CLVar("")
if sys.platform == 'win32':
- get_lex_path(env, append_paths=True)
- env["LEX"] = env.Detect(['flex', 'lex', 'win_flex'])
+ # ignore the return - we do not need the full path here
+ _ = get_lex_path(env, append_paths=True)
+ env["LEX"] = env.Detect(BINS)
if not env.get("LEXUNISTD"):
env["LEXUNISTD"] = SCons.Util.CLVar("")
env["LEXCOM"] = "$LEX $LEXUNISTD $LEXFLAGS -t $SOURCES > $TARGET"
else:
- env["LEX"] = env.Detect(["flex", "lex"])
+ env["LEX"] = env.Detect(BINS)
env["LEXCOM"] = "$LEX $LEXFLAGS -t $SOURCES > $TARGET"
def exists(env):
if sys.platform == 'win32':
return get_lex_path(env)
else:
- return env.Detect(["flex", "lex"])
+ return env.Detect(BINS)
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py
index 65fe013..dcaf91f 100644
--- a/src/engine/SCons/Tool/link.py
+++ b/src/engine/SCons/Tool/link.py
@@ -32,7 +32,7 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/link.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/link.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import re
diff --git a/src/engine/SCons/Tool/linkloc.py b/src/engine/SCons/Tool/linkloc.py
index cdcf25a..42d010d 100644
--- a/src/engine/SCons/Tool/linkloc.py
+++ b/src/engine/SCons/Tool/linkloc.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/linkloc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/linkloc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
diff --git a/src/engine/SCons/Tool/m4.py b/src/engine/SCons/Tool/m4.py
index 30dc4c9..0ecc82a 100644
--- a/src/engine/SCons/Tool/m4.py
+++ b/src/engine/SCons/Tool/m4.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/m4.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/m4.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/masm.py b/src/engine/SCons/Tool/masm.py
index 77e32c2..cf147a7 100644
--- a/src/engine/SCons/Tool/masm.py
+++ b/src/engine/SCons/Tool/masm.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/masm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/masm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/midl.py b/src/engine/SCons/Tool/midl.py
index 6879da1..f75204a 100644
--- a/src/engine/SCons/Tool/midl.py
+++ b/src/engine/SCons/Tool/midl.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/midl.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/midl.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py
index ed3f1a3..8410d2f 100644
--- a/src/engine/SCons/Tool/mingw.py
+++ b/src/engine/SCons/Tool/mingw.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mingw.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mingw.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -65,7 +65,7 @@ def shlib_generator(target, source, env, for_signature):
def_target = env.FindIxes(target, 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX')
insert_def = env.subst("$WINDOWS_INSERT_DEF")
- if not insert_def in ['', '0', 0] and def_target: \
+ if insert_def not in ['', '0', 0] and def_target: \
cmd.append('-Wl,--output-def,' + def_target.get_string(for_signature))
return [cmd]
@@ -123,7 +123,7 @@ key_program = 'mingw32-make'
def find_version_specific_mingw_paths():
- """
+ r"""
One example of default mingw install paths is:
C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64\bin
diff --git a/src/engine/SCons/Tool/msgfmt.py b/src/engine/SCons/Tool/msgfmt.py
index 87589ce..c8141a0 100644
--- a/src/engine/SCons/Tool/msgfmt.py
+++ b/src/engine/SCons/Tool/msgfmt.py
@@ -21,7 +21,7 @@
# 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/Tool/msgfmt.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msgfmt.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Builder import BuilderBase
#############################################################################
diff --git a/src/engine/SCons/Tool/msginit.py b/src/engine/SCons/Tool/msginit.py
index e52c1b5..69e803a 100644
--- a/src/engine/SCons/Tool/msginit.py
+++ b/src/engine/SCons/Tool/msginit.py
@@ -24,7 +24,7 @@ Tool specific initialization of msginit tool.
# 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/Tool/msginit.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msginit.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Warnings
import SCons.Builder
diff --git a/src/engine/SCons/Tool/msgmerge.py b/src/engine/SCons/Tool/msgmerge.py
index 849fe32..4254fa6 100644
--- a/src/engine/SCons/Tool/msgmerge.py
+++ b/src/engine/SCons/Tool/msgmerge.py
@@ -24,7 +24,7 @@ Tool specific initialization for `msgmerge` tool.
# 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/Tool/msgmerge.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msgmerge.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#############################################################################
def _update_or_init_po_files(target, source, env):
diff --git a/src/engine/SCons/Tool/mslib.py b/src/engine/SCons/Tool/mslib.py
index 00a17d7..cecdbdc 100644
--- a/src/engine/SCons/Tool/mslib.py
+++ b/src/engine/SCons/Tool/mslib.py
@@ -31,7 +31,9 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mslib.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mslib.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+
+import os
import SCons.Defaults
import SCons.Tool
@@ -54,6 +56,13 @@ def generate(env):
env['LIBPREFIX'] = ''
env['LIBSUFFIX'] = '.lib'
+ # Issue #3350
+ # Change tempfile argument joining character from a space to a newline
+ # mslink will fail if any single line is too long, but is fine with many lines
+ # in a tempfile
+ env['TEMPFILEARGJOIN'] = os.linesep
+
+
def exists(env):
return msvc_exists(env)
diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py
index 9df531b..9fbce4b 100644
--- a/src/engine/SCons/Tool/mslink.py
+++ b/src/engine/SCons/Tool/mslink.py
@@ -32,8 +32,9 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/mslink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mslink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+import os
import os.path
import SCons.Action
@@ -107,7 +108,7 @@ def _dllEmitter(target, source, env, paramtp):
raise SCons.Errors.UserError('A shared library should have exactly one target with the suffix: %s' % env.subst('$%sSUFFIX' % paramtp))
insert_def = env.subst("$WINDOWS_INSERT_DEF")
- if not insert_def in ['', '0', 0] and \
+ if insert_def not in ['', '0', 0] and \
not env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX"):
# append a def file to the list of sources
@@ -158,7 +159,7 @@ def windowsLibEmitter(target, source, env):
def ldmodEmitter(target, source, env):
"""Emitter for loadable modules.
-
+
Loadable modules are identical to shared libraries on Windows, but building
them is subject to different parameters (LDMODULE*).
"""
@@ -219,7 +220,7 @@ def embedManifestDllCheck(target, source, env):
if env.get('WINDOWS_EMBED_MANIFEST', 0):
manifestSrc = target[0].get_abspath() + '.manifest'
if os.path.exists(manifestSrc):
- ret = (embedManifestDllAction) ([target[0]],None,env)
+ ret = (embedManifestDllAction) ([target[0]],None,env)
if ret:
raise SCons.Errors.UserError("Unable to embed manifest into %s" % (target[0]))
return ret
@@ -327,6 +328,12 @@ def generate(env):
env['LDMODULEEMITTER'] = [ldmodEmitter]
env['LDMODULECOM'] = compositeLdmodAction
+ # Issue #3350
+ # Change tempfile argument joining character from a space to a newline
+ # mslink will fail if any single line is too long, but is fine with many lines
+ # in a tempfile
+ env['TEMPFILEARGJOIN'] = os.linesep
+
def exists(env):
return msvc_exists(env)
diff --git a/src/engine/SCons/Tool/mssdk.py b/src/engine/SCons/Tool/mssdk.py
index d66c7fc..7a38c6a 100644
--- a/src/engine/SCons/Tool/mssdk.py
+++ b/src/engine/SCons/Tool/mssdk.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mssdk.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mssdk.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
"""engine.SCons.Tool.mssdk
diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py
index a611f8e..052a0b0 100644
--- a/src/engine/SCons/Tool/msvc.py
+++ b/src/engine/SCons/Tool/msvc.py
@@ -31,9 +31,10 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/msvc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msvc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
+import os
import re
import sys
@@ -161,7 +162,7 @@ def msvc_batch_key(action, env, target, source):
# Note we need to do the env.subst so $MSVC_BATCH can be a reference to
# another construction variable, which is why we test for False and 0
# as strings.
- if not 'MSVC_BATCH' in env or env.subst('$MSVC_BATCH') in ('0', 'False', '', None):
+ if 'MSVC_BATCH' not in env or env.subst('$MSVC_BATCH') in ('0', 'False', '', None):
# We're not using batching; return no key.
return None
t = target[0]
@@ -187,7 +188,7 @@ def msvc_output_flag(target, source, env, for_signature):
# len(source)==1 as batch mode can compile only one file
# (and it also fixed problem with compiling only one changed file
# with batch mode enabled)
- if not 'MSVC_BATCH' in env or env.subst('$MSVC_BATCH') in ('0', 'False', '', None):
+ if 'MSVC_BATCH' not in env or env.subst('$MSVC_BATCH') in ('0', 'False', '', None):
return '/Fo$TARGET'
else:
# The Visual C/C++ compiler requires a \ at the end of the /Fo
@@ -283,6 +284,12 @@ def generate(env):
msvc_set_PCHPDBFLAGS(env)
+ # Issue #3350
+ # Change tempfile argument joining character from a space to a newline
+ # mslink will fail if any single line is too long, but is fine with many lines
+ # in a tempfile
+ env['TEMPFILEARGJOIN'] = os.linesep
+
env['PCHCOM'] = '$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'
env['BUILDERS']['PCH'] = pch_builder
diff --git a/src/engine/SCons/Tool/msvc.xml b/src/engine/SCons/Tool/msvc.xml
index 03d8ce3..b8b4f6d 100644
--- a/src/engine/SCons/Tool/msvc.xml
+++ b/src/engine/SCons/Tool/msvc.xml
@@ -353,6 +353,7 @@ constructor; setting it later has no effect.
<para>
Valid values for Windows are
+<literal>14.2</literal>,
<literal>14.1</literal>,
<literal>14.0</literal>,
<literal>14.0Exp</literal>,
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index ddf8608..38965e3 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -32,7 +32,7 @@ selection method.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/msvs.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msvs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -70,10 +70,14 @@ def xmlify(s):
s = s.replace('\n', '&#x0A;')
return s
-# Process a CPPPATH list in includes, given the env, target and source.
-# Returns a tuple of nodes.
def processIncludes(includes, env, target, source):
- return SCons.PathList.PathList(includes).subst_path(env, target, source)
+ """
+ Process a CPPPATH list in includes, given the env, target and source.
+ Returns a list of directory paths. These paths are absolute so we avoid
+ putting pound-prefixed paths in a Visual Studio project file.
+ """
+ return [env.Dir(i).abspath for i in
+ SCons.PathList.PathList(includes).subst_path(env, target, source)]
external_makefile_guid = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}'
@@ -348,10 +352,20 @@ V10DebugSettings = {
}
class _GenerateV10User(_UserGenerator):
- """Generates a Project'user file for MSVS 2010"""
+ """Generates a Project'user file for MSVS 2010 or later"""
def __init__(self, dspfile, source, env):
- self.versionstr = '4.0'
+ version_num, suite = msvs_parse_version(env['MSVS_VERSION'])
+ if version_num >= 14.2:
+ # Visual Studio 2019 is considered to be version 16.
+ self.versionstr = '16.0'
+ elif version_num >= 14.1:
+ # Visual Studio 2017 is considered to be version 15.
+ self.versionstr = '15.0'
+ elif version_num == 14.0:
+ self.versionstr = '14.0'
+ else:
+ self.versionstr = '4.0'
self.usrhead = V10UserHeader
self.usrconf = V10UserConfiguration
self.usrdebg = V10DebugSettings
@@ -397,7 +411,7 @@ class _DSPGenerator(object):
elif SCons.Util.is_List(env['variant']):
variants = env['variant']
- if 'buildtarget' not in env or env['buildtarget'] == None:
+ if 'buildtarget' not in env or env['buildtarget'] is None:
buildtarget = ['']
elif SCons.Util.is_String(env['buildtarget']):
buildtarget = [env['buildtarget']]
@@ -418,7 +432,7 @@ class _DSPGenerator(object):
for _ in variants:
buildtarget.append(bt)
- if 'outdir' not in env or env['outdir'] == None:
+ if 'outdir' not in env or env['outdir'] is None:
outdir = ['']
elif SCons.Util.is_String(env['outdir']):
outdir = [env['outdir']]
@@ -439,7 +453,7 @@ class _DSPGenerator(object):
for v in variants:
outdir.append(s)
- if 'runfile' not in env or env['runfile'] == None:
+ if 'runfile' not in env or env['runfile'] is None:
runfile = buildtarget[-1:]
elif SCons.Util.is_String(env['runfile']):
runfile = [env['runfile']]
@@ -462,15 +476,41 @@ class _DSPGenerator(object):
self.sconscript = env['MSVSSCONSCRIPT']
- if 'cmdargs' not in env or env['cmdargs'] == None:
- cmdargs = [''] * len(variants)
- elif SCons.Util.is_String(env['cmdargs']):
- cmdargs = [env['cmdargs']] * len(variants)
- elif SCons.Util.is_List(env['cmdargs']):
- if len(env['cmdargs']) != len(variants):
- raise SCons.Errors.InternalError("Sizes of 'cmdargs' and 'variant' lists must be the same.")
+ def GetKeyFromEnv(env, key, variants):
+ """
+ Retrieves a specific key from the environment. If the key is
+ present, it is expected to either be a string or a list with length
+ equal to the number of variants. The function returns a list of
+ the desired value (e.g. cpp include paths) guaranteed to be of
+ length equal to the length of the variants list.
+ """
+ if key not in env or env[key] is None:
+ return [''] * len(variants)
+ elif SCons.Util.is_String(env[key]):
+ return [env[key]] * len(variants)
+ elif SCons.Util.is_List(env[key]):
+ if len(env[key]) != len(variants):
+ raise SCons.Errors.InternalError("Sizes of '%s' and 'variant' lists must be the same." % key)
+ else:
+ return env[key]
else:
- cmdargs = env['cmdargs']
+ raise SCons.Errors.InternalError("Unsupported type for key '%s' in environment: %s" %
+ (key, type(env[key])))
+
+ cmdargs = GetKeyFromEnv(env, 'cmdargs', variants)
+
+ # The caller is allowed to put 'cppdefines' and/or 'cpppaths' in the
+ # environment, which is useful if they want to provide per-variant
+ # values for these. Otherwise, we fall back to using the global
+ # 'CPPDEFINES' and 'CPPPATH' functions.
+ if 'cppdefines' in env:
+ cppdefines = GetKeyFromEnv(env, 'cppdefines', variants)
+ else:
+ cppdefines = [env.get('CPPDEFINES', [])] * len(variants)
+ if 'cpppaths' in env:
+ cpppaths = GetKeyFromEnv(env, 'cpppaths', variants)
+ else:
+ cpppaths = [env.get('CPPPATH', [])] * len(variants)
self.env = env
@@ -513,13 +553,17 @@ class _DSPGenerator(object):
for n in sourcenames:
self.sources[n].sort(key=lambda a: a.lower())
- def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, dspfile=dspfile):
+ def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, cppdefines, cpppaths, dspfile=dspfile, env=env):
config = Config()
config.buildtarget = buildtarget
config.outdir = outdir
config.cmdargs = cmdargs
+ config.cppdefines = cppdefines
config.runfile = runfile
+ # Dir objects can't be pickled, so we need an absolute path here.
+ config.cpppaths = processIncludes(cpppaths, env, None, None)
+
match = re.match(r'(.*)\|(.*)', variant)
if match:
config.variant = match.group(1)
@@ -532,12 +576,12 @@ class _DSPGenerator(object):
print("Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dspfile) + "'")
for i in range(len(variants)):
- AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i])
+ AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i], cppdefines[i], cpppaths[i])
self.platforms = []
for key in list(self.configs.keys()):
platform = self.configs[key].platform
- if not platform in self.platforms:
+ if platform not in self.platforms:
self.platforms.append(platform)
def Build(self):
@@ -553,16 +597,16 @@ V6DSPHeader = """\
CFG=%(name)s - Win32 %(confkey)s
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "%(name)s.mak".
-!MESSAGE
+!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "%(name)s.mak" CFG="%(name)s - Win32 %(confkey)s"
-!MESSAGE
+!MESSAGE
!MESSAGE Possible choices for configuration are:
-!MESSAGE
+!MESSAGE
"""
class _GenerateV6DSP(_DSPGenerator):
@@ -580,7 +624,7 @@ class _GenerateV6DSP(_DSPGenerator):
for kind in confkeys:
self.file.write('!MESSAGE "%s - Win32 %s" (based on "Win32 (x86) External Target")\n' % (name, kind))
- self.file.write('!MESSAGE \n\n')
+ self.file.write('!MESSAGE\n\n')
def PrintProject(self):
name = self.name
@@ -637,7 +681,7 @@ class _GenerateV6DSP(_DSPGenerator):
first = 1
else:
self.file.write('!ELSEIF "$(CFG)" == "%s - Win32 %s"\n\n' % (name,kind))
- self.file.write('!ENDIF \n\n')
+ self.file.write('!ENDIF\n\n')
self.PrintSourceFiles()
self.file.write('# End Target\n'
'# End Project\n')
@@ -645,10 +689,10 @@ class _GenerateV6DSP(_DSPGenerator):
if self.nokeep == 0:
# now we pickle some data and add it to the file -- MSDEV will ignore it.
pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata + '\n')
pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata + '\n')
def PrintSourceFiles(self):
@@ -685,11 +729,13 @@ class _GenerateV6DSP(_DSPGenerator):
return # doesn't exist yet, so can't add anything to configs.
line = dspfile.readline()
+ # skip until marker
while line:
if line.find("# End Project") > -1:
break
line = dspfile.readline()
+ # read to get configs
line = dspfile.readline()
datas = line
while line and line != '\n':
@@ -707,12 +753,14 @@ class _GenerateV6DSP(_DSPGenerator):
self.configs.update(data)
+ # keep reading to get sources
data = None
line = dspfile.readline()
datas = line
while line and line != '\n':
line = dspfile.readline()
datas = datas + line
+ dspfile.close()
# OK, we've found our little pickled cache of data.
# it has a "# " in front of it, so we strip that.
@@ -878,6 +926,8 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
buildtarget = self.configs[kind].buildtarget
runfile = self.configs[kind].runfile
cmdargs = self.configs[kind].cmdargs
+ cpppaths = self.configs[kind].cpppaths
+ cppdefines = self.configs[kind].cppdefines
env_has_buildtarget = 'MSVSBUILDTARGET' in self.env
if not env_has_buildtarget:
@@ -895,9 +945,8 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
# This isn't perfect; CPPDEFINES and CPPPATH can contain $TARGET and $SOURCE,
# so they could vary depending on the command being generated. This code
# assumes they don't.
- preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', []))))
- includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None)
- includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
+ preprocdefs = xmlify(';'.join(processDefines(cppdefines)))
+ includepath = xmlify(';'.join(processIncludes(cpppaths, self.env, None, None)))
if not env_has_buildtarget:
del self.env['MSVSBUILDTARGET']
@@ -917,10 +966,10 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
if self.nokeep == 0:
# now we pickle some data and add it to the file -- MSDEV will ignore it.
pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write('<!-- SCons Data:\n' + pdata + '\n')
pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata + '-->\n')
def printSources(self, hierarchy, commonprefix):
@@ -998,11 +1047,13 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
return # doesn't exist yet, so can't add anything to configs.
line = dspfile.readline()
+ # skip until marker
while line:
if line.find('<!-- SCons Data:') > -1:
break
line = dspfile.readline()
+ # read to get configs
line = dspfile.readline()
datas = line
while line and line != '\n':
@@ -1020,12 +1071,14 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
self.configs.update(data)
+ # keep reading to get sources
data = None
line = dspfile.readline()
datas = line
while line and line != '\n':
line = dspfile.readline()
datas = datas + line
+ dspfile.close()
# OK, we've found our little pickled cache of data.
try:
@@ -1052,7 +1105,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
V10DSPHeader = """\
<?xml version="1.0" encoding="%(encoding)s"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="%(versionstr)s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
"""
V10DSPProjectConfiguration = """\
@@ -1067,6 +1120,7 @@ V10DSPGlobals = """\
\t\t<ProjectGuid>%(project_guid)s</ProjectGuid>
%(scc_attrs)s\t\t<RootNamespace>%(name)s</RootNamespace>
\t\t<Keyword>MakeFileProj</Keyword>
+\t\t<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
\t</PropertyGroup>
"""
@@ -1080,7 +1134,7 @@ V10DSPPropertyGroupCondition = """\
V10DSPImportGroupCondition = """\
\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='%(variant)s|%(platform)s'" Label="PropertySheets">
-\t\t<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
\t</ImportGroup>
"""
@@ -1104,9 +1158,9 @@ V15DSPHeader = """\
class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
"""Generates a Project file for MSVS 2010"""
- def __init__(self, dspfile, header, source, env):
+ def __init__(self, dspfile, source, env):
_DSPGenerator.__init__(self, dspfile, source, env)
- self.dspheader = header
+ self.dspheader = V10DSPHeader
self.dspconfiguration = V10DSPProjectConfiguration
self.dspglobals = V10DSPGlobals
@@ -1115,6 +1169,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
def PrintHeader(self):
env = self.env
name = self.name
+ versionstr = self.versionstr
encoding = env.subst('$MSVSENCODING')
project_guid = env.get('MSVS_PROJECT_GUID', '')
scc_provider = env.get('MSVS_SCC_PROVIDER', '')
@@ -1159,7 +1214,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
name = self.name
confkeys = sorted(self.configs.keys())
- self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\n')
+ self.file.write('\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />\n')
toolset = ''
if 'MSVC_VERSION' in self.env:
@@ -1170,7 +1225,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
platform = self.configs[kind].platform
self.file.write(V10DSPPropertyGroupCondition % locals())
- self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\n')
+ self.file.write('\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />\n')
self.file.write('\t<ImportGroup Label="ExtensionSettings">\n')
self.file.write('\t</ImportGroup>\n')
@@ -1190,6 +1245,8 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
buildtarget = self.configs[kind].buildtarget
runfile = self.configs[kind].runfile
cmdargs = self.configs[kind].cmdargs
+ cpppaths = self.configs[kind].cpppaths
+ cppdefines = self.configs[kind].cppdefines
env_has_buildtarget = 'MSVSBUILDTARGET' in self.env
if not env_has_buildtarget:
@@ -1207,9 +1264,8 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
# This isn't perfect; CPPDEFINES and CPPPATH can contain $TARGET and $SOURCE,
# so they could vary depending on the command being generated. This code
# assumes they don't.
- preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', []))))
- includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None)
- includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
+ preprocdefs = xmlify(';'.join(processDefines(cppdefines)))
+ includepath = xmlify(';'.join(processIncludes(cpppaths, self.env, None, None)))
if not env_has_buildtarget:
del self.env['MSVSBUILDTARGET']
@@ -1226,14 +1282,15 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
raise SCons.Errors.InternalError('Unable to open "' + self.filtersabs + '" for writing:' + str(detail))
self.filters_file.write('<?xml version="1.0" encoding="utf-8"?>\n'
- '<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n')
+ '<Project ToolsVersion="%s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n' %
+ self.versionstr)
self.PrintSourceFiles()
self.filters_file.write('</Project>')
self.filters_file.close()
- self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\n'
+ self.file.write('\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />\n'
'\t<ImportGroup Label="ExtensionTargets">\n'
'\t</ImportGroup>\n'
'</Project>\n')
@@ -1241,10 +1298,10 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
if self.nokeep == 0:
# now we pickle some data and add it to the file -- MSDEV will ignore it.
pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write('<!-- SCons Data:\n' + pdata + '\n')
pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata + '-->\n')
def printFilters(self, hierarchy, name):
@@ -1451,13 +1508,16 @@ class _GenerateV7DSW(_DSWGenerator):
self.platforms = []
for key in list(self.configs.keys()):
platform = self.configs[key].platform
- if not platform in self.platforms:
+ if platform not in self.platforms:
self.platforms.append(platform)
def GenerateProjectFilesInfo(self):
for dspfile in self.dspfiles:
dsp_folder_path, name = os.path.split(dspfile)
dsp_folder_path = os.path.abspath(dsp_folder_path)
+ if SCons.Util.splitext(name)[1] == '.filters':
+ # Ignore .filters project files
+ continue
dsp_relative_folder_path = os.path.relpath(dsp_folder_path, self.dsw_folder_path)
if dsp_relative_folder_path == os.curdir:
dsp_relative_file_path = name
@@ -1491,6 +1551,7 @@ class _GenerateV7DSW(_DSWGenerator):
while line:
line = dswfile.readline()
datas = datas + line
+ dswfile.close()
# OK, we've found our little pickled cache of data.
try:
@@ -1506,7 +1567,11 @@ class _GenerateV7DSW(_DSWGenerator):
def PrintSolution(self):
"""Writes a solution file"""
self.file.write('Microsoft Visual Studio Solution File, Format Version %s\n' % self.versionstr)
- if self.version_num > 14.0:
+ if self.version_num >= 14.2:
+ # Visual Studio 2019 is considered to be version 16.
+ self.file.write('# Visual Studio 16\n')
+ elif self.version_num > 14.0:
+ # Visual Studio 2015 and 2017 are both considered to be version 15.
self.file.write('# Visual Studio 15\n')
elif self.version_num >= 12.0:
self.file.write('# Visual Studio 14\n')
@@ -1617,7 +1682,7 @@ class _GenerateV7DSW(_DSWGenerator):
self.file.write('EndGlobal\n')
if self.nokeep == 0:
pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata)
self.file.write('\n')
@@ -1686,11 +1751,8 @@ def GenerateDSP(dspfile, source, env):
version_num = 6.0
if 'MSVS_VERSION' in env:
version_num, suite = msvs_parse_version(env['MSVS_VERSION'])
- if version_num > 14.0:
- g = _GenerateV10DSP(dspfile, V15DSPHeader, source, env)
- g.Build()
- elif version_num >= 10.0:
- g = _GenerateV10DSP(dspfile, V10DSPHeader, source, env)
+ if version_num >= 10.0:
+ g = _GenerateV10DSP(dspfile, source, env)
g.Build()
elif version_num >= 7.0:
g = _GenerateV7DSP(dspfile, source, env)
@@ -1730,7 +1792,7 @@ def GenerateProject(target, source, env):
dspfile = builddspfile.srcnode()
# this detects whether or not we're using a VariantDir
- if not dspfile is builddspfile:
+ if dspfile is not builddspfile:
try:
bdsp = open(str(builddspfile), "w+")
except IOError as detail:
@@ -1738,6 +1800,7 @@ def GenerateProject(target, source, env):
raise
bdsp.write("This is just a placeholder file.\nThe real project file is here:\n%s\n" % dspfile.get_abspath())
+ bdsp.close()
GenerateDSP(dspfile, source, env)
@@ -1745,7 +1808,7 @@ def GenerateProject(target, source, env):
builddswfile = target[1]
dswfile = builddswfile.srcnode()
- if not dswfile is builddswfile:
+ if dswfile is not builddswfile:
try:
bdsw = open(str(builddswfile), "w+")
@@ -1754,6 +1817,7 @@ def GenerateProject(target, source, env):
raise
bdsw.write("This is just a placeholder file.\nThe real workspace file is here:\n%s\n" % dswfile.get_abspath())
+ bdsw.close()
GenerateDSW(dswfile, source, env)
@@ -1781,11 +1845,10 @@ def projectEmitter(target, source, env):
# Project file depends on CPPDEFINES and CPPPATH
preprocdefs = xmlify(';'.join(processDefines(env.get('CPPDEFINES', []))))
- includepath_Dirs = processIncludes(env.get('CPPPATH', []), env, None, None)
- includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
+ includepath = xmlify(';'.join(processIncludes(env.get('CPPPATH', []), env, None, None)))
source = source + "; ppdefs:%s incpath:%s"%(preprocdefs, includepath)
- if 'buildtarget' in env and env['buildtarget'] != None:
+ if 'buildtarget' in env and env['buildtarget'] is not None:
if SCons.Util.is_String(env['buildtarget']):
source = source + ' "%s"' % env['buildtarget']
elif SCons.Util.is_List(env['buildtarget']):
@@ -1799,7 +1862,7 @@ def projectEmitter(target, source, env):
try: source = source + ' "%s"' % env['buildtarget'].get_abspath()
except AttributeError: raise SCons.Errors.InternalError("buildtarget can be a string, a node, a list of strings or nodes, or None")
- if 'outdir' in env and env['outdir'] != None:
+ if 'outdir' in env and env['outdir'] is not None:
if SCons.Util.is_String(env['outdir']):
source = source + ' "%s"' % env['outdir']
elif SCons.Util.is_List(env['outdir']):
@@ -1962,8 +2025,14 @@ def generate(env):
default_MSVS_SConscript = env.File('SConstruct')
env['MSVSSCONSCRIPT'] = default_MSVS_SConscript
- env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env))
- env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.get_abspath()}" -f ${MSVSSCONSCRIPT.name}'
+ # Allow consumers to provide their own versions of MSVSSCONS and
+ # MSVSSCONSFLAGS. This helps support consumers who use wrapper scripts to
+ # invoke scons.
+ if 'MSVSSCONS' not in env:
+ env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env))
+ if 'MSVSSCONSFLAGS' not in env:
+ env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.get_abspath()}" -f ${MSVSSCONSCRIPT.name}'
+
env['MSVSSCONSCOM'] = '$MSVSSCONS $MSVSSCONSFLAGS'
env['MSVSBUILDCOM'] = '$MSVSSCONSCOM "$MSVSBUILDTARGET"'
env['MSVSREBUILDCOM'] = '$MSVSSCONSCOM "$MSVSBUILDTARGET"'
diff --git a/src/engine/SCons/Tool/msvs.xml b/src/engine/SCons/Tool/msvs.xml
index 7943f22..9f2353a 100644
--- a/src/engine/SCons/Tool/msvs.xml
+++ b/src/engine/SCons/Tool/msvs.xml
@@ -48,14 +48,16 @@ See its __doc__ string for a discussion of the format.
latest installed version, or the version specified by
&cv-link-MSVS_VERSION; in the Environment constructor). For
Visual Studio 6, it will generate a <filename>.dsp</filename>
- file. For Visual Studio 7 (.NET) and later versions, it will
- generate a <filename>.vcproj</filename> file.
+ file. For Visual Studio 7, 8, and 9, it will
+ generate a <filename>.vcproj</filename> file. For Visual
+ Studio 10 and later, it will generate a
+ <filename>.vcxproj</filename> file.
</para>
<para>
By default, this also generates a solution file for the
specified project, a <filename>.dsw</filename> file for
Visual Studio 6 or a <filename>.sln</filename> file for
- Visual Studio 7 (.NET). This behavior may be disabled by
+ Visual Studio 7 and later. This behavior may be disabled by
specifying <literal>auto_build_solution=0</literal> when you
call &b-MSVSProject;, in which case you presumably want to
build the solution file(s) by calling the &b-MSVSSolution;
@@ -128,6 +130,36 @@ See its __doc__ string for a discussion of the format.
</listitem>
</varlistentry>
<varlistentry>
+ <term>cppdefines</term>
+ <listitem>
+ <para>
+ Preprocessor definitions for the different variants.
+ The number of <literal>cppdefines</literal> entries
+ must match the number of <literal>variant</literal>
+ entries, or be empty (not specified). If you give
+ only one, it will automatically be propagated to all
+ variants. If you don't give this parameter, SCons
+ will use the invoking environment's
+ <literal>CPPDEFINES</literal> entry for all variants.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>cpppaths</term>
+ <listitem>
+ <para>
+ Compiler include paths for the different variants.
+ The number of <literal>cpppaths</literal> entries
+ must match the number of <literal>variant</literal>
+ entries, or be empty (not specified). If you give
+ only one, it will automatically be propagated to all
+ variants. If you don't give this parameter, SCons
+ will use the invoking environment's
+ <literal>CPPPATH</literal> entry for all variants.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term>buildtarget</term>
<listitem>
<para>
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py
index fd5e343..e0b5ced 100644
--- a/src/engine/SCons/Tool/msvsTests.py
+++ b/src/engine/SCons/Tool/msvsTests.py
@@ -22,7 +22,7 @@
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/msvsTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msvsTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
@@ -34,6 +34,7 @@ import TestUnit
from SCons.Tool.msvs import *
from SCons.Tool.MSCommon.vs import SupportedVSList
+import SCons.Node.FS
import SCons.Util
import SCons.Warnings
@@ -352,6 +353,36 @@ regdata_80 = r'''
"VCXDCMakeTool"="*.xdc"
'''.split('\n')
+regdata_140 = r'''
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS]
+"MSMDir"="C:\\Program Files (x86)\\Common Files\\Merge Modules\\"
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+"VS7EnvironmentLocation"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
+"EnvironmentPath"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
+"EnvironmentDirectory"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\"
+"VS7CommonDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\"
+"VS7CommonBinDir"=""
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\BuildNumber]
+"1033"="14.0"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Community]
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSLS_MSI]
+"Version"="14.0.25527"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSPS_MSI]
+"Version"="14.0.25527"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Pro]
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\professional]
+"IsInstallInProgress"="0"
+"CurrentOperation"="install"
+"SetupFeedUri"="http://go.microsoft.com/fwlink/?LinkID=659004&clcid=0x409"
+"SetupFeedLocalCache"="C:\\ProgramData\\Microsoft\\VisualStudioSecondaryInstaller\\14.0\\LastUsedFeed\\{68432bbb-c9a5-4a7b-bab3-ae5a49b28303}\\Feed.xml"
+"InstallResult"="0"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller]
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AppInsightsTools]
+"Version"="7.0.20620.1"
+'''.split('\n')
+
regdata_cv = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
"ProgramFilesDir"="C:\Program Files"
"CommonFilesDir"="C:\Program Files\Common Files"
@@ -363,6 +394,7 @@ regdata_none = []
class DummyEnv(object):
def __init__(self, dict=None):
+ self.fs = SCons.Node.FS.FS()
if dict:
self.dict = dict
else:
@@ -385,6 +417,16 @@ class DummyEnv(object):
def has_key(self,name):
return name in self.dict
+ def get(self, name, value=None):
+ if self.has_key(name):
+ return self.dict[name]
+ else:
+ return value
+
+ def Dir(self, name):
+ return self.fs.Dir(name)
+
+
class RegKey(object):
"""key class for storing an 'open' registry key"""
def __init__(self,key):
@@ -554,6 +596,11 @@ class msvsTestCase(unittest.TestCase):
from SCons.Tool.MSCommon.vs import reset_installed_visual_studios
reset_installed_visual_studios()
+ self.test = TestCmd.TestCmd(workdir='')
+ # FS doesn't like the cwd to be something other than its root.
+ os.chdir(self.test.workpath(""))
+ self.fs = SCons.Node.FS.FS()
+
def test_get_default_version(self):
"""Test retrieval of the default visual studio version"""
@@ -607,13 +654,19 @@ class msvsTestCase(unittest.TestCase):
version_num, suite = msvs_parse_version(self.highest_version)
if version_num >= 10.0:
function_test = _GenerateV10DSP
+ suffix = '.vcxproj'
elif version_num >= 7.0:
function_test = _GenerateV7DSP
+ suffix = '.dsp'
else:
function_test = _GenerateV6DSP
+ suffix = '.dsp'
+
+ # Avoid any race conditions between the test cases when we test
+ # actually writing the files.
+ dspfile = 'test%s%s' % (hash(self), suffix)
str_function_test = str(function_test.__init__)
- dspfile = 'test.dsp'
source = 'test.cpp'
# Create the cmdargs test list
@@ -623,50 +676,95 @@ class msvsTestCase(unittest.TestCase):
'debug=False target_arch=32',
'debug=True target_arch=x64',
'debug=False target_arch=x64']
-
- # Tuple list : (parameter, dictionary of expected result per variant)
- tests_cmdargs = [(None, dict.fromkeys(list_variant, '')),
- ('', dict.fromkeys(list_variant, '')),
- (list_cmdargs[0], dict.fromkeys(list_variant, list_cmdargs[0])),
- (list_cmdargs, dict(list(zip(list_variant, list_cmdargs))))]
-
+ list_cppdefines = [['_A', '_B', 'C'], ['_B', '_C_'], ['D'], []]
+ list_cpppaths = [[r'C:\test1'], [r'C:\test1;C:\test2'],
+ [self.fs.Dir('subdir')], []]
+
+ def TestParamsFromList(test_variant, test_list):
+ """
+ Generates test data based on the parameters passed in.
+
+ Returns tuple list:
+ 1. Parameter.
+ 2. Dictionary of expected result per variant.
+ """
+ def normalizeParam(param):
+ """
+ Converts the raw data based into the AddConfig function of
+ msvs.py to the expected result.
+
+ Expects the following behavior:
+ 1. A value of None will be converted to an empty list.
+ 2. A File or Directory object will be converted to an
+ absolute path (because those objects can't be pickled).
+ 3. Otherwise, the parameter will be used.
+ """
+ if param is None:
+ return []
+ elif isinstance(param, list):
+ return [normalizeParam(p) for p in param]
+ elif hasattr(param, 'abspath'):
+ return param.abspath
+ else:
+ return param
+
+ return [
+ (None, dict.fromkeys(test_variant, '')),
+ ('', dict.fromkeys(test_variant, '')),
+ (test_list[0], dict.fromkeys(test_variant, normalizeParam(test_list[0]))),
+ (test_list, dict(list(zip(test_variant, [normalizeParam(x) for x in test_list]))))
+ ]
+
+ tests_cmdargs = TestParamsFromList(list_variant, list_cmdargs)
+ tests_cppdefines = TestParamsFromList(list_variant, list_cppdefines)
+ tests_cpppaths = TestParamsFromList(list_variant, list_cpppaths)
+
# Run the test for each test case
for param_cmdargs, expected_cmdargs in tests_cmdargs:
- debug('Testing %s. with :\n variant = %s \n cmdargs = "%s"' % \
- (str_function_test, list_variant, param_cmdargs))
- param_configs = []
- expected_configs = {}
- for platform in ['Win32', 'x64']:
- for variant in ['Debug', 'Release']:
- variant_platform = '%s|%s' % (variant, platform)
- runfile = '%s\\%s\\test.exe' % (platform, variant)
- buildtarget = '%s\\%s\\test.exe' % (platform, variant)
- outdir = '%s\\%s' % (platform, variant)
+ for param_cppdefines, expected_cppdefines in tests_cppdefines:
+ for param_cpppaths, expected_cpppaths in tests_cpppaths:
+ debug('Testing %s. with :\n variant = %s \n cmdargs = "%s" \n cppdefines = "%s" \n cpppaths = "%s"' % \
+ (str_function_test, list_variant, param_cmdargs, param_cppdefines, param_cpppaths))
+ param_configs = []
+ expected_configs = {}
+ for platform in ['Win32', 'x64']:
+ for variant in ['Debug', 'Release']:
+ variant_platform = '%s|%s' % (variant, platform)
+ runfile = '%s\\%s\\test.exe' % (platform, variant)
+ buildtarget = '%s\\%s\\test.exe' % (platform, variant)
+ outdir = '%s\\%s' % (platform, variant)
- # Create parameter list for this variant_platform
- param_configs.append([variant_platform, runfile, buildtarget, outdir])
-
- # Create expected dictionary result for this variant_platform
- expected_configs[variant_platform] = \
- {'variant': variant, 'platform': platform,
- 'runfile': runfile,
- 'buildtarget': buildtarget,
- 'outdir': outdir,
- 'cmdargs': expected_cmdargs[variant_platform]}
+ # Create parameter list for this variant_platform
+ param_configs.append([variant_platform, runfile, buildtarget, outdir])
+ # Create expected dictionary result for this variant_platform
+ expected_configs[variant_platform] = {
+ 'variant': variant,
+ 'platform': platform,
+ 'runfile': runfile,
+ 'buildtarget': buildtarget,
+ 'outdir': outdir,
+ 'cmdargs': expected_cmdargs[variant_platform],
+ 'cppdefines': expected_cppdefines[variant_platform],
+ 'cpppaths': expected_cpppaths[variant_platform],
+ }
+
# Create parameter environment with final parameter dictionary
param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
[list(l) for l in zip(*param_configs)])))
param_dict['cmdargs'] = param_cmdargs
+ param_dict['cppdefines'] = param_cppdefines
+ param_dict['cpppaths'] = param_cpppaths
# Hack to be able to run the test with a 'DummyEnv'
class _DummyEnv(DummyEnv):
- def subst(self, string) :
+ def subst(self, string, *args, **kwargs):
return string
env = _DummyEnv(param_dict)
env['MSVSSCONSCRIPT'] = ''
env['MSVS_VERSION'] = self.highest_version
+ env['MSVSBUILDTARGET'] = 'target'
# Call function to test
genDSP = function_test(dspfile, source, env)
@@ -676,6 +774,16 @@ class msvsTestCase(unittest.TestCase):
for key in list(genDSP.configs.keys()):
self.assertDictEqual(genDSP.configs[key].__dict__, expected_configs[key])
+ genDSP.Build()
+
+ # Delete the resulting file so we don't leave anything behind.
+ for file in [dspfile, dspfile + '.filters']:
+ path = os.path.realpath(file)
+ try:
+ os.remove(path)
+ except OSError:
+ pass
+
class msvs6aTestCase(msvsTestCase):
"""Test MSVS 6 Registry"""
registry = DummyRegistry(regdata_6a + regdata_cv)
@@ -787,6 +895,18 @@ class msvs80TestCase(msvsTestCase):
}
default_install_loc = install_locs['8.0']
+class msvs140TestCase(msvsTestCase):
+ """Test MSVS 140 Registry"""
+ registry = DummyRegistry(regdata_140 + regdata_cv)
+ default_version = '14.0'
+ highest_version = '14.0'
+ number_of_versions = 2
+ install_locs = {
+ '14.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0',
+ 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC'},
+ }
+ default_install_loc = install_locs['14.0']
+
class msvsEmptyTestCase(msvsTestCase):
"""Test Empty Registry"""
registry = DummyRegistry(regdata_none)
@@ -829,6 +949,7 @@ if __name__ == "__main__":
msvs71TestCase,
msvs8ExpTestCase,
msvs80TestCase,
+ msvs140TestCase,
msvsEmptyTestCase,
]
diff --git a/src/engine/SCons/Tool/mwcc.py b/src/engine/SCons/Tool/mwcc.py
index 5cad127..b2b2f5b 100644
--- a/src/engine/SCons/Tool/mwcc.py
+++ b/src/engine/SCons/Tool/mwcc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mwcc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mwcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/mwld.py b/src/engine/SCons/Tool/mwld.py
index 7d7341a..5049c55 100644
--- a/src/engine/SCons/Tool/mwld.py
+++ b/src/engine/SCons/Tool/mwld.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mwld.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mwld.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
diff --git a/src/engine/SCons/Tool/nasm.py b/src/engine/SCons/Tool/nasm.py
index 8871ab6..d4d0a1b 100644
--- a/src/engine/SCons/Tool/nasm.py
+++ b/src/engine/SCons/Tool/nasm.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/nasm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/nasm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py
index 513e672..72b9eef 100644
--- a/src/engine/SCons/Tool/packaging/__init__.py
+++ b/src/engine/SCons/Tool/packaging/__init__.py
@@ -25,7 +25,7 @@ SCons Packaging Tool.
# 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/Tool/packaging/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Environment
@@ -35,11 +35,11 @@ from SCons.Util import is_List, make_path_relative
from SCons.Warnings import warn, Warning
import os
-import imp
+import importlib
__all__ = [
- 'src_targz', 'src_tarbz2', 'src_xz', 'src_zip',
- 'targz', 'tarbz2', 'xz', 'zip',
+ 'src_targz', 'src_tarbz2', 'src_tarxz', 'src_zip',
+ 'targz', 'tarbz2', 'tarxz', 'zip',
'rpm', 'msi', 'ipk',
]
@@ -122,12 +122,12 @@ def Package(env, target=None, source=None, **kw):
# load the needed packagers.
def load_packager(type):
try:
- file,path,desc=imp.find_module(type, __path__)
- return imp.load_module(type, file, path, desc)
+ # the specific packager is a relative import
+ return importlib.import_module("." + type, __name__)
except ImportError as e:
- raise EnvironmentError("packager %s not available: %s"%(type,str(e)))
+ raise SConsEnvironmentError("packager %s not available: %s" % (type, str(e)))
- packagers=list(map(load_packager, PACKAGETYPE))
+ packagers = list(map(load_packager, PACKAGETYPE))
# set up targets and the PACKAGEROOT
try:
diff --git a/src/engine/SCons/Tool/packaging/ipk.py b/src/engine/SCons/Tool/packaging/ipk.py
index 60cd3cb..dbf5be8 100644
--- a/src/engine/SCons/Tool/packaging/ipk.py
+++ b/src/engine/SCons/Tool/packaging/ipk.py
@@ -3,7 +3,7 @@
#
# 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
# "Software"), to deal in the Software without restriction, including
@@ -24,7 +24,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/ipk.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/ipk.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
@@ -117,17 +117,17 @@ def build_specfiles(source, target, env):
#
#
opened_files={}
- def open_file(needle, haystack):
+ def open_file(needle, haystack=None):
try:
return opened_files[needle]
except KeyError:
files = filter(lambda x: x.get_path().rfind(needle) != -1, haystack)
# Py3: filter returns an iterable, not a list
file = list(files)[0]
- opened_files[needle]=open(file.get_abspath(), 'w')
+ opened_files[needle] = open(file.get_abspath(), 'w')
return opened_files[needle]
- control_file=open_file('control', target)
+ control_file = open_file('control', target)
if 'X_IPK_DESCRIPTION' not in env:
env['X_IPK_DESCRIPTION']="%s\n %s"%(env['SUMMARY'],
@@ -149,7 +149,7 @@ Description: $X_IPK_DESCRIPTION
control_file.write(env.subst(content))
#
- # now handle the various other files, which purpose it is to set post-,
+ # now handle the various other files, which purpose it is to set post-,
# pre-scripts and mark files as config files.
#
# We do so by filtering the source files for files which are marked with
@@ -161,14 +161,14 @@ Description: $X_IPK_DESCRIPTION
# into the same named file.
#
for f in [x for x in source if 'PACKAGING_CONFIG' in dir(x)]:
- config=open_file('conffiles')
+ config = open_file('conffiles')
config.write(f.PACKAGING_INSTALL_LOCATION)
config.write('\n')
for str in 'POSTRM PRERM POSTINST PREINST'.split():
name="PACKAGING_X_IPK_%s"%str
for f in [x for x in source if name in dir(x)]:
- file=open_file(name)
+ file = open_file(name)
file.write(env[str])
#
diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py
index 4e8724b..4a48b47 100644
--- a/src/engine/SCons/Tool/packaging/msi.py
+++ b/src/engine/SCons/Tool/packaging/msi.py
@@ -25,7 +25,7 @@ The msi packager.
# 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/Tool/packaging/msi.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/msi.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import SCons
@@ -188,7 +188,7 @@ def build_wxsfile(target, source, env):
""" Compiles a .wxs file from the keywords given in env['msi_spec'] and
by analyzing the tree of source nodes and their tags.
"""
- file = open(target[0].get_abspath(), 'w')
+ f = open(target[0].get_abspath(), 'w')
try:
# Create a document with the Wix root tag
@@ -209,7 +209,7 @@ def build_wxsfile(target, source, env):
build_license_file(target[0].get_dir(), env)
# write the xml to a file
- file.write( doc.toprettyxml() )
+ f.write( doc.toprettyxml() )
# call a user specified function
if 'CHANGE_SPECFILE' in env:
@@ -217,6 +217,8 @@ def build_wxsfile(target, source, env):
except KeyError as e:
raise SCons.Errors.UserError( '"%s" package field for MSI is missing.' % e.args[0] )
+ finally:
+ f.close()
#
# setup function
@@ -440,14 +442,13 @@ def build_license_file(directory, spec):
pass # ignore this as X_MSI_LICENSE_TEXT is optional
if name!='' or text!='':
- file = open( os.path.join(directory.get_path(), 'License.rtf'), 'w' )
- file.write('{\\rtf')
- if text!='':
- file.write(text.replace('\n', '\\par '))
- else:
- file.write(name+'\\par\\par')
- file.write('}')
- file.close()
+ with open(os.path.join(directory.get_path(), 'License.rtf'), 'w') as f:
+ f.write('{\\rtf')
+ if text!='':
+ f.write(text.replace('\n', '\\par '))
+ else:
+ f.write(name+'\\par\\par')
+ f.write('}')
#
# mandatory and optional package tags
diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py
index 48b9aab..a948e29 100644
--- a/src/engine/SCons/Tool/packaging/rpm.py
+++ b/src/engine/SCons/Tool/packaging/rpm.py
@@ -25,7 +25,7 @@ The rpm packager.
# 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/Tool/packaging/rpm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/rpm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
@@ -125,11 +125,11 @@ def build_specfile(target, source, env):
""" Builds a RPM specfile from a dictionary with string metadata and
by analyzing a tree of nodes.
"""
- with open(target[0].get_abspath(), 'w') as file:
+ with open(target[0].get_abspath(), 'w') as ofp:
try:
- file.write(build_specfile_header(env))
- file.write(build_specfile_sections(env))
- file.write(build_specfile_filesection(env, source))
+ ofp.write(build_specfile_header(env))
+ ofp.write(build_specfile_sections(env))
+ ofp.write(build_specfile_filesection(env, source))
# call a user specified function
if 'CHANGE_SPECFILE' in env:
diff --git a/src/engine/SCons/Tool/packaging/src_tarbz2.py b/src/engine/SCons/Tool/packaging/src_tarbz2.py
index 473ce75..b628ccd 100644
--- a/src/engine/SCons/Tool/packaging/src_tarbz2.py
+++ b/src/engine/SCons/Tool/packaging/src_tarbz2.py
@@ -26,7 +26,7 @@ The tarbz2 SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/src_tarbz2.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/src_tarbz2.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/src_targz.py b/src/engine/SCons/Tool/packaging/src_targz.py
index 865b8dd..4c7469c 100644
--- a/src/engine/SCons/Tool/packaging/src_targz.py
+++ b/src/engine/SCons/Tool/packaging/src_targz.py
@@ -26,7 +26,7 @@ The targz SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/src_targz.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/src_targz.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/src_tarxz.py b/src/engine/SCons/Tool/packaging/src_tarxz.py
index 07ffdb0..6688c46 100644
--- a/src/engine/SCons/Tool/packaging/src_tarxz.py
+++ b/src/engine/SCons/Tool/packaging/src_tarxz.py
@@ -26,7 +26,7 @@ The tarxz SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/src_tarxz.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/src_tarxz.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/src_zip.py b/src/engine/SCons/Tool/packaging/src_zip.py
index 819e52a..d56f3aa 100644
--- a/src/engine/SCons/Tool/packaging/src_zip.py
+++ b/src/engine/SCons/Tool/packaging/src_zip.py
@@ -26,7 +26,7 @@ The zip SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/src_zip.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/src_zip.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/tarbz2.py b/src/engine/SCons/Tool/packaging/tarbz2.py
index 5658de3..e371f1b 100644
--- a/src/engine/SCons/Tool/packaging/tarbz2.py
+++ b/src/engine/SCons/Tool/packaging/tarbz2.py
@@ -26,7 +26,7 @@ The tarbz2 packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/tarbz2.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/tarbz2.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/targz.py b/src/engine/SCons/Tool/packaging/targz.py
index f515f1e..121e4a4 100644
--- a/src/engine/SCons/Tool/packaging/targz.py
+++ b/src/engine/SCons/Tool/packaging/targz.py
@@ -26,7 +26,7 @@ The targz packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/targz.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/targz.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/tarxz.py b/src/engine/SCons/Tool/packaging/tarxz.py
index 5f7a8d8..3ec9822 100644
--- a/src/engine/SCons/Tool/packaging/tarxz.py
+++ b/src/engine/SCons/Tool/packaging/tarxz.py
@@ -26,7 +26,7 @@ The tarxz packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/tarxz.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/tarxz.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/zip.py b/src/engine/SCons/Tool/packaging/zip.py
index 2ae496e..11ab3b5 100644
--- a/src/engine/SCons/Tool/packaging/zip.py
+++ b/src/engine/SCons/Tool/packaging/zip.py
@@ -26,7 +26,7 @@ The zip SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/zip.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/zip.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
diff --git a/src/engine/SCons/Tool/pdf.py b/src/engine/SCons/Tool/pdf.py
index da970ff..50988b6 100644
--- a/src/engine/SCons/Tool/pdf.py
+++ b/src/engine/SCons/Tool/pdf.py
@@ -28,7 +28,7 @@ Add an explicit action to run epstopdf to convert .eps files to .pdf
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/pdf.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/pdf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Builder
import SCons.Tool
diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py
index 2a97d0f..2c559f7 100644
--- a/src/engine/SCons/Tool/pdflatex.py
+++ b/src/engine/SCons/Tool/pdflatex.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/pdflatex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/pdflatex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Util
diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py
index 80913ae..c658aa0 100644
--- a/src/engine/SCons/Tool/pdftex.py
+++ b/src/engine/SCons/Tool/pdftex.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/pdftex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/pdftex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import SCons.Action
diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py
index e8b0325..a582e6f 100644
--- a/src/engine/SCons/Tool/qt.py
+++ b/src/engine/SCons/Tool/qt.py
@@ -33,7 +33,7 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/qt.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/qt.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
@@ -66,11 +66,17 @@ if SCons.Util.case_sensitive_suffixes('.h', '.H'):
cxx_suffixes = cplusplus.CXXSuffixes
-#
def find_platform_specific_qt_paths():
"""
- If the platform has non-standard paths which it installs QT in,return the likely default path
- :return:
+ find non-standard QT paths
+
+ If the platform does not put QT tools in standard search paths,
+ the path is expected to be set using QTDIR. SCons violates
+ the normal rule of not pulling from the user's environment
+ in this case. However, some test cases try to validate what
+ happens when QTDIR is unset, so we need to try to make a guess.
+
+ :return: a guess at a path
"""
# qt_bin_dirs = []
@@ -83,6 +89,7 @@ def find_platform_specific_qt_paths():
# Centos installs QT under /usr/{lib,lib64}/qt{4,5,-3.3}/bin
# so we need to handle this differently
# qt_bin_dirs = glob.glob('/usr/lib64/qt*/bin')
+ # TODO: all current Fedoras do the same, need to look deeper here.
qt_bin_dir = '/usr/lib64/qt-3.3/bin'
return qt_bin_dir
@@ -97,7 +104,7 @@ def checkMocIncluded(target, source, env):
# not really sure about the path transformations (moc.cwd? cpp.cwd?) :-/
path = SCons.Defaults.CScan.path(env, moc.cwd)
includes = SCons.Defaults.CScan(cpp, env, path)
- if not moc in includes:
+ if moc not in includes:
SCons.Warnings.warn(
GeneratedMocFileNotIncluded,
"Generated moc file '%s' is not included by '%s'" %
@@ -118,7 +125,7 @@ class _Automoc(object):
def __init__(self, objBuilderName):
self.objBuilderName = objBuilderName
-
+
def __call__(self, target, source, env):
"""
Smart autoscan function. Gets the list of objects for the Program
@@ -133,25 +140,25 @@ class _Automoc(object):
debug = int(env.subst('$QT_DEBUG'))
except ValueError:
debug = 0
-
+
# some shortcuts used in the scanner
splitext = SCons.Util.splitext
objBuilder = getattr(env, self.objBuilderName)
-
+
# some regular expressions:
# Q_OBJECT detection
- q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
+ q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
# cxx and c comment 'eater'
#comment = re.compile(r'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
# CW: something must be wrong with the regexp. See also bug #998222
# CURRENTLY THERE IS NO TEST CASE FOR THAT
-
+
# The following is kind of hacky to get builders working properly (FIXME)
objBuilderEnv = objBuilder.env
objBuilder.env = env
mocBuilderEnv = env.Moc.env
env.Moc.env = env
-
+
# make a deep copy for the result; MocH objects will be appended
out_sources = source[:]
@@ -164,7 +171,7 @@ class _Automoc(object):
cpp = obj.sources[0]
if not splitext(str(cpp))[1] in cxx_suffixes:
if debug:
- print("scons: qt: '%s' is no cxx file. Discarded." % str(cpp))
+ print("scons: qt: '%s' is no cxx file. Discarded." % str(cpp))
# c or fortran source
continue
#cpp_contents = comment.sub('', cpp.get_text_contents())
@@ -260,7 +267,7 @@ def uicScannerFunc(node, env, path):
return result
uicScanner = SCons.Scanner.Base(uicScannerFunc,
- name = "UicScanner",
+ name = "UicScanner",
node_class = SCons.Node.FS.File,
node_factory = SCons.Node.FS.File,
recursive = 0)
@@ -336,7 +343,7 @@ def generate(env):
mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX'
- # register the builders
+ # register the builders
env['BUILDERS']['Uic'] = uicBld
env['BUILDERS']['Moc'] = mocBld
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
diff --git a/src/engine/SCons/Tool/rmic.py b/src/engine/SCons/Tool/rmic.py
index 1d401fd..d6f7b2b 100644
--- a/src/engine/SCons/Tool/rmic.py
+++ b/src/engine/SCons/Tool/rmic.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/rmic.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rmic.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
@@ -110,11 +110,9 @@ def generate(env):
if env['PLATFORM'] == 'win32':
version = env.get('JAVAVERSION', None)
- default_paths=get_java_install_dirs(env['PLATFORM'], version=version)
-
# Ensure that we have a proper path for rmic
- rmic = SCons.Tool.find_program_path(env, 'rmic', default_paths=default_paths)
-
+ paths = get_java_install_dirs('win32', version=version)
+ rmic = SCons.Tool.find_program_path(env, 'rmic', default_paths=paths)
# print("RMIC: %s"%rmic)
if rmic:
rmic_bin_dir = os.path.dirname(rmic)
diff --git a/src/engine/SCons/Tool/rpcgen.py b/src/engine/SCons/Tool/rpcgen.py
index 349af6a..b9f8ca6 100644
--- a/src/engine/SCons/Tool/rpcgen.py
+++ b/src/engine/SCons/Tool/rpcgen.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/rpcgen.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rpcgen.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Builder import Builder
import SCons.Util
diff --git a/src/engine/SCons/Tool/rpm.py b/src/engine/SCons/Tool/rpm.py
index 61e4185..0253365 100644
--- a/src/engine/SCons/Tool/rpm.py
+++ b/src/engine/SCons/Tool/rpm.py
@@ -33,7 +33,7 @@ tar.gz consisting of the source file and a specfile.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/rpm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rpm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import re
@@ -51,43 +51,44 @@ def get_cmd(source, env):
if SCons.Util.is_List(source):
tar_file_with_included_specfile = source[0]
return "%s %s %s"%(env['RPM'], env['RPMFLAGS'],
- tar_file_with_included_specfile.get_abspath() )
+ tar_file_with_included_specfile.get_abspath())
def build_rpm(target, source, env):
# create a temporary rpm build root.
- tmpdir = os.path.join( os.path.dirname( target[0].get_abspath() ), 'rpmtemp' )
+ tmpdir = os.path.join(os.path.dirname(target[0].get_abspath()), 'rpmtemp')
if os.path.exists(tmpdir):
shutil.rmtree(tmpdir)
# now create the mandatory rpm directory structure.
for d in ['RPMS', 'SRPMS', 'SPECS', 'BUILD']:
- os.makedirs( os.path.join( tmpdir, d ) )
+ os.makedirs(os.path.join(tmpdir, d))
# set the topdir as an rpmflag.
- env.Prepend( RPMFLAGS = '--define \'_topdir %s\'' % tmpdir )
+ env.Prepend(RPMFLAGS = '--define \'_topdir %s\'' % tmpdir)
# now call rpmbuild to create the rpm package.
handle = subprocess.Popen(get_cmd(source, env),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True)
- output = SCons.Util.to_str(handle.stdout.read())
+ with handle.stdout:
+ output = SCons.Util.to_str(handle.stdout.read())
status = handle.wait()
if status:
- raise SCons.Errors.BuildError( node=target[0],
- errstr=output,
- filename=str(target[0]) )
+ raise SCons.Errors.BuildError(node=target[0],
+ errstr=output,
+ filename=str(target[0]))
else:
# XXX: assume that LC_ALL=C is set while running rpmbuild
- output_files = re.compile( 'Wrote: (.*)' ).findall( output )
+ output_files = re.compile('Wrote: (.*)').findall(output)
- for output, input in zip( output_files, target ):
+ for output, input in zip(output_files, target):
rpm_output = os.path.basename(output)
expected = os.path.basename(input.get_path())
assert expected == rpm_output, "got %s but expected %s" % (rpm_output, expected)
- shutil.copy( output, input.get_abspath() )
+ shutil.copy(output, input.get_abspath())
# cleanup before leaving.
diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py
index 10bb28d..a2400ff 100644
--- a/src/engine/SCons/Tool/rpmutils.py
+++ b/src/engine/SCons/Tool/rpmutils.py
@@ -36,7 +36,7 @@ exact syntax.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/rpmutils.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rpmutils.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import platform
@@ -482,9 +482,11 @@ def updateRpmDicts(rpmrc, pyfile):
"""
try:
# Read old rpmutils.py file
- oldpy = open(pyfile,"r").readlines()
+ with open(pyfile,"r") as f:
+ oldpy = f.readlines()
# Read current rpmrc.in file
- rpm = open(rpmrc,"r").readlines()
+ with open(rpmrc,"r") as f:
+ rpm = f.readlines()
# Parse for data
data = {}
# Allowed section names that get parsed
@@ -511,24 +513,23 @@ def updateRpmDicts(rpmrc, pyfile):
# Insert data
data[key][tokens[1]] = tokens[2:]
# Write new rpmutils.py file
- out = open(pyfile,"w")
- pm = 0
- for l in oldpy:
- if pm:
- if l.startswith('# End of rpmrc dictionaries'):
- pm = 0
+ with open(pyfile,"w") as out:
+ pm = 0
+ for l in oldpy:
+ if pm:
+ if l.startswith('# End of rpmrc dictionaries'):
+ pm = 0
+ out.write(l)
+ else:
out.write(l)
- else:
- out.write(l)
- if l.startswith('# Start of rpmrc dictionaries'):
- pm = 1
- # Write data sections to single dictionaries
- for key, entries in data.items():
- out.write("%s = {\n" % key)
- for arch in sorted(entries.keys()):
- out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch])))
- out.write("}\n\n")
- out.close()
+ if l.startswith('# Start of rpmrc dictionaries'):
+ pm = 1
+ # Write data sections to single dictionaries
+ for key, entries in data.items():
+ out.write("%s = {\n" % key)
+ for arch in sorted(entries.keys()):
+ out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch])))
+ out.write("}\n\n")
except:
pass
diff --git a/src/engine/SCons/Tool/sgiar.py b/src/engine/SCons/Tool/sgiar.py
index 152afd4..d82ec89 100644
--- a/src/engine/SCons/Tool/sgiar.py
+++ b/src/engine/SCons/Tool/sgiar.py
@@ -33,7 +33,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgiar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgiar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/sgic++.py b/src/engine/SCons/Tool/sgic++.py
index 35f913f..84d775a 100644
--- a/src/engine/SCons/Tool/sgic++.py
+++ b/src/engine/SCons/Tool/sgic++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgic++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgic++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
from SCons.Tool.sgicxx import *
diff --git a/src/engine/SCons/Tool/sgicc.py b/src/engine/SCons/Tool/sgicc.py
index c5461e3..537f1a3 100644
--- a/src/engine/SCons/Tool/sgicc.py
+++ b/src/engine/SCons/Tool/sgicc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgicc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgicc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import cc
diff --git a/src/engine/SCons/Tool/sgicxx.py b/src/engine/SCons/Tool/sgicxx.py
index 7656939..d44ec26 100644
--- a/src/engine/SCons/Tool/sgicxx.py
+++ b/src/engine/SCons/Tool/sgicxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgicxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgicxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sgilink.py b/src/engine/SCons/Tool/sgilink.py
index 366b227..ca9e69c 100644
--- a/src/engine/SCons/Tool/sgilink.py
+++ b/src/engine/SCons/Tool/sgilink.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgilink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgilink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sunar.py b/src/engine/SCons/Tool/sunar.py
index 6745511..07d45b2 100644
--- a/src/engine/SCons/Tool/sunar.py
+++ b/src/engine/SCons/Tool/sunar.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/sunc++.py b/src/engine/SCons/Tool/sunc++.py
index f1bbf14..1611fe9 100644
--- a/src/engine/SCons/Tool/sunc++.py
+++ b/src/engine/SCons/Tool/sunc++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunc++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunc++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
diff --git a/src/engine/SCons/Tool/suncc.py b/src/engine/SCons/Tool/suncc.py
index 49cfa70..da6ca6e 100644
--- a/src/engine/SCons/Tool/suncc.py
+++ b/src/engine/SCons/Tool/suncc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/suncc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/suncc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/suncxx.py b/src/engine/SCons/Tool/suncxx.py
index 1fa5331..1ee1c6a 100644
--- a/src/engine/SCons/Tool/suncxx.py
+++ b/src/engine/SCons/Tool/suncxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/suncxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/suncxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons
@@ -52,11 +52,17 @@ def get_package_info(package_name, pkginfo, pkgchk):
version = None
pathname = None
try:
- sadm_contents = open('/var/sadm/install/contents', 'r').read()
+ from subprocess import DEVNULL # py3k
+ except ImportError:
+ DEVNULL = open(os.devnull, 'wb')
+
+ try:
+ with open('/var/sadm/install/contents', 'r') as f:
+ sadm_contents = f.read()
except EnvironmentError:
pass
else:
- sadm_re = re.compile('^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M)
+ sadm_re = re.compile(r'^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M)
sadm_match = sadm_re.search(sadm_contents)
if sadm_match:
pathname = os.path.dirname(sadm_match.group(1))
@@ -64,12 +70,12 @@ def get_package_info(package_name, pkginfo, pkgchk):
try:
p = subprocess.Popen([pkginfo, '-l', package_name],
stdout=subprocess.PIPE,
- stderr=open('/dev/null', 'w'))
+ stderr=DEVNULL)
except EnvironmentError:
pass
else:
pkginfo_contents = p.communicate()[0]
- version_re = re.compile('^ *VERSION:\s*(.*)$', re.M)
+ version_re = re.compile(r'^ *VERSION:\s*(.*)$', re.M)
version_match = version_re.search(pkginfo_contents)
if version_match:
version = version_match.group(1)
@@ -78,7 +84,7 @@ def get_package_info(package_name, pkginfo, pkgchk):
try:
p = subprocess.Popen([pkgchk, '-l', package_name],
stdout=subprocess.PIPE,
- stderr=open('/dev/null', 'w'))
+ stderr=DEVNULL)
except EnvironmentError:
pass
else:
diff --git a/src/engine/SCons/Tool/sunf77.py b/src/engine/SCons/Tool/sunf77.py
index 1d9487d..c1c216f 100644
--- a/src/engine/SCons/Tool/sunf77.py
+++ b/src/engine/SCons/Tool/sunf77.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunf77.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunf77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sunf90.py b/src/engine/SCons/Tool/sunf90.py
index 4de62c3..4cabee8 100644
--- a/src/engine/SCons/Tool/sunf90.py
+++ b/src/engine/SCons/Tool/sunf90.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunf90.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunf90.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sunf95.py b/src/engine/SCons/Tool/sunf95.py
index 6d1ccf6..077b1bc 100644
--- a/src/engine/SCons/Tool/sunf95.py
+++ b/src/engine/SCons/Tool/sunf95.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunf95.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunf95.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sunlink.py b/src/engine/SCons/Tool/sunlink.py
index 1eca1b2..8d965fa 100644
--- a/src/engine/SCons/Tool/sunlink.py
+++ b/src/engine/SCons/Tool/sunlink.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunlink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunlink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index a207a89..2e61b91 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -32,7 +32,7 @@ from __future__ import print_function
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/swig.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/swig.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
@@ -184,9 +184,10 @@ def generate(env):
from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
if sys.platform == 'win32':
- swig = SCons.Tool.find_program_path(env, 'swig', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS + [r'C:\ProgramData\chocolatey\bin'] )
+ swig = SCons.Tool.find_program_path(env, 'swig', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS + CHOCO_DEFAULT_PATH)
if swig:
swig_bin_dir = os.path.dirname(swig)
env.AppendENVPath('PATH', swig_bin_dir)
diff --git a/src/engine/SCons/Tool/tar.py b/src/engine/SCons/Tool/tar.py
index ac4f7f7..08c80f2 100644
--- a/src/engine/SCons/Tool/tar.py
+++ b/src/engine/SCons/Tool/tar.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/tar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/tar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py
index 2fecd1d..9beb557 100644
--- a/src/engine/SCons/Tool/tex.py
+++ b/src/engine/SCons/Tool/tex.py
@@ -33,7 +33,7 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/tex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/tex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
@@ -781,7 +781,7 @@ def tex_emitter_core(target, source, env, graphics_extensions):
# add side effects if feature is present.If file is to be generated,add all side effects
if Verbose and theSearch:
print("check side effects for ",suffix_list[-1])
- if (theSearch != None) or (not source[0].exists() ):
+ if theSearch is not None or not source[0].exists():
file_list = [targetbase,]
# for bibunit we need a list of files
if suffix_list[-1] == 'bibunit':
diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py
index bbbde9f..58a5007 100644
--- a/src/engine/SCons/Tool/textfile.py
+++ b/src/engine/SCons/Tool/textfile.py
@@ -44,7 +44,7 @@ Textfile/Substfile builder for SCons.
is unpredictable whether the expansion will occur.
"""
-__revision__ = "src/engine/SCons/Tool/textfile.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/textfile.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons
diff --git a/src/engine/SCons/Tool/tlib.py b/src/engine/SCons/Tool/tlib.py
index e1483a2..4d8101b 100644
--- a/src/engine/SCons/Tool/tlib.py
+++ b/src/engine/SCons/Tool/tlib.py
@@ -27,7 +27,7 @@ XXX
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/tlib.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/tlib.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
import SCons.Tool.bcc32
diff --git a/src/engine/SCons/Tool/wix.py b/src/engine/SCons/Tool/wix.py
index bba033e..e79e4a1 100644
--- a/src/engine/SCons/Tool/wix.py
+++ b/src/engine/SCons/Tool/wix.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/wix.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/wix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Builder
import SCons.Action
diff --git a/src/engine/SCons/Tool/wixTests.py b/src/engine/SCons/Tool/wixTests.py
index c1812a2..f2649a3 100644
--- a/src/engine/SCons/Tool/wixTests.py
+++ b/src/engine/SCons/Tool/wixTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/wixTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/wixTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import unittest
import os.path
diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py
index 3f11357..185558e 100644
--- a/src/engine/SCons/Tool/xgettext.py
+++ b/src/engine/SCons/Tool/xgettext.py
@@ -24,7 +24,24 @@ Tool specific initialization of `xgettext` tool.
# 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/Tool/xgettext.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/xgettext.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+
+import os
+import re
+import subprocess
+import sys
+
+import SCons.Action
+import SCons.Node.FS
+import SCons.Tool
+import SCons.Util
+from SCons.Builder import BuilderBase
+from SCons.Environment import _null
+from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
+from SCons.Tool.GettextCommon import _POTargetFactory
+from SCons.Tool.GettextCommon import RPaths, _detect_xgettext
+from SCons.Tool.GettextCommon import _xgettext_exists
#############################################################################
@@ -41,10 +58,6 @@ class _CmdRunner(object):
self.commandstr = commandstr
def __call__(self, target, source, env):
- import SCons.Action
- import subprocess
- import os
- import sys
kw = {
'stdin': 'devnull',
'stdout': subprocess.PIPE,
@@ -57,11 +70,10 @@ class _CmdRunner(object):
self.out, self.err = proc.communicate()
self.status = proc.wait()
if self.err:
- sys.stderr.write(unicode(self.err))
+ sys.stderr.write(SCons.Util.UnicodeType(self.err))
return self.status
def strfunction(self, target, source, env):
- import os
comstr = self.commandstr
if env.subst(comstr, target=target, source=source) == "":
comstr = self.command
@@ -74,9 +86,6 @@ class _CmdRunner(object):
#############################################################################
def _update_pot_file(target, source, env):
""" Action function for `POTUpdate` builder """
- import re
- import os
- import SCons.Action
nop = lambda target, source, env: 0
# Save scons cwd and os cwd (NOTE: they may be different. After the job, we
@@ -154,10 +163,6 @@ def _update_pot_file(target, source, env):
#############################################################################
#############################################################################
-from SCons.Builder import BuilderBase
-
-
-#############################################################################
class _POTBuilder(BuilderBase):
def _execute(self, env, target, source, *args):
if not target:
@@ -175,10 +180,6 @@ class _POTBuilder(BuilderBase):
def _scan_xgettext_from_files(target, source, env, files=None, path=None):
""" Parses `POTFILES.in`-like file and returns list of extracted file names.
"""
- import re
- import SCons.Util
- import SCons.Node.FS
-
if files is None:
return 0
if not SCons.Util.is_List(files):
@@ -230,10 +231,6 @@ def _scan_xgettext_from_files(target, source, env, files=None, path=None):
#############################################################################
def _pot_update_emitter(target, source, env):
""" Emitter function for `POTUpdate` builder """
- from SCons.Tool.GettextCommon import _POTargetFactory
- import SCons.Util
- import SCons.Node.FS
-
if 'XGETTEXTFROM' in env:
xfrom = env['XGETTEXTFROM']
else:
@@ -261,10 +258,6 @@ def _pot_update_emitter(target, source, env):
#############################################################################
#############################################################################
-from SCons.Environment import _null
-
-
-#############################################################################
def _POTUpdateBuilderWrapper(env, target=None, source=_null, **kw):
return env._POTUpdateBuilder(target, source, **kw)
@@ -274,8 +267,6 @@ def _POTUpdateBuilderWrapper(env, target=None, source=_null, **kw):
#############################################################################
def _POTUpdateBuilder(env, **kw):
""" Creates `POTUpdate` builder object """
- import SCons.Action
- from SCons.Tool.GettextCommon import _POTargetFactory
kw['action'] = SCons.Action.Action(_update_pot_file, None)
kw['suffix'] = '$POTSUFFIX'
kw['target_factory'] = _POTargetFactory(env, alias='$POTUPDATE_ALIAS').File
@@ -288,13 +279,6 @@ def _POTUpdateBuilder(env, **kw):
#############################################################################
def generate(env, **kw):
""" Generate `xgettext` tool """
- import sys
- import os
- import SCons.Util
- import SCons.Tool
- from SCons.Tool.GettextCommon import RPaths, _detect_xgettext
- from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
- from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
if sys.platform == 'win32':
xgettext = SCons.Tool.find_program_path(env, 'xgettext', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
@@ -359,7 +343,6 @@ def generate(env, **kw):
#############################################################################
def exists(env):
""" Check, whether the tool exists """
- from SCons.Tool.GettextCommon import _xgettext_exists
try:
return _xgettext_exists(env)
except:
diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py
index d397de1..6857574 100644
--- a/src/engine/SCons/Tool/yacc.py
+++ b/src/engine/SCons/Tool/yacc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/yacc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/yacc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
@@ -45,6 +45,11 @@ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
YaccAction = SCons.Action.Action("$YACCCOM", "$YACCCOMSTR")
+if sys.platform == 'win32':
+ BINS = ['bison', 'yacc', 'win_bison']
+else:
+ BINS = ["bison", "yacc"]
+
def _yaccEmitter(target, source, env, ysuf, hsuf):
yaccflags = env.subst("$YACCFLAGS", target=target, source=source)
flags = SCons.Util.CLVar(yaccflags)
@@ -100,25 +105,26 @@ def yyEmitter(target, source, env):
def get_yacc_path(env, append_paths=False):
"""
- Find the a path containing the lex or flex binaries. If a construction
- environment is passed in then append the path to the ENV PATH.
- """
- # save existing path to reset if we don't want to append any paths
- envPath = env['ENV']['PATH']
- bins = ['bison', 'yacc', 'win_bison']
+ Find the path to the yacc tool, searching several possible names
+
+ Only called in the Windows case, so the default_path
+ can be Windows-specific
- for prog in bins:
+ :param env: current construction environment
+ :param append_paths: if set, add the path to the tool to PATH
+ :return: path to yacc tool, if found
+ """
+ for prog in BINS:
bin_path = SCons.Tool.find_program_path(
- env,
- prog,
+ env,
+ prog,
default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
if bin_path:
- if not append_paths:
- env['ENV']['PATH'] = envPath
- else:
+ if append_paths:
env.AppendENVPath('PATH', os.path.dirname(bin_path))
return bin_path
- SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH')
+ SCons.Warnings.Warning('yacc tool requested, but yacc or bison binary not found in ENV PATH')
+
def generate(env):
"""Add Builders and construction variables for yacc to an Environment."""
@@ -140,29 +146,21 @@ def generate(env):
cxx_file.add_emitter('.yy', yyEmitter)
if sys.platform == 'win32':
- bison = SCons.Tool.find_program_path(env, 'bison', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
- if bison:
- bison_bin_dir = os.path.dirname(bison)
- env.AppendENVPath('PATH', bison_bin_dir)
- else:
- SCons.Warnings.Warning('yacc tool requested, but bison binary not found in ENV PATH')
+ # ignore the return, all we need is for the path to be added
+ _ = get_yacc_path(env, append_paths=True)
- if sys.platform == 'win32':
- get_yacc_path(env, append_paths=True)
- env["YACC"] = env.Detect(['bison', 'yacc', 'win_bison'])
- else:
- env["YACC"] = env.Detect(["bison", "yacc"])
-
+ env["YACC"] = env.Detect(BINS)
env['YACCFLAGS'] = SCons.Util.CLVar('')
env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES'
env['YACCHFILESUFFIX'] = '.h'
-
env['YACCHXXFILESUFFIX'] = '.hpp'
-
env['YACCVCGFILESUFFIX'] = '.vcg'
def exists(env):
- return env.Detect(['bison', 'yacc'])
+ if sys.platform == 'win32':
+ return get_yacc_path(env)
+ else:
+ return env.Detect(BINS)
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/zip.py b/src/engine/SCons/Tool/zip.py
index 55792c2..b7efdc7 100644
--- a/src/engine/SCons/Tool/zip.py
+++ b/src/engine/SCons/Tool/zip.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/zip.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/zip.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path