xref: /aosp_15_r20/external/bazelbuild-rules_cc/cc/toolchains/actions/BUILD (revision eed53cd41c5909d05eedc7ad9720bb158fd93452)
1*eed53cd4SHONG Yifan# Copyright 2024 The Bazel Authors. All rights reserved.
2*eed53cd4SHONG Yifan#
3*eed53cd4SHONG Yifan# Licensed under the Apache License, Version 2.0 (the "License");
4*eed53cd4SHONG Yifan# you may not use this file except in compliance with the License.
5*eed53cd4SHONG Yifan# You may obtain a copy of the License at
6*eed53cd4SHONG Yifan#
7*eed53cd4SHONG Yifan#    http://www.apache.org/licenses/LICENSE-2.0
8*eed53cd4SHONG Yifan#
9*eed53cd4SHONG Yifan# Unless required by applicable law or agreed to in writing, software
10*eed53cd4SHONG Yifan# distributed under the License is distributed on an "AS IS" BASIS,
11*eed53cd4SHONG Yifan# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*eed53cd4SHONG Yifan# See the License for the specific language governing permissions and
13*eed53cd4SHONG Yifan# limitations under the License.
14*eed53cd4SHONG Yifanload("//cc:action_names.bzl", "ACTION_NAMES")
15*eed53cd4SHONG Yifanload("//cc/toolchains:actions.bzl", "cc_action_type", "cc_action_type_set")
16*eed53cd4SHONG Yifan
17*eed53cd4SHONG Yifanpackage(default_visibility = ["//visibility:public"])
18*eed53cd4SHONG Yifan
19*eed53cd4SHONG Yifan# Keep in sync with //cc:action_names.bzl.
20*eed53cd4SHONG Yifan
21*eed53cd4SHONG Yifancc_action_type(
22*eed53cd4SHONG Yifan    name = "c_compile",
23*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.c_compile,
24*eed53cd4SHONG Yifan)
25*eed53cd4SHONG Yifan
26*eed53cd4SHONG Yifancc_action_type(
27*eed53cd4SHONG Yifan    name = "cpp_compile",
28*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cpp_compile,
29*eed53cd4SHONG Yifan)
30*eed53cd4SHONG Yifan
31*eed53cd4SHONG Yifancc_action_type(
32*eed53cd4SHONG Yifan    name = "linkstamp_compile",
33*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.linkstamp_compile,
34*eed53cd4SHONG Yifan)
35*eed53cd4SHONG Yifan
36*eed53cd4SHONG Yifancc_action_type(
37*eed53cd4SHONG Yifan    name = "cc_flags_make_variable",
38*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cc_flags_make_variable,
39*eed53cd4SHONG Yifan)
40*eed53cd4SHONG Yifan
41*eed53cd4SHONG Yifancc_action_type(
42*eed53cd4SHONG Yifan    name = "cpp_module_codegen",
43*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cpp_module_codegen,
44*eed53cd4SHONG Yifan)
45*eed53cd4SHONG Yifan
46*eed53cd4SHONG Yifancc_action_type(
47*eed53cd4SHONG Yifan    name = "cpp_header_analysis",
48*eed53cd4SHONG Yifan    action_name = "c++-header-analysis",
49*eed53cd4SHONG Yifan)
50*eed53cd4SHONG Yifan
51*eed53cd4SHONG Yifancc_action_type(
52*eed53cd4SHONG Yifan    name = "cpp_header_parsing",
53*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cpp_header_parsing,
54*eed53cd4SHONG Yifan)
55*eed53cd4SHONG Yifan
56*eed53cd4SHONG Yifancc_action_type(
57*eed53cd4SHONG Yifan    name = "cpp_module_compile",
58*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cpp_module_compile,
59*eed53cd4SHONG Yifan)
60*eed53cd4SHONG Yifan
61*eed53cd4SHONG Yifancc_action_type(
62*eed53cd4SHONG Yifan    name = "assemble",
63*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.assemble,
64*eed53cd4SHONG Yifan)
65*eed53cd4SHONG Yifan
66*eed53cd4SHONG Yifancc_action_type(
67*eed53cd4SHONG Yifan    name = "preprocess_assemble",
68*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.preprocess_assemble,
69*eed53cd4SHONG Yifan)
70*eed53cd4SHONG Yifan
71*eed53cd4SHONG Yifancc_action_type(
72*eed53cd4SHONG Yifan    name = "lto_indexing",
73*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.lto_indexing,
74*eed53cd4SHONG Yifan)
75*eed53cd4SHONG Yifan
76*eed53cd4SHONG Yifancc_action_type(
77*eed53cd4SHONG Yifan    name = "lto_backend",
78*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.lto_backend,
79*eed53cd4SHONG Yifan)
80*eed53cd4SHONG Yifan
81*eed53cd4SHONG Yifancc_action_type(
82*eed53cd4SHONG Yifan    name = "lto_index_for_executable",
83*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.lto_index_for_executable,
84*eed53cd4SHONG Yifan)
85*eed53cd4SHONG Yifan
86*eed53cd4SHONG Yifancc_action_type(
87*eed53cd4SHONG Yifan    name = "lto_index_for_dynamic_library",
88*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.lto_index_for_dynamic_library,
89*eed53cd4SHONG Yifan)
90*eed53cd4SHONG Yifan
91*eed53cd4SHONG Yifancc_action_type(
92*eed53cd4SHONG Yifan    name = "lto_index_for_nodeps_dynamic_library",
93*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.lto_index_for_nodeps_dynamic_library,
94*eed53cd4SHONG Yifan)
95*eed53cd4SHONG Yifan
96*eed53cd4SHONG Yifancc_action_type(
97*eed53cd4SHONG Yifan    name = "cpp_link_executable",
98*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cpp_link_executable,
99*eed53cd4SHONG Yifan)
100*eed53cd4SHONG Yifan
101*eed53cd4SHONG Yifancc_action_type(
102*eed53cd4SHONG Yifan    name = "cpp_link_dynamic_library",
103*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cpp_link_dynamic_library,
104*eed53cd4SHONG Yifan)
105*eed53cd4SHONG Yifan
106*eed53cd4SHONG Yifancc_action_type(
107*eed53cd4SHONG Yifan    name = "cpp_link_nodeps_dynamic_library",
108*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library,
109*eed53cd4SHONG Yifan)
110*eed53cd4SHONG Yifan
111*eed53cd4SHONG Yifancc_action_type(
112*eed53cd4SHONG Yifan    name = "cpp_link_static_library",
113*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.cpp_link_static_library,
114*eed53cd4SHONG Yifan)
115*eed53cd4SHONG Yifan
116*eed53cd4SHONG Yifancc_action_type(
117*eed53cd4SHONG Yifan    name = "strip",
118*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.strip,
119*eed53cd4SHONG Yifan)
120*eed53cd4SHONG Yifan
121*eed53cd4SHONG Yifancc_action_type(
122*eed53cd4SHONG Yifan    name = "objcopy_embed_data",
123*eed53cd4SHONG Yifan    action_name = "objcopy_embed_data",
124*eed53cd4SHONG Yifan)
125*eed53cd4SHONG Yifan
126*eed53cd4SHONG Yifan# ld_embed_data is only available within google.
127*eed53cd4SHONG Yifancc_action_type(
128*eed53cd4SHONG Yifan    # # copybara-comment-this-out-please
129*eed53cd4SHONG Yifan    name = "ld_embed_data_action",  # # copybara-comment-this-out-please
130*eed53cd4SHONG Yifan    action_name = "ld_embed_data",  # # copybara-comment-this-out-please
131*eed53cd4SHONG Yifan)  # # copybara-comment-this-out-please
132*eed53cd4SHONG Yifan
133*eed53cd4SHONG Yifan# To make things simple, both internal and external rules will refer to
134*eed53cd4SHONG Yifan# ld_embed_data, but externally it will evaluate to the empty set.
135*eed53cd4SHONG Yifancc_action_type_set(
136*eed53cd4SHONG Yifan    name = "ld_embed_data",
137*eed53cd4SHONG Yifan    actions = [
138*eed53cd4SHONG Yifan        ":ld_embed_data_action",  # # copybara-comment-this-out-please
139*eed53cd4SHONG Yifan    ],
140*eed53cd4SHONG Yifan    allow_empty = True,
141*eed53cd4SHONG Yifan    visibility = ["//cc/toolchains:__subpackages__"],
142*eed53cd4SHONG Yifan)
143*eed53cd4SHONG Yifan
144*eed53cd4SHONG Yifancc_action_type(
145*eed53cd4SHONG Yifan    name = "objc_compile",
146*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.objc_compile,
147*eed53cd4SHONG Yifan)
148*eed53cd4SHONG Yifan
149*eed53cd4SHONG Yifancc_action_type(
150*eed53cd4SHONG Yifan    name = "objc_executable",
151*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.objc_executable,
152*eed53cd4SHONG Yifan)
153*eed53cd4SHONG Yifan
154*eed53cd4SHONG Yifancc_action_type(
155*eed53cd4SHONG Yifan    name = "objc_fully_link",
156*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.objc_fully_link,
157*eed53cd4SHONG Yifan)
158*eed53cd4SHONG Yifan
159*eed53cd4SHONG Yifancc_action_type(
160*eed53cd4SHONG Yifan    name = "objcpp_compile",
161*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.objcpp_compile,
162*eed53cd4SHONG Yifan)
163*eed53cd4SHONG Yifan
164*eed53cd4SHONG Yifancc_action_type(
165*eed53cd4SHONG Yifan    name = "objcpp_executable",
166*eed53cd4SHONG Yifan    action_name = "objc++-executable",
167*eed53cd4SHONG Yifan)
168*eed53cd4SHONG Yifan
169*eed53cd4SHONG Yifancc_action_type(
170*eed53cd4SHONG Yifan    name = "clif_match",
171*eed53cd4SHONG Yifan    action_name = ACTION_NAMES.clif_match,
172*eed53cd4SHONG Yifan)
173*eed53cd4SHONG Yifan
174*eed53cd4SHONG Yifancc_action_type_set(
175*eed53cd4SHONG Yifan    name = "ar_actions",
176*eed53cd4SHONG Yifan    actions = [":cpp_link_static_library"],
177*eed53cd4SHONG Yifan)
178*eed53cd4SHONG Yifan
179*eed53cd4SHONG Yifancc_action_type_set(
180*eed53cd4SHONG Yifan    name = "assembly_actions",
181*eed53cd4SHONG Yifan    actions = [
182*eed53cd4SHONG Yifan        ":preprocess_assemble",
183*eed53cd4SHONG Yifan        ":assemble",
184*eed53cd4SHONG Yifan    ],
185*eed53cd4SHONG Yifan)
186*eed53cd4SHONG Yifan
187*eed53cd4SHONG Yifancc_action_type_set(
188*eed53cd4SHONG Yifan    name = "cpp_compile_actions",
189*eed53cd4SHONG Yifan    actions = [
190*eed53cd4SHONG Yifan        ":linkstamp_compile",
191*eed53cd4SHONG Yifan        ":cpp_compile",
192*eed53cd4SHONG Yifan        ":cpp_header_parsing",
193*eed53cd4SHONG Yifan        ":cpp_module_compile",
194*eed53cd4SHONG Yifan        ":cpp_module_codegen",
195*eed53cd4SHONG Yifan        ":lto_backend",
196*eed53cd4SHONG Yifan        ":clif_match",
197*eed53cd4SHONG Yifan    ],
198*eed53cd4SHONG Yifan)
199*eed53cd4SHONG Yifan
200*eed53cd4SHONG Yifancc_action_type_set(
201*eed53cd4SHONG Yifan    name = "compile_actions",
202*eed53cd4SHONG Yifan    actions = [
203*eed53cd4SHONG Yifan        ":cpp_compile_actions",
204*eed53cd4SHONG Yifan        ":c_compile",
205*eed53cd4SHONG Yifan        ":assembly_actions",
206*eed53cd4SHONG Yifan    ],
207*eed53cd4SHONG Yifan)
208*eed53cd4SHONG Yifan
209*eed53cd4SHONG Yifancc_action_type_set(
210*eed53cd4SHONG Yifan    name = "link_actions",
211*eed53cd4SHONG Yifan    actions = [
212*eed53cd4SHONG Yifan        ":link_executable_actions",
213*eed53cd4SHONG Yifan        ":dynamic_library_link_actions",
214*eed53cd4SHONG Yifan    ],
215*eed53cd4SHONG Yifan)
216*eed53cd4SHONG Yifan
217*eed53cd4SHONG Yifancc_action_type_set(
218*eed53cd4SHONG Yifan    name = "link_executable_actions",
219*eed53cd4SHONG Yifan    actions = [
220*eed53cd4SHONG Yifan        ":cpp_link_executable",
221*eed53cd4SHONG Yifan        ":lto_index_for_executable",
222*eed53cd4SHONG Yifan    ],
223*eed53cd4SHONG Yifan)
224*eed53cd4SHONG Yifan
225*eed53cd4SHONG Yifancc_action_type_set(
226*eed53cd4SHONG Yifan    name = "dynamic_library_link_actions",
227*eed53cd4SHONG Yifan    actions = [
228*eed53cd4SHONG Yifan        ":cpp_link_dynamic_library",
229*eed53cd4SHONG Yifan        ":lto_index_for_dynamic_library",
230*eed53cd4SHONG Yifan        ":nodeps_dynamic_library_link_actions",
231*eed53cd4SHONG Yifan    ],
232*eed53cd4SHONG Yifan)
233*eed53cd4SHONG Yifan
234*eed53cd4SHONG Yifancc_action_type_set(
235*eed53cd4SHONG Yifan    name = "nodeps_dynamic_library_link_actions",
236*eed53cd4SHONG Yifan    actions = [
237*eed53cd4SHONG Yifan        ":cpp_link_nodeps_dynamic_library",
238*eed53cd4SHONG Yifan        ":lto_index_for_nodeps_dynamic_library",
239*eed53cd4SHONG Yifan    ],
240*eed53cd4SHONG Yifan)
241*eed53cd4SHONG Yifan
242*eed53cd4SHONG Yifancc_action_type_set(
243*eed53cd4SHONG Yifan    name = "transitive_link_actions",
244*eed53cd4SHONG Yifan    actions = [
245*eed53cd4SHONG Yifan        ":cpp_link_executable",
246*eed53cd4SHONG Yifan        ":cpp_link_dynamic_library",
247*eed53cd4SHONG Yifan        ":lto_index_for_executable",
248*eed53cd4SHONG Yifan        ":lto_index_for_dynamic_library",
249*eed53cd4SHONG Yifan    ],
250*eed53cd4SHONG Yifan)
251*eed53cd4SHONG Yifan
252*eed53cd4SHONG Yifancc_action_type_set(
253*eed53cd4SHONG Yifan    name = "all_actions",
254*eed53cd4SHONG Yifan    actions = [
255*eed53cd4SHONG Yifan        ":c_compile",
256*eed53cd4SHONG Yifan        ":cpp_compile",
257*eed53cd4SHONG Yifan        ":linkstamp_compile",
258*eed53cd4SHONG Yifan        ":cc_flags_make_variable",
259*eed53cd4SHONG Yifan        ":cpp_module_codegen",
260*eed53cd4SHONG Yifan        ":cpp_header_analysis",
261*eed53cd4SHONG Yifan        ":cpp_header_parsing",
262*eed53cd4SHONG Yifan        ":cpp_module_compile",
263*eed53cd4SHONG Yifan        ":assemble",
264*eed53cd4SHONG Yifan        ":preprocess_assemble",
265*eed53cd4SHONG Yifan        ":lto_indexing",
266*eed53cd4SHONG Yifan        ":lto_backend",
267*eed53cd4SHONG Yifan        ":lto_index_for_executable",
268*eed53cd4SHONG Yifan        ":lto_index_for_dynamic_library",
269*eed53cd4SHONG Yifan        ":lto_index_for_nodeps_dynamic_library",
270*eed53cd4SHONG Yifan        ":cpp_link_executable",
271*eed53cd4SHONG Yifan        ":cpp_link_dynamic_library",
272*eed53cd4SHONG Yifan        ":cpp_link_nodeps_dynamic_library",
273*eed53cd4SHONG Yifan        ":cpp_link_static_library",
274*eed53cd4SHONG Yifan        ":strip",
275*eed53cd4SHONG Yifan        ":objcopy_embed_data",
276*eed53cd4SHONG Yifan        ":ld_embed_data",
277*eed53cd4SHONG Yifan        ":objc_compile",
278*eed53cd4SHONG Yifan        ":objc_executable",
279*eed53cd4SHONG Yifan        ":objc_fully_link",
280*eed53cd4SHONG Yifan        ":objcpp_compile",
281*eed53cd4SHONG Yifan        ":objcpp_executable",
282*eed53cd4SHONG Yifan        ":clif_match",
283*eed53cd4SHONG Yifan    ],
284*eed53cd4SHONG Yifan)
285