Skip to content

Commit

Permalink
Create acl and wire up with the starlark split transition.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 501364665
Change-Id: I08a20a492b6bb33a2a00a0cf03ebb6fae246e898
  • Loading branch information
timpeut authored and Copybara-Service committed Jan 11, 2023
1 parent baf4bae commit e364356
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
7 changes: 7 additions & 0 deletions rules/acls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ load("//rules/acls:android_test_lockdown.bzl", "ANDROID_TEST_LOCKDOWN_GENERATOR_
load("//rules/acls:android_device_plugin_rollout.bzl", "ANDROID_DEVICE_PLUGIN_FALLBACK", "ANDROID_DEVICE_PLUGIN_ROLLOUT")
load("//rules/acls:android_instrumentation_binary_starlark_resources.bzl", "ANDROID_INSTRUMENTATION_BINARY_STARLARK_RESOURCES_FALLBACK", "ANDROID_INSTRUMENTATION_BINARY_STARLARK_RESOURCES_ROLLOUT")
load("//rules/acls:android_binary_starlark_javac.bzl", "ANDROID_BINARY_STARLARK_JAVAC_FALLBACK", "ANDROID_BINARY_STARLARK_JAVAC_ROLLOUT")
load("//rules/acls:android_binary_starlark_split_transition.bzl", "ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_FALLBACK", "ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_ROLLOUT")
load("//rules/acls:android_feature_splits_dogfood.bzl", "ANDROID_FEATURE_SPLITS_DOGFOOD")
load("//rules/acls:android_library_resources_without_srcs.bzl", "ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS", "ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_GENERATOR_FUNCTIONS")
load("//rules/acls:android_library_starlark_resource_outputs.bzl", "ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_FALLBACK", "ANDROID_LIBRARY_STARLARK_RESOURCE_OUTPUTS_ROLLOUT")
Expand Down Expand Up @@ -102,6 +103,9 @@ def _in_android_instrumentation_binary_starlark_resources(fqn):
def _in_android_binary_starlark_javac(fqn):
return not matches(fqn, ANDROID_BINARY_STARLARK_JAVAC_FALLBACK_DICT) and matches(fqn, ANDROID_BINARY_STARLARK_JAVAC_ROLLOUT_DICT)

def _in_android_binary_starlark_split_transition(fqn):
return not matches(fqn, ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_FALLBACK_DICT) and matches(fqn, ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_ROLLOUT_DICT)

def _in_android_feature_splits_dogfood(fqn):
return matches(fqn, ANDROID_FEATURE_SPLITS_DOGFOOD_DICT)

Expand Down Expand Up @@ -227,6 +231,8 @@ ANDROID_INSTRUMENTATION_BINARY_STARLARK_RESOURCES_ROLLOUT_DICT = make_dict(ANDRO
ANDROID_INSTRUMENTATION_BINARY_STARLARK_RESOURCES_FALLBACK_DICT = make_dict(ANDROID_INSTRUMENTATION_BINARY_STARLARK_RESOURCES_FALLBACK)
ANDROID_BINARY_STARLARK_JAVAC_ROLLOUT_DICT = make_dict(ANDROID_BINARY_STARLARK_JAVAC_ROLLOUT)
ANDROID_BINARY_STARLARK_JAVAC_FALLBACK_DICT = make_dict(ANDROID_BINARY_STARLARK_JAVAC_FALLBACK)
ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_ROLLOUT_DICT = make_dict(ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_ROLLOUT)
ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_FALLBACK_DICT = make_dict(ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_FALLBACK)
ANDROID_FEATURE_SPLITS_DOGFOOD_DICT = make_dict(ANDROID_FEATURE_SPLITS_DOGFOOD)
ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_DICT = make_dict(ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS)
ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_GENERATOR_FUNCTIONS_DICT = make_dict(ANDROID_LIBRARY_RESOURCES_WITHOUT_SRCS_GENERATOR_FUNCTIONS)
Expand Down Expand Up @@ -331,6 +337,7 @@ acls = struct(
in_android_device_plugin_rollout = _in_android_device_plugin_rollout,
in_android_instrumentation_binary_starlark_resources = _in_android_instrumentation_binary_starlark_resources,
in_android_binary_starlark_javac = _in_android_binary_starlark_javac,
in_android_binary_starlark_split_transition = _in_android_binary_starlark_split_transition,
in_android_feature_splits_dogfood = _in_android_feature_splits_dogfood,
in_android_library_starlark_resource_outputs_rollout = _in_android_library_starlark_resource_outputs_rollout,
in_android_library_resources_without_srcs = _in_android_library_resources_without_srcs,
Expand Down
22 changes: 22 additions & 0 deletions rules/acls/android_binary_starlark_split_transition.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 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.

"""Allow and fallback lists for using the Starlark implementation of the android split transition"""

ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_ROLLOUT = [
"//tools/build_defs/android/test/dev/android_binary_internal/java/com/nativelibs:__pkg__",
]

ANDROID_BINARY_STARLARK_SPLIT_TRANSITION_FALLBACK = [
]
12 changes: 7 additions & 5 deletions rules/android_binary_internal/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ def _validate_manifest(ctx, packaged_resources_ctx, **unused_ctxs):
)

def _process_native_libs(ctx, **_unusued_ctxs):
native_libs_info = _process_native_deps(
ctx,
filename = "nativedeps",
)
providers = []
if acls.in_android_binary_starlark_split_transition(str(ctx.label)):
providers.append(_process_native_deps(
ctx,
filename = "nativedeps",
))
return ProviderInfo(
name = "native_libs_ctx",
value = struct(providers = [native_libs_info]),
value = struct(providers = providers),
)

def use_legacy_manifest_merger(ctx):
Expand Down

0 comments on commit e364356

Please sign in to comment.