diff options
author | Steven Knight <knight@baldmt.com> | 2002-03-12 21:53:24 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-03-12 21:53:24 (GMT) |
commit | a441c8d1cc8bf1ed0817b4b1deb9ff2e912bb9f0 (patch) | |
tree | 5ee2cd288a5dc2d36b8ac73483d460fd0107302a | |
parent | 50ef9e4b3dbf4f1a345297d12ffe98679c50d9d1 (diff) | |
download | SCons-a441c8d1cc8bf1ed0817b4b1deb9ff2e912bb9f0.zip SCons-a441c8d1cc8bf1ed0817b4b1deb9ff2e912bb9f0.tar.gz SCons-a441c8d1cc8bf1ed0817b4b1deb9ff2e912bb9f0.tar.bz2 |
Support whitespace separated CPPPATH, etc. (Task 49057). (Steve Leblanc)
-rw-r--r-- | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 4 | ||||
-rw-r--r-- | test/CPPPATH.py | 50 | ||||
-rw-r--r-- | test/LIBPATH.py | 45 | ||||
-rw-r--r-- | test/LIBS.py | 79 |
5 files changed, 139 insertions, 42 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b7f1e8b..46177bd 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -41,6 +41,9 @@ RELEASE 0.06 - - Add support for the -U option. + - Allow CPPPATH, LIBPATH and LIBS to be specified as white-space + separated strings. + RELEASE 0.05 - Thu, 21 Feb 2002 16:50:03 -0600 diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index d7a0253..6806c31 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -241,7 +241,9 @@ class VarInterpolator: def prepareSrc(self, dict): src = dict[self.src] - if not is_List(src): + if is_String(src): + src = string.split(src) + elif not is_List(src): src = [ src ] def prepare(x, dict=dict): diff --git a/test/CPPPATH.py b/test/CPPPATH.py index 372f6b6..958cc68 100644 --- a/test/CPPPATH.py +++ b/test/CPPPATH.py @@ -41,7 +41,7 @@ args = prog + ' ' + subdir_prog + ' ' + variant_prog test = TestSCons.TestSCons() -test.subdir('include', 'subdir', ['subdir', 'include']) +test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2') test.write('SConstruct', """ env = Environment(CPPPATH = ['include']) @@ -55,24 +55,26 @@ env = Environment(CPPPATH=[include]) SConscript('variant/SConscript', "env") """) -test.write(['subdir', 'SConscript'], """ +test.write(['subdir', 'SConscript'], +""" Import("env") env.Program(target='prog', source='prog.c') """) -test.write('include/foo.h', +test.write(['include', 'foo.h'], r""" #define FOO_STRING "include/foo.h 1\n" #include <bar.h> """) -test.write('include/bar.h', +test.write(['include', 'bar.h'], r""" #define BAR_STRING "include/bar.h 1\n" """) -test.write('subdir/prog.c', -r"""#include <foo.h> +test.write(['subdir', 'prog.c'], +r""" +#include <foo.h> #include <stdio.h> int @@ -86,13 +88,13 @@ main(int argc, char *argv[]) } """) -test.write('subdir/include/foo.h', +test.write(['subdir', 'include', 'foo.h'], r""" #define FOO_STRING "subdir/include/foo.h 1\n" #include "bar.h" """) -test.write('subdir/include/bar.h', +test.write(['subdir', 'include', 'bar.h'], r""" #define BAR_STRING "subdir/include/bar.h 1\n" """) @@ -115,8 +117,7 @@ test.fail_test(os.path.exists(test.workpath('variant', 'prog.c'))) test.up_to_date(arguments = args) -test.unlink('include/foo.h') -test.write('include/foo.h', +test.write(['include', 'foo.h'], r""" #define FOO_STRING "include/foo.h 2\n" #include "bar.h" @@ -138,9 +139,8 @@ test.fail_test(os.path.exists(test.workpath('variant', 'prog.c'))) test.up_to_date(arguments = args) - -test.unlink('include/bar.h') -test.write('include/bar.h', +# +test.write(['include', 'bar.h'], r""" #define BAR_STRING "include/bar.h 2\n" """) @@ -163,19 +163,39 @@ test.up_to_date(arguments = args) # Change CPPPATH and make sure we don't rebuild because of it. test.write('SConstruct', """ -env = Environment(CPPPATH = ['include']) +env = Environment(CPPPATH = 'inc2 include') obj = env.Object(target='prog', source='subdir/prog.c') env.Program(target='prog', source=obj) SConscript('subdir/SConscript', "env") BuildDir('variant', 'subdir', 0) include = Dir('include') -env = Environment(CPPPATH=[include]) +env = Environment(CPPPATH=['inc2', include]) SConscript('variant/SConscript', "env") """) test.up_to_date(arguments = args) +# +test.write(['inc2', 'foo.h'], +r""" +#define FOO_STRING "inc2/foo.h 1\n" +#include <bar.h> +""") + +test.run(arguments = args) + +test.run(program = test.workpath(prog), + stdout = "subdir/prog.c\ninc2/foo.h 1\ninclude/bar.h 2\n") + +test.run(program = test.workpath(subdir_prog), + stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n") + +test.run(program = test.workpath(variant_prog), + stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 2\n") + +test.up_to_date(arguments = args) + # Check that a null-string CPPPATH doesn't blow up. test.write('SConstruct', """ env = Environment(CPPPATH = '') diff --git a/test/LIBPATH.py b/test/LIBPATH.py index b2ead7a..30bc421 100644 --- a/test/LIBPATH.py +++ b/test/LIBPATH.py @@ -36,14 +36,16 @@ else: test = TestSCons.TestSCons() +test.subdir('lib1', 'lib2') + prog1 = test.workpath('prog') + _exe prog2 = test.workpath('prog2') + _exe test.write('SConstruct', """ -env = Environment(LIBS = [ 'foo1' ], - LIBPATH = [ './libs' ]) -env.Program(target = 'prog', source = 'prog.c') -env.Library(target = './libs/foo1', source = 'f1.c') +env1 = Environment(LIBS = [ 'foo1' ], + LIBPATH = [ './lib1' ]) +env1.Program(target = 'prog', source = 'prog.c') +env1.Library(target = './lib1/foo1', source = 'f1.c') env2 = Environment(LIBS = 'foo2', LIBPATH = '.') @@ -90,28 +92,49 @@ test.write('f1.c', r""" void f1(void) { - printf("f1.cnew\n"); + printf("f1.c 1\n"); } """) test.run(arguments = '.') test.run(program = prog1, - stdout = "f1.cnew\nprog.c\n") + stdout = "f1.c 1\nprog.c\n") test.run(program = prog2, - stdout = "f1.cnew\nprog.c\n") + stdout = "f1.c 1\nprog.c\n") test.up_to_date(arguments = '.') # Change LIBPATH and make sure we don't rebuild because of it. test.write('SConstruct', """ -env = Environment(LIBS = [ 'foo1' ], - LIBPATH = [ './libs', './lib2' ]) -env.Program(target = 'prog', source = 'prog.c') -env.Library(target = './libs/foo1', source = 'f1.c') +env1 = Environment(LIBS = [ 'foo1' ], + LIBPATH = [ './lib1', './lib2' ]) +env1.Program(target = 'prog', source = 'prog.c') +env1.Library(target = './lib1/foo1', source = 'f1.c') + +env2 = Environment(LIBS = 'foo2', + LIBPATH = '. ./lib2') +env2.Program(target = 'prog2', source = 'prog.c') +env2.Library(target = 'foo2', source = 'f1.c') """) test.up_to_date(arguments = '.', stderr = None) +test.write('f1.c', r""" +void +f1(void) +{ + printf("f1.c 2\n"); +} +""") + +test.run(arguments = '.') +test.run(program = prog1, + stdout = "f1.c 2\nprog.c\n") +test.run(program = prog2, + stdout = "f1.c 2\nprog.c\n") + +test.up_to_date(arguments = '.') + # Check that a null-string LIBPATH doesn't blow up. test.write('SConstruct', """ env = Environment(LIBPATH = '') diff --git a/test/LIBS.py b/test/LIBS.py index 80eadfd..6fb678a 100644 --- a/test/LIBS.py +++ b/test/LIBS.py @@ -34,45 +34,94 @@ else: test = TestSCons.TestSCons() -foo_exe = test.workpath('subdir/foo' + _exe) +test.subdir('sub1', 'sub2') + +foo_exe = test.workpath('foo' + _exe) test.write('SConstruct', """ -SConscript('subdir/SConscript') +env = Environment(LIBS=['bar'], LIBPATH = '.') +env.Program(target='foo', source='foo.c') +SConscript('sub1/SConscript', 'env') +SConscript('sub2/SConscript', 'env') +""") + +test.write(['sub1', 'SConscript'], r""" +Import('env') +lib = env.Library(target='bar', source='bar.c baz.c') +env.Install('..', lib) """) -test.subdir('subdir') +test.write(['sub2', 'SConscript'], r""" +Import('env') +lib = env.Library(target='baz', source='baz.c') +env.Install('..', lib) +""") -test.write('subdir/foo.c', r""" -void do_it(); +test.write('foo.c', r""" +void bar(); +void baz(); int main(void) { - do_it(); + bar(); + baz(); return 0; } """) -test.write('subdir/bar.c', r""" +test.write(['sub1', 'bar.c'], r""" #include <stdio.h> -void do_it() +void bar() { - printf("bar.c\n"); + printf("sub1/bar.c\n"); } """) -test.write('subdir/SConscript', r""" -env = Environment(LIBS=['bar'], LIBPATH = [ '#subdir' ]) -env.Library(target='bar', source='bar.c') -env.Program(target='foo', source='foo.c') +test.write(['sub1', 'baz.c'], r""" +#include <stdio.h> + +void baz() +{ + printf("sub1/baz.c\n"); +} +""") + +test.write(['sub2', 'baz.c'], r""" +#include <stdio.h> + +void baz() +{ + printf("sub2/baz.c\n"); +} """) test.run(arguments = '.') -test.run(program=foo_exe, stdout='bar.c\n') +test.run(program=foo_exe, stdout='sub1/bar.c\nsub1/baz.c\n') -test.pass_test() +# +test.write('SConstruct', """ +env = Environment(LIBS='baz bar', LIBPATH = '.') +env.Program(target='foo', source='foo.c') +SConscript('sub1/SConscript', 'env') +SConscript('sub2/SConscript', 'env') +""") +test.run(arguments = '.') +test.run(program=foo_exe, stdout='sub1/bar.c\nsub2/baz.c\n') +# +test.write('SConstruct', """ +env = Environment(LIBS=['bar', 'baz'], LIBPATH = '.') +env.Program(target='foo', source='foo.c') +SConscript('sub1/SConscript', 'env') +SConscript('sub2/SConscript', 'env') +""") +test.run(arguments = '.') + +test.run(program=foo_exe, stdout='sub1/bar.c\nsub1/baz.c\n') + +test.pass_test() |