Skip to content

Commit 9f3cbdb

Browse files
committed
Do not generate wat file if no debug info
1 parent 8b6bb36 commit 9f3cbdb

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/main/kotlin/com/compiler/server/service/KotlinProjectExecutor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class KotlinProjectExecutor(
101101
private fun convertWasmWithConverter(
102102
project: Project,
103103
debugInfo: Boolean,
104-
converter: (List<KtFile>, List<String>, List<String>, List<String>) -> CompilationResult<WasmTranslationSuccessfulOutput>
104+
converter: (List<KtFile>, List<String>, List<String>, List<String>, Boolean) -> CompilationResult<WasmTranslationSuccessfulOutput>
105105
): TranslationResultWithJsCode {
106106
return kotlinEnvironment.environment { environment ->
107107
val files = getFilesFrom(project, environment).map { it.kotlinFile }

0 commit comments

Comments
 (0)