Dragos Rachieru
03/07/2022, 2:01 PMsourceSet called desktopMain like in this example
The problem I'm facing, is that platform.posix.popen and platform.posix.pclose are not available in the shared sourceSet.
Any idea why it is not resolved?Dragos Rachieru
03/07/2022, 2:03 PMbuild.gradle part:
val desktopMain by creating {
dependsOn(commonMain)
}
val linuxX64Main by getting {
dependsOn(desktopMain)
}
val mingwX64Main by getting {
dependsOn(desktopMain)
}
val macosX64Main by getting {
dependsOn(desktopMain)
}Dragos Rachieru
03/07/2022, 2:04 PMactual fun runCommand(command: String) {
system(command)
}
actual fun awaitCommand(
command: String
): String {
val fp = popen(command, "r") ?: error("Failed to run command: $command")
val buffer = ByteArray(4096)
val returnString = StringBuilder()
var scan = fgets(buffer.refTo(0), buffer.size, fp)
if (scan != null) {
while (scan != NULL) {
returnString.append(scan!!.toKString())
scan = fgets(buffer.refTo(0), buffer.size, fp)
}
}
val status = pclose(fp)
if (status != 0) {
error("Command $command failed with status $status")
}
return returnString.toString()
}Dragos Rachieru
03/07/2022, 2:04 PMsystem call worksmsink
03/07/2022, 3:56 PMpopen and pclose are not supported in mingw.
Does it work if comment out mingw support?Dragos Rachieru
05/02/2022, 10:29 AMpopen and pclose work on linux and macos
For mingw I have to use _popen and _pclose, don't know why.