|
@@ -45,7 +45,7 @@ object SystemUtils {
|
|
|
)
|
|
|
for (program in programs) {
|
|
|
if (program == "xmake" || File(program).exists()) {
|
|
|
- val result = ioRunv(listOf(program, "--version"))
|
|
|
+ val result = runVOutAll(listOf(program, "--version"))
|
|
|
if (result.isNotEmpty()) {
|
|
|
_xmakeProgram = program
|
|
|
break
|
|
@@ -63,7 +63,7 @@ object SystemUtils {
|
|
|
var xmakeVersion: String
|
|
|
get() {
|
|
|
if (_xmakeVersion == "") {
|
|
|
- val result = ioRunv(listOf(xmakeProgram, "--version")).split(',')
|
|
|
+ val result = runVOutAll(listOf(xmakeProgram, "--version"))[0].split(',')
|
|
|
if (result.isNotEmpty()) {
|
|
|
_xmakeVersion = result[0]
|
|
|
}
|
|
@@ -81,84 +81,6 @@ object SystemUtils {
|
|
|
else -> "linux"
|
|
|
}
|
|
|
|
|
|
- // run command with arguments
|
|
|
- fun Runv(argv: List<String>, workingDirectory: String? = null): Int {
|
|
|
-
|
|
|
- var code = -1
|
|
|
- try {
|
|
|
-
|
|
|
- // init process builder
|
|
|
- val processBuilder = ProcessBuilder(argv)
|
|
|
-
|
|
|
- // init working directory
|
|
|
- if (workingDirectory !== null) {
|
|
|
- processBuilder.directory(File(workingDirectory))
|
|
|
- }
|
|
|
-
|
|
|
- // run process
|
|
|
- val process = processBuilder.start()
|
|
|
-
|
|
|
- // wait for process
|
|
|
- code = process.waitFor()
|
|
|
-
|
|
|
- } catch (e: IOException) {
|
|
|
- e.printStackTrace()
|
|
|
- } finally {
|
|
|
- }
|
|
|
- return code
|
|
|
- }
|
|
|
-
|
|
|
- // run command with arguments and return output
|
|
|
- fun ioRunv(argv: List<String>, workingDirectory: String? = null): String {
|
|
|
-
|
|
|
- var result = ""
|
|
|
- var bufferReader: BufferedReader? = null
|
|
|
- try {
|
|
|
-
|
|
|
- // init process builder
|
|
|
- val processBuilder = ProcessBuilder(argv)
|
|
|
-
|
|
|
- // init working directory
|
|
|
- if (workingDirectory !== null) {
|
|
|
- processBuilder.directory(File(workingDirectory))
|
|
|
- }
|
|
|
-
|
|
|
- // disable color for xmake
|
|
|
- processBuilder.environment().put("COLORTERM", "nocolor")
|
|
|
-
|
|
|
- // run process
|
|
|
- val process = processBuilder.start()
|
|
|
-
|
|
|
- // get input buffer reader
|
|
|
- bufferReader = BufferedReader(InputStreamReader(process.getInputStream()))
|
|
|
-
|
|
|
- // get io output
|
|
|
- var line: String? = bufferReader.readLine()
|
|
|
- while (line != null) {
|
|
|
- result += line + "\n"
|
|
|
- line = bufferReader.readLine()
|
|
|
- }
|
|
|
-
|
|
|
- // wait for process
|
|
|
- if (process.waitFor() != 0)
|
|
|
- result = ""
|
|
|
-
|
|
|
- } catch (e: IOException) {
|
|
|
- e.printStackTrace()
|
|
|
- } finally {
|
|
|
-
|
|
|
- if (bufferReader != null) {
|
|
|
- try {
|
|
|
- bufferReader.close()
|
|
|
- } catch (e: Exception) {
|
|
|
- e.printStackTrace()
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- return result
|
|
|
- }
|
|
|
-
|
|
|
// parse problems for the given line
|
|
|
private fun parseProblem(info: String): XMakeProblem? {
|
|
|
|