Skip to content

Commit

Permalink
Fix js test and format capabilities
Browse files Browse the repository at this point in the history
Of interesting note, I discovered the K2JsIrCompiler class that looks like it replaces the K2JSCompiler. At least, it gives better error messages.
  • Loading branch information
restingbull committed Jun 4, 2024
1 parent 24e2aa7 commit 04e6c58
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
14 changes: 11 additions & 3 deletions kotlin/compiler/compiler.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_java//java:defs.bzl", "java_import")
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")
load("@com_github_jetbrains_kotlin//:artifacts.bzl", "KOTLINC_ARTIFACTS")

def _import_artifacts(artifacts, rule_kind):
_import_labels(artifacts.plugin, rule_kind)
_import_labels(artifacts.runtime, rule_kind)
_import_labels(artifacts.compile, rule_kind, neverlink = 1)

def _import_labels(labels, rule_kind, **rule_args):
for label in labels:
for (label, file) in labels.items():
if not file.endswith(".jar"):
native.filegroup(
name = label,
srcs = [
"@%s//:%s" % (_KT_COMPILER_REPO, label),
],
)
return

if "-sources" in label:
continue
args = dict(rule_args.items())
Expand Down
4 changes: 0 additions & 4 deletions kotlin/internal/js/js.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ kt_js_import = rule(
cfg = "exec",
),
},
outputs = dict(
js = "%{module_name}.js",
js_map = "%{module_name}.js.map",
),
implementation = _kt_js_import_impl,
provides = [_KtJsInfo],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.jetbrains.kotlin.preloading.ClassPreloadingUtils
import org.jetbrains.kotlin.preloading.Preloader
import java.io.File
import java.io.PrintStream
import java.lang.ClassLoader
import java.lang.reflect.Method
import java.nio.file.FileSystems
import java.nio.file.Path
Expand Down Expand Up @@ -259,6 +258,6 @@ class KotlinToolchain private constructor(
toolchain: KotlinToolchain,
) : KotlinCliToolInvoker(
toolchain.toolchainWithReflect(),
"org.jetbrains.kotlin.cli.js.K2JSCompiler",
"org.jetbrains.kotlin.cli.js.K2JsIrCompiler",
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
# 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(default_visibility = ["//visibility:public"])

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(":artifacts.bzl", "KOTLINC_ARTIFACT_LIST")

package(default_visibility = ["//visibility:public"])

bzl_library(
name = "capabilities",
srcs = glob(["*.bzl"]),
Expand Down
1 change: 1 addition & 0 deletions src/main/starlark/core/repositories/kotlin/artifacts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ KOTLINC_ARTIFACTS = 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",
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ kt_rules_test(
name = "KotlinBuilderJsTest",
srcs = ["js/KotlinBuilderJsTest.java"],
data = [
"//kotlin/compiler:kotlin-stdlib-js.js",
"//kotlin/compiler:kotlin-stdlib-js-klib",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class KotlinBuilderJsTest {
private static final KotlinJsTestBuilder builder = new KotlinJsTestBuilder();

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

@Test
public void testSimpleJsCompile() {
Expand Down

0 comments on commit 04e6c58

Please sign in to comment.