-
Notifications
You must be signed in to change notification settings - Fork 4k
/
CcModuleApi.java
1306 lines (1275 loc) · 50.5 KB
/
CcModuleApi.java
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
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2018 The Bazel Authors. All rights reserved.
//
// 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.
package com.google.devtools.build.lib.starlarkbuildapi.cpp;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.Depset;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import com.google.devtools.build.lib.starlarkbuildapi.FileApi;
import com.google.devtools.build.lib.starlarkbuildapi.StarlarkActionFactoryApi;
import com.google.devtools.build.lib.starlarkbuildapi.StarlarkRuleContextApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.platform.ConstraintValueInfoApi;
import net.starlark.java.annot.Param;
import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkThread;
import net.starlark.java.eval.StarlarkValue;
import net.starlark.java.eval.Tuple;
/** Utilites related to C++ support. */
@StarlarkBuiltin(
name = "cc_common",
doc = "Utilities for C++ compilation, linking, and command line generation.")
public interface CcModuleApi<
StarlarkActionFactoryT extends StarlarkActionFactoryApi,
FileT extends FileApi,
FdoContextT extends FdoContextApi<?>,
CcToolchainProviderT extends CcToolchainProviderApi<FeatureConfigurationT, ?, FdoContextT>,
FeatureConfigurationT extends FeatureConfigurationApi,
CompilationContextT extends CcCompilationContextApi<FileT>,
LtoBackendArtifactsT extends LtoBackendArtifactsApi<FileT>,
LinkerInputT extends LinkerInputApi<LibraryToLinkT, LtoBackendArtifactsT, FileT>,
LinkingContextT extends CcLinkingContextApi<?>,
LibraryToLinkT extends LibraryToLinkApi<FileT, LtoBackendArtifactsT>,
CcToolchainVariablesT extends CcToolchainVariablesApi,
ConstraintValueT extends ConstraintValueInfoApi,
StarlarkRuleContextT extends StarlarkRuleContextApi<ConstraintValueT>,
CcToolchainConfigInfoT extends CcToolchainConfigInfoApi,
CompilationOutputsT extends CcCompilationOutputsApi<FileT>,
DebugInfoT extends CcDebugInfoContextApi,
CppModuleMapT extends CppModuleMapApi<FileT>>
extends StarlarkValue {
@StarlarkMethod(
name = "CcToolchainInfo",
doc =
"The key used to retrieve the provider that contains information about the C++ "
+ "toolchain being used",
structField = true)
ProviderApi getCcToolchainProvider();
@Deprecated
@StarlarkMethod(
name = "do_not_use_tools_cpp_compiler_present",
doc =
"Do not use this field, its only puprose is to help with migration from "
+ "config_setting.values{'compiler') to "
+ "config_settings.flag_values{'@bazel_tools//tools/cpp:compiler'}",
structField = true)
default void compilerFlagExists() {}
@StarlarkMethod(
name = "configure_features",
doc = "Creates a feature_configuration instance. Requires the cpp configuration fragment.",
parameters = {
@Param(
name = "ctx",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = StarlarkRuleContextApi.class),
@ParamType(type = NoneType.class),
},
doc = "The rule context."),
@Param(
name = "cc_toolchain",
doc = "cc_toolchain for which we configure features.",
positional = false,
named = true),
@Param(
name = "requested_features",
doc = "List of features to be enabled.",
positional = false,
named = true,
defaultValue = "[]"),
@Param(
name = "unsupported_features",
doc = "List of features that are unsupported by the current rule.",
positional = false,
named = true,
defaultValue = "[]"),
})
FeatureConfigurationT configureFeatures(
Object ruleContextOrNone,
CcToolchainProviderT toolchain,
Sequence<?> requestedFeatures, // <String> expected
Sequence<?> unsupportedFeatures) // <String> expected
throws EvalException;
@StarlarkMethod(
name = "get_tool_for_action",
doc = "Returns tool path for given action.",
parameters = {
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
named = true),
@Param(
name = "action_name",
doc =
"Name of the action. Has to be one of the names in "
+ "@bazel_tools//tools/build_defs/cc:action_names.bzl "
+ "(https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/"
+ "action_names.bzl)",
named = true,
positional = false),
})
String getToolForAction(FeatureConfigurationT featureConfiguration, String actionName);
@StarlarkMethod(
name = "get_execution_requirements",
doc = "Returns execution requirements for given action.",
parameters = {
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
named = true),
@Param(
name = "action_name",
doc =
"Name of the action. Has to be one of the names in "
+ "@bazel_tools//tools/build_defs/cc:action_names.bzl "
+ "(https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/"
+ "action_names.bzl)",
named = true,
positional = false),
})
Sequence<String> getExecutionRequirements(
FeatureConfigurationT featureConfiguration, String actionName);
@StarlarkMethod(
name = "is_enabled",
doc = "Returns True if given feature is enabled in the feature configuration.",
parameters = {
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
named = true),
@Param(
name = "feature_name",
doc = "Name of the feature.",
named = true,
positional = false),
})
boolean isEnabled(FeatureConfigurationT featureConfiguration, String featureName);
@StarlarkMethod(
name = "action_is_enabled",
doc = "Returns True if given action_config is enabled in the feature configuration.",
parameters = {
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
named = true),
@Param(
name = "action_name",
doc = "Name of the action_config.",
named = true,
positional = false),
})
boolean actionIsEnabled(FeatureConfigurationT featureConfiguration, String actionName);
@StarlarkMethod(
name = "get_memory_inefficient_command_line",
doc =
"Returns flattened command line flags for given action, using given variables for "
+ "expansion. Flattens nested sets and ideally should not be used, or at least "
+ "should not outlive analysis. Work on memory efficient function returning Args is "
+ "ongoing.",
parameters = {
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
named = true),
@Param(
name = "action_name",
doc =
"Name of the action. Has to be one of the names in "
+ "@bazel_tools//tools/build_defs/cc:action_names.bzl "
+ "(https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/"
+ "action_names.bzl)",
named = true,
positional = false),
@Param(
name = "variables",
doc = "Build variables to be used for template expansions.",
named = true,
positional = false),
})
Sequence<String> getCommandLine(
FeatureConfigurationT featureConfiguration,
String actionName,
CcToolchainVariablesT variables)
throws EvalException;
@StarlarkMethod(
name = "get_environment_variables",
doc = "Returns environment variables to be set for given action.",
parameters = {
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
named = true),
@Param(
name = "action_name",
doc =
"Name of the action. Has to be one of the names in "
+ "@bazel_tools//tools/build_defs/cc:action_names.bzl "
+ "(https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/"
+ "action_names.bzl)",
named = true,
positional = false),
@Param(
name = "variables",
doc = "Build variables to be used for template expansion.",
positional = false,
named = true),
})
Dict<String, String> getEnvironmentVariable(
FeatureConfigurationT featureConfiguration,
String actionName,
CcToolchainVariablesT variables)
throws EvalException;
@StarlarkMethod(
name = "create_compile_variables",
doc = "Returns variables used for compilation actions.",
parameters = {
@Param(
name = "cc_toolchain",
doc = "cc_toolchain for which we are creating build variables.",
positional = false,
named = true),
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
named = true),
@Param(
name = "source_file",
doc =
"Optional source file for the compilation. Please prefer passing source_file here "
+ "over appending it to the end of the command line generated from "
+ "cc_common.get_memory_inefficient_command_line, as then it's in the power of "
+ "the toolchain author to properly specify and position compiler flags.",
named = true,
positional = false,
defaultValue = "None"),
@Param(
name = "output_file",
doc =
"Optional output file of the compilation. Please prefer passing output_file here "
+ "over appending it to the end of the command line generated from "
+ "cc_common.get_memory_inefficient_command_line, as then it's in the power of "
+ "the toolchain author to properly specify and position compiler flags.",
named = true,
positional = false,
defaultValue = "None"),
@Param(
name = "user_compile_flags",
doc = "List of additional compilation flags (copts).",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = Sequence.class, generic1 = String.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "include_directories",
doc = "Depset of include directories.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = Depset.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "quote_include_directories",
doc = "Depset of quote include directories.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = Depset.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "system_include_directories",
doc = "Depset of system include directories.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = Depset.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "framework_include_directories",
doc = "Depset of framework include directories.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = Depset.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "preprocessor_defines",
doc = "Depset of preprocessor defines.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = Depset.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "thinlto_index",
doc = "LTO index file path.",
named = true,
positional = false,
defaultValue = "None",
allowedTypes = {
@ParamType(type = String.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "thinlto_input_bitcode_file",
doc = "Bitcode file that is input to LTO backend.",
named = true,
positional = false,
defaultValue = "None",
allowedTypes = {
@ParamType(type = String.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "thinlto_output_object_file",
doc = "Object file that is output by LTO backend.",
named = true,
positional = false,
defaultValue = "None",
allowedTypes = {
@ParamType(type = String.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "use_pic",
doc = "When true the compilation will generate position independent code.",
positional = false,
named = true,
defaultValue = "False"),
// TODO(b/65151735): Remove once we migrate crosstools to features
@Param(
name = "add_legacy_cxx_options",
doc = "Unused.",
named = true,
positional = false,
defaultValue = "False"),
@Param(
name = "variables_extension",
doc = "A dictionary of additional variables used by compile actions.",
named = true,
positional = false,
allowedTypes = {@ParamType(type = Dict.class)},
defaultValue = "unbound"),
})
CcToolchainVariablesT getCompileBuildVariables(
CcToolchainProviderT ccToolchainProvider,
FeatureConfigurationT featureConfiguration,
Object sourceFile,
Object outputFile,
Object userCompileFlags,
Object includeDirs,
Object quoteIncludeDirs,
Object systemIncludeDirs,
Object frameworkIncludeDirs,
Object defines,
Object thinLtoIndex,
Object thinLtoInputBitcodeFile,
Object thinLtoOutputObjectFile,
boolean usePic,
boolean addLegacyCxxOptions,
Object variablesExtension)
throws EvalException;
@StarlarkMethod(
name = "create_link_variables",
doc = "Returns link variables used for linking actions.",
parameters = {
@Param(
name = "cc_toolchain",
doc = "cc_toolchain for which we are creating build variables.",
positional = false,
named = true),
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
named = true),
@Param(
name = "library_search_directories",
doc = "Depset of directories where linker will look for libraries at link time.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
name = "runtime_library_search_directories",
doc = "Depset of directories where loader will look for libraries at runtime.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
name = "user_link_flags",
doc = "List of additional link flags (linkopts).",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Sequence.class)}),
@Param(
name = "output_file",
doc = "Optional output file path.",
named = true,
positional = false,
defaultValue = "None"),
@Param(
name = "param_file",
doc = "Optional param file path.",
named = true,
positional = false,
defaultValue = "None"),
@Param(
name = "def_file",
doc = "Optional .def file path.",
named = true,
positional = false,
defaultValue = "None"),
// TODO(b/65151735): Remove once we migrate crosstools to features
@Param(
name = "is_using_linker",
doc =
"True when using linker, False when archiver. Caller is responsible for keeping "
+ "this in sync with action name used (is_using_linker = True for linking "
+ "executable or dynamic library, is_using_linker = False for archiving static "
+ "library).",
named = true,
positional = false,
defaultValue = "True"),
// TODO(b/65151735): Remove once we migrate crosstools to features
@Param(
name = "is_linking_dynamic_library",
doc =
"True when creating dynamic library, False when executable or static library. "
+ "Caller is responsible for keeping this in sync with action name used. "
+ ""
+ "This field will be removed once b/65151735 is fixed.",
named = true,
positional = false,
defaultValue = "False"),
@Param(
name = "must_keep_debug",
doc =
"When set to True, bazel will expose 'strip_debug_symbols' variable, which is "
+ "usually used to use the linker to strip debug symbols from the output file.",
named = true,
positional = false,
defaultValue = "True"),
@Param(
name = "use_test_only_flags",
doc = "When set to true, 'is_cc_test' variable will be set.",
named = true,
positional = false,
defaultValue = "False"),
// TODO(b/65151735): Remove once we migrate crosstools to features
@Param(
name = "is_static_linking_mode",
doc = "Unused.",
named = true,
positional = false,
defaultValue = "True"),
})
CcToolchainVariablesT getLinkBuildVariables(
CcToolchainProviderT ccToolchainProvider,
FeatureConfigurationT featureConfiguration,
Object librarySearchDirectories,
Object runtimeLibrarySearchDirectories,
Object userLinkFlags,
Object outputFile,
Object paramFile,
Object defFile,
boolean isUsingLinkerNotArchiver,
boolean isCreatingSharedLibrary,
boolean mustKeepDebug,
boolean useTestOnlyFlags,
boolean isStaticLinkingMode)
throws EvalException;
@StarlarkMethod(name = "empty_variables", documented = false)
CcToolchainVariablesT getVariables();
@StarlarkMethod(
name = "create_library_to_link",
doc = "Creates <code>LibraryToLink</code>",
useStarlarkThread = true,
parameters = {
@Param(
name = "actions",
positional = false,
named = true,
doc = "<code>actions</code> object."),
@Param(
name = "feature_configuration",
doc = "<code>feature_configuration</code> to be queried.",
positional = false,
named = true),
@Param(
name = "cc_toolchain",
doc = "<code>CcToolchainInfo</code> provider to be used.",
positional = false,
named = true),
@Param(
name = "static_library",
doc = "<code>File</code> of static library to be linked.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "pic_static_library",
doc = "<code>File</code> of pic static library to be linked.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "dynamic_library",
doc =
"<code>File</code> of dynamic library to be linked. Always used for runtime "
+ "and used for linking if <code>interface_library</code> is not passed.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "interface_library",
doc = "<code>File</code> of interface library to be linked.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
}),
@Param(
name = "pic_objects",
doc = "Experimental, do not use",
positional = false,
named = true,
defaultValue = "unbound",
allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)}),
@Param(
name = "objects",
doc = "Experimental, do not use",
positional = false,
named = true,
defaultValue = "unbound",
allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)}),
@Param(
name = "alwayslink",
doc = "Whether to link the static library/objects in the --whole_archive block.",
positional = false,
named = true,
defaultValue = "False"),
@Param(
name = "dynamic_library_symlink_path",
doc =
"Override the default path of the dynamic library link in the solib directory. "
+ "Empty string to use the default.",
positional = false,
named = true,
allowedTypes = {
@ParamType(type = String.class),
},
defaultValue = "''"),
@Param(
name = "interface_library_symlink_path",
doc =
"Override the default path of the interface library link in the solib directory. "
+ "Empty string to use the default.",
positional = false,
named = true,
defaultValue = "''"),
@Param(
name = "must_keep_debug",
documented = false,
positional = false,
named = true,
defaultValue = "unbound"),
})
LibraryToLinkT createLibraryLinkerInput(
Object actions,
Object featureConfiguration,
Object ccToolchainProvider,
Object staticLibrary,
Object picStaticLibrary,
Object dynamicLibrary,
Object interfaceLibrary,
Object picObjectFiles, // Sequence<Artifact> expected
Object nopicObjectFiles, // Sequence<Artifact> expected
boolean alwayslink,
String dynamicLibraryPath,
String interfaceLibraryPath,
Object mustKeepDebug,
StarlarkThread thread)
throws EvalException, InterruptedException;
@StarlarkMethod(
name = "create_linker_input",
doc = "Creates a <code>LinkerInput</code>.",
useStarlarkThread = true,
parameters = {
@Param(
name = "owner",
doc = "The label of the target that produced all files used in this input.",
positional = false,
named = true),
@Param(
name = "libraries",
doc = "List of <code>LibraryToLink</code>.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
name = "user_link_flags",
doc =
"User link flags passed as strings. Accepts either [String], [[String]] or"
+ " depset(String). The latter is discouraged as it's only kept for"
+ " compatibility purposes, the depset is flattened. If you want to propagate"
+ " user_link_flags via unflattened depsets() wrap them in a LinkerInput so"
+ " that they are not flattened till the end.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = NoneType.class),
@ParamType(type = Depset.class, generic1 = String.class),
@ParamType(type = Sequence.class, generic1 = String.class)
}),
@Param(
name = "additional_inputs",
doc = "For additional inputs to the linking action, e.g.: linking scripts.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
name = "linkstamps",
documented = false,
positional = false,
named = true,
defaultValue = "unbound",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
})
LinkerInputT createLinkerInput(
Label owner,
Object librariesToLinkObject,
Object userLinkFlagsObject,
Object nonCodeInputs,
Object linkstamps,
StarlarkThread thread)
throws EvalException, InterruptedException;
@StarlarkMethod(
name = "check_experimental_cc_shared_library",
doc = "DO NOT USE. This is to guard use of cc_shared_library.",
useStarlarkThread = true,
documented = false)
void checkExperimentalCcSharedLibrary(StarlarkThread thread) throws EvalException;
@StarlarkMethod(
name = "check_experimental_starlark_cc_import",
doc = "DO NOT USE. This is to guard use of cc_import.bzl",
documented = false,
parameters = {
@Param(
name = "actions",
positional = false,
named = true,
doc = "<code>actions</code> object."),
})
void checkExperimentalStarlarkCcImport(StarlarkActionFactoryT starlarkActionFactoryApi)
throws EvalException;
@StarlarkMethod(
name = "create_linking_context",
doc = "Creates a <code>LinkingContext</code>.",
useStarlarkThread = true,
parameters = {
@Param(
name = "linker_inputs",
doc = "Depset of <code>LinkerInput</code>.",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
name = "libraries_to_link",
doc = "List of <code>LibraryToLink</code>.",
positional = false,
named = true,
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API,
defaultValue = "None",
valueWhenDisabled = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Sequence.class)}),
@Param(
name = "user_link_flags",
doc = "List of user link flags passed as strings.",
positional = false,
named = true,
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API,
defaultValue = "None",
valueWhenDisabled = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Sequence.class)}),
@Param(
name = "additional_inputs",
doc = "For additional inputs to the linking action, e.g.: linking scripts.",
positional = false,
named = true,
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API,
defaultValue = "None",
valueWhenDisabled = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Sequence.class)}),
@Param(
name = "go_link_c_archive",
documented = false,
positional = false,
named = true,
defaultValue = "unbound",
allowedTypes = {
@ParamType(type = ExtraLinkTimeLibraryApi.class),
@ParamType(type = NoneType.class)
})
})
LinkingContextT createCcLinkingInfo(
Object linkerInputs,
Object librariesToLinkObject,
Object userLinkFlagsObject,
Object nonCodeInputs, // <FileT> expected
Object goLinkCArchive,
StarlarkThread thread)
throws EvalException, InterruptedException;
@StarlarkMethod(
name = "merge_cc_infos",
doc = "Merges multiple <code>CcInfo</code>s into one.",
parameters = {
@Param(
name = "direct_cc_infos",
doc =
"List of <code>CcInfo</code>s to be merged, whose headers will be exported by "
+ "the direct fields in the returned provider.",
positional = false,
named = true,
defaultValue = "[]"),
@Param(
name = "cc_infos",
doc =
"List of <code>CcInfo</code>s to be merged, whose headers will not be exported "
+ "by the direct fields in the returned provider.",
positional = false,
named = true,
defaultValue = "[]")
})
CcInfoApi<FileT> mergeCcInfos(
Sequence<?> directCcInfos, // <CcInfoApi> expected
Sequence<?> ccInfos) // <CcInfoApi> expected
throws EvalException;
@StarlarkMethod(
name = "create_compilation_context",
doc = "Creates a <code>CompilationContext</code>.",
useStarlarkThread = true,
parameters = {
@Param(
name = "headers",
doc = "Set of headers needed to compile this target",
positional = false,
named = true,
defaultValue = "unbound"),
@Param(
name = "system_includes",
doc =
"Set of search paths for header files referenced by angle brackets, i.e. "
+ "#include <foo/bar/header.h>. They can be either relative to the exec "
+ "root or absolute. Usually passed with -isystem",
positional = false,
named = true,
defaultValue = "unbound"),
@Param(
name = "includes",
doc =
"Set of search paths for header files referenced both by angle bracket and quotes."
+ "Usually passed with -I",
positional = false,
named = true,
defaultValue = "unbound"),
@Param(
name = "quote_includes",
doc =
"Set of search paths for header files referenced by quotes, i.e. "
+ "#include \"foo/bar/header.h\". They can be either relative to the exec "
+ "root or absolute. Usually passed with -iquote",
positional = false,
named = true,
defaultValue = "unbound"),
@Param(
name = "framework_includes",
doc = "Set of framework search paths for header files (Apple platform only)",
positional = false,
named = true,
defaultValue = "unbound"),
@Param(
name = "defines",
doc =
"Set of defines needed to compile this target. Each define is a string. Propagated"
+ " transitively to dependents.",
positional = false,
named = true,
defaultValue = "unbound"),
@Param(
name = "local_defines",
doc =
"Set of defines needed to compile this target. Each define is a string. Not"
+ " propagated transitively to dependents.",
positional = false,
named = true,
defaultValue = "unbound"),
@Param(
name = "direct_textual_headers",
documented = false,
positional = false,
named = true,
defaultValue = "[]"),
@Param(
name = "direct_public_headers",
documented = false,
positional = false,
named = true,
defaultValue = "[]"),
@Param(
name = "direct_private_headers",
documented = false,
positional = false,
named = true,
defaultValue = "[]"),
@Param(
name = "purpose",
documented = false,
positional = false,
named = true,
defaultValue = "unbound"),
})
CompilationContextT createCcCompilationContext(
Object headers,
Object systemIncludes,
Object includes,
Object quoteIncludes,
Object frameworkIncludes,
Object defines,
Object localDefines,
Sequence<?> directTextualHdrs,
Sequence<?> directPublicHdrs,
Sequence<?> directPrivateHdrs,
Object purpose,
StarlarkThread thread)
throws EvalException;
@StarlarkMethod(
name = "create_module_map",
documented = false,
doc = "Creates a <code>CcModuleMap</code>.",
useStarlarkThread = true,
parameters = {
@Param(name = "file", positional = false, named = true),
@Param(
name = "umbrella_header",
positional = false,
named = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = FileApi.class), @ParamType(type = NoneType.class)}),
@Param(name = "name", positional = false, named = true),
})
CppModuleMapT createCppModuleMap(
FileT file, Object umbrellaHeader, String name, StarlarkThread thread) throws EvalException;
// TODO(b/65151735): Remove when cc_flags is entirely set from features.
// This should only be called from the cc_flags_supplier rule.
@StarlarkMethod(
name = "legacy_cc_flags_make_variable_do_not_use",
documented = false,
parameters = {
@Param(
name = "cc_toolchain",
doc = "C++ toolchain provider to be used.",
positional = false,
named = true)
})
String legacyCcFlagsMakeVariable(CcToolchainProviderT ccToolchain);
@StarlarkMethod(
name = "is_cc_toolchain_resolution_enabled_do_not_use",
documented = false,
parameters = {
@Param(name = "ctx", positional = false, named = true, doc = "The rule context."),
},
doc = "Returns true if the --incompatible_enable_cc_toolchain_resolution flag is enabled.")
boolean isCcToolchainResolutionEnabled(StarlarkRuleContextT ruleContext);
@StarlarkMethod(
name = "create_cc_toolchain_config_info",
doc = "Creates a <code>CcToolchainConfigInfo</code> provider",
parameters = {
@Param(name = "ctx", positional = false, named = true, doc = "The rule context."),
@Param(
name = "features",
positional = false,
named = true,
defaultValue = "[]",
doc =
"A list of <a href=\"https://github.com/bazelbuild/bazel/blob/master/tools/cpp/"
+ "cc_toolchain_config_lib.bzl#L336\">features</a>."),
@Param(
name = "action_configs",
positional = false,
named = true,
defaultValue = "[]",
doc =
"A list of <a href=\"https://github.com/bazelbuild/bazel/blob/master/tools/cpp/"
+ "cc_toolchain_config_lib.bzl#L461\">action_configs</a>."),
@Param(
name = "artifact_name_patterns",
positional = false,
named = true,
defaultValue = "[]",
doc =
"A list of <a href=\"https://github.com/bazelbuild/bazel/blob/master/tools/cpp/"
+ "cc_toolchain_config_lib.bzl#L516\">artifact_name_patterns</a>."),
@Param(
name = "cxx_builtin_include_directories",
positional = false,
named = true,
defaultValue = "[]",