Skip to content

Commit 4c8a12f

Browse files
A Googlercopybara-github
authored andcommitted
Add baseline_profiles_override to ignore other baseline profiles
This will result in just the baseline profiles from `android_binary.baseline_profiles_override` and `android_binary.startup_profiles` being used as the resulting baseline profiles - ignoring profiles pulled in from libraries. This should only be used if teams have very representative generated baseline profiles. PiperOrigin-RevId: 937446627 Change-Id: I85137ea713eb50828651a66117f56bd797e0f7a3
1 parent 149dcaf commit 4c8a12f

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

rules/android_binary/attrs.bzl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ ATTRS = _attrs.replace(
102102
""",
103103
cfg = android_platforms_transition,
104104
),
105+
baseline_profiles_override = attr.label_list(
106+
allow_empty = True,
107+
allow_files = [".txt"],
108+
doc = """
109+
The list of baseline profiles that override any baseline profiles from
110+
dependencies. If specified, all baseline profiles coming in from
111+
android_library.baseline_profiles are ignored. Only use this if your baseline
112+
profiles cover a very representative set of app functions. These will also be used
113+
as startup profiles if startup profiles are not specified.
114+
""",
115+
cfg = android_platforms_transition,
116+
),
105117
proguard_specs = attr.label_list(allow_empty = True, allow_files = True, cfg = android_platforms_transition),
106118
resource_apks = attr.label_list(
107119
allow_rules = ["apk_import"],

rules/android_binary/impl.bzl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -642,16 +642,20 @@ def _process_baseline_profiles(ctx, validation_ctx, deploy_ctx, **_unused_ctxs):
642642

643643
# Include startup profiles if the optimizer is disabled since profiles won't be merged
644644
# in the optimizer.
645-
transitive_profiles = depset(
646-
ctx.files.startup_profiles if enable_optimizer_integration and not has_proguard_specs else [],
647-
transitive = [
648-
profile_provider.files
649-
for profile_provider in utils.collect_providers(
650-
BaselineProfileProvider,
651-
ctx.attr.deps,
652-
)
653-
],
654-
)
645+
startup_profiles = ctx.files.startup_profiles if enable_optimizer_integration and not has_proguard_specs else []
646+
if ctx.attr.baseline_profiles_override:
647+
transitive_profiles = depset(ctx.files.baseline_profiles_override + startup_profiles)
648+
else:
649+
transitive_profiles = depset(
650+
startup_profiles,
651+
transitive = [
652+
profile_provider.files
653+
for profile_provider in utils.collect_providers(
654+
BaselineProfileProvider,
655+
ctx.attr.deps,
656+
)
657+
],
658+
)
655659
baseline_profile_output = _baseline_profiles.process(
656660
ctx,
657661
transitive_profiles = transitive_profiles,

0 commit comments

Comments
 (0)