Build: Make :kotlin-stdlib-js-ir buildKLib tasks cacheable
This commit is contained in:
@@ -167,13 +167,29 @@ val reducedRuntimeSources by task<Sync> {
|
|||||||
into("$buildDir/reducedRuntime/src")
|
into("$buildDir/reducedRuntime/src")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun JavaExec.buildKLib(moduleName: String, sources: List<String>, dependencies: List<String>, outPath: String, commonSources: List<String>) {
|
fun JavaExec.buildKLib(
|
||||||
|
moduleName: String,
|
||||||
|
sources: List<File>,
|
||||||
|
dependencies: List<File>,
|
||||||
|
outDir: File,
|
||||||
|
commonSources: List<File>
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun File.pathRelativeToWorkingDir(): String = absoluteFile.relativeTo(workingDir).path
|
||||||
|
|
||||||
inputs.files(sources)
|
inputs.files(sources)
|
||||||
outputs.dir(file(outPath).parent)
|
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||||
|
|
||||||
|
outputs.dir(file(outDir))
|
||||||
|
outputs.cacheIf { true }
|
||||||
|
|
||||||
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("-n", moduleName, "-o", outPath) + dependencies.flatMap { listOf("-d", it) } + commonSources.flatMap { listOf("-c", it) }
|
args = sources.map { it.pathRelativeToWorkingDir() } +
|
||||||
|
listOf("-n", moduleName, "-o", outDir.pathRelativeToWorkingDir()) +
|
||||||
|
dependencies.flatMap { listOf("-d", it.pathRelativeToWorkingDir()) } +
|
||||||
|
commonSources.flatMap { listOf("-c", it.pathRelativeToWorkingDir()) }
|
||||||
|
|
||||||
dependsOn(":compiler:cli-js-klib:jar")
|
dependsOn(":compiler:cli-js-klib:jar")
|
||||||
passClasspathInJar()
|
passClasspathInJar()
|
||||||
@@ -185,10 +201,10 @@ val generateFullRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
|||||||
dependsOn(fullRuntimeSources)
|
dependsOn(fullRuntimeSources)
|
||||||
|
|
||||||
buildKLib(moduleName = "kotlin",
|
buildKLib(moduleName = "kotlin",
|
||||||
sources = listOf(fullRuntimeSources.get().outputs.files.singleFile.path),
|
sources = listOf(fullRuntimeSources.get().outputs.files.singleFile),
|
||||||
dependencies = emptyList(),
|
dependencies = emptyList(),
|
||||||
outPath = fullRuntimeDir.absolutePath,
|
outDir = fullRuntimeDir,
|
||||||
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/fullRuntime/src/libraries/stdlib/$it" }
|
commonSources = listOf("common", "src", "unsigned").map { file("$buildDir/fullRuntime/src/libraries/stdlib/$it") }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,20 +218,19 @@ val packFullRuntimeKLib by tasks.registering(Jar::class) {
|
|||||||
val generateReducedRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
val generateReducedRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
||||||
dependsOn(reducedRuntimeSources)
|
dependsOn(reducedRuntimeSources)
|
||||||
|
|
||||||
val outPath = buildDir.resolve("reducedRuntime/klib").absolutePath
|
|
||||||
buildKLib(moduleName = "kotlin",
|
buildKLib(moduleName = "kotlin",
|
||||||
sources = listOf(reducedRuntimeSources.get().outputs.files.singleFile.path),
|
sources = listOf(reducedRuntimeSources.get().outputs.files.singleFile),
|
||||||
dependencies = emptyList(),
|
dependencies = emptyList(),
|
||||||
outPath = outPath,
|
outDir = buildDir.resolve("reducedRuntime/klib"),
|
||||||
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/reducedRuntime/src/libraries/stdlib/$it" }
|
commonSources = listOf("common", "src", "unsigned").map { file("$buildDir/reducedRuntime/src/libraries/stdlib/$it") }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val generateWasmRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
val generateWasmRuntimeKLib by eagerTask<NoDebugJavaExec> {
|
||||||
buildKLib(moduleName = "kotlin",
|
buildKLib(moduleName = "kotlin",
|
||||||
sources = listOf("$rootDir/libraries/stdlib/wasm"),
|
sources = listOf(file("$rootDir/libraries/stdlib/wasm")),
|
||||||
dependencies = emptyList(),
|
dependencies = emptyList(),
|
||||||
outPath = "$buildDir/wasmRuntime/klib",
|
outDir = file("$buildDir/wasmRuntime/klib"),
|
||||||
commonSources = emptyList()
|
commonSources = emptyList()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -224,15 +239,16 @@ val kotlinTestCommonSources = listOf(
|
|||||||
"$rootDir/libraries/kotlin.test/annotations-common/src/main",
|
"$rootDir/libraries/kotlin.test/annotations-common/src/main",
|
||||||
"$rootDir/libraries/kotlin.test/common/src/main"
|
"$rootDir/libraries/kotlin.test/common/src/main"
|
||||||
)
|
)
|
||||||
|
|
||||||
val generateKotlinTestKLib by eagerTask<NoDebugJavaExec> {
|
val generateKotlinTestKLib by eagerTask<NoDebugJavaExec> {
|
||||||
dependsOn(generateFullRuntimeKLib)
|
dependsOn(generateFullRuntimeKLib)
|
||||||
|
|
||||||
buildKLib(
|
buildKLib(
|
||||||
moduleName = "kotlin-test",
|
moduleName = "kotlin-test",
|
||||||
sources = listOf("$rootDir/libraries/kotlin.test/js/src/main") + kotlinTestCommonSources,
|
sources = (listOf("$rootDir/libraries/kotlin.test/js/src/main") + kotlinTestCommonSources).map(::file),
|
||||||
dependencies = listOf("${generateFullRuntimeKLib.outputs.files.singleFile.path}/klib"),
|
dependencies = listOf(generateFullRuntimeKLib.outputs.files.singleFile),
|
||||||
outPath = "$buildDir/kotlin.test/klib",
|
outDir = file("$buildDir/kotlin.test/klib"),
|
||||||
commonSources = kotlinTestCommonSources
|
commonSources = kotlinTestCommonSources.map(::file)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user