1*60517a1eSAndroid Build Coastguard Worker# Copyright 2022 The Bazel Authors. All rights reserved. 2*60517a1eSAndroid Build Coastguard Worker# 3*60517a1eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*60517a1eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*60517a1eSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*60517a1eSAndroid Build Coastguard Worker# 7*60517a1eSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*60517a1eSAndroid Build Coastguard Worker# 9*60517a1eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*60517a1eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*60517a1eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*60517a1eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*60517a1eSAndroid Build Coastguard Worker# limitations under the License. 14*60517a1eSAndroid Build Coastguard Worker 15*60517a1eSAndroid Build Coastguard Worker"" 16*60517a1eSAndroid Build Coastguard Worker 17*60517a1eSAndroid Build Coastguard Workerload("//python:versions.bzl", "PLATFORMS", "TOOL_VERSIONS") 18*60517a1eSAndroid Build Coastguard Workerload("//tests/support:sh_py_run_test.bzl", "py_reconfig_test") 19*60517a1eSAndroid Build Coastguard Worker 20*60517a1eSAndroid Build Coastguard Workerdef define_toolchain_tests(name): 21*60517a1eSAndroid Build Coastguard Worker """Define the toolchain tests. 22*60517a1eSAndroid Build Coastguard Worker 23*60517a1eSAndroid Build Coastguard Worker Args: 24*60517a1eSAndroid Build Coastguard Worker name: Only present to satisfy tooling. 25*60517a1eSAndroid Build Coastguard Worker """ 26*60517a1eSAndroid Build Coastguard Worker for platform_key, platform_info in PLATFORMS.items(): 27*60517a1eSAndroid Build Coastguard Worker native.config_setting( 28*60517a1eSAndroid Build Coastguard Worker name = "_is_{}".format(platform_key), 29*60517a1eSAndroid Build Coastguard Worker flag_values = platform_info.flag_values, 30*60517a1eSAndroid Build Coastguard Worker constraint_values = platform_info.compatible_with, 31*60517a1eSAndroid Build Coastguard Worker ) 32*60517a1eSAndroid Build Coastguard Worker 33*60517a1eSAndroid Build Coastguard Worker for python_version, meta in TOOL_VERSIONS.items(): 34*60517a1eSAndroid Build Coastguard Worker target_compatible_with = { 35*60517a1eSAndroid Build Coastguard Worker "//conditions:default": ["@platforms//:incompatible"], 36*60517a1eSAndroid Build Coastguard Worker } 37*60517a1eSAndroid Build Coastguard Worker for platform_key in meta["sha256"].keys(): 38*60517a1eSAndroid Build Coastguard Worker is_platform = "_is_{}".format(platform_key) 39*60517a1eSAndroid Build Coastguard Worker target_compatible_with[is_platform] = [] 40*60517a1eSAndroid Build Coastguard Worker 41*60517a1eSAndroid Build Coastguard Worker py_reconfig_test( 42*60517a1eSAndroid Build Coastguard Worker name = "python_{}_test".format(python_version), 43*60517a1eSAndroid Build Coastguard Worker srcs = ["python_toolchain_test.py"], 44*60517a1eSAndroid Build Coastguard Worker main = "python_toolchain_test.py", 45*60517a1eSAndroid Build Coastguard Worker python_version = python_version, 46*60517a1eSAndroid Build Coastguard Worker env = { 47*60517a1eSAndroid Build Coastguard Worker "EXPECT_PYTHON_VERSION": python_version, 48*60517a1eSAndroid Build Coastguard Worker }, 49*60517a1eSAndroid Build Coastguard Worker deps = ["//python/runfiles"], 50*60517a1eSAndroid Build Coastguard Worker data = ["//tests/support:current_build_settings"], 51*60517a1eSAndroid Build Coastguard Worker target_compatible_with = select(target_compatible_with), 52*60517a1eSAndroid Build Coastguard Worker ) 53