]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | ||
3 | # Copyright (C) 2013 Steven Watanabe | |
4 | # Distributed under the Boost Software License, Version 1.0. | |
1e59de90 TL |
5 | # (See accompanying file LICENSE.txt or copy at |
6 | # https://www.bfgroup.xyz/b2/LICENSE.txt) | |
7c673cae FG |
7 | |
8 | import BoostBuild | |
9 | import MockToolset | |
10 | ||
11 | t = BoostBuild.Tester(arguments=['toolset=mock', '--ignore-site-config', '--user-config='], pass_toolset=0) | |
12 | ||
13 | MockToolset.create(t) | |
14 | ||
15 | # Build from source | |
16 | t.write("zlib/zlib.h", 'zlib') | |
17 | t.write("zlib/deflate.c", 'deflate') | |
18 | ||
19 | t.write("Jamroot.jam", """ | |
20 | path-constant here : . ; | |
21 | using zlib : : <source>$(here)/zlib ; | |
22 | alias zlib : /zlib//zlib : : <link>static <link>shared ; | |
23 | """) | |
24 | ||
25 | MockToolset.set_expected(t, ''' | |
26 | source_file('deflate.c', 'deflate') | |
27 | action('-c -x c -I./zlib -o $deflate.o $deflate.c') | |
11fdf7f2 TL |
28 | action('-c -x c -I./zlib -DZLIB_DLL -o $deflate-shared.o $deflate.c') |
29 | action('--dll $deflate-shared.o -o $deflate.so') | |
7c673cae FG |
30 | action('--archive $deflate.o -o $deflate.a') |
31 | ''') | |
32 | ||
33 | t.run_build_system() | |
34 | t.expect_addition('bin/standalone/zlib/mock/debug/z.dll') | |
35 | t.expect_addition('bin/standalone/zlib/mock/debug/link-static/z.lib') | |
36 | ||
11fdf7f2 TL |
37 | # Build from source specified in the environment |
38 | t.rm('bin') | |
7c673cae FG |
39 | t.rm('zlib') |
40 | ||
11fdf7f2 TL |
41 | t.write("zlib root/zlib.h", 'zlib') |
42 | t.write("zlib root/deflate.c", 'deflate') | |
43 | ||
44 | t.write("Jamroot.jam", """ | |
45 | using zlib ; | |
46 | alias zlib : /zlib//zlib : : <link>static <link>shared ; | |
47 | """) | |
48 | ||
49 | MockToolset.set_expected(t, ''' | |
50 | source_file('deflate.c', 'deflate') | |
51 | action(['-c', '-x', 'c', '-I./zlib root', '-o', '$deflate.o', '$deflate.c']) | |
52 | action(['-c', '-x', 'c', '-I./zlib root', '-DZLIB_DLL', '-o', '$deflate-shared.o', '$deflate.c']) | |
53 | action('--dll $deflate-shared.o -o $deflate.so') | |
54 | action('--archive $deflate.o -o $deflate.a') | |
55 | ''') | |
56 | t.run_build_system(['-sZLIB_SOURCE=zlib root']) | |
57 | t.expect_addition('bin/standalone/zlib/mock/debug/z.dll') | |
58 | t.expect_addition('bin/standalone/zlib/mock/debug/link-static/z.lib') | |
59 | ||
60 | ||
61 | t.rm('zlib root') | |
62 | ||
7c673cae FG |
63 | # Generic definitions that aren't configuration specific |
64 | common_stuff = ''' | |
65 | source_file('test.cpp', 'test.cpp') | |
66 | source_file('main.cpp', 'int main() {}') | |
67 | source_file('zlib.h.cpp', '#include <zlib.h>\\n') | |
68 | action('-c -x c++ $main.cpp -o $main.o') | |
69 | ''' | |
70 | t.write('test.cpp', 'test.cpp') | |
71 | ||
72 | # Default initialization - static library | |
73 | t.rm('bin') | |
74 | t.write("Jamroot.jam", """ | |
75 | path-constant here : . ; | |
76 | using zlib ; | |
77 | exe test : test.cpp /zlib//zlib : : <link>static <link>shared ; | |
78 | """) | |
79 | ||
80 | MockToolset.set_expected(t, common_stuff + ''' | |
81 | action('$main.o --static-lib=z -o $config.exe') | |
82 | action('-c -x c++ $zlib.h.cpp -o $zlib.h.o') | |
83 | action('-c -x c++ $test.cpp -o $test.o') | |
84 | action('$test.o --static-lib=z -o $test') | |
85 | ''') | |
86 | t.run_build_system() | |
87 | t.expect_addition('bin/mock/debug/test.exe') | |
88 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
89 | ||
90 | # Default initialization - shared library | |
91 | t.rm('bin') | |
92 | t.write("Jamroot.jam", """ | |
93 | path-constant here : . ; | |
94 | using zlib ; | |
95 | exe test : test.cpp /zlib//zlib : : <link>static <link>shared ; | |
96 | """) | |
97 | ||
98 | MockToolset.set_expected(t, common_stuff + ''' | |
99 | action('$main.o --shared-lib=z -o $config.exe') | |
100 | action('-c -x c++ $zlib.h.cpp -o $zlib.h.o') | |
101 | action('-c -x c++ $test.cpp -o $test.o') | |
102 | action('$test.o --shared-lib=z -o $test') | |
103 | ''') | |
104 | t.run_build_system() | |
105 | t.expect_addition('bin/mock/debug/test.exe') | |
106 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
107 | ||
108 | # Initialization in explicit location - static library | |
109 | t.rm('bin') | |
110 | t.write("Jamroot.jam", """ | |
111 | path-constant here : . ; | |
112 | using zlib : : <name>myzlib <include>$(here)/zlib <search>$(here)/zlib ; | |
113 | exe test : test.cpp /zlib//zlib : : <link>static <link>shared ; | |
114 | """) | |
115 | ||
116 | t.write('zlib/zlib.h', 'zlib') | |
117 | ||
118 | MockToolset.set_expected(t, common_stuff + ''' | |
119 | action('$main.o -L./zlib --static-lib=myzlib -o $config.exe') | |
120 | action('-c -x c++ $test.cpp -I./zlib -o $test.o') | |
121 | action('$test.o -L./zlib --static-lib=myzlib -o $test') | |
122 | ''') | |
123 | t.run_build_system() | |
124 | t.expect_addition('bin/mock/debug/test.exe') | |
125 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
126 | ||
127 | # Initialization in explicit location - shared library | |
128 | t.rm('bin') | |
129 | t.write("Jamroot.jam", """ | |
130 | path-constant here : . ; | |
131 | using zlib : : <name>myzlib <include>$(here)/zlib <search>$(here)/zlib ; | |
132 | exe test : test.cpp /zlib//zlib : : <link>static <link>shared ; | |
133 | """) | |
134 | ||
135 | MockToolset.set_expected(t, common_stuff + ''' | |
136 | action('$main.o -L./zlib --shared-lib=myzlib -o $config.exe') | |
137 | action('-c -x c++ $test.cpp -I./zlib -o $test.o') | |
138 | action('$test.o -L./zlib --shared-lib=myzlib -o $test') | |
139 | ''') | |
140 | t.run_build_system() | |
141 | t.expect_addition('bin/mock/debug/test.exe') | |
142 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
143 | ||
11fdf7f2 TL |
144 | # Initialization in explicit location - both static and shared libraries |
145 | t.rm('bin') | |
146 | t.write("Jamroot.jam", """ | |
147 | path-constant here : . ; | |
148 | using zlib : : <name>myzlib <include>$(here)/zlib <search>$(here)/zlib ; | |
149 | exe test : test.cpp /zlib//zlib | |
150 | : <link>shared:<define>SHARED : <link>static <link>shared ; | |
151 | """) | |
152 | ||
153 | MockToolset.set_expected(t, common_stuff + ''' | |
154 | action('$main.o -L./zlib --static-lib=myzlib -o $config.exe') | |
155 | action('$main.o -L./zlib --shared-lib=myzlib -o $config.exe') | |
156 | action('-c -x c++ $test.cpp -I./zlib -o $test-static.o') | |
157 | action('-c -x c++ $test.cpp -I./zlib -DSHARED -o $test-shared.o') | |
158 | action('$test-static.o -L./zlib --static-lib=myzlib -o $test') | |
159 | action('$test-shared.o -L./zlib --shared-lib=myzlib -o $test') | |
160 | ''') | |
161 | t.run_build_system() | |
162 | t.expect_addition('bin/mock/debug/test.exe') | |
163 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
164 | ||
165 | # Initialization from the environment | |
166 | t.rm('bin') | |
167 | t.write('Jamroot.jam', """ | |
168 | using zlib ; | |
169 | exe test : test.cpp /zlib//zlib | |
170 | : : <link>static <link>shared ; | |
171 | """) | |
172 | t.write('zlib root/zlib.h', 'zlib') | |
173 | MockToolset.set_expected(t, common_stuff + ''' | |
174 | action(['$main.o', '-L./zlib root', '--shared-lib=myzlib', '-o', '$config.exe']) | |
175 | action(['-c', '-x', 'c++', '$test.cpp', '-I./zlib root', '-o', '$test.o']) | |
176 | action(['$test.o', '-L./zlib root', '--shared-lib=myzlib', '-o', '$test']) | |
177 | ''') | |
178 | t.run_build_system(['-sZLIB_INCLUDE=zlib root', | |
179 | '-sZLIB_LIBRARY_PATH=zlib root', | |
180 | '-sZLIB_NAME=myzlib']) | |
181 | t.expect_addition('bin/mock/debug/test.exe') | |
182 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
183 | ||
7c673cae | 184 | t.cleanup() |