aboutsummaryrefslogtreecommitdiff
path: root/rules/apex/transition.bzl
diff options
context:
space:
mode:
authorCole Faust <colefaust@google.com>2022-10-19 11:14:31 -0700
committerCole Faust <colefaust@google.com>2023-01-05 12:41:29 -0800
commitf453fe83d9cfdcc4299f1729491ea7325d53774c (patch)
tree599664529d094ed631e28acce873abe6a7a5e185 /rules/apex/transition.bzl
parent89318f00525509b977ae13d75c596f2df89707a6 (diff)
downloadbazel-f453fe83d9cfdcc4299f1729491ea7325d53774c.tar.gz
Support multiple android products in a single bazel build
We create an android_product macro that replaces a lot of the existing platform code. It takes a soong.variables file, and creates bazel platforms for the android product, various other arches, and the host platforms. (currently host builds still depend on product config variables) To change products, you'll be able to pass --platform=//build/bazel/product_config/generated/products/<product_name>, however currently we only generate the platforms for the currently lunched product for performance. When the other products are in starlark, we can allow using all of them. Bug: 249685973 Test: Presubmits Change-Id: Ic1b0942a60c66eb3fe2b1aa7a2ff436ec9b3c3fb
Diffstat (limited to 'rules/apex/transition.bzl')
-rw-r--r--rules/apex/transition.bzl28
1 files changed, 22 insertions, 6 deletions
diff --git a/rules/apex/transition.bzl b/rules/apex/transition.bzl
index 61fa1385..66b758e1 100644
--- a/rules/apex/transition.bzl
+++ b/rules/apex/transition.bzl
@@ -31,7 +31,6 @@ limitations under the License.
# https://cs.android.com/android/platform/superproject/+/master:build/soong/apex/apex.go;l=948-962;drc=539d41b686758eeb86236c0e0dcf75478acb77f3
load("@bazel_skylib//lib:dicts.bzl", "dicts")
-load("//build/bazel/platforms:product_variables/product_platform.bzl", "get_platform_for_shared_lib_transition_32")
load("//build/bazel/rules/cc:cc_library_common.bzl", "parse_apex_sdk_version")
def _create_apex_configuration(attr, additional = {}):
@@ -97,15 +96,28 @@ def _impl_shared_lib_transition_32(settings, attr):
direct_deps = [str(dep) for dep in attr.native_shared_libs_32]
direct_deps += [str(dep) for dep in attr.binaries]
+ old_platform = str(settings["//command_line_option:platforms"][0])
+
+ # TODO(b/249685973) This can be removed when the aab transition no
+ # longer transitions to these platforms
+ old_platform = (old_platform
+ .removesuffix("__internal_arm")
+ .removesuffix("__internal_arm64")
+ .removesuffix("__internal_x86")
+ .removesuffix("__internal_x86_64"))
+
return _create_apex_configuration(attr, {
- "//command_line_option:platforms": get_platform_for_shared_lib_transition_32(),
+ "//command_line_option:platforms": old_platform + "_secondary",
"//build/bazel/rules/apex:apex_direct_deps": direct_deps,
})
shared_lib_transition_32 = transition(
implementation = _impl_shared_lib_transition_32,
- inputs = [],
- outputs = SHARED_LIB_TRANSITION_BUILD_SETTINGS,
+ inputs = ["//command_line_option:platforms"],
+ outputs = APEX_TRANSITION_BUILD_SETTINGS + [
+ "//build/bazel/rules/apex:apex_direct_deps",
+ "//command_line_option:platforms",
+ ],
)
def _impl_shared_lib_transition_64(settings, attr):
@@ -115,13 +127,17 @@ def _impl_shared_lib_transition_64(settings, attr):
direct_deps = [str(dep) for dep in attr.native_shared_libs_64]
direct_deps += [str(dep) for dep in attr.binaries]
+ # For the 64 bit transition, we don't actually change the arch, because
+ # we only read the value of native_shared_libs_64 when the target
+ # is 64-bit already
return _create_apex_configuration(attr, {
- "//command_line_option:platforms": "//build/bazel/platforms:android_target",
"//build/bazel/rules/apex:apex_direct_deps": direct_deps,
})
shared_lib_transition_64 = transition(
implementation = _impl_shared_lib_transition_64,
inputs = [],
- outputs = SHARED_LIB_TRANSITION_BUILD_SETTINGS,
+ outputs = APEX_TRANSITION_BUILD_SETTINGS + [
+ "//build/bazel/rules/apex:apex_direct_deps",
+ ],
)