mirror of
https://github.com/KarolS/millfork.git
synced 2025-08-08 18:25:03 +00:00
Support BAT files for the -r
options
This commit is contained in:
@@ -66,7 +66,10 @@ Unlike `-I`, this does not replace the default include directory and allows usin
|
|||||||
|
|
||||||
* `-t <platform>` – Target platform. It is loaded from an `.ini` file found in any of the include directories. See also [this document](target-platforms.md).
|
* `-t <platform>` – Target platform. It is loaded from an `.ini` file found in any of the include directories. See also [this document](target-platforms.md).
|
||||||
|
|
||||||
* `-r <program>` – Run given program after successful compilation. Useful for automatically launching emulators without any external scripting.
|
* `-r <program>` – Run given program after successful compilation.
|
||||||
|
Useful for automatically launching emulators without any external scripting.
|
||||||
|
The program is run with the working directory set to its own directory,
|
||||||
|
and it's passed the full path to the output file as its argument.
|
||||||
|
|
||||||
* `-R <param>` – Adds a parameter to the command line of the program run with `-r`. All `-R` options are added in order, before the output file name.
|
* `-R <param>` – Adds a parameter to the command line of the program run with `-r`. All `-R` options are added in order, before the output file name.
|
||||||
|
|
||||||
|
@@ -167,8 +167,16 @@ object Main {
|
|||||||
}
|
}
|
||||||
errorReporting.debug(s"Total time: ${Math.round((System.nanoTime() - startTime)/1e6)} ms")
|
errorReporting.debug(s"Total time: ${Math.round((System.nanoTime() - startTime)/1e6)} ms")
|
||||||
c.runFileName.foreach{ program =>
|
c.runFileName.foreach{ program =>
|
||||||
|
if (!new File(program).exists()) {
|
||||||
|
errorReporting.error(s"Program $program does not exist")
|
||||||
|
}
|
||||||
val outputAbsolutePath = Paths.get(defaultPrgOutput).toAbsolutePath.toString
|
val outputAbsolutePath = Paths.get(defaultPrgOutput).toAbsolutePath.toString
|
||||||
val cmdline = program +: c.runParams :+ outputAbsolutePath
|
val isBatch = File.separatorChar == '\\' && program.toLowerCase(Locale.ROOT).endsWith(".bat")
|
||||||
|
val cmdline = if (isBatch) {
|
||||||
|
List("cmd", "/c", program) ++ c.runParams :+ outputAbsolutePath
|
||||||
|
} else {
|
||||||
|
program +: c.runParams :+ outputAbsolutePath
|
||||||
|
}
|
||||||
errorReporting.debug(s"Running: ${cmdline.mkString(" ")}")
|
errorReporting.debug(s"Running: ${cmdline.mkString(" ")}")
|
||||||
new ProcessBuilder(cmdline.toArray: _*).directory(new File(program).getParentFile).start()
|
new ProcessBuilder(cmdline.toArray: _*).directory(new File(program).getParentFile).start()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user