Continue with Automatic Exec Groups migration in Android rules Android rules already use AEGs. Still, modifications in this CL are needed since these actions are used from other rules, inside which I'm right now enabling AEGs. In this CL I've added toolchain param in affected actions and registered a java toolchain in affected rules. Example are rules which call `_java.run` since that function uses executable tool from the java toolchain. PiperOrigin-RevId: 560974870 Change-Id: Ie018585d6eac910b0a6dd9a5f7a0ef1c4a14ae13
diff --git a/rules/aapt.bzl b/rules/aapt.bzl index 284d89a..b6a4752 100644 --- a/rules/aapt.bzl +++ b/rules/aapt.bzl
@@ -14,6 +14,11 @@ """Bazel AAPT Commands.""" +load( + "//rules:utils.bzl", + "ANDROID_TOOLCHAIN_TYPE", +) + def _link( ctx, out_r_java, @@ -112,6 +117,7 @@ outputs = [out_resource_apk, out_r_java], mnemonic = "LinkAndroidResources", progress_message = "ResV3 Linking Android Resources to %s" % out_resource_apk.short_path, + toolchain = ANDROID_TOOLCHAIN_TYPE, ) def _compile( @@ -170,6 +176,7 @@ outputs = [out_dir], mnemonic = "CompileAndroidResources", progress_message = "ResV3 Compiling Android Resources in %s" % out_dir, + toolchain = ANDROID_TOOLCHAIN_TYPE, ) def _convert( @@ -191,6 +198,7 @@ outputs = [out], mnemonic = "AaptConvert", progress_message = "ResV3 Convert to %s" % out.short_path, + toolchain = ANDROID_TOOLCHAIN_TYPE, ) aapt = struct(
diff --git a/rules/android_application/android_application_rule.bzl b/rules/android_application/android_application_rule.bzl index 0a931da..a2c9b70 100644 --- a/rules/android_application/android_application_rule.bzl +++ b/rules/android_application/android_application_rule.bzl
@@ -177,6 +177,7 @@ ], mnemonic = "GenFeatureManifest", progress_message = "Generating AndroidManifest.xml for " + feature_target.label.name, + toolchain = None, ) return manifest @@ -201,6 +202,7 @@ ], mnemonic = "GenPriorityFeatureManifest", progress_message = "Generating Priority AndroidManifest.xml for " + feature_target.label.name, + toolchain = None, ) args = ctx.actions.args() @@ -213,6 +215,7 @@ inputs = [priority_manifest, info.manifest], outputs = [manifest], arguments = [args], + toolchain = None, ) return manifest @@ -336,7 +339,10 @@ "deploy_script": "%{name}.sh", "unsigned_aab": "%{name}_unsigned.aab", }, - toolchains = ["//toolchains/android:toolchain_type"], + toolchains = [ + "//toolchains/android:toolchain_type", + "@bazel_tools//tools/jdk:toolchain_type", + ], _skylark_testable = True, )
diff --git a/rules/android_application/android_feature_module_rule.bzl b/rules/android_application/android_feature_module_rule.bzl index a0f7d2b..439548b 100644 --- a/rules/android_application/android_feature_module_rule.bzl +++ b/rules/android_application/android_feature_module_rule.bzl
@@ -55,6 +55,7 @@ ], mnemonic = "ValidateFeatureModule", progress_message = "Validating feature module %s" % str(ctx.label), + toolchain = None, ) return [
diff --git a/rules/bundletool.bzl b/rules/bundletool.bzl index 0ef1baf..a60274d 100644 --- a/rules/bundletool.bzl +++ b/rules/bundletool.bzl
@@ -14,6 +14,10 @@ """Bazel Bundletool Commands.""" +load( + "//rules:utils.bzl", + "ANDROID_TOOLCHAIN_TYPE", +) load(":common.bzl", _common = "common") load(":java.bzl", _java = "java") @@ -175,6 +179,7 @@ arguments = [args], mnemonic = "BuildSdkModule", progress_message = "Building ASB zip module %s" % out.short_path, + toolchain = ANDROID_TOOLCHAIN_TYPE, ) def _bundle_to_apks( @@ -270,6 +275,7 @@ mnemonic = "ExtractBundleConfig", progress_message = "Extract bundle config to %s" % out.short_path, command = cmd, + exec_group = "android_and_java", ) def _extract_manifest( @@ -305,6 +311,7 @@ mnemonic = "ExtractBundleManifest", progress_message = "Extract bundle manifest to %s" % out.short_path, command = cmd, + exec_group = "android_and_java", ) def _proto_apk_to_module( @@ -376,6 +383,7 @@ outputs = [out], mnemonic = "Rebundle", progress_message = "Rebundle to %s" % out.short_path, + toolchain = ANDROID_TOOLCHAIN_TYPE, ) bundletool = struct(