[ci skip] Add note that this change may break SetOption() + ninja usage with fix
[scons.git] / test / HeaderInstall.py
blob071a0f43ff9bed28b280de6ffdaa3b70993002f0
1 #!/usr/bin/env python
2 # __COPYRIGHT__
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26 """
27 Test that dependencies in installed header files get re-scanned correctly.
28 """
30 import os.path
32 import TestSCons
34 test = TestSCons.TestSCons()
36 test.subdir('work1', ['work1', 'dist'])
38 test.write(['work1', 'SConstruct'], """
39 env = Environment(CPPPATH=['#include'])
40 Export('env')
41 SConscript('dist/SConscript')
42 libfoo = env.StaticLibrary('foo', ['foo.c'])
43 Default(libfoo)
44 """)
46 test.write(['work1', 'foo.c'], """
47 #include <h1.h>
48 """)
50 test.write(['work1', 'dist', 'SConscript'], """\
51 Import('env')
52 env.Install('#include', ['h1.h', 'h2.h', 'h3.h'])
53 """)
55 test.write(['work1', 'dist', 'h1.h'], """\
56 #include "h2.h"
57 """)
59 test.write(['work1', 'dist', 'h2.h'], """\
60 #include "h3.h"
61 """)
63 test.write(['work1', 'dist', 'h3.h'], """\
64 int foo = 3;
65 """)
67 test.run(chdir='work1', arguments=".",
68 stderr=TestSCons.noisy_ar,
69 match=TestSCons.match_re_dotall)
71 test.up_to_date(chdir = 'work1', arguments = ".")
74 test.subdir('ref', 'work2', ['work2', 'src'])
76 test.write(['work2', 'SConstruct'], """
77 env = Environment(CPPPATH=['build', r'%s'])
78 env.Install('build', 'src/in1.h')
79 env.Install('build', 'src/in2.h')
80 env.Install('build', 'src/in3.h')
81 """ % test.workpath('ref'))
83 test.write(['ref', 'in1.h'], '#define FILE "ref/in1.h"\n#include <in2.h>\n')
84 test.write(['ref', 'in2.h'], '#define FILE "ref/in2.h"\n#include <in3.h>\n')
85 test.write(['ref', 'in3.h'], '#define FILE "ref/in3.h"\n#define FOO 0\n')
87 src_in1_h = '#define FILE "src/in1.h"\n#include <in2.h>\n'
88 src_in2_h = '#define FILE "src/in2.h"\n#include <in3.h>\n'
89 src_in3_h = '#define FILE "src/in3.h"\n#define FOO 0\n'
90 test.write(['work2', 'src', 'in1.h'], src_in1_h)
91 test.write(['work2', 'src', 'in2.h'], src_in2_h)
92 test.write(['work2', 'src', 'in3.h'], src_in3_h)
94 test.run(chdir = 'work2', arguments = 'build')
96 test.must_match(['work2', 'build', 'in1.h'], src_in1_h)
97 test.must_match(['work2', 'build', 'in2.h'], src_in2_h)
98 test.must_match(['work2', 'build', 'in3.h'], src_in3_h)
100 test.up_to_date(chdir = 'work2', arguments = 'build')
102 src_in3_h = '#define FILE "src/in3.h"\n#define FOO 1\n'
103 test.write(['work2', 'src', 'in3.h'], src_in3_h)
105 test.run(chdir = 'work2', arguments = 'build', stdout=test.wrap_stdout("""\
106 Install file: "%s" as "%s"
107 """ % (os.path.join('src', 'in3.h'),
108 os.path.join('build', 'in3.h'))))
110 test.must_match(['work2', 'build', 'in1.h'], src_in1_h)
111 test.must_match(['work2', 'build', 'in2.h'], src_in2_h)
112 test.must_match(['work2', 'build', 'in3.h'], src_in3_h)
114 test.up_to_date(chdir = 'work2', arguments = 'build')
116 test.pass_test()
118 # Local Variables:
119 # tab-width:4
120 # indent-tabs-mode:nil
121 # End:
122 # vim: set expandtab tabstop=4 shiftwidth=4: