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
|
{ "field_artifacts_list":
{ "doc": ["Query list of artifacts from target_field's targets"]
, "vars": ["fieldname", "transition"]
, "vars_doc":
{ "fieldname": ["The name of the target_field to query."]
, "transition": ["The optional configuration transition for the targets."]
}
, "expression":
{ "type": "foreach"
, "var": "x"
, "range": {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}}
, "body":
{ "type": "DEP_ARTIFACTS"
, "dep": {"type": "var", "name": "x"}
, "transition":
{"type": "var", "name": "transition", "default": {"type": "empty_map"}}
}
}
}
, "field_artifacts":
{ "doc": ["Query and merge artifacts from target_field's targets"]
, "vars": ["fieldname", "transition"]
, "vars_doc":
{ "fieldname": ["The name of the target_field to query."]
, "transition": ["The optional configuration transition for the targets."]
}
, "imports": {"artifacts_list": "field_artifacts_list"}
, "expression":
{ "type": "disjoint_map_union"
, "msg":
["artifacts", {"type": "var", "name": "fieldname"}, "must not overlap"]
, "$1": {"type": "CALL_EXPRESSION", "name": "artifacts_list"}
}
}
, "field_runfiles_list":
{ "doc": ["Query list of runfiles from target_field's targets"]
, "vars": ["fieldname", "transition"]
, "vars_doc":
{ "fieldname": ["The name of the target_field to query."]
, "transition": ["The optional configuration transition for the targets."]
}
, "expression":
{ "type": "foreach"
, "var": "x"
, "range": {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}}
, "body":
{ "type": "DEP_RUNFILES"
, "dep": {"type": "var", "name": "x"}
, "transition":
{"type": "var", "name": "transition", "default": {"type": "empty_map"}}
}
}
}
, "field_runfiles":
{ "doc": ["Query and merge runfiles from target_field's targets"]
, "vars": ["fieldname", "transition"]
, "vars_doc":
{ "fieldname": ["The name of the target_field to query."]
, "transition": ["The optional configuration transition for the targets."]
}
, "imports": {"runfiles_list": "field_runfiles_list"}
, "expression":
{ "type": "disjoint_map_union"
, "msg":
["runfiles", {"type": "var", "name": "fieldname"}, "must not overlap"]
, "$1": {"type": "CALL_EXPRESSION", "name": "runfiles_list"}
}
}
, "field_provider_list":
{ "doc": ["Query list of providers from targets' provides map"]
, "vars": ["fieldname", "provider", "transition", "default"]
, "vars_doc":
{ "fieldname": ["The name of the target_field to query."]
, "provider": ["The name of the map provider in the provides map."]
, "transition": ["The optional configuration transition for the targets."]
, "default": ["The default if the provider was not found (default: [])."]
}
, "expression":
{ "type": "foreach"
, "var": "x"
, "range": {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}}
, "body":
{ "type": "DEP_PROVIDES"
, "dep": {"type": "var", "name": "x"}
, "provider": {"type": "var", "name": "provider"}
, "transition":
{"type": "var", "name": "transition", "default": {"type": "empty_map"}}
, "default": {"type": "var", "name": "default", "default": []}
}
}
}
, "field_map_provider":
{ "doc": ["Query and merge map-providers from targets' provides map"]
, "vars": ["fieldname", "provider", "transition"]
, "vars_doc":
{ "fieldname": ["The name of the target_field to query."]
, "provider": ["The name of the map provider in the provides map."]
, "transition": ["The optional configuration transition for the targets."]
}
, "imports": {"provider_list": "field_provider_list"}
, "expression":
{ "type": "disjoint_map_union"
, "msg":
["Overlapping entries in provider", {"type": "var", "name": "provider"}]
, "$1":
{ "type": "let*"
, "bindings": [["default", {"type": "empty_map"}]]
, "body": {"type": "CALL_EXPRESSION", "name": "provider_list"}
}
}
}
, "field_list_provider":
{ "doc": ["Query and merge list-providers from targets' provides map"]
, "vars": ["fieldname", "provider", "transition"]
, "vars_doc":
{ "fieldname": ["The name of the target_field to query."]
, "provider": ["The name of the list provider in the provides map."]
, "transition": ["The optional configuration transition for the targets."]
}
, "imports": {"provider_list": "field_provider_list"}
, "expression":
{"type": "++", "$1": {"type": "CALL_EXPRESSION", "name": "provider_list"}}
}
, "action_env":
{ "vars": ["ENV"]
, "expression":
{ "type": "map_union"
, "$1":
[ {"type": "singleton_map", "key": "PATH", "value": "/bin:/usr/bin"}
, {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
]
}
}
, "stage_singleton_field":
{ "vars": ["fieldname", "transition", "location"]
, "expression":
{ "type": "assert_non_empty"
, "msg":
["No artifact specified in field", {"type": "var", "name": "fieldname"}]
, "$1":
{ "type": "disjoint_map_union"
, "msg":
[ "Expecting (essentially) a single artifact in field"
, {"type": "var", "name": "fieldname"}
]
, "$1":
{ "type": "foreach"
, "var": "src"
, "range":
{"type": "FIELD", "name": {"type": "var", "name": "fieldname"}}
, "body":
{ "type": "disjoint_map_union"
, "$1":
{ "type": "foreach"
, "var": "artifact"
, "range":
{ "type": "values"
, "$1":
{ "type": "DEP_ARTIFACTS"
, "dep": {"type": "var", "name": "src"}
, "transition":
{ "type": "var"
, "name": "transition"
, "default": {"type": "empty_map"}
}
}
}
, "body":
{ "type": "singleton_map"
, "key": {"type": "var", "name": "location"}
, "value": {"type": "var", "name": "artifact"}
}
}
}
}
}
}
}
, "stage_artifact_to_singleton_field":
{ "vars": ["artifact", "fieldname", "transition"]
, "expression":
{ "type": "let*"
, "bindings":
[ [ "location"
, { "type": "++"
, "$1":
{ "type": "foreach"
, "var": "src"
, "range":
{"type": "FIELD", "name": {"type": "var", "name": "fieldname"}}
, "body":
{ "type": "keys"
, "$1":
{ "type": "DEP_ARTIFACTS"
, "dep": {"type": "var", "name": "src"}
, "transition":
{ "type": "var"
, "name": "transition"
, "default": {"type": "empty_map"}
}
}
}
}
}
]
, [ "staged_artifact"
, { "type": "foreach_map"
, "range": {"type": "var", "name": "artifact"}
, "var_val": "val"
, "body":
{ "type": "foreach"
, "range": {"type": "var", "name": "location"}
, "var": "pos"
, "body":
{ "type": "singleton_map"
, "key": {"type": "var", "name": "pos"}
, "value": {"type": "var", "name": "val"}
}
}
}
]
]
, "body":
{ "type": "disjoint_map_union"
, "$1": {"type": "++", "$1": {"type": "var", "name": "staged_artifact"}}
}
}
}
, "contains":
{ "doc": ["Returns the item if it is in the list or \"null\" otherwise."]
, "vars": ["list", "item", "list_prefix"]
, "vars_doc":
{ "list": ["The list to look for the item."]
, "item": ["The item to look for in the list."]
, "list_prefix":
[ "An optional string, which every item in the list is prefixed with"
, "before comparison. Note that the returned item is not prefixed."
]
}
, "expression":
{ "type": "let*"
, "bindings":
[ [ "result"
, { "type": "++"
, "$1":
{ "type": "foreach"
, "var": "entry"
, "range": {"type": "var", "name": "list"}
, "body":
{ "type": "if"
, "cond":
{ "type": "=="
, "$1":
{ "type": "join"
, "$1":
[ {"type": "var", "name": "list_prefix", "default": ""}
, {"type": "var", "name": "entry"}
]
}
, "$2": {"type": "var", "name": "item"}
}
, "then": [{"type": "var", "name": "entry"}]
}
}
}
]
]
, "body":
{ "type": "if"
, "cond": {"type": "var", "name": "result"}
, "then": {"type": "join", "$1": {"type": "var", "name": "result"}}
, "else": null
}
}
}
}
|