xref: /aosp_15_r20/external/bazelbuild-rules_cc/cc/action_names.bzl (revision eed53cd41c5909d05eedc7ad9720bb158fd93452)
1# Copyright 2018 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Constants for action names used for C++ rules."""
15
16# Keep in sync with //cc/toolchains/actions:BUILD.
17
18# Name for the C compilation action.
19C_COMPILE_ACTION_NAME = "c-compile"
20
21# Name of the C++ compilation action.
22CPP_COMPILE_ACTION_NAME = "c++-compile"
23
24# Name of the linkstamp-compile action.
25LINKSTAMP_COMPILE_ACTION_NAME = "linkstamp-compile"
26
27# Name of the action used to compute CC_FLAGS make variable.
28CC_FLAGS_MAKE_VARIABLE_ACTION_NAME = "cc-flags-make-variable"
29
30# Name of the C++ module codegen action.
31CPP_MODULE_CODEGEN_ACTION_NAME = "c++-module-codegen"
32
33# Name of the C++ header parsing action.
34CPP_HEADER_PARSING_ACTION_NAME = "c++-header-parsing"
35
36# Name of the C++ module compile action.
37CPP_MODULE_COMPILE_ACTION_NAME = "c++-module-compile"
38
39# Name of the assembler action.
40ASSEMBLE_ACTION_NAME = "assemble"
41
42# Name of the assembly preprocessing action.
43PREPROCESS_ASSEMBLE_ACTION_NAME = "preprocess-assemble"
44
45# Name of the action producing ThinLto index.
46LTO_INDEXING_ACTION_NAME = "lto-indexing"
47
48# Name of the action producing ThinLto index for executable.
49LTO_INDEX_FOR_EXECUTABLE_ACTION_NAME = "lto-index-for-executable"
50
51# Name of the action producing ThinLto index for dynamic library.
52LTO_INDEX_FOR_DYNAMIC_LIBRARY_ACTION_NAME = "lto-index-for-dynamic-library"
53
54# Name of the action producing ThinLto index for nodeps dynamic library.
55LTO_INDEX_FOR_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME = "lto-index-for-nodeps-dynamic-library"
56
57# Name of the action compiling lto bitcodes into native objects.
58LTO_BACKEND_ACTION_NAME = "lto-backend"
59
60# Name of the link action producing executable binary.
61CPP_LINK_EXECUTABLE_ACTION_NAME = "c++-link-executable"
62
63# Name of the link action producing dynamic library.
64CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME = "c++-link-dynamic-library"
65
66# Name of the link action producing dynamic library that doesn't include it's
67# transitive dependencies.
68CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME = "c++-link-nodeps-dynamic-library"
69
70# Name of the archiving action producing static library.
71CPP_LINK_STATIC_LIBRARY_ACTION_NAME = "c++-link-static-library"
72
73# Name of the action stripping the binary.
74STRIP_ACTION_NAME = "strip"
75
76# A string constant for the objc compilation action.
77OBJC_COMPILE_ACTION_NAME = "objc-compile"
78
79# A string constant for the objc++ compile action.
80OBJCPP_COMPILE_ACTION_NAME = "objc++-compile"
81
82# A string constant for the objc executable link action.
83OBJC_EXECUTABLE_ACTION_NAME = "objc-executable"
84
85# A string constant for the objc fully-link link action.
86OBJC_FULLY_LINK_ACTION_NAME = "objc-fully-link"
87
88# A string constant for the clif action.
89CLIF_MATCH_ACTION_NAME = "clif-match"
90
91ACTION_NAMES = struct(
92    c_compile = C_COMPILE_ACTION_NAME,
93    cpp_compile = CPP_COMPILE_ACTION_NAME,
94    linkstamp_compile = LINKSTAMP_COMPILE_ACTION_NAME,
95    cc_flags_make_variable = CC_FLAGS_MAKE_VARIABLE_ACTION_NAME,
96    cpp_module_codegen = CPP_MODULE_CODEGEN_ACTION_NAME,
97    cpp_header_parsing = CPP_HEADER_PARSING_ACTION_NAME,
98    cpp_module_compile = CPP_MODULE_COMPILE_ACTION_NAME,
99    assemble = ASSEMBLE_ACTION_NAME,
100    preprocess_assemble = PREPROCESS_ASSEMBLE_ACTION_NAME,
101    lto_indexing = LTO_INDEXING_ACTION_NAME,
102    lto_backend = LTO_BACKEND_ACTION_NAME,
103    lto_index_for_executable = LTO_INDEX_FOR_EXECUTABLE_ACTION_NAME,
104    lto_index_for_dynamic_library = LTO_INDEX_FOR_DYNAMIC_LIBRARY_ACTION_NAME,
105    lto_index_for_nodeps_dynamic_library = LTO_INDEX_FOR_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME,
106    cpp_link_executable = CPP_LINK_EXECUTABLE_ACTION_NAME,
107    cpp_link_dynamic_library = CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME,
108    cpp_link_nodeps_dynamic_library = CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME,
109    cpp_link_static_library = CPP_LINK_STATIC_LIBRARY_ACTION_NAME,
110    strip = STRIP_ACTION_NAME,
111    objc_compile = OBJC_COMPILE_ACTION_NAME,
112    objc_executable = OBJC_EXECUTABLE_ACTION_NAME,
113    objc_fully_link = OBJC_FULLY_LINK_ACTION_NAME,
114    objcpp_compile = OBJCPP_COMPILE_ACTION_NAME,
115    clif_match = CLIF_MATCH_ACTION_NAME,
116)
117
118# Names of actions that parse or compile C++ code.
119ALL_CPP_COMPILE_ACTION_NAMES = [
120    ACTION_NAMES.linkstamp_compile,
121    ACTION_NAMES.cpp_compile,
122    ACTION_NAMES.cpp_header_parsing,
123    ACTION_NAMES.cpp_module_compile,
124    ACTION_NAMES.cpp_module_codegen,
125    ACTION_NAMES.lto_backend,
126    ACTION_NAMES.clif_match,
127]
128
129# Names of actions that parse or compile C, C++ and assembly code.
130ALL_CC_COMPILE_ACTION_NAMES = ALL_CPP_COMPILE_ACTION_NAMES + [
131    ACTION_NAMES.c_compile,
132    ACTION_NAMES.preprocess_assemble,
133    ACTION_NAMES.assemble,
134]
135
136# Names of actions that link C, C++ and assembly code.
137ALL_CC_LINK_ACTION_NAMES = [
138    ACTION_NAMES.cpp_link_executable,
139    ACTION_NAMES.cpp_link_dynamic_library,
140    ACTION_NAMES.cpp_link_nodeps_dynamic_library,
141    ACTION_NAMES.lto_index_for_executable,
142    ACTION_NAMES.lto_index_for_dynamic_library,
143    ACTION_NAMES.lto_index_for_nodeps_dynamic_library,
144]
145
146# Names of actions that link entire programs.
147CC_LINK_EXECUTABLE_ACTION_NAMES = [
148    ACTION_NAMES.cpp_link_executable,
149    ACTION_NAMES.lto_index_for_executable,
150]
151
152# Names of actions that link dynamic libraries.
153DYNAMIC_LIBRARY_LINK_ACTION_NAMES = [
154    ACTION_NAMES.cpp_link_dynamic_library,
155    ACTION_NAMES.cpp_link_nodeps_dynamic_library,
156    ACTION_NAMES.lto_index_for_dynamic_library,
157    ACTION_NAMES.lto_index_for_nodeps_dynamic_library,
158]
159
160# Names of actions that link nodeps dynamic libraries.
161NODEPS_DYNAMIC_LIBRARY_LINK_ACTION_NAMES = [
162    ACTION_NAMES.cpp_link_nodeps_dynamic_library,
163    ACTION_NAMES.lto_index_for_nodeps_dynamic_library,
164]
165
166# Names of actions that link transitive dependencies.
167TRANSITIVE_LINK_ACTION_NAMES = [
168    ACTION_NAMES.cpp_link_executable,
169    ACTION_NAMES.cpp_link_dynamic_library,
170    ACTION_NAMES.lto_index_for_executable,
171    ACTION_NAMES.lto_index_for_dynamic_library,
172]
173
174ACTION_NAME_GROUPS = struct(
175    all_cc_compile_actions = ALL_CC_COMPILE_ACTION_NAMES,
176    all_cc_link_actions = ALL_CC_LINK_ACTION_NAMES,
177    all_cpp_compile_actions = ALL_CPP_COMPILE_ACTION_NAMES,
178    cc_link_executable_actions = CC_LINK_EXECUTABLE_ACTION_NAMES,
179    dynamic_library_link_actions = DYNAMIC_LIBRARY_LINK_ACTION_NAMES,
180    nodeps_dynamic_library_link_actions = NODEPS_DYNAMIC_LIBRARY_LINK_ACTION_NAMES,
181    transitive_link_actions = TRANSITIVE_LINK_ACTION_NAMES,
182)
183