From bda9d350b0cc52fefb2303114e20fc954710d76e Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Sat, 12 Jan 2002 19:17:54 +0000 Subject: Make the Default() method accomodate targets with white space in the file name. --- doc/man/scons.1 | 5 ++++- src/CHANGES.txt | 3 ++- src/engine/SCons/Script/SConscript.py | 4 ++-- test/Default.py | 21 +++++++++++++++++---- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 3f4af06..49c2e21 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -925,6 +925,9 @@ This specifies a list of default targets. Default targets will be built by if no explicit targets are given on the comamnd line. Multiple targets can be specified either as a space delimited string of target file names or as seperate arguments. +Target names with white space may be be enclosed in an +array to prevent the string from being split into +separate file names. .BR Default () will also accept the return value of any of the ccnstruction environment builder methods. @@ -932,7 +935,7 @@ Example: .IP .nf -Default('foo', 'bar', 'baz') +Default('foo', 'bar', 'baz', ['file with whitespace']) .PP .fi diff --git a/src/CHANGES.txt b/src/CHANGES.txt index e36ceb6..c598b1c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -12,7 +12,8 @@ RELEASE 0.04 - From Steven Knight: - - Fix using a directory as a Default(). + - Fix using a directory as a Default(), and allow Default() to + support white space in file names for strings in arrays. diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 43868b5..4208eba 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -115,8 +115,8 @@ def Default(*targets): if isinstance(t, SCons.Node.Node): default_targets.append(t) else: - for s in string.split(t): - default_targets.append(SCons.Node.FS.default_fs.Entry(s)) + default_targets.extend(SCons.Util.scons_str2nodes(t, + SCons.Node.FS.default_fs.Entry)) def Help(text): if print_help: diff --git a/test/Default.py b/test/Default.py index 1d86829..a03ff4b 100644 --- a/test/Default.py +++ b/test/Default.py @@ -32,7 +32,7 @@ python = sys.executable test = TestSCons.TestSCons() -test.subdir('one', 'two', 'three', 'four') +test.subdir('one', 'two', 'three', 'four', 'five') test.write('build.py', r""" import sys @@ -69,12 +69,21 @@ Default('foo.out bar.out') test.write(['four', 'SConstruct'], """ B = Builder(name = 'B', action = r'%s ../build.py $TARGET $SOURCES') env = Environment(BUILDERS = [B]) +env.B(target = ['foo bar'], source = 'foo.in') +env.B(target = 'foo', source = 'foo.in') +env.B(target = 'bar', source = 'bar.in') +Default(['foo bar']) +""" % python) + +test.write(['five', 'SConstruct'], """ +B = Builder(name = 'B', action = r'%s ../build.py $TARGET $SOURCES') +env = Environment(BUILDERS = [B]) Default(env.B(target = 'foo.out', source = 'foo.in')) Default(env.B(target = 'bar.out', source = 'bar.in')) """ % python) -for dir in ['one', 'two', 'three', 'four']: +for dir in ['one', 'two', 'three', 'four', 'five']: foo_in = os.path.join(dir, 'foo.in') bar_in = os.path.join(dir, 'bar.in') @@ -94,8 +103,12 @@ test.fail_test(test.read(test.workpath('two', 'bar.out')) != "two/bar.in\n") test.fail_test(test.read(test.workpath('three', 'foo.out')) != "three/foo.in\n") test.fail_test(test.read(test.workpath('three', 'bar.out')) != "three/bar.in\n") -test.fail_test(test.read(test.workpath('four', 'foo.out')) != "four/foo.in\n") -test.fail_test(test.read(test.workpath('four', 'bar.out')) != "four/bar.in\n") +test.fail_test(os.path.exists(test.workpath('four', 'foo'))) +test.fail_test(os.path.exists(test.workpath('four', 'bar'))) +test.fail_test(test.read(test.workpath('four', 'foo bar')) != "four/foo.in\n") + +test.fail_test(test.read(test.workpath('five', 'foo.out')) != "five/foo.in\n") +test.fail_test(test.read(test.workpath('five', 'bar.out')) != "five/bar.in\n") -- cgit v0.12