summaryrefslogtreecommitdiff
path: root/test/CC
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2007-01-07 07:23:05 +0000
committerSteven Knight <knight@baldmt.com>2007-01-07 07:23:05 +0000
commited6878a4af79fb56fcf5564cb3aca9cbbeac4a69 (patch)
tree05e6aee9b46b530443e01bbb762b68775a6bb0ff /test/CC
parent761c99b86da4f807e30c6aaafa876eed0c0f0f3e (diff)
downloadscons-ed6878a4af79fb56fcf5564cb3aca9cbbeac4a69.tar.gz
Merged revisions 1738-1754,1756 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r1741 | stevenknight | 2006-12-16 22:51:07 -0600 (Sat, 16 Dec 2006) | 1 line 0.96.D527 - Give the f90 and f95 Tool modules knowledge of how to build source files of earlier Fortran versions. ........ r1742 | stevenknight | 2006-12-16 23:22:54 -0600 (Sat, 16 Dec 2006) | 1 line 0.96.D528 - Better handling of timestamp fallback if there's no md5 module. ........ r1743 | stevenknight | 2006-12-17 00:21:31 -0600 (Sun, 17 Dec 2006) | 1 line 0.96.D529 - Fix portability of new tests on systems that don't have TeX installed. ........ r1744 | stevenknight | 2006-12-19 15:30:16 -0600 (Tue, 19 Dec 2006) | 1 line 0.96.D530 - Eliminate the ListBuilder subclass in favor of using the Executor's target lists. ........ r1745 | stevenknight | 2006-12-19 18:54:26 -0600 (Tue, 19 Dec 2006) | 1 line 0.96.D531 - Eliminate of MultiStepBuilder as a separate Builder subclass. ........ r1746 | garyo | 2006-12-21 13:21:08 -0600 (Thu, 21 Dec 2006) | 1 line Minor doc fix, thanks to Douglas Landgraf. ........ r1747 | stevenknight | 2006-12-21 17:13:55 -0600 (Thu, 21 Dec 2006) | 1 line 0.96.D533 - Add CFLAGS for options common to C/C++. (Gary Oberbrunner) ........ r1748 | stevenknight | 2007-01-03 19:48:05 -0600 (Wed, 03 Jan 2007) | 1 line 0.96.D534 - Fix signature storage when targets are retrieved from CacheDir(). ........ r1749 | stevenknight | 2007-01-04 16:48:47 -0600 (Thu, 04 Jan 2007) | 1 line 0.96.D535 - Teach the lex and yacc tools about target files generated by different flex/bison options, and about Objective C suffixes. (Pupeno) ........ r1750 | stevenknight | 2007-01-04 17:14:38 -0600 (Thu, 04 Jan 2007) | 1 line 0.96.D536 - Refactor duplicate disambiguation logic in Entry.get_contents(). ........ r1751 | stevenknight | 2007-01-05 13:00:54 -0600 (Fri, 05 Jan 2007) | 1 line 0.96.D537 - Fix lprof regression from 0.96.92. ........ r1752 | stevenknight | 2007-01-05 20:43:48 -0600 (Fri, 05 Jan 2007) | 1 line 0.96.D538 - Fix caching of Builder suffix matching (to fix lprof regression). ........ r1753 | stevenknight | 2007-01-06 00:03:16 -0600 (Sat, 06 Jan 2007) | 1 line 0.96.D539 - Fix --include-dir when using MinGW. (Paul) ........ r1754 | stevenknight | 2007-01-06 00:24:53 -0600 (Sat, 06 Jan 2007) | 1 line 0.96.D540 - Make bootstrap.py something useful to execute SCons out of a source directory. ........ r1756 | stevenknight | 2007-01-06 21:32:11 -0600 (Sat, 06 Jan 2007) | 1 line 0.96.D541 - Update the Copyright year string to include 2007. Automate updating the month+year string in man page title headers. Fix hard-coded __revision__ strings that crept into some older tests. ........
Diffstat (limited to 'test/CC')
-rw-r--r--test/CC/CFLAGS.py113
-rw-r--r--test/CC/SHCFLAGS.py131
2 files changed, 244 insertions, 0 deletions
diff --git a/test/CC/CFLAGS.py b/test/CC/CFLAGS.py
new file mode 100644
index 00000000..f14fcc54
--- /dev/null
+++ b/test/CC/CFLAGS.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# 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, string
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+# Make sure CFLAGS is not passed to CXX by just expanding CXXCOM
+test.write('SConstruct', """
+env = Environment(CFLAGS='-xyz', CCFLAGS='-abc')
+print env.subst('$CXXCOM')
+print env.subst('$CXXCOMSTR')
+print env.subst('$SHCXXCOM')
+print env.subst('$SHCXXCOMSTR')
+""")
+test.run(arguments = '.')
+test.fail_test(string.find(test.stdout(), "-xyz") != -1)
+test.fail_test(string.find(test.stdout(), "-abc") == -1)
+
+
+# Test passing CFLAGS to C compiler by actually compiling programs
+if sys.platform == 'win32':
+ _obj = '.obj'
+ fooflags = '/nologo -DFOO'
+ barflags = '/nologo -DBAR'
+else:
+ _obj = '.o'
+ fooflags = '-DFOO'
+ barflags = '-DBAR'
+
+
+test.write('SConstruct', """
+foo = Environment(CFLAGS = '%s')
+bar = Environment(CFLAGS = '%s')
+foo.Object(target = 'foo%s', source = 'prog.c')
+bar.Object(target = 'bar%s', source = 'prog.c')
+foo.Program(target = 'foo', source = 'foo%s')
+bar.Program(target = 'bar', source = 'bar%s')
+foo.Program(target = 'prog', source = 'prog.c',
+ CFLAGS = '$CFLAGS -DBAR $BAZ', BAZ = '-DBAZ')
+""" % (fooflags, barflags, _obj, _obj, _obj, _obj))
+
+test.write('prog.c', r"""
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+#ifdef FOO
+ printf("prog.c: FOO\n");
+#endif
+#ifdef BAR
+ printf("prog.c: BAR\n");
+#endif
+#ifdef BAZ
+ printf("prog.c: BAZ\n");
+#endif
+ exit (0);
+}
+""")
+
+
+
+test.run(arguments = '.')
+
+test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n")
+test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n")
+test.run(program = test.workpath('prog'), stdout = """\
+prog.c: FOO
+prog.c: BAR
+prog.c: BAZ
+""")
+
+test.write('SConstruct', """
+bar = Environment(CFLAGS = '%s')
+bar.Object(target = 'foo%s', source = 'prog.c')
+bar.Object(target = 'bar%s', source = 'prog.c')
+bar.Program(target = 'foo', source = 'foo%s')
+bar.Program(target = 'bar', source = 'bar%s')
+""" % (barflags, _obj, _obj, _obj, _obj))
+
+test.run(arguments = '.')
+
+test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n")
+test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n")
+
+test.pass_test()
diff --git a/test/CC/SHCFLAGS.py b/test/CC/SHCFLAGS.py
new file mode 100644
index 00000000..ef20120b
--- /dev/null
+++ b/test/CC/SHCFLAGS.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# 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
+import os
+import string
+
+test = TestSCons.TestSCons()
+
+e = test.Environment()
+fooflags = e['SHCFLAGS'] + ' -DFOO'
+barflags = e['SHCFLAGS'] + ' -DBAR'
+
+if os.name == 'posix':
+ os.environ['LD_LIBRARY_PATH'] = '.'
+if string.find(sys.platform, 'irix') > -1:
+ os.environ['LD_LIBRARYN32_PATH'] = '.'
+
+test.write('SConstruct', """
+foo = Environment(SHCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
+bar = Environment(SHCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
+
+foo_obj = foo.SharedObject(target = 'foo', source = 'prog.c')
+foo.SharedLibrary(target = 'foo', source = foo_obj)
+
+bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c')
+bar.SharedLibrary(target = 'bar', source = bar_obj)
+
+fooMain = foo.Clone(LIBS='foo', LIBPATH='.')
+foomain_obj = fooMain.Object(target='foomain', source='main.c')
+fooMain.Program(target='fooprog', source=foomain_obj)
+
+barMain = bar.Clone(LIBS='bar', LIBPATH='.')
+barmain_obj = barMain.Object(target='barmain', source='main.c')
+barMain.Program(target='barprog', source=barmain_obj)
+""" % (fooflags, barflags))
+
+test.write('foo.def', r"""
+LIBRARY "foo"
+DESCRIPTION "Foo Shared Library"
+
+EXPORTS
+ doIt
+""")
+
+test.write('bar.def', r"""
+LIBRARY "bar"
+DESCRIPTION "Bar Shared Library"
+
+EXPORTS
+ doIt
+""")
+
+test.write('prog.c', r"""
+#include <stdio.h>
+
+void
+doIt()
+{
+#ifdef FOO
+ printf("prog.c: FOO\n");
+#endif
+#ifdef BAR
+ printf("prog.c: BAR\n");
+#endif
+}
+""")
+
+test.write('main.c', r"""
+
+void doIt();
+
+int
+main(int argc, char* argv[])
+{
+ doIt();
+ return 0;
+}
+""")
+
+test.run(arguments = '.')
+
+test.run(program = test.workpath('fooprog'), stdout = "prog.c: FOO\n")
+test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n")
+
+test.write('SConstruct', """
+bar = Environment(SHCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
+
+foo_obj = bar.SharedObject(target = 'foo', source = 'prog.c')
+bar.SharedLibrary(target = 'foo', source = foo_obj)
+
+bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c')
+bar.SharedLibrary(target = 'bar', source = bar_obj)
+
+barMain = bar.Clone(LIBS='bar', LIBPATH='.')
+foomain_obj = barMain.Object(target='foomain', source='main.c')
+barmain_obj = barMain.Object(target='barmain', source='main.c')
+barMain.Program(target='barprog', source=foomain_obj)
+barMain.Program(target='fooprog', source=barmain_obj)
+""" % (barflags))
+
+test.run(arguments = '.')
+
+test.run(program = test.workpath('fooprog'), stdout = "prog.c: BAR\n")
+test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n")
+
+test.pass_test()