xref: /aosp_15_r20/build/bazel/rules/cc/cc_constants.bzl (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1# Copyright (C) 2021 The Android Open Source Project
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
15# Constants for cc_* rules.
16# To use, load the constants struct:
17#
18#   load("//build/bazel/rules:cc_constants.bzl", "constants")
19# Supported hdr extensions in Soong. Keep this consistent with hdrExts in build/soong/cc/snapshot_utils.go
20_HDR_EXTS = ["h", "hh", "hpp", "hxx", "h++", "inl", "inc", "ipp", "h.generic"]
21_C_SRC_EXTS = ["c"]
22_CPP_SRC_EXTS = ["cc", "cpp"]
23_AS_SRC_EXTS = ["s", "S"]
24_SRC_EXTS = _C_SRC_EXTS + _CPP_SRC_EXTS + _AS_SRC_EXTS
25_ALL_EXTS = _SRC_EXTS + _HDR_EXTS
26_HDR_EXTS_WITH_DOT = ["." + ext for ext in _HDR_EXTS]
27_SRC_EXTS_WITH_DOT = ["." + ext for ext in _SRC_EXTS]
28_ALL_EXTS_WITH_DOT = ["." + ext for ext in _ALL_EXTS]
29
30constants = struct(
31    hdr_exts = _HDR_EXTS,
32    c_src_exts = _C_SRC_EXTS,
33    cpp_src_exts = _CPP_SRC_EXTS,
34    as_src_exts = _AS_SRC_EXTS,
35    src_exts = _SRC_EXTS,
36    all_exts = _ALL_EXTS,
37    hdr_dot_exts = _HDR_EXTS_WITH_DOT,
38    src_dot_exts = _SRC_EXTS_WITH_DOT,
39    all_dot_exts = _ALL_EXTS_WITH_DOT,
40)
41
42# Constants for use in cc transitions
43_FEATURES_ATTR_KEY = "features"
44_CLI_FEATURES_KEY = "//command_line_option:features"
45_CLI_PLATFORMS_KEY = "//command_line_option:platforms"
46_CFI_INCLUDE_PATHS_KEY = "@//build/bazel/product_config:cfi_include_paths"
47_CFI_EXCLUDE_PATHS_KEY = "@//build/bazel/product_config:cfi_exclude_paths"
48_ENABLE_CFI_KEY = "@//build/bazel/product_config:enable_cfi"
49_CFI_ASSEMBLY_KEY = "@//build/bazel/rules/cc:cfi_assembly"
50_MEMTAG_HEAP_ASYNC_INCLUDE_PATHS_KEY = "@//build/bazel/product_config:memtag_heap_async_include_paths"
51_MEMTAG_HEAP_SYNC_INCLUDE_PATHS_KEY = "@//build/bazel/product_config:memtag_heap_sync_include_paths"
52_MEMTAG_HEAP_EXCLUDE_PATHS_KEY = "@//build/bazel/product_config:memtag_heap_exclude_paths"
53
54# TODO: b/294868620 - This can be removed when completing the bug
55_SANITIZERS_ENABLED_KEY = "@//build/bazel/rules/cc:sanitizers_enabled_setting"
56
57transition_constants = struct(
58    features_attr_key = _FEATURES_ATTR_KEY,
59    cli_features_key = _CLI_FEATURES_KEY,
60    cfi_include_paths_key = _CFI_INCLUDE_PATHS_KEY,
61    cfi_exclude_paths_key = _CFI_EXCLUDE_PATHS_KEY,
62    enable_cfi_key = _ENABLE_CFI_KEY,
63    cli_platforms_key = _CLI_PLATFORMS_KEY,
64    cfi_assembly_key = _CFI_ASSEMBLY_KEY,
65    sanitizers_enabled_key = _SANITIZERS_ENABLED_KEY,
66    memtag_heap_async_include_paths_key = _MEMTAG_HEAP_ASYNC_INCLUDE_PATHS_KEY,
67    memtag_heap_sync_include_paths_key = _MEMTAG_HEAP_SYNC_INCLUDE_PATHS_KEY,
68    memtag_heap_exclude_paths_key = _MEMTAG_HEAP_EXCLUDE_PATHS_KEY,
69)
70