编译 Kotlin-JS IR 使用 kotlinc 命令行时没有输出。

huangapple go评论66阅读模式
英文:

No output when compiling kotlin-js IR using kotlinc cli

问题

我正在尝试使用 kotlinc-js 编译一个 Kotlin 文件 test.kt

fun main() {
    println("Hello world!")
    val a = add(7, 22)
    println("Added to get $a")
}

fun add(x: Int, y: Int): Int {
    val z = x + y
    println(z)
    println("Hello $y")
    return z
}

我从 GitHub 下载了 kotlinc 压缩文件,经过一些错误修复,最终到达了这里:

kotlinc/bin/kotlinc-js -Xir-produce-js -libraries ".\kotlinc\lib\kotlin-stdlib-js.jar" -ir-output-dir build -ir-output-name test.js test.kt

这似乎是成功的,具有以下输出:

info: produce executable: build
info: cache directory: null
info: executable production duration: 3740ms

它创建了一个 build 目录,但里面没有文件。我无法从这里弄清楚接下来该做什么。

我尝试添加更多的库,像这样:

kotlinc/bin/kotlinc-js -Xir-produce-js -libraries ".\kotlinc\lib\kotlin-stdlib-js.jar;.\kotlinc\lib\kotlin-stdlib.jar" -ir-output-dir build -ir-output-name test.js test.kt

但第一个库之后的任何库都会出现以下错误:

error: source entry is not a Kotlin file

我找到了一个 YouTrack 问题,详细描述了我最初遇到的类似问题(这就是我使用的当前命令的来源),但我不知道从这里该怎么继续。

我在 Windows 11 上使用 PowerShell 7.3.4,并且使用 Kotlin 1.8.22。

英文:

I'm trying to compile a kotlin file test.kt using kotlinc-js:

fun main() {
    println("Hello world!")
    val a = add(7, 22)
    println("Added to get $a")
}

fun add(x: Int, y: Int): Int {
    val z = x + y
    println(z)
    println("Hello $y")
    return z
}

I downloaded the kotlinc zip file from github, worked through some errors, and eventually arrived here:

kotlinc/bin/kotlinc-js -Xir-produce-js -libraries ".\kotlinc\lib\kotlin-stdlib-js.jar" -ir-output-dir build -ir-output-name test.js test.kt

This seems to be successful with this output:

info: produce executable: build
info: cache directory: null
info: executable production duration: 3740ms

It creates the build directory, but there are no files within it. I can't figure out what to do from here.

I've tried adding more libraries like so:

kotlinc/bin/kotlinc-js -Xir-produce-js -libraries ".\kotlinc\lib\kotlin-stdlib-js.jar;.\kotlinc\lib\kotlin-stdlib.jar" -ir-output-dir build -ir-output-name test.js test.kt

But any library after the first one gives the following error:

error: source entry is not a Kotlin file

I found a YouTrack issue which detailed similar problems to those I was having initially (which is how I came up with the command I am using right now), but I don't know how to continue from here.

I am using Kotlin 1.8.22 in PowerShell 7.3.4 on Windows 11

答案1

得分: 1

我遇到了相同的问题,测试了许多标志组合,直到我发现它只有在使用**-ir-output-dir标志的绝对路径**时才有效。我想知道当这个路径是相对路径时输出会去哪里。

英文:

I ran into the same problem and tested many flags combinations until I discovered that it works with absolute path for -ir-output-dir flag. I wonder where the output go when this path is relative.

huangapple
  • 本文由 发表于 2023年6月25日 23:58:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76551274.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定