Skip to content

Commit

Permalink
Continue with Automatic Exec Groups migration in Android rules
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kotlaja authored and copybara-github committed Aug 29, 2023
1 parent ad14784 commit 4556d21
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions rules/aapt.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

"""Bazel AAPT Commands."""

load(
"//rules:utils.bzl",
"ANDROID_TOOLCHAIN_TYPE",
)

def _link(
ctx,
out_r_java,
Expand Down Expand Up @@ -112,6 +117,7 @@ echo $(tac $1) > $2
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(
Expand Down Expand Up @@ -170,6 +176,7 @@ done
outputs = [out_dir],
mnemonic = "CompileAndroidResources",
progress_message = "ResV3 Compiling Android Resources in %s" % out_dir,
toolchain = ANDROID_TOOLCHAIN_TYPE,
)

def _convert(
Expand All @@ -191,6 +198,7 @@ def _convert(
outputs = [out],
mnemonic = "AaptConvert",
progress_message = "ResV3 Convert to %s" % out.short_path,
toolchain = ANDROID_TOOLCHAIN_TYPE,
)

aapt = struct(
Expand Down
8 changes: 7 additions & 1 deletion rules/android_application/android_application_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def _create_feature_manifest(
],
mnemonic = "GenFeatureManifest",
progress_message = "Generating AndroidManifest.xml for " + feature_target.label.name,
toolchain = None,
)
return manifest

Expand All @@ -201,6 +202,7 @@ def _create_feature_manifest(
],
mnemonic = "GenPriorityFeatureManifest",
progress_message = "Generating Priority AndroidManifest.xml for " + feature_target.label.name,
toolchain = None,
)

args = ctx.actions.args()
Expand All @@ -213,6 +215,7 @@ def _create_feature_manifest(
inputs = [priority_manifest, info.manifest],
outputs = [manifest],
arguments = [args],
toolchain = None,
)

return manifest
Expand Down Expand Up @@ -336,7 +339,10 @@ android_application = rule(
"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,
)

Expand Down
1 change: 1 addition & 0 deletions rules/android_application/android_feature_module_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def _impl(ctx):
],
mnemonic = "ValidateFeatureModule",
progress_message = "Validating feature module %s" % str(ctx.label),
toolchain = None,
)

return [
Expand Down
8 changes: 8 additions & 0 deletions rules/bundletool.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

"""Bazel Bundletool Commands."""

load(
"//rules:utils.bzl",
"ANDROID_TOOLCHAIN_TYPE",
)
load(":common.bzl", _common = "common")
load(":java.bzl", _java = "java")

Expand Down Expand Up @@ -175,6 +179,7 @@ def _build_sdk_module(
arguments = [args],
mnemonic = "BuildSdkModule",
progress_message = "Building ASB zip module %s" % out.short_path,
toolchain = ANDROID_TOOLCHAIN_TYPE,
)

def _bundle_to_apks(
Expand Down Expand Up @@ -270,6 +275,7 @@ echo "$contents" > %s
mnemonic = "ExtractBundleConfig",
progress_message = "Extract bundle config to %s" % out.short_path,
command = cmd,
exec_group = "android_and_java",
)

def _extract_manifest(
Expand Down Expand Up @@ -305,6 +311,7 @@ echo "$contents" > %s
mnemonic = "ExtractBundleManifest",
progress_message = "Extract bundle manifest to %s" % out.short_path,
command = cmd,
exec_group = "android_and_java",
)

def _proto_apk_to_module(
Expand Down Expand Up @@ -376,6 +383,7 @@ cd "${OUT_DIR}"
outputs = [out],
mnemonic = "Rebundle",
progress_message = "Rebundle to %s" % out.short_path,
toolchain = ANDROID_TOOLCHAIN_TYPE,
)

bundletool = struct(
Expand Down

0 comments on commit 4556d21

Please sign in to comment.