[WASM] Support for mjs universal launcher

This commit is contained in:
Igor Yakovlev
2022-06-03 18:45:40 +02:00
committed by teamcity
parent c8806763fa
commit f996278171
20 changed files with 103 additions and 171 deletions
@@ -249,13 +249,6 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xwasm-debug-info", description = "Add debug info to WebAssembly compiled module")
var wasmDebug: Boolean by FreezableVar(true)
@Argument(
value = "-Xwasm-launcher",
valueDescription = "esm|nodejs|d8",
description = "Picks flavor for the wasm launcher. Default is ESM."
)
var wasmLauncher: String? by NullableStringFreezableVar("esm")
@Argument(value = "-Xwasm-kclass-fqn", description = "Enable support for FQ names in KClass")
var wasmKClassFqn: Boolean by FreezableVar(false)
@@ -11,7 +11,6 @@ import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.backend.common.CompilationException
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion
import org.jetbrains.kotlin.backend.wasm.WasmLoaderKind
import org.jetbrains.kotlin.backend.wasm.compileWasm
import org.jetbrains.kotlin.backend.wasm.compileToLoweredIr
import org.jetbrains.kotlin.backend.wasm.wasmPhases
@@ -362,18 +361,9 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
generateWat = true,
)
val launcherKind = when (arguments.wasmLauncher) {
"esm" -> WasmLoaderKind.BROWSER
"nodejs" -> WasmLoaderKind.NODE
"d8" -> WasmLoaderKind.D8
"d8NodeCompatible" -> WasmLoaderKind.D8NodeCompatible
else -> throw IllegalArgumentException("Unrecognized flavor for the wasm launcher")
}
writeCompilationResult(
result = res,
dir = outputFile.parentFile,
loaderKind = launcherKind,
fileNameBase = outputFile.nameWithoutExtension
)