diff --git a/kotlin/internal/toolchains.bzl b/kotlin/internal/toolchains.bzl index 5d208514e..9f965372b 100644 --- a/kotlin/internal/toolchains.bzl +++ b/kotlin/internal/toolchains.bzl @@ -24,10 +24,6 @@ load( _KtJsInfo = "KtJsInfo", _TOOLCHAIN_TYPE = "TOOLCHAIN_TYPE", ) -load( - "//src/main/starlark/core/repositories:tools.bzl", - "absolute_target", -) """Kotlin Toolchains @@ -264,9 +260,24 @@ _kt_toolchain = rule( provides = [platform_common.ToolchainInfo], ) +_KT_DEFAULT_TOOLCHAIN = Label("//kotlin/internal:default_toolchain") + def kt_register_toolchains(): """This macro registers the kotlin toolchain.""" - native.register_toolchains(absolute_target("//kotlin/internal:default_toolchain")) + native.register_toolchains(str(_KT_DEFAULT_TOOLCHAIN)) + +# Evaluating the select in the context of bzl file to get its repository +_DEBUG_SELECT = select({ + Label("//kotlin/internal:builder_debug_trace"): ["trace"], + "//conditions:default": [], +}) + select({ + Label("//kotlin/internal:builder_debug_timings"): ["timings"], + "//conditions:default": [], +}) + +# Evaluating the labels in the context of bzl file to get its repository +_EXPERIMENTAL_USE_ABI_JARS = Label("//kotlin/internal:experimental_use_abi_jars") +_NOEXPERIMENTAL_USE_ABI_JARS = Label("//kotlin/internal:noexperimental_use_abi_jars") def define_kt_toolchain( name, @@ -289,18 +300,10 @@ def define_kt_toolchain( language_version = language_version, api_version = api_version, jvm_target = jvm_target, - debug = - select({ - absolute_target("//kotlin/internal:builder_debug_trace"): ["trace"], - "//conditions:default": [], - }) + - select({ - absolute_target("//kotlin/internal:builder_debug_timings"): ["timings"], - "//conditions:default": [], - }), + debug = _DEBUG_SELECT, experimental_use_abi_jars = select({ - absolute_target("//kotlin/internal:experimental_use_abi_jars"): True, - absolute_target("//kotlin/internal:noexperimental_use_abi_jars"): False, + _EXPERIMENTAL_USE_ABI_JARS: True, + _NOEXPERIMENTAL_USE_ABI_JARS: False, "//conditions:default": experimental_use_abi_jars, }), experimental_multiplex_workers = experimental_multiplex_workers, diff --git a/src/main/starlark/core/repositories/BUILD b/src/main/starlark/core/repositories/BUILD index bd1880f3a..240510bdb 100644 --- a/src/main/starlark/core/repositories/BUILD +++ b/src/main/starlark/core/repositories/BUILD @@ -19,7 +19,6 @@ release_archive( srcs = [ "BUILD.com_github_jetbrains_kotlin.bazel", "compiler.bzl", - "tools.bzl", "versions.bzl", ] + glob(["capabilities_*.bazel"]), src_map = { diff --git a/src/main/starlark/core/repositories/tools.bzl b/src/main/starlark/core/repositories/tools.bzl deleted file mode 100644 index 7500a6db2..000000000 --- a/src/main/starlark/core/repositories/tools.bzl +++ /dev/null @@ -1,17 +0,0 @@ -"""tools for managing repositories.""" - -def absolute_target(repo_relative_target): - """Converts a relative path inside a repository to a fully qualified name. - - This uses builtin Label to translate relative paths to repository qualified targets of the defining bzl file. - - For instance, absolute_target is defined in repository "zumgali". Calling absolute_target("//gali/gali:zum") returns - "@zumgali//gali/gali:zum" - - Args: - repo_relative_target: relative target expression - Returns: - Fully qualified repository string. - """ - label = Label(repo_relative_target) - return "@%s//%s:%s" % (label.workspace_name, label.package, label.name)