From 2e2ba90baa24a9919000edbf688c306e2c428fb6 Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Fri, 1 Nov 2019 08:32:23 +0100 Subject: Fix incorrect testing assumptions for Solaris --- src/engine/SCons/ActionTests.py | 4 ---- src/engine/SCons/Tool/MSCommon/vc.py | 9 ++++++++- test/Clang/clang_shared_library.py | 2 +- test/Clang/clangxx_shared_library.py | 3 +++ test/Errors/execute-a-directory.py | 6 +----- test/Errors/non-executable-file.py | 6 +----- test/LINK/VersionedLib.py | 12 ++++++------ test/SWIG/recursive-includes-cpp.py | 2 ++ testing/framework/TestCommon.py | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 3054368..3303750 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -1208,10 +1208,6 @@ class CommandActionTestCase(unittest.TestCase): # Newer cygwin seems to return 126 for following expect_nonexecutable_file = 126 expect_nonexecutable_dir = 127 - elif sys.platform.find('sunos') != -1: - expect_nonexistent = 1 - expect_nonexecutable_file = 1 - expect_nonexecutable_dir = 1 else: expect_nonexistent = 127 expect_nonexecutable_file = 126 diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 4f6048d..86bdbe0 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -161,11 +161,18 @@ def get_host_target(env): if not host_platform: host_platform = platform.machine() + # Solaris returns i86pc for both 32 and 64 bit architectures + if host_platform == "i86pc": + if platform.architecture()[0] == "64bit": + host_platform = "amd64" + else: + host_platform = "x86" + # Retain user requested TARGET_ARCH req_target_platform = env.get('TARGET_ARCH') debug('get_host_target() req_target_platform:%s'%req_target_platform) - if req_target_platform: + if req_target_platform: # If user requested a specific platform then only try that one. target_platform = req_target_platform else: diff --git a/test/Clang/clang_shared_library.py b/test/Clang/clang_shared_library.py index 9af3770..83fa4dd 100644 --- a/test/Clang/clang_shared_library.py +++ b/test/Clang/clang_shared_library.py @@ -35,7 +35,7 @@ if not test.where_is('clang'): base = Base() platform = base['PLATFORM'] -if platform == 'posix': +if platform in ['posix', 'sunos']: filename_options = ['foo.os'] libraryname = 'libfoo.so' elif platform == 'darwin': diff --git a/test/Clang/clangxx_shared_library.py b/test/Clang/clangxx_shared_library.py index 6240299..a16be6b 100644 --- a/test/Clang/clangxx_shared_library.py +++ b/test/Clang/clangxx_shared_library.py @@ -44,6 +44,9 @@ elif platform == 'darwin': elif platform == 'win32': filename_options = ['foo.obj','foo.os'] libraryname = 'foo.dll' +elif platform == 'sunos': + filename_options = ['foo.pic.o'] + libraryname = 'libfoo.so' else: test.fail_test() diff --git a/test/Errors/execute-a-directory.py b/test/Errors/execute-a-directory.py index 95fa7b6..8b6d13b 100644 --- a/test/Errors/execute-a-directory.py +++ b/test/Errors/execute-a-directory.py @@ -65,7 +65,7 @@ scons: \\*\\*\\* \\[%s\\] Error 1 """ cannot_execute = """\ -(sh: )*.+: cannot execute +(sh: )*.+: cannot execute( \\[Is a directory\\])? scons: \\*\\*\\* \\[%s\\] Error %s """ @@ -93,10 +93,6 @@ if os.name == 'nt': konnte_nicht_gefunden_werden % ('f3', 1), unspecified % 'f3' ] -elif sys.platform.find('sunos') != -1: - errs = [ - cannot_execute % ('f3', 1), - ] else: errs = [ cannot_execute % ('f3', 126), diff --git a/test/Errors/non-executable-file.py b/test/Errors/non-executable-file.py index 0e00c77..64c75c6 100644 --- a/test/Errors/non-executable-file.py +++ b/test/Errors/non-executable-file.py @@ -54,7 +54,7 @@ scons: \\*\\*\\* \\[%s\\] Error 1 """ cannot_execute = """\ -(sh: )*.+: cannot execute +(sh: )*.+: cannot execute( \\[Permission denied\\])? scons: \\*\\*\\* \\[%s\\] Error %s """ @@ -88,10 +88,6 @@ if os.name == 'nt': konnte_nicht_gefunden_werden % ('f1', 1), unspecified % 'f1' ] -elif sys.platform.find('sunos') != -1: - errs = [ - cannot_execute % ('f1', 1), - ] else: errs = [ cannot_execute % ('f1', 126), diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py index 468e3e5..64f9b90 100644 --- a/test/LINK/VersionedLib.py +++ b/test/LINK/VersionedLib.py @@ -138,37 +138,37 @@ elif 'sunlink' in tool_list: test_plan = [ { 'libversion' : '2', - 'files' : [ 'libtest.so', 'libtest.so.2', 'so_test.os' ], + 'files' : [ 'libtest.so', 'libtest.so.2', 'test.pic.o' ], 'instfiles' : [ 'libtest.so', 'libtest.so.2' ], 'symlinks' : [ ('libtest.so', 'libtest.so.2') ], }, { 'libversion' : '2.5', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'so_test.os' ], + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.pic.o' ], 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ], 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ], }, { 'libversion' : '2.5.4', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'so_test.os' ], + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.pic.o' ], 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ], 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ], }, { 'libversion' : '2.5.4.7.8', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'so_test.os' ], + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.pic.o' ], 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ], 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ], }, { 'libversion' : 'aabf114f', - 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'so_test.os' ], + 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.pic.o' ], 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ], 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ], }, { 'libversion' : '2.dfffa11', - 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'so_test.os' ], + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.pic.o' ], 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ], 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ], }, diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 3999cc3..dcd9d05 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -115,6 +115,8 @@ env.SharedLibrary( if sys.platform == 'win32': object_suffix = ".obj" +elif sys.platform == 'sunos5': + object_suffix = ".pic.o" else: object_suffix = ".os" diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index ca4a147..8e6cc8e 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -165,8 +165,8 @@ elif sys.platform.find('darwin') != -1: elif sys.platform.find('sunos') != -1: exe_suffix = '' obj_suffix = '.o' - shobj_suffix = '.o' - shobj_prefix = 'so_' + shobj_suffix = '.pic.o' + shobj_prefix = '' lib_prefix = 'lib' lib_suffix = '.a' dll_prefix = 'lib' -- cgit v0.12 From 83d5fe4d674aefd8bdd8b2eebd966173fef4911b Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 13 Nov 2019 07:42:02 -0700 Subject: Document that AddOpt has limitations [ci skip] Manpage describes that using spaces between AddOption'd option and its argument is undefined. Use Guide goes into more detail, including workarounds. :: these are not a solution, but do at least reduce the surprise factor. (multiple github issues) Fix tag mismatch in depends.xml introduced by a previous deletion. Signed-off-by: Mats Wichmann --- doc/user/command-line.xml | 34 ++++++++++++++++++++++++++++++++++ doc/user/depends.xml | 1 + src/engine/SCons/Script/Main.xml | 15 +++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/doc/user/command-line.xml b/doc/user/command-line.xml index d129d2e..8b8949a 100644 --- a/doc/user/command-line.xml +++ b/doc/user/command-line.xml @@ -608,6 +608,7 @@ foo.in of the optparse.OptionParser. + Once you have added a custom command-line option with the &AddOption; function, the value of the option (if any) is immediately available @@ -678,6 +679,39 @@ foo.in scons -Q -n --prefix=/tmp/install + + + Long options and option-arguments separated by a space, rather than + by =, are ambiguous. + While --input=ARG + has a clear meaning, for --input ARG it is not + possible to tell without instructions whether + ARG is an argument belonging to the + input option or a positional argument + (that is, an argument that does not start with a single or double dash). + In scons, positional arguments are treated as either + command-line build options or command-line targets + (see the immediately following sections for details), + which are made available for use in the &SConscript;. + This means they have to be collected before &SConscript; processing + takes place. Since &AddOption; calls, which provide + the necessary processing instructions, happen in the &SConscript;, + scons cannot resolve the ambiguity in time + for options added this way, and unexpected things will happen. + As a result, this usage style should be avoided when invoking + scons. For single-argument + options, use the --input=ARG style on the + command line. For multiple-argument options + (nargs greater than one), + set nargs to one in + &AddOption; and combine the option-arguments into one word + with a separator, and parse the result in your own code. + See the built-in --debug option, which + allows specifying multiple arguments as a single comma-separated + word, for an example of such usage. + + + diff --git a/doc/user/depends.xml b/doc/user/depends.xml index 5a78eb5..cd5094a 100644 --- a/doc/user/depends.xml +++ b/doc/user/depends.xml @@ -764,6 +764,7 @@ int main() { printf("Hello, world!\n"); } encounter them in older &SConscript; files. +
Implicit Dependencies: The &cv-CPPPATH; Construction Variable diff --git a/src/engine/SCons/Script/Main.xml b/src/engine/SCons/Script/Main.xml index e95afbc..13ad336 100644 --- a/src/engine/SCons/Script/Main.xml +++ b/src/engine/SCons/Script/Main.xml @@ -133,6 +133,21 @@ AddOption('--prefix', help='installation prefix') env = Environment(PREFIX = GetOption('prefix')) + + + +While &AddOption; behaves like +optparse.add_option, +the behavior of options added by &AddOption; +which take arguments is underfined in +scons if a space +(rather than = sign) is used as +the separator on the command line when +the option is invoked. +Such usage should be avoided. + + + -- cgit v0.12 From 0be4c7daa8d983be0faa53907f52aee9217f3704 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 15 Nov 2019 12:30:45 -0700 Subject: [PR 3475] add repeated-args suggestion for AddOpt [ci skip] Signed-off-by: Mats Wichmann --- doc/user/command-line.xml | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/doc/user/command-line.xml b/doc/user/command-line.xml index 8b8949a..f8f6a66 100644 --- a/doc/user/command-line.xml +++ b/doc/user/command-line.xml @@ -2,7 +2,7 @@ %scons; - + %builders-mod; @@ -89,7 +89,7 @@ all of the command-line variable settings, the ability to apply command-line variable settings to construction environments, - and functions for configuring + and functions for configuring specific types of variables (Boolean values, path names, etc.) with automatic validation of the user's specified values. @@ -681,36 +681,43 @@ foo.in - Long options and option-arguments separated by a space, rather than + Long options and option-arguments separated by space, rather than by =, are ambiguous. While --input=ARG has a clear meaning, for --input ARG it is not possible to tell without instructions whether ARG is an argument belonging to the - input option or a positional argument - (that is, an argument that does not start with a single or double dash). - In scons, positional arguments are treated as either + input option or a positional argument. + scons treats positional arguments as either command-line build options or command-line targets (see the immediately following sections for details), which are made available for use in the &SConscript;. - This means they have to be collected before &SConscript; processing + Thus, they must be collected before &SConscript; processing takes place. Since &AddOption; calls, which provide - the necessary processing instructions, happen in the &SConscript;, - scons cannot resolve the ambiguity in time - for options added this way, and unexpected things will happen. + the processing instructions to resolve the ambiguity, + happen in the &SConscript;, + scons does not know in time + for options added this way, and unexpected things will happen, + such as option-arguments assigned as targets and/or exceptions + due to missing option-arguments. + + As a result, this usage style should be avoided when invoking scons. For single-argument - options, use the --input=ARG style on the - command line. For multiple-argument options + options, use the --input=ARG form on the + command line. For multiple-argument options (nargs greater than one), set nargs to one in - &AddOption; and combine the option-arguments into one word - with a separator, and parse the result in your own code. - See the built-in --debug option, which + &AddOption; calls and either: combine the option-arguments into one word + with a separator, and parse the result in your own code + (see the built-in --debug option, which allows specifying multiple arguments as a single comma-separated - word, for an example of such usage. + word, for an example of such usage); or allow the option to + be specified multiple times by setting + action='append'. Both methods can be + supported at the same time. - +
@@ -1166,12 +1173,12 @@ vars = Variables('custom.py', ARGUMENTS) - + where values in the option file &custom_py; get overwritten by the ones specified on the command line. - +
-- cgit v0.12 From 24b5dfae51cbb67b9274899ff42a5f9f8edd87f2 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 15 Nov 2019 13:10:56 -0700 Subject: [PR 3475] fix another xml tag error that was lurking [ci skip] docs validate again after this Signed-off-by: Mats Wichmann --- doc/man/scons.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/man/scons.xml b/doc/man/scons.xml index ae54e2e..7ee3453 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -2278,10 +2278,10 @@ env.SomeTool(targets, sources) Builder Methods -You tell scons what to build +You tell scons what to build by calling Builders, functions which know to take a particular action when given files of a particular type -to produce a particular result type. scons +to produce a particular result type. scons defines a number of builders, and you can also write your own. Builders are attached to a &consenv; as methods, and the available builder methods are listed as -- cgit v0.12 From 8822795f5e37be2e0cd694523217693fac680d55 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 15 Nov 2019 14:20:14 -0700 Subject: [PR 3475] review edit: space -> whitespace [ci skip] Signed-off-by: Mats Wichmann --- doc/user/command-line.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/user/command-line.xml b/doc/user/command-line.xml index f8f6a66..62d0558 100644 --- a/doc/user/command-line.xml +++ b/doc/user/command-line.xml @@ -681,8 +681,8 @@ foo.in - Long options and option-arguments separated by space, rather than - by =, are ambiguous. + Long options and option-arguments separated by whitespace, + rather than by =, are ambiguous. While --input=ARG has a clear meaning, for --input ARG it is not possible to tell without instructions whether -- cgit v0.12 From c3f7bb42338d5008ff908c2f4ee85c07de9fffcb Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 16 Nov 2019 07:22:14 -0700 Subject: [PR 3475] update docs/generated [ci skip] There's debated about whether the generated should be checked in at all; without an answer to that, they've fallen far enough out of sync that it becomes harder to use "git diff" as a spot-check that nothing strange is happening due to any given doc change. This should resync them to current. Signed-off-by: Mats Wichmann --- doc/generated/builders.gen | 30 +++- doc/generated/functions.gen | 376 +++++++++------------------------------ doc/generated/functions.mod | 8 - doc/generated/variables.gen | 120 ++++++++----- doc/generated/variables.mod | 2 + src/engine/SCons/Script/Main.xml | 4 +- 6 files changed, 183 insertions(+), 357 deletions(-) diff --git a/doc/generated/builders.gen b/doc/generated/builders.gen index 54c7aaa..59d2dca 100644 --- a/doc/generated/builders.gen +++ b/doc/generated/builders.gen @@ -48,11 +48,15 @@ env.CFile(target = 'bar', source = 'bar.y') -The Command "Builder" is actually implemented -as a function that looks like a Builder, -but actually takes an additional argument of the action -from which the Builder should be made. -See the Command function description +The Command "Builder" is actually +a function that looks like a Builder, +but takes a required third argument, which is the +action to take to construct the target +from the source, used for "one-off" builds +where a full builder is not needed. +Thus it does not follow the builder +calling rules described at the start of this section. +See instead the Command function description for the calling syntax and details. @@ -465,6 +469,22 @@ a builder. env.Install('/usr/local/bin', source = ['foo', 'bar']) + + +If the command line +option is given, the target directory will be prefixed +by the directory path specified. +This is useful to test installs without installing to +a "live" location in the system. + + + +See also FindInstalledFiles. +For more thoughts on installation, see the User Guide +(particularly the section on Command-Line Targets +and the chapters on Installing Files and on Alias Targets). + + diff --git a/doc/generated/functions.gen b/doc/generated/functions.gen index e55799c..60e733f 100644 --- a/doc/generated/functions.gen +++ b/doc/generated/functions.gen @@ -25,8 +25,8 @@ Creates an Action object for the specified action. -See the section "Action Objects," -below, for a complete explanation of the arguments and behavior. +See the manpage section "Action Objects" +for a complete explanation of the arguments and behavior. @@ -221,6 +221,21 @@ AddOption('--prefix', help='installation prefix') env = Environment(PREFIX = GetOption('prefix')) + + + +While AddOption behaves like +optparse.add_option, +the behavior of options added by AddOption +which take arguments is underfined in +scons if whitespace +(rather than = sign) is used as +the separator on the command line when +the option is invoked. +Such usage should be avoided. + + + @@ -241,7 +256,8 @@ has been built. The specified action(s) may be an Action object, or anything that can be converted into an Action object -(see below). +See the manpage section "Action Objects" +for a complete explanation. @@ -270,7 +286,8 @@ is built. The specified action(s) may be an Action object, or anything that can be converted into an Action object -(see below). +See the manpage section "Action Objects" +for a complete explanation. @@ -444,7 +461,7 @@ Otherwise, the construction variable and the value of the keyword argument are both coerced to lists, and the lists are added together. -(See also the Prepend method, below.) +(See also the Prepend method). @@ -568,8 +585,8 @@ or Creates a Builder object for the specified action. -See the section "Builder Objects," -below, for a complete explanation of the arguments and behavior. +See the manpage section "Builder Objects" +for a complete explanation of the arguments and behavior. @@ -873,7 +890,7 @@ same-named existing construction variables. An action can be an external command, specified as a string, or a callable Python object; -see "Action Objects," below, +see the manpage section "Action Objects" for more complete information. Also note that a string specifying an external command may be preceded by an @@ -897,7 +914,7 @@ env.Command('foo.out', 'foo.in', env.Command('bar.out', 'bar.in', ["rm -f $TARGET", "$BAR_BUILD < $SOURCES > $TARGET"], - ENV = {'PATH' : '/usr/local/bin/'}) + ENV={'PATH': '/usr/local/bin/'}) def rename(env, target, source): import os @@ -905,7 +922,7 @@ def rename(env, target, source): env.Command('baz.out', 'baz.in', ["$BAZ_BUILD < $SOURCES > .tmp", - rename ]) + rename]) @@ -914,14 +931,14 @@ Note that the function will usually assume, by default, that the specified targets and/or sources are Files, if no other part of the configuration -identifies what type of entry it is. +identifies what type of entries they are. If necessary, you can explicitly specify that targets or source nodes should -be treated as directoriese +be treated as directories by using the Dir or -env.Dir() +env.Dir functions. @@ -937,9 +954,9 @@ env.Command(env.Dir('$DISTDIR')), None, make_distdir) -(Also note that SCons will usually +Also note that SCons will usually automatically create any directory necessary to hold a target file, -so you normally don't need to create directories by hand.) +so you normally don't need to create directories by hand. @@ -954,8 +971,8 @@ so you normally don't need to create directories by hand.) Creates a Configure object for integrated functionality similar to GNU autoconf. -See the section "Configure Contexts," -below, for a complete explanation of the arguments and behavior. +See the manpage section "Configure Contexts" +for a complete explanation of the arguments and behavior. @@ -1385,7 +1402,8 @@ would supply a string as a directory name to a Builder method or function. Directory Nodes have attributes and methods that are useful in many situations; -see "File and Directory Nodes," below. +see manpage section "File and Directory Nodes" +for more information. @@ -1528,8 +1546,8 @@ Executes an Action object. The specified action may be an Action object -(see the section "Action Objects," -below, for a complete explanation of the arguments and behavior), +(see manpage section "Action Objects" +for a complete explanation of the arguments and behavior), or it may be a command-line string, list of commands, or executable Python function, @@ -1686,7 +1704,8 @@ would supply a string as a file name to a Builder method or function. File Nodes have attributes and methods that are useful in many situations; -see "File and Directory Nodes," below. +see manpage section "File and Directory Nodes" +for more information. @@ -2836,7 +2855,7 @@ and the construction variables they affect are as specified for the env.ParseFlags method (which this method calls). -See that method's description, below, +See that method's description for a table of options and construction variables. @@ -3539,8 +3558,8 @@ Return('val1 val2') Creates a Scanner object for the specified function. -See the section "Scanner Objects," -below, for a complete explanation of the arguments and behavior. +See manpage section "Scanner Objects" +for a complete explanation of the arguments and behavior. @@ -4229,107 +4248,6 @@ env.SourceCode('no_source.c', None) - - - SourceSignatures(type) - - - env.SourceSignatures(type) - - - -Note: Although it is not yet officially deprecated, -use of this function is discouraged. -See the -Decider -function for a more flexible and straightforward way -to configure SCons' decision-making. - - - -The -SourceSignatures -function tells -scons -how to decide if a source file -(a file that is not built from any other files) -has changed since the last time it -was used to build a particular target file. -Legal values are -MD5 -or -timestamp. - - - -If the environment method is used, -the specified type of source signature -is only used when deciding whether targets -built with that environment are up-to-date or must be rebuilt. -If the global function is used, -the specified type of source signature becomes the default -used for all decisions -about whether targets are up-to-date. - - - -MD5 -means -scons -decides that a source file has changed -if the MD5 checksum of its contents has changed since -the last time it was used to rebuild a particular target file. - - - -timestamp -means -scons -decides that a source file has changed -if its timestamp (modification time) has changed since -the last time it was used to rebuild a particular target file. -(Note that although this is similar to the behavior of Make, -by default it will also rebuild if the dependency is -older -than the last time it was used to rebuild the target file.) - - - -There is no different between the two behaviors -for Python -Value -node objects. - - - -MD5 -signatures take longer to compute, -but are more accurate than -timestamp -signatures. -The default value is -MD5. - - - -Note that the default -TargetSignatures -setting (see below) -is to use this -SourceSignatures -setting for any target files that are used -to build other target files. -Consequently, changing the value of -SourceSignatures -will, by default, -affect the up-to-date decision for all files in the build -(or all files built with a specific construction environment -when -env.SourceSignatures -is used). - - - Split(arg) @@ -4501,161 +4419,6 @@ Tag( 'file2.txt', DOC ) - - - TargetSignatures(type) - - - env.TargetSignatures(type) - - - -Note: Although it is not yet officially deprecated, -use of this function is discouraged. -See the -Decider -function for a more flexible and straightforward way -to configure SCons' decision-making. - - - -The -TargetSignatures -function tells -scons -how to decide if a target file -(a file that -is -built from any other files) -has changed since the last time it -was used to build some other target file. -Legal values are -"build"; -"content" -(or its synonym -"MD5"); -"timestamp"; -or -"source". - - - -If the environment method is used, -the specified type of target signature is only used -for targets built with that environment. -If the global function is used, -the specified type of signature becomes the default -used for all target files that -don't have an explicit target signature type -specified for their environments. - - - -"content" -(or its synonym -"MD5") -means -scons -decides that a target file has changed -if the MD5 checksum of its contents has changed since -the last time it was used to rebuild some other target file. -This means -scons -will open up -MD5 sum the contents -of target files after they're built, -and may decide that it does not need to rebuild -"downstream" target files if a file was -rebuilt with exactly the same contents as the last time. - - - -"timestamp" -means -scons -decides that a target file has changed -if its timestamp (modification time) has changed since -the last time it was used to rebuild some other target file. -(Note that although this is similar to the behavior of Make, -by default it will also rebuild if the dependency is -older -than the last time it was used to rebuild the target file.) - - - -"source" -means -scons -decides that a target file has changed -as specified by the corresponding -SourceSignatures -setting -("MD5" -or -"timestamp"). -This means that -scons -will treat all input files to a target the same way, -regardless of whether they are source files -or have been built from other files. - - - -"build" -means -scons -decides that a target file has changed -if it has been rebuilt in this invocation -or if its content or timestamp have changed -as specified by the corresponding -SourceSignatures -setting. -This "propagates" the status of a rebuilt file -so that other "downstream" target files -will always be rebuilt, -even if the contents or the timestamp -have not changed. - - - -"build" -signatures are fastest because -"content" -(or -"MD5") -signatures take longer to compute, -but are more accurate than -"timestamp" -signatures, -and can prevent unnecessary "downstream" rebuilds -when a target file is rebuilt to the exact same contents -as the previous build. -The -"source" -setting provides the most consistent behavior -when other target files may be rebuilt from -both source and target input files. -The default value is -"source". - - - -Because the default setting is -"source", -using -SourceSignatures -is generally preferable to -TargetSignatures, -so that the up-to-date decision -will be consistent for all files -(or all files built with a specific construction environment). -Use of -TargetSignatures -provides specific control for how built target files -affect their "downstream" dependencies. - - - Tool(string, [toolpath, **kw]) @@ -4949,30 +4712,51 @@ SConscript(dirs='doc', variant_dir='build/doc', duplicate=0) Searches for the specified executable program, returning the full path name to the program -if it is found, -and returning None if not. -Searches the specified -path, -the value of the calling environment's PATH -(env['ENV']['PATH']), -or the user's current external PATH -(os.environ['PATH']) -by default. +if it is found, else None. +Searches the value of the +path keyword argument, +or if None (the default) +the value of the calling environment's PATH +(env['ENV']['PATH']). +If path is None and +the env['ENV']['PATH'] key does not exist, +the user's current external PATH +(os.environ['PATH']) is used as fallback. + + On Windows systems, searches for executable -programs with any of the file extensions -listed in the specified -pathext, -the calling environment's PATHEXT -(env['ENV']['PATHEXT']) -or the user's current PATHEXT +programs with any of the file extensions listed in the +pathext keyword argument, +or if None (the default) +the calling environment's PATHEXT +(env['ENV']['PATHEXT']). +The user's current external PATHEXT (os.environ['PATHEXT']) -by default. +is used as a fallback if pathext is +None +and the key env['ENV']['PATHEXT'] +does not exist. + + Will not select any path name or names in the specified reject list, if any. + + +If you would prefer to search +the user's current external PATH +(os.environ['PATH']) +by default, +consider using the function SCons.Util.WhereIs instead. +Note that SCons.Util.WhereIs +does not expand environment variables automatically +(no implicit env.subst for its arguments). + + + diff --git a/doc/generated/functions.mod b/doc/generated/functions.mod index e460aaf..91710a3 100644 --- a/doc/generated/functions.mod +++ b/doc/generated/functions.mod @@ -82,11 +82,9 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. SetOption"> SideEffect"> SourceCode"> -SourceSignatures"> Split"> subst"> Tag"> -TargetSignatures"> Tool"> Value"> VariantDir"> @@ -166,11 +164,9 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.SetOption"> env.SideEffect"> env.SourceCode"> -env.SourceSignatures"> env.Split"> env.subst"> env.Tag"> -env.TargetSignatures"> env.Tool"> env.Value"> env.VariantDir"> @@ -260,11 +256,9 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. SetOption"> SideEffect"> SourceCode"> -SourceSignatures"> Split"> subst"> Tag"> -TargetSignatures"> Tool"> Value"> VariantDir"> @@ -344,11 +338,9 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. env.SetOption"> env.SideEffect"> env.SourceCode"> -env.SourceSignatures"> env.Split"> env.subst"> env.Tag"> -env.TargetSignatures"> env.Tool"> env.Value"> env.VariantDir"> diff --git a/doc/generated/variables.gen b/doc/generated/variables.gen index 8f09512..cf54aab 100644 --- a/doc/generated/variables.gen +++ b/doc/generated/variables.gen @@ -488,7 +488,8 @@ after the SCons template for the file has been written. A reserved variable name that may not be set or used in a construction environment. -(See "Variable Substitution," below.) +(See the manpage section "Variable Substitution" +for more information). @@ -498,7 +499,8 @@ that may not be set or used in a construction environment. A reserved variable name that may not be set or used in a construction environment. -(See "Variable Substitution," below.) +(See the manpage section "Variable Substitution" +for more information). @@ -2804,15 +2806,6 @@ is -dNOPAUSE -dBATCH -sDEVICE=pdfwrite HOST_ARCH - The name of the host hardware architecture used to create the Environment. - If a platform is specified when creating the Environment, then - that Platform's logic will handle setting this value. - This value is immutable, and should not be changed by the user after - the Environment is initialized. - Currently only set for Win32. - - - Sets the host architecture for Visual Studio compiler. If not set, default to the detected host architecture: note that this may depend on the python you are using. @@ -2828,7 +2821,16 @@ Valid values are the same as for This is currently only used on Windows, but in the future it will be used on other OSes as well. - + + + The name of the host hardware architecture used to create the Environment. + If a platform is specified when creating the Environment, then + that Platform's logic will handle setting this value. + This value is immutable, and should not be changed by the user after + the Environment is initialized. + Currently only set for Win32. + + HOST_OS @@ -2900,7 +2902,7 @@ to '.dll'. Used to override $SHLIBVERSION/$LDMODULEVERSION when generating versioned import library for a shared library/loadable module. If undefined, the $SHLIBVERSION/$LDMODULEVERSION is used to -determine the version of versioned import library. +determine the version of versioned import library. @@ -3070,7 +3072,7 @@ The command line used to call the Java archive tool. The string displayed when the Java archive tool is called -If this is not set, then $JARCOM (the command line) is displayed. +If this is not set, then $JARCOM (the command line) is displayed. @@ -3080,7 +3082,7 @@ env = Environment(JARCOMSTR = "JARchiving $SOURCES into $TARGET") The string displayed when the Java archive tool is called -If this is not set, then $JARCOM (the command line) is displayed. +If this is not set, then $JARCOM (the command line) is displayed. @@ -3446,6 +3448,17 @@ If this is not set, then + LDMODULEEMITTER + + +Contains the emitter specification for the +LoadableModule builder. +The manpage section "Builder Objects" contains +general information on specifying emitters. + + + LDMODULEFLAGS @@ -3618,7 +3631,10 @@ when the $_LIBDIRFLAGS va LIBEMITTER -TODO +Contains the emitter specification for the +StaticLibrary builder. +The manpage section "Builder Objects" contains +general information on specifying emitters. @@ -5108,7 +5124,10 @@ for example. PROGEMITTER -TODO +Contains the emitter specification for the +Program builder. +The manpage section "Builder Objects" contains +general information on specifying emitters. @@ -5803,9 +5822,9 @@ appending to this list, although the more flexible approach is to associate scanners with a specific Builder. -See the sections "Builder Objects" -and "Scanner Objects," -below, for more information. +See the manpage sections "Builder Objects" +and "Scanner Objects" +for more information. @@ -6465,7 +6484,10 @@ If this is not set, then -TODO +Contains the emitter specification for the +SharedLibrary builder. +The manpage section "Builder Objects" contains +general information on specifying emitters. @@ -6509,7 +6531,7 @@ The suffix used for shared library file names. When this construction variable is defined, a versioned shared library -is created by SharedLibrary builder. This activates the +is created by the SharedLibrary builder. This activates the $_SHLIBVERSIONFLAGS and thus modifies the $SHLINKCOM as required, adds the version number to the library name, and creates the symlinks that are needed. $SHLIBVERSION versions should exist as alpha-numeric, @@ -6518,6 +6540,16 @@ Example + + SHLIBVERSIONFLAGS + + +Extra flags added to $SHLINKCOM when building versioned +SharedLibrary. These flags are only used when $SHLIBVERSION is +set. + + + _SHLIBVERSIONFLAGS @@ -6531,16 +6563,6 @@ and some extra dynamically generated options (such as - - SHLIBVERSIONFLAGS - - -Extra flags added to $SHLINKCOM when building versioned -SharedLibrary. These flags are only used when $SHLIBVERSION is -set. - - - SHLINK @@ -6629,7 +6651,8 @@ The variable is used, for example, by A reserved variable name that may not be set or used in a construction environment. -(See "Variable Substitution," below.) +(See the manpage section "Variable Substitution" +for more information). @@ -6652,7 +6675,8 @@ field in the controlling information for Ipkg and RPM packages. A reserved variable name that may not be set or used in a construction environment. -(See "Variable Substitution," below.) +(See the manpage section "Variable Substitution" +for more information). @@ -6996,7 +7020,8 @@ General options passed to the tar archiver. A reserved variable name that may not be set or used in a construction environment. -(See "Variable Substitution," below.) +(See the manpage section "Variable Substitution" +for more information). @@ -7004,13 +7029,6 @@ that may not be set or used in a construction environment. TARGET_ARCH - The name of the target hardware architecture for the compiled objects - created by this Environment. - This defaults to the value of HOST_ARCH, and the user can override it. - Currently only set for Win32. - - - Sets the target architecture for Visual Studio compiler (i.e. the arch of the binaries generated by the compiler). If not set, default to $HOST_ARCH, or, if that is unset, to the architecture of the @@ -7041,7 +7059,14 @@ and ia64 (Itanium). For example, if you want to compile 64-bit binaries, you would set TARGET_ARCH='x86_64' in your SCons environment. - + + + The name of the target hardware architecture for the compiled objects + created by this Environment. + This defaults to the value of HOST_ARCH, and the user can override it. + Currently only set for Win32. + + TARGET_OS @@ -7060,7 +7085,8 @@ For example, if you want to compile 64-bit binaries, you would set A reserved variable name that may not be set or used in a construction environment. -(See "Variable Substitution," below.) +(See the manpage section "Variable Substitution" +for more information). @@ -7193,7 +7219,8 @@ that are part of this construction environment. A reserved variable name that may not be set or used in a construction environment. -(See "Variable Substitution," below.) +(See the manpage section "Variable Substitution" +for more information). @@ -7203,7 +7230,8 @@ that may not be set or used in a construction environment. A reserved variable name that may not be set or used in a construction environment. -(See "Variable Substitution," below.) +(See the manpage section "Variable Substitution" +for more information). diff --git a/doc/generated/variables.mod b/doc/generated/variables.mod index 372a15f..1a5bc97 100644 --- a/doc/generated/variables.mod +++ b/doc/generated/variables.mod @@ -251,6 +251,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $LDMODULE"> $LDMODULECOM"> $LDMODULECOMSTR"> +$LDMODULEEMITTER"> $LDMODULEFLAGS"> $LDMODULENOVERSIONSYMLINKS"> $LDMODULEPREFIX"> @@ -891,6 +892,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. $LDMODULE"> $LDMODULECOM"> $LDMODULECOMSTR"> +$LDMODULEEMITTER"> $LDMODULEFLAGS"> $LDMODULENOVERSIONSYMLINKS"> $LDMODULEPREFIX"> diff --git a/src/engine/SCons/Script/Main.xml b/src/engine/SCons/Script/Main.xml index 13ad336..514c1ae 100644 --- a/src/engine/SCons/Script/Main.xml +++ b/src/engine/SCons/Script/Main.xml @@ -138,9 +138,9 @@ env = Environment(PREFIX = GetOption('prefix')) While &AddOption; behaves like optparse.add_option, -the behavior of options added by &AddOption; +the behavior of options added by &AddOption; which take arguments is underfined in -scons if a space +scons if whitespace (rather than = sign) is used as the separator on the command line when the option is invoked. -- cgit v0.12 From edaee69677e2a07b2d515e821acb4d58cc5c8196 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 21 Nov 2019 08:58:05 -0700 Subject: [PR 3475] further wording tweaks on AddOption [ci skip] Reword some parts. Add note to manpage that AddOption does not support matching "abbreviations" for long option names. Add note to manpage and user guide that you can't SetOption on options added via AddOption. (as noted in issue #2105) Signed-off-by: Mats Wichmann --- doc/user/command-line.xml | 30 ++++++++++++++++++------------ src/engine/SCons/Script/Main.xml | 26 ++++++++++++++++++++------ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/doc/user/command-line.xml b/doc/user/command-line.xml index 62d0558..d8f9fff 100644 --- a/doc/user/command-line.xml +++ b/doc/user/command-line.xml @@ -599,25 +599,30 @@ foo.in &SCons; also allows you to define your own command-line options with the &AddOption; function. The &AddOption; function takes the same arguments - as the optparse.add_option function - from the standard Python library. + as the add_option method + from the standard Python library module optparse. The &AddOption; function is, in fact, implemented using a subclass - of the optparse.OptionParser. + of optparse.OptionParser. + + Once you have added a custom command-line option with the &AddOption; function, the value of the option (if any) is immediately available using the standard &GetOption; function. + + &SetOption; is not currently supported for + options added with &AddOption;. @@ -681,21 +686,22 @@ foo.in - Long options and option-arguments separated by whitespace, - rather than by =, are ambiguous. + Option-arguments separated from long options by whitespace, + rather than by an =, cannot be correctly + resolved by scons. While --input=ARG - has a clear meaning, for --input ARG it is not - possible to tell without instructions whether + is clearly opt followed by arg, for --input ARG + it is not possible to tell without instructions whether ARG is an argument belonging to the input option or a positional argument. scons treats positional arguments as either command-line build options or command-line targets - (see the immediately following sections for details), - which are made available for use in the &SConscript;. + which are made available for use in an &SConscript; + (see the immediately following sections for details). Thus, they must be collected before &SConscript; processing takes place. Since &AddOption; calls, which provide - the processing instructions to resolve the ambiguity, - happen in the &SConscript;, + the processing instructions to resolve any ambiguity, + happen in an &SConscript;, scons does not know in time for options added this way, and unexpected things will happen, such as option-arguments assigned as targets and/or exceptions diff --git a/src/engine/SCons/Script/Main.xml b/src/engine/SCons/Script/Main.xml index 514c1ae..f518422 100644 --- a/src/engine/SCons/Script/Main.xml +++ b/src/engine/SCons/Script/Main.xml @@ -33,11 +33,11 @@ See its __doc__ string for a discussion of the format. This function adds a new command-line option to be recognized. The specified arguments -are the same as supported by the standard Python -optparse.add_option() -method (with a few additional capabilities noted below); +are the same as supported by the add_option +method in the standard Python library module optparse, +with a few additional capabilities noted below; see the documentation for -optparse +optparse for a thorough discussion of its option-processing capabities. @@ -78,12 +78,22 @@ the option will have a default value of +Unlike regular optparse, option names +added via AddOption must be matched +exactly, the automatic matching of abbreviations on the +command line for long options is not supported. +To allow specific abbreviations, +include them in the &f-AddOption; call. + + + Once a new command-line option has been added with &f-AddOption;, the option value may be accessed using &f-GetOption; or env.GetOption(). + +&f-SetOption; is not currently supported for +options added with &f-AddOption;. @@ -137,11 +150,12 @@ env = Environment(PREFIX = GetOption('prefix')) While &AddOption; behaves like -optparse.add_option, +add_option, +from the optparse module, the behavior of options added by &AddOption; which take arguments is underfined in scons if whitespace -(rather than = sign) is used as +(rather than an = sign) is used as the separator on the command line when the option is invoked. Such usage should be avoided. -- cgit v0.12 From 3e039f1b101f7d52b333e1c5d7f75d3984ff0551 Mon Sep 17 00:00:00 2001 From: Jason Kenny Date: Wed, 4 Dec 2019 15:30:42 -0600 Subject: Allow Command to take more builder options add to change log add documentation update test --- src/CHANGES.txt | 3 +++ src/engine/SCons/Environment.py | 13 +++++++++++++ src/engine/SCons/Environment.xml | 22 +++++++++++++++------ test/Command.py | 42 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 617b3d0..b42dd0a 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -5,6 +5,9 @@ Change Log RELEASE VERSION/DATE TO BE FILLED IN LATER + From Jason Kenny + - Update Command() function to accept target_scanner, source_factory, and target_factory arguments. + This make Command act more like a one-off builder. From Philipp Maierhöfer: - Avoid crash with UnicodeDecodeError on Python 3 when a Latex log file in diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 0e1102e..17d3250 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -1984,9 +1984,22 @@ class Base(SubstitutionEnvironment): 'target_factory' : self.fs.Entry, 'source_factory' : self.fs.Entry, } + # source scanner try: bkw['source_scanner'] = kw['source_scanner'] except KeyError: pass else: del kw['source_scanner'] + #target scanner + try: bkw['target_scanner'] = kw['target_scanner'] + except KeyError: pass + else: del kw['target_scanner'] + #source factory + try: bkw['source_factory'] = kw['source_factory'] + except KeyError: pass + else: del kw['source_factory'] + #target factory + try: bkw['target_factory'] = kw['target_factory'] + except KeyError: pass + else: del kw['target_factory'] bld = SCons.Builder.Builder(**bkw) return bld(self, target, source, **kw) diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml index 829bf12..a32d43d 100644 --- a/src/engine/SCons/Environment.xml +++ b/src/engine/SCons/Environment.xml @@ -937,19 +937,29 @@ for a single special-case build. -As a special case, the -source_scanner -keyword argument can +&b-Command; builder accepts +source_scanner, +target_scanner, +source_factory, and +target_factory +keyword arguments. The *_scanner args can be used to specify a Scanner object -that will be used to scan the sources. -(The global +that will be used to apply a custom +scanner for a source or target. +For example, the global DirScanner object can be used if any of the sources will be directories that must be scanned on-disk for changes to files that aren't -already specified in other Builder of function calls.) +already specified in other Builder of function calls. +The *_factory args take a factory function that the +Command will use to turn any sources or targets +specified as strings into SCons Nodes. +See the sections "Builder Objects" +below, for more information about how these +args work in a Builder. diff --git a/test/Command.py b/test/Command.py index 09a8daa..380c171 100644 --- a/test/Command.py +++ b/test/Command.py @@ -44,6 +44,7 @@ test.write(['expand_chdir_sub', 'subbuild.py'], build_py) test.write('SConstruct', """ import os +import sys def buildIt(env, target, source): with open(str(target[0]), 'w') as f, open(str(source[0]), 'r') as infp: @@ -62,6 +63,19 @@ def sub(env, target, source): t.write(s.read()) return 0 +def source_scanner(node, env, path, builder): + print("Source scanner node=", node, "builder =", builder,file=sys.stderr) + return [] + + +def target_scanner(node, env, path, builder): + print("Target scanner node=", node, "builder =", builder,file=sys.stderr) + return [] + +def factory(node,*lst,**kw): + print("factory called on:",node,file=sys.stderr) + return env.File(node) + env = Environment(COPY_THROUGH_TEMP = r'%(_python_)s build.py .tmp $SOURCE' + '\\n' + r'%(_python_)s build.py $TARGET .tmp', EXPAND = '$COPY_THROUGH_TEMP') env.Command(target = 'f1.out', source = 'f1.in', @@ -82,6 +96,19 @@ env.Command(target = 'f7.out', source = 'f7.in', action = r'%(_python_)s build.py $TARGET $SOURCE') Command(target = 'f8.out', source = 'f8.in', action = r'%(_python_)s build.py $TARGET $SOURCE') +env.Command(target = 'f7s.out', source = 'f7.in', + action = r'%(_python_)s build.py $TARGET $SOURCE', + target_scanner=Scanner(lambda node, env, path: target_scanner(node, env, path, "w-env")), + source_scanner=Scanner(lambda node, env, path: source_scanner(node, env, path, "w-env"))) +Command(target = 'f8s.out', source = 'f8.in', + action = r'%(_python_)s build.py $TARGET $SOURCE', + target_scanner=Scanner(lambda node, env, path: target_scanner(node, env, path, "wo-env")), + source_scanner=Scanner(lambda node, env, path: source_scanner(node, env, path, "wo-env"))) +Command(target = 'f8f.out', source = 'f8.in', + action = r'%(_python_)s build.py $TARGET $SOURCE', + target_factory=factory, + source_factory=factory + ) env.Command(target = 'f9.out', source = 'f9.in', action = r'$EXPAND') env.Command(target = '${F10}.out', source = '${F10}.in', @@ -108,7 +135,18 @@ test.write('f9.in', "f9.in\n") test.write('f10.in', "f10.in\n") test.write(['expand_chdir_sub', 'f11.in'], "expand_chdir_sub/f11.in\n") -test.run(arguments = '.') +test_str = r'''factory called on: f8.in +factory called on: f8f.out +Source scanner node= f7.in builder = w-env +Target scanner node= f7s.out builder = w-env +Source scanner node= f8.in builder = wo-env +Target scanner node= f8s.out builder = wo-env +''' + +out = test.run(arguments = '.', + stderr = test_str, + match=TestSCons.match_re_dotall) + test.must_match('f1.out', "f1.in\n", mode='r') test.must_match('f2.out', "f2.in\n", mode='r') @@ -118,6 +156,8 @@ test.must_match('f5.out', "XYZZY is set\nf5.in\n", mode='r') test.must_match('f6.out', "f6.in\n", mode='r') test.must_match('f7.out', "f7.in\n", mode='r') test.must_match('f8.out', "f8.in\n", mode='r') +test.must_match('f7s.out', "f7.in\n", mode='r') +test.must_match('f8s.out', "f8.in\n", mode='r') test.must_match('f9.out', "f9.in\n", mode='r') test.must_match('f10.out', "f10.in\n", mode='r') test.must_match(['expand_chdir_sub', 'f11.out'], "expand_chdir_sub/f11.in\n", mode='r') -- cgit v0.12 From 16f42198ba3afe2e40b21c5627274fec48c8611e Mon Sep 17 00:00:00 2001 From: Jason Kenny Date: Fri, 6 Dec 2019 11:00:25 -0600 Subject: add py3 compatible print() functions --- test/Command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Command.py b/test/Command.py index 380c171..7189d06 100644 --- a/test/Command.py +++ b/test/Command.py @@ -21,7 +21,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons @@ -43,6 +42,7 @@ test.write('build.py', build_py) test.write(['expand_chdir_sub', 'subbuild.py'], build_py) test.write('SConstruct', """ +from __future__ import print_function import os import sys -- cgit v0.12 From ed66f1338f029a63b7a93f7027f3149ab5376bdd Mon Sep 17 00:00:00 2001 From: Adam Gross Date: Fri, 6 Dec 2019 16:43:52 -0500 Subject: Fix multithreaded Windows builds when a thread has a file open for write Python 2 enables handle inheritance by default for child processes. It wasn't until Python 3.4 that it was disabled. This causes problems because if a Python action is writing to a file and a child process is spawned at that exact moment, builds fail because of sharing issues. --- src/engine/SCons/Platform/win32.py | 59 ++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 0a3b199..c0cf03b 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -51,10 +51,6 @@ try: import msvcrt import win32api import win32con - - msvcrt.get_osfhandle - win32api.SetHandleInformation - win32con.HANDLE_FLAG_INHERIT except ImportError: parallel_msg = \ "you do not seem to have the pywin32 extensions installed;\n" + \ @@ -66,28 +62,41 @@ except AttributeError: else: parallel_msg = None - _builtin_open = open - - def _scons_open(*args, **kw): - fp = _builtin_open(*args, **kw) - win32api.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()), - win32con.HANDLE_FLAG_INHERIT, - 0) - return fp - - open = _scons_open - if sys.version_info.major == 2: - _builtin_file = file - class _scons_file(_builtin_file): - def __init__(self, *args, **kw): - _builtin_file.__init__(self, *args, **kw) - win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), - win32con.HANDLE_FLAG_INHERIT, 0) - file = _scons_file - else: - # No longer needed for python 3.4 and above. Files are opened non sharable - pass + import __builtin__ + + _builtin_file = __builtin__.file + _builtin_open = __builtin__.open + + def _scons_fixup_mode(mode): + """Adjust 'mode' to mark handle as non-inheritable. + + SCons is multithreaded, so allowing handles to be inherited by + children opens us up to races, where (e.g.) processes spawned by + the Taskmaster may inherit and retain references to files opened + by other threads. This may lead to sharing violations and, + ultimately, build failures. + + By including 'N' as part of fopen's 'mode' parameter, all file + handles returned from these functions are atomically marked as + non-inheritable. + """ + if not mode: + # Python's default is 'r'. + # https://docs.python.org/2/library/functions.html#open + mode = 'rN' + elif 'N' not in mode: + mode += 'N' + return mode + + def _scons_file(name, mode=None, *args, **kwargs): + return _builtin_file(name, _scons_fixup_mode(mode), *args, **kwargs) + + def _scons_open(name, mode=None, *args, **kwargs): + return _builtin_open(name, _scons_fixup_mode(mode), *args, **kwargs) + + __builtin__.file = _scons_file + __builtin__.open = _scons_open -- cgit v0.12 From 3b9e2a859177952ecec8370e56a5ecfc29d307b1 Mon Sep 17 00:00:00 2001 From: Adam Gross Date: Fri, 6 Dec 2019 16:55:16 -0500 Subject: Change src\CHANGES.txt --- src/CHANGES.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index e24555d..1c05960 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -16,6 +16,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Tim Gates - Resolved a typo in engine.SCons.Tool + From Adam Gross: + - Resolved a race condition in multithreaded Windows builds with Python 2 + in the case where a child process is spawned while a Python action has a + file open. + From Ivan Kravets - Added support for "-imacros" to ParseFlags -- cgit v0.12 From 3be99b7a05858fb00b99620ec1277a2fd967d415 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 7 Dec 2019 08:46:20 -0700 Subject: Update debug=action-timestamps + Rename to action-timestamps (from action_timestamps) for consistency with other compound word options. + Put manpage entry in alphabetical order. + Describe what option does and shorten it (refers to debug=time instead of duplicating it) + Change prints a bit (and tests to match) + Show scons version where added. + Slight adjustment to manpage introduction to debug options. Along the way, fixes a lingering tag mismatch from an earlier documentation PR. Updates PR#3456 Signed-off-by: Mats Wichmann --- doc/man/scons.xml | 61 +++++++++++---------------------- doc/user/depends.xml | 1 + src/engine/SCons/Script/Main.py | 7 ++-- src/engine/SCons/Script/SConsOptions.py | 2 +- test/option/debug-action-timestamps.py | 10 +++--- 5 files changed, 30 insertions(+), 51 deletions(-) diff --git a/doc/man/scons.xml b/doc/man/scons.xml index ae54e2e..e0f920d 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -686,19 +686,32 @@ option except for the way default targets are handled. When this option is used and no targets are specified on the command line, all default targets are built, whether or not they are below the current directory. - + - --debug=type + --debug=type[,type...] Debug the build process. -type[,type...] -specifies what type of debugging. Multiple types may be specified, -separated by commas. The following types are valid: +type +specifies the kind of debugging info to emit. +Multiple types may be specified, separated by commas. +The following entries show the recognized types: + + + + --debug=action-timestamps + +Prints additional time profiling information. For +each command, shows the absolute start and end times. +This may be useful in debugging parallel builds. +Implies the option. + +Since &scons; 3.1. + --debug=count @@ -893,40 +906,6 @@ should take place in parallel.) - - --debug=action_timestamps - - Prints additional 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) - - - The total time spent executing all build commands - - - The elapsed wall-clock time spent executing those build commands - - - The absolute start and end wall-clock time spent executing those build commands - - - The time spent processing each file passed to the SConscript() function - - - - - --diskcheck=types @@ -2278,10 +2257,10 @@ env.SomeTool(targets, sources) Builder Methods -You tell scons what to build +You tell scons what to build by calling Builders, functions which know to take a particular action when given files of a particular type -to produce a particular result type. scons +to produce a particular result type. scons defines a number of builders, and you can also write your own. Builders are attached to a &consenv; as methods, and the available builder methods are listed as diff --git a/doc/user/depends.xml b/doc/user/depends.xml index 5a78eb5..cd5094a 100644 --- a/doc/user/depends.xml +++ b/doc/user/depends.xml @@ -764,6 +764,7 @@ int main() { printf("Hello, world!\n"); } encounter them in older &SConscript; files. +
Implicit Dependencies: The &cv-CPPPATH; Construction Variable diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 58dbf64..238a828 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -211,10 +211,9 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask): last_command_end = finish_time cumulative_command_time = cumulative_command_time+finish_time-start_time if print_action_timestamps: - sys.stdout.write("Command execution start time: %s: %f seconds\n"%(str(self.node), start_time)) + sys.stdout.write("Command execution start timestamp: %s: %f\n"%(str(self.node), start_time)) + sys.stdout.write("Command execution end timestamp: %s: %f\n"%(str(self.node), finish_time)) sys.stdout.write("Command execution time: %s: %f seconds\n"%(str(self.node), finish_time-start_time)) - if print_action_timestamps: - sys.stdout.write("Command execution stop time: %s: %f seconds\n"%(str(self.node), finish_time)) def do_failed(self, status=2): _BuildFailures.append(self.exception[1]) @@ -679,7 +678,7 @@ def _set_debug_values(options): options.tree_printers.append(TreePrinter(status=True)) if "time" in debug_values: print_time = 1 - if "action_timestamps" in debug_values: + if "action-timestamps" in debug_values: print_time = 1 print_action_timestamps = 1 if "tree" in debug_values: diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 7b5d523..66c7239 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -622,7 +622,7 @@ def Parser(version): debug_options = ["count", "duplicate", "explain", "findlibs", "includes", "memoizer", "memory", "objects", "pdb", "prepare", "presub", "stacktrace", - "time", "action_timestamps"] + "time", "action-timestamps"] def opt_debug(option, opt, value__, parser, debug_options=debug_options, diff --git a/test/option/debug-action-timestamps.py b/test/option/debug-action-timestamps.py index 0277516..059cfdf 100644 --- a/test/option/debug-action-timestamps.py +++ b/test/option/debug-action-timestamps.py @@ -34,13 +34,13 @@ def setup_fixtures(): test.file_fixture('../fixture/SConstruct_test_main.py', 'SConstruct') def test_help_function(): - # Before anything else, make sure we get valid --debug=action_timestamps results + # Before anything else, make sure we get valid --debug=action-timestamps results # when just running the help option. - test.run(arguments = "-h --debug=action_timestamps") + test.run(arguments = "-h --debug=action-timestamps") def build(): # Execute build - test.run(arguments='--debug=action_timestamps') + test.run(arguments='--debug=action-timestamps') build_output = test.stdout() return build_output @@ -84,8 +84,8 @@ def test_correctness_of_timestamps(build_output): debug_time_patterns = [ r'Command execution time: (.*): (\d+\.\d+) seconds', - r'Command execution start time: (.*): (\d+\.\d+) seconds', - r'Command execution stop time: (.*): (\d+\.\d+) seconds' + r'Command execution start timestamp: (.*): (\d+\.\d+)', + r'Command execution end timestamp: (.*): (\d+\.\d+)' ] test = TestSCons.TestSCons() -- cgit v0.12 From b1ac9ecfe28437f7e3480cd31120f12bd43c968b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 7 Dec 2019 23:02:14 -0500 Subject: Address GaryO's feedback on PR 3129. Also reformatted Command() PEP8 --- src/CHANGES.txt | 9 ++++--- src/engine/SCons/Environment.py | 52 +++++++++++++++++++++++++++-------------- test/Command.py | 1 - 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a5a37b8..34c7b9b 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -4,10 +4,9 @@ Change Log +NOTE: Please add your name below (and your changes) alphabetically by last name. + RELEASE VERSION/DATE TO BE FILLED IN LATER - From Jason Kenny - - Update Command() function to accept target_scanner, source_factory, and target_factory arguments. - This make Command act more like a one-off builder. From Edoardo Bezzeccheri - Added debug option "action_timestamps" which outputs to stdout the absolute start and end time for each target. @@ -19,6 +18,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Tim Gates - Resolved a typo in engine.SCons.Tool + From Jason Kenny + - Update Command() function to accept target_scanner, source_factory, and target_factory arguments. + This makes Command act more like a one-off builder. + From Ivan Kravets - Added support for "-imacros" to ParseFlags diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 4a9cf11..916ebc4 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -1983,26 +1983,42 @@ class Base(SubstitutionEnvironment): be any type that the Builder constructor will accept for an action.""" bkw = { - 'action' : action, - 'target_factory' : self.fs.Entry, - 'source_factory' : self.fs.Entry, + 'action': action, + 'target_factory': self.fs.Entry, + 'source_factory': self.fs.Entry, } # source scanner - try: bkw['source_scanner'] = kw['source_scanner'] - except KeyError: pass - else: del kw['source_scanner'] - #target scanner - try: bkw['target_scanner'] = kw['target_scanner'] - except KeyError: pass - else: del kw['target_scanner'] - #source factory - try: bkw['source_factory'] = kw['source_factory'] - except KeyError: pass - else: del kw['source_factory'] - #target factory - try: bkw['target_factory'] = kw['target_factory'] - except KeyError: pass - else: del kw['target_factory'] + try: + bkw['source_scanner'] = kw['source_scanner'] + except KeyError: + pass + else: + del kw['source_scanner'] + + # target scanner + try: + bkw['target_scanner'] = kw['target_scanner'] + except KeyError: + pass + else: + del kw['target_scanner'] + + # source factory + try: + bkw['source_factory'] = kw['source_factory'] + except KeyError: + pass + else: + del kw['source_factory'] + + # target factory + try: + bkw['target_factory'] = kw['target_factory'] + except KeyError: + pass + else: + del kw['target_factory'] + bld = SCons.Builder.Builder(**bkw) return bld(self, target, source, **kw) diff --git a/test/Command.py b/test/Command.py index 7189d06..1eb5f77 100644 --- a/test/Command.py +++ b/test/Command.py @@ -67,7 +67,6 @@ def source_scanner(node, env, path, builder): print("Source scanner node=", node, "builder =", builder,file=sys.stderr) return [] - def target_scanner(node, env, path, builder): print("Target scanner node=", node, "builder =", builder,file=sys.stderr) return [] -- cgit v0.12 From a8e707d20e1a7d7d6a45510194b2acbdf9ca8c3d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 7 Dec 2019 23:03:17 -0500 Subject: Reformat test/Command.py PEP8 --- test/Command.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/Command.py b/test/Command.py index 1eb5f77..d8ca86d 100644 --- a/test/Command.py +++ b/test/Command.py @@ -142,9 +142,9 @@ Source scanner node= f8.in builder = wo-env Target scanner node= f8s.out builder = wo-env ''' -out = test.run(arguments = '.', - stderr = test_str, - match=TestSCons.match_re_dotall) +out = test.run(arguments='.', + stderr=test_str, + match=TestSCons.match_re_dotall) test.must_match('f1.out', "f1.in\n", mode='r') @@ -159,7 +159,8 @@ test.must_match('f7s.out', "f7.in\n", mode='r') test.must_match('f8s.out', "f8.in\n", mode='r') test.must_match('f9.out', "f9.in\n", mode='r') test.must_match('f10.out', "f10.in\n", mode='r') -test.must_match(['expand_chdir_sub', 'f11.out'], "expand_chdir_sub/f11.in\n", mode='r') +test.must_match(['expand_chdir_sub', 'f11.out'], + "expand_chdir_sub/f11.in\n", mode='r') test.pass_test() -- cgit v0.12 From 82016c7b8f990391f8afdc120d89a9a1f0e0a5ad Mon Sep 17 00:00:00 2001 From: Adam Gross Date: Sun, 8 Dec 2019 14:34:16 -0500 Subject: Fix SConsTests.py to actually clear out the file/open overrides This was breaking the tests because it was not clearing the overrides in a manner consistent with the new logic. --- src/engine/SCons/SConfTests.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index f770450..787138e 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -56,6 +56,18 @@ class SConfTestCase(unittest.TestCase): os.chdir(self.save_cwd) def _resetSConfState(self): + if sys.platform in ['cygwin', 'win32'] and sys.version_info.major == 2: + # On Windows with Python2, SCons.Platform.win32 redefines the + # built-in file() and open() functions to disable handle + # inheritance. Because we are unloading all SCons modules other + # than SCons.Compat, SCons.Platform.win32 will lose the variables + # it needs. As a result, we should reset the file() and open() + # functions to their original built-in versions. + import __builtin__ + import SCons.Platform.win32 + __builtin__.file = SCons.Platform.win32._builtin_file + __builtin__.open = SCons.Platform.win32._builtin_open + # Ok, this is tricky, and i do not know, if everything is sane. # We try to reset scons' state (including all global variables) import SCons.SConsign @@ -90,22 +102,6 @@ class SConfTestCase(unittest.TestCase): global existing_lib existing_lib = 'm' - if sys.platform in ['cygwin', 'win32']: - # On Windows, SCons.Platform.win32 redefines the builtin - # file() and open() functions to close the file handles. - # This interferes with the unittest.py infrastructure in - # some way. Just sidestep the issue by restoring the - # original builtin functions whenever we have to reset - # all of our global state. - - import SCons.Platform.win32 - - try: - file = SCons.Platform.win32._builtin_file - open = SCons.Platform.win32._builtin_open - except AttributeError: - pass - def _baseTryXXX(self, TryFunc): # TryCompile and TryLink are much the same, so we can test them # in one method, we pass the function as a string ('TryCompile', -- cgit v0.12 From b18b21d1cb1a000fb6e59338cc6f48afdea7348c Mon Sep 17 00:00:00 2001 From: Adam Gross Date: Sun, 8 Dec 2019 21:13:43 -0500 Subject: Convert our file replacement to be a class This hopefully will fix one unit test that validates that it's a class. --- src/engine/SCons/Platform/win32.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index c0cf03b..77c048e 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -89,11 +89,14 @@ else: mode += 'N' return mode - def _scons_file(name, mode=None, *args, **kwargs): - return _builtin_file(name, _scons_fixup_mode(mode), *args, **kwargs) + class _scons_file(_builtin_file): + def __init__(self, name, mode=None, *args, **kwargs): + _builtin_file.__init__(self, name, _scons_fixup_mode(mode), + *args, **kwargs) def _scons_open(name, mode=None, *args, **kwargs): - return _builtin_open(name, _scons_fixup_mode(mode), *args, **kwargs) + return _builtin_open(name, _scons_fixup_mode(mode), + *args, **kwargs) __builtin__.file = _scons_file __builtin__.open = _scons_open -- cgit v0.12 From 46b24a5cc8094f81802bfa79534e496872fb97ab Mon Sep 17 00:00:00 2001 From: Adam Gross Date: Mon, 9 Dec 2019 10:51:32 -0500 Subject: Update CHANGES.txt to indicate original author of patch --- src/CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 2c239a2..47b63ee 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -21,7 +21,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Adam Gross: - Resolved a race condition in multithreaded Windows builds with Python 2 in the case where a child process is spawned while a Python action has a - file open. + file open. Original author: Ryan Beasley. From Jason Kenny - Update Command() function to accept target_scanner, source_factory, and target_factory arguments. -- cgit v0.12