Skip to content

Commit

Permalink
Add optional DeviceGroupConfig.json metadata file.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 693971789
Change-Id: Ifcee8975417c7aba0a31d3bf6640271c201e817d
  • Loading branch information
A Googler authored and copybara-github committed Nov 7, 2024
1 parent b2307a2 commit 2db3d8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions rules/android_application/android_application.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def android_application(**attrs):
`feature_modules` | New. List of labels to `android_feature_module`s to include as feature splits. Note: must be fully qualified paths (//some:target), not relative.
`bundle_config_file` | New. String path to .pb.json file containing the bundle config. See the [bundletool docs](https://developer.android.com/studio/build/building-cmdline#bundleconfig) for format and examples. Note: this attribute is subject to changes which may require teams to migrate their configurations to a build target.
`app_integrity_config` | Optional. String path to .binarypb file containing the play integrity config. See https://github.com/google/bundletool/blob/master/src/main/proto/app_integrity_config.proto.
`device_group_config` | Optional. String path to .json file containing the device targeting definitions. See https://github.com/google/bundletool/blob/master/src/main/proto/device_targeting_config.proto.
`rotation_config` | Optional. String path to .textproto file containing the V3 rotation config.
Args:
Expand Down
5 changes: 5 additions & 0 deletions rules/android_application/android_application_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ def _impl(ctx):
if ProguardMappingInfo in ctx.attr.base_module:
metadata["com.android.tools.build.obfuscation/proguard.map"] = ctx.attr.base_module[ProguardMappingInfo].proguard_mapping

if ctx.file.device_group_config:
metadata["com.android.tools.build.bundletool/DeviceGroupConfig.pb"] = ctx.file.device_group_config

if ctx.file.rotation_config:
metadata["com.google.play.apps.signing/RotationConfig.textproto"] = ctx.file.rotation_config

Expand Down Expand Up @@ -449,6 +452,7 @@ def android_application_macro(_android_binary, **attrs):

# Must pop these because android_binary does not have these attributes.
app_integrity_config = attrs.pop("app_integrity_config", None)
device_group_config = attrs.pop("device_group_config", None)
rotation_config = attrs.pop("rotation_config", None)

# default to [] if feature_modules = None is passed
Expand Down Expand Up @@ -502,6 +506,7 @@ def android_application_macro(_android_binary, **attrs):
base_module = ":%s" % base_split_name,
bundle_config_file = bundle_config_file,
app_integrity_config = app_integrity_config,
device_group_config = device_group_config,
rotation_config = rotation_config,
custom_package = attrs.get("custom_package", None),
testonly = attrs.get("testonly"),
Expand Down
6 changes: 6 additions & 0 deletions rules/android_application/attrs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ ANDROID_APPLICATION_ATTRS = _attrs.add(
"Provide a path to a binary .binarypb instance of " +
"https://github.com/google/bundletool/blob/master/src/main/proto/app_integrity_config.proto",
),
device_group_config = attr.label(
allow_single_file = [".json"],
doc = "Path to the device targeting configuration json file. " +
"See " +
"https://github.com/google/bundletool/blob/master/src/main/proto/device_targeting_config.proto",
),
rotation_config = attr.label(
allow_single_file = [".textproto"],
default = None,
Expand Down

0 comments on commit 2db3d8f

Please sign in to comment.