summaryrefslogtreecommitdiffstats
path: root/test/Libs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Libs')
-rw-r--r--test/Libs/LIBPATH.py175
-rw-r--r--test/Libs/LIBPREFIX.py38
-rw-r--r--test/Libs/LIBPREFIXES.py77
-rw-r--r--test/Libs/LIBS.py289
-rw-r--r--test/Libs/LIBSUFFIX.py38
-rw-r--r--test/Libs/LIBSUFFIXES.py77
-rw-r--r--test/Libs/Library.py167
-rw-r--r--test/Libs/SHLIBPREFIX.py53
-rw-r--r--test/Libs/SHLIBSUFFIX.py53
-rw-r--r--test/Libs/SharedLibrary.py285
-rw-r--r--test/Libs/SharedLibraryIxes.py261
11 files changed, 1513 insertions, 0 deletions
diff --git a/test/Libs/LIBPATH.py b/test/Libs/LIBPATH.py
new file mode 100644
index 0000000..7fd4f9b
--- /dev/null
+++ b/test/Libs/LIBPATH.py
@@ -0,0 +1,175 @@
+#!/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 TestSCons
+import sys
+import os.path
+import time
+
+_exe = TestSCons._exe
+_dll = TestSCons._dll
+dll_ = TestSCons.dll_
+
+test = TestSCons.TestSCons()
+
+test.subdir('lib1', 'lib2')
+
+prog1 = test.workpath('prog') + _exe
+prog2 = test.workpath(dll_ + 'shlib') + _dll
+
+test.write('SConstruct', """
+env1 = Environment(LIBS = [ 'foo1' ],
+ LIBPATH = [ '$FOO' ],
+ FOO='./lib1')
+
+f1 = env1.SharedObject('f1', 'f1.c')
+
+env1.Program(target = 'prog', source = 'prog.c')
+env1.Library(target = './lib1/foo1', source = f1)
+
+env2 = Environment(LIBS = 'foo2',
+ LIBPATH = '.')
+env2.SharedLibrary(target = 'shlib', source = 'shlib.c', no_import_lib = 1)
+env2.Library(target = 'foo2', source = f1)
+""")
+
+test.write('f1.c', r"""
+#include <stdio.h>
+
+void
+f1(void)
+{
+ printf("f1.c\n");
+}
+""")
+
+test.write('shlib.c', r"""
+void f1(void);
+int
+test()
+{
+ f1();
+ return 0;
+}
+""")
+
+test.write('prog.c', r"""
+#include <stdio.h>
+
+void f1(void);
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ f1();
+ printf("prog.c\n");
+ return 0;
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.run(program = prog1,
+ stdout = "f1.c\nprog.c\n")
+
+oldtime1 = os.path.getmtime(prog1)
+oldtime2 = os.path.getmtime(prog2)
+time.sleep(2)
+test.run(arguments = '.')
+
+test.fail_test(oldtime1 != os.path.getmtime(prog1))
+test.fail_test(oldtime2 != os.path.getmtime(prog2))
+
+test.write('f1.c', r"""
+#include <stdio.h>
+
+void
+f1(void)
+{
+ printf("f1.c 1\n");
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+test.run(program = prog1,
+ stdout = "f1.c 1\nprog.c\n")
+test.fail_test(oldtime2 == os.path.getmtime(prog2))
+#test.up_to_date(arguments = '.')
+# Change LIBPATH and make sure we don't rebuild because of it.
+test.write('SConstruct', """
+env1 = Environment(LIBS = [ 'foo1' ],
+ LIBPATH = [ './lib1', './lib2' ])
+
+f1 = env1.SharedObject('f1', 'f1.c')
+
+env1.Program(target = 'prog', source = 'prog.c')
+env1.Library(target = './lib1/foo1', source = f1)
+
+env2 = Environment(LIBS = 'foo2',
+ LIBPATH = Split('. ./lib2'))
+env2.SharedLibrary(target = 'shlib', source = 'shlib.c', no_import_lib = 1)
+env2.Library(target = 'foo2', source = f1)
+""")
+
+test.up_to_date(arguments = '.', stderr=None)
+
+test.write('f1.c', r"""
+#include <stdio.h>
+
+void
+f1(void)
+{
+ printf("f1.c 2\n");
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+test.run(program = prog1,
+ stdout = "f1.c 2\nprog.c\n")
+
+test.up_to_date(arguments = '.')
+
+# We need at least one file for some implementations of the Library
+# builder, notably the SGI one.
+test.write('empty.c', 'int a=0;\n')
+
+# Check that a null-string LIBPATH doesn't blow up.
+test.write('SConstruct', """
+env = Environment(LIBPATH = '')
+env.Library('foo', source = 'empty.c')
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.pass_test()
diff --git a/test/Libs/LIBPREFIX.py b/test/Libs/LIBPREFIX.py
new file mode 100644
index 0000000..a71e967
--- /dev/null
+++ b/test/Libs/LIBPREFIX.py
@@ -0,0 +1,38 @@
+#!/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 TestSCons
+
+test = TestSCons.TestSCons()
+
+test.pass_test() #XXX Short-circuit until this is implemented.
+
+test.write('SConstruct', """
+""")
+
+test.run(arguments = '.')
+
+test.pass_test()
diff --git a/test/Libs/LIBPREFIXES.py b/test/Libs/LIBPREFIXES.py
new file mode 100644
index 0000000..1e5d6c2
--- /dev/null
+++ b/test/Libs/LIBPREFIXES.py
@@ -0,0 +1,77 @@
+#!/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 os
+import sys
+import TestSCons
+
+if sys.platform == 'win32':
+ _lib = '.lib'
+else:
+ _lib = '.a'
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment(LIBPREFIX = 'xxx-',
+ LIBPREFIXES = ['xxx-'])
+lib = env.Library(target = 'foo', source = 'foo.c')
+env.Program(target = 'prog', source = ['prog.c', lib])
+""")
+
+test.write('foo.c', r"""
+#include <stdio.h>
+
+void
+foo(void)
+{
+ printf("foo.c\n");
+}
+""")
+
+test.write('prog.c', r"""
+#include <stdio.h>
+
+void foo(void);
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ foo();
+ printf("prog.c\n");
+ return 0;
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.fail_test(not os.path.exists(test.workpath('xxx-foo' + _lib)))
+
+test.run(program = test.workpath('prog'), stdout = "foo.c\nprog.c\n")
+
+test.pass_test()
diff --git a/test/Libs/LIBS.py b/test/Libs/LIBS.py
new file mode 100644
index 0000000..e9f6545
--- /dev/null
+++ b/test/Libs/LIBS.py
@@ -0,0 +1,289 @@
+#!/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 TestSCons
+import sys
+
+if sys.platform == 'win32':
+ _exe = '.exe'
+ bar_lib = 'bar.lib'
+else:
+ _exe = ''
+ bar_lib = 'libbar.a'
+
+test = TestSCons.TestSCons()
+
+test.subdir('sub1', 'sub2')
+
+foo1_exe = test.workpath('foo1' + _exe)
+foo2_exe = test.workpath('foo2' + _exe)
+foo3_exe = test.workpath('foo3' + _exe)
+foo4_exe = test.workpath('foo4' + _exe)
+foo5_exe = test.workpath('foo5' + _exe)
+slprog_exe = test.workpath('slprog' + _exe)
+
+test.write('SConstruct', """
+env = Environment(LIBS=['bar'], LIBPATH = '.')
+env.Program(target='foo1', source='foo1.c')
+env2 = Environment(LIBS=[File(r'%s')], LIBPATH = '.')
+env2.Program(target='foo2', source='foo2.c')
+env3 = Environment(LIBS='bar', LIBPATH = '.')
+env3.Program(target='foo3', source='foo3.c')
+env4 = Environment(LIBS=File(r'%s'), LIBPATH = '.')
+env4.Program(target='foo4', source='foo4.c')
+env5 = Environment(LIBS=['bar', '$UNSPECIFIED'], LIBPATH = '.')
+env5.Program(target='foo5', source='foo5.c')
+sl = env.StaticLibrary('sl.c')
+env.Program(target='slprog.c', LIBS=[sl])
+SConscript('sub1/SConscript', 'env')
+SConscript('sub2/SConscript', 'env')
+""" % (bar_lib, bar_lib))
+
+test.write(['sub1', 'SConscript'], r"""
+Import('env')
+lib = env.Library(target='bar', source=Split('bar.c baz.c'))
+env.Install('..', lib)
+""")
+
+test.write(['sub2', 'SConscript'], r"""
+Import('env')
+lib = env.Library(target='baz', source='baz.c')
+env.Install('..', lib)
+""")
+
+foo_contents = r"""
+void bar();
+void baz();
+
+int main(void)
+{
+ bar();
+ baz();
+ return 0;
+}
+"""
+
+test.write('foo1.c', foo_contents)
+test.write('foo2.c', foo_contents)
+test.write('foo3.c', foo_contents)
+test.write('foo4.c', foo_contents)
+test.write('foo5.c', foo_contents)
+
+test.write('sl.c', """\
+#include <stdio.h>
+void
+sl(void)
+{
+ printf("sl.c\\n");
+}
+""")
+
+test.write('slprog.c', """\
+#include <stdio.h>
+int
+main(int argc, char *argv[])
+{
+ sl();
+ printf("slprog.c\\n");
+ exit (0);
+}
+""")
+
+test.write(['sub1', 'bar.c'], r"""
+#include <stdio.h>
+
+void bar()
+{
+ printf("sub1/bar.c\n");
+}
+""")
+
+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");
+}
+""")
+
+# ar sometimes produces a "warning" on stderr -- ar: creating sub1/libbar.a
+test.run(arguments = '.', stderr=None)
+
+test.run(program=foo1_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
+test.run(program=foo2_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
+test.run(program=foo3_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
+test.run(program=foo4_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
+test.run(program=foo5_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
+test.run(program=slprog_exe, stdout='sl.c\nslprog.c\n')
+
+#
+test.write('SConstruct', """
+env = Environment(LIBS=['baz'])
+env.Program(target='foo1', source='foo1.c', LIBS=['$LIBS', 'bar'], LIBPATH = '.')
+SConscript('sub1/SConscript', 'env')
+SConscript('sub2/SConscript', 'env')
+""")
+
+test.run(arguments = '.')
+
+test.run(program=foo1_exe, stdout='sub1/bar.c\nsub2/baz.c\n')
+
+#
+test.write('SConstruct', """
+env = Environment(LIBS=['bar', 'baz'], LIBPATH = '.')
+env.Program(target='foo1', source='foo1.c')
+SConscript('sub1/SConscript', 'env')
+SConscript('sub2/SConscript', 'env')
+""")
+
+
+# on IRIX, ld32 prints out a warning saying that libbaz.a isn't used
+sw = 'ld32: WARNING 84 : ./libbaz.a is not used for resolving any symbol.\n'
+test.run(arguments = '.',
+ stderr='(%s|%s'%(sw, TestSCons.noisy_ar[1:]),
+ match=TestSCons.match_re_dotall)
+#test.fail_test(not test.stderr() in ['', sw])
+
+test.run(program=foo1_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
+
+#
+test.write('SConstruct', """
+env = Environment()
+env.Program(target='foo1', source='foo1.c', LIBS=['bar', 'baz'], LIBPATH = '.')
+SConscript('sub1/SConscript', 'env')
+SConscript('sub2/SConscript', 'env')
+""")
+
+test.run(arguments = '.')
+
+test.run(program=foo1_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
+
+test.write(['sub1', 'baz.c'], r"""
+#include <stdio.h>
+
+void baz()
+{
+ printf("sub1/baz.c 2\n");
+}
+""")
+
+test.run(arguments = '.',
+ stderr='(%s|%s'%(sw, TestSCons.noisy_ar[1:]),
+ match=TestSCons.match_re_dotall)
+#test.fail_test(not test.stderr() in ['', sw, TestSCons.noisy_ar])
+
+test.run(program=foo1_exe, stdout='sub1/bar.c\nsub1/baz.c 2\n')
+
+# Make sure we don't add $LIBPREFIX to library names that
+# already have the prefix on them.
+blender_exe = test.workpath('blender' + _exe)
+
+test.subdir('src', ['src', 'component1'], ['src', 'component2'])
+
+test.write('SConstruct', """\
+SConscript(['src/SConscript'])
+
+libpath = (['lib'])
+libraries = (['libtest_component2',
+ 'libtest_component1'])
+
+# To remove the dependency problem, you should rename blender to mlender.
+Program (source='main.c', target='blender', LIBS=libraries, LIBPREFIX='lib', LIBPATH=libpath, CPPPATH=['src/component2'])
+""")
+
+test.write('main.c', """\
+#include <stdlib.h>
+#include "message2.h"
+
+int main (void)
+{
+ DisplayMessage2();
+ exit (0);
+}
+""")
+
+test.write(['src', 'SConscript'], """\
+SConscript(['component1/SConscript',
+ 'component2/SConscript'])
+""")
+
+test.write(['src', 'component1', 'SConscript'], """\
+source_files = ['message1.c']
+Library (target='../../lib/libtest_component1', source=source_files, LINKFLAGS='')
+""")
+
+test.write(['src', 'component1', 'message1.c'], """\
+#include <stdio.h>
+
+void DisplayMessage1 (void)
+{
+ printf ("src/component1/message.c\\n");
+}
+""")
+
+test.write(['src', 'component1', 'message1.h'], """\
+void DisplayMessage1 (void);
+""")
+
+test.write(['src', 'component2', 'SConscript'], """\
+source_files = ['message2.c']
+include_paths = ['../component1']
+Library (target='../../lib/libtest_component2', source=source_files, CPPPATH=include_paths)
+""")
+
+test.write(['src', 'component2', 'message2.h'], """\
+void DisplayMessage2 (void);
+""")
+
+test.write(['src', 'component2', 'message2.c'], """\
+#include <stdio.h>
+#include "message1.h"
+
+void DisplayMessage2 (void)
+{
+ DisplayMessage1();
+ printf ("src/component2/hello.c\\n");
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.run(program=blender_exe,
+ stdout='src/component1/message.c\nsrc/component2/hello.c\n')
+
+test.pass_test()
diff --git a/test/Libs/LIBSUFFIX.py b/test/Libs/LIBSUFFIX.py
new file mode 100644
index 0000000..a71e967
--- /dev/null
+++ b/test/Libs/LIBSUFFIX.py
@@ -0,0 +1,38 @@
+#!/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 TestSCons
+
+test = TestSCons.TestSCons()
+
+test.pass_test() #XXX Short-circuit until this is implemented.
+
+test.write('SConstruct', """
+""")
+
+test.run(arguments = '.')
+
+test.pass_test()
diff --git a/test/Libs/LIBSUFFIXES.py b/test/Libs/LIBSUFFIXES.py
new file mode 100644
index 0000000..29cbb18
--- /dev/null
+++ b/test/Libs/LIBSUFFIXES.py
@@ -0,0 +1,77 @@
+#!/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 os
+import sys
+import TestSCons
+
+if sys.platform == 'win32':
+ lib_ = ''
+else:
+ lib_ = 'lib'
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment(LIBSUFFIX = '.xxx',
+ LIBSUFFIXES = ['.xxx'])
+lib = env.Library(target = 'foo', source = 'foo.c')
+env.Program(target = 'prog', source = ['prog.c', lib])
+""")
+
+test.write('foo.c', r"""
+#include <stdio.h>
+
+void
+foo(void)
+{
+ printf("foo.c\n");
+}
+""")
+
+test.write('prog.c', r"""
+#include <stdio.h>
+
+void foo(void);
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ foo();
+ printf("prog.c\n");
+ return 0;
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.fail_test(not os.path.exists(test.workpath(lib_ + 'foo.xxx')))
+
+test.run(program = test.workpath('prog'), stdout = "foo.c\nprog.c\n")
+
+test.pass_test()
diff --git a/test/Libs/Library.py b/test/Libs/Library.py
new file mode 100644
index 0000000..4bcb2c7
--- /dev/null
+++ b/test/Libs/Library.py
@@ -0,0 +1,167 @@
+#!/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 TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment(LIBS = [ 'foo1', 'libfoo2' ],
+ LIBPATH = [ '.' ])
+env.Library(target = 'foo1', source = 'f1.c')
+Library(target = 'libfoo2', source = Split('f2a.c f2b.c f2c.c'))
+libtgt=env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.cpp'])
+env.Program(target = 'prog', source = [ 'prog.cpp', libtgt ])
+""")
+
+test.write('f1.c', r"""
+#include <stdio.h>
+void
+f1(void)
+{
+ printf("f1.c\n");
+}
+""")
+
+test.write('f2a.c', r"""
+#include <stdio.h>
+void
+f2a(void)
+{
+ printf("f2a.c\n");
+}
+""")
+
+test.write('f2b.c', r"""
+#include <stdio.h>
+void
+f2b(void)
+{
+ printf("f2b.c\n");
+}
+""")
+
+test.write('f2c.c', r"""
+#include <stdio.h>
+void
+f2c(void)
+{
+ printf("f2c.c\n");
+}
+""")
+
+test.write('f3a.c', r"""
+#include <stdio.h>
+void
+f3a(void)
+{
+ printf("f3a.c\n");
+}
+""")
+
+test.write('f3b.c', r"""
+#include <stdio.h>
+void
+f3b(void)
+{
+ printf("f3b.c\n");
+}
+""")
+
+test.write('f3c.cpp', r"""
+#include <stdio.h>
+extern "C" void
+f3c(void)
+{
+ printf("f3c.cpp\n");
+}
+""")
+
+test.write('prog.cpp', r"""
+#include <stdio.h>
+extern "C" {
+void f1(void);
+void f2a(void);
+void f2b(void);
+void f2c(void);
+void f3a(void);
+void f3b(void);
+void f3c(void);
+}
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = (char *)"--";
+ f1();
+ f2a();
+ f2b();
+ f2c();
+ f3a();
+ f3b();
+ f3c();
+ printf("prog.c\n");
+ return 0;
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.run(program = test.workpath('prog'),
+ stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.cpp\nprog.c\n")
+
+# Tests whether you can reference libraries with substitutions.
+
+test.write('SConstruct', r"""
+# nrd = not referenced directly :)
+Library('nrd', 'nrd.c')
+p = Program('uses-nrd', 'uses-nrd.c', NRD='nrd', LIBPATH=['.'], LIBS=['$NRD'])
+Default(p)
+""")
+
+test.write('nrd.c', r"""
+#include <stdio.h>
+void nrd() {
+ puts("nrd");
+}
+""")
+
+test.write('uses-nrd.c', r"""
+void nrd();
+int main() {
+ nrd();
+ return 0;
+}
+""")
+
+test.run(stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.run(program = test.workpath('uses-nrd'),
+ stdout = "nrd\n")
+
+test.pass_test()
diff --git a/test/Libs/SHLIBPREFIX.py b/test/Libs/SHLIBPREFIX.py
new file mode 100644
index 0000000..87b92fa
--- /dev/null
+++ b/test/Libs/SHLIBPREFIX.py
@@ -0,0 +1,53 @@
+#!/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 os
+import sys
+import TestSCons
+
+_lib = TestSCons._dll
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment(SHLIBPREFIX = 'shlib-')
+env.SharedLibrary(target = 'foo', source = 'foo.c')
+""")
+
+test.write('foo.c', r"""
+#include <stdio.h>
+void
+foo(void)
+{
+ printf("foo.c\n");
+}
+""")
+
+test.run(arguments = '.')
+
+test.fail_test(not os.path.exists(test.workpath('shlib-foo' + _lib)))
+
+test.pass_test()
diff --git a/test/Libs/SHLIBSUFFIX.py b/test/Libs/SHLIBSUFFIX.py
new file mode 100644
index 0000000..dc88e3b
--- /dev/null
+++ b/test/Libs/SHLIBSUFFIX.py
@@ -0,0 +1,53 @@
+#!/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 os
+import sys
+import TestSCons
+
+dll_ = TestSCons.dll_
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment(SHLIBSUFFIX = '.shlib')
+env.SharedLibrary(target = 'foo', source = 'foo.c')
+""")
+
+test.write('foo.c', r"""
+#include <stdio.h>
+void
+foo(void)
+{
+ printf("foo.c\n");
+}
+""")
+
+test.run(arguments = '.')
+
+test.fail_test(not os.path.exists(test.workpath(dll_ + 'foo.shlib')))
+
+test.pass_test()
diff --git a/test/Libs/SharedLibrary.py b/test/Libs/SharedLibrary.py
new file mode 100644
index 0000000..f8447ca
--- /dev/null
+++ b/test/Libs/SharedLibrary.py
@@ -0,0 +1,285 @@
+#!/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 os
+import string
+import sys
+
+import TestCmd
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+import sys
+env=Environment(WINDOWS_INSERT_DEF=1)
+env2 = Environment(LIBS = [ 'foo1', 'foo2', 'foo3' ],
+ LIBPATH = [ '.' ])
+env.SharedLibrary(target = 'foo1', source = 'f1.c')
+if sys.platform == 'win32':
+ env.StaticLibrary(target = 'foo1-static', source = 'f1.c')
+else:
+ env.StaticLibrary(target = 'foo1', source = 'f1.c')
+SharedLibrary(target = 'foo2',
+ source = Split('f2a.c f2b.c f2c.c'),
+ WINDOWS_INSERT_DEF = 1)
+env.SharedLibrary(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'])
+env2.Program(target = 'prog', source = 'prog.c')
+""")
+
+test.write('SConstructFoo', """
+env=Environment()
+obj = env.Object('foo', 'foo.c')
+Default(env.SharedLibrary(target = 'foo', source = obj))
+""")
+
+test.write('SConstructFoo2', """
+env=Environment()
+obj = env.SharedObject('bar', 'foo.c')
+Default(env.Library(target = 'foo', source = obj))
+""")
+
+test.write('foo.c', r"""
+#include <stdio.h>
+
+void
+f1(void)
+{
+ printf("foo.c\n");
+ fflush(stdout);
+}
+""")
+
+
+test.write('f1.c', r"""
+#include <stdio.h>
+
+void
+f1(void)
+{
+ printf("f1.c\n");
+ fflush(stdout);
+}
+""")
+
+test.write("foo1.def", r"""
+LIBRARY "foo1"
+DESCRIPTION "Foo1 Shared Library"
+
+EXPORTS
+ f1
+""")
+
+test.write('f2a.c', r"""
+#include <stdio.h>
+
+void
+f2a(void)
+{
+ printf("f2a.c\n");
+}
+""")
+
+test.write('f2b.c', r"""
+#include <stdio.h>
+void
+f2b(void)
+{
+ printf("f2b.c\n");
+}
+""")
+
+test.write('f2c.c', r"""
+#include <stdio.h>
+
+void
+f2c(void)
+{
+ printf("f2c.c\n");
+ fflush(stdout);
+}
+""")
+
+test.write("foo2.def", r"""
+LIBRARY "foo2"
+DESCRIPTION "Foo2 Shared Library"
+
+EXPORTS
+ f2a
+ f2b
+ f2c
+""")
+
+test.write('f3a.c', r"""
+#include <stdio.h>
+void
+f3a(void)
+{
+ printf("f3a.c\n");
+}
+""")
+
+test.write('f3b.c', r"""
+#include <stdio.h>
+void
+f3b(void)
+{
+ printf("f3b.c\n");
+}
+""")
+
+test.write('f3c.c', r"""
+#include <stdio.h>
+
+void
+f3c(void)
+{
+ printf("f3c.c\n");
+ fflush(stdout);
+}
+""")
+
+test.write("foo3.def", r"""
+LIBRARY "foo3"
+DESCRIPTION "Foo3 Shared Library"
+
+EXPORTS
+ f3a
+ f3b
+ f3c
+""")
+
+test.write('prog.c', r"""
+#include <stdio.h>
+void f1(void);
+void f2a(void);
+void f2b(void);
+void f2c(void);
+void f3a(void);
+void f3b(void);
+void f3c(void);
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ f1();
+ f2a();
+ f2b();
+ f2c();
+ f3a();
+ f3b();
+ f3c();
+ printf("prog.c\n");
+ return 0;
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+if os.name == 'posix':
+ os.environ['LD_LIBRARY_PATH'] = '.'
+if string.find(sys.platform, 'irix') != -1:
+ os.environ['LD_LIBRARYN32_PATH'] = '.'
+
+test.run(program = test.workpath('prog'),
+ stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n")
+
+if sys.platform == 'win32' or string.find(sys.platform, 'irix') != -1:
+ test.run(arguments = '-f SConstructFoo')
+else:
+ test.run(arguments = '-f SConstructFoo', status=2, stderr='''\
+scons: \*\*\* Source file: foo\..* is static and is not compatible with shared target: .*
+''',
+ match=TestSCons.match_re_dotall)
+ # Run it again to make sure that we still get the error
+ # even though the static objects already exist.
+ test.run(arguments = '-f SConstructFoo', status=2, stderr='''\
+scons: \*\*\* Source file: foo\..* is static and is not compatible with shared target: .*
+''',
+ match=TestSCons.match_re_dotall)
+
+test.run(arguments = '-f SConstructFoo2',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+if sys.platform == 'win32':
+ # Make sure we don't insert a .def source file (when
+ # WINDOWS_INSERT_DEF is set) and a .lib target file if
+ # they're specified explicitly.
+
+ test.write('SConstructBar', '''
+env = Environment(WINDOWS_INSERT_DEF=1)
+env2 = Environment(LIBS = [ 'foo4' ],
+ LIBPATH = [ '.' ])
+env.SharedLibrary(target = ['foo4', 'foo4.lib'], source = ['f4.c', 'foo4.def'])
+env2.Program(target = 'progbar', source = 'progbar.c')
+''')
+
+ test.write('f4.c', r"""
+#include <stdio.h>
+
+f4(void)
+{
+ printf("f4.c\n");
+ fflush(stdout);
+}
+""")
+
+ test.write("foo4.def", r"""
+LIBRARY "foo4"
+DESCRIPTION "Foo4 Shared Library"
+
+EXPORTS
+ f4
+""")
+
+ test.write('progbar.c', r"""
+#include <stdio.h>
+void f4(void);
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ f4();
+ printf("progbar.c\n");
+ return 0;
+}
+""")
+
+ test.run(arguments = '-f SConstructBar .')
+
+ # Make sure there is (at most) one mention each of the
+ # appropriate .def and .lib files per line.
+ for line in string.split(test.stdout(), '\n'):
+ test.fail_test(string.count(line, 'foo4.def') > 1)
+ test.fail_test(string.count(line, 'foo4.lib') > 1)
+
+ test.run(program = test.workpath('progbar'),
+ stdout = "f4.c\nprogbar.c\n")
+
+test.pass_test()
diff --git a/test/Libs/SharedLibraryIxes.py b/test/Libs/SharedLibraryIxes.py
new file mode 100644
index 0000000..f9d1471
--- /dev/null
+++ b/test/Libs/SharedLibraryIxes.py
@@ -0,0 +1,261 @@
+#!/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__"
+
+"""
+Test that we can build shared libraries and link against shared
+libraries that have non-standard library prefixes and suffixes.
+"""
+
+import re
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+import sys
+isWindows = sys.platform == 'win32'
+
+env = Environment()
+
+# Make sure that the shared library can be located at runtime.
+env.Append(RPATH=['.'])
+env.Append(LIBPATH=['.'])
+
+# We first bake the LIBSUFFIXES, so that it will not change as a
+# side-effect of changing SHLIBSUFFIX.
+env['LIBSUFFIXES'] = map( env.subst, env.get('LIBSUFFIXES', []))
+
+weird_prefixes = ['libXX', 'libYY']
+
+if isWindows:
+ weird_suffixes = ['.xxx', '.yyy', '.xxx.dll', '.yyy.dll']
+ env.Append(CCFLAGS = '/MD')
+elif env['PLATFORM'] == 'darwin':
+ weird_suffixes = ['.xxx.dylib', '.yyy.dylib']
+else:
+ weird_suffixes = ['.xxx.so', '.yyy.so']
+
+shlibprefix = env.subst('$SHLIBPREFIX')
+shlibsuffix = env.subst('$SHLIBSUFFIX')
+
+progprefix = env.subst('$PROGPREFIX')
+progsuffix = env.subst('$PROGSUFFIX')
+
+goo_obj = env.SharedObject(source='goo.c')
+foo_obj = env.SharedObject(source='foo.c')
+prog_obj = env.SharedObject(source='prog.c')
+
+#
+# The following functions define all the different way that one can
+# use link againt a shared library.
+#
+def nodeInSrc(source, lib, libname):
+ return (source+lib, '')
+
+def pathInSrc(source, lib, libname):
+ return (source+map(str,lib), '')
+
+def nodeInLib(source, lib, libname):
+ return (source, lib)
+
+def pathInLib(source, lib, libname):
+ return (source, map(str,lib))
+
+def nameInLib(source, lib, libname):
+ # NOTE: libname must contain both the proper prefix and suffix.
+ #
+ # When using non-standard prefixes and suffixes, one has to
+ # provide the full name of the library since scons can not know
+ # which of the non-standard extension to use.
+ #
+ # Note that this is not necessarally SHLIBPREFIX and
+ # SHLIBSUFFIX. These are the ixes of the target library, not the
+ # ixes of the library that we are linking againt.
+ return (source, libname)
+
+libmethods = [
+ nodeInSrc, pathInSrc, nodeInLib, pathInLib,
+ nameInLib ]
+
+def buildAndlinkAgainst(builder, target, source, method, lib, libname, **kw):
+ '''Build a target using a given builder while linking againt a given
+ library using a specified method for linking against the library.'''
+
+ # On Windows, we have to link against the .lib file.
+ if isWindows:
+ for l in lib:
+ if str(l)[-4:] == '.lib':
+ lib = [l]
+ break
+ (source, LIBS) = method(source, lib, libname)
+ #build = builder(target=target, source=source, LIBS=LIBS, **kw)
+ kw = kw.copy()
+ kw['target'] = target
+ kw['source'] = source
+ kw['LIBS'] = LIBS
+ build = apply(builder, (), kw)
+
+ # Check that the build target depends on at least one of the
+ # library target.
+ found_dep = False
+ children = build[0].children()
+ for l in lib:
+ if l in children:
+ found_dep = True
+ break;
+ assert found_dep, \
+ "One of %s not found in %s, method=%s, libname=%s, shlibsuffix=%s" % \
+ (map(str,lib), map(str, build[0].children()), method.__name__, libname, shlibsuffix)
+ return build
+
+def prog(i,
+ goomethod, goolibprefix, goolibsuffix,
+ foomethod, foolibprefix, foolibsuffix):
+ '''Build a program
+
+ The program links against a shared library foo which itself links
+ against a shared library goo. The libraries foo and goo can use
+ arbitrary library prefixes and suffixes.'''
+
+ goo_name = goolibprefix+'goo'+str(i)+goolibsuffix
+ foo_name = foolibprefix+'foo'+str(i)+foolibsuffix
+ prog_name = progprefix+'prog'+str(i)+progsuffix
+
+ print 'Prog: %d, %s, %s, %s' % (i, goo_name, foo_name, prog_name)
+
+ # On Windows, we have to link against the .lib file.
+ if isWindows:
+ goo_libname = goolibprefix+'goo'+str(i)+'.lib'
+ foo_libname = foolibprefix+'foo'+str(i)+'.lib'
+ else:
+ goo_libname = goo_name
+ foo_libname = foo_name
+
+ goo_lib = env.SharedLibrary(
+ goo_name, goo_obj, SHLIBSUFFIX=goolibsuffix)
+ foo_lib = buildAndlinkAgainst(
+ env.SharedLibrary, foo_name, foo_obj,
+ goomethod, goo_lib, goo_libname, SHLIBSUFFIX=foolibsuffix)
+ prog = buildAndlinkAgainst(env.Program, prog_name, prog_obj,
+ foomethod, foo_lib, foo_libname)
+
+
+#
+# Create the list of all possible permutations to test.
+#
+i = 0
+tests = []
+prefixes = [shlibprefix] + weird_prefixes
+suffixes = [shlibsuffix] + weird_suffixes
+for foolibprefix in prefixes:
+ for foolibsuffix in suffixes:
+ for foomethod in libmethods:
+ for goolibprefix in prefixes:
+ for goolibsuffix in suffixes:
+ for goomethod in libmethods:
+ tests.append(
+ (i,
+ goomethod, goolibprefix, goolibsuffix,
+ foomethod, foolibprefix, foolibsuffix))
+ i = i + 1
+
+#
+# Pseudo-randomly choose 200 tests to run out of the possible
+# tests. (Testing every possible permutation would take too long.)
+#
+import random
+random.seed(123456)
+try:
+ random.shuffle(tests)
+except AttributeError:
+ pass
+
+for i in range(200):
+ apply(prog, tests[i])
+
+""")
+
+test.write('goo.c', r"""
+#include <stdio.h>
+
+#ifdef _WIN32
+#define EXPORT __declspec( dllexport )
+#else
+#define EXPORT
+#endif
+
+EXPORT void
+goo(void)
+{
+ printf("goo.c\n");
+}
+""")
+
+test.write('foo.c', r"""
+#include <stdio.h>
+
+#ifdef _WIN32
+#define EXPORT __declspec( dllexport )
+#else
+#define EXPORT
+#endif
+
+EXPORT void
+foo(void)
+{
+ goo();
+ printf("foo.c\n");
+}
+""")
+
+test.write('prog.c', r"""
+#include <stdio.h>
+
+void foo(void);
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ foo();
+ printf("prog.c\n");
+ return 0;
+}
+""")
+
+test.run(arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+tests = re.findall(r'Prog: (\d+), (\S+), (\S+), (\S+)', test.stdout())
+expected = "goo.c\nfoo.c\nprog.c\n"
+
+for t in tests:
+ test.must_exist(t[1])
+ test.must_exist(t[2])
+ test.must_exist(t[3])
+ test.run(program = test.workpath(t[3]), stdout=expected)
+
+test.pass_test()