Gradle, native: Escape spaces in K/N compiler args
We use an argument file to pass arguments to the K/N compiler. Earlier each line of such a file was treated by the compiler as a separate argument. But this logic was updated some time ago and now content for this file is treated as a space separated list of arguments. This patch takes this into account at the Gradle side and quotes arguments written to the arg file. Issue #KT-35934 Fixed
This commit is contained in:
+16
@@ -2249,4 +2249,20 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNativeArgsWithSpaces() = with(Project("sample-lib", directoryPrefix = "new-mpp-lib-and-app")) {
|
||||
setupWorkingDir()
|
||||
val fileWithSpacesInPath = projectDir.resolve("src/commonMain/kotlin/path with spaces and special symbols like \"")
|
||||
.apply { mkdirs() }
|
||||
.resolve("B.kt")
|
||||
fileWithSpacesInPath.writeText("fun foo() = 42")
|
||||
|
||||
build("compileKotlin${nativeHostTargetName.capitalize()}") {
|
||||
assertSuccessful()
|
||||
checkNativeCommandLineFor(":compileKotlin${nativeHostTargetName.capitalize()}") {
|
||||
it.contains(fileWithSpacesInPath.absolutePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -227,8 +227,11 @@ internal class KonanCompilerRunner(
|
||||
deleteOnExit()
|
||||
}
|
||||
argFile.printWriter().use { writer ->
|
||||
args.forEach {
|
||||
writer.println(it)
|
||||
args.forEach { arg ->
|
||||
val escapedArg = arg
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\"")
|
||||
writer.println("\"$escapedArg\"")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user