Add args for release, verbose, and forcebuilding
This commit is contained in:
parent
b9c805f466
commit
795876d5e4
1 changed files with 32 additions and 7 deletions
|
|
@ -17,9 +17,14 @@ type
|
||||||
libs: string
|
libs: string
|
||||||
includes: string
|
includes: string
|
||||||
|
|
||||||
|
force: bool
|
||||||
|
verbose: bool
|
||||||
|
release: bool
|
||||||
|
|
||||||
elfLocation: string
|
elfLocation: string
|
||||||
|
|
||||||
proc execProc(cmd: string): string {.discardable.}=
|
|
||||||
|
proc execProc(cmd: string, verbose: bool=false): string {.discardable.}=
|
||||||
result = ""
|
result = ""
|
||||||
var
|
var
|
||||||
p = startProcess(cmd, options = {poStdErrToStdOut, poUsePath, poEvalCommand})
|
p = startProcess(cmd, options = {poStdErrToStdOut, poUsePath, poEvalCommand})
|
||||||
|
|
@ -29,6 +34,8 @@ proc execProc(cmd: string): string {.discardable.}=
|
||||||
|
|
||||||
while true:
|
while true:
|
||||||
if outp.readLine(line):
|
if outp.readLine(line):
|
||||||
|
if verbose:
|
||||||
|
echo line
|
||||||
result.add(line)
|
result.add(line)
|
||||||
result.add("\n")
|
result.add("\n")
|
||||||
elif not running(p): break
|
elif not running(p): break
|
||||||
|
|
@ -52,6 +59,9 @@ proc writeHelp() =
|
||||||
switch-build [options] project-file.nim
|
switch-build [options] project-file.nim
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
-f, --forceBuild force compilation of files
|
||||||
|
-r, --release compile in release mode (no stack traces, more efficient)
|
||||||
|
--verbose Stream output of compilation tasks
|
||||||
-d, --devkitProPath:PATH devkitpro installation path for switch-build.
|
-d, --devkitProPath:PATH devkitpro installation path for switch-build.
|
||||||
Required if DEVKITPRO environment var is unset
|
Required if DEVKITPRO environment var is unset
|
||||||
-c, --devkitCompilerPath:PATH
|
-c, --devkitCompilerPath:PATH
|
||||||
|
|
@ -81,9 +91,18 @@ Note, single letter options that take an argument require a colon. E.g. -p:PATH.
|
||||||
|
|
||||||
proc buildElf(buildInfo: BuildInfo): string =
|
proc buildElf(buildInfo: BuildInfo): string =
|
||||||
echo "Building elf file..."
|
echo "Building elf file..."
|
||||||
let cmd = "nim c " &
|
var cmd = "nim $args c " &
|
||||||
"--os:nintendoswitch " & buildInfo.filename
|
"--os:nintendoswitch " & buildInfo.filename
|
||||||
execProc cmd
|
|
||||||
|
var args = ""
|
||||||
|
if buildInfo.release:
|
||||||
|
args &= " -d:release"
|
||||||
|
if buildInfo.force:
|
||||||
|
args &= " -f"
|
||||||
|
|
||||||
|
cmd = cmd % ["args", args]
|
||||||
|
|
||||||
|
execProc cmd, buildInfo.verbose
|
||||||
|
|
||||||
result = buildInfo.filename.splitFile().dir / buildInfo.name & ".elf"
|
result = buildInfo.filename.splitFile().dir / buildInfo.name & ".elf"
|
||||||
|
|
||||||
|
|
@ -95,7 +114,7 @@ proc buildNso(buildInfo: BuildInfo): string =
|
||||||
var cmd = buildInfo.toolsPath / "elf2nso "
|
var cmd = buildInfo.toolsPath / "elf2nso "
|
||||||
cmd &= buildInfo.elfLocation & " " & result
|
cmd &= buildInfo.elfLocation & " " & result
|
||||||
|
|
||||||
execProc cmd
|
execProc cmd, buildInfo.verbose
|
||||||
|
|
||||||
|
|
||||||
proc buildPfs0(buildInfo: BuildInfo): string =
|
proc buildPfs0(buildInfo: BuildInfo): string =
|
||||||
|
|
@ -122,7 +141,7 @@ proc buildLst(buildInfo: BuildInfo): string =
|
||||||
var cmd = compDir / "aarch64-none-elf-gcc-nm " & buildInfo.elfLocation
|
var cmd = compDir / "aarch64-none-elf-gcc-nm " & buildInfo.elfLocation
|
||||||
cmd &= " > " & result
|
cmd &= " > " & result
|
||||||
|
|
||||||
execProc cmd
|
execProc cmd, buildInfo.verbose
|
||||||
|
|
||||||
proc buildNacp(buildInfo: BuildInfo): string =
|
proc buildNacp(buildInfo: BuildInfo): string =
|
||||||
let
|
let
|
||||||
|
|
@ -138,7 +157,7 @@ proc buildNacp(buildInfo: BuildInfo): string =
|
||||||
cmd &= " '" & author & "' '" & version & "' "
|
cmd &= " '" & author & "' '" & version & "' "
|
||||||
cmd &= result
|
cmd &= result
|
||||||
|
|
||||||
execProc cmd
|
execProc cmd, buildInfo.verbose
|
||||||
|
|
||||||
proc buildNro(buildInfo: BuildInfo): string =
|
proc buildNro(buildInfo: BuildInfo): string =
|
||||||
let nacpPath = buildNacp(buildInfo)
|
let nacpPath = buildNacp(buildInfo)
|
||||||
|
|
@ -154,7 +173,7 @@ proc buildNro(buildInfo: BuildInfo): string =
|
||||||
var cmd = toolsPath / "elf2nro " & elfLocation & " " & result
|
var cmd = toolsPath / "elf2nro " & elfLocation & " " & result
|
||||||
cmd &= " --icon=" & icon & " --nacp=" & nacpPath
|
cmd &= " --icon=" & icon & " --nacp=" & nacpPath
|
||||||
|
|
||||||
execProc cmd
|
execProc cmd, buildInfo.verbose
|
||||||
|
|
||||||
proc buildAll(buildInfo: BuildInfo): seq[string] =
|
proc buildAll(buildInfo: BuildInfo): seq[string] =
|
||||||
result = @[]
|
result = @[]
|
||||||
|
|
@ -232,6 +251,12 @@ proc processArgs() =
|
||||||
buildInfo.icon = val
|
buildInfo.icon = val
|
||||||
of "version", "v":
|
of "version", "v":
|
||||||
buildInfo.version = val
|
buildInfo.version = val
|
||||||
|
of "forceBuild", "f":
|
||||||
|
buildInfo.force = true
|
||||||
|
of "release", "r":
|
||||||
|
buildInfo.release = true
|
||||||
|
of "verbose":
|
||||||
|
buildInfo.verbose = true
|
||||||
of "help", "h":
|
of "help", "h":
|
||||||
writeHelp()
|
writeHelp()
|
||||||
quit(0)
|
quit(0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue