1 | # Copyright 2001 Dave Abrahams |
---|
2 | # Distributed under the Boost Software License, Version 1.0. |
---|
3 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
---|
4 | |
---|
5 | # assert_equal a : b |
---|
6 | # |
---|
7 | # exits with an assertion failure if a != b |
---|
8 | rule assert_equal |
---|
9 | { |
---|
10 | if $(<) != $(>) |
---|
11 | { |
---|
12 | EXIT "assertion failure: [" $(<) "] != [" $(>) "]" ; |
---|
13 | } |
---|
14 | } |
---|
15 | |
---|
16 | rule assert_equal_sets |
---|
17 | { |
---|
18 | if ! [ equal-sets $(<) : $(>) ] |
---|
19 | { |
---|
20 | EXIT "assertion failure: [" $(<) "] !=(set) [" $(>) "]" ; |
---|
21 | } |
---|
22 | } |
---|
23 | |
---|
24 | # FAppendSuffix |
---|
25 | assert_equal [ FAppendSuffix yacc lex foo.bat : ] : yacc lex foo.bat ; |
---|
26 | assert_equal [ FAppendSuffix yacc lex foo.bat : .exe ] : yacc.exe lex.exe foo.bat ; |
---|
27 | assert_equal [ FAppendSuffix yacc lex foo.bat : .dll .lib ] : yacc.dll yacc.lib lex.dll lex.lib foo.bat foo.lib ; |
---|
28 | |
---|
29 | # sort |
---|
30 | assert_equal [ sort 7 3 5 6 2 4 ] : 2 3 4 5 6 7 ; |
---|
31 | |
---|
32 | # min |
---|
33 | assert_equal [ min 7 3 5 6 2 4 ] : 2 ; |
---|
34 | |
---|
35 | # difference |
---|
36 | assert_equal [ difference 0 1 2 3 4 5 6 7 8 9 : 2 3 5 7 ] : 0 1 4 6 8 9 ; |
---|
37 | |
---|
38 | # replace |
---|
39 | assert_equal [ replace 1 3 5 7 7 9 2 5 4 3 1 : 7 x ] : 1 3 5 x x 9 2 5 4 3 1 ; |
---|
40 | |
---|
41 | # select-ungristed |
---|
42 | assert_equal [ select-ungristed <a>b c <d>e f ] : c f ; |
---|
43 | |
---|
44 | # split-qualified-property |
---|
45 | assert_equal [ split-qualified-property <feature>value ] |
---|
46 | : <*> <*> <feature>value ; |
---|
47 | |
---|
48 | assert_equal [ split-qualified-property <variant><feature>value ] |
---|
49 | : <*> <variant> <feature>value ; |
---|
50 | |
---|
51 | assert_equal [ split-qualified-property <toolset><variant><feature>value ] |
---|
52 | : <toolset> <variant> <feature>value ; |
---|
53 | |
---|
54 | # unique |
---|
55 | assert_equal [ unique 0 1 2 3 1 7 6 6 4 5 ] : 0 1 2 3 7 6 4 5 ; |
---|
56 | |
---|
57 | # get-properties |
---|
58 | assert_equal [ get-properties <foo> <bar> : <foo>bar <foo>baz <bar>fight <baz>niss ] |
---|
59 | : <foo>bar <foo>baz <bar>fight ; |
---|
60 | |
---|
61 | # get-values |
---|
62 | assert_equal [ get-values <foo> : <foo>bar <foo>baz <bar>fight <baz>niss ] : bar baz ; |
---|
63 | |
---|
64 | # normalize-properties |
---|
65 | assert_equal [ normalize-properties <a>b <c><d>e <f><g><h>i ] : |
---|
66 | <*><*><a>b <*><c><d>e <f><g><h>i ; |
---|
67 | |
---|
68 | # intersection |
---|
69 | assert_equal [ intersection 1 2 2 3 3 4 5 6 7 : 5 1 3 7 3 9 11 ] : 1 3 3 5 7 ; |
---|
70 | |
---|
71 | # is-subset |
---|
72 | assert_equal [ is-subset a b c : c a b d ] : true ; |
---|
73 | assert_equal [ is-subset a b z : c a b d ] : ; |
---|
74 | |
---|
75 | # split-path |
---|
76 | assert_equal [ split-path <a>b/c/<d>e ] : <a>b c <d>e ; |
---|
77 | assert_equal [ split-path <a>/<d>/<e> ] : <a> <d> <e> ; |
---|
78 | assert_equal [ split-path <a> ] : <a> ; |
---|
79 | assert_equal [ split-path x ] : x ; |
---|
80 | assert_equal [ split-path $(DOT) ] : $(DOT) ; |
---|
81 | assert_equal [ split-path a/b.c/d.e/f ] : a b.c d.e f ; |
---|
82 | if $(NT) |
---|
83 | { |
---|
84 | assert_equal [ split-path x:\\y\\z\\w ] : x: y z w ; |
---|
85 | assert_equal [ split-path x:\\y\\z ] : x: y z ; |
---|
86 | assert_equal [ split-path x:\\y ] : x: y ; |
---|
87 | assert_equal [ split-path x:\\ ] : x: ; |
---|
88 | assert_equal [ split-path x: ] : x: ; |
---|
89 | } |
---|
90 | |
---|
91 | # distribute-feature |
---|
92 | assert_equal [ distribute-feature <feature>value1 ] : <feature>value1 ; |
---|
93 | assert_equal [ distribute-feature <feature>value1/value2 ] : <feature>value1 <feature>value2 ; |
---|
94 | assert_equal [ distribute-feature <feature>value1/value2/value3 ] : <feature>value1 <feature>value2 <feature>value3 ; |
---|
95 | |
---|
96 | # segregate-free-properties |
---|
97 | { |
---|
98 | local gFREE_FEATURES = <a> <c> <e> ; |
---|
99 | local x = <a>b <b>c <d>e ; |
---|
100 | local y = <a>b <a>c <b>c <e>f ; |
---|
101 | local free = [ segregate-free-properties x y ] ; |
---|
102 | assert_equal $(free) : <a>b <a>c <e>f ; |
---|
103 | assert_equal $(x) : <b>c <d>e ; |
---|
104 | assert_equal $(y) : <b>c ; |
---|
105 | } |
---|
106 | |
---|
107 | # set-insert |
---|
108 | { |
---|
109 | local gTEST_SET = 1 2 3 ; |
---|
110 | set-insert gTEST_SET : 2 ; |
---|
111 | assert_equal $(gTEST_SET) : 1 2 3 ; |
---|
112 | set-insert gTEST_SET : 0 ; |
---|
113 | assert_equal $(gTEST_SET) : 1 2 3 0 ; |
---|
114 | } |
---|
115 | |
---|
116 | # equal-sets |
---|
117 | assert_equal [ equal-sets 1 2 3 : 3 2 2 1 ] : true ; |
---|
118 | assert_equal [ equal-sets 1 2 3 3 : 3 2 2 1 ] : true ; |
---|
119 | assert_equal [ equal-sets 1 2 3 3 4 : 3 2 2 1 ] : ; |
---|
120 | |
---|
121 | # segregate-overrides |
---|
122 | { |
---|
123 | local base = <a>b <c>d <e>f ; |
---|
124 | local overrides = <a>b <c>c <d>e <f>g ; |
---|
125 | segregate-overrides overrides : base ; |
---|
126 | assert_equal $(overrides) : <c>c <d>e <f>g ; |
---|
127 | assert_equal $(base) : <a>b <e>f ; |
---|
128 | } |
---|
129 | |
---|
130 | # select-properties |
---|
131 | { |
---|
132 | local TOOLS = gcc msvc ; |
---|
133 | |
---|
134 | local gRELEVANT_FEATURES(msvc) = <debug-symbols> <optimization> <inlining> <inline> <runtime-build> <runtime-link> <threading> <define> <undef> <include> <target-type> ; |
---|
135 | local gRELEVANT_FEATURES(gcc) = <runtime-link> <debug-symbols> <optimization> <inlining> <profiling> <define> <undef> <include> <shared-linkable> <target-type> ; |
---|
136 | local gFREE_FEATURES = <define> <undef> <include> ; |
---|
137 | |
---|
138 | local gBASE_PROPERTIES(msvc,debug) = <debug-symbols>on <inlining>off <optimization>off <runtime-build>debug <threading>single ; |
---|
139 | local gBASE_PROPERTIES(gcc,debug) = <debug-symbols>on <inlining>off <optimization>off <profiling>off <shared-linkable>false ; |
---|
140 | local gBASE_PROPERTIES(msvc,release) = <debug-symbols>off <define>NDEBUG <inlining>full <optimization>speed <runtime-build>release <threading>single ; |
---|
141 | local gBASE_PROPERTIES(gcc,release) = <debug-symbols>off <define>NDEBUG <inlining>full <optimization>speed <profiling>off <shared-linkable>false ; |
---|
142 | |
---|
143 | local TEST_PROPERTIES = <inlining>off <define>FOO <*><release><inlining>on |
---|
144 | <debug><define>DEBUG <msvc><release><foo>bar |
---|
145 | <gcc><*><inlining>on |
---|
146 | <msvc><*><foo>baz |
---|
147 | <msvc><release><optimization>speed |
---|
148 | <msvc><*><optimization>off |
---|
149 | <*><debug><optimization>off |
---|
150 | ; |
---|
151 | |
---|
152 | assert_equal_sets [ select-properties gcc debug my-target : $(TEST_PROPERTIES) ] |
---|
153 | : <define>FOO <define>DEBUG <inlining>on <optimization>off ; |
---|
154 | |
---|
155 | assert_equal_sets [ select-properties gcc release my-target : $(TEST_PROPERTIES) ] |
---|
156 | : <define>FOO <inlining>on ; |
---|
157 | |
---|
158 | assert_equal_sets [ select-properties msvc debug my-target : $(TEST_PROPERTIES) ] |
---|
159 | : <define>FOO <define>DEBUG <inlining>off <optimization>off ; |
---|
160 | |
---|
161 | assert_equal_sets [ select-properties msvc release my-target : $(TEST_PROPERTIES) ] |
---|
162 | : <define>FOO <inlining>on <optimization>speed ; |
---|
163 | } |
---|
164 | |
---|
165 | |
---|
166 | # ungrist-properties |
---|
167 | feature TEST_FEATURE1 : a b ; |
---|
168 | feature TEST_FEATURE2 : c d ; |
---|
169 | assert_equal [ ungrist-properties <TEST_FEATURE1>a <TEST_FEATURE2>c ] |
---|
170 | : TEST_FEATURE1-a TEST_FEATURE2-c ; |
---|
171 | |
---|
172 | |
---|
173 | # fixup-path-properties |
---|
174 | { |
---|
175 | local RELATIVE_SUBDIR = foobar ; |
---|
176 | local gPATH_FEATURES = <include> ; |
---|
177 | assert_equal [ fixup-path-properties <a>b <include>.. <c>d ] |
---|
178 | : <include>foobar$(SLASH).. <a>b <c>d ; |
---|
179 | } |
---|
180 | # multiply-property-sets |
---|
181 | assert_equal [ multiply-property-sets <b>1 <a>2/3 <c>4/5 ] |
---|
182 | : <a>2/<b>1/<c>4 <a>2/<b>1/<c>5 <a>3/<b>1/<c>4 <a>3/<b>1/<c>5 ; |
---|
183 | |
---|
184 | # make-path-property-sets |
---|
185 | { |
---|
186 | local gUNGRISTED(<a>) = a ; |
---|
187 | local gUNGRISTED(<c>) = c ; |
---|
188 | local gUNGRISTED(<e>) = e ; |
---|
189 | local gUNGRISTED(<g>) = g ; |
---|
190 | local gUNGRISTED(<i>) = i ; |
---|
191 | assert_equal [ make-path-property-sets foo$(SLASH)bar : <a>b <c>d : <e>f$(SLASH)<g>h <i>j ] |
---|
192 | : foo$(SLASH)bar$(SLASH)e-f$(SLASH)g-h$(SLASH)<a>b$(SLASH)<c>d$(SLASH)<e>f$(SLASH)<g>h foo$(SLASH)bar$(SLASH)i-j$(SLASH)<a>b$(SLASH)<c>d$(SLASH)<i>j ; |
---|
193 | assert_equal [ make-path-property-sets foo$(SLASH)bar : <a>b <c>d : ] |
---|
194 | : foo$(SLASH)bar$(SLASH)<a>b$(SLASH)<c>d ; |
---|
195 | } |
---|
196 | |
---|
197 | |
---|
198 | # split-path-at-grist |
---|
199 | assert_equal |
---|
200 | [ split-path-at-grist <a>b$(SLASH)c$(SLASH)<d>e$(SLASH)<f>g$(SLASH)h$(SLASH)i ] |
---|
201 | : <a>b$(SLASH)c <d>e <f>g$(SLASH)h$(SLASH)i ; |
---|
202 | assert_equal |
---|
203 | [ split-path-at-grist b$(SLASH)c$(SLASH)<d>e$(SLASH)<f>g$(SLASH)h$(SLASH)i ] |
---|
204 | : b$(SLASH)c <d>e <f>g$(SLASH)h$(SLASH)i ; |
---|
205 | if $(NT) |
---|
206 | { |
---|
207 | assert_equal |
---|
208 | [ split-path-at-grist b\\c\\<include>e:\\f\\g\\<h>i ] |
---|
209 | : b\\c <include>e:\\f\\g <h>i ; |
---|
210 | } |
---|
211 | # directory-of |
---|
212 | assert_equal [ directory-of a$(SLASH)b c d$(SLASH)e$(SLASH)f ] : a . d$(SLASH)e ; |
---|
213 | |
---|
214 | # top-relative-tokens |
---|
215 | { |
---|
216 | local SUBDIR_TOKENS = a b c ; |
---|
217 | assert_equal [ top-relative-tokens ..$(SLASH)d$(SLASH)e ] : a b d e ; |
---|
218 | } |
---|
219 | |
---|
220 | # flags |
---|
221 | { |
---|
222 | local gBUILD_PROPERTIES = <a>b <c>d <e>f ; |
---|
223 | local FLAGS1 FLAGS2 FLAGS3 ; |
---|
224 | flags toolset FLAGS1 <a>b/<c>d <a>b/<e>f <x>y <a>/<c> <e> : foobar ; |
---|
225 | assert_equal $(FLAGS1) : foobar b d f ; |
---|
226 | flags toolset FLAGS2 <a> : foobar ; |
---|
227 | assert_equal $(FLAGS2) : b ; |
---|
228 | flags toolset FLAGS1 <a>b/<c>d <a>b/<e>f : foobar ; |
---|
229 | assert_equal $(FLAGS1) : foobar b d f foobar ; |
---|
230 | } |
---|
231 | |
---|
232 | # get-BUILD |
---|
233 | { |
---|
234 | local DEFAULT_BUILD = a ; |
---|
235 | local BUILD = b ; |
---|
236 | assert_equal [ get-BUILD c <d>e ] : b ; |
---|
237 | BUILD = ; |
---|
238 | assert_equal [ get-BUILD c <d>e ] : c <d>e ; |
---|
239 | assert_equal [ get-BUILD ] : a ; |
---|
240 | assert_equal [ get-BUILD <d>e ] : <d>e a ; |
---|
241 | BUILD = <f>g ; |
---|
242 | assert_equal [ get-BUILD c <d>e ] : <f>g a ; |
---|
243 | } |
---|
244 | |
---|
245 | # strip-initial |
---|
246 | assert_equal [ strip-initial a b c : a b c d e f g ] : d e f g ; |
---|
247 | assert_equal [ strip-initial a b c : a b d e f g ] : a b d e f g ; |
---|
248 | assert_equal [ strip-initial a b c : b d e f g ] : b d e f g ; |
---|
249 | assert_equal [ strip-initial a b c : ] : ; |
---|
250 | |
---|
251 | # simplify-path-tokens |
---|
252 | { |
---|
253 | local $(gTOP)_TOKENS = .. .. .. ; |
---|
254 | local gINVOCATION_SUBDIR_TOKENS = d e ; |
---|
255 | assert_equal [ simplify-path-tokens a b . c .. .. d e ] : a d e ; |
---|
256 | assert_equal [ simplify-path-tokens a b .. .. .. d e ] : .. d e ; |
---|
257 | assert_equal [ simplify-path-tokens .. .. d e : xxx ] : .. .. d e ; |
---|
258 | assert_equal [ simplify-path-tokens a b .. .. : xxx ] : xxx ; |
---|
259 | $(gTOP)_TOKENS = .. .. ; |
---|
260 | assert_equal [ simplify-path-tokens .. .. d e : xxx ] : xxx ; |
---|
261 | assert_equal [ simplify-path-tokens .. .. d e f g : xxx ] : f g ; |
---|
262 | } |
---|