Unverified Commit 16b2dee5 authored by Shagen Ogandzhanian's avatar Shagen Ogandzhanian Committed by GitHub

Postprocess skiko.js file directly while adding to the jar (#196)

parent 3cc441cc
...@@ -343,7 +343,7 @@ fun List<String>.findAllFiles(suffix: String): List<String> = this ...@@ -343,7 +343,7 @@ fun List<String>.findAllFiles(suffix: String): List<String> = this
.filter { it.endsWith(suffix) } .filter { it.endsWith(suffix) }
val wasmCompileTask = project.tasks.register<Exec>("wasmCompile") { val wasmCompile = project.tasks.register<Exec>("wasmCompile") {
dependsOn(skiaWasmDir) dependsOn(skiaWasmDir)
val skiaDir = skiaWasmDir.get().absolutePath val skiaDir = skiaWasmDir.get().absolutePath
val outDir = "$buildDir/wasm" val outDir = "$buildDir/wasm"
...@@ -381,19 +381,6 @@ val wasmCompileTask = project.tasks.register<Exec>("wasmCompile") { ...@@ -381,19 +381,6 @@ val wasmCompileTask = project.tasks.register<Exec>("wasmCompile") {
outputs.files(outJs, outWasm) outputs.files(outJs, outWasm)
} }
val wasmJsPatcher = project.tasks.register<Exec>("wasmJsPatcher") {
dependsOn(wasmCompileTask)
val inJs = wasmCompileTask.get().outputs.files.single { it.name.endsWith(".js") }
val outDir = "$buildDir/wasm"
val outJs = "$outDir/skiko_processed.js"
commandLine = listOf(
"bash", "-c",
"sed 's/_org_jetbrains_/org_jetbrains_/g' ${inJs.absolutePath} > ${outJs}"
)
inputs.files(inJs)
outputs.files(outJs)
}
// Very hacky way to compile native bridges and add the // Very hacky way to compile native bridges and add the
// resulting object files into the final native klib. // resulting object files into the final native klib.
project.tasks.register<Exec>("nativeBridgesCompile") { project.tasks.register<Exec>("nativeBridgesCompile") {
...@@ -672,9 +659,14 @@ val skikoJvmRuntimeJar by project.tasks.registering(Jar::class) { ...@@ -672,9 +659,14 @@ val skikoJvmRuntimeJar by project.tasks.registering(Jar::class) {
val skikoWasmJar by project.tasks.registering(Jar::class) { val skikoWasmJar by project.tasks.registering(Jar::class) {
// We produce jar that contains .js of wrapper/bindings and .wasm with Skia + bindings. // We produce jar that contains .js of wrapper/bindings and .wasm with Skia + bindings.
from(wasmCompileTask.get().outputs.files.single { it.name.endsWith(".wasm")}) val wasmOutputs = wasmCompile.get().outputs
from(wasmJsPatcher.get().outputs) from(wasmOutputs.files.single { it.name.endsWith(".wasm")})
rename { if (it == "skiko_processed.js") "skiko.js" else it }
from(wasmOutputs) {
include("skiko.js")
filter { line -> line.replace("_org_jetbrains_", "org_jetbrains_") }
}
archiveBaseName.set("skiko-wasm") archiveBaseName.set("skiko-wasm")
doLast { doLast {
println("Wasm and JS at ${outputs.files.files.single()}") println("Wasm and JS at ${outputs.files.files.single()}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment