Merge pull request #4674 from bdbaddog/fix_2281_Aliases_ignore_pre_post_add_actions
[scons.git] / test / AR / AR.py
blobfbf45569d98e9b75165e74614b59be937d94e5aa
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 import TestSCons
29 _python_ = TestSCons._python_
30 _exe = TestSCons._exe
32 test = TestSCons.TestSCons()
34 test.file_fixture('wrapper.py')
36 test.write('SConstruct', """
37 DefaultEnvironment(tools=[])
38 foo = Environment(LIBS = ['foo'], LIBPATH = ['.'])
39 ar = foo.Dictionary('AR')
40 bar = Environment(LIBS = ['bar'], LIBPATH = ['.'], AR = r'%(_python_)s wrapper.py ' + ar)
41 foo.Library(target = 'foo', source = 'foo.c')
42 bar.Library(target = 'bar', source = 'bar.c')
44 obj = foo.Object('main', 'main.c')
46 foo.Program(target = 'f', source = obj)
47 bar.Program(target = 'b', source = obj)
48 """ % locals())
50 test.write('foo.c', r"""
51 #include <stdio.h>
53 void
54 library_function(void)
56 printf("foo.c\n");
58 """)
60 test.write('bar.c', r"""
61 #include <stdio.h>
63 void
64 library_function(void)
66 printf("bar.c\n");
68 """)
70 test.write('main.c', r"""
71 #include <stdio.h>
72 #include <stdlib.h>
74 extern void
75 library_function(void);
77 int
78 main(int argc, char *argv[])
80 argv[argc++] = "--";
81 library_function();
82 exit (0);
84 """)
87 test.run(arguments = 'f' + _exe,
88 stderr=TestSCons.noisy_ar,
89 match=TestSCons.match_re_dotall)
91 test.must_not_exist(test.workpath('wrapper.out'))
93 test.run(arguments = 'b' + _exe,
94 stderr=TestSCons.noisy_ar,
95 match=TestSCons.match_re_dotall)
97 test.must_match('wrapper.out', 'wrapper.py\n', mode='r')
99 test.pass_test()
101 # Local Variables:
102 # tab-width:4
103 # indent-tabs-mode:nil
104 # End:
105 # vim: set expandtab tabstop=4 shiftwidth=4: