diff options
author | William Deegan <bill@baddogconsulting.com> | 2019-12-29 03:15:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-29 03:15:52 (GMT) |
commit | 643bdf9c989713e69b3c34700cbed98e9816f663 (patch) | |
tree | be4f0f9d098711851ede4fa6ecff8ec339928f9a /src/engine/SCons | |
parent | f5251e030120b729c17dae4de7e7e7efb8651e0e (diff) | |
parent | 37a9d36e9939bccd165885333a7c7b2870e85565 (diff) | |
download | SCons-643bdf9c989713e69b3c34700cbed98e9816f663.zip SCons-643bdf9c989713e69b3c34700cbed98e9816f663.tar.gz SCons-643bdf9c989713e69b3c34700cbed98e9816f663.tar.bz2 |
Merge branch 'master' into topic/grossag/pythonscanner
Diffstat (limited to 'src/engine/SCons')
45 files changed, 179 insertions, 315 deletions
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index b03a425..f28e201 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -581,7 +581,7 @@ class BuilderTestCase(unittest.TestCase): assert b5.src_suffixes(env) == ['.y'], b5.src_suffixes(env) def test_srcsuffix_nonext(self): - "Test target generation from non-extension source suffixes" + """Test target generation from non-extension source suffixes""" env = Environment() b6 = SCons.Builder.Builder(action = '', src_suffix='_src.a', @@ -679,7 +679,7 @@ class BuilderTestCase(unittest.TestCase): """create the file""" with open(str(target[0]), "w"): pass - if (len(source) == 1 and len(target) == 1): + if len(source) == 1 and len(target) == 1: env['CNT'][0] = env['CNT'][0] + 1 env = Environment() diff --git a/src/engine/SCons/CacheDirTests.py b/src/engine/SCons/CacheDirTests.py index 07c32b4..0e242c4 100644 --- a/src/engine/SCons/CacheDirTests.py +++ b/src/engine/SCons/CacheDirTests.py @@ -130,7 +130,7 @@ class ExceptionTestCase(unittest.TestCase): @unittest.skipIf(sys.platform.startswith("win"), "This fixture will not trigger an OSError on Windows") def test_throws_correct_on_OSError(self): """Test that the correct error is thrown when cache directory cannot be created.""" - privileged_dir = os.path.join(os.getcwd(), "privileged") + privileged_dir = os.path.join(self.tmpdir, "privileged") try: os.mkdir(privileged_dir) os.chmod(privileged_dir, stat.S_IREAD) diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 27179c3..19e7bd1 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -2199,16 +2199,6 @@ class Base(SubstitutionEnvironment): target.side_effects.append(side_effect) return side_effects - def SourceCode(self, entry, builder): - """Arrange for a source code builder for (part of) a tree.""" - msg = """SourceCode() has been deprecated and there is no replacement. -\tIf you need this function, please contact scons-dev@scons.org""" - SCons.Warnings.warn(SCons.Warnings.DeprecatedSourceCodeWarning, msg) - entries = self.arg2nodes(entry, self.fs.Entry) - for entry in entries: - entry.set_src_builder(builder) - return entries - def Split(self, arg): """This function converts a string or list into a list of strings or Nodes. This makes things easier for users by allowing files to @@ -2257,7 +2247,7 @@ class Base(SubstitutionEnvironment): build_source(node.all_children()) def final_source(node): - while (node != node.srcnode()): + while node != node.srcnode(): node = node.srcnode() return node sources = list(map(final_source, sources)) diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml index 6f263a4..b1c2039 100644 --- a/src/engine/SCons/Environment.xml +++ b/src/engine/SCons/Environment.xml @@ -2879,137 +2879,6 @@ function. </summary> </scons_function> -<scons_function name="SourceCode"> -<arguments> -(entries, builder) -</arguments> -<summary> -<para> -This function and its associate factory functions are deprecated. -There is no replacement. -The intended use was to keep a local tree in sync with an archive, -but in actuality the function only causes the archive -to be fetched on the first run. -Synchronizing with the archive is best done external to &SCons;. -</para> - -<para> -Arrange for non-existent source files to -be fetched from a source code management system -using the specified -<varname>builder</varname>. -The specified -<varname>entries</varname> -may be a Node, string or list of both, -and may represent either individual -source files or directories in which -source files can be found. -</para> - -<para> -For any non-existent source files, -&scons; -will search up the directory tree -and use the first -&f-SourceCode; -builder it finds. -The specified -<varname>builder</varname> -may be -<literal>None</literal>, -in which case -&scons; -will not use a builder to fetch -source files for the specified -<varname>entries</varname>, -even if a -&f-SourceCode; -builder has been specified -for a directory higher up the tree. -</para> - -<para> -&scons; -will, by default, -fetch files from SCCS or RCS subdirectories -without explicit configuration. -This takes some extra processing time -to search for the necessary -source code management files on disk. -You can avoid these extra searches -and speed up your build a little -by disabling these searches as follows: -</para> - -<example_commands> -env.SourceCode('.', None) -</example_commands> - -<para> -Note that if the specified -<varname>builder</varname> -is one you create by hand, -it must have an associated -construction environment to use -when fetching a source file. -</para> - -<para> -&scons; -provides a set of canned factory -functions that return appropriate -Builders for various popular -source code management systems. -Canonical examples of invocation include: -</para> - -<example_commands> -env.SourceCode('.', env.BitKeeper('/usr/local/BKsources')) -env.SourceCode('src', env.CVS('/usr/local/CVSROOT')) -env.SourceCode('/', env.RCS()) -env.SourceCode(['f1.c', 'f2.c'], env.SCCS()) -env.SourceCode('no_source.c', None) -</example_commands> -<para> -<!-- env.SourceCode('.', env.Subversion('file:///usr/local/Subversion')) --> -</para> -</summary> -</scons_function> - -<scons_function name="Split"> -<arguments> -(arg) -</arguments> -<summary> -<para> -Returns a list of file names or other objects. -If arg is a string, -it will be split on strings of white-space characters -within the string, -making it easier to write long lists of file names. -If arg is already a list, -the list will be returned untouched. -If arg is any other type of object, -it will be returned as a list -containing just the object. -</para> - -<para> -Example: -</para> - -<example_commands> -files = Split("f1.c f2.c f3.c") -files = env.Split("f4.c f5.c f6.c") -files = Split(""" - f7.c - f8.c - f9.c -""") -</example_commands> -</summary> -</scons_function> - <scons_function name="subst"> <arguments signature="env"> (input, [raw, target, source, conv]) diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index b2f2bd5..0e71f9e 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -726,7 +726,7 @@ sys.exit(0) assert r == 'replace_func2', r def test_Override(self): - "Test overriding construction variables" + """Test overriding construction variables""" env = SubstitutionEnvironment(ONE=1, TWO=2, THREE=3, FOUR=4) assert env['ONE'] == 1, env['ONE'] assert env['TWO'] == 2, env['TWO'] @@ -1408,7 +1408,7 @@ def exists(env): assert env['XYZ'] == 'ddd', env def test_concat(self): - "Test _concat()" + """Test _concat()""" e1 = self.TestEnvironment(PRE='pre', SUF='suf', STR='a b', LIST=['a', 'b']) s = e1.subst x = s("${_concat('', '', '', __env__)}") @@ -1423,7 +1423,7 @@ def exists(env): assert x == 'preasuf prebsuf', x def test_concat_nested(self): - "Test _concat() on a nested substitution strings." + """Test _concat() on a nested substitution strings.""" e = self.TestEnvironment(PRE='pre', SUF='suf', L1=['a', 'b'], L2=['c', 'd'], @@ -1956,7 +1956,7 @@ def generate(env): assert 'XXX' not in env.Dictionary() def test_FindIxes(self): - "Test FindIxes()" + """Test FindIxes()""" env = self.TestEnvironment(LIBPREFIX='lib', LIBSUFFIX='.a', SHLIBPREFIX='lib', @@ -2398,7 +2398,7 @@ f5: \ assert hasattr(env3, 'b2'), "b2 was not set" def test_ReplaceIxes(self): - "Test ReplaceIxes()" + """Test ReplaceIxes()""" env = self.TestEnvironment(LIBPREFIX='lib', LIBSUFFIX='.a', SHLIBPREFIX='lib', @@ -3255,25 +3255,6 @@ def generate(env): assert ggg.side_effects == [s], ggg.side_effects assert ccc.side_effects == [s], ccc.side_effects - def test_SourceCode(self): - """Test the SourceCode() method.""" - env = self.TestEnvironment(FOO='mmm', BAR='nnn') - e = env.SourceCode('foo', None)[0] - assert e.get_internal_path() == 'foo' - s = e.src_builder() - assert s is None, s - - b = Builder() - e = env.SourceCode(e, b)[0] - assert e.get_internal_path() == 'foo' - s = e.src_builder() - assert s is b, s - - e = env.SourceCode('$BAR$FOO', None)[0] - assert e.get_internal_path() == 'nnnmmm' - s = e.src_builder() - assert s is None, s - def test_Split(self): """Test the Split() method""" env = self.TestEnvironment(FOO = 'fff', BAR = 'bbb') @@ -3450,7 +3431,7 @@ def generate(env): assert x in over, bad_msg % x def test_parse_flags(self): - '''Test the Base class parse_flags argument''' + """Test the Base class parse_flags argument""" # all we have to show is that it gets to MergeFlags internally env = Environment(tools=[], parse_flags = '-X') assert env['CCFLAGS'] == ['-X'], env['CCFLAGS'] @@ -3464,7 +3445,7 @@ def generate(env): assert env['CPPDEFINES'] == ['FOO', 'BAR'], env['CPPDEFINES'] def test_clone_parse_flags(self): - '''Test the env.Clone() parse_flags argument''' + """Test the env.Clone() parse_flags argument""" # all we have to show is that it gets to MergeFlags internally env = Environment(tools = []) env2 = env.Clone(parse_flags = '-X') @@ -3733,7 +3714,7 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture): assert x == ['x3', 'y3', 'z3'], x def test_parse_flags(self): - '''Test the OverrideEnvironment parse_flags argument''' + """Test the OverrideEnvironment parse_flags argument""" # all we have to show is that it gets to MergeFlags internally env = SubstitutionEnvironment() env2 = env.Override({'parse_flags' : '-X'}) diff --git a/src/engine/SCons/EnvironmentValues.py b/src/engine/SCons/EnvironmentValues.py index d94bf3a..6599196 100644 --- a/src/engine/SCons/EnvironmentValues.py +++ b/src/engine/SCons/EnvironmentValues.py @@ -3,7 +3,7 @@ import re _is_valid_var = re.compile(r'[_a-zA-Z]\w*$') _rm = re.compile(r'\$[()]') -_remove = re.compile(r'\$\([^\$]*(\$[^\)][^\$]*)*\$\)') +_remove = re.compile(r'\$\([^$]*(\$[^)][^$]*)*\$\)') # Regular expressions for splitting strings and handling substitutions, # for use by the scons_subst() and scons_subst_list() functions: @@ -28,7 +28,7 @@ _remove = re.compile(r'\$\([^\$]*(\$[^\)][^\$]*)*\$\)') # _dollar_exps_str = r'\$[\$\(\)]|\$[_a-zA-Z][\.\w]*|\${[^}]*}' _dollar_exps = re.compile(r'(%s)' % _dollar_exps_str) -_separate_args = re.compile(r'(%s|\s+|[^\s\$]+|\$)' % _dollar_exps_str) +_separate_args = re.compile(r'(%s|\s+|[^\s$]+|\$)' % _dollar_exps_str) # This regular expression is used to replace strings of multiple white # space characters in the string result from the scons_subst() function. diff --git a/src/engine/SCons/JobTests.py b/src/engine/SCons/JobTests.py index 26e3d37..2e3af4f 100644 --- a/src/engine/SCons/JobTests.py +++ b/src/engine/SCons/JobTests.py @@ -46,7 +46,7 @@ def get_cpu_nums(): return int( os.popen2( "sysctl -n hw.ncpu")[1].read() ) # Windows: if "NUMBER_OF_PROCESSORS" in os.environ: - ncpus = int( os.environ[ "NUMBER_OF_PROCESSORS" ] ); + ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]) if ncpus > 0: return ncpus return 1 # Default @@ -59,14 +59,14 @@ num_jobs = get_cpu_nums()*2 # in case we werent able to detect num cpus for this test # just make a hardcoded suffcient large number, though not future proof -if(num_jobs == 2): +if num_jobs == 2: num_jobs = 33 # how many tasks to perform for the test num_tasks = num_jobs*5 class DummyLock(object): - "fake lock class to use if threads are not supported" + """fake lock class to use if threads are not supported""" def acquire(self): pass @@ -74,7 +74,7 @@ class DummyLock(object): pass class NoThreadsException(Exception): - "raised by the ParallelTestCase if threads are not supported" + """raised by the ParallelTestCase if threads are not supported""" def __str__(self): return "the interpreter doesn't support threads" @@ -113,7 +113,7 @@ class Task(object): # check if task was executing while another was also executing for j in range(1, self.taskmaster.num_tasks): - if(self.taskmaster.parallel_list[j+1] == 1): + if self.taskmaster.parallel_list[j + 1] == 1: self.taskmaster.found_parallel = True break @@ -237,7 +237,7 @@ class Taskmaster(object): return self.num_postprocessed == self.num_tasks def tasks_were_serial(self): - "analyze the task order to see if they were serial" + """analyze the task order to see if they were serial""" return not self.found_parallel def exception_set(self): @@ -251,7 +251,7 @@ ThreadPoolCallList = [] class ParallelTestCase(unittest.TestCase): def runTest(self): - "test parallel jobs" + """test parallel jobs""" try: import threading @@ -319,7 +319,7 @@ class ParallelTestCase(unittest.TestCase): class SerialTestCase(unittest.TestCase): def runTest(self): - "test a serial job" + """test a serial job""" taskmaster = Taskmaster(num_tasks, self, RandomTask) jobs = SCons.Job.Jobs(1, taskmaster) @@ -338,7 +338,7 @@ class SerialTestCase(unittest.TestCase): class NoParallelTestCase(unittest.TestCase): def runTest(self): - "test handling lack of parallel support" + """test handling lack of parallel support""" def NoParallel(tm, num, stack_size): raise NameError save_Parallel = SCons.Job.Parallel @@ -365,7 +365,7 @@ class NoParallelTestCase(unittest.TestCase): class SerialExceptionTestCase(unittest.TestCase): def runTest(self): - "test a serial job with tasks that raise exceptions" + """test a serial job with tasks that raise exceptions""" taskmaster = Taskmaster(num_tasks, self, ExceptionTask) jobs = SCons.Job.Jobs(1, taskmaster) @@ -382,7 +382,7 @@ class SerialExceptionTestCase(unittest.TestCase): class ParallelExceptionTestCase(unittest.TestCase): def runTest(self): - "test parallel jobs with tasks that raise exceptions" + """test parallel jobs with tasks that raise exceptions""" taskmaster = Taskmaster(num_tasks, self, ExceptionTask) jobs = SCons.Job.Jobs(num_jobs, taskmaster) @@ -534,13 +534,13 @@ class _SConsTaskTest(unittest.TestCase): class SerialTaskTest(_SConsTaskTest): def runTest(self): - "test serial jobs with actual Taskmaster and Task" + """test serial jobs with actual Taskmaster and Task""" self._test_seq(1) class ParallelTaskTest(_SConsTaskTest): def runTest(self): - "test parallel jobs with actual Taskmaster and Task" + """test parallel jobs with actual Taskmaster and Task""" self._test_seq(num_jobs) diff --git a/src/engine/SCons/Node/Alias.py b/src/engine/SCons/Node/Alias.py index a035816..55d94f9 100644 --- a/src/engine/SCons/Node/Alias.py +++ b/src/engine/SCons/Node/Alias.py @@ -37,6 +37,7 @@ import collections import SCons.Errors import SCons.Node import SCons.Util +from SCons.Util import MD5signature class AliasNameSpace(collections.UserDict): def Alias(self, name, **kw): @@ -166,7 +167,7 @@ class Alias(SCons.Node.Node): pass contents = self.get_contents() - csig = SCons.Util.MD5signature(contents) + csig = MD5signature(contents) self.get_ninfo().csig = csig return csig diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 4c68358..e1d6f68 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -54,6 +54,7 @@ import SCons.Node import SCons.Node.Alias import SCons.Subst import SCons.Util +from SCons.Util import MD5signature, MD5filesignature, MD5collect import SCons.Warnings from SCons.Debug import Trace @@ -1862,7 +1863,7 @@ class Dir(Base): node is called which has a child directory, the child directory should return the hash of its contents.""" contents = self.get_contents() - return SCons.Util.MD5signature(contents) + return MD5signature(contents) def do_duplicate(self, src): pass @@ -2501,14 +2502,14 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): Attributes unique to FileBuildInfo: dependency_map : Caches file->csig mapping - for all dependencies. Currently this is only used when using - MD5-timestamp decider. - It's used to ensure that we copy the correct - csig from previous build to be written to .sconsign when current build - is done. Previously the matching of csig to file was strictly by order - they appeared in bdepends, bsources, or bimplicit, and so a change in order - or count of any of these could yield writing wrong csig, and then false positive - rebuilds + for all dependencies. Currently this is only used when using + MD5-timestamp decider. + It's used to ensure that we copy the correct csig from the + previous build to be written to .sconsign when current build + is done. Previously the matching of csig to file was strictly + by order they appeared in bdepends, bsources, or bimplicit, + and so a change in order or count of any of these could + yield writing wrong csig, and then false positive rebuilds """ __slots__ = ['dependency_map', ] current_version_id = 2 @@ -2723,11 +2724,10 @@ class File(Base): Compute and return the MD5 hash for this file. """ if not self.rexists(): - return SCons.Util.MD5signature('') + return MD5signature('') fname = self.rfile().get_abspath() try: - cs = SCons.Util.MD5filesignature(fname, - chunksize=SCons.Node.FS.File.md5_chunksize*1024) + cs = MD5filesignature(fname, chunksize=File.md5_chunksize * 1024) except EnvironmentError as e: if not e.filename: e.filename = fname @@ -3028,7 +3028,7 @@ class File(Base): @see: built() and Node.release_target_info() """ - if (self.released_target_info or SCons.Node.interactive): + if self.released_target_info or SCons.Node.interactive: return if not hasattr(self.attributes, 'keep_targetinfo'): @@ -3210,7 +3210,7 @@ class File(Base): if csig is None: try: - if self.get_size() < SCons.Node.FS.File.md5_chunksize: + if self.get_size() < File.md5_chunksize: contents = self.get_contents() else: csig = self.get_content_hash() @@ -3312,7 +3312,7 @@ class File(Base): # For an "empty" binfo properties like bsources # do not exist: check this to avoid exception. - if (len(binfo.bsourcesigs) + len(binfo.bdependsigs) + \ + if (len(binfo.bsourcesigs) + len(binfo.bdependsigs) + len(binfo.bimplicitsigs)) == 0: return {} @@ -3580,7 +3580,7 @@ class File(Base): node = repo_dir.file_on_disk(self.name) if node and node.exists() and \ - (isinstance(node, File) or isinstance(node, Entry) \ + (isinstance(node, File) or isinstance(node, Entry) or not node.is_derived()): retvals.append(node) @@ -3611,8 +3611,7 @@ class File(Base): cachedir, cachefile = self.get_build_env().get_CacheDir().cachepath(self) if not self.exists() and cachefile and os.path.exists(cachefile): - self.cachedir_csig = SCons.Util.MD5filesignature(cachefile, \ - SCons.Node.FS.File.md5_chunksize * 1024) + self.cachedir_csig = MD5filesignature(cachefile, File.md5_chunksize * 1024) else: self.cachedir_csig = self.get_csig() return self.cachedir_csig @@ -3632,7 +3631,7 @@ class File(Base): executor = self.get_executor() - result = self.contentsig = SCons.Util.MD5signature(executor.get_contents()) + result = self.contentsig = MD5signature(executor.get_contents()) return result def get_cachedir_bsig(self): @@ -3663,7 +3662,7 @@ class File(Base): sigs.append(self.get_internal_path()) # Merge this all into a single signature - result = self.cachesig = SCons.Util.MD5collect(sigs) + result = self.cachesig = MD5collect(sigs) return result default_fs = None diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index eddfdf0..9c19481 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -2508,8 +2508,8 @@ class FileTestCase(_tempdirTestCase): build_f1, src_f1) def test_changed(self): - """ - Verify that changes between BuildInfo's list of souces, depends, and implicit + """ + Verify that changes between BuildInfo's list of souces, depends, and implicit dependencies do not corrupt content signature values written to .SConsign when using CacheDir and Timestamp-MD5 decider. This is for issue #2980 @@ -3374,10 +3374,11 @@ class find_fileTestCase(unittest.TestCase): node_pseudo.set_src_builder(1) # Any non-zero value. paths = tuple(map(fs.Dir, ['.', 'same', './bar'])) - nodes = [SCons.Node.FS.find_file('foo', paths)] - nodes.append(SCons.Node.FS.find_file('baz', paths)) - nodes.append(SCons.Node.FS.find_file('pseudo', paths)) - nodes.append(SCons.Node.FS.find_file('same', paths)) + nodes = [SCons.Node.FS.find_file('foo', paths), + SCons.Node.FS.find_file('baz', paths), + SCons.Node.FS.find_file('pseudo', paths), + SCons.Node.FS.find_file('same', paths) + ] file_names = list(map(str, nodes)) file_names = list(map(os.path.normpath, file_names)) diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 678e03e..d8179ff 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -1304,7 +1304,7 @@ class NodeTestCase(unittest.TestCase): def test_postprocess(self): """Test calling the base Node postprocess() method""" n = SCons.Node.Node() - n.waiting_parents = set( ['foo','bar'] ) + n.waiting_parents = {'foo', 'bar'} n.postprocess() assert n.waiting_parents == set(), n.waiting_parents @@ -1316,7 +1316,7 @@ class NodeTestCase(unittest.TestCase): assert n1.waiting_parents == set(), n1.waiting_parents r = n1.add_to_waiting_parents(n2) assert r == 1, r - assert n1.waiting_parents == set((n2,)), n1.waiting_parents + assert n1.waiting_parents == {n2}, n1.waiting_parents r = n1.add_to_waiting_parents(n2) assert r == 0, r diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index daf79ba..0b58282 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -60,6 +60,7 @@ from SCons.Debug import logInstanceCreation import SCons.Executor import SCons.Memoize import SCons.Util +from SCons.Util import MD5signature from SCons.Debug import Trace @@ -1167,7 +1168,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)): if self.has_builder(): binfo.bact = str(executor) - binfo.bactsig = SCons.Util.MD5signature(executor.get_contents()) + binfo.bactsig = MD5signature(executor.get_contents()) if self._specific_sources: sources = [s for s in self.sources if s not in ignore_set] @@ -1205,7 +1206,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)): return self.ninfo.csig except AttributeError: ninfo = self.get_ninfo() - ninfo.csig = SCons.Util.MD5signature(self.get_contents()) + ninfo.csig = MD5signature(self.get_contents()) return self.ninfo.csig def get_cachedir_csig(self): @@ -1496,7 +1497,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)): if self.has_builder(): contents = self.get_executor().get_contents() - newsig = SCons.Util.MD5signature(contents) + newsig = MD5signature(contents) if bi.bactsig != newsig: if t: Trace(': bactsig %s != newsig %s' % (bi.bactsig, newsig)) result = True diff --git a/src/engine/SCons/PathListTests.py b/src/engine/SCons/PathListTests.py index b5989bb..104be73 100644 --- a/src/engine/SCons/PathListTests.py +++ b/src/engine/SCons/PathListTests.py @@ -108,7 +108,7 @@ class subst_pathTestCase(unittest.TestCase): self.env.subst = lambda s, target, source, conv: 'NOT THIS STRING' - pl = SCons.PathList.PathList(('x')) + pl = SCons.PathList.PathList(('x',)) result = pl.subst_path(self.env, 'y', 'z') diff --git a/src/engine/SCons/Platform/virtualenv.py b/src/engine/SCons/Platform/virtualenv.py index 4127d8c..4708cb2 100644 --- a/src/engine/SCons/Platform/virtualenv.py +++ b/src/engine/SCons/Platform/virtualenv.py @@ -61,7 +61,7 @@ def _is_path_in(path, base): if not path or not base: # empty path may happen, base too return False rp = os.path.relpath(path, base) - return ((not rp.startswith(os.path.pardir)) and (not rp == os.path.curdir)) + return (not rp.startswith(os.path.pardir)) and (not rp == os.path.curdir) def _inject_venv_variables(env): diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 71729c9..e706dae 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -270,7 +270,7 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask): cached_error = False cachable = True for t in self.targets: - if T: Trace('%s' % (t)) + if T: Trace('%s' % t) bi = t.get_stored_info().binfo if isinstance(bi, SConfBuildInfo): if T: Trace(': SConfBuildInfo') @@ -280,7 +280,7 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask): else: if T: Trace(': get_state() %s' % t.get_state()) if T: Trace(': changed() %s' % t.changed()) - if (t.get_state() != SCons.Node.up_to_date and t.changed()): + if t.get_state() != SCons.Node.up_to_date and t.changed(): changed = True if T: Trace(': changed %s' % changed) cached_error = cached_error or bi.result @@ -668,7 +668,7 @@ class SConfBase(object): is saved in self.lastTarget (for further processing). """ ok = self.TryLink(text, extension) - if( ok ): + if ok: prog = self.lastTarget pname = prog.get_internal_path() output = self.confdir.File(os.path.basename(pname)+'.out') @@ -866,9 +866,9 @@ class CheckContext(object): return self.sconf.TryRun(*args, **kw) def __getattr__( self, attr ): - if( attr == 'env' ): + if attr == 'env': return self.sconf.env - elif( attr == 'lastTarget' ): + elif attr == 'lastTarget': return self.sconf.lastTarget else: raise AttributeError("CheckContext instance has no attribute '%s'" % attr) @@ -1067,7 +1067,7 @@ def CheckLibWithHeader(context, libs, header, language, """ prog_prefix, dummy = \ createIncludesFromHeaders(header, 0) - if libs == []: + if not libs: libs = [None] if not SCons.Util.is_List(libs): diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index 787138e..c5d1fbd 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -151,7 +151,7 @@ class SConfTestCase(unittest.TestCase): log_file=self.test.workpath('config.log')) no_std_header_h = self.test.workpath('config.tests', 'no_std_header.h') test_h = self.test.write( no_std_header_h, - "/* we are changing a dependency now */\n" ); + "/* we are changing a dependency now */\n" ) try: res = checks( self, sconf, TryFunc ) log = self.test.read( self.test.workpath('config.log') ) diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index 64a2345..abe4042 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -236,7 +236,7 @@ class BaseTestCase(unittest.TestCase): def test___cmp__(self): """Test the Scanner.Base class __cmp__() method""" s = SCons.Scanner.Base(self.func, "Cmp") - assert s != None + assert s is not None def test_hash(self): """Test the Scanner.Base class __hash__() method""" @@ -578,8 +578,6 @@ class ClassicTestCase(unittest.TestCase): "recursive = 1 didn't return all nodes: %s" % n) - - class ClassicCPPTestCase(unittest.TestCase): def test_find_include(self): """Test the Scanner.ClassicCPP find_include() method""" diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 238a828..f9c8384 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -355,7 +355,7 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): display("Removed directory " + pathstr) else: errstr = "Path '%s' exists but isn't a file or directory." - raise SCons.Errors.UserError(errstr % (pathstr)) + raise SCons.Errors.UserError(errstr % pathstr) except SCons.Errors.UserError as e: print(e) except (IOError, OSError) as e: diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 66c7239..8ec8ccf 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -28,7 +28,7 @@ import re import sys import textwrap -no_hyphen_re = re.compile(r'(\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') +no_hyphen_re = re.compile(r'(\s+|(?<=[\w!\"\'&.,?])-{2,}(?=\w))') try: from gettext import gettext diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 9947943..8f526be 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -344,7 +344,6 @@ GlobalDefaultEnvironmentFunctions = [ 'Requires', 'SConsignFile', 'SideEffect', - 'SourceCode', 'Split', 'Tag', 'Value', diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py index f3693a1..664cd6c 100644 --- a/src/engine/SCons/Subst.py +++ b/src/engine/SCons/Subst.py @@ -754,7 +754,7 @@ _list_remove = [ _rm_list, None, _remove_list ] # _dollar_exps_str = r'\$[\$\(\)]|\$[_a-zA-Z][\.\w]*|\${[^}]*}' _dollar_exps = re.compile(r'(%s)' % _dollar_exps_str) -_separate_args = re.compile(r'(%s|\s+|[^\s\$]+|\$)' % _dollar_exps_str) +_separate_args = re.compile(r'(%s|\s+|[^\s$]+|\$)' % _dollar_exps_str) # This regular expression is used to replace strings of multiple white # space characters in the string result from the scons_subst() function. diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py index f6fe1ec..c25b377 100644 --- a/src/engine/SCons/SubstTests.py +++ b/src/engine/SCons/SubstTests.py @@ -133,8 +133,8 @@ class SubstTestCase(unittest.TestCase): return self.value # only use of this is currently commented out below - def function_foo(arg): - pass + #def function_foo(arg): + # pass target = [ MyNode("./foo/bar.exe"), MyNode("/bar/baz with spaces.obj"), @@ -207,7 +207,7 @@ class SubstTestCase(unittest.TestCase): 'S' : 'x y', 'LS' : ['x y'], 'L' : ['x', 'y'], - 'TS' : ('x y'), + 'TS' : ('x y',), 'T' : ('x', 'y'), 'CS' : cs, 'CL' : cl, diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index a7e247d..1711de1 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -40,7 +40,7 @@ default_java_version = '1.4' # a switch for which jdk versions to use the Scope state for smarter # anonymous inner class parsing. -scopeStateVersions = ('1.8') +scopeStateVersions = ('1.8',) # Glob patterns for use in finding where the JDK is. # These are pairs, *dir_glob used in the general case, @@ -87,8 +87,8 @@ if java_parsing: # any alphanumeric token surrounded by angle brackets (generics); # the multi-line comment begin and end tokens /* and */; # array declarations "[]". - _reToken = re.compile(r'(\n|\\\\|//|\\[\'"]|[\'"\{\}\;\.\(\)]|' + - r'\d*\.\d*|[A-Za-z_][\w\$\.]*|<[A-Za-z_]\w+>|' + + _reToken = re.compile(r'(\n|\\\\|//|\\[\'"]|[\'"{\};.()]|' + + r'\d*\.\d*|[A-Za-z_][\w$.]*|<[A-Za-z_]\w+>|' + r'/\*|\*/|\[\])') diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index bbccf61..386f445 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -50,7 +50,7 @@ elif LOGFILE: level=logging.DEBUG) debug = logging.getLogger(name=__name__).debug else: - debug = lambda x: None + def debug(x): return None # SCONS_CACHE_MSVC_CONFIG is public, and is documented. @@ -58,6 +58,7 @@ CONFIG_CACHE = os.environ.get('SCONS_CACHE_MSVC_CONFIG') if CONFIG_CACHE in ('1', 'true', 'True'): CONFIG_CACHE = os.path.join(os.path.expanduser('~'), '.scons_msvc_cache') + def read_script_env_cache(): """ fetch cached msvc env vars if requested, else return empty dict """ envcache = {} @@ -65,7 +66,7 @@ def read_script_env_cache(): try: with open(CONFIG_CACHE, 'r') as f: envcache = json.load(f) - #TODO can use more specific FileNotFoundError when py2 dropped + # TODO can use more specific FileNotFoundError when py2 dropped except IOError: # don't fail if no cache file, just proceed without it pass @@ -88,6 +89,7 @@ def write_script_env_cache(cache): _is_win64 = None + def is_win64(): """Return true if running on windows 64 bits. @@ -122,6 +124,7 @@ def is_win64(): def read_reg(value, hkroot=SCons.Util.HKEY_LOCAL_MACHINE): return SCons.Util.RegGetValue(hkroot, value)[0] + def has_reg(value): """Return True if the given key exists in HKEY_LOCAL_MACHINE, False otherwise.""" @@ -134,6 +137,7 @@ def has_reg(value): # Functions for fetching environment variable settings from batch files. + def normalize_env(env, keys, force=False): """Given a dictionary representing a shell environment, add the variables from os.environ needed for the processing of .bat files; the keys are @@ -172,11 +176,12 @@ def normalize_env(env, keys, force=False): if sys32_wbem_dir not in normenv['PATH']: normenv['PATH'] = normenv['PATH'] + os.pathsep + sys32_wbem_dir - debug("PATH: %s"%normenv['PATH']) + debug("PATH: %s" % normenv['PATH']) return normenv -def get_output(vcbat, args = None, env = None): + +def get_output(vcbat, args=None, env=None): """Parse the output of given bat file, with given args.""" if env is None: @@ -242,7 +247,13 @@ def get_output(vcbat, args = None, env = None): output = stdout.decode("mbcs") return output -KEEPLIST = ("INCLUDE", "LIB", "LIBPATH", "PATH", 'VSCMD_ARG_app_plat') + +KEEPLIST = ("INCLUDE", "LIB", "LIBPATH", "PATH", 'VSCMD_ARG_app_plat', + 'VCINSTALLDIR', # needed by clang -VS 2017 and newer + 'VCToolsInstallDir', # needed by clang - VS 2015 and older + ) + + def parse_output(output, keep=KEEPLIST): """ Parse output from running visual c++/studios vcvarsall.bat and running set diff --git a/src/engine/SCons/Tool/MSCommon/sdk.py b/src/engine/SCons/Tool/MSCommon/sdk.py index 281c1e3..9627f17 100644 --- a/src/engine/SCons/Tool/MSCommon/sdk.py +++ b/src/engine/SCons/Tool/MSCommon/sdk.py @@ -110,12 +110,12 @@ class SDKDefinition(object): """ Return the script to initialize the VC compiler installed by SDK """ - if (host_arch == 'amd64' and target_arch == 'x86'): + if host_arch == 'amd64' and target_arch == 'x86': # No cross tools needed compiling 32 bits on 64 bit machine host_arch=target_arch arch_string=target_arch - if (host_arch != target_arch): + if host_arch != target_arch: arch_string='%s_%s'%(host_arch,target_arch) debug("get_sdk_vc_script():arch_string:%s host_arch:%s target_arch:%s"%(arch_string, diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 86bdbe0..6f9bd12 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -509,7 +509,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version): debug('_check_cl_exists_in_vc_dir(): found ' + _CL_EXE_NAME + '!') return True - elif ver_num <= 14 and ver_num >= 8: + elif 14 >= 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 @@ -541,7 +541,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version): debug('_check_cl_exists_in_vc_dir(): found ' + _CL_EXE_NAME + '!') return True - elif ver_num < 8 and ver_num >= 6: + elif 8 > ver_num >= 6: # not sure about these versions so if a walk the VC dir (could be slow) for root, _, files in os.walk(vc_dir): if _CL_EXE_NAME in files: @@ -766,12 +766,12 @@ def msvc_find_valid_batch_script(env, version): vc_script=None continue if not vc_script and sdk_script: - debug('msvc_find_valid_batch_script() use_script 4: trying sdk script: %s'%(sdk_script)) + debug('msvc_find_valid_batch_script() use_script 4: trying sdk script: %s' % sdk_script) try: d = script_env(sdk_script) found = sdk_script except BatchFileExecutionError as e: - debug('msvc_find_valid_batch_script() use_script 5: failed running SDK script %s: Error:%s'%(repr(sdk_script),e)) + debug('msvc_find_valid_batch_script() use_script 5: failed running SDK script %s: Error:%s'%(repr(sdk_script), e)) continue elif not vc_script and not sdk_script: debug('msvc_find_valid_batch_script() use_script 6: Neither VC script nor SDK script found') diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index f255b21..14306ab 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -774,11 +774,11 @@ def EmitLibSymlinks(env, symlinks, libnode, **kw): for link, linktgt in symlinks: env.SideEffect(link, linktgt) - if (Verbose): + if Verbose: print("EmitLibSymlinks: SideEffect(%r,%r)" % (link.get_path(), linktgt.get_path())) clean_list = [x for x in nodes if x != linktgt] env.Clean(list(set([linktgt] + clean_targets)), clean_list) - if (Verbose): + if Verbose: print("EmitLibSymlinks: Clean(%r,%r)" % (linktgt.get_path(), [x.get_path() for x in clean_list])) @@ -792,18 +792,18 @@ def CreateLibSymlinks(env, symlinks): for link, linktgt in symlinks: linktgt = link.get_dir().rel_path(linktgt) link = link.get_path() - if (Verbose): + if Verbose: print("CreateLibSymlinks: preparing to add symlink %r -> %r" % (link, linktgt)) # Delete the (previously created) symlink if exists. Let only symlinks # to be deleted to prevent accidental deletion of source files... if env.fs.islink(link): env.fs.unlink(link) - if (Verbose): + if Verbose: print("CreateLibSymlinks: removed old symlink %r" % link) # If a file or directory exists with the same name as link, an OSError # will be thrown, which should be enough, I think. env.fs.symlink(linktgt, link) - if (Verbose): + if Verbose: print("CreateLibSymlinks: add symlink %r -> %r" % (link, linktgt)) return 0 diff --git a/src/engine/SCons/Tool/clang.py b/src/engine/SCons/Tool/clang.py index 081ab67..162daad 100644 --- a/src/engine/SCons/Tool/clang.py +++ b/src/engine/SCons/Tool/clang.py @@ -46,6 +46,7 @@ import sys import SCons.Util import SCons.Tool.cc from SCons.Tool.clangCommon import get_clang_install_dirs +from SCons.Tool.MSCommon import msvc_setup_env_once compilers = ['clang'] @@ -62,6 +63,10 @@ def generate(env): clang_bin_dir = os.path.dirname(clang) env.AppendENVPath('PATH', clang_bin_dir) + # Set-up ms tools paths + msvc_setup_env_once(env) + + env['CC'] = env.Detect(compilers) or 'clang' if env['PLATFORM'] in ['cygwin', 'win32']: env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') diff --git a/src/engine/SCons/Tool/clangCommon/__init__.py b/src/engine/SCons/Tool/clangCommon/__init__.py index 37efbf6..5501457 100644 --- a/src/engine/SCons/Tool/clangCommon/__init__.py +++ b/src/engine/SCons/Tool/clangCommon/__init__.py @@ -6,6 +6,7 @@ clang_win32_dirs = [ r'C:\Program Files\LLVM\bin', r'C:\cygwin64\bin', r'C:\msys64', + r'C:\msys64\mingw64\bin', r'C:\cygwin\bin', r'C:\msys', ] diff --git a/src/engine/SCons/Tool/clangxx.py b/src/engine/SCons/Tool/clangxx.py index a29cf79..b1dc6f3 100644 --- a/src/engine/SCons/Tool/clangxx.py +++ b/src/engine/SCons/Tool/clangxx.py @@ -47,6 +47,7 @@ import SCons.Tool import SCons.Util import SCons.Tool.cxx from SCons.Tool.clangCommon import get_clang_install_dirs +from SCons.Tool.MSCommon import msvc_setup_env_once compilers = ['clang++'] @@ -75,6 +76,10 @@ def generate(env): clangxx_bin_dir = os.path.dirname(clangxx) env.AppendENVPath('PATH', clangxx_bin_dir) + # Set-up ms tools paths + msvc_setup_env_once(env) + + # determine compiler version if env['CXX']: pipe = SCons.Action._subproc(env, [env['CXX'], '--version'], diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py index b93d916..c4fdfba 100644 --- a/src/engine/SCons/Tool/docbook/__init__.py +++ b/src/engine/SCons/Tool/docbook/__init__.py @@ -135,7 +135,7 @@ def __get_xml_text(root): """ Return the text for the given root node (xml.dom.minidom). """ txt = "" for e in root.childNodes: - if (e.nodeType == e.TEXT_NODE): + if e.nodeType == e.TEXT_NODE: txt += e.data return txt @@ -207,7 +207,7 @@ def _detect(env): if env.get('DOCBOOK_PREFER_XSLTPROC',''): prefer_xsltproc = True - if ((not has_libxml2 and not has_lxml) or (prefer_xsltproc)): + 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) __detect_cl_tool(env, 'DOCBOOK_XMLLINT', xmllint_com) diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py index e7b8cfa..de1375d 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py @@ -33,10 +33,10 @@ def adjustColumnWidths(ctx, nodeset): # Get the nominal table width varString = lookupVariable(tctxt, "nominal.table.width", None) - if varString == None: - nominalWidth = 6 * pixelsPerInch; + if varString is None: + nominalWidth = 6 * pixelsPerInch else: - nominalWidth = convertLength(varString); + nominalWidth = convertLength(varString) # Get the requested table width tableWidth = lookupVariable(tctxt, "table.width", "100%") @@ -58,13 +58,13 @@ def adjustColumnWidths(ctx, nodeset): colChildren = colgroup.children col = colChildren - while col != None: + while col is not None: if foStylesheet: width = col.prop("column-width") else: width = col.prop("width") - if width == None: + if width is None: width = "1*" relPart = 0.0 @@ -145,7 +145,7 @@ def adjustColumnWidths(ctx, nodeset): # Side-effect free? We don' need no steenkin' side-effect free! count = 0 col = colChildren - while col != None: + while col is not None: if foStylesheet: col.setProp("column-width", widths[count]) else: @@ -161,8 +161,8 @@ def convertLength(length): global pixelsPerInch global unitHash - m = re.search('([+-]?[\d\.]+)(\S+)', length) - if m != None and m.lastindex > 1: + m = re.search('([+-]?[\d.]+)(\S+)', length) + if m is not None and m.lastindex > 1: unit = pixelsPerInch if m.group(2) in unitHash: unit = unitHash[m.group(2)] @@ -204,7 +204,7 @@ def correctRoundingError(floatWidths): def lookupVariable(tctxt, varName, default): varString = tctxt.variableLookup(varName, None) - if varString == None: + if varString is None: return default # If it's a list, get the first element diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py index 77ca0de..d5529b8 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py @@ -36,7 +36,7 @@ try: outfile = None count = 4 - while (sys.argv[count]): + while sys.argv[count]: try: name, value = sys.argv[count].split("=", 2) if name in params: diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index c0a193b..dcb3581 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -168,7 +168,7 @@ def installShlibLinks(dest, source, env): Verbose = False symlinks = listShlibLinksToInstall(dest, source, env) if Verbose: - print('installShlibLinks: symlinks={:r}'.format(SCons.Tool.StringizeLibSymlinks(symlinks))) + print('installShlibLinks: symlinks={!r}'.format(SCons.Tool.StringizeLibSymlinks(symlinks))) if symlinks: SCons.Tool.CreateLibSymlinks(env, symlinks) return @@ -244,7 +244,7 @@ def add_versioned_targets_to_INSTALLED_FILES(target, source, env): Verbose = False _INSTALLED_FILES.extend(target) if Verbose: - print("add_versioned_targets_to_INSTALLED_FILES: target={:r}".format(list(map(str, target)))) + print("add_versioned_targets_to_INSTALLED_FILES: target={!r}".format(list(map(str, target)))) symlinks = listShlibLinksToInstall(target[0], source, env) if symlinks: SCons.Tool.EmitLibSymlinks(env, symlinks, target[0]) diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index 7550c34..5a101b4 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -318,7 +318,7 @@ def get_intel_compiler_top(version, abi): if not os.path.exists(os.path.join(top, "Bin", "icl.exe")) \ and not os.path.exists(os.path.join(top, "Bin", abi, "icl.exe")) \ and not os.path.exists(os.path.join(top, "Bin", archdir, "icl.exe")): - raise MissingDirError("Can't find Intel compiler in %s"%(top)) + raise MissingDirError("Can't find Intel compiler in %s" % top) elif is_mac or is_linux: def find_in_2008style_dir(version): # first dir is new (>=9.0) style, second is old (8.0) style. diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py index e75fa13..502aa60 100644 --- a/src/engine/SCons/Tool/jar.py +++ b/src/engine/SCons/Tool/jar.py @@ -158,7 +158,7 @@ def Jar(env, target = None, source = [], *args, **kw): # files. def dir_to_class(s): dir_targets = env.JavaClassDir(source = s, *args, **kw) - if(dir_targets == []): + if dir_targets == []: # no classes files could be built from the source dir # so pass the dir as is. return [env.fs.Dir(s)] diff --git a/src/engine/SCons/Tool/javah.py b/src/engine/SCons/Tool/javah.py index 80f8a6b..fbfcbe2 100644 --- a/src/engine/SCons/Tool/javah.py +++ b/src/engine/SCons/Tool/javah.py @@ -115,7 +115,7 @@ def getJavaHClassPath(env,target, source, for_signature): path = "${SOURCE.attributes.java_classdir}" if 'JAVACLASSPATH' in env and env['JAVACLASSPATH']: path = SCons.Util.AppendPath(path, env['JAVACLASSPATH']) - return "-classpath %s" % (path) + return "-classpath %s" % path def generate(env): """Add Builders and construction variables for javah to an Environment.""" diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index 0fa6454..fc5f009 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -220,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 @@ -234,7 +234,7 @@ def embedManifestExeCheck(target, source, env): if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + '.manifest' if os.path.exists(manifestSrc): - ret = (embedManifestExeAction) ([target[0]],None,env) + ret = embedManifestExeAction([target[0]], None, env) if ret: raise SCons.Errors.UserError("Unable to embed manifest into %s" % (target[0])) return ret diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 7dca9e1..929e558 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -172,9 +172,9 @@ def makeHierarchy(sources): return hierarchy class _UserGenerator(object): - ''' + """ Base class for .dsp.user file generator - ''' + """ # Default instance values. # Ok ... a bit defensive, but it does not seem reasonable to crash the # build for a workspace user file. :-) @@ -980,7 +980,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): if SCons.Util.is_Dict(value): self.file.write('\t\t\t<Filter\n' '\t\t\t\tName="%s"\n' - '\t\t\t\tFilter="">\n' % (key)) + '\t\t\t\tFilter="">\n' % key) self.printSources(value, commonprefix) self.file.write('\t\t\t</Filter>\n') @@ -992,7 +992,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): file = os.path.normpath(file) self.file.write('\t\t\t<File\n' '\t\t\t\tRelativePath="%s">\n' - '\t\t\t</File>\n' % (file)) + '\t\t\t</File>\n' % file) def PrintSourceFiles(self): categories = {'Source Files': 'cpp;c;cxx;l;y;def;odl;idl;hpj;bat', @@ -2047,17 +2047,17 @@ def generate(env): (version_num, suite) = (7.0, None) # guess at a default if 'MSVS' not in env: env['MSVS'] = {} - if (version_num < 7.0): + if version_num < 7.0: env['MSVS']['PROJECTSUFFIX'] = '.dsp' env['MSVS']['SOLUTIONSUFFIX'] = '.dsw' - elif (version_num < 10.0): + elif version_num < 10.0: env['MSVS']['PROJECTSUFFIX'] = '.vcproj' env['MSVS']['SOLUTIONSUFFIX'] = '.sln' else: env['MSVS']['PROJECTSUFFIX'] = '.vcxproj' env['MSVS']['SOLUTIONSUFFIX'] = '.sln' - if (version_num >= 10.0): + if version_num >= 10.0: env['MSVSENCODING'] = 'utf-8' else: env['MSVSENCODING'] = 'Windows-1252' diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py index 34e4f0f..9f28b72 100644 --- a/src/engine/SCons/Tool/packaging/msi.py +++ b/src/engine/SCons/Tool/packaging/msi.py @@ -182,7 +182,7 @@ def generate_guids(root): def string_wxsfile(target, source, env): - return "building WiX file %s"%( target[0].path ) + return "building WiX file %s" % target[0].path def build_wxsfile(target, source, env): """ Compiles a .wxs file from the keywords given in env['msi_spec'] and diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index 5cf7bca..fa18cf9 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -204,7 +204,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None # with LaTeXAction and from the pdflatex.py with PDFLaTeXAction # set this up now for the case where the user requests a different extension # for the target filename - if (XXXLaTeXAction == LaTeXAction): + if XXXLaTeXAction == LaTeXAction: callerSuffix = ".dvi" else: callerSuffix = env['PDFSUFFIX'] @@ -283,7 +283,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None count = 0 - while (must_rerun_latex and count < int(env.subst('$LATEXRETRIES'))) : + while must_rerun_latex and count < int(env.subst('$LATEXRETRIES')): result = XXXLaTeXAction(target, source, env) if result != 0: return result @@ -461,7 +461,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None if Verbose: print("rerun Latex due to undefined references or citations") - if (count >= int(env.subst('$LATEXRETRIES')) and must_rerun_latex): + if count >= int(env.subst('$LATEXRETRIES')) and must_rerun_latex: print("reached max number of retries on Latex ,",int(env.subst('$LATEXRETRIES'))) # end of while loop @@ -861,7 +861,7 @@ def generate_darwin(env): environ = {} env['ENV'] = environ - if (platform.system() == 'Darwin'): + if platform.system() == 'Darwin': try: ospath = env['ENV']['PATHOSX'] except: diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py index 936924b..11ca32f 100644 --- a/src/engine/SCons/Tool/xgettext.py +++ b/src/engine/SCons/Tool/xgettext.py @@ -133,7 +133,7 @@ def _update_pot_file(target, source, env): re_cdate = re.compile(r'^"POT-Creation-Date: .*"$[\r\n]?', re.M) old_content_nocdate = re.sub(re_cdate, "", old_content) new_content_nocdate = re.sub(re_cdate, "", new_content) - if (old_content_nocdate == new_content_nocdate): + if old_content_nocdate == new_content_nocdate: # Messages are up-to-date needs_update = False explain = "messages in file found to be up-to-date" diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 8519a98..4b4ead5 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -312,18 +312,21 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): '\n') sys.stdout.write(legend) - tags = ['['] - tags.append(' E'[IDX(root.exists())]) - tags.append(' R'[IDX(root.rexists() and not root.exists())]) - tags.append(' BbB'[[0,1][IDX(root.has_explicit_builder())] + - [0,2][IDX(root.has_builder())]]) - tags.append(' S'[IDX(root.side_effect)]) - tags.append(' P'[IDX(root.precious)]) - tags.append(' A'[IDX(root.always_build)]) - tags.append(' C'[IDX(root.is_up_to_date())]) - tags.append(' N'[IDX(root.noclean)]) - tags.append(' H'[IDX(root.nocache)]) - tags.append(']') + tags = [ + '[', + ' E'[IDX(root.exists())], + ' R'[IDX(root.rexists() and not root.exists())], + ' BbB'[ + [0, 1][IDX(root.has_explicit_builder())] + + [0, 2][IDX(root.has_builder())] + ], + ' S'[IDX(root.side_effect)], ' P'[IDX(root.precious)], + ' A'[IDX(root.always_build)], + ' C'[IDX(root.is_up_to_date())], + ' N'[IDX(root.noclean)], + ' H'[IDX(root.nocache)], + ']' + ] else: tags = [] @@ -352,7 +355,6 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): margin.pop() - # Functions for deciding if things are like various types, mainly to # handle UserDict, UserList and UserString like their underlying types. # @@ -390,7 +392,7 @@ except NameError: try: BaseStringTypes = (str, unicode) except NameError: - BaseStringTypes = (str) + BaseStringTypes = str def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes): return isinstance(obj, DictTypes) diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 0017844..7f6508d 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -451,11 +451,11 @@ class UtilTestCase(unittest.TestCase): assert get_environment_var("${BAR}") == "BAR", get_environment_var("${BAR}") assert get_environment_var("$FOO_BAR1234") == "FOO_BAR1234", get_environment_var("$FOO_BAR1234") assert get_environment_var("${BAR_FOO1234}") == "BAR_FOO1234", get_environment_var("${BAR_FOO1234}") - assert get_environment_var("${BAR}FOO") == None, get_environment_var("${BAR}FOO") - assert get_environment_var("$BAR ") == None, get_environment_var("$BAR ") - assert get_environment_var("FOO$BAR") == None, get_environment_var("FOO$BAR") - assert get_environment_var("$FOO[0]") == None, get_environment_var("$FOO[0]") - assert get_environment_var("${some('complex expression')}") == None, get_environment_var( + assert get_environment_var("${BAR}FOO") is None, get_environment_var("${BAR}FOO") + assert get_environment_var("$BAR ") is None, get_environment_var("$BAR ") + assert get_environment_var("FOO$BAR") is None, get_environment_var("FOO$BAR") + assert get_environment_var("$FOO[0]") is None, get_environment_var("$FOO[0]") + assert get_environment_var("${some('complex expression')}") is None, get_environment_var( "${some('complex expression')}") def test_Proxy(self): diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 14bd93d..55254b3 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -131,9 +131,10 @@ class dblite(object): # Note how we catch KeyErrors too here, which might happen # when we don't have cPickle available (default pickle # throws it). - if (ignore_corrupt_dbfiles == 0): raise - if (ignore_corrupt_dbfiles == 1): + if ignore_corrupt_dbfiles: corruption_warning(self._file_name) + else: + raise def close(self): if self._needs_sync: @@ -166,13 +167,13 @@ class dblite(object): except OSError: pass self._needs_sync = 00000 - if (keep_all_files): + if keep_all_files: self._shutil_copyfile( self._file_name, self._file_name + "_" + str(int(self._time_time()))) def _check_writable(self): - if (self._flag == "r"): + if self._flag == "r": raise IOError("Read-only database: %s" % self._file_name) def __getitem__(self, key): @@ -180,9 +181,9 @@ class dblite(object): def __setitem__(self, key, value): self._check_writable() - if (not is_string(key)): + if not is_string(key): raise TypeError("key `%s' must be a string but is %s" % (key, type(key))) - if (not is_bytes(value)): + if not is_bytes(value): raise TypeError("value `%s' must be a bytes but is %s" % (value, type(value))) self._dict[key] = value self._needs_sync = 0o001 @@ -280,7 +281,7 @@ def _exercise(): raise RuntimeError("IOError expected.") -if (__name__ == "__main__"): +if __name__ == "__main__": _exercise() # Local Variables: |