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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
|
{ "defaults":
{ "doc":
[ "A rule to provide defaults."
, "All CC targets take their defaults for CXX, CC, flags, etc from"
, "the target [\"CC\", \"defaults\"]. This is probably the only sensibe"
, "use of this rule. As targets form a different root, the defaults"
, "can be provided without changing this directory."
]
, "target_fields": ["base"]
, "string_fields":
[ "CC"
, "CXX"
, "CFLAGS"
, "CXXFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
, "PATH"
, "AR"
]
, "imports": {"base-provides": "defaults-base-provides"}
, "expression":
{ "type": "let*"
, "bindings":
[ ["CC", {"type": "FIELD", "name": "CC"}]
, ["CXX", {"type": "FIELD", "name": "CXX"}]
, ["CFLAGS", {"type": "FIELD", "name": "CFLAGS"}]
, ["CXXFLAGS", {"type": "FIELD", "name": "CXXFLAGS"}]
, ["AR", {"type": "FIELD", "name": "AR"}]
, ["PATH", {"type": "FIELD", "name": "PATH"}]
, ["provider", "CC"]
, [ "CC"
, { "type": "if"
, "cond": {"type": "var", "name": "CC"}
, "then": {"type": "var", "name": "CC"}
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
, ["provider", "CXX"]
, [ "CXX"
, { "type": "if"
, "cond": {"type": "var", "name": "CXX"}
, "then": {"type": "var", "name": "CXX"}
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
, ["provider", "CFLAGS"]
, [ "CFLAGS"
, { "type": "if"
, "cond": {"type": "var", "name": "CFLAGS"}
, "then": {"type": "var", "name": "CFLAGS"}
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
, ["provider", "CXXFLAGS"]
, [ "CXXFLAGS"
, { "type": "if"
, "cond": {"type": "var", "name": "CXXFLAGS"}
, "then": {"type": "var", "name": "CXXFLAGS"}
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
, ["provider", "AR"]
, [ "AR"
, { "type": "if"
, "cond": {"type": "var", "name": "AR"}
, "then": {"type": "var", "name": "AR"}
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
, ["provider", "ENV"]
, [ "ENV"
, { "type": "if"
, "cond": {"type": "var", "name": "PATH"}
, "then":
{ "type": "singleton_map"
, "key": "PATH"
, "value":
{ "type": "join"
, "separator": ":"
, "$1": {"type": "var", "name": "PATH"}
}
}
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
, [ "CFLAGS"
, { "type": "++"
, "$1":
[ {"type": "var", "name": "CFLAGS"}
, {"type": "FIELD", "name": "ADD_CFLAGS"}
]
}
]
, [ "CXXFLAGS"
, { "type": "++"
, "$1":
[ {"type": "var", "name": "CXXFLAGS"}
, {"type": "FIELD", "name": "ADD_CXXFLAGS"}
]
}
]
]
, "body":
{ "type": "RESULT"
, "provides":
{ "type": "env"
, "vars": ["CC", "CXX", "CFLAGS", "CXXFLAGS", "AR", "ENV"]
}
}
}
}
, "header directory":
{ "doc":
[ "A directory of header files."
, ""
, "Define a directory of header files that belong together and are staged"
, "in such a way that no other target (used together with this target) will"
, "have to put files in this directory. The typical use case is a library"
, "libfoo that expects all headers to be included as #include \"foo/bar.h\"."
, "In this case, one would define a header direcotry for \"foo\"."
, ""
, "Technically, a tree is created from the given files and staged to the"
, "specified location. Since trees are opaque, the directory name becomes"
, "essentially owned by target. In this way, staging conflicts can be"
, "avoided by detecting them early and not only once a file with the same"
, "name is added to the staging location. Also, as only a tree identifier"
, "has to be passed around, such a directory can be handled more"
, "efficiently by the tool."
]
, "target_fields": ["hdrs"]
, "string_fields": ["stage"]
, "field_doc":
{ "hdrs": ["The header files to be put into the header directory."]
, "stage":
[ "The location of the header directory."
, "Path segments are joined with \"/\"."
]
}
, "artifacts_doc": ["The single tree artifact staged to the given location"]
, "runfiles_doc": ["Same as artifacts"]
, "imports": {"runfiles": ["./", "..", "field_runfiles"]}
, "expression":
{ "type": "let*"
, "bindings":
[ [ "hdrs"
, { "type": "let*"
, "bindings": [["fieldname", "hdrs"]]
, "body": {"type": "CALL_EXPRESSION", "name": "runfiles"}
}
]
, [ "stage"
, { "type": "join"
, "separator": "/"
, "$1": {"type": "FIELD", "name": "stage"}
}
]
, [ "dir"
, { "type": "singleton_map"
, "key": {"type": "var", "name": "stage"}
, "value": {"type": "TREE", "$1": {"type": "var", "name": "hdrs"}}
}
]
]
, "body":
{ "type": "RESULT"
, "artifacts": {"type": "var", "name": "dir"}
, "runfiles": {"type": "var", "name": "dir"}
}
}
}
, "library":
{ "doc": ["A C++ libaray"]
, "target_fields": ["srcs", "hdrs", "private-hdrs", "deps", "proto"]
, "string_fields":
[ "name"
, "stage"
, "pure C"
, "local defines"
, "local cflags"
, "link external"
]
, "config_vars":
[ "CXX"
, "CC"
, "CXXFLAGS"
, "CFLAGS"
, "ADD_CXXFLAGS"
, "ADD_CFLAGS"
, "ENV"
, "AR"
]
, "implicit": {"defaults": ["defaults"]}
, "field_doc":
{ "name":
["The name of the library (without leading \"lib\" or trailing \".a\")."]
, "srcs": ["The source files of the library."]
, "hdrs": ["Any public header files of the library."]
, "private-hdrs":
[ "Any header files that only need to be present when compiling the"
, "source files, but are not needed for any consumer of the library."
]
, "stage":
[ "The logical location of all header and source files, as well as the"
, "resulting library file. Individual directory components are joined"
, "with \"/\"."
]
, "pure C":
[ "If non-empty, compile as C sources rathter than C++ sources."
, "In particular, CC is used to compile rather than CXX (or their"
, "respective defaults)."
]
, "local defines":
[ "List of defines set for source files local to this target."
, "Each list entry will be prepended by \"-D\"."
]
, "local cflags":
["List of compile flags set for source files local to this target."]
, "link external":
[ "Additional linker flags for linking external libraries (not built"
, "by this tool, typically system libraries)."
]
, "deps": ["Any other libraries this library depends upon."]
, "proto":
[ "Any [\"proto\", \"library\"] this target depends upon directly."
, "The creation of C++ bindings for this proto library as well as of"
, "its dependencies will be taken care of (as anonymous targets, so no"
, "duplicate work will be carried out, even if the same proto library"
, "is used at various places)."
]
}
, "config_doc":
{ "CXX":
[ "The name of the C++ compiler to be used."
, "If None, the respective value from [\"CC\", \"defaults\"] will be taken."
]
, "CC":
[ "The name of the C compiler to be used (when compiling pure C code)."
, "If None, the respective value from [\"CC\", \"defaults\"] will be taken."
]
, "AR":
[ "The archive tool to used for creating the library"
, "If None, the respective value from [\"CC\", \"defaults\"] will be taken."
]
, "ENV": ["The environment for any action generated."]
, "CXXFLAGS":
[ "The flags for CXX to be used instead of the default ones."
, "For libraries that should be built in a non-standard way; usually"
, "adapting the default target [\"CC\", \"defaults\"] is the better"
, "choice."
]
, "CFLAGS":
[ "The flags for CC to be used instead of the default ones."
, "For libraries that should be built in a non-standard way; usually"
, "adapting the default target [\"CC\", \"defaults\"] is the better"
, "choice"
]
, "ADD_CXXFLAGS":
[ "The flags to add to the default ones for CXX."
, "For libraries that should be built in a non-standard way; usually"
, "adapting the default target [\"CC\", \"defaults\"] is the better"
, "choice."
]
, "ADD_CFLAGS":
[ "The flags to add to the default ones for CC."
, "For libraries that should be built in a non-standard way; usually"
, "adapting the default target [\"CC\", \"defaults\"] is the better"
, "choice."
]
}
, "artifacts_doc":
["The actual library (libname.a) staged in the specified directory"]
, "runfiles_doc": ["The public headers of this library"]
, "provides_doc":
{ "compile-deps":
[ "Map of artifacts specifying any additional files that, besides the runfiles,"
, "have to be present in compile actions of targets depending on this library"
]
, "link-deps":
[ "Map of artifacts specifying any additional files that, besides the artifacts,"
, "have to be present in a link actions of targets depending on this library"
]
, "link-args":
[ "List of strings that have to be added to the command line for linking actions"
, "in targets depending on on this library"
]
}
, "anonymous":
{ "proto-deps":
{ "target": "proto"
, "provider": "proto"
, "rule_map":
{ "library": ["./", "proto", "library"]
, "service library": ["./", "proto", "service library"]
}
}
}
, "imports":
{ "artifacts": ["./", "..", "field_artifacts"]
, "default-CXXFLAGS": "default-CXXFLAGS"
, "default-CFLAGS": "default-CFLAGS"
, "result": "lib result"
}
, "expression":
{ "type": "let*"
, "bindings":
[ [ "local defines"
, { "type": "foreach"
, "var": "def"
, "range": {"type": "FIELD", "name": "local defines"}
, "body":
{"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]}
}
]
, ["local cflags", {"type": "FIELD", "name": "local cflags"}]
, [ "CFLAGS"
, { "type": "++"
, "$1":
[ { "type": "var"
, "name": "CFLAGS"
, "default":
{"type": "CALL_EXPRESSION", "name": "default-CFLAGS"}
}
, {"type": "var", "name": "local defines"}
]
}
]
, [ "CXXFLAGS"
, { "type": "++"
, "$1":
[ { "type": "var"
, "name": "CXXFLAGS"
, "default":
{"type": "CALL_EXPRESSION", "name": "default-CXXFLAGS"}
}
, {"type": "var", "name": "local defines"}
]
}
]
, [ "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"}
}
}
]
, [ "hdrs"
, { "type": "to_subdir"
, "subdir": {"type": "var", "name": "stage"}
, "$1":
{ "type": "let*"
, "bindings": [["fieldname", "hdrs"]]
, "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
}
}
]
, [ "private-hdrs"
, { "type": "to_subdir"
, "subdir": {"type": "var", "name": "stage"}
, "$1":
{ "type": "let*"
, "bindings": [["fieldname", "private-hdrs"]]
, "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
}
}
]
, ["link external", {"type": "FIELD", "name": "link external"}]
]
, "body": {"type": "CALL_EXPRESSION", "name": "result"}
}
}
, "binary":
{ "doc": ["A binary written in C++"]
, "target_fields": ["srcs", "private-hdrs", "deps", "proto"]
, "string_fields":
["name", "stage", "pure C", "local defines", "link external"]
, "config_vars":
["CXX", "CC", "CXXFLAGS", "CFLAGS", "ADD_CXXFLAGS", "ADD_CFLAGS", "ENV"]
, "implicit": {"defaults": ["defaults"]}
, "field_doc":
{ "name": ["The name of the binary"]
, "srcs": ["The source files of the library."]
, "private-hdrs":
[ "Any header files that need to be present when compiling the"
, "source files."
]
, "stage":
[ "The logical location of all header and source files, as well as the"
, "resulting binary file. Individual directory components are joined"
, "with \"/\"."
]
, "pure C":
[ "If non-empty, compile as C sources rathter than C++ sources."
, "In particular, CC is used to compile rather than CXX"
]
, "local defines":
[ "List of defines set for source files local to this target."
, "Each list entry will be prepended by \"-D\"."
]
, "link external":
["Additional linker flags for linking external libraries."]
, "deps": ["Any other libraries this binary depends upon."]
, "proto":
[ "Any [\"proto\", \"library\"] this target depends upon directly."
, "The creation of C++ bindings for this proto library as well as of"
, "is dependencies will be taken care of (as anonymous targets, so no"
, "duplicate work will be carried out, even if the same proto library"
, "is used at various places)."
]
}
, "config_doc":
{ "CXX": ["The name of the C++ compiler to be used."]
, "CC":
["The name of the C compiler to be used (when compiling pure C code)"]
, "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"
]
, "CFLAGS":
[ "The flags for CXX to be used instead of the default ones"
, "taken from the [\"CC\", \"defaults\"] target"
]
, "ADD_CXXFLAGS":
[ "The flags to add to the default ones for CXX"
, "taken from the [\"CC\", \"defaults\"] target"
]
, "ADD_CFLAGS":
[ "The flags to add to the default ones for CC"
, "taken from the [\"CC\", \"defaults\"] target"
]
}
, "artifacts_doc": ["The final binary, staged to the given directory"]
, "runfiles_doc": ["None"]
, "anonymous":
{ "proto-deps":
{ "target": "proto"
, "provider": "proto"
, "rule_map":
{ "library": ["./", "proto", "library"]
, "service library": ["./", "proto", "service library"]
}
}
}
, "imports":
{ "artifacts": ["./", "..", "field_artifacts"]
, "compile-deps": "compile-deps"
, "link-deps": "link-deps"
, "link-args-deps": "link-args-deps"
, "objects": "objects"
, "compiler": "compiler"
, "flags": "flags"
, "default-ENV": "default-ENV"
}
, "expression":
{ "type": "let*"
, "bindings":
[ [ "local defines"
, { "type": "foreach"
, "var": "def"
, "range": {"type": "FIELD", "name": "local defines"}
, "body":
{"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]}
}
]
, [ "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": "CALL_EXPRESSION", "name": "compiler"}]
, ["CXXFLAGS", {"type": "CALL_EXPRESSION", "name": "flags"}]
, [ "CXXFLAGS"
, { "type": "++"
, "$1":
[ {"type": "var", "name": "CXXFLAGS"}
, {"type": "var", "name": "local defines"}
]
}
]
, [ "ENV"
, { "type": "map_union"
, "$1":
{ "type": "++"
, "$1":
[ {"type": "CALL_EXPRESSION", "name": "default-ENV"}
, [ { "type": "var"
, "name": "ENV"
, "default": {"type": "empty_map"}
}
]
]
}
}
]
, ["deps-fieldnames", ["deps", "proto-deps"]]
, ["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-empty name has to be provided for binaries"
, "$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": "CALL_EXPRESSION", "name": "link-args-deps"}
, {"type": "FIELD", "name": "link external"}
]
}
}
]
, [ "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": "CXXFLAGS"}
, {"type": "var", "name": "link-args"}
]
}
, "env": {"type": "var", "name": "ENV"}
}
]
]
, "body":
{"type": "RESULT", "artifacts": {"type": "var", "name": "binary"}}
}
}
}
|