# 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.

# ====================
# NOTE: tests/support/support.bzl has constants to easily refer to
# these toolchains.
# ====================

load("//python:py_runtime.bzl", "py_runtime")
load("//python:py_runtime_pair.bzl", "py_runtime_pair")
load("//python/private:py_exec_tools_toolchain.bzl", "py_exec_tools_toolchain")  # buildifier: disable=bzl-visibility

# NOTE: A platform runtime is used because it doesn't include any files. This
# makes it easier for analysis tests to verify content.
py_runtime(
    name = "platform_runtime",
    implementation_name = "fakepy",
    interpreter_path = "/fake/python3.9",
    interpreter_version_info = {
        "major": "4",
        "minor": "5",
    },
)

py_runtime_pair(
    name = "platform_runtime_pair",
    py3_runtime = ":platform_runtime",
)

toolchain(
    name = "platform_toolchain",
    toolchain = ":platform_runtime_pair",
    toolchain_type = "//python:toolchain_type",
)

toolchain(
    name = "exec_toolchain",
    toolchain = ":exec_toolchain_impl",
    toolchain_type = "//python:exec_tools_toolchain_type",
)

# An exec toolchain is explicitly defined so that the tests pass when run
# in environments that aren't using the toolchains generated by the
# hermetic runtimes.
py_exec_tools_toolchain(
    name = "exec_toolchain_impl",
    precompiler = "//tools/precompiler:precompiler",
)
