Add: static lib building mode #1
3 changed files with 45 additions and 11 deletions
|
|
@ -84,6 +84,7 @@ Options:
|
||||||
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")
|
||||||
|
-S, --staticLib Build static library ("*.a")
|
||||||
-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",
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ type
|
||||||
|
|
||||||
nimCompilerArgs: string
|
nimCompilerArgs: string
|
||||||
|
|
||||||
|
type OperationModes = enum default, staticLib
|
||||||
|
|
||||||
proc execProc(command: string, verbose: bool=false): string {.discardable.} =
|
proc execProc(command: string, verbose: bool=false): string {.discardable.} =
|
||||||
|
|
||||||
|
|
@ -65,7 +66,7 @@ proc execProc(command: string, verbose: bool=false): string {.discardable.} =
|
||||||
)
|
)
|
||||||
|
|
||||||
proc writeVersion() =
|
proc writeVersion() =
|
||||||
echo "Switch build version $version." % ["version", "0.1.3"]
|
echo "Switch build version $version." % ["version", "0.1.4"]
|
||||||
|
|
||||||
proc writeHelp() =
|
proc writeHelp() =
|
||||||
writeVersion()
|
writeVersion()
|
||||||
|
|
@ -91,6 +92,7 @@ Options:
|
||||||
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")
|
||||||
|
-S, --staticLib Build static library ("*.a")
|
||||||
-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",
|
||||||
|
|
@ -174,6 +176,30 @@ proc buildLst(buildInfo: BuildInfo): string =
|
||||||
|
|
||||||
execProc cmd, buildInfo.verbose
|
execProc cmd, buildInfo.verbose
|
||||||
|
|
||||||
|
proc buildStaticLib(buildInfo: BuildInfo): string =
|
||||||
|
echo "Building static lib file..."
|
||||||
|
var cmd = "nim $args c " &
|
||||||
|
"--os:nintendoswitch " & buildInfo.filename.quoteShell
|
||||||
|
|
||||||
|
result = buildInfo.outDir/"lib" & buildInfo.name & ".a"
|
||||||
|
|
||||||
|
var args = " --out=" & quoteShell(result)
|
||||||
|
args &= " --nimcache=nimcache" / buildInfo.name.quoteShell
|
||||||
|
if buildInfo.release:
|
||||||
|
args &= " -d:release"
|
||||||
|
if buildInfo.force:
|
||||||
|
args &= " -f"
|
||||||
|
if buildInfo.libs != "":
|
||||||
|
args &= " --passL=" & buildInfo.libs.quoteShell
|
||||||
|
if buildInfo.includes != "":
|
||||||
|
args &= " --passC=" & buildInfo.includes.quoteShell
|
||||||
|
args &= " " & "--app:staticlib"
|
||||||
|
args &= " " & "--noMain"
|
||||||
|
args &= " " & buildInfo.nimCompilerArgs
|
||||||
|
|
||||||
|
cmd = cmd % ["args", args]
|
||||||
|
execProc cmd, buildInfo.verbose
|
||||||
|
|
||||||
proc buildNacp(buildInfo: BuildInfo): string =
|
proc buildNacp(buildInfo: BuildInfo): string =
|
||||||
let
|
let
|
||||||
name = buildInfo.name
|
name = buildInfo.name
|
||||||
|
|
@ -267,7 +293,9 @@ proc processArgs() =
|
||||||
nimCompilerArgs: ""
|
nimCompilerArgs: ""
|
||||||
)
|
)
|
||||||
|
|
||||||
var buildTypes: seq[string] = @[]
|
var
|
||||||
|
buildTypes: seq[string] = @[]
|
||||||
|
mode = OperationModes.default
|
||||||
|
|
||||||
|
|
||||||
for kind, key, val in getopt():
|
for kind, key, val in getopt():
|
||||||
|
|
@ -287,6 +315,8 @@ proc processArgs() =
|
||||||
buildInfo.outDir = val.expandFilename()
|
buildInfo.outDir = val.expandFilename()
|
||||||
of "tools", "t":
|
of "tools", "t":
|
||||||
buildInfo.toolsPath = val.expandFilename()
|
buildInfo.toolsPath = val.expandFilename()
|
||||||
|
of "staticLib", "S":
|
||||||
|
mode = OperationModes.staticLib
|
||||||
of "build", "b":
|
of "build", "b":
|
||||||
buildTypes.add(val)
|
buildTypes.add(val)
|
||||||
of "libs", "l":
|
of "libs", "l":
|
||||||
|
|
@ -374,15 +404,18 @@ proc processArgs() =
|
||||||
buildInfo.toolsPath = buildInfo.dkpPath / "tools/bin"
|
buildInfo.toolsPath = buildInfo.dkpPath / "tools/bin"
|
||||||
|
|
||||||
echo "Building: $#..." % buildInfo.filename
|
echo "Building: $#..." % buildInfo.filename
|
||||||
|
case mode:
|
||||||
|
of OperationModes.default:
|
||||||
|
buildInfo.elfLocation = buildElf(buildInfo)
|
||||||
|
|
||||||
buildInfo.elfLocation = buildElf(buildInfo)
|
# Build the files
|
||||||
|
for buildType in buildTypes:
|
||||||
# Build the files
|
let path = build(buildType, buildInfo)
|
||||||
for buildType in buildTypes:
|
echo "\nBuilt:"
|
||||||
let path = build(buildType, buildInfo)
|
echo path
|
||||||
echo "\nBuilt:"
|
echo ""
|
||||||
echo path
|
of OperationModes.staticLib:
|
||||||
echo ""
|
discard buildStaticLib(buildInfo)
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
processArgs()
|
processArgs()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
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