[JS IR] Use short klib names instead of absolute paths
This commit is contained in:
@@ -104,12 +104,14 @@ fun main(args: Array<String>) {
|
|||||||
var outputPath: String? = null
|
var outputPath: String? = null
|
||||||
val dependencies = mutableListOf<String>()
|
val dependencies = mutableListOf<String>()
|
||||||
val commonSources = mutableListOf<String>()
|
val commonSources = mutableListOf<String>()
|
||||||
|
var moduleName: String? = null
|
||||||
|
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < args.size) {
|
while (index < args.size) {
|
||||||
val arg = args[index++]
|
val arg = args[index++]
|
||||||
|
|
||||||
when (arg) {
|
when (arg) {
|
||||||
|
"-n" -> moduleName = args[index++]
|
||||||
"-o" -> outputPath = args[index++]
|
"-o" -> outputPath = args[index++]
|
||||||
"-d" -> dependencies += args[index++]
|
"-d" -> dependencies += args[index++]
|
||||||
"-c" -> commonSources += args[index++]
|
"-c" -> commonSources += args[index++]
|
||||||
@@ -121,11 +123,15 @@ fun main(args: Array<String>) {
|
|||||||
error("Please set path to .klm file: `-o some/dir/module-name.klm`")
|
error("Please set path to .klm file: `-o some/dir/module-name.klm`")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (moduleName == null) {
|
||||||
|
error("Please set module name: `-n module-name`")
|
||||||
|
}
|
||||||
|
|
||||||
val resolvedLibraries = jsResolveLibraries(
|
val resolvedLibraries = jsResolveLibraries(
|
||||||
dependencies, messageCollectorLogger(MessageCollector.NONE)
|
dependencies, messageCollectorLogger(MessageCollector.NONE)
|
||||||
)
|
)
|
||||||
|
|
||||||
buildKLib(File(outputPath).absolutePath, listOfKtFilesFrom(inputFiles), outputPath, resolvedLibraries, listOfKtFilesFrom(commonSources))
|
buildKLib(moduleName, listOfKtFilesFrom(inputFiles), outputPath, resolvedLibraries, listOfKtFilesFrom(commonSources))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copied here from `K2JsIrCompiler` instead of reusing in order to avoid circular dependencies between Gradle tasks
|
// Copied here from `K2JsIrCompiler` instead of reusing in order to avoid circular dependencies between Gradle tasks
|
||||||
|
|||||||
@@ -162,13 +162,13 @@ val reducedRuntimeSources by task<Sync> {
|
|||||||
into("$buildDir/reducedRuntime/src")
|
into("$buildDir/reducedRuntime/src")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun JavaExec.buildKLib(sources: List<String>, dependencies: List<String>, outPath: String, commonSources: List<String>) {
|
fun JavaExec.buildKLib(moduleName: String, sources: List<String>, dependencies: List<String>, outPath: String, commonSources: List<String>) {
|
||||||
inputs.files(sources)
|
inputs.files(sources)
|
||||||
outputs.dir(file(outPath).parent)
|
outputs.dir(file(outPath).parent)
|
||||||
classpath = jsIrKlibCli
|
classpath = jsIrKlibCli
|
||||||
main = "org.jetbrains.kotlin.ir.backend.js.GenerateJsIrKlibKt"
|
main = "org.jetbrains.kotlin.ir.backend.js.GenerateJsIrKlibKt"
|
||||||
workingDir = rootDir
|
workingDir = rootDir
|
||||||
args = sources.toList() + listOf("-o", outPath) + dependencies.flatMap { listOf("-d", it) } + commonSources.flatMap { listOf("-c", it) }
|
args = sources.toList() + listOf("-n", moduleName, "-o", outPath) + dependencies.flatMap { listOf("-d", it) } + commonSources.flatMap { listOf("-c", it) }
|
||||||
|
|
||||||
dependsOn(":compiler:cli-js-klib:jar")
|
dependsOn(":compiler:cli-js-klib:jar")
|
||||||
passClasspathInJar()
|
passClasspathInJar()
|
||||||
@@ -179,7 +179,8 @@ val fullRuntimeDir = buildDir.resolve("fullRuntime/klib")
|
|||||||
val generateFullRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
val generateFullRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
||||||
dependsOn(fullRuntimeSources)
|
dependsOn(fullRuntimeSources)
|
||||||
|
|
||||||
buildKLib(sources = listOf(fullRuntimeSources.get().outputs.files.singleFile.path),
|
buildKLib(moduleName = "kotlin",
|
||||||
|
sources = listOf(fullRuntimeSources.get().outputs.files.singleFile.path),
|
||||||
dependencies = emptyList(),
|
dependencies = emptyList(),
|
||||||
outPath = fullRuntimeDir.absolutePath,
|
outPath = fullRuntimeDir.absolutePath,
|
||||||
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/fullRuntime/src/libraries/stdlib/$it" }
|
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/fullRuntime/src/libraries/stdlib/$it" }
|
||||||
@@ -197,7 +198,8 @@ val generateReducedRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
|||||||
dependsOn(reducedRuntimeSources)
|
dependsOn(reducedRuntimeSources)
|
||||||
|
|
||||||
val outPath = buildDir.resolve("reducedRuntime/klib").absolutePath
|
val outPath = buildDir.resolve("reducedRuntime/klib").absolutePath
|
||||||
buildKLib(sources = listOf(reducedRuntimeSources.get().outputs.files.singleFile.path),
|
buildKLib(moduleName = "kotlin",
|
||||||
|
sources = listOf(reducedRuntimeSources.get().outputs.files.singleFile.path),
|
||||||
dependencies = emptyList(),
|
dependencies = emptyList(),
|
||||||
outPath = outPath,
|
outPath = outPath,
|
||||||
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/reducedRuntime/src/libraries/stdlib/$it" }
|
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/reducedRuntime/src/libraries/stdlib/$it" }
|
||||||
@@ -205,7 +207,8 @@ val generateReducedRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val generateWasmRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
val generateWasmRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
||||||
buildKLib(sources = listOf("$rootDir/libraries/stdlib/wasm"),
|
buildKLib(moduleName = "kotlin",
|
||||||
|
sources = listOf("$rootDir/libraries/stdlib/wasm"),
|
||||||
dependencies = emptyList(),
|
dependencies = emptyList(),
|
||||||
outPath = "$buildDir/wasmRuntime/klib",
|
outPath = "$buildDir/wasmRuntime/klib",
|
||||||
commonSources = emptyList()
|
commonSources = emptyList()
|
||||||
@@ -220,6 +223,7 @@ val generateKotlinTestKLib by eagerTask<NoDebugJavaExec> {
|
|||||||
dependsOn(generateFullRuntimeKLib)
|
dependsOn(generateFullRuntimeKLib)
|
||||||
|
|
||||||
buildKLib(
|
buildKLib(
|
||||||
|
moduleName = "kotlin-test",
|
||||||
sources = listOf("$rootDir/libraries/kotlin.test/js/src/main") + kotlinTestCommonSources,
|
sources = listOf("$rootDir/libraries/kotlin.test/js/src/main") + kotlinTestCommonSources,
|
||||||
dependencies = listOf("${generateFullRuntimeKLib.outputs.files.singleFile.path}/klib"),
|
dependencies = listOf("${generateFullRuntimeKLib.outputs.files.singleFile.path}/klib"),
|
||||||
outPath = "$buildDir/kotlin.test/klib",
|
outPath = "$buildDir/kotlin.test/klib",
|
||||||
|
|||||||
Reference in New Issue
Block a user