[ci skip] update generated files
[scons.git] / test / AR / ARFLAGS.py
blobf1a0f98cbbdc7cf5e7d23a27b9c0e5b904aff570
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 bar = Environment(LIBS = ['bar'], LIBPATH = ['.'],
40 AR = '', ARFLAGS = foo.subst(r'%(_python_)s wrapper.py $AR $ARFLAGS'))
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 <stdlib.h>
73 extern void
74 library_function();
76 int
77 main(int argc, char *argv[])
79 argv[argc++] = "--";
80 library_function();
81 exit (0);
83 """)
86 test.run(arguments = 'f' + _exe,
87 stderr=TestSCons.noisy_ar,
88 match=TestSCons.match_re_dotall)
90 test.must_not_exist(test.workpath('wrapper.out'))
92 test.run(arguments = 'b' + _exe,
93 stderr=TestSCons.noisy_ar,
94 match=TestSCons.match_re_dotall)
96 test.must_match('wrapper.out', 'wrapper.py\n', mode='r')
98 test.pass_test()
100 # Local Variables:
101 # tab-width:4
102 # indent-tabs-mode:nil
103 # End:
104 # vim: set expandtab tabstop=4 shiftwidth=4: