diff options
-rw-r--r-- | src/engine/SCons/Script/Main.py | 9 | ||||
-rw-r--r-- | src/engine/SCons/Script/__init__.py | 17 | ||||
-rw-r--r-- | test/option--U.py | 72 |
3 files changed, 58 insertions, 40 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 8156208..e5a8cb2 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -1080,10 +1080,11 @@ def _main(args, parser): fs.set_max_drift(ssoptions.get('max_drift')) lookup_top = None - if SCons.Script.BUILD_TARGETS: - # They specified targets on the command line, so if they - # used -u, -U or -D, we have to look up targets relative - # to the top, but we build whatever they specified. + if targets or SCons.Script.BUILD_TARGETS != SCons.Script._build_plus_default: + # They specified targets on the command line or modified + # BUILD_TARGETS in the SConscript file(s), so if they used -u, + # -U or -D, we have to look up targets relative to the top, + # but we build whatever they specified. if target_top: lookup_top = fs.Dir(target_top) target_top = None diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 734ce3f..f8f46f7 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -175,6 +175,17 @@ BUILD_TARGETS = TargetList() COMMAND_LINE_TARGETS = [] DEFAULT_TARGETS = [] +# BUILD_TARGETS can be modified in the SConscript files. If so, we +# want to treat the modified BUILD_TARGETS list as if they specified +# targets on the command line. To do that, though, we need to know if +# BUILD_TARGETS was modified through "official" APIs or by hand. We do +# this by updating two lists in parallel, the documented BUILD_TARGETS +# list, above, and this internal _build_plus_default targets list which +# should only have "official" API changes. Then Script/Main.py can +# compare these two afterwards to figure out if the user added their +# own targets to BUILD_TARGETS. +_build_plus_default = TargetList() + def _Add_Arguments(alist): for arg in alist: a, b = string.split(arg, '=', 1) @@ -187,6 +198,9 @@ def _Add_Targets(tlist): BUILD_TARGETS.extend(tlist) BUILD_TARGETS._add_Default = BUILD_TARGETS._do_nothing BUILD_TARGETS._clear = BUILD_TARGETS._do_nothing + _build_plus_default.extend(tlist) + _build_plus_default._add_Default = _build_plus_default._do_nothing + _build_plus_default._clear = _build_plus_default._do_nothing def _Set_Default_Targets_Has_Been_Called(d, fs): return DEFAULT_TARGETS @@ -209,13 +223,16 @@ def _Set_Default_Targets(env, tlist): # variables will still point to the same object we point to. del DEFAULT_TARGETS[:] BUILD_TARGETS._clear() + _build_plus_default._clear() elif isinstance(t, SCons.Node.Node): DEFAULT_TARGETS.append(t) BUILD_TARGETS._add_Default([t]) + _build_plus_default._add_Default([t]) else: nodes = env.arg2nodes(t, env.fs.Entry) DEFAULT_TARGETS.extend(nodes) BUILD_TARGETS._add_Default(nodes) + _build_plus_default._add_Default(nodes) # help_text = None diff --git a/test/option--U.py b/test/option--U.py index 45ba97c..db6532e 100644 --- a/test/option--U.py +++ b/test/option--U.py @@ -75,12 +75,12 @@ test.write('xxx.in', "xxx.in\n") test.write('SConscript', """assert GetLaunchDir() == r'%s'\n"""%test.workpath('sub1')) test.run(arguments = '-U foo.out', chdir = 'sub1') -test.fail_test(not os.path.exists(test.workpath('sub1', 'foo.out'))) -test.fail_test(os.path.exists(test.workpath('sub2', 'bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub2b', 'bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out'))) -test.fail_test(os.path.exists(test.workpath('bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub2/xxx.out'))) +test.must_exist(test.workpath('sub1', 'foo.out')) +test.must_not_exist(test.workpath('sub2', 'bar.out')) +test.must_not_exist(test.workpath('sub2b', 'bar.out')) +test.must_not_exist(test.workpath('sub3', 'baz.out')) +test.must_not_exist(test.workpath('bar.out')) +test.must_not_exist(test.workpath('sub2/xxx.out')) test.unlink(['sub1', 'foo.out']) @@ -92,26 +92,26 @@ test.run(arguments = '-U', chdir = 'sub1', stderr = "scons: *** No targets specified and no Default() targets found. Stop.\n", status = 2) -test.fail_test(os.path.exists(test.workpath('sub1', 'foo.out'))) -test.fail_test(os.path.exists(test.workpath('sub2', 'bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub2b', 'bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out'))) -test.fail_test(os.path.exists(test.workpath('bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub2/xxx.out'))) +test.must_not_exist(test.workpath('sub1', 'foo.out')) +test.must_not_exist(test.workpath('sub2', 'bar.out')) +test.must_not_exist(test.workpath('sub2b', 'bar.out')) +test.must_not_exist(test.workpath('sub3', 'baz.out')) +test.must_not_exist(test.workpath('bar.out')) +test.must_not_exist(test.workpath('sub2/xxx.out')) if sys.platform == 'win32': - test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath('SUB2')) - test.run(chdir = 'SUB2', arguments = '-U') + sub2 = 'SUB2' else: - test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath('sub2')) - test.run(chdir = 'sub2', arguments = '-U') -test.fail_test(os.path.exists(test.workpath('sub1', 'foo.out'))) -test.fail_test(not os.path.exists(test.workpath('sub2', 'bar.out'))) -test.fail_test(not os.path.exists(test.workpath('sub2b', 'bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out'))) -test.fail_test(not os.path.exists(test.workpath('bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub2/xxx.out'))) + sub2 = 'sub2' +test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath(sub2)) +test.run(chdir = sub2, arguments = '-U') +test.must_not_exist(test.workpath('sub1', 'foo.out')) +test.must_exist(test.workpath('sub2', 'bar.out')) +test.must_exist(test.workpath('sub2b', 'bar.out')) +test.must_not_exist(test.workpath('sub3', 'baz.out')) +test.must_exist(test.workpath('bar.out')) +test.must_not_exist(test.workpath('sub2/xxx.out')) test.unlink(['sub2', 'bar.out']) test.unlink(['sub2b', 'bar.out']) @@ -119,12 +119,12 @@ test.unlink('bar.out') test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath()) test.run(arguments='-U') -test.fail_test(not os.path.exists(test.workpath('sub1', 'foo.out'))) -test.fail_test(os.path.exists(test.workpath('sub2', 'bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub2b', 'bar.out'))) -test.fail_test(not os.path.exists(test.workpath('sub3', 'baz.out'))) -test.fail_test(os.path.exists(test.workpath('bar.out'))) -test.fail_test(not os.path.exists(test.workpath('sub2/xxx.out'))) +test.must_exist(test.workpath('sub1', 'foo.out')) +test.must_not_exist(test.workpath('sub2', 'bar.out')) +test.must_not_exist(test.workpath('sub2b', 'bar.out')) +test.must_exist(test.workpath('sub3', 'baz.out')) +test.must_not_exist(test.workpath('bar.out')) +test.must_exist(test.workpath('sub2/xxx.out')) test.unlink(['sub1', 'foo.out']) test.unlink(['sub3', 'baz.out']) @@ -132,12 +132,12 @@ test.unlink(['sub2', 'xxx.out']) test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath('sub3')) test.run(chdir = 'sub3', arguments='-U bar') -test.fail_test(os.path.exists(test.workpath('sub1', 'foo.out'))) -test.fail_test(not os.path.exists(test.workpath('sub2', 'bar.out'))) -test.fail_test(not os.path.exists(test.workpath('sub2b', 'bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out'))) -test.fail_test(os.path.exists(test.workpath('bar.out'))) -test.fail_test(os.path.exists(test.workpath('sub2/xxx.out'))) +test.must_not_exist(test.workpath('sub1', 'foo.out')) +test.must_exist(test.workpath('sub2', 'bar.out')) +test.must_exist(test.workpath('sub2b', 'bar.out')) +test.must_not_exist(test.workpath('sub3', 'baz.out')) +test.must_not_exist(test.workpath('bar.out')) +test.must_not_exist(test.workpath('sub2/xxx.out')) # Make sure that a Default() directory doesn't cause an exception. test.subdir('sub4') @@ -195,7 +195,7 @@ test.write(['sub6', 'dir', 'bar.in'], "bar.in\n") test.run(chdir = 'sub6/dir', arguments = '-U ../foo.out') -test.fail_test(not os.path.exists(test.workpath('sub6', 'foo.out'))) -test.fail_test(os.path.exists(test.workpath('sub6', 'dir', 'bar.out'))) +test.must_exist(test.workpath('sub6', 'foo.out')) +test.must_not_exist(test.workpath('sub6', 'dir', 'bar.out')) test.pass_test() |