@@ -47,7 +47,7 @@ class KotlinToJSTranslator(
4747 files : List <KtFile >,
4848 debugInfo : Boolean ,
4949 projectType : ProjectType ,
50- translate : (List <KtFile >, List <String >, List <String >, List <String >) -> CompilationResult <WasmTranslationSuccessfulOutput >
50+ translate : (List <KtFile >, List <String >, List <String >, List <String >, Boolean ) -> CompilationResult <WasmTranslationSuccessfulOutput >
5151 ): TranslationResultWithJsCode {
5252 return try {
5353 val (dependencies, compilerPlugins, compilerPluginOptions) = when (projectType) {
@@ -67,7 +67,8 @@ class KotlinToJSTranslator(
6767 files,
6868 dependencies,
6969 compilerPlugins,
70- compilerPluginOptions
70+ compilerPluginOptions,
71+ debugInfo
7172 )
7273 val wasmCompilationOutput = when (compilationResult) {
7374 is Compiled <WasmTranslationSuccessfulOutput > -> compilationResult.result
@@ -138,6 +139,7 @@ class KotlinToJSTranslator(
138139 dependencies : List <String >,
139140 compilerPlugins : List <String >,
140141 compilerPluginOptions : List <String >,
142+ debugInfo : Boolean ,
141143 ): CompilationResult <WasmTranslationSuccessfulOutput > =
142144 usingTempDirectory { inputDir ->
143145 val moduleName = " moduleId"
@@ -167,25 +169,24 @@ class KotlinToJSTranslator(
167169
168170 k2JSCompiler.tryCompilation(inputDir, ioFiles, filePaths + additionalCompilerArgumentsForKLib)
169171 .flatMap {
170- k2JSCompiler.tryCompilation(inputDir, ioFiles, listOf (
172+ k2JSCompiler.tryCompilation(inputDir, ioFiles, mutableListOf (
171173 " -Xreport-all-warnings" ,
172174 " -Xuse-fir-extended-checkers" ,
173175 " -Xwasm" ,
174- " -Xwasm-generate-wat" ,
175176 " -Xir-produce-js" ,
176177 " -Xir-dce" ,
177178 " -Xinclude=$klibPath " ,
178179 " -libraries=${dependencies.joinToString(PATH_SEPARATOR )} " ,
179180 " -ir-output-dir=${(outputDir / " wasm" ).toFile().canonicalPath} " ,
180181 " -ir-output-name=$moduleName " ,
181- ))
182+ ). also { if (debugInfo) it.add( " -Xwasm-generate-wat " ) } )
182183 }
183184 .map {
184185 WasmTranslationSuccessfulOutput (
185186 jsCode = (outputDir / " wasm" / " $moduleName .uninstantiated.mjs" ).readText(),
186187 jsInstantiated = (outputDir / " wasm" / " $moduleName .mjs" ).readText(),
187188 wasm = (outputDir / " wasm" / " $moduleName .wasm" ).readBytes(),
188- wat = ( outputDir / " wasm" / " $moduleName .wat" ).readText(),
189+ wat = if (debugInfo) ( outputDir / " wasm" / " $moduleName .wat" ).readText() else null ,
189190 )
190191 }
191192 }
0 commit comments