Skip to content

Commit 7dcb7f9

Browse files
authored
Fix js test and format capabilities (#1178)
* Fix js test and format capabilities Of interesting note, I discovered the K2JsIrCompiler class that looks like it replaces the K2JSCompiler. At least, it gives better error messages. * Revert rule detritus * Fix merge error
1 parent 24e2aa7 commit 7dcb7f9

File tree

8 files changed

+22
-10
lines changed

8 files changed

+22
-10
lines changed

kotlin/compiler/compiler.bzl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,27 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@rules_java//java:defs.bzl", "java_import")
15+
load("@com_github_jetbrains_kotlin//:artifacts.bzl", "KOTLINC_ARTIFACTS")
1616
load("//kotlin:js.bzl", "kt_js_import")
1717
load("//kotlin:jvm.bzl", "kt_jvm_import")
1818
load("//kotlin/internal:defs.bzl", _KT_COMPILER_REPO = "KT_COMPILER_REPO")
19-
load("@com_github_jetbrains_kotlin//:artifacts.bzl", "KOTLINC_ARTIFACTS")
2019

2120
def _import_artifacts(artifacts, rule_kind):
2221
_import_labels(artifacts.plugin, rule_kind)
2322
_import_labels(artifacts.runtime, rule_kind)
2423
_import_labels(artifacts.compile, rule_kind, neverlink = 1)
2524

2625
def _import_labels(labels, rule_kind, **rule_args):
27-
for label in labels:
26+
for (label, file) in labels.items():
27+
if not file.endswith(".jar"):
28+
native.filegroup(
29+
name = label,
30+
srcs = [
31+
"@%s//:%s" % (_KT_COMPILER_REPO, label),
32+
],
33+
)
34+
return
35+
2836
if "-sources" in label:
2937
continue
3038
args = dict(rule_args.items())

src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.preloading.ClassPreloadingUtils
2424
import org.jetbrains.kotlin.preloading.Preloader
2525
import java.io.File
2626
import java.io.PrintStream
27-
import java.lang.ClassLoader
2827
import java.lang.reflect.Method
2928
import java.nio.file.FileSystems
3029
import java.nio.file.Path
@@ -259,6 +258,6 @@ class KotlinToolchain private constructor(
259258
toolchain: KotlinToolchain,
260259
) : KotlinCliToolInvoker(
261260
toolchain.toolchainWithReflect(),
262-
"org.jetbrains.kotlin.cli.js.K2JSCompiler",
261+
"org.jetbrains.kotlin.cli.js.K2JsIrCompiler",
263262
)
264263
}

src/main/starlark/core/repositories/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ release_archive(
1919
srcs = [
2020
"BUILD.com_github_google_ksp.bazel",
2121
"BUILD.com_github_jetbrains_kotlin.bazel",
22+
"BUILD.kotlin_capabilities.bazel",
2223
"bzlmod_impl.bzl",
2324
"compiler.bzl",
2425
"ksp.bzl",

src/main/starlark/core/repositories/BUILD.kotlin_capabilities.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
package(default_visibility = ["//visibility:public"])
15-
1614
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1715
load(":artifacts.bzl", "KOTLINC_ARTIFACT_LIST")
1816

17+
package(default_visibility = ["//visibility:public"])
18+
1919
bzl_library(
2020
name = "capabilities",
2121
srcs = glob(["*.bzl"]),

src/main/starlark/core/repositories/kotlin/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ load("//src/main/starlark/release:packager.bzl", "release_archive")
22

33
release_archive(
44
name = "pkg",
5-
srcs = glob(["capabilities_*.bazel"]),
5+
srcs = glob([
6+
"capabilities_*.bazel",
7+
"artifacts.bzl",
8+
]),
69
src_map = {
710
"BUILD.release.bazel": "BUILD",
811
},

src/main/starlark/core/repositories/kotlin/artifacts.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ KOTLINC_ARTIFACTS = struct(
55
plugin = {},
66
runtime = {
77
"kotlin-stdlib-js": "lib/kotlin-stdlib-js.jar",
8+
"kotlin-stdlib-js-klib": "lib/kotlin-stdlib-js.klib",
89
"kotlin-stdlib-js-sources": "lib/kotlin-stdlib-js-sources.jar",
910
"kotlin-test-js": "lib/kotlin-test-js.jar",
1011
"kotlin-test-js-sources": "lib/kotlin-test-js-sources.jar",

src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ kt_rules_test(
103103
name = "KotlinBuilderJsTest",
104104
srcs = ["js/KotlinBuilderJsTest.java"],
105105
data = [
106-
"//kotlin/compiler:kotlin-stdlib-js.js",
106+
"//kotlin/compiler:kotlin-stdlib-js-klib",
107107
],
108108
)
109109

src/test/kotlin/io/bazel/kotlin/builder/tasks/js/KotlinBuilderJsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
public class KotlinBuilderJsTest {
1313
private static final KotlinJsTestBuilder builder = new KotlinJsTestBuilder();
1414

15-
private Dep stdLib = Dep.fromLabel("@com_github_jetbrains_kotlin//:lib/kotlin-stdlib-js.jar");
15+
private Dep stdLib = Dep.fromLabel("//kotlin/compiler:kotlin-stdlib-js-klib");
1616

1717
@Test
1818
public void testSimpleJsCompile() {

0 commit comments

Comments
 (0)