aboutsummaryrefslogtreecommitdiff
path: root/rules
diff options
context:
space:
mode:
authorCole Faust <colefaust@google.com>2023-04-11 14:02:09 -0700
committerCole Faust <colefaust@google.com>2023-04-11 15:38:53 -0700
commit11f30d40734ff86685c385f66bb1f4aa9a7cd65c (patch)
treeae18c65fdc987845bf465e8a54421178c3ac3806 /rules
parent251a914137c101c5f6ca8b8c2aaadd04973f0251 (diff)
downloadbazel-11f30d40734ff86685c385f66bb1f4aa9a7cd65c.tar.gz
Don't load product_variables.bzl where possible
product_variables.bzl should not be loaded directly, but instead read from the transitionable //build/bazel/product_config:product_vars target. Some of the information in product_variables.bzl is constant, and doesn't need to be read from that target. In those cases, load the information from other files so that the product_variables.bzl file can be made private. Bug: 269577299 Test: m nothing Change-Id: I69d9d5479b51ff9098a3ff8f2caf5daa9fb4d49a
Diffstat (limited to 'rules')
-rw-r--r--rules/abi/abi_dump.bzl8
-rw-r--r--rules/apex/apex.bzl1
-rw-r--r--rules/cc/cc_library_common.bzl6
-rw-r--r--rules/common/api.bzl12
4 files changed, 13 insertions, 14 deletions
diff --git a/rules/abi/abi_dump.bzl b/rules/abi/abi_dump.bzl
index 745a9c0b..f1e47618 100644
--- a/rules/abi/abi_dump.bzl
+++ b/rules/abi/abi_dump.bzl
@@ -19,7 +19,7 @@ load(
"CPP_COMPILE_ACTION_NAME",
"C_COMPILE_ACTION_NAME",
)
-load("@soong_injection//product_config:product_variables.bzl", "product_vars")
+load("@soong_injection//api_levels:platform_versions.bzl", "platform_versions")
load("//build/bazel/platforms:platform_utils.bzl", "platforms")
load(
"//build/bazel/rules/cc:cc_library_common.bzl",
@@ -219,10 +219,10 @@ def create_linked_abi_dump(ctx, dump_files):
return output
def find_abi_config(_ctx):
- sdk_version = str(product_vars["Platform_sdk_version"])
+ sdk_version = str(platform_versions.platform_sdk_version)
prev_version = int(parse_apex_sdk_version(sdk_version))
version = "current"
- if product_vars["Platform_sdk_final"]:
+ if platform_versions.platform_sdk_final:
prev_version -= 1
version = sdk_version
@@ -238,7 +238,7 @@ def create_abi_diff(ctx, dump_file):
# The logic below comes from:
# https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/library.go;l=1891;drc=c645853ab73ac8c5889b42f4ce7dc9353ee8fd35
abi_reference_file = None
- if not product_vars["Platform_sdk_final"]:
+ if not platform_versions.platform_sdk_final:
abi_reference_file = _find_abi_ref_file(ctx, prev_version, arch, bitness, abi_class, dump_file.basename)
if not abi_reference_file:
prev_version -= 1
diff --git a/rules/apex/apex.bzl b/rules/apex/apex.bzl
index 3f033d91..51cfab63 100644
--- a/rules/apex/apex.bzl
+++ b/rules/apex/apex.bzl
@@ -15,7 +15,6 @@
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@soong_injection//apex_toolchain:constants.bzl", "default_manifest_version")
-load("@soong_injection//product_config:product_variables.bzl", "product_vars")
load("//build/bazel/platforms:platform_utils.bzl", "platforms")
load("//build/bazel/product_config:product_variables_providing_rule.bzl", "ProductVariablesInfo")
load("//build/bazel/rules:common.bzl", "get_dep_targets")
diff --git a/rules/cc/cc_library_common.bzl b/rules/cc/cc_library_common.bzl
index 164d6629..bd861c50 100644
--- a/rules/cc/cc_library_common.bzl
+++ b/rules/cc/cc_library_common.bzl
@@ -14,7 +14,7 @@
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
load("@soong_injection//android:constants.bzl", android_constants = "constants")
-load("@soong_injection//product_config:product_variables.bzl", "product_vars")
+load("@soong_injection//api_levels:platform_versions.bzl", "platform_versions")
load("//build/bazel/rules:common.bzl", "strip_bp2build_label_suffix")
load("//build/bazel/rules/common:api.bzl", "api")
@@ -237,10 +237,10 @@ def parse_apex_sdk_version(version):
version = int(version)
if version in api.api_levels.values():
return version
- elif version == product_vars["Platform_sdk_version"]:
+ elif version == platform_versions.platform_sdk_version:
# For internal branch states, support parsing a finalized version number
# that's also still in
- # product_vars["Platform_version_active_codenames"], but not api.api_levels.
+ # platform_versions.platform_version_active_codenames, but not api.api_levels.
#
# This happens a few months each year on internal branches where the
# internal master branch has a finalized API, but is not released yet,
diff --git a/rules/common/api.bzl b/rules/common/api.bzl
index 2547133e..4d8e6db2 100644
--- a/rules/common/api.bzl
+++ b/rules/common/api.bzl
@@ -18,17 +18,17 @@
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@soong_injection//api_levels:api_levels.bzl", "api_levels_released_versions")
-load("@soong_injection//product_config:product_variables.bzl", "product_vars")
+load("@soong_injection//api_levels:platform_versions.bzl", "platform_versions")
_NONE_API_LEVEL_INT = -1
_PREVIEW_API_LEVEL_BASE = 9000 # Base constant for preview API levels.
_FUTURE_API_LEVEL_INT = 10000 # API Level associated with an arbitrary future release
# TODO(b/271280342): access these variables in a transition friendly way.
-_PLATFORM_SDK_FINAL = product_vars.get("Platform_sdk_final")
-_PLATFORM_SDK_VERSION = product_vars.get("Platform_sdk_version")
-_PLATFORM_SDK_CODENAME = product_vars.get("Platform_sdk_codename")
-_PLATFORM_VERSION_ACTIVE_CODENAMES = product_vars.get("Platform_version_active_codenames", [])
+_PLATFORM_SDK_FINAL = platform_versions.platform_sdk_final
+_PLATFORM_SDK_VERSION = platform_versions.platform_sdk_version
+_PLATFORM_SDK_CODENAME = platform_versions.platform_sdk_codename
+_PLATFORM_VERSION_ACTIVE_CODENAMES = platform_versions.platform_version_active_codenames
# Dict of unfinalized codenames to a placeholder preview API int.
_preview_codenames_to_ints = {
@@ -61,7 +61,7 @@ _final_codename = {
} if _PLATFORM_SDK_FINAL and _PLATFORM_SDK_VERSION else {}
_api_levels_with_previews = dicts.add(api_levels_released_versions, _preview_codenames_to_ints)
-_api_levels_with_final_codenames = dicts.add(api_levels_released_versions, _final_codename)
+_api_levels_with_final_codenames = dicts.add(api_levels_released_versions, _final_codename) # @unused
# parse_api_level_from_version is a Starlark implementation of ApiLevelFromUser
# at https://cs.android.com/android/platform/superproject/+/master:build/soong/android/api_levels.go;l=221-250;drc=5095a6c4b484f34d5c4f55a855d6174e00fb7f5e