1# Copyright (C) 2021 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""Configuration transitions to change the platform flavor. 16 17These transitions are used to specify the build setting configuration of 18test targets required by test runner rule, because in different use cases, 19test runner requires the test target in different platform flavor and in 20the test target provider rules, the test target will be built based on the 21build setting specified by these transitions. 22 23More documentation on how to use transitions at 24https://docs.bazel.build/versions/main/skylark/config.html#user-defined-transitions 25""" 26 27def _host_transition_impl(settings, attr): 28 _ignore = (settings, attr) 29 return { 30 "//bazel/rules:platform_flavor": "host", 31 } 32 33host_transition = transition( 34 inputs = [], 35 outputs = ["//bazel/rules:platform_flavor"], 36 implementation = _host_transition_impl, 37) 38 39def _device_transition_impl(settings, attr): 40 _ignore = (settings, attr) 41 return { 42 "//bazel/rules:platform_flavor": "device", 43 } 44 45device_transition = transition( 46 inputs = [], 47 outputs = ["//bazel/rules:platform_flavor"], 48 implementation = _device_transition_impl, 49) 50