Add better libnx path handling with a new cmd option. Better errors
This commit is contained in:
parent
e7e1a66a1e
commit
04a67da8d4
2 changed files with 52 additions and 24 deletions
|
|
@ -9,6 +9,7 @@ type
|
||||||
icon: string
|
icon: string
|
||||||
|
|
||||||
dkpPath: string
|
dkpPath: string
|
||||||
|
libnxPath: string
|
||||||
|
|
||||||
compilerPath: string
|
compilerPath: string
|
||||||
toolsPath: string
|
toolsPath: string
|
||||||
|
|
@ -67,34 +68,41 @@ proc writeHelp() =
|
||||||
::
|
::
|
||||||
switch-build [options] project-file.nim
|
switch-build [options] project-file.nim
|
||||||
|
|
||||||
|
Note:
|
||||||
|
$DKP refers to the devkitpro path, set either by env vars or
|
||||||
|
the command line options.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-f, --forceBuild force compilation of files
|
-f, --forceBuild Force compilation of files
|
||||||
-r, --release compile in release mode (no stack traces, more efficient)
|
-r, --release Compile in release mode (no stack traces, more efficient)
|
||||||
--verbose Stream output of compilation tasks
|
--verbose Stream output of compilation tasks
|
||||||
-d, --devkitProPath:PATH devkitpro installation path for switch-build.
|
-x, --libnxPath:PATH The path where your libnx libraries live. (default is
|
||||||
|
$DKP/libnx). Useful for development of custom libnx
|
||||||
|
features
|
||||||
|
-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
|
||||||
the path where the binaries for the devkitpro
|
The path where the binaries for the devkitpro
|
||||||
compiler lives. (defaults to "$DKP/devkitA64/bin/")
|
compiler lives. (defaults to "$DKP/devkitA64/bin/")
|
||||||
-t, --tools:PATH the devkitpro tools (defaults to "$DKP/tools/bin")
|
-t, --tools:PATH The devkitpro tools (defaults to "$DKP/tools/bin")
|
||||||
-o, --output:PATH output files in a specified directory (defaults to "build")
|
-o, --output:PATH Output files in a specified directory (defaults to "build")
|
||||||
-b, --build:TYPE the type of output file you want (defaults to "all")
|
-b, --build:TYPE The type of output file you want (defaults to "all")
|
||||||
and can be specified multiple times.
|
and can be specified multiple times.
|
||||||
TYPE is one of: "all", "nro", "nso", "pfs0", "nacp",
|
TYPE is one of: "all", "nro", "nso", "pfs0", "nacp",
|
||||||
or "lst"
|
or "lst"
|
||||||
-l, --libs:STR additional linker args to pass to the compiler.
|
-l, --libs:STR Additional linker args to pass to the compiler.
|
||||||
Ex: --libs="-lsdl -Lpath/to/lib"
|
Ex: --libs="-lsdl -Lpath/to/lib"
|
||||||
|
|
||||||
-i, --includes:STR additional includes to pass to the compiler
|
-i, --includes:STR Additional includes to pass to the compiler
|
||||||
Ex: --includes="-Ipath/to/include -Ipath/to/another/include"
|
Ex: --includes="-Ipath/to/include -Ipath/to/another/include"
|
||||||
-n, --name:STR the output file name to use. (defaults to input file name)
|
-n, --name:STR The output file name to use. (defaults to input file name)
|
||||||
-a, --author:STR sets the author name for the generate NRO and NACP file
|
-a, --author:STR Sets the author name for the generate NRO and NACP file
|
||||||
-v, --version:STR sets the version information for the generated NRO and NACP
|
-v, --version:STR Sets the version information for the generated NRO and NACP
|
||||||
file
|
file
|
||||||
-q, --romfsPath:PATH Path to use to build in a romfs image
|
-q, --romfsPath:PATH Path to use to build in a romfs image
|
||||||
-p, --icon:PATH sets the icon to use for the generated NRO and NACP
|
-p, --icon:PATH Sets the icon to use for the generated NRO and NACP
|
||||||
(defaults to "$DKP/libnx/default_icon.jpg)
|
(defaults to "$DKP/libnx/default_icon.jpg)
|
||||||
--nimCompilerArgs: STR Args to pass to the nim compiler
|
--nimCompilerArgs:STR Args to pass to the nim compiler
|
||||||
-h, --help show this help
|
-h, --help show this help
|
||||||
|
|
||||||
Note, single letter options that take an argument require a colon. E.g. -p:PATH.
|
Note, single letter options that take an argument require a colon. E.g. -p:PATH.
|
||||||
|
|
@ -234,6 +242,7 @@ proc processArgs() =
|
||||||
icon: "",
|
icon: "",
|
||||||
|
|
||||||
dkpPath: getEnv(dkpEnv),
|
dkpPath: getEnv(dkpEnv),
|
||||||
|
libnxPath: "",
|
||||||
|
|
||||||
compilerPath: "",
|
compilerPath: "",
|
||||||
toolsPath: "",
|
toolsPath: "",
|
||||||
|
|
@ -265,6 +274,8 @@ proc processArgs() =
|
||||||
putEnv(dkpEnv, val)
|
putEnv(dkpEnv, val)
|
||||||
of "devkitCompilerPath", "c":
|
of "devkitCompilerPath", "c":
|
||||||
buildInfo.compilerPath = val
|
buildInfo.compilerPath = val
|
||||||
|
of "libnxPath", "x":
|
||||||
|
buildInfo.libnxPath = val.sanitizePath()
|
||||||
of "output", "o":
|
of "output", "o":
|
||||||
buildInfo.outDir = val.sanitizePath()
|
buildInfo.outDir = val.sanitizePath()
|
||||||
of "tools", "t":
|
of "tools", "t":
|
||||||
|
|
@ -303,8 +314,8 @@ proc processArgs() =
|
||||||
of cmdEnd: assert(false) # cannot happen
|
of cmdEnd: assert(false) # cannot happen
|
||||||
|
|
||||||
if buildInfo.filename == "":
|
if buildInfo.filename == "":
|
||||||
# no filename has been given, so we show the help:
|
|
||||||
writeHelp()
|
writeHelp()
|
||||||
|
echo "filename argument was expected!"
|
||||||
quit(1)
|
quit(1)
|
||||||
|
|
||||||
if buildTypes.len == 0:
|
if buildTypes.len == 0:
|
||||||
|
|
@ -314,7 +325,7 @@ proc processArgs() =
|
||||||
buildInfo.name = buildInfo.filename.splitFile().name
|
buildInfo.name = buildInfo.filename.splitFile().name
|
||||||
|
|
||||||
if buildInfo.outDir == "":
|
if buildInfo.outDir == "":
|
||||||
buildInfo.outDir = "build"
|
buildInfo.outDir = "build" / buildInfo.name
|
||||||
|
|
||||||
if not dirExists buildInfo.outDir:
|
if not dirExists buildInfo.outDir:
|
||||||
createDir buildInfo.outDir
|
createDir buildInfo.outDir
|
||||||
|
|
@ -322,12 +333,33 @@ proc processArgs() =
|
||||||
|
|
||||||
if buildInfo.dkpPath == "":
|
if buildInfo.dkpPath == "":
|
||||||
buildInfo.dkpPath = getEnv(dkpEnv, "").sanitizePath()
|
buildInfo.dkpPath = getEnv(dkpEnv, "").sanitizePath()
|
||||||
if buildInfo.dkpPath == "" and not dkpEnv.existsEnv():
|
let exists = buildInfo.dkpPath.dirExists()
|
||||||
|
if buildInfo.dkpPath == "" and not dkpEnv.existsEnv() and exists:
|
||||||
writeHelp()
|
writeHelp()
|
||||||
raise newException(Exception, dkpEnv & " path must be set!")
|
raise newException(
|
||||||
|
Exception,
|
||||||
|
dkpEnv & " environment var must be set and be an existing path or " &
|
||||||
|
"--devkitProPath must be set in the command line arguments."
|
||||||
|
)
|
||||||
|
|
||||||
|
if buildInfo.libnxPath == "":
|
||||||
|
buildInfo.libnxPath = buildInfo.dkpPath / "libnx"
|
||||||
|
if not buildInfo.libnxPath.dirExists():
|
||||||
|
try:
|
||||||
|
buildInfo.libnxPath = execProc("nimble path libnx") / "src/libnx/wrapper/nx"
|
||||||
|
except Exception:
|
||||||
|
raise newException(Exception,
|
||||||
|
"Could not find a suitable libnx install. " &
|
||||||
|
"Make sure libnx is installed in $DEVKITPRO/libnx or " &
|
||||||
|
"you have --libnxPath set in the command line arguments.")
|
||||||
|
|
||||||
|
buildInfo.includes &= getEnv("SWITCH_INCLUDES") & " -I" & buildInfo.libnxPath / "include"
|
||||||
|
buildInfo.libs &= getEnv("SWITCH_LIBS")
|
||||||
|
buildInfo.libs &= " -specs=" & buildInfo.libnxPath / "switch.specs"
|
||||||
|
buildInfo.libs &= " -L" & buildInfo.libnxPath / "lib -lnx"
|
||||||
|
|
||||||
if buildInfo.icon == "":
|
if buildInfo.icon == "":
|
||||||
buildInfo.icon = buildInfo.dkpPath / "libnx/default_icon.jpg"
|
buildInfo.icon = buildInfo.libnxPath / "default_icon.jpg"
|
||||||
|
|
||||||
if buildInfo.compilerPath == "":
|
if buildInfo.compilerPath == "":
|
||||||
buildInfo.compilerPath = buildInfo.dkpPath / "devkitA64/bin"
|
buildInfo.compilerPath = buildInfo.dkpPath / "devkitA64/bin"
|
||||||
|
|
@ -335,10 +367,6 @@ proc processArgs() =
|
||||||
if buildInfo.toolsPath == "":
|
if buildInfo.toolsPath == "":
|
||||||
buildInfo.toolsPath = buildInfo.dkpPath / "tools/bin"
|
buildInfo.toolsPath = buildInfo.dkpPath / "tools/bin"
|
||||||
|
|
||||||
|
|
||||||
putEnv("SWITCH_LIBS", getEnv("SWITCH_LIBS") & " " & buildInfo.libs)
|
|
||||||
putEnv("SWITCH_INCLUDES", getEnv("SWITCH_INCLUDES") & " " & buildInfo.includes)
|
|
||||||
|
|
||||||
echo "Building: $#..." % buildInfo.filename
|
echo "Building: $#..." % buildInfo.filename
|
||||||
|
|
||||||
buildInfo.elfLocation = buildElf(buildInfo)
|
buildInfo.elfLocation = buildElf(buildInfo)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
author = "Joey Payne"
|
author = "Joey Payne"
|
||||||
description = "Nintendo Switch library libnx for Nim."
|
description = "Nintendo Switch library libnx for Nim."
|
||||||
license = "The Unlicense"
|
license = "The Unlicense"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue