• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag", "string_list_flag")
2load("//build/bazel/rules/aconfig:aconfig_value_sets.bzl", "aconfig_value_sets")
3load(":product_variables_for_attributes.bzl", "product_variables_for_attributes")
4
5package(default_visibility = ["//visibility:public"])
6
7# This rule type outputs a TemplateVariableInfo provider that contains a subset of the product
8# variables to be available for expansion using make-like syntax on certain rule attributes.
9# Soong had this feature, so it was ported to bazel.
10product_variables_for_attributes(name = "product_variables_for_attributes")
11
12# This label flag will always point to the device platform for the current android product.
13# It can be used to transition into the device configuration from the host configuration.
14label_flag(
15    name = "device_platform",
16    build_setting_default = "//build/bazel/utils:fail",
17)
18
19string_flag(
20    name = "target_build_variant",
21    build_setting_default = "eng",
22    values = [
23        "user",
24        "userdebug",
25        "eng",
26    ],
27)
28
29_string_list_variables = [
30    # keep-sorted start
31    "aapt_config",
32    "build_version_tags",
33    "cfi_exclude_paths",
34    "cfi_include_paths",
35    "device_abi",
36    "manifest_package_name_overrides",
37    "memtag_heap_async_include_paths",
38    "memtag_heap_exclude_paths",
39    "memtag_heap_sync_include_paths",
40    "tidy_checks",
41    "unbundled_build_apps",
42    # keep-sorted end
43]
44
45_string_variables = [
46    # keep-sorted start
47    # TODO: b/301593550 - commas can't be escaped in a string-list passed in a platform mapping,
48    # so commas are switched for ":" in soong injection, and must be back-substituted
49    # into commas wherever the AAPTCharacteristics product config variable is used.
50    "aapt_characteristics",
51    "aapt_preferred_config",
52    "apex_global_min_sdk_version_override",
53    "build_id",
54    "default_app_certificate",
55    "device_max_page_size_supported",
56    "device_name",
57    "device_product",
58    "override_rs_driver",
59    "platform_sdk_extension_version",
60    "platform_sdk_version",
61    "platform_sdk_version_or_codename",
62    "platform_security_patch",
63    "platform_version_last_stable",
64    "platform_version_name",
65    "product_brand",
66    "product_manufacturer",
67    "release_aconfig_flag_default_permission",
68    "release_version",
69    # keep-sorted end
70]
71
72_bool_variables = [
73    # keep-sorted start
74    "always_use_prebuilt_sdks",
75    "arc",
76    "binder32bit",
77    "build_broken_incorrect_partition_images",
78    "build_from_text_stub",
79    "compressed_apex",
80    "device_no_bionic_page_size_macro",
81    "enforce_vintf_manifest",
82    "malloc_not_svelte",
83    "malloc_pattern_fill_contents",
84    "malloc_zero_contents",
85    "native_coverage",
86    "pdk",
87    "platform_sdk_final",
88    "release_aidl_use_unfrozen",
89    "safestack",
90    "treble_linker_namespaces",
91    "uml",
92    "unbundled_build",
93    # keep-sorted end
94]
95
96[
97    string_list_flag(
98        name = name,
99        build_setting_default = [],
100    )
101    for name in _string_list_variables
102]
103
104[
105    string_flag(
106        name = name,
107        build_setting_default = "",
108    )
109    for name in _string_variables
110]
111
112[
113    bool_flag(
114        name = name,
115        build_setting_default = False,
116    )
117    for name in _bool_variables
118]
119
120bool_flag(
121    name = "enable_cfi",
122    build_setting_default = True,
123)
124
125label_flag(
126    name = "default_app_certificate_filegroup",
127    build_setting_default = "//build/bazel/utils:empty_filegroup",
128)
129
130label_flag(
131    name = "release_aconfig_value_sets",
132    build_setting_default = ":empty_aconfig_value_sets",
133)
134
135aconfig_value_sets(
136    name = "empty_aconfig_value_sets",
137    value_sets = [],
138    visibility = ["//visibility:public"],
139)
140