forked from bazelbuild/rules_kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple Kotlin compiler from Kotlin rules
Move Kotlin specific targets (like `kt_jvm_import`) from `BUILD.com_github_jetbrains_kotlin` to `//kotlin/compiler`. This will make it possible to release `kotlin-compiler` module on `bazel-central-registry` without depending on `rules_kotlin`. The release will contain the new form `BUILD.com_github_jetbrains_kotlin` which doesn't depend on `rules_kotlin`. RELNOTES[INC]: This breaks users that depend on `@com_github_jetbrains_kotlin//:*` targets. The same targets can be found under `@io_bazel_rules_kotlin//kotlin/compiler:*`. It's not possible to add an `alias` to `@com_github_jetbrains_kotlin` repository, becuase it would already create a dependency on `rules_kotlin` repository in the bzlmod world. Technically it's possible to release 2 bzlmod modules that have a circular dependency. But this might create some unexpected problems. It addition it would be harder to convince `com_github_jetbrains_kotlin` owners to depend on `rules_kotlin`. Works toward: bazelbuild#660
- Loading branch information
Showing
34 changed files
with
248 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2020 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. | ||
load(":compiler.bzl", "kt_configure_compiler") | ||
load("//src/main/starlark/release:packager.bzl", "release_archive") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
# Configures the compiler | ||
kt_configure_compiler() | ||
|
||
release_archive( | ||
name = "pkg", | ||
srcs = glob(["*.bzl"]), | ||
src_map = { | ||
"BUILD.release.bazel": "BUILD.bazel", | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2020 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. | ||
load(":compiler.bzl", "kt_configure_compiler") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
# Configures the compiler | ||
kt_configure_compiler() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# Copyright 2022 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. | ||
|
||
load("//kotlin:jvm.bzl", "kt_jvm_import") | ||
load("//kotlin:js.bzl", "kt_js_import") | ||
load("@rules_java//java:defs.bzl", "java_import") | ||
load("//kotlin/internal:defs.bzl", _KT_COMPILER_REPO = "KT_COMPILER_REPO") | ||
|
||
_KT_COMPILER_REPO_PREFIX = "@" + _KT_COMPILER_REPO + "//:" | ||
|
||
def kt_configure_compiler(): | ||
""" | ||
Defines the toolchain_type and default toolchain for kotlin compilation. | ||
Must be called in kotlin/internal/BUILD.bazel | ||
""" | ||
if native.package_name() != "kotlin/compiler": | ||
fail("kt_configure_compiler must be called in kotlin/compiler not %s" % native.package_name()) | ||
|
||
kt_jvm_import( | ||
name = "annotations", | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/annotations-13.0.jar", | ||
neverlink = 1, | ||
) | ||
|
||
kt_jvm_import( | ||
name = "jvm-abi-gen", | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/jvm-abi-gen.jar", | ||
) | ||
|
||
# Kotlin dependencies that are internal to this repo and are meant to be loaded manually into a classloader. | ||
[ | ||
kt_jvm_import( | ||
name = "kotlin-%s" % art, | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/kotlin-%s.jar" % art, | ||
neverlink = 1, | ||
) | ||
for art in [ | ||
"annotation-processing", | ||
"annotation-processing-runtime", | ||
"compiler", | ||
] | ||
] | ||
|
||
kt_jvm_import( | ||
name = "kotlinx-serialization-compiler-plugin", | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/kotlinx-serialization-compiler-plugin.jar", | ||
) | ||
|
||
kt_jvm_import( | ||
name = "allopen-compiler-plugin", | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/allopen-compiler-plugin.jar", | ||
) | ||
|
||
kt_jvm_import( | ||
name = "noarg-compiler-plugin", | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/noarg-compiler-plugin.jar", | ||
) | ||
|
||
kt_jvm_import( | ||
name = "sam-with-receiver-compiler-plugin", | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/sam-with-receiver-compiler-plugin.jar", | ||
) | ||
|
||
kt_jvm_import( | ||
name = "parcelize-compiler-plugin", | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/parcelize-compiler.jar", | ||
) | ||
|
||
kt_jvm_import( | ||
name = "parcelize-runtime", | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/parcelize-runtime.jar", | ||
) | ||
|
||
# Kotlin dependencies that are internal to this repo and may be linked. | ||
[ | ||
java_import( | ||
name = "kotlin-%s" % art, | ||
jars = [_KT_COMPILER_REPO_PREFIX + "lib/kotlin-%s.jar" % art], | ||
) | ||
for art in [ | ||
"preloader", | ||
] | ||
] | ||
|
||
# The Kotlin standard libraries. These should be setup in a Toolchain. | ||
[ | ||
kt_jvm_import( | ||
name = "kotlin-%s" % art, | ||
jar = _KT_COMPILER_REPO_PREFIX + "lib/kotlin-%s.jar" % art, | ||
srcjar = _KT_COMPILER_REPO_PREFIX + "lib/kotlin-%s-sources.jar" % art, | ||
visibility = ["//visibility:public"], | ||
) | ||
for art in [ | ||
"stdlib", | ||
"stdlib-jdk7", | ||
"stdlib-jdk8", | ||
"reflect", | ||
"test", | ||
"script-runtime", | ||
] | ||
] | ||
|
||
# The Kotlin JS standard libraries. These should be setup in a Toolchain. | ||
[ | ||
kt_js_import( | ||
name = "kotlin-%s" % art, | ||
jars = [_KT_COMPILER_REPO_PREFIX + "lib/kotlin-%s.jar" % art], | ||
srcjar = _KT_COMPILER_REPO_PREFIX + "lib/kotlin-%s-sources.jar" % art, | ||
visibility = ["//visibility:public"], | ||
) | ||
for art in [ | ||
"test-js", | ||
"stdlib-js", | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.