From: stevenknight Date: Thu, 11 Apr 2002 22:03:57 +0000 (+0000) Subject: Change the meaning of -U, and made -D work like -U used to. (Anthony Roach) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1de2dfd8f45c84b09ef054d065559d97655d294b;p=scons.git Change the meaning of -U, and made -D work like -U used to. (Anthony Roach) git-svn-id: http://scons.tigris.org/svn/scons/trunk@329 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 543a259c..be1ded0c 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -300,6 +300,15 @@ in the specified directory.) .\" figuring out why a specific file is being rebuilt, as well as .\" general debugging of the build process. +.TP +-D +Works exactly the same way as the +.B -u +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. + .TP .RI --debug= type Debug the build process. @@ -524,6 +533,16 @@ Ignored for compatibility with GNU appear up-to-date is unnecessary when using .BR scons .) +.TP +-T +Works exactly the same way as the +.B -u +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 that are defined in the SConscript files in the current +directory are built, regardless of what directory the resulant targets end +up in. + .TP -u, --up, --search-up Walks up the directory structure until an @@ -541,8 +560,9 @@ Works exactly the same way as the .B -u 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. +all default targets that are defined in the SConscript(s) in the current +directory are built, regardless of what directory the resulant targets end +up in. .TP -v, --version diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 2207f3a2..19834947 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -49,6 +49,9 @@ RELEASE 0.07 - - Write out .sconsign files on error or interrupt so intermediate build results are saved. + - Change the -U option to -D. Make a new -U that builds just the + targets from the local SConscript file. + RELEASE 0.06 - Thu, 28 Mar 2002 01:24:29 -0600 diff --git a/src/RELEASE.txt b/src/RELEASE.txt index 41cd49bb..b3442e89 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -25,8 +25,11 @@ RELEASE 0.07 - This is the seventh alpha release of SCons. Please consult the CHANGES.txt file for a list of specific changes since last release. - Please note the following important changes since the previous - release: + Please note the following important changes since release 0.06: + + - The functionality of the -U option has changed. XXX + + Please note the following important changes since release 0.05: - Scanner functions now take four arguments. diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 813c3634..09b85be9 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -399,6 +399,14 @@ def options_init(): short = 'd', help = "Print file dependency information.") + def opt_D(opt, arg): + global climb_up + climb_up = 2 + + Option(func = opt_D, + short = 'D', + help = "Search up directory tree for SConstruct.") + def opt_debug(opt, arg): global print_tree global print_dtree @@ -596,11 +604,11 @@ def options_init(): def opt_U(opt, arg): global climb_up - climb_up = 2 + climb_up = 3 Option(func = opt_U, - short = 'U', - help = "Search up directory tree for SConstruct.") + short = 'U', + help = "Search up directory tree for SConstruct.") def option_v(opt, arg): import SCons @@ -722,7 +730,7 @@ def _main(): SCons.Script.SConscript._scons_add_args(xmit_args) if climb_up: - target_top = '' # directory to prepend to targets + target_top = '.' # directory to prepend to targets script_dir = os.getcwd() # location of script while script_dir and not _SConstruct_exists(script_dir): script_dir, last_part = os.path.split(script_dir) @@ -782,11 +790,18 @@ def _main(): sys.exit(0) if target_top: + target_top = SCons.Node.FS.default_fs.Dir(target_top) + if climb_up == 2 and not targets: + # -D with default targets + target_top = None + elif climb_up == 3 and not targets: # -U with default targets + default_targets = SCons.Script.SConscript.default_targets + default_targets = filter(lambda x: x.cwd.srcpath == str(target_top), + default_targets) + SCons.Script.SConscript.default_targets = default_targets target_top = None - else: - target_top = SCons.Node.FS.default_fs.Dir(target_top) if not targets: targets = SCons.Script.SConscript.default_targets diff --git a/test/option--D.py b/test/option--D.py new file mode 100644 index 00000000..572cd658 --- /dev/null +++ b/test/option--D.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001, 2002 Steven Knight +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# 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 sys +import TestSCons + +python = sys.executable + +test = TestSCons.TestSCons() + +test.subdir('sub1', 'sub2') + +test.write('build.py', r""" +import sys +contents = open(sys.argv[2], 'rb').read() +file = open(sys.argv[1], 'wb') +file.write(contents) +file.close() +""") + +test.write('SConstruct', """ +B = Builder(name='B', action='%s build.py $TARGET $SOURCES') +env = Environment(BUILDERS = [B]) +env.B(target = 'sub1/foo.out', source = 'sub1/foo.in') +Export('env') +SConscript('sub1/SConscript') +SConscript('sub2/SConscript') +""" % python) + +test.write(['sub1', 'SConscript'], """ +Import('env') +env.B(target = 'foo.out', source = 'foo.in') +Default('.') +""") + +test.write(['sub1', 'foo.in'], "sub1/foo.in") + +test.write(['sub2', 'SConscript'], """ +Import('env') +env.B(target = 'bar.out', source = 'bar.in') +Default('.') +""") + +test.write(['sub2', 'bar.in'], "sub2/bar.in") + +test.run(arguments = '-D', chdir = 'sub1') + +test.fail_test(test.read(['sub1', 'foo.out']) != "sub1/foo.in") +test.fail_test(test.read(['sub2', 'bar.out']) != "sub2/bar.in") + +test.pass_test() + diff --git a/test/option--U.py b/test/option--U.py index b2e9b44a..128e6c10 100644 --- a/test/option--U.py +++ b/test/option--U.py @@ -24,14 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os.path import sys -import TestSCons -python = sys.executable +import TestSCons test = TestSCons.TestSCons() -test.subdir('sub1', 'sub2') +python = sys.executable + +test.subdir('sub1', 'sub2', 'sub3') test.write('build.py', r""" import sys @@ -44,31 +46,65 @@ file.close() test.write('SConstruct', """ B = Builder(name='B', action='%s build.py $TARGET $SOURCES') env = Environment(BUILDERS = [B]) -env.B(target = 'sub1/foo.out', source = 'sub1/foo.in') +Default(env.B(target = 'sub1/foo.out', source = 'sub1/foo.in')) Export('env') -SConscript('sub1/SConscript') SConscript('sub2/SConscript') +Default(env.B(target = 'sub3/baz.out', source = 'sub3/baz.in')) +BuildDir('sub2b', 'sub2') +SConscript('sub2b/SConscript') +Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in')) """ % python) -test.write(['sub1', 'SConscript'], """ +test.write(['sub2', 'SConscript'], """ Import('env') -env.B(target = 'foo.out', source = 'foo.in') -Default('.') +Default(env.B(target = 'bar.out', source = 'bar.in')) +Default(env.B(target = '../bar.out', source = 'bar.in')) """) -test.write(['sub1', 'foo.in'], "sub1/foo.in") -test.write(['sub2', 'SConscript'], """ -Import('env') -env.B(target = 'bar.out', source = 'bar.in') -Default('.') -""") +test.write(['sub1', 'foo.in'], "sub1/foo.in\n") +test.write(['sub2', 'bar.in'], "sub2/bar.in\n") +test.write(['sub3', 'baz.in'], "sub3/baz.in\n") +test.write('xxx.in', "xxx.in\n") + +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.write(['sub2', 'bar.in'], "sub2/bar.in") +test.unlink(['sub1', 'foo.out']) test.run(arguments = '-U', chdir = 'sub1') +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.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'))) + +test.unlink(['sub2', 'bar.out']) +test.unlink(['sub2b', 'bar.out']) +test.unlink('bar.out') + +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.fail_test(test.read(['sub1', 'foo.out']) != "sub1/foo.in") -test.fail_test(test.read(['sub2', 'bar.out']) != "sub2/bar.in") test.pass_test()