Create a new a`android_host_hybrid_mode_transition` and apply it to android_local_test This removes the Feature Flags Transition. PiperOrigin-RevId: 949618519 Change-Id: I539a5cfc788cabae0b393c6f4f26f64e9f7b58e0
diff --git a/rules/BUILD b/rules/BUILD index 295c065..7f79f07 100644 --- a/rules/BUILD +++ b/rules/BUILD
@@ -96,6 +96,16 @@ ) bzl_library( + name = "android_host_hybrid_mode_transition_bzl", + srcs = [ + "android_host_hybrid_mode_transition.bzl", + ], + deps = [ + ":visibility_bzl", + ], +) + +bzl_library( name = "bzl", srcs = [ "android_sdk.bzl",
diff --git a/rules/android_host_hybrid_mode_transition.bzl b/rules/android_host_hybrid_mode_transition.bzl new file mode 100644 index 0000000..008efa2 --- /dev/null +++ b/rules/android_host_hybrid_mode_transition.bzl
@@ -0,0 +1,35 @@ +# Copyright 2026 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. +""" +Transition that sets android_host_hybrid_mode to true. + +This is used to signal that code is being built for Android tests but running on a non-Android host. +""" + +load("//rules:visibility.bzl", "PROJECT_VISIBILITY") + +visibility(PROJECT_VISIBILITY) + +def _android_host_hybrid_mode_transition_impl(settings, attr): + return { + "//rules/flags:android_host_hybrid_mode": True, + } + +android_host_hybrid_mode_transition = transition( + implementation = _android_host_hybrid_mode_transition_impl, + inputs = [], + outputs = [ + "//rules/flags:android_host_hybrid_mode", + ], +)
diff --git a/rules/android_local_test/BUILD b/rules/android_local_test/BUILD index 6284b03..96fbfb4 100644 --- a/rules/android_local_test/BUILD +++ b/rules/android_local_test/BUILD
@@ -22,6 +22,7 @@ srcs = glob(["*.bzl"]), deps = [ "//rules:add_constraints_bzl", + "//rules:android_host_hybrid_mode_transition_bzl", "//rules:common_bzl", "//rules:min_sdk_version_bzl", "//rules:visibility_bzl",
diff --git a/rules/android_local_test/rule.bzl b/rules/android_local_test/rule.bzl index 059653f..27db3b9 100644 --- a/rules/android_local_test/rule.bzl +++ b/rules/android_local_test/rule.bzl
@@ -13,6 +13,7 @@ # limitations under the License. """Bazel rule for Android local test.""" +load("//rules:android_host_hybrid_mode_transition.bzl", "android_host_hybrid_mode_transition") load("//rules:utils.bzl", "ANDROID_SDK_TOOLCHAIN_TYPE") load("//rules:visibility.bzl", "PROJECT_VISIBILITY") load("@rules_java//java/common:java_info.bzl", "JavaInfo") @@ -21,15 +22,20 @@ visibility(PROJECT_VISIBILITY) +_DEFAULT_CFG = android_host_hybrid_mode_transition + def make_rule( attrs = ATTRS, implementation = impl, - additional_toolchains = []): + additional_toolchains = [], + cfg = _DEFAULT_CFG): """Makes the rule. Args: attrs: A dict. The attributes for the rule. implementation: A function. The rule's implementation method. + additional_toolchains: A list of toolchain types to for the rule to use. + cfg: The set of transitions to use on the incoming edge of the rule. Returns: A rule. @@ -37,7 +43,7 @@ return rule( attrs = attrs, implementation = implementation, - cfg = config_common.config_feature_flag_transition("feature_flags"), + cfg = cfg, fragments = [ "android", "bazel_android", # NOTE: Only exists for Bazel