1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
{ "test":
{ "doc":
[ "A test written in C++"
, "FIXME: the test binary and data must be built for host"
]
, "tainted": ["test"]
, "target_fields": ["srcs", "private-hdrs", "deps", "data"]
, "string_fields": ["name", "stage"]
, "config_vars": ["CXX", "CC", "CXXFLAGS", "CFLAGS", "ENV"]
, "implicit":
{ "defaults": [["./", "..", "defaults"]]
, "proto-deps": []
, "runner": ["test_runner.sh"]
}
, "field_doc":
{ "name":
[ "The name of the test"
, ""
, "Used to name the test binary as well as for staging the test result"
]
, "srcs": ["The sources of the test binary"]
, "private-hdrs":
[ "Any additional header files that need to be present when compiling"
, "the test binary."
]
, "stage":
[ "The logical location of all header and source files."
, "Individual directory components are joined with \"/\"."
]
, "data": ["Any files the test binary needs access to when running"]
}
, "config_doc":
{ "CXX": ["The name of the C++ compiler to be used."]
, "ENV": ["The environment for any action generated."]
, "CXXFLAGS":
[ "The flags for CXX to be used instead of the default ones"
, "taken from the [\"CC\", \"defaults\"] target"
]
}
, "imports":
{ "artifacts": ["./", "../..", "field_artifacts"]
, "compile-deps": ["./", "..", "compile-deps"]
, "link-deps": ["./", "..", "link-deps"]
, "objects": ["./", "..", "objects"]
, "default-CXX": ["./", "..", "default-CXX"]
, "default-CXXFLAGS": ["./", "..", "default-CXXFLAGS"]
, "default-ENV": ["./", "..", "default-ENV"]
}
, "expression":
{ "type": "let*"
, "bindings":
[ [ "stage"
, { "type": "join"
, "separator": "/"
, "$1": {"type": "FIELD", "name": "stage"}
}
]
, [ "srcs"
, { "type": "to_subdir"
, "subdir": {"type": "var", "name": "stage"}
, "$1":
{ "type": "let*"
, "bindings": [["fieldname", "srcs"]]
, "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
}
}
]
, [ "local hdrs"
, { "type": "to_subdir"
, "subdir": {"type": "var", "name": "stage"}
, "$1":
{ "type": "let*"
, "bindings": [["fieldname", "private-hdrs"]]
, "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
}
}
]
, [ "CXX"
, { "type": "var"
, "name": "CXX"
, "default": {"type": "CALL_EXPRESSION", "name": "default-CXX"}
}
]
, [ "CXXFLAGS"
, { "type": "var"
, "name": "CXXFLAGS"
, "default": {"type": "CALL_EXPRESSION", "name": "default-CXXFLAGS"}
}
]
, [ "ENV"
, { "type": "map_union"
, "$1":
{ "type": "++"
, "$1":
[ {"type": "CALL_EXPRESSION", "name": "default-ENV"}
, [ { "type": "var"
, "name": "ENV"
, "default": {"type": "empty_map"}
}
]
]
}
}
]
, ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
, ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
, ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}]
, [ "base name"
, { "type": "assert_non_empty"
, "msg": "A non-empy name has to be provided"
, "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}}
}
]
, [ "binary name"
, { "type": "if"
, "cond": {"type": "var", "name": "stage"}
, "else": {"type": "var", "name": "base name"}
, "then":
{ "type": "join"
, "separator": "/"
, "$1":
[ {"type": "var", "name": "stage"}
, {"type": "var", "name": "base name"}
]
}
}
]
, [ "link-args"
, { "type": "nub_right"
, "$1":
{ "type": "++"
, "$1":
[ {"type": "keys", "$1": {"type": "var", "name": "objects"}}
, { "type": "++"
, "$1":
{ "type": "foreach"
, "var": "dep"
, "range": {"type": "FIELD", "name": "deps"}
, "body":
{ "type": "DEP_PROVIDES"
, "dep": {"type": "var", "name": "dep"}
, "provider": "link-args"
}
}
}
]
}
}
]
, [ "binary"
, { "type": "ACTION"
, "outs": [{"type": "var", "name": "binary name"}]
, "inputs":
{ "type": "disjoint_map_union"
, "$1":
[ {"type": "var", "name": "objects"}
, {"type": "var", "name": "link-deps"}
]
}
, "cmd":
{ "type": "++"
, "$1":
[ [ {"type": "var", "name": "CXX"}
, "-o"
, {"type": "var", "name": "binary name"}
]
, {"type": "var", "name": "link-args"}
]
}
, "env": {"type": "var", "name": "ENV"}
}
]
, [ "staged test binary"
, { "type": "map_union"
, "$1":
{ "type": "foreach_map"
, "range": {"type": "var", "name": "binary"}
, "var_val": "binary"
, "body":
{ "type": "singleton_map"
, "key": "test"
, "value": {"type": "var", "name": "binary"}
}
}
}
]
, [ "runner"
, { "type": "map_union"
, "$1":
{ "type": "foreach"
, "var": "runner"
, "range": {"type": "FIELD", "name": "runner"}
, "body":
{ "type": "map_union"
, "$1":
{ "type": "foreach"
, "var": "runner"
, "range":
{ "type": "values"
, "$1":
{ "type": "DEP_ARTIFACTS"
, "dep": {"type": "var", "name": "runner"}
}
}
, "body":
{ "type": "singleton_map"
, "key": "runner.sh"
, "value": {"type": "var", "name": "runner"}
}
}
}
}
}
]
, [ "data"
, { "type": "disjoint_map_union"
, "msg": "Data runfiles may not conflict"
, "$1":
{ "type": "foreach"
, "var": "dep"
, "range": {"type": "FIELD", "name": "data"}
, "body":
{"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "dep"}}
}
}
]
, [ "test-results"
, { "type": "ACTION"
, "outs": ["result", "stdout", "stderr", "time-start", "time-stop"]
, "inputs":
{ "type": "map_union"
, "$1":
[ { "type": "to_subdir"
, "subdir": "work"
, "$1": {"type": "var", "name": "data"}
}
, {"type": "var", "name": "runner"}
, {"type": "var", "name": "staged test binary"}
]
}
, "cmd": ["sh", "./runner.sh"]
, "may_fail": ["test"]
, "fail_message":
{ "type": "join"
, "$1":
["CC test ", {"type": "var", "name": "binary name"}, " failed"]
}
}
]
, [ "runfiles"
, { "type": "singleton_map"
, "key": {"type": "var", "name": "base name"}
, "value":
{"type": "TREE", "$1": {"type": "var", "name": "test-results"}}
}
]
]
, "body":
{ "type": "RESULT"
, "artifacts": {"type": "var", "name": "test-results"}
, "runfiles": {"type": "var", "name": "runfiles"}
}
}
}
}
|