diff options
author | Steven Knight <knight@baldmt.com> | 2004-05-19 17:49:55 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-05-19 17:49:55 (GMT) |
commit | 04ebe107191659f805bd63148c61c1026efeb686 (patch) | |
tree | 9122729d1120c1119fe10ff360f4675789ca8f9b /test/CPPSUFFIXES.py | |
parent | 12d2ae1193b9e32e0164218bb73240791914f976 (diff) | |
download | SCons-04ebe107191659f805bd63148c61c1026efeb686.zip SCons-04ebe107191659f805bd63148c61c1026efeb686.tar.gz SCons-04ebe107191659f805bd63148c61c1026efeb686.tar.bz2 |
Fix spurious rebuilds/reinstalls of header files and circular dependencies with generated header files by allowing Scanners to be associated explicitly with Builders, not just through Scanner file suffix lists.
Diffstat (limited to 'test/CPPSUFFIXES.py')
-rw-r--r-- | test/CPPSUFFIXES.py | 112 |
1 files changed, 100 insertions, 12 deletions
diff --git a/test/CPPSUFFIXES.py b/test/CPPSUFFIXES.py index e64dff2..a340a4a 100644 --- a/test/CPPSUFFIXES.py +++ b/test/CPPSUFFIXES.py @@ -25,43 +25,131 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -Test that we can add filesuffixes to $CPPSUFFIXES. +Test the ability to scan additional filesuffixes added to $CPPSUFFIXES. """ import TestSCons +python = TestSCons.python + test = TestSCons.TestSCons() +test.write('mycc.py', r""" +import string +import sys +def do_file(outf, inf): + for line in open(inf, 'rb').readlines(): + if line[:10] == '#include <': + do_file(outf, line[10:-2]) + else: + outf.write(line) +outf = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + do_file(outf, f) +sys.exit(0) +""") + test.write('SConstruct', """ -env = Environment(CPPPATH = ['.']) +env = Environment(CPPPATH = ['.'], + CC = r'%s mycc.py', + CCFLAGS = [], + CCCOM = '$CC $TARGET $SOURCES', + OBJSUFFIX = '.o') env.Append(CPPSUFFIXES = ['.x']) -env.InstallAs('foo_c', 'foo.c') -env.InstallAs('foo_x', 'foo.x') +env.Object(target = 'test1', source = 'test1.c') +env.InstallAs('test1_c', 'test1.c') +env.InstallAs('test1_h', 'test1.h') +env.InstallAs('test1_x', 'test1.x') +""" % (python,)) + +test.write('test1.c', """\ +test1.c 1 +#include <test1.h> +#include <test1.x> """) -test.write('foo.c', """\ +test.write('test1.h', """\ +test1.h 1 #include <foo.h> """) -test.write('foo.x', """\ +test.write('test1.x', """\ +test1.x 1 #include <foo.h> """) test.write('foo.h', "foo.h 1\n") test.run(arguments='.', stdout=test.wrap_stdout("""\ -Install file: "foo.c" as "foo_c" -Install file: "foo.x" as "foo_x" -""")) +%s mycc.py test1.o test1.c +Install file: "test1.c" as "test1_c" +Install file: "test1.h" as "test1_h" +Install file: "test1.x" as "test1_x" +""" % (python,))) + +test.must_match('test1.o', """\ +test1.c 1 +test1.h 1 +foo.h 1 +test1.x 1 +foo.h 1 +""") test.up_to_date(arguments='.') test.write('foo.h', "foo.h 2\n") test.run(arguments='.', stdout=test.wrap_stdout("""\ -Install file: "foo.c" as "foo_c" -Install file: "foo.x" as "foo_x" -""")) +%s mycc.py test1.o test1.c +""" % (python,))) + +test.must_match('test1.o', """\ +test1.c 1 +test1.h 1 +foo.h 2 +test1.x 1 +foo.h 2 +""") + +test.up_to_date(arguments='.') + +test.write('test1.x', """\ +test1.x 2 +#include <foo.h> +""") + +test.run(arguments='.', stdout=test.wrap_stdout("""\ +%s mycc.py test1.o test1.c +Install file: "test1.x" as "test1_x" +""" % (python,))) + +test.must_match('test1.o', """\ +test1.c 1 +test1.h 1 +foo.h 2 +test1.x 2 +foo.h 2 +""") + +test.up_to_date(arguments='.') + +test.write('test1.h', """\ +test1.h 2 +#include <foo.h> +""") + +test.run(arguments='.', stdout=test.wrap_stdout("""\ +%s mycc.py test1.o test1.c +Install file: "test1.h" as "test1_h" +""" % (python,))) + +test.must_match('test1.o', """\ +test1.c 1 +test1.h 2 +foo.h 2 +test1.x 2 +foo.h 2 +""") test.up_to_date(arguments='.') |