diff options
205 files changed, 1812 insertions, 1310 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index c46a804..a23140c 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,102 @@ Change Log +RELEASE 3.1.0 - Mon, 20 Jul 2019 16:59:23 -0700 + + From Joseph Brill: + - Code to supply correct version-specifier argument to vswhere for + VS version selection. + + From William Deegan: + - Enhanced --debug=explain output. Now the separate components of the dependency list are split up + as follows: + + scons: rebuilding `file3' because: + the dependency order changed: + ->Sources + Old:xxx New:zzz + Old:yyy New:yyy + Old:zzz New:xxx + ->Depends + ->Implicit + Old:/usr/bin/python New:/usr/bin/python + - Fix Issue #3350 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError. + - Fix spurious rebuilds on second build for cases where builder has > 1 target and the source file + is generated. This was causing the > 1th target to not have it's implicit list cleared when the source + file was actually built, leaving an implicit list similar to follows for 2nd and higher target + ['/usr/bin/python', 'xxx', 'yyy', 'zzz'] + This was getting persisted to SConsign and on rebuild it would be corrected to be similar to this + ['zzz', 'yyy', 'xxx', '/usr/bin/python'] + Which would trigger a rebuild because the order changed. + The fix involved added logic to mark all shared targets as peers and then ensure they're implicit + list is all cleared together. + - Fix Issue #3349 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError. + Renamed to SConsEnvironmentError + - Fix Issue #3350 - mslink failing when too many objects. This is resolved by adding TEMPFILEARGJOIN variable + which specifies what character to join all the argements output into the tempfile. The default remains a space + when mslink, msvc, or mslib tools are loaded they change the TEMPFILEARGJOIN to be a line separator (\r\n on win32) + - Fix performance degradation for MD5-timestamp decider. NOTE: This changes the Decider() function arguments. + From: + def my_decider(dependency, target, prev_ni): + To: + def my_decider(dependency, target, prev_ni, repo_node): + Where repo_node is the repository (or other) node to use to check if the node is out of date instead of dependency. + + From Peter Diener: + - Additional fix to issue #3135 - Also handle 'pure' and 'elemental' type bound procedures + - Fix issue #3135 - Handle Fortran submodules and type bound procedures + + From Adam Gross: + - Upgraded and improved Visual Studio solution/project generation code using the MSVSProject builder. + - Added support for Visual Studio 2017 and 2019. + - Added support for the following per-variant parameters to the builder: + - cpppaths: Provides per-variant include paths. + - cppdefines: Provides per-variant preprocessor definitions. + + From Michael Hartmann: + - Fix handling of Visual Studio Compilers to properly reject any unknown HOST_PLATFORM or TARGET_PLATFORM + + From Bert Huijben: + - Added support for Visual Studio 2019 toolset. + + From Mathew Robinson: + - Update cache debug output to include cache hit rate. + - No longer unintentionally hide exceptions in Action.py + - Allow builders and pseudo-builders to inherit from OverrideEnvironments + + From Leonard de Ruijter: + - Add logic to derive correct version argument to vswhere + + From Lukas Schrangl: + - Enable LaTeX scanner to find more than one include per line + + From Mats Wichmann: + - scons-time takes more care closing files and uses safer mkdtemp to avoid + possible races on multi-job runs. + - Use importlib to dynamically load tool and platform modules instead of imp module + - sconsign: default to .sconsign.dblite if no filename is specified. + Be more informative in case of unsupported pickle protocol (py2 only). + - Fix issue #3336 - on Windows, paths were being added to PATH even if + tools were not found in those paths. + - More fixes for newer Java versions (since 9): handle new jdk directory + naming (jdk-X.Y instead of jdkX.Y) on Windows; handle two-digit major + version. Docstrings improved. + - Fixups for pylint: exception types, redefined functions, + globals, etc. Some old code removed to resolve issues (hashlib is + always present on modern Pythons; no longer need the code for + 2.5-and-earlier optparse). cmp is not a builtin function in Py3, + drop one (unused) use; replace one. Fix another instance of + renaming to SConsEnvironmentError. Trailing whitespace. + Consistently use not is/in (if not x is y -> if x is not y). + - Add a PY3-only function for setting up the cachedir that should be less + prone to races. Add a hack to the PY2 version (from Issue #3351) to + be less prone to a race in the check for old-style cache. + - Fix coding error in docbook tool only exercised when using python lxml + - Recognize two additional GNU compiler header directory options in + ParseFlags: -iquote and -idirafter. + - Fix more re patterns that contain \ but not specified as raw strings + (affects scanners for D, LaTeX, swig) + RELEASE 3.0.5 - Mon, 26 Mar 2019 15:04:42 -0700 @@ -24,7 +120,7 @@ RELEASE 3.0.5 - Mon, 26 Mar 2019 15:04:42 -0700 From Maciej Kumorek: - Update the MSVC tool to include the nologo flag by default in RCFLAGS - From Daniel Moody: +From Daniel Moody: - Change the default for AppendENVPath to delete_existing=0, so path order will not be changed, unless explicitly set (Issue #3276) - Fixed bug which threw error when running SCons on windows system with no MSVC installed. @@ -191,6 +191,7 @@ engine/SCons/Variables/PathVariable.py engine/SCons/Variables/__init__.py engine/SCons/Warnings.py engine/SCons/__init__.py +engine/SCons/__main__.py engine/SCons/compat/__init__.py engine/SCons/compat/_scons_dbm.py engine/SCons/cpp.py @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: scons -Version: 3.0.5 +Version: 3.1.0 Summary: Open Source next-generation build tool. Home-page: http://www.scons.org/ Author: William Deegan diff --git a/RELEASE.txt b/RELEASE.txt index 90cc745..5927ef8 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -1,43 +1,81 @@ -A new SCons release, 3.0.5, is now available on the SCons download page: + A new SCons checkpoint release, 3.1.0, is now available + on the SCons download page: - https://scons.org/pages/download.html + https://scons.org/pages/download.html + Here is a summary of the changes since 3.0.5: -Here is a summary of the changes since 3.0.4: + NEW FUNCTIONALITY -CHANGED/ENHANCED EXISTING FUNCTIONALITY + - Added variable TEMPFILEARGJOIN to specify how to join arguments written + to temp files used when command lines exceed MAXLINELENGTH when the + command uses $TEMPFILE{...} + - Support for MSVC 2019 + - Upgraded and improved Visual Studio solution/project generation code using the MSVSProject builder. + - Added support for Visual Studio 2017 and 2019. + - Added support for the following per-variant parameters to the builder: + - cpppaths: Provides per-variant include paths. + - cppdefines: Provides per-variant preprocessor definitions. - - Change the default for AppendENVPath to delete_existing=0, so path - order will not be changed, unless explicitly set (Issue #3276) - - Add lex construction variable LEXUNISTD for turning off unix headers on windows - - Update lex tool to use win_flex on windows if available - - Add the textfile tool to the default tool list -FIXES + CHANGED/ENHANCED EXISTING FUNCTIONALITY - - Fix Issue #3283 - Handle using --config=force in combination with Decider('MD5-timestamp'). - 3.0.2 in fix for issue #2980 added that deciders can throw DeciderNeedsNode exception. - The Configure logic directly calls the decider when using --config=force but wasn't handling - that exception. This would yield minimally configure tests using TryLink() not running and - leaving TypeError Nonetype exception in config.log - - Fix Issue #3303 - Handle --config=force overwriting the Environment passed into Configure()'s - Decider and not clearing it when the configure context is completed. - - Add default paths for yacc tool on windows to include cygwin, mingw, and chocolatey - - Fix issue #2799 - Fix mingw tool to respect SHCCCOMSTR, SHLINKCOMSTR and LDMODULECOMSTR - - Fix Issue #3329 - Add support for MS SDK V10.0A (which is commonly installed with VS2017) - - Fix Issue #3333 - Add support for finding vswhere under 32 bit windows installs. - - Update the MSVC tool to include the nologo flag by default in RCFLAGS - - Fixed bug which threw error when running SCons on windows system with no MSVC installed. + - Fix performance degradation for MD5-timestamp decider. NOTE: This changes the Decider() function arguments. + From: + def my_decider(dependency, target, prev_ni): + To: + def my_decider(dependency, target, prev_ni, repo_node): + Where repo_node is the repository (or other) node to use to check if the node is out of date instead of dependency. + - Enhanced --debug=explain output. Now the separate components of the dependency list are split up + as follows: -IMPROVEMENTS - - Do not store build host+user name if reproducible builds are wanted + scons: rebuilding `file3' because: + the dependency order changed: + ->Sources + Old:xxx New:zzz + Old:yyy New:yyy + Old:zzz New:xxx + ->Depends + ->Implicit + Old:/usr/bin/python New:/usr/bin/python + - Changed: Pseudo-builders now inherit OverrideEnvironments. For + example when calling a pseudo-builder from another + pseudo-builder the override variables passed to the first + pseudo-builder call had to be explicitly passed on to the + internal pseudo-builder call. Now the second pseudo-builder call + will automatically inherit these override values. -git shortlog --no-merges -ns 3.0.4..HEAD - 34 William Deegan - 33 Mats Wichmann - 18 Daniel - 4 Daniel Moody - 3 Bernhard M. Wiedemann - 2 Maciej Kumorek + FIXES + - Fix Issue #3350 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError. + - Fix spurious rebuilds on second build for cases where builder has > 1 target and the source file + is generated. This was causing the > 1th target to not have it's implicit list cleared when the source + file was actually built, leaving an implicit list similar to follows for 2nd and higher target + ['/usr/bin/python', 'xxx', 'yyy', 'zzz'] + This was getting persisted to SConsign and on rebuild it would be corrected to be similar to this + ['zzz', 'yyy', 'xxx', '/usr/bin/python'] + Which would trigger a rebuild because the order changed. + The fix involved added logic to mark all shared targets as peers and then ensure they're implicit + list is all cleared together. + - Fix Issue #3349 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError. + Renamed to SConsEnvironmentError + - Fix Issue #3350 - mslink failing when too many objects. This is resolved by adding TEMPFILEARGJOIN variable + which specifies what character to join all the argements output into the tempfile. The default remains a space + when mslink, msvc, or mslib tools are loaded they change the TEMPFILEARGJOIN to be a line separator (\r\n on win32) + - Additional fix to issue #3135 - Also handle 'pure' and 'elemental' type bound procedures + + - Fix handling of Visual Studio Compilers to properly reject any unknown HOST_PLATFORM or TARGET_PLATFORM + - Enable LaTeX scanner to find more than one include per line + + under which they would be observed), or major code cleanups + +git shortlog --no-merges -ns 3.0.5..HEAD + 64 William Deegan + 56 Mats Wichmann + 10 Adam Gross + 4 Mathew Robinson + 4 Peter Diener + 3 Lukas Schrangl + 1 Daniel Holth + 1 bdbaddog diff --git a/engine/SCons/Action.py b/engine/SCons/Action.py index 861db48..b541256 100644 --- a/engine/SCons/Action.py +++ b/engine/SCons/Action.py @@ -98,7 +98,7 @@ way for wrapping up the functions. # 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/Action.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Action.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import pickle @@ -211,7 +211,7 @@ def _object_contents(obj): def _code_contents(code, docstring=None): - """Return the signature contents of a code object. + r"""Return the signature contents of a code object. By providing direct access to the code object of the function, Python makes this extremely easy. Hooray! @@ -534,7 +534,7 @@ class ActionBase(object): result = self.get_presig(target, source, env) if not isinstance(result,(bytes, bytearray)): - result = bytearray("",'utf-8').join([ SCons.Util.to_bytes(r) for r in result ]) + result = bytearray(result, 'utf-8') else: # Make a copy and put in bytearray, without this the contents returned by get_presig # can be changed by the logic below, appending with each call and causing very @@ -767,16 +767,22 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): it'll have to be tweaked to get the full desired functionality. one special arg (so far?), 'error', to tell what to do with exceptions. """ - # allow std{in,out,err} to be "'devnull'" - io = kw.get('stdin') - if is_String(io) and io == 'devnull': - kw['stdin'] = open(os.devnull) - io = kw.get('stdout') - if is_String(io) and io == 'devnull': - kw['stdout'] = open(os.devnull, 'w') - io = kw.get('stderr') - if is_String(io) and io == 'devnull': - kw['stderr'] = open(os.devnull, 'w') + # allow std{in,out,err} to be "'devnull'". This is like + # subprocess.DEVNULL, which does not exist for Py2. Use the + # subprocess one if possible. + # Clean this up when Py2 support is dropped + try: + from subprocess import DEVNULL + except ImportError: + DEVNULL = None + + for stream in 'stdin', 'stdout', 'stderr': + io = kw.get(stream) + if is_String(io) and io == 'devnull': + if DEVNULL: + kw[stream] = DEVNULL + else: + kw[stream] = open(os.devnull, "r+") # Figure out what shell environment to use ENV = kw.get('env', None) @@ -802,7 +808,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): kw['env'] = new_env try: - pobj = subprocess.Popen(cmd, **kw) + pobj = subprocess.Popen(cmd, **kw) except EnvironmentError as e: if error == 'raise': raise # return a dummy Popen instance that only returns error @@ -820,9 +826,10 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw): finally: # clean up open file handles stored in parent's kw for k, v in kw.items(): - if hasattr(v, 'close'): + if inspect.ismethod(getattr(v, 'close', None)): v.close() - return pobj + + return pobj class CommandAction(_ActionAction): @@ -1091,7 +1098,7 @@ class LazyAction(CommandGeneratorAction, CommandAction): def get_parent_class(self, env): c = env.get(self.var) - if is_String(c) and not '\n' in c: + if is_String(c) and '\n' not in c: return CommandAction return CommandGeneratorAction diff --git a/engine/SCons/Builder.py b/engine/SCons/Builder.py index 2d337c9..7777436 100644 --- a/engine/SCons/Builder.py +++ b/engine/SCons/Builder.py @@ -98,7 +98,7 @@ There are the following methods for internal use within this module: # 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/Builder.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Builder.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import collections @@ -274,7 +274,7 @@ def Builder(**kw): result = BuilderBase(**kw) - if not composite is None: + if composite is not None: result = CompositeBuilder(result, composite) return result @@ -293,7 +293,7 @@ def _node_errors(builder, env, tlist, slist): if t.has_explicit_builder(): # Check for errors when the environments are different # No error if environments are the same Environment instance - if (not t.env is None and not t.env is env and + if (t.env is not None and t.env is not env and # Check OverrideEnvironment case - no error if wrapped Environments # are the same instance, and overrides lists match not (getattr(t.env, '__subject', 0) is getattr(env, '__subject', 1) and @@ -309,7 +309,7 @@ def _node_errors(builder, env, tlist, slist): else: try: msg = "Two environments with different actions were specified for the same target: %s\n(action 1: %s)\n(action 2: %s)" % (t,t_contents.decode('utf-8'),contents.decode('utf-8')) - except UnicodeDecodeError as e: + except UnicodeDecodeError: msg = "Two environments with different actions were specified for the same target: %s"%t raise UserError(msg) if builder.multi: @@ -424,7 +424,7 @@ class BuilderBase(object): if name: self.name = name self.executor_kw = {} - if not chdir is _null: + if chdir is not _null: self.executor_kw['chdir'] = chdir self.is_explicit = is_explicit @@ -554,8 +554,10 @@ class BuilderBase(object): result = [] if target is None: target = [None]*len(source) for tgt, src in zip(target, source): - if not tgt is None: tgt = [tgt] - if not src is None: src = [src] + if tgt is not None: + tgt = [tgt] + if src is not None: + src = [src] result.extend(self._execute(env, tgt, src, overwarn)) return SCons.Node.NodeList(result) @@ -563,6 +565,13 @@ class BuilderBase(object): tlist, slist = self._create_nodes(env, target, source) + # If there is more than one target ensure that if we need to reset + # the implicit list to new scan of dependency all targets implicit lists + # are cleared. (SCons GH Issue #2811 and MongoDB SERVER-33111) + if len(tlist) > 1: + for t in tlist: + t.target_peers = tlist + # Check for errors with the specified target/source lists. _node_errors(self, env, tlist, slist) @@ -744,7 +753,7 @@ class BuilderBase(object): for s in SCons.Util.flatten(source): if SCons.Util.is_String(s): match_suffix = match_src_suffix(env.subst(s)) - if not match_suffix and not '.' in s: + if not match_suffix and '.' not in s: src_suf = self.get_src_suffix(env) s = self._adjustixes(s, None, src_suf)[0] else: diff --git a/engine/SCons/CacheDir.py b/engine/SCons/CacheDir.py index 81c74f0..c9e8ea7 100644 --- a/engine/SCons/CacheDir.py +++ b/engine/SCons/CacheDir.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/CacheDir.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/CacheDir.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __doc__ = """ CacheDir support @@ -35,6 +35,7 @@ import sys import SCons.Action import SCons.Warnings +from SCons.Util import PY3 cache_enabled = True cache_debug = False @@ -46,10 +47,12 @@ def CacheRetrieveFunc(target, source, env): t = target[0] fs = t.fs cd = env.get_CacheDir() + cd.requests += 1 cachedir, cachefile = cd.cachepath(t) if not fs.exists(cachefile): cd.CacheDebug('CacheRetrieve(%s): %s not in cache\n', t, cachefile) return 1 + cd.hits += 1 cd.CacheDebug('CacheRetrieve(%s): retrieving from %s\n', t, cachefile) if SCons.Action.execute_actions: if fs.islink(cachefile): @@ -111,7 +114,7 @@ def CachePushFunc(target, source, env): # has beaten us creating the directory. if not fs.isdir(cachedir): msg = errfmt % (str(target), cachefile) - raise SCons.Errors.EnvironmentError(msg) + raise SCons.Errors.SConsEnvironmentError(msg) try: if fs.islink(t.get_internal_path()): @@ -139,34 +142,97 @@ warned = dict() class CacheDir(object): def __init__(self, path): + """ + Initialize a CacheDir object. + + The cache configuration is stored in the object. It + is read from the config file in the supplied path if + one exists, if not the config file is created and + the default config is written, as well as saved in the object. + """ + self.requests = 0 + self.hits = 0 self.path = path self.current_cache_debug = None self.debugFP = None self.config = dict() if path is None: return - # See if there's a config file in the cache directory. If there is, - # use it. If there isn't, and the directory exists and isn't empty, - # produce a warning. If the directory doesn't exist or is empty, - # write a config file. + + if PY3: + self._readconfig3(path) + else: + self._readconfig2(path) + + + def _readconfig3(self, path): + """ + Python3 version of reading the cache config. + + If directory or config file do not exist, create. Take advantage + of Py3 capability in os.makedirs() and in file open(): just try + the operation and handle failure appropriately. + + Omit the check for old cache format, assume that's old enough + there will be none of those left to worry about. + + :param path: path to the cache directory + """ + config_file = os.path.join(path, 'config') + try: + os.makedirs(path, exist_ok=True) + except FileExistsError: + pass + except OSError: + msg = "Failed to create cache directory " + path + raise SCons.Errors.EnvironmentError(msg) + + try: + with open(config_file, 'x') as config: + self.config['prefix_len'] = 2 + try: + json.dump(self.config, config) + except Exception: + msg = "Failed to write cache configuration for " + path + raise SCons.Errors.EnvironmentError(msg) + except FileExistsError: + try: + with open(config_file) as config: + self.config = json.load(config) + except ValueError: + msg = "Failed to read cache configuration for " + path + raise SCons.Errors.EnvironmentError(msg) + + + def _readconfig2(self, path): + """ + Python2 version of reading cache config. + + See if there is a config file in the cache directory. If there is, + use it. If there isn't, and the directory exists and isn't empty, + produce a warning. If the directory does not exist or is empty, + write a config file. + + :param path: path to the cache directory + """ config_file = os.path.join(path, 'config') if not os.path.exists(config_file): - # A note: There is a race hazard here, if two processes start and + # A note: There is a race hazard here if two processes start and # attempt to create the cache directory at the same time. However, - # python doesn't really give you the option to do exclusive file - # creation (it doesn't even give you the option to error on opening - # an existing file for writing...). The ordering of events here - # as an attempt to alleviate this, on the basis that it's a pretty - # unlikely occurence (it'd require two builds with a brand new cache + # Python 2.x does not give you the option to do exclusive file + # creation (not even the option to error on opening an existing + # file for writing...). The ordering of events here is an attempt + # to alleviate this, on the basis that it's a pretty unlikely + # occurrence (would require two builds with a brand new cache # directory) - if os.path.isdir(path) and len(os.listdir(path)) != 0: + if os.path.isdir(path) and any(f != "config" for f in os.listdir(path)): self.config['prefix_len'] = 1 # When building the project I was testing this on, the warning # was output over 20 times. That seems excessive global warned if self.path not in warned: msg = "Please upgrade your cache by running " +\ - " scons-configure-cache.py " + self.path + "scons-configure-cache.py " + self.path SCons.Warnings.warn(SCons.Warnings.CacheVersionWarning, msg) warned[self.path] = True else: @@ -177,24 +243,24 @@ class CacheDir(object): # If someone else is trying to create the directory at # the same time as me, bad things will happen msg = "Failed to create cache directory " + path - raise SCons.Errors.EnvironmentError(msg) - + raise SCons.Errors.SConsEnvironmentError(msg) + self.config['prefix_len'] = 2 if not os.path.exists(config_file): try: with open(config_file, 'w') as config: json.dump(self.config, config) - except: + except Exception: msg = "Failed to write cache configuration for " + path - raise SCons.Errors.EnvironmentError(msg) + raise SCons.Errors.SConsEnvironmentError(msg) else: try: with open(config_file) as config: self.config = json.load(config) except ValueError: msg = "Failed to read cache configuration for " + path - raise SCons.Errors.EnvironmentError(msg) - + raise SCons.Errors.SConsEnvironmentError(msg) + def CacheDebug(self, fmt, target, cachefile): if cache_debug != self.current_cache_debug: @@ -207,9 +273,19 @@ class CacheDir(object): self.current_cache_debug = cache_debug if self.debugFP: self.debugFP.write(fmt % (target, os.path.split(cachefile)[1])) + self.debugFP.write("requests: %d, hits: %d, misses: %d, hit rate: %.2f%%\n" % + (self.requests, self.hits, self.misses, self.hit_ratio)) + + @property + def hit_ratio(self): + return (100.0 * self.hits / self.requests if self.requests > 0 else 100) + + @property + def misses(self): + return self.requests - self.hits def is_enabled(self): - return cache_enabled and not self.path is None + return cache_enabled and self.path is not None def is_readonly(self): return cache_readonly diff --git a/engine/SCons/Conftest.py b/engine/SCons/Conftest.py index 84aa992..1163aa3 100644 --- a/engine/SCons/Conftest.py +++ b/engine/SCons/Conftest.py @@ -354,7 +354,7 @@ def CheckHeader(context, header_name, header = None, language = None, context.Display("Checking for %s header file %s... " % (lang, header_name)) ret = context.CompileProg(text, suffix) - _YesNoResult(context, ret, "HAVE_" + header_name, text, + _YesNoResult(context, ret, "HAVE_" + header_name, text, "Define to 1 if you have the <%s> header file." % header_name) return ret @@ -439,7 +439,7 @@ def CheckTypeSize(context, type_name, header = None, language = None, expect = N Returns: status : int 0 if the check failed, or the found size of the type if the check succeeded.""" - + # Include "confdefs.h" first, so that the header can use HAVE_HEADER_H. if context.headerfilename: includetext = '#include "%s"' % context.headerfilename @@ -454,8 +454,8 @@ def CheckTypeSize(context, type_name, header = None, language = None, expect = N context.Display("Cannot check for %s type: %s\n" % (type_name, msg)) return msg - src = includetext + header - if not expect is None: + src = includetext + header + if expect is not None: # Only check if the given size is the right one context.Display('Checking %s is %d bytes... ' % (type_name, expect)) @@ -477,7 +477,7 @@ int main(void) st = context.CompileProg(src % (type_name, expect), suffix) if not st: context.Display("yes\n") - _Have(context, "SIZEOF_%s" % type_name, expect, + _Have(context, "SIZEOF_%s" % type_name, expect, "The size of `%s', as computed by sizeof." % type_name) return expect else: @@ -541,7 +541,7 @@ def CheckDeclaration(context, symbol, includes = None, language = None): Returns: status : bool True if the check failed, False if succeeded.""" - + # Include "confdefs.h" first, so that the header can use HAVE_HEADER_H. if context.headerfilename: includetext = '#include "%s"' % context.headerfilename @@ -556,7 +556,7 @@ def CheckDeclaration(context, symbol, includes = None, language = None): context.Display("Cannot check for declaration %s: %s\n" % (symbol, msg)) return msg - src = includetext + includes + src = includetext + includes context.Display('Checking whether %s is declared... ' % symbol) src = src + r""" @@ -677,7 +677,7 @@ return 0; "Define to 1 if you have the `%s' library." % lib_name) if oldLIBS != -1 and (ret or not autoadd): context.SetLIBS(oldLIBS) - + if not ret: return ret @@ -704,7 +704,7 @@ def CheckProg(context, prog_name): # def _YesNoResult(context, ret, key, text, comment = None): - """ + r""" Handle the result of a test with a "yes" or "no" result. :Parameters: @@ -723,7 +723,7 @@ def _YesNoResult(context, ret, key, text, comment = None): def _Have(context, key, have, comment = None): - """ + r""" Store result of a test in context.havedict and context.headerfilename. :Parameters: @@ -751,7 +751,7 @@ def _Have(context, key, have, comment = None): line = "#define %s %d\n" % (key_up, have) else: line = "#define %s %s\n" % (key_up, str(have)) - + if comment is not None: lines = "\n/* %s */\n" % comment + line else: diff --git a/engine/SCons/Debug.py b/engine/SCons/Debug.py index be19a01..c19862a 100644 --- a/engine/SCons/Debug.py +++ b/engine/SCons/Debug.py @@ -31,7 +31,7 @@ caller_trace() # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Debug.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Debug.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import sys diff --git a/engine/SCons/Defaults.py b/engine/SCons/Defaults.py index 15ad91e..30c0052 100644 --- a/engine/SCons/Defaults.py +++ b/engine/SCons/Defaults.py @@ -33,7 +33,7 @@ from distutils.msvccompiler. # from __future__ import division -__revision__ = "src/engine/SCons/Defaults.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Defaults.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os @@ -193,7 +193,7 @@ def chmod_func(dest, mode): SCons.Node.FS.invalidate_node_memos(dest) if not SCons.Util.is_List(dest): dest = [dest] - if SCons.Util.is_String(mode) and not 0 in [i in digits for i in mode]: + if SCons.Util.is_String(mode) and 0 not in [i in digits for i in mode]: mode = int(mode, 8) if not SCons.Util.is_String(mode): for element in dest: @@ -582,6 +582,7 @@ ConstructionEnvironment = { '__DSHLIBVERSIONFLAGS' : '${__libversionflags(__env__,"DSHLIBVERSION","_DSHLIBVERSIONFLAGS")}', 'TEMPFILE' : NullCmdGenerator, + 'TEMPFILEARGJOIN': ' ', 'Dir' : Variable_Method_Caller('TARGET', 'Dir'), 'Dirs' : Variable_Method_Caller('TARGET', 'Dirs'), 'File' : Variable_Method_Caller('TARGET', 'File'), diff --git a/engine/SCons/Environment.py b/engine/SCons/Environment.py index 0fcd617..31a4721 100644 --- a/engine/SCons/Environment.py +++ b/engine/SCons/Environment.py @@ -31,7 +31,7 @@ Environment # 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/Environment.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Environment.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import copy @@ -608,7 +608,7 @@ class SubstitutionEnvironment(object): Removes the specified function's MethodWrapper from the added_methods list, so we don't re-bind it when making a clone. """ - self.added_methods = [dm for dm in self.added_methods if not dm.method is function] + self.added_methods = [dm for dm in self.added_methods if dm.method is not function] def Override(self, overrides): """ @@ -719,6 +719,12 @@ class SubstitutionEnvironment(object): elif append_next_arg_to == '-isystem': t = ('-isystem', arg) dict['CCFLAGS'].append(t) + elif append_next_arg_to == '-iquote': + t = ('-iquote', arg) + dict['CCFLAGS'].append(t) + elif append_next_arg_to == '-idirafter': + t = ('-idirafter', arg) + dict['CCFLAGS'].append(t) elif append_next_arg_to == '-arch': t = ('-arch', arg) dict['CCFLAGS'].append(t) @@ -791,7 +797,7 @@ class SubstitutionEnvironment(object): elif arg[0] == '+': dict['CCFLAGS'].append(arg) dict['LINKFLAGS'].append(arg) - elif arg in ['-include', '-isysroot', '-isystem', '-arch']: + elif arg in ['-include', '-isysroot', '-isystem', '-iquote', '-idirafter', '-arch']: append_next_arg_to = arg else: dict['CCFLAGS'].append(arg) @@ -858,18 +864,21 @@ class SubstitutionEnvironment(object): return self -def default_decide_source(dependency, target, prev_ni): +def default_decide_source(dependency, target, prev_ni, repo_node=None): f = SCons.Defaults.DefaultEnvironment().decide_source - return f(dependency, target, prev_ni) + return f(dependency, target, prev_ni, repo_node) -def default_decide_target(dependency, target, prev_ni): + +def default_decide_target(dependency, target, prev_ni, repo_node=None): f = SCons.Defaults.DefaultEnvironment().decide_target - return f(dependency, target, prev_ni) + return f(dependency, target, prev_ni, repo_node) + def default_copy_from_cache(src, dst): f = SCons.Defaults.DefaultEnvironment().copy_from_cache return f(src, dst) + class Base(SubstitutionEnvironment): """Base class for "real" construction Environments. These are the primary objects used to communicate dependency and construction @@ -1342,7 +1351,7 @@ class Base(SubstitutionEnvironment): dk = list(filter(lambda x, val=val: x not in val, dk)) self._dict[key] = dk + [val] else: - if not val in dk: + if val not in dk: self._dict[key] = dk + [val] else: if key == 'CPPDEFINES': @@ -1428,30 +1437,30 @@ class Base(SubstitutionEnvironment): _warn_copy_deprecated = False return self.Clone(*args, **kw) - def _changed_build(self, dependency, target, prev_ni): - if dependency.changed_state(target, prev_ni): + def _changed_build(self, dependency, target, prev_ni, repo_node=None): + if dependency.changed_state(target, prev_ni, repo_node): return 1 - return self.decide_source(dependency, target, prev_ni) + return self.decide_source(dependency, target, prev_ni, repo_node) - def _changed_content(self, dependency, target, prev_ni): - return dependency.changed_content(target, prev_ni) + def _changed_content(self, dependency, target, prev_ni, repo_node=None): + return dependency.changed_content(target, prev_ni, repo_node) - def _changed_source(self, dependency, target, prev_ni): + def _changed_source(self, dependency, target, prev_ni, repo_node=None): target_env = dependency.get_build_env() type = target_env.get_tgt_sig_type() if type == 'source': - return target_env.decide_source(dependency, target, prev_ni) + return target_env.decide_source(dependency, target, prev_ni, repo_node) else: - return target_env.decide_target(dependency, target, prev_ni) + return target_env.decide_target(dependency, target, prev_ni, repo_node) - def _changed_timestamp_then_content(self, dependency, target, prev_ni): - return dependency.changed_timestamp_then_content(target, prev_ni) + def _changed_timestamp_then_content(self, dependency, target, prev_ni, repo_node=None): + return dependency.changed_timestamp_then_content(target, prev_ni, repo_node) - def _changed_timestamp_newer(self, dependency, target, prev_ni): - return dependency.changed_timestamp_newer(target, prev_ni) + def _changed_timestamp_newer(self, dependency, target, prev_ni, repo_node=None): + return dependency.changed_timestamp_newer(target, prev_ni, repo_node) - def _changed_timestamp_match(self, dependency, target, prev_ni): - return dependency.changed_timestamp_match(target, prev_ni) + def _changed_timestamp_match(self, dependency, target, prev_ni, repo_node=None): + return dependency.changed_timestamp_match(target, prev_ni, repo_node) def _copy_from_cache(self, src, dst): return self.fs.copy(src, dst) @@ -1722,7 +1731,7 @@ class Base(SubstitutionEnvironment): dk = [x for x in dk if x not in val] self._dict[key] = [val] + dk else: - if not val in dk: + if val not in dk: self._dict[key] = [val] + dk else: if delete_existing: @@ -2299,7 +2308,20 @@ class OverrideEnvironment(Base): # Methods that make this class act like a proxy. def __getattr__(self, name): - return getattr(self.__dict__['__subject'], name) + attr = getattr(self.__dict__['__subject'], name) + # Here we check if attr is one of the Wrapper classes. For + # example when a pseudo-builder is being called from an + # OverrideEnvironment. + # + # These wrappers when they're constructed capture the + # Environment they are being constructed with and so will not + # have access to overrided values. So we rebuild them with the + # OverrideEnvironment so they have access to overrided values. + if isinstance(attr, (MethodWrapper, BuilderWrapper)): + return attr.clone(self) + else: + return attr + def __setattr__(self, name, value): setattr(self.__dict__['__subject'], name, value) diff --git a/engine/SCons/Errors.py b/engine/SCons/Errors.py index 4f1403d..28f58be 100644 --- a/engine/SCons/Errors.py +++ b/engine/SCons/Errors.py @@ -28,7 +28,7 @@ and user errors in SCons. """ -__revision__ = "src/engine/SCons/Errors.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Errors.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import shutil import SCons.Util @@ -124,7 +124,7 @@ class UserError(Exception): class StopError(Exception): pass -class EnvironmentError(Exception): +class SConsEnvironmentError(Exception): pass class MSVCError(IOError): @@ -184,7 +184,7 @@ def convert_to_BuildError(status, exc_info=None): filename=filename, exc_info=exc_info) - elif isinstance(status, (EnvironmentError, OSError, IOError)): + elif isinstance(status, (SConsEnvironmentError, OSError, IOError)): # If an IOError/OSError happens, raise a BuildError. # Report the name of the file or directory that caused the # error, which might be different from the target being built diff --git a/engine/SCons/Executor.py b/engine/SCons/Executor.py index cc3813c..c6ffe81 100644 --- a/engine/SCons/Executor.py +++ b/engine/SCons/Executor.py @@ -28,7 +28,7 @@ Nodes. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. from __future__ import print_function -__revision__ = "src/engine/SCons/Executor.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Executor.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import collections @@ -36,15 +36,16 @@ import SCons.Debug from SCons.Debug import logInstanceCreation import SCons.Errors import SCons.Memoize +import SCons.Util from SCons.compat import with_metaclass, NoSlotsPyPy class Batch(object): """Remembers exact association between targets and sources of executor.""" - + __slots__ = ('targets', 'sources') - + def __init__(self, targets=[], sources=[]): self.targets = targets self.sources = sources @@ -71,7 +72,7 @@ class TSList(collections.UserList): return nl[i] def __getslice__(self, i, j): nl = self.func() - i = max(i, 0); j = max(j, 0) + i, j = max(i, 0), max(j, 0) return nl[i:j] def __str__(self): nl = self.func() @@ -127,13 +128,13 @@ def execute_action_list(obj, target, kw): status = act(*args, **kw) if isinstance(status, SCons.Errors.BuildError): status.executor = obj - raise status + raise status # TODO pylint E0702: raising int not allowed elif status: msg = "Error %s" % status raise SCons.Errors.BuildError( - errstr=msg, + errstr=msg, node=obj.batches[0].targets, - executor=obj, + executor=obj, action=act) return status @@ -572,7 +573,6 @@ def AddBatchExecutor(key, executor): nullenv = None -import SCons.Util class NullEnvironment(SCons.Util.Null): import SCons.CacheDir _CacheDir_path = None @@ -597,7 +597,7 @@ class Null(object, with_metaclass(NoSlotsPyPy)): disassociate Builders from Nodes entirely, so we're not going to worry about unit tests for this--at least for now. """ - + __slots__ = ('pre_actions', 'post_actions', 'env', @@ -613,9 +613,10 @@ class Null(object, with_metaclass(NoSlotsPyPy)): 'action_list', '_do_execute', '_execute_str') - + def __init__(self, *args, **kw): - if SCons.Debug.track_instances: logInstanceCreation(self, 'Executor.Null') + if SCons.Debug.track_instances: + logInstanceCreation(self, 'Executor.Null') self.batches = [Batch(kw['targets'][:], [])] def get_build_env(self): return get_NullEnvironment() @@ -649,7 +650,7 @@ class Null(object, with_metaclass(NoSlotsPyPy)): """Morph this Null executor to a real Executor object.""" batches = self.batches self.__class__ = Executor - self.__init__([]) + self.__init__([]) self.batches = batches # The following methods require morphing this Null Executor to a diff --git a/engine/SCons/Job.py b/engine/SCons/Job.py index e049142..12ba19f 100644 --- a/engine/SCons/Job.py +++ b/engine/SCons/Job.py @@ -29,7 +29,7 @@ stop, and wait on jobs. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Job.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Job.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.compat @@ -53,14 +53,14 @@ interrupt_msg = 'Build interrupted.' class InterruptState(object): - def __init__(self): - self.interrupted = False + def __init__(self): + self.interrupted = False - def set(self): - self.interrupted = True + def set(self): + self.interrupted = True - def __call__(self): - return self.interrupted + def __call__(self): + return self.interrupted class Jobs(object): @@ -87,7 +87,7 @@ class Jobs(object): stack_size = explicit_stack_size if stack_size is None: stack_size = default_stack_size - + try: self.job = Parallel(taskmaster, num, stack_size) self.num_jobs = num @@ -172,14 +172,14 @@ class Serial(object): """ def __init__(self, taskmaster): - """Create a new serial job given a taskmaster. + """Create a new serial job given a taskmaster. The taskmaster's next_task() method should return the next task that needs to be executed, or None if there are no more tasks. The taskmaster's executed() method will be called for each task when it is successfully executed, or failed() will be called if it failed to execute (e.g. execute() raised an exception).""" - + self.taskmaster = taskmaster self.interrupted = InterruptState() @@ -188,7 +188,7 @@ class Serial(object): and executing them, and return when there are no more tasks. If a task fails to execute (i.e. execute() raises an exception), then the job will stop.""" - + while True: task = self.taskmaster.next_task() @@ -199,7 +199,7 @@ class Serial(object): task.prepare() if task.needs_execute(): task.execute() - except Exception as e: + except Exception: if self.interrupted(): try: raise SCons.Errors.BuildError( @@ -269,7 +269,7 @@ else: def __init__(self, num, stack_size, interrupted): """Create the request and reply queues, and 'num' worker threads. - + One must specify the stack size of the worker threads. The stack size is specified in kilobytes. """ @@ -277,11 +277,11 @@ else: self.resultsQueue = queue.Queue(0) try: - prev_size = threading.stack_size(stack_size*1024) + prev_size = threading.stack_size(stack_size*1024) except AttributeError as e: # Only print a warning if the stack size has been # explicitly set. - if not explicit_stack_size is None: + if explicit_stack_size is not None: msg = "Setting stack size is unsupported by this version of Python:\n " + \ e.args[0] SCons.Warnings.warn(SCons.Warnings.StackSizeWarning, msg) @@ -322,7 +322,7 @@ else: self.requestQueue.put(None) # Wait for all of the workers to terminate. - # + # # If we don't do this, later Python versions (2.4, 2.5) often # seem to raise exceptions during shutdown. This happens # in requestQueue.get(), as an assertion failure that @@ -339,7 +339,7 @@ else: self.workers = [] class Parallel(object): - """This class is used to execute tasks in parallel, and is somewhat + """This class is used to execute tasks in parallel, and is somewhat less efficient than Serial, but is appropriate for parallel builds. This class is thread safe. @@ -373,7 +373,7 @@ else: an exception), then the job will stop.""" jobs = 0 - + while True: # Start up as many available tasks as we're # allowed to. diff --git a/engine/SCons/Memoize.py b/engine/SCons/Memoize.py index 12fe043..f7b45bf 100644 --- a/engine/SCons/Memoize.py +++ b/engine/SCons/Memoize.py @@ -22,7 +22,7 @@ # from __future__ import print_function -__revision__ = "src/engine/SCons/Memoize.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Memoize.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __doc__ = """Memoizer diff --git a/engine/SCons/Node/Alias.py b/engine/SCons/Node/Alias.py index 8fbeef7..a9defb6 100644 --- a/engine/SCons/Node/Alias.py +++ b/engine/SCons/Node/Alias.py @@ -30,7 +30,7 @@ This creates a hash of global Aliases (dummy targets). # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Node/Alias.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Node/Alias.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import collections diff --git a/engine/SCons/Node/FS.py b/engine/SCons/Node/FS.py index be9f7fd..21ccecc 100644 --- a/engine/SCons/Node/FS.py +++ b/engine/SCons/Node/FS.py @@ -33,7 +33,7 @@ that can be used by scripts or modules looking for the canonical default. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. from __future__ import print_function -__revision__ = "src/engine/SCons/Node/FS.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Node/FS.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import fnmatch import os @@ -57,7 +57,6 @@ import SCons.Util import SCons.Warnings from SCons.Debug import Trace -from . import DeciderNeedsNode print_duplicate = 0 @@ -282,7 +281,7 @@ def set_duplicate(duplicate): 'copy' : _copy_func } - if not duplicate in Valid_Duplicates: + if duplicate not in Valid_Duplicates: raise SCons.Errors.InternalError("The argument of set_duplicate " "should be in Valid_Duplicates") global Link_Funcs @@ -480,7 +479,7 @@ class EntryProxy(SCons.Util.Proxy): return SCons.Subst.SpecialAttrWrapper(r, entry.name + "_posix") def __get_windows_path(self): - """Return the path with \ as the path separator, + r"""Return the path with \ as the path separator, regardless of platform.""" if OS_SEP == '\\': return self @@ -531,7 +530,7 @@ class EntryProxy(SCons.Util.Proxy): except KeyError: try: attr = SCons.Util.Proxy.__getattr__(self, name) - except AttributeError as e: + except AttributeError: # Raise our own AttributeError subclass with an # overridden __str__() method that identifies the # name of the entry that caused the exception. @@ -699,13 +698,13 @@ class Base(SCons.Node.Node): @SCons.Memoize.CountMethodCall def stat(self): - try: + try: return self._memo['stat'] - except KeyError: + except KeyError: pass - try: + try: result = self.fs.stat(self.get_abspath()) - except os.error: + except os.error: result = None self._memo['stat'] = result @@ -719,16 +718,16 @@ class Base(SCons.Node.Node): def getmtime(self): st = self.stat() - if st: + if st: return st[stat.ST_MTIME] - else: + else: return None def getsize(self): st = self.stat() - if st: + if st: return st[stat.ST_SIZE] - else: + else: return None def isdir(self): @@ -1418,7 +1417,7 @@ class FS(LocalFS): self.Top.addRepository(d) def PyPackageDir(self, modulename): - """Locate the directory of a given python module name + r"""Locate the directory of a given python module name For example scons might resolve to Windows: C:\Python27\Lib\site-packages\scons-2.5.1 @@ -1689,7 +1688,7 @@ class Dir(Base): return result def addRepository(self, dir): - if dir != self and not dir in self.repositories: + if dir != self and dir not in self.repositories: self.repositories.append(dir) dir._tpath = '.' self.__clearRepositoryCache() @@ -1729,7 +1728,7 @@ class Dir(Base): if self is other: result = '.' - elif not other in self._path_elements: + elif other not in self._path_elements: try: other_dir = other.get_dir() except AttributeError: @@ -2261,7 +2260,7 @@ class RootDir(Dir): this directory. """ - __slots__ = ['_lookupDict'] + __slots__ = ('_lookupDict', ) def __init__(self, drive, fs): if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.RootDir') @@ -2467,7 +2466,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase): """ state = getattr(self, '__dict__', {}).copy() for obj in type(self).mro(): - for name in getattr(obj,'__slots__',()): + for name in getattr(obj, '__slots__', ()): if hasattr(self, name): state[name] = getattr(self, name) @@ -2511,7 +2510,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): or count of any of these could yield writing wrong csig, and then false positive rebuilds """ - __slots__ = ('dependency_map') + __slots__ = ['dependency_map', ] current_version_id = 2 def __setattr__(self, key, value): @@ -3283,14 +3282,14 @@ class File(Base): self._memo['changed'] = has_changed return has_changed - def changed_content(self, target, prev_ni): + def changed_content(self, target, prev_ni, repo_node=None): cur_csig = self.get_csig() try: return cur_csig != prev_ni.csig except AttributeError: return 1 - def changed_state(self, target, prev_ni): + def changed_state(self, target, prev_ni, repo_node=None): return self.state != SCons.Node.up_to_date @@ -3317,13 +3316,26 @@ class File(Base): len(binfo.bimplicitsigs)) == 0: return {} - - # store this info so we can avoid regenerating it. - binfo.dependency_map = { str(child):signature for child, signature in zip(chain(binfo.bsources, binfo.bdepends, binfo.bimplicit), + binfo.dependency_map = { child:signature for child, signature in zip(chain(binfo.bsources, binfo.bdepends, binfo.bimplicit), chain(binfo.bsourcesigs, binfo.bdependsigs, binfo.bimplicitsigs))} return binfo.dependency_map + # @profile + def _add_strings_to_dependency_map(self, dmap): + """ + In the case comparing node objects isn't sufficient, we'll add the strings for the nodes to the dependency map + :return: + """ + + first_string = str(next(iter(dmap))) + + # print("DMAP:%s"%id(dmap)) + if first_string not in dmap: + string_dict = {str(child): signature for child, signature in dmap.items()} + dmap.update(string_dict) + return dmap + def _get_previous_signatures(self, dmap): """ Return a list of corresponding csigs from previous @@ -3342,37 +3354,62 @@ class File(Base): if len(dmap) == 0: if MD5_TIMESTAMP_DEBUG: print("Nothing dmap shortcutting") return None + elif MD5_TIMESTAMP_DEBUG: print("len(dmap):%d"%len(dmap)) + - if MD5_TIMESTAMP_DEBUG: print("len(dmap):%d"%len(dmap)) - # First try the simple name for node - c_str = str(self) - if MD5_TIMESTAMP_DEBUG: print("Checking :%s"%c_str) - df = dmap.get(c_str, None) + # First try retrieving via Node + if MD5_TIMESTAMP_DEBUG: print("Checking if self is in map:%s id:%s type:%s"%(str(self), id(self), type(self))) + df = dmap.get(self, False) if df: return df - + + # Now check if self's repository file is in map. + rf = self.rfile() + if MD5_TIMESTAMP_DEBUG: print("Checking if self.rfile is in map:%s id:%s type:%s"%(str(rf), id(rf), type(rf))) + rfm = dmap.get(rf, False) + if rfm: + return rfm + + # get default string for node and then also string swapping os.altsep for os.sep (/ for \) + c_strs = [str(self)] + if os.altsep: - c_str = c_str.replace(os.sep, os.altsep) - df = dmap.get(c_str, None) - if MD5_TIMESTAMP_DEBUG: print("-->%s"%df) + c_strs.append(c_strs[0].replace(os.sep, os.altsep)) + + # In some cases the dependency_maps' keys are already strings check. + # Check if either string is now in dmap. + for s in c_strs: + if MD5_TIMESTAMP_DEBUG: print("Checking if str(self) is in map :%s" % s) + df = dmap.get(s, False) + if df: + return df + + # Strings don't exist in map, add them and try again + # If there are no strings in this dmap, then add them. + # This may not be necessary, we could walk the nodes in the dmap and check each string + # rather than adding ALL the strings to dmap. In theory that would be n/2 vs 2n str() calls on node + # if not dmap.has_strings: + dmap = self._add_strings_to_dependency_map(dmap) + + # In some cases the dependency_maps' keys are already strings check. + # Check if either string is now in dmap. + for s in c_strs: + if MD5_TIMESTAMP_DEBUG: print("Checking if str(self) is in map (now with strings) :%s" % s) + df = dmap.get(s, False) if df: return df + # Lastly use nodes get_path() to generate string and see if that's in dmap if not df: try: # this should yield a path which matches what's in the sconsign c_str = self.get_path() - df = dmap.get(c_str, None) - if MD5_TIMESTAMP_DEBUG: print("-->%s"%df) - if df: - return df - if os.altsep: c_str = c_str.replace(os.sep, os.altsep) - df = dmap.get(c_str, None) - if MD5_TIMESTAMP_DEBUG: print("-->%s"%df) - if df: - return df + + if MD5_TIMESTAMP_DEBUG: print("Checking if self.get_path is in map (now with strings) :%s" % s) + + df = dmap.get(c_str, None) except AttributeError as e: raise FileBuildInfoFileToCsigMappingError("No mapping from file name to content signature for :%s"%c_str) @@ -3387,21 +3424,17 @@ class File(Base): file and just copy the prev_ni provided. If the prev_ni is wrong. It will propagate it. See: https://github.com/SCons/scons/issues/2980 - + Args: self - dependency target - target prev_ni - The NodeInfo object loaded from previous builds .sconsign - node - Node instance. This is the only changed* function which requires - node to function. So if we detect that it's not passed. - we throw DeciderNeedsNode, and caller should handle this and pass node. + node - Node instance. Check this node for file existence/timestamp + if specified. - Returns: + Returns: Boolean - Indicates if node(File) has changed. """ - if node is None: - # We need required node argument to get BuildInfo to function - raise DeciderNeedsNode(self.changed_timestamp_then_content) # Now get sconsign name -> csig map and then get proper prev_ni if possible bi = node.get_stored_info().binfo @@ -3433,7 +3466,6 @@ class File(Base): print("Mismatch self.changed_timestamp_match(%s, prev_ni) old:%s new:%s"%(str(target), old, new)) new_prev_ni = self._get_previous_signatures(dependency_map) - if not new: try: # NOTE: We're modifying the current node's csig in a query. @@ -3443,13 +3475,13 @@ class File(Base): return False return self.changed_content(target, new_prev_ni) - def changed_timestamp_newer(self, target, prev_ni): + def changed_timestamp_newer(self, target, prev_ni, repo_node=None): try: return self.get_timestamp() > target.get_timestamp() except AttributeError: return 1 - def changed_timestamp_match(self, target, prev_ni): + def changed_timestamp_match(self, target, prev_ni, repo_node=None): """ Return True if the timestamps don't match or if there is no previous timestamp :param target: @@ -3462,14 +3494,18 @@ class File(Base): return 1 def is_up_to_date(self): + """Check for whether the Node is current + In all cases self is the target we're checking to see if it's up to date + """ + T = 0 if T: Trace('is_up_to_date(%s):' % self) if not self.exists(): if T: Trace(' not self.exists():') - # The file doesn't exist locally... + # The file (always a target) doesn't exist locally... r = self.rfile() if r != self: - # ...but there is one in a Repository... + # ...but there is one (always a target) in a Repository... if not self.changed(r): if T: Trace(' changed(%s):' % r) # ...and it's even up-to-date... diff --git a/engine/SCons/Node/Python.py b/engine/SCons/Node/Python.py index d235de8..d338051 100644 --- a/engine/SCons/Node/Python.py +++ b/engine/SCons/Node/Python.py @@ -27,7 +27,7 @@ Python nodes. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Node/Python.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Node/Python.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Node diff --git a/engine/SCons/Node/__init__.py b/engine/SCons/Node/__init__.py index 889e7a4..5455bd6 100644 --- a/engine/SCons/Node/__init__.py +++ b/engine/SCons/Node/__init__.py @@ -43,13 +43,18 @@ from __future__ import print_function # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -__revision__ = "src/engine/SCons/Node/__init__.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Node/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import collections import copy from itertools import chain +try: + from itertools import zip_longest +except ImportError: + from itertools import izip_longest as zip_longest + import SCons.Debug from SCons.Debug import logInstanceCreation import SCons.Executor @@ -103,9 +108,9 @@ implicit_deps_changed = 0 # A variable that can be set to an interface-specific function be called # to annotate a Node with information about its creation. -def do_nothing(node): pass +def do_nothing_node(node): pass -Annotate = do_nothing +Annotate = do_nothing_node # Gets set to 'True' if we're running in interactive mode. Is # currently used to release parts of a target's info during @@ -248,25 +253,10 @@ _target_from_source_map = {0 : target_from_source_none, # used by it. # - -class DeciderNeedsNode(Exception): - """ - Indicate that the decider needs the node as well as the target and the dependency. - Normally the node and the target are the same, but in the case of repository - They may be different. Also the NodeInfo is retrieved from the node - """ - def __init__(self, call_this_decider): - """ - :param call_this_decider: to return the decider to call directly since deciders - are called through several levels of indirection - """ - self.decider = call_this_decider - - # # First, the single decider functions # -def changed_since_last_build_node(node, target, prev_ni): +def changed_since_last_build_node(node, target, prev_ni, repo_node=None): """ Must be overridden in a specific subclass to return True if this @@ -287,7 +277,7 @@ def changed_since_last_build_node(node, target, prev_ni): raise NotImplementedError -def changed_since_last_build_alias(node, target, prev_ni): +def changed_since_last_build_alias(node, target, prev_ni, repo_node=None): cur_csig = node.get_csig() try: return cur_csig != prev_ni.csig @@ -295,24 +285,24 @@ def changed_since_last_build_alias(node, target, prev_ni): return 1 -def changed_since_last_build_entry(node, target, prev_ni): +def changed_since_last_build_entry(node, target, prev_ni, repo_node=None): node.disambiguate() - return _decider_map[node.changed_since_last_build](node, target, prev_ni) + return _decider_map[node.changed_since_last_build](node, target, prev_ni, repo_node) -def changed_since_last_build_state_changed(node, target, prev_ni): +def changed_since_last_build_state_changed(node, target, prev_ni, repo_node=None): return node.state != SCons.Node.up_to_date -def decide_source(node, target, prev_ni): - return target.get_build_env().decide_source(node, target, prev_ni) +def decide_source(node, target, prev_ni, repo_node=None): + return target.get_build_env().decide_source(node, target, prev_ni, repo_node) -def decide_target(node, target, prev_ni): - return target.get_build_env().decide_target(node, target, prev_ni) +def decide_target(node, target, prev_ni, repo_node=None): + return target.get_build_env().decide_target(node, target, prev_ni, repo_node) -def changed_since_last_build_python(node, target, prev_ni): +def changed_since_last_build_python(node, target, prev_ni, repo_node=None): cur_csig = node.get_csig() try: return cur_csig != prev_ni.csig @@ -529,6 +519,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)): __slots__ = ['sources', 'sources_set', + 'target_peers', '_specific_sources', 'depends', 'depends_set', @@ -784,6 +775,25 @@ class Node(object, with_metaclass(NoSlotsPyPy)): for parent in self.waiting_parents: parent.implicit = None + # Handle issue where builder emits more than one target and + # the source file for the builder is generated. + # in that case only the first target was getting it's .implicit + # cleared when the source file is built (second scan). + # leaving only partial implicits from scan before source file is generated + # typically the compiler only. Then scanned files are appended + # This is persisted to sconsign and rebuild causes false rebuilds + # because the ordering of the implicit list then changes to what it + # should have been. + # This is at least the following bugs + # https://github.com/SCons/scons/issues/2811 + # https://jira.mongodb.org/browse/SERVER-33111 + try: + for peer in parent.target_peers: + peer.implicit = None + except AttributeError: + pass + + self.clear() if self.pseudo: @@ -1160,7 +1170,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)): binfo.bactsig = SCons.Util.MD5signature(executor.get_contents()) if self._specific_sources: - sources = [s for s in self.sources if not s in ignore_set] + sources = [s for s in self.sources if s not in ignore_set] else: sources = executor.get_unignored_sources(self, self.ignore) @@ -1480,17 +1490,11 @@ class Node(object, with_metaclass(NoSlotsPyPy)): result = True for child, prev_ni in zip(children, then): - try: - if _decider_map[child.changed_since_last_build](child, self, prev_ni): - if t: Trace(': %s changed' % child) - result = True - except DeciderNeedsNode as e: - if e.decider(self, prev_ni, node=node): - if t: Trace(': %s changed' % child) - result = True + if _decider_map[child.changed_since_last_build](child, self, prev_ni, node): + if t: Trace(': %s changed' % child) + result = True if self.has_builder(): - import SCons.Util contents = self.get_executor().get_contents() newsig = SCons.Util.MD5signature(contents) if bi.bactsig != newsig: @@ -1647,14 +1651,14 @@ class Node(object, with_metaclass(NoSlotsPyPy)): lines = [] - removed = [x for x in old_bkids if not x in new_bkids] + removed = [x for x in old_bkids if x not in new_bkids] if removed: removed = [stringify(r) for r in removed] fmt = "`%s' is no longer a dependency\n" lines.extend([fmt % s for s in removed]) for k in new_bkids: - if not k in old_bkids: + if k not in old_bkids: lines.append("`%s' is a new dependency\n" % stringify(k)) else: try: @@ -1666,9 +1670,16 @@ class Node(object, with_metaclass(NoSlotsPyPy)): lines.append("`%s' changed\n" % stringify(k)) if len(lines) == 0 and old_bkids != new_bkids: - lines.append("the dependency order changed:\n" + - "%sold: %s\n" % (' '*15, list(map(stringify, old_bkids))) + - "%snew: %s\n" % (' '*15, list(map(stringify, new_bkids)))) + lines.append("the dependency order changed:\n") + lines.append("->Sources\n") + for (o,n) in zip_longest(old.bsources, new.bsources, fillvalue=None): + lines.append("Old:%s\tNew:%s\n"%(o,n)) + lines.append("->Depends\n") + for (o,n) in zip_longest(old.bdepends, new.bdepends, fillvalue=None): + lines.append("Old:%s\tNew:%s\n"%(o,n)) + lines.append("->Implicit\n") + for (o,n) in zip_longest(old.bimplicit, new.bimplicit, fillvalue=None): + lines.append("Old:%s\tNew:%s\n"%(o,n)) if len(lines) == 0: def fmt_with_title(title, strlines): @@ -1711,7 +1722,6 @@ class Walker(object): This is depth-first, children are visited before the parent. The Walker object can be initialized with any node, and returns the next node on the descent with each get_next() call. - 'kids_func' is an optional function that will be called to get the children of a node instead of calling 'children'. 'cycle_func' is an optional function that will be called when a cycle is detected. diff --git a/engine/SCons/PathList.py b/engine/SCons/PathList.py index fa73a9d..d6a01e7 100644 --- a/engine/SCons/PathList.py +++ b/engine/SCons/PathList.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/PathList.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/PathList.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __doc__ = """SCons.PathList diff --git a/engine/SCons/Platform/__init__.py b/engine/SCons/Platform/__init__.py index e1cc941..8da1e9d 100644 --- a/engine/SCons/Platform/__init__.py +++ b/engine/SCons/Platform/__init__.py @@ -43,11 +43,11 @@ their own platform definition. # from __future__ import print_function -__revision__ = "src/engine/SCons/Platform/__init__.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.compat -import imp +import importlib import os import sys import tempfile @@ -101,13 +101,8 @@ def platform_module(name = platform_default()): eval(full_name) else: try: - file, path, desc = imp.find_module(name, - sys.modules['SCons.Platform'].__path__) - try: - mod = imp.load_module(full_name, file, path, desc) - finally: - if file: - file.close() + # the specific platform module is a relative import + mod = importlib.import_module("." + name, __name__) except ImportError: try: import zipimport @@ -231,8 +226,10 @@ class TempFileMunge(object): prefix = '@' args = list(map(SCons.Subst.quote_spaces, cmd[1:])) - os.write(fd, bytearray(" ".join(args) + "\n",'utf-8')) + join_char = env.get('TEMPFILEARGJOIN',' ') + os.write(fd, bytearray(join_char.join(args) + "\n",'utf-8')) os.close(fd) + # XXX Using the SCons.Action.print_actions value directly # like this is bogus, but expedient. This class should # really be rewritten as an Action that defines the diff --git a/engine/SCons/Platform/aix.py b/engine/SCons/Platform/aix.py index 7faddd9..70fbb35 100644 --- a/engine/SCons/Platform/aix.py +++ b/engine/SCons/Platform/aix.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/aix.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/aix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import subprocess diff --git a/engine/SCons/Platform/cygwin.py b/engine/SCons/Platform/cygwin.py index 434d125..70b6443 100644 --- a/engine/SCons/Platform/cygwin.py +++ b/engine/SCons/Platform/cygwin.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/cygwin.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/cygwin.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import sys diff --git a/engine/SCons/Platform/darwin.py b/engine/SCons/Platform/darwin.py index 7f4b468..d5861d9 100644 --- a/engine/SCons/Platform/darwin.py +++ b/engine/SCons/Platform/darwin.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/darwin.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/darwin.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import posix import os @@ -56,12 +56,11 @@ def generate(env): for file in filelist: if os.path.isfile(file): - f = open(file, 'r') - lines = f.readlines() - for line in lines: - if line: - env.AppendENVPath('PATHOSX', line.strip('\n')) - f.close() + with open(file, 'r') as f: + lines = f.readlines() + for line in lines: + if line: + env.AppendENVPath('PATHOSX', line.strip('\n')) # Not sure why this wasn't the case all along? if env['ENV'].get('PATHOSX', False) and os.environ.get('SCONS_USE_MAC_PATHS', False): diff --git a/engine/SCons/Platform/hpux.py b/engine/SCons/Platform/hpux.py index cc97d39..6867212 100644 --- a/engine/SCons/Platform/hpux.py +++ b/engine/SCons/Platform/hpux.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/hpux.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/hpux.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import posix diff --git a/engine/SCons/Platform/irix.py b/engine/SCons/Platform/irix.py index 5df080a..a382e71 100644 --- a/engine/SCons/Platform/irix.py +++ b/engine/SCons/Platform/irix.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/irix.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/irix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import posix diff --git a/engine/SCons/Platform/mingw.py b/engine/SCons/Platform/mingw.py index f3f7e44..c03c9c8 100644 --- a/engine/SCons/Platform/mingw.py +++ b/engine/SCons/Platform/mingw.py @@ -27,7 +27,7 @@ Platform-specific initialization for the MinGW system. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/mingw.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/mingw.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import sys diff --git a/engine/SCons/Platform/os2.py b/engine/SCons/Platform/os2.py index a680f94..ebabe3d 100644 --- a/engine/SCons/Platform/os2.py +++ b/engine/SCons/Platform/os2.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/os2.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/os2.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import win32 def generate(env): diff --git a/engine/SCons/Platform/posix.py b/engine/SCons/Platform/posix.py index aa43f51..780c764 100644 --- a/engine/SCons/Platform/posix.py +++ b/engine/SCons/Platform/posix.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/posix.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/posix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import errno import os diff --git a/engine/SCons/Platform/sunos.py b/engine/SCons/Platform/sunos.py index 2ec4c99..6aa54aa 100644 --- a/engine/SCons/Platform/sunos.py +++ b/engine/SCons/Platform/sunos.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/sunos.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/sunos.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import posix diff --git a/engine/SCons/Platform/virtualenv.py b/engine/SCons/Platform/virtualenv.py index 4cfb6e1..9fb3e45 100644 --- a/engine/SCons/Platform/virtualenv.py +++ b/engine/SCons/Platform/virtualenv.py @@ -26,7 +26,7 @@ Support for virtualenv. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/virtualenv.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/virtualenv.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import sys diff --git a/engine/SCons/Platform/win32.py b/engine/SCons/Platform/win32.py index 756f6d6..ea567a2 100644 --- a/engine/SCons/Platform/win32.py +++ b/engine/SCons/Platform/win32.py @@ -30,7 +30,7 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/win32.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Platform/win32.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import os.path @@ -193,7 +193,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): # actually do the spawn try: - args = [sh, '/C', escape(' '.join(args)) ] + args = [sh, '/C', escape(' '.join(args))] ret = spawnve(os.P_WAIT, sh, args, env) except OSError as e: # catch any error @@ -207,15 +207,17 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): # and do clean up stuff if stdout is not None and stdoutRedirected == 0: try: - stdout.write(open( tmpFileStdout, "r" ).read()) - os.remove( tmpFileStdout ) + with open(tmpFileStdout, "r" ) as tmp: + stdout.write(tmp.read()) + os.remove(tmpFileStdout) except (IOError, OSError): pass if stderr is not None and stderrRedirected == 0: try: - stderr.write(open( tmpFileStderr, "r" ).read()) - os.remove( tmpFileStderr ) + with open(tmpFileStderr, "r" ) as tmp: + stderr.write(tmp.read()) + os.remove(tmpFileStderr) except (IOError, OSError): pass return ret diff --git a/engine/SCons/SConf.py b/engine/SCons/SConf.py index 66592d4..7409c50 100644 --- a/engine/SCons/SConf.py +++ b/engine/SCons/SConf.py @@ -35,7 +35,7 @@ libraries are installed, if some command line options are supported etc. # from __future__ import print_function -__revision__ = "src/engine/SCons/SConf.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/SConf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.compat @@ -56,7 +56,6 @@ import SCons.Warnings import SCons.Conftest from SCons.Debug import Trace -from SCons.Node import DeciderNeedsNode # Turn off the Conftest error logging SCons.Conftest.LogInputFiles = 0 @@ -247,6 +246,7 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask): # ConfigureCacheError and if yes, reraise the exception exc_type = self.exc_info()[0] if issubclass(exc_type, SConfError): + # TODO pylint E0704: bare raise not inside except raise elif issubclass(exc_type, SCons.Errors.BuildError): # we ignore Build Errors (occurs, when a test doesn't pass) @@ -406,12 +406,10 @@ class SConfBase(object): # that the correct .sconsign info will get calculated # and keep the build state consistent. def force_build(dependency, target, prev_ni, - env_decider=env.decide_source, - node=None): + repo_node=None, + env_decider=env.decide_source): try: - env_decider(dependency, target, prev_ni) - except DeciderNeedsNode as e: - e.decider(target, prev_ni, node=target) + env_decider(dependency, target, prev_ni, repo_node) except Exception as e: raise e return True @@ -787,7 +785,7 @@ class SConfBase(object): self.active = 0 sconf_global = None - if not self.config_h is None: + if self.config_h is not None: _ac_config_hs[self.config_h] = self.config_h_text self.env.fs = self.lastEnvFs diff --git a/engine/SCons/SConsign.py b/engine/SCons/SConsign.py index 1fec6a0..e003933 100644 --- a/engine/SCons/SConsign.py +++ b/engine/SCons/SConsign.py @@ -29,7 +29,7 @@ Writing and reading information to the .sconsign file or files. from __future__ import print_function -__revision__ = "src/engine/SCons/SConsign.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/SConsign.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.compat @@ -76,7 +76,8 @@ def Get_DataBase(dir): except KeyError: path = d.entry_abspath(DB_Name) try: db = DataBase[d] = DB_Module.open(path, mode) - except (IOError, OSError): pass + except (IOError, OSError): + pass else: if mode != "r": DB_sync_list.append(db) @@ -334,10 +335,15 @@ class DirFile(Dir): Dir.__init__(self, fp, dir) except KeyboardInterrupt: raise - except: + except Exception: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt .sconsign file: %s"%self.sconsign) + try: + fp.close() + except AttributeError: + pass + global sig_files sig_files.append(self) @@ -417,7 +423,7 @@ def File(name, dbm_module=None): else: ForDirectory = DB DB_Name = name - if not dbm_module is None: + if dbm_module is not None: DB_Module = dbm_module # Local Variables: diff --git a/engine/SCons/Scanner/C.py b/engine/SCons/Scanner/C.py index 6f59edb..206de5f 100644 --- a/engine/SCons/Scanner/C.py +++ b/engine/SCons/Scanner/C.py @@ -27,7 +27,7 @@ This module implements the dependency scanner for C/C++ code. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/C.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/C.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Node.FS import SCons.Scanner diff --git a/engine/SCons/Scanner/D.py b/engine/SCons/Scanner/D.py index 543cc3c..1ad9e89 100644 --- a/engine/SCons/Scanner/D.py +++ b/engine/SCons/Scanner/D.py @@ -30,7 +30,7 @@ Coded by Andy Friesen # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/D.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/D.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Scanner @@ -46,7 +46,7 @@ class D(SCons.Scanner.Classic): name = "DScanner", suffixes = '$DSUFFIXES', path_variable = 'DPATH', - regex = '(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)' + regex = r'(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)' ) def find_include(self, include, source_dir, path): diff --git a/engine/SCons/Scanner/Dir.py b/engine/SCons/Scanner/Dir.py index 1b82046..be8ae6c 100644 --- a/engine/SCons/Scanner/Dir.py +++ b/engine/SCons/Scanner/Dir.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/Scanner/Dir.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/Dir.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Node.FS import SCons.Scanner diff --git a/engine/SCons/Scanner/Fortran.py b/engine/SCons/Scanner/Fortran.py index b52269f..d315bc9 100644 --- a/engine/SCons/Scanner/Fortran.py +++ b/engine/SCons/Scanner/Fortran.py @@ -26,7 +26,7 @@ This module implements the dependency scanner for Fortran code. # 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/Scanner/Fortran.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/Fortran.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import re @@ -187,7 +187,7 @@ def FortranScan(path_variable="FORTRANPATH"): # (\w+) : match the module name that is being USE'd # # - use_regex = "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" + use_regex = r"(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)" # The INCLUDE statement regex matches the following: @@ -275,7 +275,7 @@ def FortranScan(path_variable="FORTRANPATH"): # set of semicolon-separated INCLUDE statements # (as allowed by the F2003 standard) - include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" + include_regex = r"""(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" # The MODULE statement regex finds module definitions by matching # the following: @@ -285,21 +285,29 @@ def FortranScan(path_variable="FORTRANPATH"): # but *not* the following: # # MODULE PROCEDURE procedure_name +# MODULE SUBROUTINE subroutine_name +# MODULE FUNCTION function_name +# MODULE PURE SUBROUTINE|FUNCTION subroutine_name|function_name +# MODULE ELEMENTAL SUBROUTINE|FUNCTION subroutine_name|function_name # # Here is a breakdown of the regex: # -# (?i) : regex is case insensitive -# ^\s* : any amount of white space -# MODULE : match the string MODULE, case insensitive -# \s+ : match one or more white space characters -# (?!PROCEDURE) : but *don't* match if the next word matches -# PROCEDURE (negative lookahead assertion), -# case insensitive -# (\w+) : match one or more alphanumeric characters -# that make up the defined module name and -# save it in a group - - def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)""" +# (?i) : regex is case insensitive +# ^\s* : any amount of white space +# MODULE : match the string MODULE, case +# insensitive +# \s+ : match one or more white space +# characters +# (?!PROCEDURE|SUBROUTINE|FUNCTION|PURE|ELEMENTAL) +# : but *don't* match if the next word +# matches PROCEDURE, SUBROUTINE, +# FUNCTION, PURE or ELEMENTAL (negative +# lookahead assertion), case insensitive +# (\w+) : match one or more alphanumeric +# characters that make up the defined +# module name and save it in a group + + def_regex = r"""(?i)^\s*MODULE\s+(?!PROCEDURE|SUBROUTINE|FUNCTION|PURE|ELEMENTAL)(\w+)""" scanner = F90Scanner("FortranScan", "$FORTRANSUFFIXES", diff --git a/engine/SCons/Scanner/IDL.py b/engine/SCons/Scanner/IDL.py index 843a147..88226e6 100644 --- a/engine/SCons/Scanner/IDL.py +++ b/engine/SCons/Scanner/IDL.py @@ -28,7 +28,7 @@ Definition Language) files. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/IDL.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/IDL.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Node.FS import SCons.Scanner diff --git a/engine/SCons/Scanner/LaTeX.py b/engine/SCons/Scanner/LaTeX.py index d9e3692..8afe5b0 100644 --- a/engine/SCons/Scanner/LaTeX.py +++ b/engine/SCons/Scanner/LaTeX.py @@ -27,7 +27,7 @@ This module implements the dependency scanner for LaTeX code. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/LaTeX.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/LaTeX.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path import re @@ -179,15 +179,7 @@ class LaTeX(SCons.Scanner.Base): 'inputfrom', 'subinputfrom'] def __init__(self, name, suffixes, graphics_extensions, *args, **kw): - - # We have to include \n with the % we exclude from the first part - # part of the regex because the expression is compiled with re.M. - # Without the \n, the ^ could match the beginning of a *previous* - # line followed by one or more newline characters (i.e. blank - # lines), interfering with a match on the next line. - # add option for whitespace before the '[options]' or the '{filename}' regex = r''' - ^[^%\n]* \\( include | includegraphics(?:\s*\[[^\]]+\])? @@ -348,7 +340,7 @@ class LaTeX(SCons.Scanner.Base): # Cache the includes list in node so we only scan it once: # path_dict = dict(list(path)) # add option for whitespace (\s) before the '[' - noopt_cre = re.compile('\s*\[.*$') + noopt_cre = re.compile(r'\s*\[.*$') if node.includes is not None: includes = node.includes else: @@ -372,9 +364,9 @@ class LaTeX(SCons.Scanner.Base): inc_list = include[2].split(',') else: inc_list = include[1].split(',') - for j in range(len(inc_list)): - split_includes.append( (inc_type, inc_subdir, inc_list[j]) ) - # + for inc in inc_list: + split_includes.append((inc_type, inc_subdir, inc)) + includes = split_includes node.includes = includes diff --git a/engine/SCons/Scanner/Prog.py b/engine/SCons/Scanner/Prog.py index 78deb18..2ae3c68 100644 --- a/engine/SCons/Scanner/Prog.py +++ b/engine/SCons/Scanner/Prog.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/Prog.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/Prog.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Node import SCons.Node.FS diff --git a/engine/SCons/Scanner/RC.py b/engine/SCons/Scanner/RC.py index cf970c5..4f0cee2 100644 --- a/engine/SCons/Scanner/RC.py +++ b/engine/SCons/Scanner/RC.py @@ -28,7 +28,7 @@ Definition Language) files. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/RC.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/RC.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import re @@ -48,9 +48,9 @@ def RCScan(): """Return a prototype Scanner instance for scanning RC source files""" res_re= r'^(?:\s*#\s*(?:include)|' \ - '.*?\s+(?:ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)' \ - '\s*.*?)' \ - '\s*(<|"| )([^>"\s]+)(?:[>"\s])*$' + r'.*?\s+(?:ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)' \ + r'\s*.*?)' \ + r'\s*(<|"| )([^>"\s]+)(?:[>"\s])*$' resScanner = SCons.Scanner.ClassicCPP("ResourceScanner", "$RCSUFFIXES", "CPPPATH", diff --git a/engine/SCons/Scanner/SWIG.py b/engine/SCons/Scanner/SWIG.py index 6bffbe3..5f2a3e3 100644 --- a/engine/SCons/Scanner/SWIG.py +++ b/engine/SCons/Scanner/SWIG.py @@ -27,14 +27,14 @@ This module implements the dependency scanner for SWIG code. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/SWIG.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/SWIG.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Scanner SWIGSuffixes = [ '.i' ] def SWIGScanner(): - expr = '^[ \t]*%[ \t]*(?:include|import|extern)[ \t]*(<|"?)([^>\s"]+)(?:>|"?)' + expr = r'^[ \t]*%[ \t]*(?:include|import|extern)[ \t]*(<|"?)([^>\s"]+)(?:>|"?)' scanner = SCons.Scanner.ClassicCPP("SWIGScanner", ".i", "SWIGPATH", expr) return scanner diff --git a/engine/SCons/Scanner/__init__.py b/engine/SCons/Scanner/__init__.py index b5df1cc..feff12a 100644 --- a/engine/SCons/Scanner/__init__.py +++ b/engine/SCons/Scanner/__init__.py @@ -27,7 +27,7 @@ The Scanner package for the SCons software construction utility. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Scanner/__init__.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Scanner/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import re @@ -207,7 +207,7 @@ class Base(object): self = self.select(node) - if not self.argument is _null: + if self.argument is not _null: node_list = self.function(node, env, path, self.argument) else: node_list = self.function(node, env, path) diff --git a/engine/SCons/Script/Interactive.py b/engine/SCons/Script/Interactive.py index 0e73204..3d70728 100644 --- a/engine/SCons/Script/Interactive.py +++ b/engine/SCons/Script/Interactive.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. from __future__ import print_function -__revision__ = "src/engine/SCons/Script/Interactive.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Script/Interactive.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __doc__ = """ SCons interactive mode diff --git a/engine/SCons/Script/Main.py b/engine/SCons/Script/Main.py index c677937..878f824 100644 --- a/engine/SCons/Script/Main.py +++ b/engine/SCons/Script/Main.py @@ -38,7 +38,7 @@ deprecated_python_version = (2, 7, 0) # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -__revision__ = "src/engine/SCons/Script/Main.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Script/Main.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.compat @@ -68,6 +68,20 @@ import SCons.Warnings import SCons.Script.Interactive +# Global variables +first_command_start = None +last_command_end = None +print_objects = 0 +print_memoizer = 0 +print_stacktrace = 0 +print_time = 0 +sconscript_time = 0 +cumulative_command_time = 0 +exit_status = 0 # final exit status, assume success by default +this_build_status = 0 # "exit status" of an individual build +num_jobs = None +delayed_warnings = [] + def fetch_win32_parallel_msg(): # A subsidiary function that exists solely to isolate this import @@ -87,15 +101,14 @@ def revert_io(): sys.stderr = sys.__stderr__ sys.stdout = sys.__stdout__ + class SConsPrintHelpException(Exception): pass + display = SCons.Util.display progress_display = SCons.Util.DisplayEngine() -first_command_start = None -last_command_end = None - class Progressor(object): prev = '' @@ -443,19 +456,6 @@ def python_version_deprecated(version=sys.version_info): return version < deprecated_python_version -# Global variables - -print_objects = 0 -print_memoizer = 0 -print_stacktrace = 0 -print_time = 0 -sconscript_time = 0 -cumulative_command_time = 0 -exit_status = 0 # final exit status, assume success by default -this_build_status = 0 # "exit status" of an individual build -num_jobs = None -delayed_warnings = [] - class FakeOptionParser(object): """ A do-nothing option parser, used for the initial OptionsParser variable. @@ -1170,7 +1170,7 @@ def _build_targets(fs, options, targets, target_top): # -U, local SConscript Default() targets target_top = fs.Dir(target_top) def check_dir(x, target_top=target_top): - if hasattr(x, 'cwd') and not x.cwd is None: + if hasattr(x, 'cwd') and x.cwd is not None: cwd = x.cwd.srcnode() return cwd == target_top else: diff --git a/engine/SCons/Script/SConsOptions.py b/engine/SCons/Script/SConsOptions.py index 65e1868..5651c96 100644 --- a/engine/SCons/Script/SConsOptions.py +++ b/engine/SCons/Script/SConsOptions.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Script/SConsOptions.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Script/SConsOptions.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import optparse import re @@ -147,7 +147,7 @@ class SConsValues(optparse.Values): """ Sets an option from an SConscript file. """ - if not name in self.settable: + if name not in self.settable: raise SCons.Errors.UserError("This option is not settable from a SConscript file: %s"%name) if name == 'num_jobs': @@ -167,7 +167,7 @@ class SConsValues(optparse.Values): value = str(value) except ValueError: raise SCons.Errors.UserError("A string is required: %s"%repr(value)) - if not value in SCons.Node.FS.Valid_Duplicates: + if value not in SCons.Node.FS.Valid_Duplicates: raise SCons.Errors.UserError("Not a valid duplication style: %s" % value) # Set the duplicate style right away so it can affect linking # of SConscript files. @@ -226,39 +226,8 @@ class SConsOption(optparse.Option): fmt = "option %s: nargs='?' is incompatible with short options" raise SCons.Errors.UserError(fmt % self._short_opts[0]) - try: - _orig_CONST_ACTIONS = optparse.Option.CONST_ACTIONS - - _orig_CHECK_METHODS = optparse.Option.CHECK_METHODS - - except AttributeError: - # optparse.Option had no CONST_ACTIONS before Python 2.5. - - _orig_CONST_ACTIONS = ("store_const",) - - def _check_const(self): - if self.action not in self.CONST_ACTIONS and self.const is not None: - raise OptionError( - "'const' must not be supplied for action %r" % self.action, - self) - - # optparse.Option collects its list of unbound check functions - # up front. This sucks because it means we can't just override - # the _check_const() function like a normal method, we have to - # actually replace it in the list. This seems to be the most - # straightforward way to do that. - - _orig_CHECK_METHODS = [optparse.Option._check_action, - optparse.Option._check_type, - optparse.Option._check_choice, - optparse.Option._check_dest, - _check_const, - optparse.Option._check_nargs, - optparse.Option._check_callback] - - CHECK_METHODS = _orig_CHECK_METHODS + [_check_nargs_optional] - - CONST_ACTIONS = _orig_CONST_ACTIONS + optparse.Option.TYPED_ACTIONS + CHECK_METHODS = optparse.Option.CHECK_METHODS + [_check_nargs_optional] + CONST_ACTIONS = optparse.Option.CONST_ACTIONS + optparse.Option.TYPED_ACTIONS class SConsOptionGroup(optparse.OptionGroup): """ @@ -364,7 +333,7 @@ class SConsOptionParser(optparse.OptionParser): in self.largs, so that any value overridden on the command line is immediately available if the user turns around and does a GetOption() right away. - + We mimic the processing of the single args in the original OptionParser._process_args(), but here we allow exact matches for long-opts only (no partial @@ -375,7 +344,7 @@ class SConsOptionParser(optparse.OptionParser): command-line arguments that 1. haven't been processed so far (self.largs), but 2. are possibly not added to the list of options yet. - + So, when we only have a value for "--myargument" yet, a command-line argument of "--myarg=test" would set it. Responsible for this behaviour is the method @@ -384,7 +353,7 @@ class SConsOptionParser(optparse.OptionParser): be unique. This would lead to further confusion, because we might want to add another option "--myarg" later on (see issue #2929). - + """ rargs = [] largs_restore = [] @@ -401,7 +370,7 @@ class SConsOptionParser(optparse.OptionParser): if "=" in l: # Split into option and value lopt = l.split("=", 1) - + if lopt[0] in self._long_opt: # Argument is already known rargs.append('='.join(lopt)) @@ -416,7 +385,7 @@ class SConsOptionParser(optparse.OptionParser): skip = True else: rargs.append(l) - + # Parse the filtered list self.parse_args(rargs, self.values) # Restore the list of remaining arguments for the @@ -690,7 +659,7 @@ def Parser(version): metavar="TYPE") def opt_duplicate(option, opt, value, parser): - if not value in SCons.Node.FS.Valid_Duplicates: + if value not in SCons.Node.FS.Valid_Duplicates: raise OptionValueError(opt_invalid('duplication', value, SCons.Node.FS.Valid_Duplicates)) setattr(parser.values, option.dest, value) diff --git a/engine/SCons/Script/SConscript.py b/engine/SCons/Script/SConscript.py index 8377a54..9687c29 100644 --- a/engine/SCons/Script/SConscript.py +++ b/engine/SCons/Script/SConscript.py @@ -27,7 +27,7 @@ files. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -__revision__ = "src/engine/SCons/Script/SConscript.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Script/SConscript.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons import SCons.Action diff --git a/engine/SCons/Script/__init__.py b/engine/SCons/Script/__init__.py index d78e746..cf2e472 100644 --- a/engine/SCons/Script/__init__.py +++ b/engine/SCons/Script/__init__.py @@ -34,7 +34,7 @@ it goes here. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Script/__init__.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Script/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import time start_time = time.time() diff --git a/engine/SCons/Subst.py b/engine/SCons/Subst.py index 5fae669..1e0d423 100644 --- a/engine/SCons/Subst.py +++ b/engine/SCons/Subst.py @@ -26,7 +26,7 @@ SCons string substitution. # 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/Subst.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Subst.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import collections import re @@ -350,7 +350,7 @@ _rm_split = re.compile(r'(?<!\$)(\$[()])') _regex_remove = [ _rm, None, _rm_split ] def _rm_list(list): - return [l for l in list if not l in ('$(', '$)')] + return [l for l in list if l not in ('$(', '$)')] def _remove_list(list): result = [] @@ -468,7 +468,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={ s = lvars[key] elif key in self.gvars: s = self.gvars[key] - elif not NameError in AllowableExceptions: + elif NameError not in AllowableExceptions: raise_exception(NameError(key), lvars['TARGETS'], s) else: return '' @@ -690,7 +690,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv s = lvars[key] elif key in self.gvars: s = self.gvars[key] - elif not NameError in AllowableExceptions: + elif NameError not in AllowableExceptions: raise_exception(NameError(), lvars['TARGETS'], s) else: return diff --git a/engine/SCons/Taskmaster.py b/engine/SCons/Taskmaster.py index 48a8241..29e48ac 100644 --- a/engine/SCons/Taskmaster.py +++ b/engine/SCons/Taskmaster.py @@ -27,10 +27,10 @@ import sys __doc__ = """ Generic Taskmaster module for the SCons build engine. ===================================================== - + This module contains the primary interface(s) between a wrapping user interface and the SCons build engine. There are two key classes here: - + Taskmaster ---------- This is the main engine for walking the dependency graph and @@ -54,7 +54,7 @@ __doc__ = """ target(s) that it decides need to be evaluated and/or built. """ -__revision__ = "src/engine/SCons/Taskmaster.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Taskmaster.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from itertools import chain import operator @@ -477,7 +477,7 @@ class Task(object): for s in t.side_effects: if s.get_state() == NODE_EXECUTING: s.set_state(NODE_NO_STATE) - + # The side-effects may have been transferred to # NODE_NO_STATE by executed_with{,out}_callbacks, but was # not taken out of the waiting parents/pending children @@ -551,7 +551,7 @@ class Task(object): try: exc_type, exc_value, exc_traceback = exc except ValueError: - exc_type, exc_value = exc + exc_type, exc_value = exc # pylint: disable=unbalanced-tuple-unpacking exc_traceback = None # raise exc_type(exc_value).with_traceback(exc_traceback) diff --git a/engine/SCons/Tool/386asm.py b/engine/SCons/Tool/386asm.py index c01f09e..1121c3d 100644 --- a/engine/SCons/Tool/386asm.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/DCommon.py b/engine/SCons/Tool/DCommon.py index c4e42d0..f6b6000 100644 --- a/engine/SCons/Tool/DCommon.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/DCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path diff --git a/engine/SCons/Tool/FortranCommon.py b/engine/SCons/Tool/FortranCommon.py index 9287396..11f1eb7 100644 --- a/engine/SCons/Tool/FortranCommon.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/GettextCommon.py b/engine/SCons/Tool/GettextCommon.py index 37da33a..79912b6 100644 --- a/engine/SCons/Tool/GettextCommon.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/JavaCommon.py b/engine/SCons/Tool/JavaCommon.py index 29ab007..1e58af6 100644 --- a/engine/SCons/Tool/JavaCommon.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/MSCommon/__init__.py b/engine/SCons/Tool/MSCommon/__init__.py index 2fb9c99..e3c4471 100644 --- a/engine/SCons/Tool/MSCommon/__init__.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/MSCommon/arch.py b/engine/SCons/Tool/MSCommon/arch.py index 12ff1f9..6312541 100644 --- a/engine/SCons/Tool/MSCommon/arch.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/MSCommon/common.py b/engine/SCons/Tool/MSCommon/common.py index 041c394..8353944 100644 --- a/engine/SCons/Tool/MSCommon/common.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/MSCommon/netframework.py b/engine/SCons/Tool/MSCommon/netframework.py index a32a05d..edd9fd9 100644 --- a/engine/SCons/Tool/MSCommon/netframework.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/MSCommon/sdk.py b/engine/SCons/Tool/MSCommon/sdk.py index aa89f2a..e664a30 100644 --- a/engine/SCons/Tool/MSCommon/sdk.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/MSCommon/vc.py b/engine/SCons/Tool/MSCommon/vc.py index 1f1332e..fa7be96 100644 --- a/engine/SCons/Tool/MSCommon/vc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/MSCommon/vs.py b/engine/SCons/Tool/MSCommon/vs.py index f7f3de2..731f328 100644 --- a/engine/SCons/Tool/MSCommon/vs.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/PharLapCommon.py b/engine/SCons/Tool/PharLapCommon.py index b78dc2a..623f2a8 100644 --- a/engine/SCons/Tool/PharLapCommon.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/__init__.py b/engine/SCons/Tool/__init__.py index fcd9bca..271f214 100644 --- a/engine/SCons/Tool/__init__.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/aixc++.py b/engine/SCons/Tool/aixc++.py index 5ededea..bafaea4 100644 --- a/engine/SCons/Tool/aixc++.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/aixcc.py b/engine/SCons/Tool/aixcc.py index d58184b..349a40a 100644 --- a/engine/SCons/Tool/aixcc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/aixcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path diff --git a/engine/SCons/Tool/aixcxx.py b/engine/SCons/Tool/aixcxx.py index c568366..0830e33 100644 --- a/engine/SCons/Tool/aixcxx.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/aixcxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path diff --git a/engine/SCons/Tool/aixf77.py b/engine/SCons/Tool/aixf77.py index 54f196f..d2c619a 100644 --- a/engine/SCons/Tool/aixf77.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/aixf77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path diff --git a/engine/SCons/Tool/aixlink.py b/engine/SCons/Tool/aixlink.py index 0d808be..ea2949f 100644 --- a/engine/SCons/Tool/aixlink.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/aixlink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import os.path diff --git a/engine/SCons/Tool/applelink.py b/engine/SCons/Tool/applelink.py index dfb9d9d..011b29d 100644 --- a/engine/SCons/Tool/applelink.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/applelink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/ar.py b/engine/SCons/Tool/ar.py index aee2426..459fb55 100644 --- a/engine/SCons/Tool/ar.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/ar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/as.py b/engine/SCons/Tool/as.py index e0d0239..02139c5 100644 --- a/engine/SCons/Tool/as.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/as.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/bcc32.py b/engine/SCons/Tool/bcc32.py index 17cd4fc..e8ffbbf 100644 --- a/engine/SCons/Tool/bcc32.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/bcc32.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import os.path diff --git a/engine/SCons/Tool/c++.py b/engine/SCons/Tool/c++.py index bdd067c..8819f82 100644 --- a/engine/SCons/Tool/c++.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/cc.py b/engine/SCons/Tool/cc.py index e00df46..698d725 100644 --- a/engine/SCons/Tool/cc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/cc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Tool import SCons.Defaults diff --git a/engine/SCons/Tool/clang.py b/engine/SCons/Tool/clang.py index 83311eb..f48afbf 100644 --- a/engine/SCons/Tool/clang.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +# __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/engine/SCons/Tool/clangxx.py b/engine/SCons/Tool/clangxx.py index 6e4199e..d88874e 100644 --- a/engine/SCons/Tool/clangxx.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +# __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/engine/SCons/Tool/cvf.py b/engine/SCons/Tool/cvf.py index dde3a3e..aa24d69 100644 --- a/engine/SCons/Tool/cvf.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/cvf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import fortran diff --git a/engine/SCons/Tool/cxx.py b/engine/SCons/Tool/cxx.py index 85fb2fb..2ac278e 100644 --- a/engine/SCons/Tool/cxx.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/cxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path diff --git a/engine/SCons/Tool/cyglink.py b/engine/SCons/Tool/cyglink.py index f69b886..c3d78de 100644 --- a/engine/SCons/Tool/cyglink.py +++ b/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/engine/SCons/Tool/default.py b/engine/SCons/Tool/default.py index 928e365..866b823 100644 --- a/engine/SCons/Tool/default.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/default.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Tool diff --git a/engine/SCons/Tool/dmd.py b/engine/SCons/Tool/dmd.py index d9bed9c..befcd22 100644 --- a/engine/SCons/Tool/dmd.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/dmd.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import subprocess diff --git a/engine/SCons/Tool/docbook/__init__.py b/engine/SCons/Tool/docbook/__init__.py index d7d10c0..147556d 100644 --- a/engine/SCons/Tool/docbook/__init__.py +++ b/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/engine/SCons/Tool/dvi.py b/engine/SCons/Tool/dvi.py index 7fbca27..5cd85ed 100644 --- a/engine/SCons/Tool/dvi.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/dvi.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Builder import SCons.Tool diff --git a/engine/SCons/Tool/dvipdf.py b/engine/SCons/Tool/dvipdf.py index 340929e..32f57e6 100644 --- a/engine/SCons/Tool/dvipdf.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/dvipdf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Defaults diff --git a/engine/SCons/Tool/dvips.py b/engine/SCons/Tool/dvips.py index 16d409d..988ecd3 100644 --- a/engine/SCons/Tool/dvips.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/dvips.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Builder diff --git a/engine/SCons/Tool/f03.py b/engine/SCons/Tool/f03.py index dddc650..541ec88 100644 --- a/engine/SCons/Tool/f03.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/f03.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/f08.py b/engine/SCons/Tool/f08.py index c5209e4..5dc49da 100644 --- a/engine/SCons/Tool/f08.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/f08.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/f77.py b/engine/SCons/Tool/f77.py index 2665867..6d60edf 100644 --- a/engine/SCons/Tool/f77.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/f90.py b/engine/SCons/Tool/f90.py index a6f5cff..e0b5fae 100644 --- a/engine/SCons/Tool/f90.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/f95.py b/engine/SCons/Tool/f95.py index 3e611e8..9a1afdf 100644 --- a/engine/SCons/Tool/f95.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/f95.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/filesystem.py b/engine/SCons/Tool/filesystem.py index 312f08c..a625714 100644 --- a/engine/SCons/Tool/filesystem.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/fortran.py b/engine/SCons/Tool/fortran.py index b57a845..1b09880 100644 --- a/engine/SCons/Tool/fortran.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/fortran.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import re diff --git a/engine/SCons/Tool/g++.py b/engine/SCons/Tool/g++.py index b28e39d..8cf881f 100644 --- a/engine/SCons/Tool/g++.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/g77.py b/engine/SCons/Tool/g77.py index 1c1f101..fc0bcba 100644 --- a/engine/SCons/Tool/g77.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/gas.py b/engine/SCons/Tool/gas.py index 5ad8a76..c104e34 100644 --- a/engine/SCons/Tool/gas.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/gcc.py b/engine/SCons/Tool/gcc.py index 880fc80..2532427 100644 --- a/engine/SCons/Tool/gcc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/gcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import cc import os diff --git a/engine/SCons/Tool/gdc.py b/engine/SCons/Tool/gdc.py index 2e5f03b..46a910c 100644 --- a/engine/SCons/Tool/gdc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/gdc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Defaults diff --git a/engine/SCons/Tool/gettext_tool.py b/engine/SCons/Tool/gettext_tool.py index 504ec46..5fc0158 100644 --- a/engine/SCons/Tool/gettext_tool.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/gettext_tool.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" ############################################################################# def generate(env,**kw): diff --git a/engine/SCons/Tool/gfortran.py b/engine/SCons/Tool/gfortran.py index e543efd..8d02daa 100644 --- a/engine/SCons/Tool/gfortran.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/gfortran.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/gnulink.py b/engine/SCons/Tool/gnulink.py index cf8a65d..53f5081 100644 --- a/engine/SCons/Tool/gnulink.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/gnulink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util import SCons.Tool diff --git a/engine/SCons/Tool/gs.py b/engine/SCons/Tool/gs.py index a1e0bd9..371b810 100644 --- a/engine/SCons/Tool/gs.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/gs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Builder diff --git a/engine/SCons/Tool/gxx.py b/engine/SCons/Tool/gxx.py index b98ae07..d956c9f 100644 --- a/engine/SCons/Tool/gxx.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/gxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path import re diff --git a/engine/SCons/Tool/hpc++.py b/engine/SCons/Tool/hpc++.py index 5cbe20e..4ec2fe3 100644 --- a/engine/SCons/Tool/hpc++.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/hpcc.py b/engine/SCons/Tool/hpcc.py index 27bdfa6..6a564b9 100644 --- a/engine/SCons/Tool/hpcc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/hpcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/hpcxx.py b/engine/SCons/Tool/hpcxx.py index 6bfb600..8ee888f 100644 --- a/engine/SCons/Tool/hpcxx.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/hplink.py b/engine/SCons/Tool/hplink.py index 502b945..1afa95e 100644 --- a/engine/SCons/Tool/hplink.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/hplink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import os.path diff --git a/engine/SCons/Tool/icc.py b/engine/SCons/Tool/icc.py index f16e79a..8110a60 100644 --- a/engine/SCons/Tool/icc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/icc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import cc diff --git a/engine/SCons/Tool/icl.py b/engine/SCons/Tool/icl.py index 7a7b21b..29d5862 100644 --- a/engine/SCons/Tool/icl.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/icl.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Tool.intelc diff --git a/engine/SCons/Tool/ifl.py b/engine/SCons/Tool/ifl.py index d351e4e..0eb7cda 100644 --- a/engine/SCons/Tool/ifl.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/ifort.py b/engine/SCons/Tool/ifort.py index 7a3128e..730e778 100644 --- a/engine/SCons/Tool/ifort.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/ilink.py b/engine/SCons/Tool/ilink.py index c27443a..7c69e72 100644 --- a/engine/SCons/Tool/ilink.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/ilink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/ilink32.py b/engine/SCons/Tool/ilink32.py index 69430ec..a1e12a6 100644 --- a/engine/SCons/Tool/ilink32.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/install.py b/engine/SCons/Tool/install.py index c388b2a..c0a8917 100644 --- a/engine/SCons/Tool/install.py +++ b/engine/SCons/Tool/install.py @@ -31,7 +31,7 @@ selection method. # from __future__ import print_function -__revision__ = "src/engine/SCons/Tool/install.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/install.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import re diff --git a/engine/SCons/Tool/intelc.py b/engine/SCons/Tool/intelc.py index 63df411..fdd9730 100644 --- a/engine/SCons/Tool/intelc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/ipkg.py b/engine/SCons/Tool/ipkg.py index 0027781..664c3a6 100644 --- a/engine/SCons/Tool/ipkg.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/jar.py b/engine/SCons/Tool/jar.py index 4d686af..98be08f 100644 --- a/engine/SCons/Tool/jar.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/javac.py b/engine/SCons/Tool/javac.py index a295bfe..387afdb 100644 --- a/engine/SCons/Tool/javac.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/javah.py b/engine/SCons/Tool/javah.py index 791c7ab..251778d 100644 --- a/engine/SCons/Tool/javah.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/latex.py b/engine/SCons/Tool/latex.py index 008a98a..3f1af08 100644 --- a/engine/SCons/Tool/latex.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/latex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Defaults diff --git a/engine/SCons/Tool/ldc.py b/engine/SCons/Tool/ldc.py index c2e9a8f..dda1a5e 100644 --- a/engine/SCons/Tool/ldc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/ldc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import subprocess diff --git a/engine/SCons/Tool/lex.py b/engine/SCons/Tool/lex.py index fc6322f..4831776 100644 --- a/engine/SCons/Tool/lex.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/link.py b/engine/SCons/Tool/link.py index 95a00cc..dcaf91f 100644 --- a/engine/SCons/Tool/link.py +++ b/engine/SCons/Tool/link.py @@ -32,7 +32,7 @@ selection method. # from __future__ import print_function -__revision__ = "src/engine/SCons/Tool/link.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/link.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import sys import re diff --git a/engine/SCons/Tool/linkloc.py b/engine/SCons/Tool/linkloc.py index 42c180e..42d010d 100644 --- a/engine/SCons/Tool/linkloc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/linkloc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path import re diff --git a/engine/SCons/Tool/m4.py b/engine/SCons/Tool/m4.py index bb27b53..0ecc82a 100644 --- a/engine/SCons/Tool/m4.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/m4.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Builder diff --git a/engine/SCons/Tool/masm.py b/engine/SCons/Tool/masm.py index 092f5dc..cf147a7 100644 --- a/engine/SCons/Tool/masm.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/masm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/midl.py b/engine/SCons/Tool/midl.py index 2dfd347..f75204a 100644 --- a/engine/SCons/Tool/midl.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/midl.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Builder diff --git a/engine/SCons/Tool/mingw.py b/engine/SCons/Tool/mingw.py index cb9bc3c..8410d2f 100644 --- a/engine/SCons/Tool/mingw.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/msgfmt.py b/engine/SCons/Tool/msgfmt.py index 3a73abd..c8141a0 100644 --- a/engine/SCons/Tool/msgfmt.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/msgfmt.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from SCons.Builder import BuilderBase ############################################################################# diff --git a/engine/SCons/Tool/msginit.py b/engine/SCons/Tool/msginit.py index 5b3dc0b..69e803a 100644 --- a/engine/SCons/Tool/msginit.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/msginit.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Warnings import SCons.Builder diff --git a/engine/SCons/Tool/msgmerge.py b/engine/SCons/Tool/msgmerge.py index c8b7688..4254fa6 100644 --- a/engine/SCons/Tool/msgmerge.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/mslib.py b/engine/SCons/Tool/mslib.py index 1434773..cecdbdc 100644 --- a/engine/SCons/Tool/mslib.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/mslink.py b/engine/SCons/Tool/mslink.py index 9fd84c7..9fbce4b 100644 --- a/engine/SCons/Tool/mslink.py +++ b/engine/SCons/Tool/mslink.py @@ -32,8 +32,9 @@ selection method. # from __future__ import print_function -__revision__ = "src/engine/SCons/Tool/mslink.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/mssdk.py b/engine/SCons/Tool/mssdk.py index 1372e87..7a38c6a 100644 --- a/engine/SCons/Tool/mssdk.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/mssdk.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" """engine.SCons.Tool.mssdk diff --git a/engine/SCons/Tool/msvc.py b/engine/SCons/Tool/msvc.py index 4649963..052a0b0 100644 --- a/engine/SCons/Tool/msvc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/msvs.py b/engine/SCons/Tool/msvs.py index afe4bef..38965e3 100644 --- a/engine/SCons/Tool/msvs.py +++ b/engine/SCons/Tool/msvs.py @@ -32,7 +32,7 @@ selection method. from __future__ import print_function -__revision__ = "src/engine/SCons/Tool/msvs.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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', '
') 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/engine/SCons/Tool/mwcc.py b/engine/SCons/Tool/mwcc.py index bc1e62c..b2b2f5b 100644 --- a/engine/SCons/Tool/mwcc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/mwcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import os.path diff --git a/engine/SCons/Tool/mwld.py b/engine/SCons/Tool/mwld.py index f671319..5049c55 100644 --- a/engine/SCons/Tool/mwld.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/mwld.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Tool diff --git a/engine/SCons/Tool/nasm.py b/engine/SCons/Tool/nasm.py index 1615b6b..d4d0a1b 100644 --- a/engine/SCons/Tool/nasm.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/nasm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/packaging/__init__.py b/engine/SCons/Tool/packaging/__init__.py index af60e8b..72b9eef 100644 --- a/engine/SCons/Tool/packaging/__init__.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/ipk.py b/engine/SCons/Tool/packaging/ipk.py index 2ebc168..dbf5be8 100644 --- a/engine/SCons/Tool/packaging/ipk.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/msi.py b/engine/SCons/Tool/packaging/msi.py index fbb8b21..4a48b47 100644 --- a/engine/SCons/Tool/packaging/msi.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/rpm.py b/engine/SCons/Tool/packaging/rpm.py index 3f44d83..a948e29 100644 --- a/engine/SCons/Tool/packaging/rpm.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/src_tarbz2.py b/engine/SCons/Tool/packaging/src_tarbz2.py index eea29cb..b628ccd 100644 --- a/engine/SCons/Tool/packaging/src_tarbz2.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/src_targz.py b/engine/SCons/Tool/packaging/src_targz.py index 94ebea4..4c7469c 100644 --- a/engine/SCons/Tool/packaging/src_targz.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/src_tarxz.py b/engine/SCons/Tool/packaging/src_tarxz.py index 62db2e2..6688c46 100644 --- a/engine/SCons/Tool/packaging/src_tarxz.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/src_zip.py b/engine/SCons/Tool/packaging/src_zip.py index b1f63fb..d56f3aa 100644 --- a/engine/SCons/Tool/packaging/src_zip.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/tarbz2.py b/engine/SCons/Tool/packaging/tarbz2.py index 70e7ee4..e371f1b 100644 --- a/engine/SCons/Tool/packaging/tarbz2.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/targz.py b/engine/SCons/Tool/packaging/targz.py index fa8800d..121e4a4 100644 --- a/engine/SCons/Tool/packaging/targz.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/tarxz.py b/engine/SCons/Tool/packaging/tarxz.py index bad495b..3ec9822 100644 --- a/engine/SCons/Tool/packaging/tarxz.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/packaging/zip.py b/engine/SCons/Tool/packaging/zip.py index c5dd7cc..11ab3b5 100644 --- a/engine/SCons/Tool/packaging/zip.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/pdf.py b/engine/SCons/Tool/pdf.py index 792c4ca..50988b6 100644 --- a/engine/SCons/Tool/pdf.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/pdf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Builder import SCons.Tool diff --git a/engine/SCons/Tool/pdflatex.py b/engine/SCons/Tool/pdflatex.py index 8d4a1a7..2c559f7 100644 --- a/engine/SCons/Tool/pdflatex.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/pdflatex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Util diff --git a/engine/SCons/Tool/pdftex.py b/engine/SCons/Tool/pdftex.py index c30066d..c658aa0 100644 --- a/engine/SCons/Tool/pdftex.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/pdftex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import SCons.Action diff --git a/engine/SCons/Tool/qt.py b/engine/SCons/Tool/qt.py index 1b1925c..a582e6f 100644 --- a/engine/SCons/Tool/qt.py +++ b/engine/SCons/Tool/qt.py @@ -33,7 +33,7 @@ selection method. # from __future__ import print_function -__revision__ = "src/engine/SCons/Tool/qt.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/rmic.py b/engine/SCons/Tool/rmic.py index b2df405..d6f7b2b 100644 --- a/engine/SCons/Tool/rmic.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/rpcgen.py b/engine/SCons/Tool/rpcgen.py index a495fdd..b9f8ca6 100644 --- a/engine/SCons/Tool/rpcgen.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/rpm.py b/engine/SCons/Tool/rpm.py index 9531431..0253365 100644 --- a/engine/SCons/Tool/rpm.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/rpmutils.py b/engine/SCons/Tool/rpmutils.py index 6c87f73..a2400ff 100644 --- a/engine/SCons/Tool/rpmutils.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/sgiar.py b/engine/SCons/Tool/sgiar.py index feab04f..d82ec89 100644 --- a/engine/SCons/Tool/sgiar.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sgiar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/sgic++.py b/engine/SCons/Tool/sgic++.py index 9d5fc96..84d775a 100644 --- a/engine/SCons/Tool/sgic++.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/sgicc.py b/engine/SCons/Tool/sgicc.py index f957534..537f1a3 100644 --- a/engine/SCons/Tool/sgicc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sgicc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" from . import cc diff --git a/engine/SCons/Tool/sgicxx.py b/engine/SCons/Tool/sgicxx.py index f4bfb8d..d44ec26 100644 --- a/engine/SCons/Tool/sgicxx.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sgicxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/sgilink.py b/engine/SCons/Tool/sgilink.py index fa64736..ca9e69c 100644 --- a/engine/SCons/Tool/sgilink.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sgilink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/sunar.py b/engine/SCons/Tool/sunar.py index abce0a4..07d45b2 100644 --- a/engine/SCons/Tool/sunar.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sunar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Defaults import SCons.Tool diff --git a/engine/SCons/Tool/sunc++.py b/engine/SCons/Tool/sunc++.py index ef915f6..1611fe9 100644 --- a/engine/SCons/Tool/sunc++.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/suncc.py b/engine/SCons/Tool/suncc.py index 5b01402..da6ca6e 100644 --- a/engine/SCons/Tool/suncc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/suncc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/suncxx.py b/engine/SCons/Tool/suncxx.py index d421946..1ee1c6a 100644 --- a/engine/SCons/Tool/suncxx.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/sunf77.py b/engine/SCons/Tool/sunf77.py index 9938d91..c1c216f 100644 --- a/engine/SCons/Tool/sunf77.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sunf77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/sunf90.py b/engine/SCons/Tool/sunf90.py index 2f6ef97..4cabee8 100644 --- a/engine/SCons/Tool/sunf90.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sunf90.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/sunf95.py b/engine/SCons/Tool/sunf95.py index 1854165..077b1bc 100644 --- a/engine/SCons/Tool/sunf95.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sunf95.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Util diff --git a/engine/SCons/Tool/sunlink.py b/engine/SCons/Tool/sunlink.py index 28ec971..8d965fa 100644 --- a/engine/SCons/Tool/sunlink.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/sunlink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import os.path diff --git a/engine/SCons/Tool/swig.py b/engine/SCons/Tool/swig.py index a8d6400..2e61b91 100644 --- a/engine/SCons/Tool/swig.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/tar.py b/engine/SCons/Tool/tar.py index 05a7c70..08c80f2 100644 --- a/engine/SCons/Tool/tar.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/tar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Action import SCons.Builder diff --git a/engine/SCons/Tool/tex.py b/engine/SCons/Tool/tex.py index 4607d2f..9beb557 100644 --- a/engine/SCons/Tool/tex.py +++ b/engine/SCons/Tool/tex.py @@ -33,7 +33,7 @@ selection method. # from __future__ import print_function -__revision__ = "src/engine/SCons/Tool/tex.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/textfile.py b/engine/SCons/Tool/textfile.py index 2cfa906..58a5007 100644 --- a/engine/SCons/Tool/textfile.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/textfile.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons diff --git a/engine/SCons/Tool/tlib.py b/engine/SCons/Tool/tlib.py index 70dd18a..4d8101b 100644 --- a/engine/SCons/Tool/tlib.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/wix.py b/engine/SCons/Tool/wix.py index b4f63ad..e79e4a1 100644 --- a/engine/SCons/Tool/wix.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/wix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import SCons.Builder import SCons.Action diff --git a/engine/SCons/Tool/xgettext.py b/engine/SCons/Tool/xgettext.py index 8925a9d..185558e 100644 --- a/engine/SCons/Tool/xgettext.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/yacc.py b/engine/SCons/Tool/yacc.py index d328d20..6857574 100644 --- a/engine/SCons/Tool/yacc.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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/engine/SCons/Tool/zip.py b/engine/SCons/Tool/zip.py index 2689634..b7efdc7 100644 --- a/engine/SCons/Tool/zip.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Tool/zip.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path diff --git a/engine/SCons/Util.py b/engine/SCons/Util.py index 476f5d8..5b4c225 100644 --- a/engine/SCons/Util.py +++ b/engine/SCons/Util.py @@ -24,7 +24,7 @@ Various utility functions go here. # 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/Util.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Util.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import sys @@ -33,6 +33,7 @@ import re import types import codecs import pprint +import hashlib PY3 = sys.version_info[0] == 3 @@ -656,13 +657,15 @@ except ImportError: pass RegError = _NoError -WinError = None + # Make sure we have a definition of WindowsError so we can # run platform-independent tests of Windows functionality on # platforms other than Windows. (WindowsError is, in fact, an # OSError subclass on Windows.) + class PlainWindowsError(OSError): pass + try: WinError = WindowsError except NameError: @@ -676,7 +679,7 @@ if can_read_reg: HKEY_USERS = hkey_mod.HKEY_USERS def RegGetValue(root, key): - """This utility function returns a value in the registry + r"""This utility function returns a value in the registry without having to open the key first. Only available on Windows platforms with a version of Python that can read the registry. Returns the same thing as @@ -883,7 +886,7 @@ def PrependPath(oldpath, newpath, sep = os.pathsep, # now we add them only if they are unique for path in newpaths: normpath = os.path.normpath(os.path.normcase(path)) - if path and not normpath in normpaths: + if path and normpath not in normpaths: paths.append(path) normpaths.append(normpath) @@ -963,7 +966,7 @@ def AppendPath(oldpath, newpath, sep = os.pathsep, # now we add them only if they are unique for path in newpaths: normpath = os.path.normpath(os.path.normcase(path)) - if path and not normpath in normpaths: + if path and normpath not in normpaths: paths.append(path) normpaths.append(normpath) paths.reverse() @@ -999,7 +1002,9 @@ if sys.platform == 'cygwin': def get_native_path(path): """Transforms an absolute path into a native path for the system. In Cygwin, this converts from a Cygwin path to a Windows one.""" - return os.popen('cygpath -w ' + path).read().replace('\n', '') + with os.popen('cygpath -w ' + path) as p: + npath = p.read().replace('\n', '') + return npath else: def get_native_path(path): """Transforms an absolute path into a native path for the system. @@ -1176,10 +1181,13 @@ def unique(s): # ASPN: Python Cookbook: Remove duplicates from a sequence # First comment, dated 2001/10/13. # (Also in the printed Python Cookbook.) +# This not currently used, in favor of the next function... def uniquer(seq, idfun=None): - if idfun is None: - def idfun(x): return x + def default_idfun(x): + return x + if not idfun: + idfun = default_idfun seen = {} result = [] for item in seq: @@ -1444,56 +1452,53 @@ def RenameFunction(function, name): function.__defaults__) -md5 = False - +if hasattr(hashlib, 'md5'): + md5 = True -def MD5signature(s): - return str(s) + def MD5signature(s): + """ + Generate md5 signature of a string + :param s: either string or bytes. Normally should be bytes + :return: String of hex digits representing the signature + """ + m = hashlib.md5() -def MD5filesignature(fname, chunksize=65536): - with open(fname, "rb") as f: - result = f.read() - return result + try: + m.update(to_bytes(s)) + except TypeError as e: + m.update(to_bytes(str(s))) -try: - import hashlib -except ImportError: - pass -else: - if hasattr(hashlib, 'md5'): - md5 = True + return m.hexdigest() - def MD5signature(s): - """ - Generate a String of Hex digits representing the md5 signature of the string - :param s: either string or bytes. Normally should be bytes - :return: String of hex digits - """ - m = hashlib.md5() + def MD5filesignature(fname, chunksize=65536): + """ + Generate the md5 signature of a file - try: - m.update(to_bytes(s)) - except TypeError as e: - m.update(to_bytes(str(s))) - - return m.hexdigest() - - def MD5filesignature(fname, chunksize=65536): - """ - :param fname: - :param chunksize: - :return: String of Hex digits - """ - m = hashlib.md5() - f = open(fname, "rb") + :param fname: file to hash + :param chunksize: chunk size to read + :return: String of Hex digits representing the signature + """ + m = hashlib.md5() + with open(fname, "rb") as f: while True: blck = f.read(chunksize) if not blck: break m.update(to_bytes(blck)) - f.close() - return m.hexdigest() + return m.hexdigest() +else: + # if md5 algorithm not available, just return data unmodified + # could add alternative signature scheme here + md5 = False + + def MD5signature(s): + return str(s) + + def MD5filesignature(fname, chunksize=65536): + with open(fname, "rb") as f: + result = f.read() + return result def MD5collect(signatures): @@ -1509,7 +1514,6 @@ def MD5collect(signatures): return MD5signature(', '.join(signatures)) - def silent_intern(x): """ Perform sys.intern() on the passed argument and return the result. @@ -1533,7 +1537,7 @@ def silent_intern(x): class Null(object): """ Null objects always and reliably "do nothing." """ def __new__(cls, *args, **kwargs): - if not '_instance' in vars(cls): + if '_instance' not in vars(cls): cls._instance = super(Null, cls).__new__(cls, *args, **kwargs) return cls._instance def __init__(self, *args, **kwargs): diff --git a/engine/SCons/Variables/BoolVariable.py b/engine/SCons/Variables/BoolVariable.py index 71b554a..4cb9f35 100644 --- a/engine/SCons/Variables/BoolVariable.py +++ b/engine/SCons/Variables/BoolVariable.py @@ -34,7 +34,7 @@ Usage example:: # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Variables/BoolVariable.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Variables/BoolVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __all__ = ['BoolVariable',] diff --git a/engine/SCons/Variables/EnumVariable.py b/engine/SCons/Variables/EnumVariable.py index 4995bb1..ba9f972 100644 --- a/engine/SCons/Variables/EnumVariable.py +++ b/engine/SCons/Variables/EnumVariable.py @@ -37,7 +37,7 @@ Usage example:: # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Variables/EnumVariable.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Variables/EnumVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __all__ = ['EnumVariable',] @@ -45,7 +45,7 @@ __all__ = ['EnumVariable',] import SCons.Errors def _validator(key, val, env, vals): - if not val in vals: + if val not in vals: raise SCons.Errors.UserError( 'Invalid value for option %s: %s. Valid values are: %s' % (key, val, vals)) diff --git a/engine/SCons/Variables/ListVariable.py b/engine/SCons/Variables/ListVariable.py index 4995382..a30f265 100644 --- a/engine/SCons/Variables/ListVariable.py +++ b/engine/SCons/Variables/ListVariable.py @@ -46,7 +46,7 @@ Usage example:: # 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/Variables/ListVariable.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Variables/ListVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" # Known Bug: This should behave like a Set-Type, but does not really, # since elements can occur twice. @@ -96,7 +96,7 @@ def _converter(val, allowedElems, mapdict): else: val = [_f for _f in val.split(',') if _f] val = [mapdict.get(v, v) for v in val] - notAllowed = [v for v in val if not v in allowedElems] + notAllowed = [v for v in val if v not in allowedElems] if notAllowed: raise ValueError("Invalid value(s) for option: %s" % ','.join(notAllowed)) diff --git a/engine/SCons/Variables/PackageVariable.py b/engine/SCons/Variables/PackageVariable.py index e1d2e3d..7c23cca 100644 --- a/engine/SCons/Variables/PackageVariable.py +++ b/engine/SCons/Variables/PackageVariable.py @@ -50,7 +50,7 @@ Usage example: # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Variables/PackageVariable.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Variables/PackageVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __all__ = ['PackageVariable',] diff --git a/engine/SCons/Variables/PathVariable.py b/engine/SCons/Variables/PathVariable.py index 8003ba6..bf123fb 100644 --- a/engine/SCons/Variables/PathVariable.py +++ b/engine/SCons/Variables/PathVariable.py @@ -67,7 +67,7 @@ Usage example:: # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Variables/PathVariable.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Variables/PathVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __all__ = ['PathVariable',] diff --git a/engine/SCons/Variables/__init__.py b/engine/SCons/Variables/__init__.py index c218e18..5b4b3af 100644 --- a/engine/SCons/Variables/__init__.py +++ b/engine/SCons/Variables/__init__.py @@ -26,7 +26,7 @@ customizable variables to an SCons build. # 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/Variables/__init__.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Variables/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os.path import sys @@ -99,7 +99,7 @@ class Variables(object): option.converter = converter self.options.append(option) - + # options might be added after the 'unknown' dict has been set up, # so we remove the key and all its aliases from that dict for alias in list(option.aliases) + [ option.key ]: @@ -168,7 +168,7 @@ class Variables(object): # first set the defaults: for option in self.options: - if not option.default is None: + if option.default is not None: values[option.key] = option.default # next set the value specified in the options file @@ -288,7 +288,7 @@ class Variables(object): env - an environment that is used to get the current values of the options. - cmp - Either a function as follows: The specific sort function should take two arguments and return -1, 0 or 1 + cmp - Either a function as follows: The specific sort function should take two arguments and return -1, 0 or 1 or a boolean to indicate if it should be sorted. """ diff --git a/engine/SCons/Warnings.py b/engine/SCons/Warnings.py index d3143fd..1c84d57 100644 --- a/engine/SCons/Warnings.py +++ b/engine/SCons/Warnings.py @@ -27,7 +27,7 @@ This file implements the warnings framework for SCons. """ -__revision__ = "src/engine/SCons/Warnings.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/Warnings.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import sys @@ -193,9 +193,10 @@ def warn(clazz, *args): break def process_warn_strings(arguments): - """Process string specifications of enabling/disabling warnings, - as passed to the --warn option or the SetOption('warn') function. - + """Process requests to enable/disable warnings. + + The requests are strings passed to the --warn option or the + SetOption('warn') function. An argument to this option should be of the form <warning-class> or no-<warning-class>. The warning class is munged in order @@ -210,7 +211,6 @@ def process_warn_strings(arguments): As a special case, --warn=all and --warn=no-all will enable or disable (respectively) the base Warning class of all warnings. - """ def _capitalize(s): diff --git a/engine/SCons/__init__.py b/engine/SCons/__init__.py index 27c37eb..1f52e1f 100644 --- a/engine/SCons/__init__.py +++ b/engine/SCons/__init__.py @@ -27,15 +27,15 @@ The main package for the SCons software construction utility. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/__init__.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/__init__.py ae4de9ab2249be220b6658a514eef8c3a57afc04 2019-07-21 02:32:15 bdeegan" -__version__ = "3.0.5" +__version__ = "3.1.0" -__build__ = "a56bbd8c09fb219ab8a9673330ffcd55279219d0" +__build__ = "ae4de9ab2249be220b6658a514eef8c3a57afc04" __buildsys__ = "kufra" -__date__ = "2019-03-26 23:16:31" +__date__ = "2019-07-21 02:32:15" __developer__ = "bdeegan" diff --git a/engine/SCons/__main__.py b/engine/SCons/__main__.py new file mode 100644 index 0000000..0dfbb9d --- /dev/null +++ b/engine/SCons/__main__.py @@ -0,0 +1,4 @@ +import SCons.Script +# this does all the work, and calls sys.exit +# with the proper exit status when done. +SCons.Script.main() diff --git a/engine/SCons/compat/__init__.py b/engine/SCons/compat/__init__.py index 7846577..dcbd8e8 100644 --- a/engine/SCons/compat/__init__.py +++ b/engine/SCons/compat/__init__.py @@ -57,31 +57,22 @@ function defined below loads the module as the "real" name (without the rest of our code will find our pre-loaded compatibility module. """ -__revision__ = "src/engine/SCons/compat/__init__.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/compat/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import sys -import imp # Use the "imp" module to protect imports from fixers. +import importlib PYPY = hasattr(sys, 'pypy_translation_info') -def import_as(module, name): - """ - Imports the specified module (from our local directory) as the - specified name, returning the loaded module object. - """ - dir = os.path.split(__file__)[0] - return imp.load_module(name, *imp.find_module(module, [dir])) - - def rename_module(new, old): """ - Attempts to import the old module and load it under the new name. + Attempt to import the old module and load it under the new name. Used for purely cosmetic name changes in Python 3.x. """ try: - sys.modules[new] = imp.load_module(old, *imp.find_module(old)) + sys.modules[new] = importlib.import_module(old) return True except ImportError: return False @@ -122,28 +113,28 @@ except AttributeError: # intern into the sys package sys.intern = intern -# Preparing for 3.x. UserDict, UserList, UserString are in -# collections for 3.x, but standalone in 2.7.x +# UserDict, UserList, UserString are in # collections for 3.x, +# but standalone in 2.7.x. Monkey-patch into collections for 2.7. import collections try: collections.UserDict except AttributeError: - exec ('from UserDict import UserDict as _UserDict') + from UserDict import UserDict as _UserDict collections.UserDict = _UserDict del _UserDict try: collections.UserList except AttributeError: - exec ('from UserList import UserList as _UserList') + from UserList import UserList as _UserList collections.UserList = _UserList del _UserList try: collections.UserString except AttributeError: - exec ('from UserString import UserString as _UserString') + from UserString import UserString as _UserString collections.UserString = _UserString del _UserString diff --git a/engine/SCons/compat/_scons_dbm.py b/engine/SCons/compat/_scons_dbm.py index a57f105..ec5e261 100644 --- a/engine/SCons/compat/_scons_dbm.py +++ b/engine/SCons/compat/_scons_dbm.py @@ -30,7 +30,7 @@ that the whichdb.whichdb() implementstation in the various 2.X versions of Python won't blow up even if dbm wasn't compiled in. """ -__revision__ = "src/engine/SCons/compat/_scons_dbm.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/compat/_scons_dbm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" class error(Exception): pass diff --git a/engine/SCons/cpp.py b/engine/SCons/cpp.py index eb537e2..7c4ac92 100644 --- a/engine/SCons/cpp.py +++ b/engine/SCons/cpp.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/cpp.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/cpp.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" __doc__ = """ SCons C Pre-Processor module @@ -165,7 +165,7 @@ def CPP_to_Python(s): """ s = CPP_to_Python_Ops_Expression.sub(CPP_to_Python_Ops_Sub, s) for expr, repl in CPP_to_Python_Eval_List: - s = expr.sub(repl, s) + s = re.sub(expr, repl, s) return s @@ -210,7 +210,7 @@ class FunctionEvaluator(object): parts = [] for s in self.expansion: - if not s in self.args: + if s not in self.args: s = repr(s) parts.append(s) statement = ' + '.join(parts) diff --git a/engine/SCons/exitfuncs.py b/engine/SCons/exitfuncs.py index e1b9382..c5414a2 100644 --- a/engine/SCons/exitfuncs.py +++ b/engine/SCons/exitfuncs.py @@ -27,7 +27,7 @@ Register functions which are executed when SCons exits for any reason. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/exitfuncs.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/engine/SCons/exitfuncs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import atexit diff --git a/scons-time.1 b/scons-time.1 index d9e9bae..8ea1da3 100644 --- a/scons-time.1 +++ b/scons-time.1 @@ -2,12 +2,12 @@ .\" Title: SCONS-TIME .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/> -.\" Date: 03/26/2019 -.\" Manual: SCons 3.0.5 -.\" Source: SCons 3.0.5 +.\" Date: 07/20/2019 +.\" Manual: SCons 3.1.0 +.\" Source: SCons 3.1.0 .\" Language: English .\" -.TH "SCONS\-TIME" "1" "03/26/2019" "SCons 3\&.0\&.5" "SCons 3\&.0\&.5" +.TH "SCONS\-TIME" "1" "07/20/2019" "SCons 3\&.1\&.0" "SCons 3\&.1\&.0" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -3,11 +3,11 @@ .\" Author: Steven Knight .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/> .\" Date: <pubdate>2004 - 2019</pubdate> -.\" Manual: SCons 3.0.5 -.\" Source: SCons 3.0.5 version 3.0.5 +.\" Manual: SCons 3.1.0 +.\" Source: SCons 3.1.0 version 3.1.0 .\" Language: English .\" -.TH "SCONS" "1" "<pubdate>2004 - 2019</pubdate>" "SCons 3\&.0\&.5 version 3.0.5" "SCons 3\&.0\&.5" +.TH "SCONS" "1" "<pubdate>2004 - 2019</pubdate>" "SCons 3\&.1\&.0 version 3.1.0" "SCons 3\&.1\&.0" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -1413,14 +1413,14 @@ env[\*(AqBAR\*(Aq] = \*(Aqbar\*(Aq As a convenience, construction variables may also be set or modified by the \fIparse_flags\fR keyword argument, which applies the -\fBParseFlags\fR +\fBenv\&.MergeFlags\fR method (described below) to the argument value after all other processing is completed\&. This is useful either if the exact content of the flags is unknown (for example, read from a control file) or if the flags are distributed to a number of construction variables\&. .sp .if n \{\ .RS 4 .\} .nf -env = Environment(parse_flags = \*(Aq\-Iinclude \-DEBUG \-lm\*(Aq) +env = Environment(parse_flags=\*(Aq\-Iinclude \-DEBUG \-lm\*(Aq) .fi .if n \{\ .RE @@ -3875,13 +3875,14 @@ env\&.SharedLibrary(\*(Aqword\*(Aq, \*(Aqword\&.cpp\*(Aq, .PP It is also possible to use the \fIparse_flags\fR -keyword argument in an override: +keyword argument in an override, to merge command\-line style arguments into the appropriate construction variables (see +\fBenv\&.MergeFlags\fR)\&. .sp .if n \{\ .RS 4 .\} .nf -env = Program(\*(Aqhello\*(Aq, \*(Aqhello\&.c\*(Aq, parse_flags = \*(Aq\-Iinclude \-DEBUG \-lm\*(Aq) +env = Program(\*(Aqhello\*(Aq, \*(Aqhello\&.c\*(Aq, parse_flags=\*(Aq\-Iinclude \-DEBUG \-lm\*(Aq) .fi .if n \{\ .RE @@ -4891,15 +4892,17 @@ This builds a Visual Studio project file, based on the version of Visual Studio \fB$MSVS_VERSION\fR in the Environment constructor)\&. For Visual Studio 6, it will generate a \&.dsp -file\&. For Visual Studio 7 (\&.NET) and later versions, it will generate a +file\&. For Visual Studio 7, 8, and 9, it will generate a \&.vcproj +file\&. For Visual Studio 10 and later, it will generate a +\&.vcxproj file\&. .sp By default, this also generates a solution file for the specified project, a \&.dsw file for Visual Studio 6 or a \&.sln -file for Visual Studio 7 (\&.NET)\&. This behavior may be disabled by specifying +file for Visual Studio 7 and later\&. This behavior may be disabled by specifying auto_build_solution=0 when you call \fBMSVSProject\fR, in which case you presumably want to build the solution file(s) by calling the @@ -4951,6 +4954,28 @@ variant entries, or be empty (not specified)\&. If you give only one, it will automatically be propagated to all variants\&. .RE .PP +cppdefines +.RS 4 +Preprocessor definitions for the different variants\&. The number of +cppdefines +entries must match the number of +variant +entries, or be empty (not specified)\&. If you give only one, it will automatically be propagated to all variants\&. If you don\*(Aqt give this parameter, SCons will use the invoking environment\*(Aqs +CPPDEFINES +entry for all variants\&. +.RE +.PP +cpppaths +.RS 4 +Compiler include paths for the different variants\&. The number of +cpppaths +entries must match the number of +variant +entries, or be empty (not specified)\&. If you give only one, it will automatically be propagated to all variants\&. If you don\*(Aqt give this parameter, SCons will use the invoking environment\*(Aqs +CPPPATH +entry for all variants\&. +.RE +.PP buildtarget .RS 4 An optional string, node, or list of strings or nodes (one per build variant), to tell the Visual Studio debugger what output target to use in what build variant\&. The number of @@ -7524,14 +7549,15 @@ env4 = env\&.Clone(tools = [\*(Aqmsvc\*(Aq, MyTool]) .sp The \fIparse_flags\fR -keyword argument is also recognized: +keyword argument is also recognized to allow merging command\-line style arguments into the appropriate construction variables (see +\fBenv\&.MergeFlags\fR)\&. .sp .if n \{\ .RS 4 .\} .nf # create an environment for compiling programs that use wxWidgets -wx_env = env\&.Clone(parse_flags = \*(Aq!wx\-config \-\-cflags \-\-cxxflags\*(Aq) +wx_env = env\&.Clone(parse_flags=\*(Aq!wx\-config \-\-cflags \-\-cxxflags\*(Aq) .fi .if n \{\ .RE @@ -7704,6 +7730,13 @@ the last time the \fItarget\fR was built\&. This can be consulted to match various file characteristics such as the timestamp, size, or content signature\&. .RE +.PP +\fIrepo_node\fR +.RS 4 +Use this node instead of the one specified by +\fIdependency\fR +to determine if the dependency has changed\&. +.RE .sp The \fIfunction\fR @@ -7727,7 +7760,7 @@ Example: .RS 4 .\} .nf -def my_decider(dependency, target, prev_ni): +def my_decider(dependency, target, prev_ni, repo_node=None): return not os\&.path\&.exists(str(target)) env\&.Decider(my_decider) @@ -8868,6 +8901,9 @@ Flag values are translated accordig to the prefix found, and added to the follow \-frameworkdir= FRAMEWORKPATH \-include CCFLAGS \-isysroot CCFLAGS, LINKFLAGS +\-isystem CCFLAGS +\-iquote CCFLAGS +\-idirafter CCFLAGS \-I CPPPATH \-l LIBS \-L LIBPATH @@ -13925,6 +13961,7 @@ If is not set, SCons will (by default) select the latest version of Visual C/C++ installed on your system\&. If the specified version isn\*(Aqt installed, tool initialization will fail\&. This variable must be passed as an argument to the Environment() constructor; setting it later has no effect\&. .sp Valid values for Windows are +14\&.2, 14\&.1, 14\&.0, 14\&.0Exp, @@ -16011,6 +16048,12 @@ TARSUFFIX The suffix used for tar file names\&. .RE .PP +TEMPFILEARGJOIN +.RS 4 +The string (or character) to be used to join the arguments passed to TEMPFILE when command line exceeds the limit set by +\fB$MAXLINELENGTH\fR\&. The default value is a space\&. However for MSVC, MSLINK the default is a line seperator characters as defined by os\&.linesep\&. Note this value is used literally and not expanded by the subst logic\&. +.RE +.PP TEMPFILEPREFIX .RS 4 The prefix for a temporary file used to store lines lines longer than $MAXLINELENGTH as operations which call out to a shell will fail if the line is too long, which particularly impacts linking\&. The default is \*(Aq@\*(Aq, which works for the Microsoft and GNU toolchains on Windows\&. Set this appropriately for other toolchains, for example \*(Aq\-@\*(Aq for the diab compiler or \*(Aq\-via\*(Aq for ARM toolchain\&. @@ -2,12 +2,12 @@ .\" Title: SCONSIGN .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/> -.\" Date: 03/26/2019 -.\" Manual: SCons 3.0.5 -.\" Source: SCons 3.0.5 +.\" Date: 07/20/2019 +.\" Manual: SCons 3.1.0 +.\" Source: SCons 3.1.0 .\" Language: English .\" -.TH "SCONSIGN" "1" "03/26/2019" "SCons 3\&.0\&.5" "SCons 3\&.0\&.5" +.TH "SCONSIGN" "1" "07/20/2019" "SCons 3\&.1\&.0" "SCons 3\&.1\&.0" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,26 +28,36 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -sconsign \- print SCons \&.sconsign file information +sconsign \- print SCons signature file information .SH "SYNOPSIS" .HP \w'\fBsconsign\fR\ 'u -\fBsconsign\fR [\fIoptions\fR...] \fIfile\fR [\fI\&.\&.\&.\fR] +\fBsconsign\fR [\fIoptions\fR...] [\fIfile\fR...] .SH "DESCRIPTION" .PP The \fBsconsign\fR -command displays the contents of one or more -\fB\&.sconsign\fR -files specified by the user\&. +command displays the contents of one or more signature ("\fBsconsign\fR") files specified by the user\&. .PP By default, \fBsconsign\fR -dumps the entire contents of the specified file(s)\&. Each entry is printed in the following format: -.PP -file: signature timestamp length implicit_dependency_1: signature timestamp length implicit_dependency_2: signature timestamp length action_signature [action string] +dumps the entire contents of the specified file(s)\&. Without the verbose option, each entry is printed in the following format: +.sp +.if n \{\ +.RS 4 +.\} +.nf +file: signature timestamp length + implicit_dependency_1: signature timestamp length + implicit_dependency_2: signature timestamp length + \&.\&.\&. + action_signature [action string] +.fi +.if n \{\ +.RE +.\} .PP \fBNone\fR -is printed in place of any missing timestamp, bsig, or csig values for any entry or any of its dependencies\&. If the entry has no implicit dependencies, or no build action, the lines are simply omitted\&. +is printed in place of any missing timestamp, build signature ("bsig"), or content signature ("csig") values for any entry or any of its dependencies\&. If the entry has no implicit dependencies, or no build action, the lines are simply omitted\&. The verbose option expands the display into a more human readable format\&. .PP By default, \fBsconsign\fR @@ -56,7 +66,7 @@ assumes that any arguments that end with a \fB\&.dbm\fR suffix contains signature entries for more than one directory (that is, was specified by the -\fBSConsignFile ()\fR +\fBSConsignFile\fR function)\&. Any \fIfile\fR argument that ends in @@ -70,6 +80,12 @@ attempts to guess the format\&. If that does not work, an explicit format may be or \fB\-\-format=\fR options\&. +.PP +If there are no +\fIfile\fR +arguments, the name +\&.sconsign\&.dblite +is assumed\&. .SH "OPTIONS" .PP Various options control what information is printed and the format: @@ -110,7 +126,8 @@ The file(s) to be printed are in the specified \fIFORMAT\fR\&. Legal values are \fBdbm\fR (the DBM format used when the -\fBSConsignFile\fR() function is used) or +\fBSConsignFile\fR +function is used) or \fBsconsign\fR (the default format used for an individual \fB\&.sconsign\fR @@ -124,12 +141,12 @@ Prints a help message and exits\&. .PP \-i, \-\-implicit .RS 4 -Prints the list of cached implicit dependencies for all entries or the the specified entries\&. +Prints the list of cached implicit dependencies for all entries or for the specified entries\&. .RE .PP \-\-raw .RS 4 -Prints a pretty\-printed representation of the raw Python dictionary that holds build information about individual entry (both the entry itself or its implicit dependencies)\&. An entry\*(Aqs build action is still printed in its usual format\&. +Prints a pretty\-printed representation of the raw Python dictionary that holds build information about individual entries (both the entry itself and its implicit dependencies)\&. An entry\*(Aqs build action is still printed in its usual format\&. .RE .PP \-r, \-\-readable @@ -150,7 +167,8 @@ Prints labels identifying each field being printed\&. .PP SCONS_LIB_DIR .RS 4 -Specifies the directory that contains the SCons Python module directory (e\&.g\&. /home/aroach/scons\-src\-0\&.01/src/engine)\&. on the command line\&. +Specifies the directory that contains the SCons Python module directory (e\&.g\&. +/home/aroach/scons\-src\-0\&.01/src/engine)\&. on the command line\&. .RE .SH "SEE ALSO" .PP diff --git a/script/scons b/script/scons index c0fe872..98f4e62 100755 --- a/script/scons +++ b/script/scons @@ -25,15 +25,15 @@ from __future__ import print_function -__revision__ = "src/script/scons.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/script/scons.py ae4de9ab2249be220b6658a514eef8c3a57afc04 2019-07-21 02:32:15 bdeegan" -__version__ = "3.0.5" +__version__ = "3.1.0" -__build__ = "a56bbd8c09fb219ab8a9673330ffcd55279219d0" +__build__ = "ae4de9ab2249be220b6658a514eef8c3a57afc04" __buildsys__ = "kufra" -__date__ = "2019-03-26 23:16:31" +__date__ = "2019-07-21 02:32:15" __developer__ = "bdeegan" diff --git a/script/scons-configure-cache b/script/scons-configure-cache index 798b8fa..757a79f 100644 --- a/script/scons-configure-cache +++ b/script/scons-configure-cache @@ -37,15 +37,15 @@ import glob import json import os -__revision__ = "src/script/scons-configure-cache.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/script/scons-configure-cache.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" -__version__ = "3.0.5" +__version__ = "3.1.0" -__build__ = "a56bbd8c09fb219ab8a9673330ffcd55279219d0" +__build__ = "e724ae812eb96f4858a132f5b8c769724744faf6" __buildsys__ = "kufra" -__date__ = "2019-03-26 23:16:31" +__date__ = "2019-07-21 00:04:47" __developer__ = "bdeegan" diff --git a/script/scons-time b/script/scons-time index 26ddd77..975ff64 100644 --- a/script/scons-time +++ b/script/scons-time @@ -31,7 +31,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. from __future__ import division, print_function -__revision__ = "src/script/scons-time.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/script/scons-time.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import getopt import glob @@ -41,21 +41,7 @@ import shutil import sys import tempfile import time - -def make_temp_file(**kw): - try: - result = tempfile.mktemp(**kw) - result = os.path.realpath(result) - except TypeError: - try: - save_template = tempfile.template - prefix = kw['prefix'] - del kw['prefix'] - tempfile.template = prefix - result = tempfile.mktemp(**kw) - finally: - tempfile.template = save_template - return result +import subprocess def HACK_for_exec(cmd, *args): """ @@ -121,7 +107,7 @@ class Line(object): # in the line's index number. We might want to represent # this some way rather than just drawing the line straight # between the two points on either side. - if not y is None: + if y is not None: print(fmt % (x, y)) print('e') @@ -155,13 +141,13 @@ class Gnuplotter(Plotter): result = [] for line in self.lines: result.extend(line.get_x_values()) - return [r for r in result if not r is None] + return [r for r in result if r is not None] def get_all_y_values(self): result = [] for line in self.lines: result.extend(line.get_y_values()) - return [r for r in result if not r is None] + return [r for r in result if r is not None] def get_min_x(self): try: @@ -248,14 +234,16 @@ def unzip(fname): os.makedirs(dir) except: pass - open(name, 'wb').write(zf.read(name)) + with open(name, 'wb') as f: + f.write(zf.read(name)) def read_tree(dir): for dirpath, dirnames, filenames in os.walk(dir): for fn in filenames: fn = os.path.join(dirpath, fn) if os.path.isfile(fn): - open(fn, 'rb').read() + with open(fn, 'rb') as f: + f.read() def redirect_to_file(command, log): return '%s > %s 2>&1' % (command, log) @@ -264,7 +252,7 @@ def tee_to_file(command, log): return '%s 2>&1 | tee %s' % (command, log) - + class SConsTimer(object): """ Usage: scons-time SUBCOMMAND [ARGUMENTS] @@ -360,7 +348,7 @@ class SConsTimer(object): 'SCons' : 'Total SCons execution time', 'commands' : 'Total command execution time', } - + time_string_all = 'Total .* time' # @@ -456,14 +444,20 @@ class SConsTimer(object): def log_execute(self, command, log): command = self.subst(command, self.__dict__) - output = os.popen(command).read() + p = os.popen(command) + output = p.read() + p.close() + #TODO: convert to subrocess, os.popen is obsolete. This didn't work: + #process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) + #output = process.stdout.read() + #process.stdout.close() + #process.wait() if self.verbose: sys.stdout.write(output) # TODO: Figure out # Not sure we need to write binary here - open(log, 'w').write(output) - - # + with open(log, 'w') as f: + f.write(str(output)) def archive_splitext(self, path): """ @@ -628,13 +622,14 @@ class SConsTimer(object): search_string = self.time_string_all else: search_string = time_string - contents = open(file).read() + with open(file) as f: + contents = f.read() if not contents: sys.stderr.write('file %s has no contents!\n' % repr(file)) return None result = re.findall(r'%s: ([\d\.]*)' % search_string, contents)[-4:] result = [ float(r) for r in result ] - if not time_string is None: + if time_string is not None: try: result = result[0] except IndexError: @@ -673,7 +668,8 @@ class SConsTimer(object): search_string = self.memory_string_all else: search_string = memory_string - lines = open(file).readlines() + with open(file) as f: + lines = f.readlines() lines = [ l for l in lines if l.startswith(search_string) ][-4:] result = [ int(l.split()[-1]) for l in lines[-4:] ] if len(result) == 1: @@ -685,14 +681,14 @@ class SConsTimer(object): Returns the counts of the specified object_name. """ object_string = ' ' + object_name + '\n' - lines = open(file).readlines() + with open(file) as f: + lines = f.readlines() line = [ l for l in lines if l.endswith(object_string) ][0] result = [ int(field) for field in line.split()[:4] ] if index is not None: result = result[index] return result - # command_alias = {} @@ -925,7 +921,7 @@ class SConsTimer(object): elif o in ('-p', '--prefix'): self.prefix = a elif o in ('--stage',): - if not a in self.stages: + if a not in self.stages: sys.stderr.write('%s: mem: Unrecognized stage "%s".\n' % (self.name, a)) sys.exit(1) stage = a @@ -1039,7 +1035,7 @@ class SConsTimer(object): elif o in ('-p', '--prefix'): self.prefix = a elif o in ('--stage',): - if not a in self.stages: + if a not in self.stages: sys.stderr.write('%s: obj: Unrecognized stage "%s".\n' % (self.name, a)) sys.stderr.write('%s Type "%s help obj" for help.\n' % (self.name_spaces, self.name)) sys.exit(1) @@ -1239,7 +1235,7 @@ class SConsTimer(object): return os.path.join(dir, 'src', 'engine') def prep_aegis_run(self, commands, removals): - self.aegis_tmpdir = make_temp_file(prefix = self.name + '-aegis-') + self.aegis_tmpdir = tempfile.mkdtemp(prefix=self.name + '-aegis-') removals.append((shutil.rmtree, 'rm -rf %%s', self.aegis_tmpdir)) self.aegis_parent_project = os.path.splitext(self.aegis_project)[0] @@ -1247,21 +1243,19 @@ class SConsTimer(object): self.scons_lib_dir = self.scons_lib_dir_path(self.aegis_tmpdir) commands.extend([ - 'mkdir %(aegis_tmpdir)s', (lambda: os.chdir(self.aegis_tmpdir), 'cd %(aegis_tmpdir)s'), '%(aegis)s -cp -ind -p %(aegis_parent_project)s .', '%(aegis)s -cp -ind -p %(aegis_project)s -delta %(run_number)s .', ]) def prep_subversion_run(self, commands, removals): - self.svn_tmpdir = make_temp_file(prefix = self.name + '-svn-') + self.svn_tmpdir = tempfile.mkdtemp(prefix=self.name + '-svn-') removals.append((shutil.rmtree, 'rm -rf %%s', self.svn_tmpdir)) self.scons = self.scons_path(self.svn_tmpdir) self.scons_lib_dir = self.scons_lib_dir_path(self.svn_tmpdir) commands.extend([ - 'mkdir %(svn_tmpdir)s', '%(svn)s co %(svn_co_flag)s -r %(run_number)s %(subversion_url)s %(svn_tmpdir)s', ]) @@ -1308,11 +1302,9 @@ class SConsTimer(object): if self.targets2 is None: self.targets2 = self.targets - self.tmpdir = make_temp_file(prefix = self.name + '-') + self.tmpdir = tempfile.mkdtemp(prefix=self.name + '-') commands.extend([ - 'mkdir %(tmpdir)s', - (os.chdir, 'cd %%s', self.tmpdir), ]) @@ -1365,7 +1357,6 @@ class SConsTimer(object): if not os.environ.get('PRESERVE'): commands.extend(removals) - commands.append((shutil.rmtree, 'rm -rf %%s', self.tmpdir)) self.run_command_list(commands, self.__dict__) @@ -1432,14 +1423,16 @@ class SConsTimer(object): elif o in ('--title',): self.title = a elif o in ('--which',): - if not a in list(self.time_strings.keys()): + if a not in list(self.time_strings.keys()): sys.stderr.write('%s: time: Unrecognized timer "%s".\n' % (self.name, a)) sys.stderr.write('%s Type "%s help time" for help.\n' % (self.name_spaces, self.name)) sys.exit(1) which = a if self.config_file: - HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__) + with open(self.config_file, 'r') as f: + config = f.read() + HACK_for_exec(config, self.__dict__) if self.chdir: os.chdir(self.chdir) diff --git a/script/scons.bat b/script/scons.bat index 45c77ab..75e2a49 100644 --- a/script/scons.bat +++ b/script/scons.bat @@ -1,11 +1,11 @@ @REM Copyright (c) 2001 - 2019 The SCons Foundation
-@REM src/script/scons.bat a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan
+@REM src/script/scons.bat e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan
@echo off
set SCONS_ERRORLEVEL=
if "%OS%" == "Windows_NT" goto WinNT
@REM for 9x/Me you better not have more than 9 args
-python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-3.0.5'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-3.0.5'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9
+python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-3.1.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-3.1.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9
@REM no way to set exit status of this script for 9x/Me
goto endscons
diff --git a/script/sconsign b/script/sconsign index 3b1e52d..3e8d4cf 100644 --- a/script/sconsign +++ b/script/sconsign @@ -25,15 +25,15 @@ from __future__ import print_function -__revision__ = "src/script/sconsign.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/script/sconsign.py ae4de9ab2249be220b6658a514eef8c3a57afc04 2019-07-21 02:32:15 bdeegan" -__version__ = "3.0.5" +__version__ = "3.1.0" -__build__ = "a56bbd8c09fb219ab8a9673330ffcd55279219d0" +__build__ = "ae4de9ab2249be220b6658a514eef8c3a57afc04" __buildsys__ = "kufra" -__date__ = "2019-03-26 23:16:31" +__date__ = "2019-07-21 02:32:15" __developer__ = "bdeegan" @@ -117,7 +117,7 @@ else: # check `pwd`/lib/scons*. temp.append(os.getcwd()) else: - if script_dir == '.' or script_dir == '': + if script_dir in ('.', ''): script_dir = os.getcwd() head, tail = os.path.split(script_dir) if tail == "bin": @@ -185,13 +185,13 @@ import SCons.compat try: import whichdb + whichdb = whichdb.whichdb except ImportError as e: from dbm import whichdb import time import pickle -import imp import SCons.SConsign @@ -200,9 +200,8 @@ def my_whichdb(filename): if filename[-7:] == ".dblite": return "SCons.dblite" try: - f = open(filename + ".dblite", "rb") - f.close() - return "SCons.dblite" + with open(filename + ".dblite", "rb"): + return "SCons.dblite" except IOError: pass return _orig_whichdb(filename) @@ -217,6 +216,8 @@ whichdb = my_whichdb #dbm.whichdb = my_whichdb def my_import(mname): + import imp + if '.' in mname: i = mname.rfind('.') parent = my_import(mname[:i]) @@ -247,9 +248,8 @@ Readable = 0 Warns = 0 - def default_mapper(entry, name): - ''' + """ Stringify an entry that doesn't have an explicit mapping. Args: @@ -258,10 +258,10 @@ def default_mapper(entry, name): Returns: str - ''' + """ try: val = eval("entry." + name) - except: + except AttributeError: val = None if sys.version_info.major >= 3 and isinstance(val, bytes): # This is a dirty hack for py 2/3 compatibility. csig is a bytes object @@ -272,7 +272,7 @@ def default_mapper(entry, name): def map_action(entry, _): - ''' + """ Stringify an action entry and signature. Args: @@ -281,7 +281,7 @@ def map_action(entry, _): Returns: str - ''' + """ try: bact = entry.bact bactsig = entry.bactsig @@ -289,8 +289,9 @@ def map_action(entry, _): return None return '%s [%s]' % (bactsig, bact) + def map_timestamp(entry, _): - ''' + """ Stringify a timestamp entry. Args: @@ -299,7 +300,7 @@ def map_timestamp(entry, _): Returns: str - ''' + """ try: timestamp = entry.timestamp except AttributeError: @@ -309,8 +310,9 @@ def map_timestamp(entry, _): else: return str(timestamp) + def map_bkids(entry, _): - ''' + """ Stringify an implicit entry. Args: @@ -319,7 +321,7 @@ def map_bkids(entry, _): Returns: str - ''' + """ try: bkids = entry.bsources + entry.bdepends + entry.bimplicit bkidsigs = entry.bsourcesigs + entry.bdependsigs + entry.bimplicitsigs @@ -448,8 +450,8 @@ class Do_SConsignDB(object): def __call__(self, fname): # The *dbm modules stick their own file suffixes on the names - # that are passed in. This is causes us to jump through some - # hoops here to be able to allow the user + # that are passed in. This causes us to jump through some + # hoops here. try: # Try opening the specified file name. Example: # SPECIFIED OPENED BY self.dbm.open() @@ -461,16 +463,17 @@ class Do_SConsignDB(object): print_e = e try: # That didn't work, so try opening the base name, - # so that if the actually passed in 'sconsign.dblite' + # so that if they actually passed in 'sconsign.dblite' # (for example), the dbm module will put the suffix back # on for us and open it anyway. db = self.dbm.open(os.path.splitext(fname)[0], "r") except (IOError, OSError): # That didn't work either. See if the file name - # they specified just exists (independent of the dbm + # they specified even exists (independent of the dbm # suffix-mangling). try: - open(fname, "r") + with open(fname, "rb"): + pass # this is a touch only, we don't use it here. except (IOError, OSError) as e: # Nope, that file doesn't even exist, so report that # fact back. @@ -486,6 +489,9 @@ class Do_SConsignDB(object): except Exception as e: sys.stderr.write("sconsign: ignoring invalid `%s' file `%s': %s\n" % (self.dbm_name, fname, e)) + exc_type, _, _ = sys.exc_info() + if exc_type.__name__ == "ValueError" and sys.version_info < (3,0,0): + sys.stderr.write("Python 2 only supports pickle protocols 0-2.\n") return if Print_Directories: @@ -512,23 +518,23 @@ class Do_SConsignDB(object): def Do_SConsignDir(name): try: - fp = open(name, 'rb') + with open(name, 'rb') as fp: + try: + sconsign = SCons.SConsign.Dir(fp) + except KeyboardInterrupt: + raise + except pickle.UnpicklingError: + err = "sconsign: ignoring invalid .sconsign file `%s'\n" % (name) + sys.stderr.write(err) + return + except Exception as e: + err = "sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e) + sys.stderr.write(err) + return + printentries(sconsign.entries, args[0]) except (IOError, OSError) as e: sys.stderr.write("sconsign: %s\n" % e) return - try: - sconsign = SCons.SConsign.Dir(fp) - except KeyboardInterrupt: - raise - except pickle.UnpicklingError: - err = "sconsign: ignoring invalid .sconsign file `%s'\n" % (name) - sys.stderr.write(err) - return - except Exception as e: - err = "sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e) - sys.stderr.write(err) - return - printentries(sconsign.entries, args[0]) ############################################################################## @@ -536,7 +542,7 @@ def Do_SConsignDir(name): import getopt helpstr = """\ -Usage: sconsign [OPTIONS] FILE [...] +Usage: sconsign [OPTIONS] [FILE ...] Options: -a, --act, --action Print build action information. -c, --csig Print content signature information. @@ -552,13 +558,17 @@ Options: -v, --verbose Verbose, describe each field. """ -opts, args = getopt.getopt(sys.argv[1:], "acd:e:f:hirstv", - ['act', 'action', - 'csig', 'dir=', 'entry=', - 'format=', 'help', 'implicit', - 'raw', 'readable', - 'size', 'timestamp', 'verbose']) - +try: + opts, args = getopt.getopt(sys.argv[1:], "acd:e:f:hirstv", + ['act', 'action', + 'csig', 'dir=', 'entry=', + 'format=', 'help', 'implicit', + 'raw', 'readable', + 'size', 'timestamp', 'verbose']) +except getopt.GetoptError as err: + sys.stderr.write(str(err) + '\n') + print(helpstr) + sys.exit(2) for o, a in opts: if o in ('-a', '--act', '--action'): @@ -586,7 +596,7 @@ for o, a in opts: # this was handled by calling my_import('SCons.dblite') # again in earlier versions... SCons.dblite.ignore_corrupt_dbfiles = 0 - except: + except ImportError: sys.stderr.write("sconsign: illegal file format `%s'\n" % a) print(helpstr) sys.exit(2) @@ -613,6 +623,8 @@ if Do_Call: for a in args: Do_Call(a) else: + if not args: + args = [".sconsign.dblite"] for a in args: dbm_name = whichdb(a) if dbm_name: @@ -44,13 +44,13 @@ NOTE: Installed SCons is not importable like usual Python packages. It is """ -__revision__ = "src/setup.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__revision__ = "src/setup.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import os import stat import sys -Version = "3.0.5" +Version = "3.1.0" man_pages = [ 'scons.1', |