Skip to content

Commit

Permalink
Create and wire up ACL for target-specific optimizer action requirements
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 690770694
Change-Id: Ic18d98e4a9272fd80ec5eb94e639be6e1f304499
  • Loading branch information
timpeut authored and copybara-github committed Oct 28, 2024
1 parent 1b1faa3 commit f0de7b9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rules/acls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ load("//rules/acls:force_final_resources.bzl", "FORCE_FINAL_ANDROID_BINARY_RESOU
load("//rules/acls:install_apps_in_data.bzl", "INSTALL_APPS_IN_DATA")
load("//rules/acls:lint_registry_rollout.bzl", "LINT_REGISTRY_FALLBACK", "LINT_REGISTRY_ROLLOUT")
load("//rules/acls:local_test_multi_proto.bzl", "LOCAL_TEST_MULTI_PROTO_PKG")
load("//rules/acls:optimizer_execution_requirements.bzl", "OPTIMIZER_EXECUTION_REQUIREMENTS")
load(
"//rules/acls:partial_jetification_targets.bzl",
"PARTIAL_JETIFICATION_TARGETS_FALLBACK",
Expand Down Expand Up @@ -203,6 +204,9 @@ def _in_resource_shrinking_in_optimizer(fqn):
def _in_record_desugaring_rollout(fqn):
return matches(fqn, RECORD_DESUGARING_ROLLOUT_DICT) and not matches(fqn, RECORD_DESUGARING_FALLBACK_DICT)

def _get_optimizer_execution_requirements(target_package):
return OPTIMIZER_EXECUTION_REQUIREMENTS.get(target_package, None)

def make_dict(lst):
"""Do not use this method outside of acls directory."""
return {t: True for t in lst}
Expand Down Expand Up @@ -322,6 +326,7 @@ def matches(fqn, dct):
acls = struct(
get_android_archive_duplicate_class_allowlist = _get_android_archive_duplicate_class_allowlist,
get_android_archive_exposed_package_allowlist = _get_android_archive_exposed_package_allowlist,
get_optimizer_execution_requirements = _get_optimizer_execution_requirements,
in_aar_import_deps_checker = _in_aar_import_deps_checker,
in_aar_import_explicit_exports_manifest = _in_aar_import_explicit_exports_manifest,
in_aar_import_exports_r_java = _in_aar_import_exports_r_java,
Expand Down
23 changes: 23 additions & 0 deletions rules/acls/optimizer_execution_requirements.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Packages with custom optimizer action execution requirements."""

load("//rules:visibility.bzl", "PROJECT_VISIBILITY")

visibility(PROJECT_VISIBILITY)

# Dictionary of target_package -> {execution_requirement}.
# NOTE: This is expected to be used by a small number of packages. Does not support individual
# targets or subpackages.
OPTIMIZER_EXECUTION_REQUIREMENTS = {}
2 changes: 2 additions & 0 deletions rules/proguard.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

load("//rules:visibility.bzl", "PROJECT_VISIBILITY")
load("@rules_java//java/common:proguard_spec_info.bzl", "ProguardSpecInfo")
load(":acls.bzl", "acls")
load(":android_neverlink_aspect.bzl", "StarlarkAndroidNeverlinkInfo")
load(":baseline_profiles.bzl", _baseline_profiles = "baseline_profiles")
load(":common.bzl", "common")
Expand Down Expand Up @@ -332,6 +333,7 @@ def _optimization_action(
arguments = [args],
mnemonic = mnemonic,
progress_message = progress_message,
execution_requirements = acls.get_optimizer_execution_requirements(ctx.label.package),
toolchain = None, # TODO(timpeut): correctly set this based off which optimizer is selected
)

Expand Down

0 comments on commit f0de7b9

Please sign in to comment.