diff --git a/rules/acls.bzl b/rules/acls.bzl index d342ac73..8e43ec50 100644 --- a/rules/acls.bzl +++ b/rules/acls.bzl @@ -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", @@ -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} @@ -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, diff --git a/rules/acls/optimizer_execution_requirements.bzl b/rules/acls/optimizer_execution_requirements.bzl new file mode 100644 index 00000000..bcf275ca --- /dev/null +++ b/rules/acls/optimizer_execution_requirements.bzl @@ -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 = {} diff --git a/rules/proguard.bzl b/rules/proguard.bzl index 0cb775ec..fca08a9e 100644 --- a/rules/proguard.bzl +++ b/rules/proguard.bzl @@ -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") @@ -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 )