diff options
-rw-r--r-- | QMTest/TestSConsMSVS.py | 4 | ||||
-rw-r--r-- | doc/man/scons.xml | 27 | ||||
-rw-r--r-- | src/CHANGES.txt | 9 | ||||
-rw-r--r-- | src/engine/SCons/Script/SConscript.py | 9 | ||||
-rw-r--r-- | src/engine/SCons/Tool/__init__.py | 12 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/Variables/VariablesTests.py | 27 | ||||
-rw-r--r-- | src/engine/SCons/Variables/__init__.py | 7 | ||||
-rw-r--r-- | test/Deprecated/Options/Options.py | 4 | ||||
-rw-r--r-- | test/Java/JAR.py | 62 | ||||
-rw-r--r-- | test/Variables/Variables.py | 4 |
11 files changed, 149 insertions, 27 deletions
diff --git a/QMTest/TestSConsMSVS.py b/QMTest/TestSConsMSVS.py index 19ce747..1e879d9 100644 --- a/QMTest/TestSConsMSVS.py +++ b/QMTest/TestSConsMSVS.py @@ -1039,8 +1039,8 @@ class TestSConsMSVS(TestSCons): input = """\ import SCons import SCons.Tool.MSCommon -print("self.scons_version =", repr(SCons.__%s__)) -print("self._msvs_versions =", str(SCons.Tool.MSCommon.query_versions())) +print("self.scons_version =%%s"%%repr(SCons.__%s__)) +print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions())) """ % 'version' self.run(arguments = '-n -q -Q -f -', stdin = input) diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 3268860..1f38b5d 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -853,14 +853,18 @@ and ultimately removed.</para> <varlistentry> <term>--debug=time</term> <listitem> -<para>Prints various time profiling information: -the time spent executing each individual build command; -the total build time (time SCons ran from beginning to end); -the total time spent reading and executing SConscript files; -the total time spent SCons itself spend running -(that is, not counting reading and executing SConscript files); -and both the total time spent executing all build commands -and the elapsed wall-clock time spent executing those build commands. +<para>Prints various time profiling information:</para> +<itemizedlist> +<listitem>The time spent executing each individual build command</listitem> +<listitem>The total build time (time SCons ran from beginning to end)</listitem> +<listitem>The total time spent reading and executing SConscript files</listitem> +<listitem>The total time spent SCons itself spend running +(that is, not counting reading and executing SConscript files)</listitem> +<listitem>The total time spent executing all build commands</listitem> +<listitem>The elapsed wall-clock time spent executing those build commands</listitem> +<listitem>The time spent processing each file passed to the <emphasis>SConscript()</emphasis> function</listitem> +</itemizedlist> +<para> (When <command>scons</command> is executed without the @@ -884,7 +888,8 @@ be significantly smaller than the total time spent executing all the build commands, since multiple build commands and intervening SCons processing -should take place in parallel.)</para> +should take place in parallel.) +</para> </listitem> </varlistentry> @@ -4056,7 +4061,9 @@ and return -1, 0 or 1 (like the standard Python <emphasis>cmp</emphasis> -function).</para> +function). + +Optionally a Boolean value of True for <emphasis>sort</emphasis> will cause a standard alphabetical sort to be performed</para> <literallayout class="monospaced"> Help(vars.GenerateHelpText(env)) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index c9faf86..5df9c4f 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -11,10 +11,19 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Whatever John Doe did. + From Daniel Moody: + - Updated the Jar Builder tool in Tool/__init.py so that is doesn't force class files as + sources, allowing directories to be passed, which was causing test/Java/JAR.py to fail. + From William Deegan: - Fix issue where code in utility routine to_String_for_subst() had code whose result was never properly returned. (Found by: James Rinkevich https://pairlist4.pair.net/pipermail/scons-users/2017-October/006358.html ) + - Fixed Variables.GenerateHelpText() to now use the sort parameter. Due to incorrect 2to3 fixer changes + 8 years ago it was being used as a boolean parameter. Now you can specify sort to be a callable, or boolean + value. (True = normal sort). Manpage also updated. + - Fixed Tool loading logic from exploding sys.path with many site_scons/site_tools prepended on py3. + - Added additional output with time to process each SConscript file when using --debug=time. From Thomas Berg: - Fixed a regression in scons-3.0.0 where "from __future__ import print_function" was imposed diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 8fea9c4..db6552c 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -44,12 +44,15 @@ import SCons.Script.Main import SCons.Tool import SCons.Util +from . import Main + import collections import os import os.path import re import sys import traceback +import time class SConscriptReturn(Exception): pass @@ -247,11 +250,17 @@ def _SConscript(fs, *files, **kw): try: try: # _file_ = SCons.Util.to_str(_file_) + if Main.print_time: + time1 = time.time() exec(compile(_file_.read(), _file_.name, 'exec'), call_stack[-1].globals) except SConscriptReturn: pass finally: + if Main.print_time: + time2 = time.time() + print('SConscript:%s took %0.3f ms' % (f.get_abspath(), (time2 - time1) * 1000.0)) + if old_file is not None: call_stack[-1].globals.update({__file__:old_file}) else: diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 6ddb9fc..a4e44a0 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -222,8 +222,10 @@ class Tool(object): # Don't reload a tool we already loaded. sys_modules_value = sys.modules.get(found_name,False) + + found_module = None if sys_modules_value and sys_modules_value.__file__ == spec.origin: - return sys.modules[found_name] + found_module = sys.modules[found_name] else: # Not sure what to do in the case that there already # exists sys.modules[self.name] but the source file is @@ -235,7 +237,11 @@ class Tool(object): # If we found it in SCons.Tool, then add it to the module setattr(SCons.Tool, self.name, module) - return module + found_module = module + + if found_module is not None: + sys.path = oldpythonpath + return found_module sys.path = oldpythonpath @@ -914,8 +920,6 @@ def CreateJarBuilder(env): jar_com = SCons.Action.Action('$JARCOM', '$JARCOMSTR') java_jar = SCons.Builder.Builder(action = jar_com, suffix = '$JARSUFFIX', - src_suffix = '$JAVACLASSSUFFIX', - src_builder = 'JavaClassFile', source_factory = fs.Entry) env['BUILDERS']['Jar'] = java_jar return java_jar diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 11bcf2e..7ed9706 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1619,6 +1619,17 @@ def to_str (s): return s return str (s, 'utf-8') + + +# No cmp in py3, so we'll define it. +def cmp(a, b): + """ + Define cmp because it's no longer available in python3 + Works under python 2 as well + """ + return (a > b) - (a < b) + + # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py index 7ee66ca..175a14b 100644 --- a/src/engine/SCons/Variables/VariablesTests.py +++ b/src/engine/SCons/Variables/VariablesTests.py @@ -32,6 +32,7 @@ import TestUnit import SCons.Variables import SCons.Subst import SCons.Warnings +from SCons.Util import cmp class Environment(object): @@ -49,12 +50,6 @@ class Environment(object): return key in self.dict -def cmp(a, b): - """ - Define cmp because it's no longer available in python3 - Works under python 2 as well - """ - return (a > b) - (a < b) def check(key, value, env): @@ -492,9 +487,29 @@ B: b - alpha test default: 42 actual: 54 """ + + expectBackwards = """ +B: b - alpha test + default: 42 + actual: 54 + +ANSWER: THE answer to THE question + default: 42 + actual: 54 + +A: a - alpha test + default: 42 + actual: 54 +""" text = opts.GenerateHelpText(env, sort=cmp) assert text == expectAlpha, text + textBool = opts.GenerateHelpText(env, sort=True) + assert text == expectAlpha, text + + textBackwards = opts.GenerateHelpText(env, sort=lambda x, y: cmp(y, x)) + assert textBackwards == expectBackwards, "Expected:\n%s\nGot:\n%s\n"%(textBackwards, expectBackwards) + def test_FormatVariableHelpText(self): """Test generating custom format help text""" opts = SCons.Variables.Variables() diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index 5b20b30..6ad40ed 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -30,6 +30,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path import sys +from functools import cmp_to_key import SCons.Environment import SCons.Errors @@ -287,9 +288,13 @@ 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 + or a boolean to indicate if it should be sorted. """ - if sort: + if callable(sort): + options = sorted(self.options, key=cmp_to_key(lambda x,y: sort(x.key,y.key))) + elif sort is True: options = sorted(self.options, key=lambda x: x.key) else: options = self.options diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index e415739..f196b79 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -334,8 +334,8 @@ opts.Add('UNSPECIFIED', env = Environment(options=opts) -def compare(a,b): - return a < b +def compare(a, b): + return (a > b) - (a < b) Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=compare)) diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 476bfcd..08b7ab1 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -239,6 +239,68 @@ test.must_exist('bar.jar') test.up_to_date(arguments = '.') +####### +# test java source files as source to Jar builder + +# make some directories to test in +test.subdir('testdir2', + ['testdir2', 'com'], + ['testdir2', 'com', 'javasource']) + +# simple SConstruct which passes the 3 .java as source +test.write(['testdir2', 'SConstruct'], """ +foo = Environment() +foo.Jar(target = 'foo', source = [ + 'com/javasource/JavaFile1.java', + 'com/javasource/JavaFile2.java', + 'com/javasource/JavaFile3.java' +]) +""") + +test.write(['testdir2', 'com', 'javasource', 'JavaFile1.java'], """\ +package com.javasource; + +public class JavaFile1 +{ + public static void main(String[] args) + { + + } +} +""") + +test.write(['testdir2', 'com', 'javasource', 'JavaFile2.java'], """\ +package com.javasource; + +public class JavaFile2 +{ + public static void main(String[] args) + { + + } +} +""") + +test.write(['testdir2', 'com', 'javasource', 'JavaFile3.java'], """\ +package com.javasource; + +public class JavaFile3 +{ + public static void main(String[] args) + { + + } +} +""") + +test.run(chdir='testdir2') + +if("jar cf foo.jar com/javasource/JavaFile1.java com/javasource/JavaFile2.java " + + "com/javasource/JavaFile3.java" not in test.stdout()): + test.fail_test() + +test.must_exist(['testdir2','foo.jar']) + test.pass_test() # Local Variables: diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index 17b33af..0fe3745 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -320,8 +320,8 @@ opts.Add('UNSPECIFIED', env = Environment(variables=opts) -def compare(a,b): - return a < b +def compare(a, b): + return (a > b) - (a < b) Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=compare)) |