diff options
author | Steven Knight <knight@baldmt.com> | 2001-09-10 23:38:55 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2001-09-10 23:38:55 (GMT) |
commit | 41a56f7c2d2faac0b6a084e591de3faa1a3e79ff (patch) | |
tree | 7aacb222c2e89cdc423842a0a137a9df30e0f862 | |
parent | 5baa0ff42fc922008a0a148bef7da73b09f0dfbd (diff) | |
download | SCons-41a56f7c2d2faac0b6a084e591de3faa1a3e79ff.zip SCons-41a56f7c2d2faac0b6a084e591de3faa1a3e79ff.tar.gz SCons-41a56f7c2d2faac0b6a084e591de3faa1a3e79ff.tar.bz2 |
Add -C support.
-rw-r--r-- | doc/man/options.sgml | 9 | ||||
-rw-r--r-- | src/scons.py | 8 | ||||
-rw-r--r-- | test/option--C.py | 48 |
3 files changed, 53 insertions, 12 deletions
diff --git a/doc/man/options.sgml b/doc/man/options.sgml index b24c18f..b88a585 100644 --- a/doc/man/options.sgml +++ b/doc/man/options.sgml @@ -111,11 +111,12 @@ <filename>Sconstruct</filename> or <filename>sconstruct</filename> file, or doing anything else. Multiple <option>-C</option> options are interpreted - relative to the previous one. (This is nearly equivalent - to <literal>-f directory/SConstruct</literal>, except - that it will search for <filename>SConstruct</filename>, + relative to the previous one, and the right-most + <option>-C</option> option wins. (This option is nearly + equivalent to <literal>-f directory/SConstruct</literal>, + except that it will search for <filename>SConstruct</filename>, <filename>Sconstruct</filename>, or - <filename>sconstruct</filename> in the directory.) + <filename>sconstruct</filename> in the specified directory.) </para> </listitem> diff --git a/src/scons.py b/src/scons.py index f624fba..66932f6 100644 --- a/src/scons.py +++ b/src/scons.py @@ -248,7 +248,13 @@ Option(func = opt_not_yet, future = 1, long = ['cache-show'], help = "Print what would have built Cached targets.") -Option(func = opt_not_yet, +def opt_C(opt, arg): + try: + os.chdir(arg) + except: + sys.stderr.write("Could not change directory to 'arg'\n") + +Option(func = opt_C, short = 'C', long = ['directory'], arg = 'DIRECTORY', help = "Change to DIRECTORY before doing anything.") diff --git a/test/option--C.py b/test/option--C.py index db3402d..d1389bb 100644 --- a/test/option--C.py +++ b/test/option--C.py @@ -10,17 +10,51 @@ test = TestCmd.TestCmd(program = 'scons.py', workdir = '', interpreter = 'python') -test.write('SConstruct', "") +wpath = test.workpath() +wpath_sub = test.workpath('sub') +wpath_sub_dir = test.workpath('sub', 'dir') -test.run(chdir = '.', arguments = '-C foo') +test.subdir('sub', ['sub', 'dir']) -test.fail_test(test.stderr() != - "Warning: the -C option is not yet implemented\n") +test.write('SConstruct', """ +import os +print "SConstruct", os.getcwd() +""") -test.run(chdir = '.', arguments = '--directory=foo') +test.write(['sub', 'SConstruct'], """ +import os +print "sub/SConstruct", os.getcwd() +""") -test.fail_test(test.stderr() != - "Warning: the --directory option is not yet implemented\n") +test.write(['sub', 'dir', 'SConstruct'], """ +import os +print "sub/dir/SConstruct", os.getcwd() +""") + +test.run(chdir = '.', arguments = '-C sub') + +test.fail_test(test.stdout() != "sub/SConstruct %s\n" % wpath_sub) +test.fail_test(test.stderr() != "") + +test.run(chdir = '.', arguments = '-C sub -C dir') + +test.fail_test(test.stdout() != "sub/dir/SConstruct %s\n" % wpath_sub_dir) +test.fail_test(test.stderr() != "") + +test.run(chdir = '.') + +test.fail_test(test.stdout() != "SConstruct %s\n" % wpath) +test.fail_test(test.stderr() != "") + +test.run(chdir = '.', arguments = '--directory=sub/dir') + +test.fail_test(test.stdout() != "sub/dir/SConstruct %s\n" % wpath_sub_dir) +test.fail_test(test.stderr() != "") + +test.run(chdir = '.', arguments = '-C %s -C %s' % (wpath_sub_dir, wpath_sub)) + +test.fail_test(test.stdout() != "sub/SConstruct %s\n" % wpath_sub) +test.fail_test(test.stderr() != "") test.pass_test() |