diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index 76c345a42e7..5b009b240f7 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -336,6 +336,9 @@ class K2JSCompilerArguments : CommonCompilerArguments() { @Argument(value = "-Xwasm-enable-asserts", description = "Turn on asserts") var wasmEnableAsserts: Boolean by FreezableVar(false) + @Argument(value = "-Xwasm-generate-wat", description = "Generate wat file") + var wasmGenerateWat: Boolean by FreezableVar(false) + @Argument( value = "-Xuse-deprecated-legacy-compiler", description = "Use deprecated legacy compiler without error" diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index 4284418a9d1..e2d9a570877 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -200,6 +200,7 @@ class K2JsIrCompiler : CLICompiler() { 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) val commonSourcesArray = arguments.commonSources val commonSources = commonSourcesArray?.toSet() ?: emptySet() @@ -376,7 +377,7 @@ class K2JsIrCompiler : CLICompiler() { baseFileName = outputName, emitNameSection = arguments.wasmDebug, allowIncompleteImplementations = arguments.irDce, - generateWat = true, + generateWat = configuration.get(JSConfigurationKeys.WASM_GENERATE_WAT, false), generateSourceMaps = generateSourceMaps ) diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index 7a0ae1623cc..ba3c2819192 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -50,6 +50,7 @@ where advanced options include: -Xwasm-enable-array-range-checks Turn on range checks for the array access functions -Xwasm-enable-asserts Turn on asserts + -Xwasm-generate-wat Generate wat file -Xwasm-kclass-fqn Enable support for FQ names in KClass -Xallow-any-scripts-in-source-roots Allow to compile any scripts along with regular Kotlin sources diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java b/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java index f056778459c..a46412ac126 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java @@ -120,4 +120,7 @@ public class JSConfigurationKeys { public static final CompilerConfigurationKey WASM_ENABLE_ASSERTS = CompilerConfigurationKey.create("enable asserts"); + + public static final CompilerConfigurationKey WASM_GENERATE_WAT = + CompilerConfigurationKey.create("generate wat file"); }