[Wasm] Add kotlin wasm wasi mode compiler flag
This commit is contained in:
committed by
Space Team
parent
7c7aa98875
commit
750653e4b3
+1
@@ -72,6 +72,7 @@ fun copyK2JSCompilerArguments(from: K2JSCompilerArguments, to: K2JSCompilerArgum
|
||||
to.wasmEnableAsserts = from.wasmEnableAsserts
|
||||
to.wasmGenerateWat = from.wasmGenerateWat
|
||||
to.wasmKClassFqn = from.wasmKClassFqn
|
||||
to.wasmTarget = from.wasmTarget
|
||||
|
||||
return to
|
||||
}
|
||||
|
||||
+7
@@ -623,6 +623,13 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
field = value
|
||||
}
|
||||
|
||||
@Argument(value = "-Xwasm-target", description = "Set up Wasm target (wasm-js or wasm-wasi)")
|
||||
var wasmTarget: String? = null
|
||||
set(value) {
|
||||
checkFrozen()
|
||||
field = if (value.isNullOrEmpty()) null else value
|
||||
}
|
||||
|
||||
@Argument(
|
||||
value = "-Xforce-deprecated-legacy-compiler-usage",
|
||||
description = "The flag is used only for our inner infrastructure. It will be removed soon, so it's unsafe to use it nowadays."
|
||||
|
||||
@@ -169,6 +169,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
configuration.put(JSConfigurationKeys.WASM_ENABLE_ARRAY_RANGE_CHECKS, arguments.wasmEnableArrayRangeChecks)
|
||||
configuration.put(JSConfigurationKeys.WASM_ENABLE_ASSERTS, arguments.wasmEnableAsserts)
|
||||
configuration.put(JSConfigurationKeys.WASM_GENERATE_WAT, arguments.wasmGenerateWat)
|
||||
configuration.putIfNotNull(JSConfigurationKeys.WASM_TARGET, arguments.wasmTarget?.let(WasmTarget::fromName))
|
||||
|
||||
configuration.put(JSConfigurationKeys.OPTIMIZE_GENERATED_JS, arguments.optimizeGeneratedJs)
|
||||
|
||||
val commonSourcesArray = arguments.commonSources
|
||||
|
||||
+1
@@ -59,6 +59,7 @@ where advanced options include:
|
||||
-Xwasm-enable-asserts Turn on asserts
|
||||
-Xwasm-generate-wat Generate wat file
|
||||
-Xwasm-kclass-fqn Enable support for FQ names in KClass
|
||||
-Xwasm-target Set up Wasm target (wasm-js or wasm-wasi)
|
||||
-Xallow-any-scripts-in-source-roots
|
||||
Allow to compile any scripts along with regular Kotlin sources
|
||||
-Xallow-kotlin-package Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info
|
||||
|
||||
@@ -121,6 +121,9 @@ public class JSConfigurationKeys {
|
||||
public static final CompilerConfigurationKey<Boolean> WASM_GENERATE_WAT =
|
||||
CompilerConfigurationKey.create("generate wat file");
|
||||
|
||||
public static final CompilerConfigurationKey<WasmTarget> WASM_TARGET =
|
||||
CompilerConfigurationKey.create("wasm target");
|
||||
|
||||
public static final CompilerConfigurationKey<ZipFileSystemAccessor> ZIP_FILE_SYSTEM_ACCESSOR =
|
||||
CompilerConfigurationKey.create("zip file system accessor, used for klib reading");
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.config
|
||||
|
||||
enum class WasmTarget {
|
||||
JS,
|
||||
WASI;
|
||||
|
||||
companion object {
|
||||
fun fromName(name: String): WasmTarget? = when (name) {
|
||||
"wasm-js" -> JS
|
||||
"wasm-wasi" -> WASI
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user