From d964c23ffa1a1ef9cc91e40510a6ef60ad669609 Mon Sep 17 00:00:00 2001 From: Ben Lee Date: Tue, 16 Jul 2024 09:27:12 -0700 Subject: [PATCH] Drop support for JavaScript (#1185) * Drop support for JavaScript * Remove more * More --- .bazelci/presubmit.yml | 10 - README.md | 2 +- docs/kotlin.md | 42 -- empty.py | 0 examples/node/.bazelversion | 1 - examples/node/.gitignore | 1 - examples/node/BUILD | 36 -- examples/node/README.MD | 1 - examples/node/WORKSPACE | 59 --- examples/node/coroutines-helloworld/BUILD | 32 -- examples/node/coroutines-helloworld/Main.kt | 14 - examples/node/express/App.kt | 26 -- examples/node/express/BUILD | 48 -- examples/node/express/Routes.kt | 27 -- examples/node/express/auth/Auth.kt | 5 - examples/node/express/auth/BUILD | 21 - examples/node/package.json | 10 - examples/node/yarn.lock | 414 ------------------ kotlin/BUILD | 2 - kotlin/compiler/compiler.bzl | 2 - kotlin/internal/BUILD | 2 - kotlin/internal/BUILD.release.bazel | 1 - kotlin/internal/defs.bzl | 9 - kotlin/internal/js/BUILD | 41 -- kotlin/internal/js/BUILD.release.bazel | 28 -- kotlin/internal/js/impl.bzl | 159 ------- kotlin/internal/js/importer.py | 83 ---- kotlin/internal/js/js.bzl | 165 ------- kotlin/internal/toolchains.bzl | 12 - kotlin/js.bzl | 8 - kotlin/kotlin.bzl | 25 -- .../builder/KotlinBuilderComponent.java | 3 - .../kotlin/builder/tasks/KotlinBuilder.kt | 41 -- .../builder/tasks/js/Kotlin2JsTaskExecutor.kt | 105 ----- .../tasks/jvm/KotlinJvmTaskExecutor.kt | 2 +- .../builder/toolchain/KotlinToolchain.kt | 10 - src/main/protobuf/kotlin_model.proto | 32 -- .../starlark/core/repositories/download.bzl | 7 - .../core/repositories/kotlin/artifacts.bzl | 14 +- .../starlark/core/repositories/versions.bzl | 2 - src/test/kotlin/io/bazel/kotlin/builder/BUILD | 1 - .../builder/KotlinBuilderTestComponent.java | 3 - .../kotlin/builder/KotlinJsTestBuilder.java | 106 ----- .../io/bazel/kotlin/builder/tasks/BUILD.bazel | 9 - .../builder/tasks/js/KotlinBuilderJsTest.java | 73 --- 45 files changed, 3 insertions(+), 1691 deletions(-) create mode 100644 empty.py delete mode 120000 examples/node/.bazelversion delete mode 100644 examples/node/.gitignore delete mode 100644 examples/node/BUILD delete mode 100644 examples/node/README.MD delete mode 100644 examples/node/WORKSPACE delete mode 100644 examples/node/coroutines-helloworld/BUILD delete mode 100644 examples/node/coroutines-helloworld/Main.kt delete mode 100644 examples/node/express/App.kt delete mode 100644 examples/node/express/BUILD delete mode 100644 examples/node/express/Routes.kt delete mode 100644 examples/node/express/auth/Auth.kt delete mode 100644 examples/node/express/auth/BUILD delete mode 100644 examples/node/package.json delete mode 100644 examples/node/yarn.lock delete mode 100644 kotlin/internal/js/BUILD delete mode 100644 kotlin/internal/js/BUILD.release.bazel delete mode 100644 kotlin/internal/js/impl.bzl delete mode 100644 kotlin/internal/js/importer.py delete mode 100644 kotlin/internal/js/js.bzl delete mode 100644 kotlin/js.bzl delete mode 100644 src/main/kotlin/io/bazel/kotlin/builder/tasks/js/Kotlin2JsTaskExecutor.kt delete mode 100644 src/test/kotlin/io/bazel/kotlin/builder/KotlinJsTestBuilder.java delete mode 100644 src/test/kotlin/io/bazel/kotlin/builder/tasks/js/KotlinBuilderJsTest.java diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 76695826a..a2bdbd885 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -179,16 +179,6 @@ tasks: - test build_targets: - //... -# examples-nodejs: -# name: Example - Node -# platform: ubuntu1804 -# working_directory: examples/node -# include_json_profile: -# - build -# - test -# build_targets: -# - //coroutines-helloworld/... -# - //express/... example-jetpack-compose: name: "Example - Jetpack Compose" platform: ubuntu1804 diff --git a/README.md b/README.md index 44d49fe29..09694418f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ For more information about release and changelogs please see [Changelog](CHANGEL **rules_kotlin** supports the basic paradigm of `*_binary`, `*_library`, `*_test` of other Bazel language rules. It also supports `jvm`, `android`, and `js` flavors, with the prefix `kt_jvm` -and `kt_js`, and `kt_android` typically applied to the rules. +and `kt_android` typically applied to the rules. Support for kotlin's -Xfriend-paths via the `associates=` attribute in the jvm allow access to `internal` members. diff --git a/docs/kotlin.md b/docs/kotlin.md index db061d90e..866ff5d94 100755 --- a/docs/kotlin.md +++ b/docs/kotlin.md @@ -2,48 +2,6 @@ - - -## kt_js_import - -
-kt_js_import(name, kwargs)
-
- - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name |

-

| none | -| kwargs |

-

| none | - - - - -## kt_js_library - -
-kt_js_library(name, kwargs)
-
- - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name |

-

| none | -| kwargs |

-

| none | - - - - - - ## kt_javac_options diff --git a/empty.py b/empty.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/node/.bazelversion b/examples/node/.bazelversion deleted file mode 120000 index 96cf94962..000000000 --- a/examples/node/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -../../.bazelversion \ No newline at end of file diff --git a/examples/node/.gitignore b/examples/node/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/examples/node/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/examples/node/BUILD b/examples/node/BUILD deleted file mode 100644 index 3376d0b41..000000000 --- a/examples/node/BUILD +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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("@rules_kotlin//kotlin:js.bzl", "kt_js_import") - -# Create kt_js_imports for KotlinX's Coroutines and Atomicfu libraries. -# -# These could be imported using package.json and NPM, but they are here as an example of how to -# use KotlinJS libraries hosted on Maven directly. -# -# Note: It's important that the `name`s correspond to the base name of the library only (ie. not-ending with -js/_js) -kt_js_import( - name = "kotlinx-coroutines-core", - jars = [ - "@maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core_js", - ], - visibility = ["//:__subpackages__"], -) - -kt_js_import( - name = "kotlinx-atomicfu", - jars = [ - "@maven//:org_jetbrains_kotlinx_atomicfu_js", - ], - visibility = ["//:__subpackages__"], -) diff --git a/examples/node/README.MD b/examples/node/README.MD deleted file mode 100644 index 5721a60c9..000000000 --- a/examples/node/README.MD +++ /dev/null @@ -1 +0,0 @@ -This example workspace demonstrates the JS support. \ No newline at end of file diff --git a/examples/node/WORKSPACE b/examples/node/WORKSPACE deleted file mode 100644 index 2bdb326ba..000000000 --- a/examples/node/WORKSPACE +++ /dev/null @@ -1,59 +0,0 @@ -workspace(name = "kotlin_node_examples") - -local_repository( - name = "release_archive", - path = "../../src/main/starlark/release_archive", -) - -load("@release_archive//:repository.bzl", "archive_repository") - -archive_repository( - name = "rules_kotlin", -) - -load("@rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions") - -kotlin_repositories() - -load("@rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") - -kt_register_toolchains() - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "rules_jvm_external", - sha256 = versions.RULES_JVM_EXTERNAL_SHA, - strip_prefix = "rules_jvm_external-%s" % versions.RULES_JVM_EXTERNAL_TAG, - url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % ( - versions.RULES_JVM_EXTERNAL_TAG, - versions.RULES_JVM_EXTERNAL_TAG, - ), -) - -http_archive( - name = "build_bazel_rules_nodejs", - sha256 = versions.RULES_NODEJS_SHA, - url = "https://github.com/bazelbuild/rules_nodejs/releases/download/{0}/rules_nodejs-{0}.tar.gz".format(versions.RULES_NODEJS_VERSION), -) - -load("@rules_jvm_external//:defs.bzl", "maven_install") - -maven_install( - artifacts = [ - "org.jetbrains.kotlinx:atomicfu-js:0.15.2", - "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.2", - ], - repositories = [ - "https://maven-central.storage.googleapis.com/repos/central/data/", - "https://repo1.maven.org/maven2", - ], -) - -load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") - -build_bazel_rules_nodejs_dependencies() - -load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories") - -node_repositories() diff --git a/examples/node/coroutines-helloworld/BUILD b/examples/node/coroutines-helloworld/BUILD deleted file mode 100644 index b2265080d..000000000 --- a/examples/node/coroutines-helloworld/BUILD +++ /dev/null @@ -1,32 +0,0 @@ -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") - -# Copyright 2018 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("@rules_kotlin//kotlin:js.bzl", "kt_js_library") - -kt_js_library( - name = "app", - srcs = ["Main.kt"], - visibility = ["//visibility:public"], - deps = [ - "//:kotlinx-coroutines-core", - ], -) - -nodejs_binary( - name = "coroutines-helloworld", - data = [":app"], - entry_point = ":app.js", - visibility = ["//visibility:public"], -) diff --git a/examples/node/coroutines-helloworld/Main.kt b/examples/node/coroutines-helloworld/Main.kt deleted file mode 100644 index 940c1972e..000000000 --- a/examples/node/coroutines-helloworld/Main.kt +++ /dev/null @@ -1,14 +0,0 @@ -package trivial - -import kotlinx.coroutines.* - -val scope = CoroutineScope(Dispatchers.Default) - -suspend fun main(vararg args: String) { - val job = scope.launch { - delay(1000) - println("Hello world!") - } - - job.join() -} diff --git a/examples/node/express/App.kt b/examples/node/express/App.kt deleted file mode 100644 index a7cfa6e30..000000000 --- a/examples/node/express/App.kt +++ /dev/null @@ -1,26 +0,0 @@ -package express - -import kotlinx.coroutines.* -import kotlinx.coroutines.channels.* - -@JsModule("express") -external fun express(): dynamic - -val app = express() - -@ExperimentalCoroutinesApi -fun main(args: Array) { - val scope = CoroutineScope(Dispatchers.Default) - - // register the routes. - val hitCountChannel = routes(app) - scope.launch { - hitCountChannel.consumeEach { - println("Hits so far: $it") - } - } - - app.listen(3000, { - println("Listening on port 3000") - }) -} diff --git a/examples/node/express/BUILD b/examples/node/express/BUILD deleted file mode 100644 index 6ce59cf6c..000000000 --- a/examples/node/express/BUILD +++ /dev/null @@ -1,48 +0,0 @@ -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") - -# Copyright 2018 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("@rules_kotlin//kotlin:js.bzl", "kt_js_library") - -# routes and auth have acme prepended to the rule name as these are the names of the resulting jars. The name of the -# jar is the name of the module, and thus the name of the require statements. -kt_js_library( - name = "acme-routes", - srcs = [":Routes.kt"], - deps = [ - "//:kotlinx-atomicfu", - "//:kotlinx-coroutines-core", - "//express/auth:acme-auth", - ], -) - -kt_js_library( - name = "app", - srcs = [":App.kt"], - tags = [ - "timings", - "trace", - ], - deps = [ - ":acme-routes", - "//:kotlinx-coroutines-core", - ], -) - -# The binary demonstrates an express app composed of three modules. The modules can co-exist in the same directory. -nodejs_binary( - name = "express", - data = [":app"], - entry_point = ":app.js", -) diff --git a/examples/node/express/Routes.kt b/examples/node/express/Routes.kt deleted file mode 100644 index dc00de50f..000000000 --- a/examples/node/express/Routes.kt +++ /dev/null @@ -1,27 +0,0 @@ -package express - -import express.auth.isAuthenticated -import kotlinx.atomicfu.* -import kotlinx.coroutines.* -import kotlinx.coroutines.channels.* - -fun routes(app: dynamic): Channel { - val scope = CoroutineScope(Dispatchers.Default) - val channel = Channel() - val hitCounter = atomic(0) - - app.get("/") { req, res -> - scope.launch { - val hitsSoFar = hitCounter.updateAndGet { it + 1 } - channel.send(hitsSoFar) - } - if (!isAuthenticated("bob")) { - res.send(401, "you sir, are not authorized !") - } else { - res.type("text/plain") - res.send("hello world") - } - } - - return channel -} diff --git a/examples/node/express/auth/Auth.kt b/examples/node/express/auth/Auth.kt deleted file mode 100644 index 8665a22f3..000000000 --- a/examples/node/express/auth/Auth.kt +++ /dev/null @@ -1,5 +0,0 @@ -package express.auth - -fun isAuthenticated(user: String): Boolean { - return user != "bob" -} diff --git a/examples/node/express/auth/BUILD b/examples/node/express/auth/BUILD deleted file mode 100644 index c69c124f1..000000000 --- a/examples/node/express/auth/BUILD +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2018 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("@rules_kotlin//kotlin:js.bzl", "kt_js_library") - -kt_js_library( - name = "acme-auth", - srcs = ["Auth.kt"], - tags = ["trace"], - visibility = ["//visibility:public"], -) diff --git a/examples/node/package.json b/examples/node/package.json deleted file mode 100644 index 6dc77907b..000000000 --- a/examples/node/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "node_packages", - "version": "1.0.0", - "dependencies": { - "express": "^4.19.2" - }, - "devDependencies": { - "source-map-support": "^0.5.6" - } -} diff --git a/examples/node/yarn.lock b/examples/node/yarn.lock deleted file mode 100644 index 158a39b82..000000000 --- a/examples/node/yarn.lock +++ /dev/null @@ -1,414 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -accepts@~1.3.8: - version "1.3.8" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" - dependencies: - mime-types "~2.1.34" - negotiator "0.6.3" - -array-flatten@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" - -body-parser@1.20.2: - version "1.20.2" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd" - dependencies: - bytes "3.1.2" - content-type "~1.0.5" - debug "2.6.9" - depd "2.0.0" - destroy "1.2.0" - http-errors "2.0.0" - iconv-lite "0.4.24" - on-finished "2.4.1" - qs "6.11.0" - raw-body "2.5.2" - type-is "~1.6.18" - unpipe "1.0.0" - -buffer-from@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04" - -bytes@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" - -call-bind@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" - dependencies: - es-define-property "^1.0.0" - es-errors "^1.3.0" - function-bind "^1.1.2" - get-intrinsic "^1.2.4" - set-function-length "^1.2.1" - -content-disposition@0.5.4: - version "0.5.4" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" - dependencies: - safe-buffer "5.2.1" - -content-type@~1.0.4, content-type@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" - -cookie-signature@1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" - -cookie@0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.6.0.tgz#2798b04b071b0ecbff0dbb62a505a8efa4e19051" - -debug@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - dependencies: - ms "2.0.0" - -define-data-property@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" - dependencies: - es-define-property "^1.0.0" - es-errors "^1.3.0" - gopd "^1.0.1" - -depd@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" - -destroy@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - -encodeurl@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" - -es-define-property@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" - dependencies: - get-intrinsic "^1.2.4" - -es-errors@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - -etag@~1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" - -express@^4.19.2: - version "4.19.2" - resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465" - dependencies: - accepts "~1.3.8" - array-flatten "1.1.1" - body-parser "1.20.2" - content-disposition "0.5.4" - content-type "~1.0.4" - cookie "0.6.0" - cookie-signature "1.0.6" - debug "2.6.9" - depd "2.0.0" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - finalhandler "1.2.0" - fresh "0.5.2" - http-errors "2.0.0" - merge-descriptors "1.0.1" - methods "~1.1.2" - on-finished "2.4.1" - parseurl "~1.3.3" - path-to-regexp "0.1.7" - proxy-addr "~2.0.7" - qs "6.11.0" - range-parser "~1.2.1" - safe-buffer "5.2.1" - send "0.18.0" - serve-static "1.15.0" - setprototypeof "1.2.0" - statuses "2.0.1" - type-is "~1.6.18" - utils-merge "1.0.1" - vary "~1.1.2" - -finalhandler@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32" - dependencies: - debug "2.6.9" - encodeurl "~1.0.2" - escape-html "~1.0.3" - on-finished "2.4.1" - parseurl "~1.3.3" - statuses "2.0.1" - unpipe "~1.0.0" - -forwarded@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" - -fresh@0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" - -function-bind@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" - -get-intrinsic@^1.1.3, get-intrinsic@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" - dependencies: - es-errors "^1.3.0" - function-bind "^1.1.2" - has-proto "^1.0.1" - has-symbols "^1.0.3" - hasown "^2.0.0" - -gopd@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" - dependencies: - get-intrinsic "^1.1.3" - -has-property-descriptors@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" - dependencies: - es-define-property "^1.0.0" - -has-proto@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.3.tgz#b31ddfe9b0e6e9914536a6ab286426d0214f77fd" - -has-symbols@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" - -hasown@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" - dependencies: - function-bind "^1.1.2" - -http-errors@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" - dependencies: - depd "2.0.0" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses "2.0.1" - toidentifier "1.0.1" - -iconv-lite@0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - dependencies: - safer-buffer ">= 2.1.2 < 3" - -inherits@2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - -ipaddr.js@1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - -merge-descriptors@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" - -methods@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - -mime-types@~2.1.24, mime-types@~2.1.34: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - dependencies: - mime-db "1.52.0" - -mime@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - -ms@2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - -negotiator@0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" - -object-inspect@^1.13.1: - version "1.13.1" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" - -on-finished@2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" - dependencies: - ee-first "1.1.1" - -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - -path-to-regexp@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" - -proxy-addr@~2.0.7: - version "2.0.7" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" - dependencies: - forwarded "0.2.0" - ipaddr.js "1.9.1" - -qs@6.11.0: - version "6.11.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" - dependencies: - side-channel "^1.0.4" - -range-parser@~1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" - -raw-body@2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a" - dependencies: - bytes "3.1.2" - http-errors "2.0.0" - iconv-lite "0.4.24" - unpipe "1.0.0" - -safe-buffer@5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - -"safer-buffer@>= 2.1.2 < 3": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - -send@0.18.0: - version "0.18.0" - resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" - dependencies: - debug "2.6.9" - depd "2.0.0" - destroy "1.2.0" - encodeurl "~1.0.2" - escape-html "~1.0.3" - etag "~1.8.1" - fresh "0.5.2" - http-errors "2.0.0" - mime "1.6.0" - ms "2.1.3" - on-finished "2.4.1" - range-parser "~1.2.1" - statuses "2.0.1" - -serve-static@1.15.0: - version "1.15.0" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.15.0.tgz#faaef08cffe0a1a62f60cad0c4e513cff0ac9540" - dependencies: - encodeurl "~1.0.2" - escape-html "~1.0.3" - parseurl "~1.3.3" - send "0.18.0" - -set-function-length@^1.2.1: - version "1.2.2" - resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" - dependencies: - define-data-property "^1.1.4" - es-errors "^1.3.0" - function-bind "^1.1.2" - get-intrinsic "^1.2.4" - gopd "^1.0.1" - has-property-descriptors "^1.0.2" - -setprototypeof@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" - -side-channel@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2" - dependencies: - call-bind "^1.0.7" - es-errors "^1.3.0" - get-intrinsic "^1.2.4" - object-inspect "^1.13.1" - -source-map-support@^0.5.6: - version "0.5.6" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.6.tgz#4435cee46b1aab62b8e8610ce60f788091c51c13" - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - -statuses@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" - -toidentifier@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" - -type-is@~1.6.18: - version "1.6.18" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -unpipe@1.0.0, unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - -vary@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" diff --git a/kotlin/BUILD b/kotlin/BUILD index fe50b275d..9b7f751f1 100644 --- a/kotlin/BUILD +++ b/kotlin/BUILD @@ -46,7 +46,6 @@ release_archive( ], ) for doc in [ - "js", "jvm", "lint", "core", @@ -57,7 +56,6 @@ release_archive( genrule( name = "stardoc", srcs = [doc for doc in [ - "js", "jvm", "lint", "core", diff --git a/kotlin/compiler/compiler.bzl b/kotlin/compiler/compiler.bzl index 2c74617cd..b07322383 100644 --- a/kotlin/compiler/compiler.bzl +++ b/kotlin/compiler/compiler.bzl @@ -13,7 +13,6 @@ # limitations under the License. load("@com_github_jetbrains_kotlin//:artifacts.bzl", "KOTLINC_ARTIFACTS") -load("//kotlin:js.bzl", "kt_js_import") load("//kotlin:jvm.bzl", "kt_jvm_import") load("//kotlin/internal:defs.bzl", _KT_COMPILER_REPO = "KT_COMPILER_REPO") @@ -53,6 +52,5 @@ def kt_configure_compiler(): if native.package_name() != "kotlin/compiler": fail("kt_configure_compiler must be called in kotlin/compiler not %s" % native.package_name()) - _import_artifacts(KOTLINC_ARTIFACTS.js, kt_js_import) _import_artifacts(KOTLINC_ARTIFACTS.jvm, kt_jvm_import) _import_artifacts(KOTLINC_ARTIFACTS.core, kt_jvm_import) diff --git a/kotlin/internal/BUILD b/kotlin/internal/BUILD index 9cfa710f2..d8d8d635e 100644 --- a/kotlin/internal/BUILD +++ b/kotlin/internal/BUILD @@ -28,7 +28,6 @@ release_archive( "BUILD.release.bazel": "BUILD.bazel", }, deps = [ - "//kotlin/internal/js:pkg", "//kotlin/internal/jvm:pkg", "//kotlin/internal/lint:pkg", "//kotlin/internal/utils:pkg", @@ -40,7 +39,6 @@ bzl_library( srcs = glob(["*.bzl"]), visibility = ["//kotlin:__subpackages__"], deps = [ - "//kotlin/internal/js", "//kotlin/internal/jvm", "//kotlin/internal/lint", "//kotlin/internal/utils", diff --git a/kotlin/internal/BUILD.release.bazel b/kotlin/internal/BUILD.release.bazel index e427d942f..423b53698 100644 --- a/kotlin/internal/BUILD.release.bazel +++ b/kotlin/internal/BUILD.release.bazel @@ -22,7 +22,6 @@ bzl_library( srcs = glob(["*.bzl"]), visibility = ["//visibility:public"], deps = [ - "//kotlin/internal/js", "//kotlin/internal/jvm", "//kotlin/internal/lint", "//kotlin/internal/utils", diff --git a/kotlin/internal/defs.bzl b/kotlin/internal/defs.bzl index 7981fe438..26d8e2123 100644 --- a/kotlin/internal/defs.bzl +++ b/kotlin/internal/defs.bzl @@ -48,15 +48,6 @@ KtJvmInfo = provider( }, ) -KtJsInfo = provider( - fields = { - "js": "The primary output of the library", - "js_map": "The map file for the library", - "jar": "A jar of the library.", - "srcjar": "The jar containing the sources of the library", - }, -) - KtCompilerPluginInfo = _KtCompilerPluginInfo KspPluginInfo = _KspPluginInfo diff --git a/kotlin/internal/js/BUILD b/kotlin/internal/js/BUILD deleted file mode 100644 index 291613a5c..000000000 --- a/kotlin/internal/js/BUILD +++ /dev/null @@ -1,41 +0,0 @@ -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_python//python:defs.bzl", "py_binary") - -# Copyright 2018 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("//src/main/starlark/release:packager.bzl", "release_archive") - -# TODO(https://github.com/bazelbuild/rules_kotlin/issues/270): Replace with Starlark -py_binary( - name = "importer", - srcs = ["importer.py"], - visibility = ["//visibility:public"], -) - -release_archive( - name = "pkg", - srcs = glob([ - "*.bzl", - "*.py", - ]), - src_map = { - "BUILD.release.bazel": "BUILD.bazel", - }, -) - -bzl_library( - name = "js", - srcs = glob(["*.bzl"]), - visibility = ["//kotlin:__subpackages__"], -) diff --git a/kotlin/internal/js/BUILD.release.bazel b/kotlin/internal/js/BUILD.release.bazel deleted file mode 100644 index ff430dfc5..000000000 --- a/kotlin/internal/js/BUILD.release.bazel +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2018 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("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@rules_python//python:defs.bzl", "py_binary") - -py_binary( - name = "importer", - srcs = ["importer.py"], - visibility = ["//visibility:public"], -) - -bzl_library( - name = "js", - srcs = glob(["*.bzl"]), - visibility = ["//visibility:public"], -) diff --git a/kotlin/internal/js/impl.bzl b/kotlin/internal/js/impl.bzl deleted file mode 100644 index faf39846e..000000000 --- a/kotlin/internal/js/impl.bzl +++ /dev/null @@ -1,159 +0,0 @@ -# Copyright 2018 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/internal:defs.bzl", - _KtJsInfo = "KtJsInfo", - _TOOLCHAIN_TYPE = "TOOLCHAIN_TYPE", -) -load( - "//kotlin/internal:opts.bzl", - "KotlincOptions", - "kotlinc_options_to_flags", -) -load( - "//kotlin/internal/utils:utils.bzl", - _utils = "utils", -) - -# The following kt-js flags are currently not used. -# -Xfriend-modules= -# -output-postfix Path to file which will be added to the end of output file -# -output-prefix Path to file which will be added to the beginning of output file -# -source-map-base-dirs Base directories which are used to calculate relative paths to source files in source map -# -source-map-embed-sources { always, never, inlining } -# Embed source files into source map -# -source-map-prefix Prefix for paths in a source map -# -Xtyped-arrays - -def kt_js_library_impl(ctx): - toolchain = ctx.toolchains[_TOOLCHAIN_TYPE] - - libraries = depset([d[_KtJsInfo].jar for d in ctx.attr.deps]) - - args = _utils.init_args( - ctx, - "kt_js_library", - _utils.derive_module_name(ctx), - ) - - kotlinc_options = ctx.attr.kotlinc_opts[KotlincOptions] if ctx.attr.kotlinc_opts else toolchain.kotlinc_options - - args.add_all( - "--kotlin_js_passthrough_flags", - kotlinc_options_to_flags(kotlinc_options) + [ - "-source-map", - "-Xir-produce-klib-dir", - "-no-stdlib", - "-module-kind", - ctx.attr.module_kind, - "-target", - ctx.attr.js_target, - ], - ) - - args.add("--output", ctx.outputs.js) - args.add("--kotlin_output_js_jar", ctx.outputs.jar) - args.add("--kotlin_output_srcjar", ctx.outputs.srcjar) - args.add("--strict_kotlin_deps", "off") - args.add("--reduced_classpath_mode", "NONE") - - args.add_all("--kotlin_js_libraries", libraries, omit_if_empty = False) - args.add_all("--sources", ctx.files.srcs) - - inputs, _, input_manifests = ctx.resolve_command(tools = [toolchain.kotlinbuilder, toolchain.kotlin_home]) - - ctx.actions.run( - mnemonic = "KotlinCompile", - inputs = depset(inputs + ctx.files.srcs, transitive = [libraries]), - outputs = [ - ctx.outputs.js, - ctx.outputs.js_map, - ctx.outputs.jar, - ctx.outputs.srcjar, - ], - executable = toolchain.kotlinbuilder.files_to_run.executable, - execution_requirements = {"supports-workers": "1"}, - arguments = [args], - progress_message = "Compiling Kotlin to JS %%{label} { kt: %d }" % len(ctx.files.srcs), - input_manifests = input_manifests, - env = { - "REPOSITORY_NAME": _utils.builder_workspace_name(ctx), - }, - ) - - return [ - DefaultInfo( - files = depset([ctx.outputs.js, ctx.outputs.js_map]), - ), - _KtJsInfo( - js = ctx.outputs.js, - js_map = ctx.outputs.js_map, - jar = ctx.outputs.jar, - srcjar = ctx.outputs.srcjar, - ), - ] - -# buildifier: disable=unused-variable -def _strip_version(jarfile): - """strip version suffix if present - e.g. kotlinx-html-js-0.6.12.jar -> kotlinx-html-js.jar - """ - if not jarfile.endswith(".jar"): - fail("_strip_version expects paths ending with .jar") - segments = jarfile[:-len(".jar")].split("-") - - # Remove the last segment if all digits separated by dot - parts = segments[-1].split(".") - if len([p for p in parts if not p.isdigit()]) == 0: - segments = segments[0:-1] - return "%s.jar" % "-".join(segments) - -def kt_js_import_impl(ctx): - if len(ctx.files.jars) != 1: - fail("a single jar should be supplied, multiple jars not supported") - jar_file = ctx.files.jars[0] - - srcjar = ctx.files.srcjar[0] if len(ctx.files.srcjar) == 1 else None - - args = ctx.actions.args() - args.add("--jar", jar_file) - args.add("--import_pattern", "^[^/.]+\\.js$") - args.add("--import_out", ctx.outputs.js) - args.add("--aux_pattern", "^[^/]+\\.js\\.map$") - args.add("--aux_out", ctx.outputs.js_map) - - tools, _, input_manifest = ctx.resolve_command(tools = [ctx.attr._importer]) - ctx.actions.run( - inputs = [jar_file], - tools = tools, - executable = ctx.executable._importer, - outputs = [ - ctx.outputs.js, - ctx.outputs.js_map, - ], - arguments = [args], - input_manifests = input_manifest, - ) - - return [ - DefaultInfo( - files = depset([ctx.outputs.js, ctx.outputs.js_map]), - ), - _KtJsInfo( - js = ctx.outputs.js, - js_map = ctx.outputs.js_map, - jar = jar_file, - srcjar = srcjar, - ), - ] diff --git a/kotlin/internal/js/importer.py b/kotlin/internal/js/importer.py deleted file mode 100644 index c6d023c5e..000000000 --- a/kotlin/internal/js/importer.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2018 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. -import argparse -import os -import re -import shutil -import tempfile -import zipfile - - -def _is_jar(jar): - if not os.path.exists(jar): - raise argparse.ArgumentTypeError("jar:{0} does not exist".format(jar)) - else: - return zipfile.ZipFile(jar) - - -def _extract_root_entry(jar, filename_pattern, output_path, touch=False): - """ - Extracts a root entry from a jar. and write it to a path. - - output_path is absolute and the basename is used to extract the entry from the jar. - - :param jar: The jar from which to make the extraction. - :param filename_pattern: Regular expression to match when searching for the file in the jar. - :param output_path: An absolute file path to where the entry should be written. - :param touch: Should the file be touched if it was not found in the jar. - """ - target = None - for filename in jar.namelist(): - if filename_pattern.match(filename): - target = filename - break - - if not target: - if touch: - f = open(output_path, 'a') - f.close() - return - else: - raise FileNotFoundError("No file matching {0} was found in jar".format(filename_pattern)) - - # Extract the target file to a temporary location. - temp_dir = tempfile.gettempdir() - temp_file = os.path.join(temp_dir, os.path.basename(target)) - jar.extract(target, path=temp_dir) - - # Move the temp file into the final output location. - shutil.move(temp_file, output_path) - - -def _main(p): - args = p.parse_args() - _extract_root_entry(args.jar, args.import_pattern, args.import_out) - for (p, e) in zip(args.aux_pattern, args.aux_out): - _extract_root_entry(args.jar, p, e, touch=True) - - -parser = argparse.ArgumentParser() - -parser.add_argument("--jar", type=_is_jar, required=True) -parser.add_argument("--import_pattern", required=True, type=re.compile, - help="regular expression to match when searching the jar for the KotlinJS file") -parser.add_argument("--import_out", required=True, help="path where the extracted KotlinJS import should be stored") -parser.add_argument( - "--aux_pattern", nargs="*", type=re.compile, - help="""regular expressions to match when searching the jar for additional files""") -parser.add_argument( - "--aux_out", nargs="*", - help="""paths where additonal files from the jar should be stored, if the files do not exist these paths are touched.""") - -_main(parser) diff --git a/kotlin/internal/js/js.bzl b/kotlin/internal/js/js.bzl deleted file mode 100644 index e7a42fa70..000000000 --- a/kotlin/internal/js/js.bzl +++ /dev/null @@ -1,165 +0,0 @@ -# Copyright 2018 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/internal:defs.bzl", - _KT_COMPILER_REPO = "KT_COMPILER_REPO", - _KtJsInfo = "KtJsInfo", - _TOOLCHAIN_TYPE = "TOOLCHAIN_TYPE", -) -load( - "//kotlin/internal:opts.bzl", - _KotlincOptions = "KotlincOptions", -) -load( - "//kotlin/internal/js:impl.bzl", - _kt_js_import_impl = "kt_js_import_impl", - _kt_js_library_impl = "kt_js_library_impl", -) - -_JS_STDLIB_MAP = { - "kotlin-stdlib-js": "kotlin", - "kotlin-test-js": "kotlin-test", -} - -# The macro, and the ones using it exist to ensure compatibility with the nodejs rules, the nodejs rules process the -# attributes and not the providers. Ideally providers would be used so the rules can pass the information along without -# having to have user facing attributes visible. -# module_root: if the module_root is made settable then there is a possibility of collisions. Keeping it simple here. -# module_name: The require statement generated by Kotlinc-js seems to be based on the name of the jar. Unlike the jvm -# compiler, there is no 'module-name' flag available. So to keep things simple it's hard coded to the module name. -def _lock_attrs(name, kwargs): - if native.repository_name().startswith("@") and native.repository_name().endswith(_KT_COMPILER_REPO): - name = _JS_STDLIB_MAP.get(name, name) - if kwargs.get("module_root") != None: - fail("The module_root is an internal attribute.") - else: - kwargs["module_root"] = name + ".js" - if kwargs.get("module_name") != None: - fail("module_name is an internal attribute.") - else: - kwargs["module_name"] = name - return kwargs - -kt_js_library = rule( - attrs = { - "srcs": attr.label_list( - allow_empty = False, - allow_files = [".kt"], - mandatory = True, - ), - "data": attr.label_list( - allow_files = True, - default = [], - ), - "deps": attr.label_list( - doc = """A list of other kotlin JS libraries.""", - default = [], - allow_empty = True, - providers = [_KtJsInfo], - ), - "runtime_deps": attr.label_list( - doc = """A list of other kotlin JS libraries that should be available at runtime.""", - default = [], - allow_empty = True, - providers = [_KtJsInfo], - ), - "module_kind": attr.string( - doc = """The Kind of a module generated by compiler, users should stick to commonjs.""", - default = "commonjs", - values = ["umd", "commonjs", "amd", "plain"], - ), - "js_target": attr.string( - default = "v5", - values = ["v5"], - ), - "module_root": attr.string( - doc = "internal attriubte", - mandatory = False, - ), - "module_name": attr.string( - doc = "internal attribute", - mandatory = False, - ), - "kotlinc_opts": attr.label( - doc = """Kotlinc options to be used when compiling this target. These opts if provided - will be used instead of the ones provided to the toolchain.""", - default = None, - providers = [_KotlincOptions], - mandatory = False, - ), - "_toolchain": attr.label( - doc = """The Kotlin JS Runtime.""", - default = Label("//kotlin/compiler:kotlin-stdlib-js"), - cfg = "target", - ), - }, - implementation = _kt_js_library_impl, - outputs = dict( - js = "%{name}.js", - js_map = "%{name}.js.map", - jar = "%{name}.jar", - srcjar = "%{name}-sources.jar", - ), - toolchains = [_TOOLCHAIN_TYPE], - provides = [_KtJsInfo], -) - -def kt_js_library_macro(name, **kwargs): - kwargs = _lock_attrs(name, kwargs) - - # TODO this is a runtime dep, it should be picked up from the _toolchain attr or from a provider. - kwargs["deps"] = kwargs.get("deps", []) + ["@rules_kotlin//kotlin/compiler:kotlin-stdlib-js"] - kt_js_library(name = name, **kwargs) - -kt_js_import = rule( - attrs = { - "jars": attr.label_list( - allow_files = [".jar"], - mandatory = True, - ), - "srcjar": attr.label( - mandatory = False, - allow_single_file = ["-sources.jar"], - ), - "runtime_deps": attr.label_list( - default = [], - allow_files = [".jar"], - mandatory = False, - ), - "module_name": attr.string( - doc = "internal attribute", - mandatory = False, - ), - "module_root": attr.string( - doc = "internal attriubte", - mandatory = False, - ), - "_importer": attr.label( - default = Label("//kotlin/internal/js:importer"), - allow_files = True, - executable = True, - cfg = "exec", - ), - }, - outputs = dict( - js = "%{module_name}.js", - js_map = "%{module_name}.js.map", - ), - implementation = _kt_js_import_impl, - provides = [_KtJsInfo], -) - -def kt_js_import_macro(name, **kwargs): - kwargs = _lock_attrs(name, kwargs) - kt_js_import(name = name, **kwargs) diff --git a/kotlin/internal/toolchains.bzl b/kotlin/internal/toolchains.bzl index 0f455eb41..ce93cea89 100644 --- a/kotlin/internal/toolchains.bzl +++ b/kotlin/internal/toolchains.bzl @@ -3,7 +3,6 @@ load("@rules_java//java:defs.bzl", "JavaInfo", "java_common") load( "//kotlin/internal:defs.bzl", _KT_COMPILER_REPO = "KT_COMPILER_REPO", - _KtJsInfo = "KtJsInfo", _TOOLCHAIN_TYPE = "TOOLCHAIN_TYPE", ) @@ -78,7 +77,6 @@ def _kotlin_toolchain_impl(ctx): kotlin_home = ctx.attr.kotlin_home, jvm_stdlibs = java_common.merge(compile_time_providers + runtime_providers), jvm_emit_jdeps = ctx.attr._jvm_emit_jdeps[BuildSettingInfo].value, - js_stdlibs = ctx.attr.js_stdlibs, execution_requirements = { "supports-workers": "1", "supports-multiplex-workers": "1" if ctx.attr.experimental_multiplex_workers else "0", @@ -202,16 +200,6 @@ _kt_toolchain = rule( "21", ], ), - "js_target": attr.string( - default = "v5", - values = ["v5"], - ), - "js_stdlibs": attr.label_list( - default = [ - Label("//kotlin/compiler:kotlin-stdlib-js"), - ], - providers = [_KtJsInfo], - ), "experimental_multiplex_workers": attr.bool( doc = """Run workers in multiplex mode.""", default = False, diff --git a/kotlin/js.bzl b/kotlin/js.bzl deleted file mode 100644 index 2e454a20e..000000000 --- a/kotlin/js.bzl +++ /dev/null @@ -1,8 +0,0 @@ -load( - "//kotlin/internal/js:js.bzl", - _kt_js_import = "kt_js_import_macro", - _kt_js_library = "kt_js_library_macro", -) - -kt_js_import = _kt_js_import -kt_js_library = _kt_js_library diff --git a/kotlin/kotlin.bzl b/kotlin/kotlin.bzl index 4eb3c8d1f..cba5b1687 100644 --- a/kotlin/kotlin.bzl +++ b/kotlin/kotlin.bzl @@ -24,11 +24,6 @@ load( _kt_ksp_plugin = "kt_ksp_plugin", _kt_register_toolchains = "kt_register_toolchains", ) -load( - ":js.bzl", - _kt_js_import = "kt_js_import", - _kt_js_library = "kt_js_library", -) load( ":jvm.bzl", _kt_jvm_binary = "kt_jvm_binary", @@ -56,26 +51,6 @@ def kt_kotlinc_options(**kwargs): def kt_javac_options(**kwargs): fail("use load('//kotlin:core.bzl', kt_javac_options)") -def kt_js_library(**kwargs): - """ - Forwarding macro for kt_js_library - - Deprecated: - kt_js_library should be loaded from //kotlin:js.bzl - """ - print("kt_js_library should be loaded from //kotlin:js.bzl") - _kt_js_library(**kwargs) - -def kt_js_import(**kwargs): - """ - Forwarding macro for kt_js_import - - Deprecated: - kt_js_import should be loaded from //kotlin:js.bzl - """ - print("kt_js_import should be loaded from //kotlin:js.bzl") - _kt_js_import(**kwargs) - def kt_jvm_binary(**kwargs): """ Forwarding macro for kt_jvm_binary diff --git a/src/main/kotlin/io/bazel/kotlin/builder/KotlinBuilderComponent.java b/src/main/kotlin/io/bazel/kotlin/builder/KotlinBuilderComponent.java index d9da55e95..9cda68bd8 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/KotlinBuilderComponent.java +++ b/src/main/kotlin/io/bazel/kotlin/builder/KotlinBuilderComponent.java @@ -20,7 +20,6 @@ import dagger.Component; import dagger.Provides; import io.bazel.kotlin.builder.tasks.CompileKotlin; -import io.bazel.kotlin.builder.tasks.js.Kotlin2JsTaskExecutor; import io.bazel.kotlin.builder.tasks.jvm.InternalCompilerPlugins; import io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor; import io.bazel.kotlin.builder.toolchain.KotlinToolchain; @@ -34,8 +33,6 @@ public interface KotlinBuilderComponent { KotlinJvmTaskExecutor jvmTaskExecutor(); - Kotlin2JsTaskExecutor jsTaskExecutor(); - CompileKotlin work(); @Component.Builder diff --git a/src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt index d94cd4e3c..ea1c03797 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt +++ b/src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt @@ -16,7 +16,6 @@ */ package io.bazel.kotlin.builder.tasks -import io.bazel.kotlin.builder.tasks.js.Kotlin2JsTaskExecutor import io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor import io.bazel.kotlin.builder.toolchain.CompilationStatusException import io.bazel.kotlin.builder.toolchain.CompilationTaskContext @@ -26,7 +25,6 @@ import io.bazel.kotlin.builder.utils.Flag import io.bazel.kotlin.builder.utils.partitionJvmSources import io.bazel.kotlin.builder.utils.resolveNewDirectories import io.bazel.kotlin.model.CompilationTaskInfo -import io.bazel.kotlin.model.JsCompilationTask import io.bazel.kotlin.model.JvmCompilationTask import io.bazel.kotlin.model.Platform import io.bazel.kotlin.model.RuleKind @@ -45,7 +43,6 @@ class KotlinBuilder @Inject internal constructor( private val jvmTaskExecutor: KotlinJvmTaskExecutor, - private val jsTaskExecutor: Kotlin2JsTaskExecutor, ) { companion object { @JvmStatic @@ -77,9 +74,6 @@ class KotlinBuilder GENERATED_CLASSDIR("--kotlin_generated_classdir"), FRIEND_PATHS("--kotlin_friend_paths"), OUTPUT_JDEPS("--kotlin_output_jdeps"), - OUTPUT_JS_JAR("--kotlin_output_js_jar"), - JS_PASSTHROUGH_FLAGS("--kotlin_js_passthrough_flags"), - JS_LIBRARIES("--kotlin_js_libraries"), DEBUG("--kotlin_debug_tags"), TASK_ID("--kotlin_task_id"), ABI_JAR("--abi_jar"), @@ -105,7 +99,6 @@ class KotlinBuilder @Suppress("WHEN_ENUM_CAN_BE_NULL_IN_JAVA") when (compileContext.info.platform) { Platform.JVM -> executeJvmTask(compileContext, taskContext.directory, argMap) - Platform.JS -> executeJsTask(compileContext, taskContext.directory, argMap) Platform.UNRECOGNIZED -> throw IllegalStateException( "unrecognized platform: ${compileContext.info}", ) @@ -171,40 +164,6 @@ class KotlinBuilder this } - private fun executeJsTask( - context: CompilationTaskContext, - workingDir: Path, - argMap: ArgMap, - ) = buildJsTask(context.info, workingDir, argMap).let { jsTask -> - context.whenTracing { printProto("js task input", jsTask) } - jsTaskExecutor.execute(context, jsTask) - } - - private fun buildJsTask( - info: CompilationTaskInfo, - workingDir: Path, - argMap: ArgMap, - ): JsCompilationTask = - with(JsCompilationTask.newBuilder()) { - this.info = info - - with(directoriesBuilder) { - temp = workingDir.toString() - } - - with(inputsBuilder) { - addAllLibraries(argMap.mandatory(KotlinBuilderFlags.JS_LIBRARIES)) - addAllKotlinSources(argMap.mandatory(KotlinBuilderFlags.SOURCES)) - } - with(outputsBuilder) { - js = argMap.mandatorySingle(KotlinBuilderFlags.OUTPUT) - jar = argMap.mandatorySingle(KotlinBuilderFlags.OUTPUT_JS_JAR) - srcjar = argMap.mandatorySingle(KotlinBuilderFlags.OUTPUT_SRCJAR) - } - addAllPassThroughFlags(argMap.mandatory(KotlinBuilderFlags.JS_PASSTHROUGH_FLAGS)) - build() - } - private fun executeJvmTask( context: CompilationTaskContext, workingDir: Path, diff --git a/src/main/kotlin/io/bazel/kotlin/builder/tasks/js/Kotlin2JsTaskExecutor.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/js/Kotlin2JsTaskExecutor.kt deleted file mode 100644 index b9ded3357..000000000 --- a/src/main/kotlin/io/bazel/kotlin/builder/tasks/js/Kotlin2JsTaskExecutor.kt +++ /dev/null @@ -1,105 +0,0 @@ -package io.bazel.kotlin.builder.tasks.js - -import io.bazel.kotlin.builder.toolchain.CompilationException -import io.bazel.kotlin.builder.toolchain.CompilationTaskContext -import io.bazel.kotlin.builder.toolchain.KotlinToolchain -import io.bazel.kotlin.builder.utils.addAll -import io.bazel.kotlin.builder.utils.jars.JarCreator -import io.bazel.kotlin.builder.utils.jars.SourceJarCreator -import io.bazel.kotlin.model.JsCompilationTask -import java.nio.file.FileSystem -import java.nio.file.FileSystems -import java.nio.file.Files -import java.nio.file.Path -import java.util.stream.Collectors -import javax.inject.Inject -import javax.inject.Singleton -import kotlin.io.path.absolute -import kotlin.io.path.absolutePathString -import kotlin.io.path.nameWithoutExtension - -@Singleton -class Kotlin2JsTaskExecutor - @Inject - constructor( - private val invoker: KotlinToolchain.K2JSCompilerInvoker, - ) { - private val fileSystem: FileSystem = FileSystems.getDefault() - - fun execute( - context: CompilationTaskContext, - task: JsCompilationTask, - ) { - val outputDirectory = task.compile(context) - task.createJar(outputDirectory) - task.createSourceJar() - } - - private fun JsCompilationTask.compile(context: CompilationTaskContext): Path { - val jsOut = fileSystem.getPath(outputs.js) - val outputDirectory = jsOut.parent - val baseName = jsOut.fileName.nameWithoutExtension - val mapOut = outputDirectory.resolve("$baseName.js.map") - val workingDirectory = fileSystem.getPath(directories.temp) - - val execRoot = fileSystem.getPath(".").absolute() - - val args = - mutableListOf().apply { - addAll(passThroughFlagsList) - add("-Xdisable-default-scripting-plugin") - add("-Xir-produce-js") - add("-progressive") - add("-Xoptimize-generated-js=false") - addAll( - "-libraries", - inputs.librariesList - .map { - execRoot - .resolve( - it, - ).absolutePathString() - }.joinToString(":"), - ) - addAll("-ir-output-name", baseName) - addAll("-ir-output-dir", workingDirectory.toString()) - addAll("-Xir-module-name=${info.moduleName}") - addAll(inputs.kotlinSourcesList.map { execRoot.resolve(it).absolutePathString() }) - } - - context.whenTracing { printLines("js compile args", args) } - context.executeCompilerTask(args, invoker::compile) - context.whenTracing { - printLines( - "outputs", - Files.walk(outputDirectory).map { p -> p.toString() }.collect(Collectors.toList()), - ) - } - Files.copy(workingDirectory.resolve(jsOut.fileName), jsOut) - Files.copy(workingDirectory.resolve(mapOut.fileName), mapOut) - - return workingDirectory - } - - private fun JsCompilationTask.createSourceJar() { - try { - SourceJarCreator(fileSystem.getPath(outputs.srcjar), false) - .also { creator -> - creator.addSources(inputs.kotlinSourcesList.map { fileSystem.getPath(it) }.stream()) - }.execute() - } catch (ex: Throwable) { - throw CompilationException("could not create source jar", ex) - } - } - - private fun JsCompilationTask.createJar(jsDirectoryPath: Path) { - try { - JarCreator(fileSystem.getPath(outputs.jar)).use { creator -> - creator.addDirectory(jsDirectoryPath) - creator.execute() - } - } catch (ex: Throwable) { - throw CompilationException("error creating js jar", ex) - } - } - } diff --git a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt index f8763b744..b1e07f733 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt +++ b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt @@ -25,7 +25,7 @@ import javax.inject.Singleton /** * Due to an inconsistency in the handling of -Xfriends-path, jvm uses a comma (property list - * separator), js uses the system path separator. + * separator) */ const val X_FRIENDS_PATH_SEPARATOR = "," diff --git a/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt b/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt index 291377d16..5f0d0f1af 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt +++ b/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt @@ -274,14 +274,4 @@ class KotlinToolchain private constructor( toolchain.toolchainWithReflect(), "io.bazel.kotlin.compiler.BazelK2JVMCompiler", ) - - @Singleton - class K2JSCompilerInvoker - @Inject - constructor( - toolchain: KotlinToolchain, - ) : KotlinCliToolInvoker( - toolchain.toolchainWithReflect(), - "org.jetbrains.kotlin.cli.js.K2JsIrCompiler", - ) } diff --git a/src/main/protobuf/kotlin_model.proto b/src/main/protobuf/kotlin_model.proto index 2a3b5146b..3fb6ca2da 100644 --- a/src/main/protobuf/kotlin_model.proto +++ b/src/main/protobuf/kotlin_model.proto @@ -54,7 +54,6 @@ enum RuleKind { enum Platform { JVM = 0; - JS = 1; } // Common info about a Kotlin compilation task, this message is shared by all compilation tasks. @@ -167,34 +166,3 @@ message JvmCompilationTask { bool compile_kotlin = 6; bool instrument_coverage = 7; } - -message JsCompilationTask { - - // Directories used by the builder. - message Directories { - // A temp directory that the compiler may use. - string temp = 4; - } - - message Outputs { - // The primary output - string js = 1; - string jar = 3; - string srcjar = 4; - } - - message Inputs { - repeated string libraries = 1; - // Partitioned from the builder flags, expanding the source_jars. - repeated string kotlin_sources = 2; - } - - CompilationTaskInfo info = 1; - Outputs outputs = 3; - Inputs inputs = 4; - - // flags that should be passed through straight to the kotlinc-js compiler. - repeated string pass_through_flags = 5; - - Directories directories = 6; -} diff --git a/src/main/starlark/core/repositories/download.bzl b/src/main/starlark/core/repositories/download.bzl index 29e8b6bd7..0a5b3f312 100644 --- a/src/main/starlark/core/repositories/download.bzl +++ b/src/main/starlark/core/repositories/download.bzl @@ -51,13 +51,6 @@ def kt_download_local_dev_dependencies(): urls = versions.RBE.URLS, ) - maybe( - http_archive, - name = "build_bazel_rules_nodejs", - sha256 = versions.RULES_NODEJS_SHA, - url = "https://github.com/bazelbuild/rules_nodejs/releases/download/{0}/rules_nodejs-{0}.tar.gz".format(versions.RULES_NODEJS_VERSION), - ) - maybe( http_archive, name = "rules_jvm_external", diff --git a/src/main/starlark/core/repositories/kotlin/artifacts.bzl b/src/main/starlark/core/repositories/kotlin/artifacts.bzl index b541aaecb..3e6b4af52 100644 --- a/src/main/starlark/core/repositories/kotlin/artifacts.bzl +++ b/src/main/starlark/core/repositories/kotlin/artifacts.bzl @@ -1,17 +1,6 @@ """A map of label to artifacts made available by the kotlinc github repo""" KOTLINC_ARTIFACTS = struct( - js = struct( - plugin = {}, - runtime = { - "kotlin-stdlib-js": "lib/kotlin-stdlib-js.jar", - "kotlin-stdlib-js-klib": "lib/kotlin-stdlib-js.klib", - "kotlin-stdlib-js-sources": "lib/kotlin-stdlib-js-sources.jar", - "kotlin-test-js": "lib/kotlin-test-js.jar", - "kotlin-test-js-sources": "lib/kotlin-test-js-sources.jar", - }, - compile = {}, - ), jvm = struct( plugin = { "allopen-compiler-plugin": "lib/allopen-compiler-plugin.jar", @@ -57,7 +46,6 @@ KOTLINC_ARTIFACTS = struct( "android-extensions-compiler": "lib/android-extensions-compiler.jar", "android-extensions-runtime": "lib/android-extensions-runtime.jar", "annotations": "lib/annotations-13_0.jar", - "js_engines": "lib/js_engines.jar", "kotlin-annotation-processing": "lib/kotlin-annotation-processing.jar", "kotlin-annotation-processing-cli": "lib/kotlin-annotation-processing-cli.jar", "kotlin-annotation-processing-compiler": "lib/kotlin-annotation-processing-compiler.jar", @@ -83,7 +71,7 @@ KOTLINC_ARTIFACTS = struct( KOTLINC_ARTIFACT_LIST = { label: file - for lang in ["js", "jvm", "core"] + for lang in ["jvm", "core"] for type in ["compile", "plugin", "runtime"] for (label, file) in getattr(getattr(KOTLINC_ARTIFACTS, lang), type).items() } diff --git a/src/main/starlark/core/repositories/versions.bzl b/src/main/starlark/core/repositories/versions.bzl index d095b271f..88c8b0864 100644 --- a/src/main/starlark/core/repositories/versions.bzl +++ b/src/main/starlark/core/repositories/versions.bzl @@ -20,8 +20,6 @@ def _use_repository(name, version, rule, **kwargs): maybe(rule, name = name, **http_archive_arguments) versions = struct( - RULES_NODEJS_VERSION = "5.5.3", - RULES_NODEJS_SHA = "f10a3a12894fc3c9bf578ee5a5691769f6805c4be84359681a785a0c12e8d2b6", BAZEL_TOOLCHAINS_VERSION = "4.1.0", BAZEL_TOOLCHAINS_SHA = "179ec02f809e86abf56356d8898c8bd74069f1bd7c56044050c2cd3d79d0e024", # IMPORTANT! rules_kotlin does not use the bazel_skylib unittest in production diff --git a/src/test/kotlin/io/bazel/kotlin/builder/BUILD b/src/test/kotlin/io/bazel/kotlin/builder/BUILD index 5f6505d1d..010f6a407 100644 --- a/src/test/kotlin/io/bazel/kotlin/builder/BUILD +++ b/src/test/kotlin/io/bazel/kotlin/builder/BUILD @@ -36,7 +36,6 @@ java_library( "JdepsMergerTestComponent.java", "KotlinAbstractTestBuilder.java", "KotlinBuilderTestComponent.java", - "KotlinJsTestBuilder.java", "KotlinJvmTestBuilder.java", ], data = [ diff --git a/src/test/kotlin/io/bazel/kotlin/builder/KotlinBuilderTestComponent.java b/src/test/kotlin/io/bazel/kotlin/builder/KotlinBuilderTestComponent.java index f1425e7ea..d13570e0d 100644 --- a/src/test/kotlin/io/bazel/kotlin/builder/KotlinBuilderTestComponent.java +++ b/src/test/kotlin/io/bazel/kotlin/builder/KotlinBuilderTestComponent.java @@ -20,7 +20,6 @@ import dagger.BindsInstance; import dagger.Component; import io.bazel.kotlin.builder.tasks.KotlinBuilder; -import io.bazel.kotlin.builder.tasks.js.Kotlin2JsTaskExecutor; import io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor; import io.bazel.kotlin.builder.toolchain.KotlinToolchain; @@ -36,8 +35,6 @@ public interface KotlinBuilderTestComponent { KotlinJvmTaskExecutor jvmTaskExecutor(); - Kotlin2JsTaskExecutor jsTaskExecutor(); - @Component.Builder interface Builder { @BindsInstance diff --git a/src/test/kotlin/io/bazel/kotlin/builder/KotlinJsTestBuilder.java b/src/test/kotlin/io/bazel/kotlin/builder/KotlinJsTestBuilder.java deleted file mode 100644 index 35315cef1..000000000 --- a/src/test/kotlin/io/bazel/kotlin/builder/KotlinJsTestBuilder.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2018 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. - */ -package io.bazel.kotlin.builder; - -import io.bazel.kotlin.builder.toolchain.KotlinToolchain; -import io.bazel.kotlin.model.CompilationTaskInfo; -import io.bazel.kotlin.model.JsCompilationTask; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.List; -import java.util.function.Consumer; - -public final class KotlinJsTestBuilder extends KotlinAbstractTestBuilder { - private static final List PASSTHROUGH_FLAGS = - Arrays.asList("-source-map", "-module-kind", "commonjs", "-target", "v5", "-Xir-produce-klib-dir"); - private static final JsCompilationTask.Builder taskBuilder = JsCompilationTask.newBuilder(); - private static final KotlinBuilderComponent component = - DaggerKotlinBuilderComponent.builder().toolchain(withReflect(toolchainForTest())).build(); - private static final EnumSet ALL_DIRECTORY_TYPES = - EnumSet.allOf(DirectoryType.class); - private final TaskBuilder taskBuilderInstance = new TaskBuilder(); - - private static KotlinToolchain withReflect(KotlinToolchain toolchain) { - return toolchain.toolchainWithReflect( - new File(Deps.Dep.fromLabel("@rules_kotlin//kotlin/compiler:kotlin-reflect").singleCompileJar()) - ); - } - - @Override - JsCompilationTask buildTask() { - return taskBuilder.build(); - } - - @Override - void setupForNext(CompilationTaskInfo.Builder infoBuilder) { - taskBuilder.clear().setInfo(infoBuilder); - DirectoryType.createAll(instanceRoot(), ALL_DIRECTORY_TYPES); - taskBuilder.addAllPassThroughFlags(PASSTHROUGH_FLAGS); - try { - taskBuilder.getDirectoriesBuilder().setTemp( - Files.createDirectories(directory(DirectoryType.TEMP).resolve("working")).toString()); - } catch (IOException e) { - throw new RuntimeException(e); - } - taskBuilder - .getOutputsBuilder() - .setJar(directory(DirectoryType.TEMP).resolve(label() + ".jar").toAbsolutePath().toString()) - .setSrcjar(directory(DirectoryType.TEMP).resolve(label() + "-sources.jar").toAbsolutePath().toString()) - .setJs(directory(DirectoryType.TEMP).resolve(label() + ".js").toAbsolutePath().toString()); - } - - public String runCompilationTask(Consumer setup, Consumer> outlines) { - resetForNext(); - setup.accept(taskBuilderInstance); - try { - return runCompileTask( - (taskContext, task) -> { - component.jsTaskExecutor().execute(taskContext, task); - String jsFile = task.getOutputs().getJs(); - assertFilesExist( - jsFile, - jsFile + ".map", - task.getOutputs().getJar(), - task.getOutputs().getSrcjar()); - return task.getOutputs().getJar(); - }); - } finally{ - outlines.accept(outLines()); - } - } - - public void runCompilationTask(Consumer setup) { - runCompilationTask(setup, l -> {}); - } - - public final class TaskBuilder { - public void addSource(String filename, String... lines) { - taskBuilder.getInputsBuilder().addKotlinSources(writeSourceFile(filename, lines).toString()); - } - - public void addDependency(String filename) { - taskBuilder.getInputsBuilder().addLibraries(filename); - } - - public void addArg(String flag) { - taskBuilder.addPassThroughFlags(flag ); - } - } -} diff --git a/src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel b/src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel index be9f0cb8b..cddfd4b0a 100644 --- a/src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel +++ b/src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel @@ -99,14 +99,6 @@ kt_rules_test( ], ) -kt_rules_test( - name = "KotlinBuilderJsTest", - srcs = ["js/KotlinBuilderJsTest.java"], - data = [ - "//kotlin/compiler:kotlin-stdlib-js-klib", - ], -) - kt_rules_test( name = "KotlinJvmTaskExecutorTest", srcs = ["jvm/KotlinJvmTaskExecutorTest.kt"], @@ -122,7 +114,6 @@ test_suite( tests = [ ":JdepsMergerTest", ":JdepsParserTest", - ":KotlinBuilderJsTest", ":KotlinBuilderJvmAbiTest", ":KotlinBuilderJvmBasicTest", ":KotlinBuilderJvmCoverageTest", diff --git a/src/test/kotlin/io/bazel/kotlin/builder/tasks/js/KotlinBuilderJsTest.java b/src/test/kotlin/io/bazel/kotlin/builder/tasks/js/KotlinBuilderJsTest.java deleted file mode 100644 index 0a34a04a8..000000000 --- a/src/test/kotlin/io/bazel/kotlin/builder/tasks/js/KotlinBuilderJsTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package io.bazel.kotlin.builder.tasks.js; - -import io.bazel.kotlin.builder.Deps.Dep; -import io.bazel.kotlin.builder.KotlinJsTestBuilder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import static com.google.common.truth.Truth.assertThat; - -@RunWith(JUnit4.class) -public class KotlinBuilderJsTest { - private static final KotlinJsTestBuilder builder = new KotlinJsTestBuilder(); - - private Dep stdLib = Dep.fromLabel("//kotlin/compiler:kotlin-stdlib-js-klib"); - - @Test - public void testSimpleJsCompile() { - builder.runCompilationTask( - it -> { - it.addDependency(stdLib.singleCompileJar()); - it.addArg("-Xreport-output-files"); - it.addArg("-Xreport-perf"); - it.addArg("-verbose"); - it.addSource( - "AClass.kt", - "package something", - "class AClass{", - " fun foo() : String {", - " return \"bar\"", - " }", - "}"); - }, - lines -> { - lines.forEach(System.out::println); - }); - } - - @Test - public void testFuncJsCompile() { - - builder.runCompilationTask( - it -> { - it.addDependency(stdLib.singleCompileJar()); - it.addArg("-Xreport-output-files"); - it.addArg("-Xreport-perf"); - it.addArg("-verbose"); - it.addSource( - "auth/Auth.kt", - "package express.something", - "fun isAuthenticated(user: String): Boolean {", - " return user != \"bob\"", - "}"); - }, - lines -> { - lines.forEach(System.out::println); - }); - } - - @Test - public void testJsErrorRendering() { - builder.runFailingCompileTaskAndValidateOutput( - () -> - builder.runCompilationTask( - it -> { - it.addSource("AClass.kt", "package something", "class AClass{"); - it.addDependency(stdLib.singleCompileJar()); - }), - lines -> - assertThat(lines) - .contains("sources/AClass.kt:2:14: error: missing '}")); - } -}