Should be fixed upstream in the next snapshot; it's late and the patch doesn't backport trivially so I'll not upload immediately.
-- "You grabbed my hand and we fell into it, like a daydream - or a fever."
--- Begin Message ---Gary saw this one coming: http://scons.tigris.org/issues/show_bug.cgi?id=1737 It's too draconian to forcibly *not* execute the configure checks when the -c (a.k.a. --clean) or -h (a.k.a. --help) options are invoked, because the configure checks may be used to detect what targets should be available for cleaning -- or what help The safe thing is to execute configure checks by default and let them be configured off for cleaning / helping. This patch lets you do this by supporting "clean" and "help" keyword arguments that can be set to False (or equivalent value) to disable the configure checks when doing either of those: conf = Configure( env, custom_tests = { 'CheckQt' : CheckQt }, clean=False, help=False ) I'm not entirely comfortable with pushing those into the Configure() call's keyword argument namespace, but couldn't come up with a more natural interface. Alternate suggestions (before this gets released, of course) are welcome. --SK Index: test/Configure/help.py =================================================================== --- test/Configure/help.py (revision 2465) +++ test/Configure/help.py (working copy) @@ -39,7 +39,7 @@ env = Environment() import os env.AppendENVPath('PATH', os.environ['PATH']) -conf = Configure(env) +conf = Configure(env, help=int(ARGUMENTS['help'])) r1 = conf.CheckCHeader( 'math.h' ) r2 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error env = conf.Finish() @@ -65,45 +65,26 @@ "Checking for C header file no_std_c_header.h... " ] -unexpected = [] +# The help setting should have no effect on -H, so the -H output +# should never contain the lines. +test.run(arguments = '-H help=0') +test.must_not_contain_lines(lines, test.stdout()) -test.run(arguments = '-H') +test.run(arguments = '-H help=1') +test.must_not_contain_lines(lines, test.stdout()) -for line in lines: - if string.find(test.stdout(), line) != -1: - unexpected.append(line) +# For -h and --help, the lines appear or not depending on how Configure() +# is initialized. +test.run(arguments = '-h help=0') +test.must_not_contain_lines(lines, test.stdout()) -if unexpected: - print "Unexpected lines in standard output:" - print string.join(unexpected, '\n') - print "STDOUT ============================================================" - print test.stdout() - test.fail_test() +test.run(arguments = '-h help=1') +test.must_contain_lines(lines, test.stdout()) -test.run(arguments = '-h') +test.run(arguments = '--help help=0') +test.must_not_contain_lines(lines, test.stdout()) -for line in lines: - if string.find(test.stdout(), line) != -1: - unexpected.append(line) +test.run(arguments = '--help help=1') +test.must_contain_lines(lines, test.stdout()) -if unexpected: - print "Unexpected lines in standard output:" - print string.join(unexpected, '\n') - print "STDOUT ============================================================" - print test.stdout() - test.fail_test() - -test.run(arguments = '--help') - -for line in lines: - if string.find(test.stdout(), line) != -1: - unexpected.append(line) - -if unexpected: - print "Unexpected lines in standard output:" - print string.join(unexpected, '\n') - print "STDOUT ============================================================" - print test.stdout() - test.fail_test() - test.pass_test() Index: test/Configure/clean.py =================================================================== --- test/Configure/clean.py (revision 2465) +++ test/Configure/clean.py (working copy) @@ -39,7 +39,7 @@ env = Environment() import os env.AppendENVPath('PATH', os.environ['PATH']) -conf = Configure(env) +conf = Configure(env, clean=int(ARGUMENTS['clean'])) r1 = conf.CheckCHeader( 'math.h' ) r2 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error env = conf.Finish() @@ -65,32 +65,16 @@ "Checking for C header file no_std_c_header.h... " ] -unexpected = [] +test.run(arguments = '-c clean=0') +test.must_not_contain_lines(lines, test.stdout()) -test.run(arguments = '-c') +test.run(arguments = '-c clean=1') +test.must_contain_lines(lines, test.stdout()) -for line in lines: - if string.find(test.stdout(), line) != -1: - unexpected.append(line) +test.run(arguments = '--clean clean=0') +test.must_not_contain_lines(lines, test.stdout()) -if unexpected: - print "Unexpected lines in standard output:" - print string.join(unexpected, '\n') - print "STDOUT ============================================================" - print test.stdout() - test.fail_test() +test.run(arguments = '--clean clean=1') +test.must_contain_lines(lines, test.stdout()) -test.run(arguments = '--clean') - -for line in lines: - if string.find(test.stdout(), line) != -1: - unexpected.append(line) - -if unexpected: - print "Unexpected lines in standard output:" - print string.join(unexpected, '\n') - print "STDOUT ============================================================" - print test.stdout() - test.fail_test() - test.pass_test() Index: src/engine/SCons/Script/Main.py =================================================================== --- src/engine/SCons/Script/Main.py (revision 2465) +++ src/engine/SCons/Script/Main.py (working copy) @@ -833,12 +833,10 @@ CleanTask.execute = CleanTask.show if options.question: SCons.SConf.dryrun = 1 - if options.clean or options.help: - # If they're cleaning targets or have asked for help, replace - # the whole SCons.SConf module with a Null object so that the - # Configure() calls when reading the SConscript files don't - # actually do anything. - SCons.SConf.SConf = SCons.Util.Null + if options.clean: + SCons.SConf.SetBuildType('clean') + if options.help: + SCons.SConf.SetBuildType('help') SCons.SConf.SetCacheMode(options.config) SCons.SConf.SetProgressDisplay(progress_display) Index: src/engine/SCons/SConfTests.py =================================================================== --- src/engine/SCons/SConfTests.py (revision 2465) +++ src/engine/SCons/SConfTests.py (working copy) @@ -95,7 +95,7 @@ # 'TryLink'), so we are aware of reloading modules. def checks(self, sconf, TryFuncString): - TryFunc = self.SConf.SConf.__dict__[TryFuncString] + TryFunc = self.SConf.SConfBase.__dict__[TryFuncString] res1 = TryFunc( sconf, "int main() { return 0; }\n", ".c" ) res2 = TryFunc( sconf, '#include "no_std_header.h"\nint main() {return 0; }\n', Index: src/engine/SCons/SConf.py =================================================================== --- src/engine/SCons/SConf.py (revision 2465) +++ src/engine/SCons/SConf.py (working copy) @@ -54,6 +54,14 @@ SCons.Conftest.LogInputFiles = 0 SCons.Conftest.LogErrorMessages = 0 +# Set +build_type = None +build_types = ['clean', 'help'] + +def SetBuildType(type): + global build_type + build_type = type + # to be set, if we are in dry-run mode dryrun = 0 @@ -354,7 +362,7 @@ sconsign.set_entry(t.name, sconsign_entry) sconsign.merge() -class SConf: +class SConfBase: """This is simply a class to represent a configure context. After creating a SConf object, you can call any tests. After finished with your tests, be sure to call the Finish() method, which returns the modified @@ -603,7 +611,7 @@ def AddTest(self, test_name, test_instance): """Adds test_class to this SConf instance. It can be called with self.test_name(...)""" - setattr(self, test_name, SConf.TestWrapper(test_instance, self)) + setattr(self, test_name, SConfBase.TestWrapper(test_instance, self)) def AddTests(self, tests): """Adds all the tests given in the tests dictionary to this SConf @@ -815,6 +823,19 @@ #### End of stuff used by Conftest.py. +def SConf(*args, **kw): + if kw.get(build_type, True): + kw['_depth'] = kw.get('_depth', 0) + 1 + for bt in build_types: + try: + del kw[bt] + except KeyError: + pass + return apply(SConfBase, args, kw) + else: + return SCons.Util.Null() + + def CheckFunc(context, function_name, header = None, language = None): res = SCons.Conftest.CheckFunc(context, function_name, header = header, language = language) context.did_show_result = 1 Index: doc/man/scons.1 =================================================================== --- doc/man/scons.1 (revision 2465) +++ doc/man/scons.1 (working copy) @@ -5659,9 +5659,9 @@ The following methods can be used to perform checks: .TP -.RI Configure( env ", [" custom_tests ", " conf_dir ", " log_file ", " config_h ]) +.RI Configure( env ", [" custom_tests ", " conf_dir ", " log_file ", " config_h ", " clean ", " help]) .TP -.RI env.Configure([ custom_tests ", " conf_dir ", " log_file ", " config_h ]) +.RI env.Configure([ custom_tests ", " conf_dir ", " log_file ", " config_h ", " clean ", " help]) This creates a configure context, which can be used to perform checks. .I env specifies the environment for building the tests. @@ -5709,6 +5709,30 @@ .I config_h file is being built. +The optional +.B clean +and +.B help +arguments can be used to suppress execution of the configuration +tests when the +.B -c/--clean +or +.B -H/-h/--help +options are used, respectively. +The default behavior is always to execute +configure context tests, +since the results of the tests may +affect the list of targets to be cleaned +or the help text. +If the configure tests do not affect these, +then you may add the +.B clean=False +or +.B help=False +arguments +(or both) +to avoid unnecessary test execution. + .EE A created .B Configure --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--- End Message ---
signature.asc
Description: Digital signature

