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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
{ "build_script":
{ "doc":
[ "The custom build script supported by cargo. This binary is"
, "executed before compiling the other crates. Currently, only its"
, "output is processed to augment the rustc flags. During a cross"
, "compilation, since the build script must be run on the host"
, "system, it is always compiled according to the configuration"
, "provided by the \"defaults\" for the \"HOST_ARCH\"."
]
, "string_fields": ["name", "edition", "stage", "version", "pkg_name"]
, "target_fields": ["crate_root", "srcs", "deps", "cargo_features"]
, "field_doc":
{ "name": ["The name of the crate being built."]
, "cargo_features":
["List of cargo features this binary requires to be enabled."]
, "crate_root":
[ "The crate to be fed to the Rust compiler. It must evaluate to"
, "a single artifact/file."
]
, "defaults": ["The Rust toolchain to use."]
, "deps": ["Any other libraries this binary depends upon."]
, "edition":
[ "The edition of the compiler to use during compilation. If"
, "unset, 2015 is used."
]
, "pkg_name":
[ "The name of the package the crate belongs to. It is"
, "exported to the CARGO_PKG_NAME environment variable."
]
, "srcs": ["The source files of the binary."]
, "stage":
[ "The logical location of the resulting artifact. Elements are"
, "joined with \"/\"."
]
, "version":
[ "The crate version. Elements are joined with \".\" and the first"
, "three elements are used for the major, minor, and patch"
, "number respectively."
]
}
, "config_vars": ["ARCH", "HOST_ARCH", "ENV"]
, "config_doc":
{ "ARCH":
[ "Default value for both HOST_ARCH and TARGET_ARCH. It is user's"
, "responsibility to adapt the \"defaults\" according to the"
, "provided value."
]
, "ENV":
[ "Additional environment variables (besides ones provided by"
, "the \"defaults\" target) to be set for each action. If the"
, "same variable is set here and in the \"defaults\", the former"
, "is taken."
]
, "HOST_ARCH":
[ "The host CPU architecture. It is user's responsibility to"
, "adapt the \"defaults\" according to the provided value."
]
}
, "config_transitions":
{ "cargo_features":
[{"type": "CALL_EXPRESSION", "name": "for host as rlib"}]
, "crate_root": [{"type": "CALL_EXPRESSION", "name": "for host"}]
, "defaults": [{"type": "CALL_EXPRESSION", "name": "for host"}]
, "deps": [{"type": "CALL_EXPRESSION", "name": "for host as rlib"}]
, "srcs": [{"type": "CALL_EXPRESSION", "name": "for host"}]
}
, "imports":
{ "call rustc artifact": ["./", "../rust", "call rustc artifact"]
, "for host": ["./", "../rust", "for host"]
, "for host as rlib": ["./", "../rust", "for host as rlib"]
, "get_runfiles": ["./", "..", "get_runfiles"]
}
, "implicit": {"defaults": [["./", "../rust", "defaults"]]}
, "expression":
{ "type": "let*"
, "bindings":
[ ["crate_name", {"type": "FIELD", "name": "name"}]
, ["crate_type", "bin"]
, [ "stage"
, { "type": "if"
, "cond": {"type": "FIELD", "name": "stage"}
, "then":
{ "type": "join"
, "$1": {"type": "FIELD", "name": "stage"}
, "separator": "/"
}
, "else": "."
}
]
, ["crate_root", {"type": "FIELD", "name": "crate_root"}]
, ["edition", {"type": "FIELD", "name": "edition"}]
, ["srcs", {"type": "FIELD", "name": "srcs"}]
, ["deps", {"type": "FIELD", "name": "deps"}]
, ["cargo_features", {"type": "FIELD", "name": "cargo_features"}]
, ["emit", "link"]
, ["is_custom_build_script", true]
, ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}]
, [ "deps-transition"
, {"type": "CALL_EXPRESSION", "name": "for host as rlib"}
]
, ["version", {"type": "FIELD", "name": "version"}]
, ["pkg_name", {"type": "FIELD", "name": "pkg_name"}]
, ["defaults", {"type": "FIELD", "name": "defaults"}]
, [ "artifact result"
, {"type": "CALL_EXPRESSION", "name": "call rustc artifact"}
]
, [ "exe"
, { "type": "assert"
, "msg":
{ "type": "join"
, "$1":
[ "Expected single executable but found "
, {"type": "json_encode", "$1": {"type": "var", "name": "_"}}
]
}
, "predicate":
{ "type": "=="
, "$1":
{ "type": "length"
, "$1": {"type": "keys", "$1": {"type": "var", "name": "_"}}
}
, "$2": 1
}
, "$1":
{ "type": "lookup"
, "key": "artifact"
, "map": {"type": "var", "name": "artifact result"}
}
}
]
, [ "exe_name"
, { "type": "lookup"
, "key": "artifact-name"
, "map": {"type": "var", "name": "artifact result"}
}
]
, [ "out_name"
, { "type": "join"
, "$1": [{"type": "var", "name": "stage"}, "out"]
, "separator": "/"
}
]
, [ "out"
, { "type": "ACTION"
, "outs": [{"type": "var", "name": "out_name"}]
, "inputs": {"type": "var", "name": "exe"}
, "cmd":
[ "sh"
, "-ce"
, { "type": "join"
, "$1":
[ { "type": "join_cmd"
, "$1": [{"type": "var", "name": "exe_name"}]
}
, " > "
, {"type": "var", "name": "out_name"}
, " && "
, { "type": "join_cmd"
, "$1": ["cat", {"type": "var", "name": "out_name"}]
}
, " | "
, { "type": "join_cmd"
, "$1":
[ "xargs"
, "printf"
, { "type": "join"
, "$1":
["[", {"type": "var", "name": "stage"}, "] ", "%s\n"]
, "separator": ""
}
]
}
]
, "separator": ""
}
]
, "env":
{ "type": "lookup"
, "key": "env"
, "map": {"type": "var", "name": "artifact result"}
}
}
]
, [ "file_args_name"
, { "type": "join"
, "$1": [{"type": "var", "name": "stage"}, "file_args"]
, "separator": "/"
}
]
, [ "file_args"
, { "type": "ACTION"
, "outs": [{"type": "var", "name": "file_args_name"}]
, "inputs": {"type": "var", "name": "out"}
, "cmd":
[ "sh"
, "-c"
, { "type": "join"
, "$1":
[ { "type": "join_cmd"
, "$1": ["cat", {"type": "var", "name": "out_name"}]
}
, " | "
, { "type": "join_cmd"
, "$1":
[ "awk"
, { "type": "join"
, "$1":
[ "/rustc-cfg/ {split($0,x,\"=\"); printf \"--cfg\\n%s\\n\", x[2]}"
, "/rustc-link-arg/ {split($0,x,\"=\"); printf \"-Clink-arg=%s\\n\", x[2]}"
]
, "separator": " "
}
]
}
, " > "
, {"type": "var", "name": "file_args_name"}
]
, "separator": ""
}
]
, "env":
{ "type": "lookup"
, "key": "env"
, "map": {"type": "var", "name": "artifact result"}
}
}
]
, [ "args"
, { "type": "join"
, "$1": ["@", {"type": "var", "name": "file_args_name"}]
, "separator": ""
}
]
]
, "body":
{ "type": "RESULT"
, "artifacts":
{ "type": "map_union"
, "$1":
[ {"type": "var", "name": "exe"}
, {"type": "var", "name": "file_args"}
, {"type": "var", "name": "out"}
]
}
, "provides":
{ "type": "map_union"
, "$1":
[ { "type": "singleton_map"
, "key": "rust-compile-artifacts"
, "value": {"type": "var", "name": "file_args"}
}
, { "type": "singleton_map"
, "key": "rust-link-artifacts"
, "value": {"type": "var", "name": "file_args"}
}
, { "type": "singleton_map"
, "key": "rustc-compile-args"
, "value": [{"type": "var", "name": "args"}]
}
, { "type": "singleton_map"
, "key": "rustc-link-args"
, "value": [{"type": "var", "name": "args"}]
}
]
}
}
}
}
, "feature":
{ "doc": ["A cargo feature."]
, "string_fields": ["name"]
, "target_fields": ["deps"]
, "field_doc":
{ "name":
[ "The feature name. The flag `--cfg feature=<name>` is passed to"
, "the Rust compiler."
]
, "deps":
["Any other features or \"[rust, library]\" this feature depends", "on."]
}
, "imports":
{ "disjoint_map_from_provides": ["./", "..", "disjoint_map_from_provides"]
, "flatten_from_provides": ["./", "..", "flatten_from_provides"]
}
, "expression":
{ "type": "let*"
, "bindings":
[ [ "feature_name"
, {"type": "[]", "index": 0, "list": {"type": "FIELD", "name": "name"}}
]
, [ "my_feature_arg"
, [ "--cfg"
, { "type": "join"
, "$1":
["feature=\"", {"type": "var", "name": "feature_name"}, "\""]
}
]
]
, ["deps", {"type": "FIELD", "name": "deps"}]
, ["range", {"type": "var", "name": "deps"}]
, [ "compile-deps"
, { "type": "let*"
, "bindings": [["key", "rust-compile-artifacts"]]
, "body":
{"type": "CALL_EXPRESSION", "name": "disjoint_map_from_provides"}
}
]
, [ "link-deps"
, { "type": "let*"
, "bindings": [["key", "rust-link-artifacts"]]
, "body":
{"type": "CALL_EXPRESSION", "name": "disjoint_map_from_provides"}
}
]
, [ "compile-deps-args"
, { "type": "let*"
, "bindings": [["key", "rustc-compile-args"]]
, "body":
{"type": "CALL_EXPRESSION", "name": "flatten_from_provides"}
}
]
, [ "link-deps-args"
, { "type": "let*"
, "bindings": [["key", "rustc-link-args"]]
, "body":
{"type": "CALL_EXPRESSION", "name": "flatten_from_provides"}
}
]
, [ "stage-deps-args"
, { "type": "let*"
, "bindings": [["key", "stage-args"]]
, "body":
{"type": "CALL_EXPRESSION", "name": "flatten_from_provides"}
}
]
]
, "body":
{ "type": "RESULT"
, "provides":
{ "type": "map_union"
, "$1":
[ { "type": "singleton_map"
, "key": "rust-compile-artifacts"
, "value": {"type": "var", "name": "compile-deps"}
}
, { "type": "singleton_map"
, "key": "rust-link-artifacts"
, "value": {"type": "var", "name": "link-deps"}
}
, { "type": "singleton_map"
, "key": "rustc-compile-args"
, "value":
{ "type": "++"
, "$1":
[ {"type": "var", "name": "my_feature_arg"}
, {"type": "var", "name": "compile-deps-args"}
]
}
}
, { "type": "singleton_map"
, "key": "rustc-link-args"
, "value":
{ "type": "++"
, "$1":
[ {"type": "var", "name": "my_feature_arg"}
, {"type": "var", "name": "link-deps-args"}
]
}
}
, { "type": "singleton_map"
, "key": "stage-args"
, "value": {"type": "var", "name": "stage-deps-args"}
}
]
}
}
}
}
}
|