forked from facebook/buck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__cxx_common.soy
624 lines (584 loc) · 21.9 KB
/
__cxx_common.soy
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
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{namespace cxx_common}
/**
* @param? sample_file_name File name to use in samples. If null, defaults to 'foo/bar.c'.
*/
{template .srcs_arg}
{call buck.arg}
{param name : 'srcs' /}
{param default : '[]' /}
{param desc}
The set of C, C++, Objective-C, Objective-C++, or assembly source files
to be preprocessed, compiled, and assembled by this
rule. We determine which stages to run on each input source based on its file extension. See the
{sp}<a href="https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html">GCC documentation</a>{sp}
for more detail on how file extensions are interpreted. Each element can be either a string
specifying a source file (e.g. <code>'{$sample_file_name ?: 'foo/bar.c'}'</code>) or a tuple of
a string specifying a source file and a list of compilation flags
(e.g. <code>('{$sample_file_name ?: 'foo/bar.c'}', ['-Wall', '-Werror'])
</code>). In the latter case the specified flags will be used in addition to the rule's other
flags when preprocessing and compiling that file (if applicable).
{/param}
{/call}
{/template}
/***/
{template .platform_srcs_arg}
{call buck.arg}
{param name : 'platform_srcs' /}
{param default : '[]' /}
{param desc}
Platform specific source files. These should be specified as a list of pairs where the first
element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform
name is matched, and the second element is either a list of source files or a list of tuples of
source files and a list of compilation flags to be preprocessed, compiled and assembled if the
platform matches the regex. See <code>srcs</code> for more information.
{/param}
{/call}
{/template}
/***/
{template .supported_platforms_regex_arg}
{call buck.arg}
{param name : 'supported_platforms_regex' /}
{param default : 'None' /}
{param desc}
If present, an un-anchored regex (in java.util.regex.Pattern syntax) that matches all platforms
that this library supports. It will not be built for other platforms.
{/param}
{/call}
{/template}
/***/
{template .headers_arg}
{call buck.arg}
{param name : 'headers' /}
{param default : '[]' /}
{param desc}
The set of header files that are made available for inclusion to the source files in this
target. These should be specified as either a list
of header files or a dictionary of header names to header files. The header name can contain
forward slashes (<code>/</code>). The headers can be included with <code>#include
"$HEADER_NAMESPACE/$HEADER_NAME"</code> or <code>#include <$HEADER_NAMESPACE/$HEADER_NAME>
</code>, where <code>$HEADER_NAMESPACE</code> is the value of the target's <code>header_namespace
</code> attribute, and <code>$HEADER_NAME</code> is the header name if specified, and the filename
of the header file otherwise. See <code>header_namespace</code> for more information.
{/param}
{/call}
{/template}
/***/
{template .platform_headers_arg}
{call buck.arg}
{param name : 'platform_headers' /}
{param default : '[]' /}
{param desc}
Platform specific header files. These should be specified as a list of pairs where the first
element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform
name is matched, and the second element is either a list of header files or a dictionary of
header names to header files that will be made available for inclusion to the source files in the
target if the platform matches the regex. See <code>headers</code> for more information.
{/param}
{/call}
{/template}
/***/
{template .exported_headers_arg}
{call buck.arg}
{param name : 'exported_headers' /}
{param default : '[]' /}
{param desc}
The set of header files that are made available for inclusion to the source files in the
target and all targets that transitively depend on it. These should be specified as either a list
of header files or a dictionary of header names to header files. The headers can be included
with <code>#include "$HEADER_NAMESPACE/$HEADER_NAME"</code> or <code>#include
<$HEADER_NAMESPACE/$HEADER_NAME></code>, where <code>$HEADER_NAMESPACE</code> is the value
of the target's <code>header_namespace</code> attribute, and <code>$HEADER_NAME</code> is the
header name if specified, and the filename of the header file otherwise. Note that the header name
can contain forward slashes (<code>/</code>). See <code>header_namespace</code> for more
information.
{/param}
{/call}
{/template}
/***/
{template .exported_header_style_arg}
{call buck.arg}
{param name : 'exported_header_style' /}
{param default : 'local' /}
{param desc}
How dependents should include exported headers from this rule. Can be either <code>local</code>
(e.g. <code>-I</code>) or <code>system</code> (e.g. <code>-isystem</code>).
{/param}
{/call}
{/template}
/***/
{template .exported_platform_headers_arg}
{call buck.arg}
{param name : 'exported_platform_headers' /}
{param default : '[]' /}
{param desc}
Platform specific header files. These should be specified as a list of pairs where the first
element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform
name is matched, and the second element is either a list of header files or a dictionary of
header names to header files that will be made available for inclusion to the source files in the
target and all targets that transitively depend on it if the platform matches the regex.
See <code>headers</code> for more information.
{/param}
{/call}
{/template}
/***/
{template .header_namespace_arg}
{call buck.arg}
{param name : 'header_namespace' /}
{param default : 'name' /}
{param desc}
A path prefix when including headers of this target. Defaults to the path from the root of the
repository to the directory where this target is defined. Can
contain forward slashes (<code>/</code>), but cannot start with one. See <code>headers</code> for
more information.
{/param}
{/call}
{/template}
/***/
{template .preprocessor_flags_arg}
{call buck.arg}
{param name : 'preprocessor_flags' /}
{param default : '[]' /}
{param desc}
Flags to use when preprocessing any of the above sources (which require preprocessing).
{/param}
{/call}
{/template}
/***/
{template .lang_preprocessor_flags_arg}
{call buck.arg}
{param name : 'lang_preprocessor_flags' /}
{{param default : '{}' /}}
{param desc}
Language-specific preprocessor flags. These should be specified as a map of C-family language short
names to lists of flags and is used to target flags to sources files for a specific language in the
C-family (C, C++, assembler, etc.). The keys in the map can be:
<ul>
<li>
<code>c</code> for C
</li>
<li>
<code>c++</code> for C++
</li>
<li>
<code>objective-c</code> for Objective-C
</li>
<li>
<code>objective-c++</code> for Objective-C++
</li>
<li>
<code>cuda</code> for Cuda
</li>
<li>
<code>assembler-with-cpp</code> for Assembly
</li>
<li>
<code>asm-with-cpp</code> for ASM
</li>
</ul>
{/param}
{/call}
{/template}
/***/
{template .exported_lang_preprocessor_flags_arg}
{call buck.arg}
{param name : 'exported_lang_preprocessor_flags' /}
{{param default : '{}' /}}
{param desc}
Just as <code>lang_preprocessor_flags</code>, but these flags also apply to
rules that transitively depend on this rule.
{/param}
{/call}
{/template}
/***/
{template .lang_platform_preprocessor_flags_arg}
{call buck.arg}
{param name : 'lang_platform_preprocessor_flags' /}
{{param default : '{}' /}}
{param desc}
Language- and platform-specific preprocessor flags. These should be specified as a map of C-family language short
names, as described in <code>lang_preprocessor_flags</code>, to lists of pairs, as described in <code>platform_preprocessor_flags</code>.
{/param}
{/call}
{/template}
/***/
{template .exported_lang_platform_preprocessor_flags_arg}
{call buck.arg}
{param name : 'exported_lang_platform_preprocessor_flags' /}
{{param default : '{}' /}}
{param desc}
Just as <code>lang_platform_preprocessor_flags</code>, but these flags also apply to
rules that transitively depend on this rule.
{/param}
{/call}
{/template}
/***/
{template .platform_preprocessor_flags_arg}
{call buck.arg}
{param name : 'platform_preprocessor_flags' /}
{param default : '[]' /}
{param desc}
Platform specific preprocessor flags. These should be specified as a list of pairs where the first
element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform
name is matched, and the second element is a list of flags to use when preprocessing the target's
sources. See <code>preprocessor_flags</code> for more information.
{/param}
{/call}
{/template}
/***/
{template .exported_preprocessor_flags_arg}
{call buck.arg}
{param name : 'exported_preprocessor_flags' /}
{param default : '[]' /}
{param desc}
Just as <code>preprocessor_flags</code>, flags to use when preprocessing any of the above sources
(which require preprocessing). However, unlike <code>preprocessor_flags</code>, these preprocessor
flags are also used by rules that transitively depend on this rule when preprocessing their own
sources.
{/param}
{/call}
{/template}
/***/
{template .exported_platform_preprocessor_flags_arg}
{call buck.arg}
{param name : 'exported_platform_preprocessor_flags' /}
{param default : '[]' /}
{param desc}
Platform specific exported preprocessor flags. These should be specified as a list of pairs where
the first element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the
platform name is matched, and the second element is a list of flags to use when preprocessing the
source files in the target and all targets that transitively depend on it if the platform matches
the regex. See <code>exported_preprocessor_flags</code> for more information.
{/param}
{/call}
{/template}
/***/
{template .compiler_flags_arg}
{call buck.arg}
{param name : 'compiler_flags' /}
{param default : '[]' /}
{param desc}
Flags to use when compiling any of the above sources (which require compilation).
{/param}
{/call}
{/template}
/***/
{template .platform_compiler_flags_arg}
{call buck.arg}
{param name : 'platform_compiler_flags' /}
{param default : '[]' /}
{param desc}
Platform specific compiler flags. These should be specified as a list of pairs where the first
element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform
name is matched, and the second element is a list of flags to use when compiling the target's
sources. See <code>compiler_flags</code> for more information.
{/param}
{/call}
{/template}
/***/
{template .lang_compiler_flags_arg}
{call buck.arg}
{param name : 'lang_compiler_flags' /}
{{param default : '{}' /}}
{param desc}
Language-specific compiler flags. These should be specified as a map of C-family language short
names to lists of flags and is used to target flags to sources files for a specific language in the
C-family (C, C++, assembler, etc.). The keys in the map can be:
<ul>
<li>
<code>cpp-output</code> for C
</li>
<li>
<code>c++-cpp-output</code> for C++
</li>
<li>
<code>objective-c-cpp-output</code> for Objective-C
</li>
<li>
<code>objective-c++-cpp-output</code> for Objective-C++
</li>
<li>
<code>cuda-cpp-output</code> for Cuda
</li>
<li>
<code>assembler</code> for Assembly
</li>
<li>
<code>asm</code> for ASM
</li>
</ul>
{/param}
{/call}
{/template}
/***/
{template .lang_platform_compiler_flags_arg}
{call buck.arg}
{param name : 'lang_platform_compiler_flags' /}
{{param default : '{}' /}}
{param desc}
Language- and platform-specific compiler flags. These should be specified as a map of C-family language short
names, as described in <code>lang_compiler_flags</code>, to lists of pairs, as described in <code>platform_compiler_flags</code>.
{/param}
{/call}
{/template}
/***/
{template .linker_extra_outputs_arg}
{call buck.arg}
{param name : 'linker_extra_outputs' /}
{param default : '[]' /}
{param desc}
Declares extra outputs that the linker emits. These identifiers can be used in
{sp}<code>$(output ...)</code> macros in <code>linker_flags</code> to interpolate the output path
into the linker command line. Useful for custom linkers that emit extra output files.
{/param}
{/call}
{/template}
/***/
{template .linker_flags_arg}
{call buck.arg}
{param name : 'linker_flags' /}
{param default : '[]' /}
{param desc}
Flags to add to the linker command line whenever the output from this
rule is used in a link operation, such as linked into an executable
or a shared library.
{/param}
{/call}
{/template}
/***/
{template .platform_linker_flags_arg}
{call buck.arg}
{param name : 'platform_linker_flags' /}
{param default : '[]' /}
{param desc}
Platform-specific linker flags. This argument is specified as a list of pairs where the first
element in each pair is an un-anchored regex against which the platform name is matched.
The regex should use <code>java.util.regex.Pattern</code> syntax.
The second element in each pair is a list of linker flags. If the regex matches the
platform, these flags are added to the linker command line when the
output from this rule is used in a link operation.
{/param}
{/call}
{/template}
/***/
{template .exported_linker_flags_arg}
{call buck.arg}
{param name : 'exported_linker_flags' /}
{param default : '[]' /}
{param desc}
Flags to add to the linker command line when the output from this
rule, or the output from any rule that transitively depends on this
rule, is used in a link operation.
{/param}
{/call}
{/template}
/***/
{template .exported_post_linker_flags_arg}
{call buck.arg}
{param name : 'exported_post_linker_flags' /}
{param default : '[]' /}
{param desc}
Flags to add to the linker command line when the output from this
rule, or the output from any rule that transitively depends on this
rule, is used in a link operation—with the additional feature
that these flags are guaranteed to be placed <em>after</em> the compiled
object (<code>.o</code>) files on the linker command line.
{/param}
{/call}
{/template}
/***/
{template .exported_platform_linker_flags_arg}
{call buck.arg}
{param name : 'exported_platform_linker_flags' /}
{param default : '[]' /}
{param desc}
Platform-specific linker flags for this rule and for all rules that
transitively depend on this rule. This argument is specified
as a list of pairs where the first element in each pair is an un-anchored regex
against which the platform name is matched.
The regex should use <code>java.util.regex.Pattern</code> syntax.
The second element in each pair is a list of linker flags. If the regex matches the
platform, these flags are added to the linker command line when the output from
this rule, or the output from any rule that transitively depends on
this rule, is used in a link operation.
{/param}
{/call}
{/template}
/***/
{template .exported_post_platform_linker_flags_arg}
{call buck.arg}
{param name : 'exported_post_platform_linker_flags' /}
{param default : '[]' /}
{param desc}
Platform-specific linker flags for this rule and for all
rules that transitively depend on this rule—and that
are guaranteed to be placed <em>after</em> the compiled object
(<code>.o</code>) files on the linker command line. In other respects,
the syntax and semantics of this argument are the same as
for the <code>exported_platform_linker_flags</code> argument.
{/param}
{/call}
{/template}
/***/
{template .precompiled_header_arg}
{call buck.arg}
{param name : 'precompiled_header' /}
{param default : 'None' /}
{param desc}
Path to a{sp}
<a href="{ROOT}rule/cxx_precompiled_header.html"><code>cxx_precompiled_header</code></a>{sp}
to use when compiling this rule's sources. The precompiled header (PCH) is built on-demand, using
compiler flags matching those used in this rule's compile jobs. This is to ensure
compatibility between this rule and the PCH. Also, this rule will inherit additional
{sp}<code>deps</code>{sp} from the PCH rule, and as a result, additional include paths as well
(e.g. <code>-I</code>, <code>-isystem</code>, <code>-iquote</code> path lists,
and framework paths specified with <code>-F</code>).
{/param}
{/call}
{/template}
/***/
{template .force_static}
{call buck.arg}
{param name : 'force_static' /}
{param default: 'False' /}
{param desc}
DEPRECATED: <code>See preferred_linkage</code>.
If <code>true</code>, the library will always be linked statically, even if the target that
depends on it specifies <code>link_style</code> to be something other than <code>static</code>.
Note that this may still cause the library to be linked into its own shared library, if it happens
to be the root of the linkable dependency tree (e.g. if a Python library directly depends on the
library with <code>force_static=True</code>).
Also note this will cause duplicate symbols if multiple targets that depend on the library are linked
together.
{/param}
{/call}
{/template}
/***/
{template .reexport_all_header_dependencies_arg}
{call buck.arg}
{param name : 'reexport_all_header_dependencies' /}
{param default: 'True' /}
{param desc}
Whether to automatically re-export the exported headers of all dependencies.
<p>
When this is set to false, only exported headers from
{sp}<code>exported_deps</code> are re-exported.
{/param}
{/call}
{/template}
/***/
{template .exported_deps_arg}
{call buck.arg}
{param name : 'exported_deps' /}
{param default: '[]' /}
{param desc}
Dependencies that will also appear to belong to any rules that depend on this
one. This has two effects:
<ul>
<li>
Exported dependencies will also be included in the link line of
dependents of this rules, but normal dependencies will not.
</li>
<li>
When <code>reexport_all_header_dependencies = False</code>, only exported
headers of the rules specified here are re-exported.
</li>
</ul>
{/param}
{/call}
{/template}
/***/
{template .exported_platform_deps_arg}
{call buck.arg}
{param name : 'exported_platform_deps' /}
{param default: '[]' /}
{param desc}
Platform specific dependencies that will also appear to belong to any rules
that depend on this one.
These should be specified as a list of pairs where the first element is an
un-anchored regex (in java.util.regex.Pattern syntax) against which the
platform name is matched, and the second element is a list of external
dependencies (same format as <code>exported_deps</code>) that are exported
if the platform matches the regex.
See <code>exported_deps</code> for more information.
{/param}
{/call}
{/template}
/***/
{template .supports_merged_linking}
{call buck.arg}
{param name : 'supports_merged_linking' /}
{param default : 'True' /}
{param desc}
Whether this rule supports building with the merged linking strategy when building for non-native
binaries (e.g. when using {call buckconfig.python_native_link_strategy /}s <code>merged</code> setting).
{/param}
{/call}
{/template}
/***/
{template .raw_headers_arg}
{call buck.arg}
{param name : 'raw_headers' /}
{param default : '[]' /}
{param desc}
The set of header files that can be used for inclusion to the source files in the target and all
targets that transitively depend on it. Buck doesn't add raw headers to the search path of a
compiler/preprocessor automatically.
<code>include_directories</code> and <code>public_include_directories</code> are the recommended
way to add raw headers to the search path (they will be added via <code>-I</code>).
<code>compiler_flags</code>, <code>preprocessor_flags</code> and <code>exported_preprocessor_flags</code>
can also be used to add such raw headers to the search path if inclusion via <code>-isystem</code> or
<code>-iquote</code> is needed.
<code>raw_headers</code> cannot be used together with <code>headers</code> or <code>exported_headers</code> in the same target.
{/param}
{/call}
{/template}
/***/
{template .include_directories_arg}
{call buck.arg}
{param name : 'include_directories' /}
{param default : '[]' /}
{param desc}
A list of include directories (with <code>raw_headers</code>) to be added to the compile command for compiling this target
(via <code>-I</code>).
An include directory is relative to the current package.
{/param}
{/call}
{/template}
/***/
{template .public_include_directories_arg}
{call buck.arg}
{param name : 'public_include_directories' /}
{param default : '[]' /}
{param desc}
A list of include directories (with <code>raw_headers</code>) to be added to the compile command for compiling this target
and every target that depends on it (via <code>-I</code>). An include directory is relative to the current package.
{/param}
{/call}
{/template}
/***/
{template .public_system_include_directories_arg}
{call buck.arg}
{param name : 'public_system_include_directories' /}
{param default : '[]' /}
{param desc}
A list of include directories (with <code>raw_headers</code>) to be added to the compile command for compiling this target
and every target that depends on it (via <code>-isystem</code> if the compiler supports it of via <code>-I</code> otherwise).
An include directory is relative to the current package.
{/param}
{/call}
{/template}