Pass additional koch options to the nim compiler (#11615)

Add possibility when "koch tools" command is used, nim compiler options
to be passed. The current options are kept and the new user specified
options will be added to the end of the command line if present.

Example:
> koch --latest tools -d:danger --debugInfo --lineDir:on
bin\nim.exe c -o:bin\nimsuggest.exe -d:release -d:danger -d:danger
 --debugInfo --lineDir:on nimsuggest/nimsuggest.nim
...
bin\nim.exe c -o:bin\nimgrep.exe -d:release -d:danger --debugInfo
 --lineDir:on tools/nimgrep.nim
...
bin\nim.exe c -o:bin\vccexe.exe -d:danger --debugInfo --lineDir:on
 tools/vccexe/vccexe.nim
...
bin\nim.exe c -o:bin\nimpretty.exe -d:release -d:danger --debugInfo
 --lineDir:on nimpretty/nimpretty.nim
...
bin\nim.exe c -o:bin\nimfind.exe -d:release -d:danger --debugInfo
 --lineDir:on tools/nimfind.nim
...
bin\nim.exe c -o:bin\nimble.exe --noNimblePath --nilseqs:on -d:release
 -d:danger --debugInfo --lineDir:on dist\nimble\src\nimble.nim
This commit is contained in:
Ivan Bobev 2019-06-28 19:06:43 +03:00 • committed by Andreas Rumpf
commit 5be5bf0222

View file

@ -121,12 +121,13 @@ proc csource(args: string) =
"--main:compiler/nim.nim compiler/installer.ini $1") % "--main:compiler/nim.nim compiler/installer.ini $1") %
[args, VersionAsString, compileNimInst]) [args, VersionAsString, compileNimInst])
proc bundleC2nim() = proc bundleC2nim(args: string) =
if not dirExists("dist/c2nim/.git"): if not dirExists("dist/c2nim/.git"):
exec("git clone https://github.com/nim-lang/c2nim.git dist/c2nim") exec("git clone https://github.com/nim-lang/c2nim.git dist/c2nim")
nimCompile("dist/c2nim/c2nim", options = "--noNimblePath --path:.") nimCompile("dist/c2nim/c2nim",
options = "--noNimblePath --path:. " & args)
proc bundleNimbleExe(latest: bool) = proc bundleNimbleExe(latest: bool, args: string) =
if not dirExists("dist/nimble/.git"): if not dirExists("dist/nimble/.git"):
exec("git clone https://github.com/nim-lang/nimble.git dist/nimble") exec("git clone https://github.com/nim-lang/nimble.git dist/nimble")
if not latest: if not latest:
@ -134,9 +135,10 @@ proc bundleNimbleExe(latest: bool) =
exec("git fetch") exec("git fetch")
exec("git checkout " & NimbleStableCommit) exec("git checkout " & NimbleStableCommit)
# installer.ini expects it under $nim/bin # installer.ini expects it under $nim/bin
nimCompile("dist/nimble/src/nimble.nim", options = "-d:release --nilseqs:on") nimCompile("dist/nimble/src/nimble.nim",
options = "-d:release --nilseqs:on " & args)
proc buildNimble(latest: bool) = proc buildNimble(latest: bool, args: string) =
# if koch is used for a tar.xz, build the dist/nimble we shipped # if koch is used for a tar.xz, build the dist/nimble we shipped
# with the tarball: # with the tarball:
var installDir = "dist/nimble" var installDir = "dist/nimble"
@ -157,29 +159,32 @@ proc buildNimble(latest: bool) =
else: else:
exec("git fetch") exec("git fetch")
exec("git checkout " & NimbleStableCommit) exec("git checkout " & NimbleStableCommit)
nimCompile(installDir / "src/nimble.nim", options = "--noNimblePath --nilseqs:on -d:release") nimCompile(installDir / "src/nimble.nim",
options = "--noNimblePath --nilseqs:on -d:release " & args)
proc bundleNimsuggest() = proc bundleNimsuggest(args: string) =
nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", options = "-d:release -d:danger") nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim",
options = "-d:release -d:danger " & args)
proc buildVccTool() = proc buildVccTool(args: string) =
nimCompileFold("Compile Vcc", "tools/vccexe/vccexe.nim") nimCompileFold("Compile Vcc", "tools/vccexe/vccexe.nim ", options = args)
proc bundleWinTools() = proc bundleWinTools(args: string) =
nimCompile("tools/finish.nim", outputDir = "") nimCompile("tools/finish.nim", outputDir = "", options = args)
buildVccTool() buildVccTool(args)
nimCompile("tools/nimgrab.nim", options = "-d:ssl") nimCompile("tools/nimgrab.nim", options = "-d:ssl " & args)
nimCompile("tools/nimgrep.nim") nimCompile("tools/nimgrep.nim", options = args)
bundleC2nim() bundleC2nim(args)
when false: when false:
# not yet a tool worth including # not yet a tool worth including
nimCompile(r"tools\downloader.nim", options = r"--cc:vcc --app:gui -d:ssl --noNimblePath --path:..\ui") nimCompile(r"tools\downloader.nim",
options = r"--cc:vcc --app:gui -d:ssl --noNimblePath --path:..\ui " & args)
proc zip(latest: bool; args: string) = proc zip(latest: bool; args: string) =
bundleNimbleExe(latest) bundleNimbleExe(latest, args)
bundleNimsuggest() bundleNimsuggest(args)
bundleWinTools() bundleWinTools(args)
nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
[VersionAsString, compileNimInst]) [VersionAsString, compileNimInst])
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" % exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" %
@ -203,17 +208,20 @@ proc buildTool(toolname, args: string) =
nimexec("cc $# $#" % [args, toolname]) nimexec("cc $# $#" % [args, toolname])
copyFile(dest="bin" / splitFile(toolname).name.exe, source=toolname.exe) copyFile(dest="bin" / splitFile(toolname).name.exe, source=toolname.exe)
proc buildTools() = proc buildTools(args: string = "") =
bundleNimsuggest() bundleNimsuggest(args)
nimCompileFold("Compile nimgrep", "tools/nimgrep.nim", options = "-d:release") nimCompileFold("Compile nimgrep", "tools/nimgrep.nim",
when defined(windows): buildVccTool() options = "-d:release " & args)
nimCompileFold("Compile nimpretty", "nimpretty/nimpretty.nim", options = "-d:release") when defined(windows): buildVccTool(args)
nimCompileFold("Compile nimfind", "tools/nimfind.nim", options = "-d:release") nimCompileFold("Compile nimpretty", "nimpretty/nimpretty.nim",
options = "-d:release " & args)
nimCompileFold("Compile nimfind", "tools/nimfind.nim",
options = "-d:release " & args)
proc nsis(latest: bool; args: string) = proc nsis(latest: bool; args: string) =
bundleNimbleExe(latest) bundleNimbleExe(latest, args)
bundleNimsuggest() bundleNimsuggest(args)
bundleWinTools() bundleWinTools(args)
# make sure we have generated the niminst executables: # make sure we have generated the niminst executables:
buildTool("tools/niminst/niminst", args) buildTool("tools/niminst/niminst", args)
#buildTool("tools/nimgrep", args) #buildTool("tools/nimgrep", args)
@ -603,17 +611,17 @@ when isMainModule:
of "test", "tests": tests(op.cmdLineRest) of "test", "tests": tests(op.cmdLineRest)
of "temp": temp(op.cmdLineRest) of "temp": temp(op.cmdLineRest)
of "xtemp": xtemp(op.cmdLineRest) of "xtemp": xtemp(op.cmdLineRest)
of "wintools": bundleWinTools() of "wintools": bundleWinTools(op.cmdLineRest)
of "nimble": buildNimble(latest) of "nimble": buildNimble(latest, op.cmdLineRest)
of "nimsuggest": bundleNimsuggest() of "nimsuggest": bundleNimsuggest(op.cmdLineRest)
of "toolsnonimble": of "toolsnonimble":
buildTools() buildTools(op.cmdLineRest)
of "tools": of "tools":
buildTools() buildTools(op.cmdLineRest)
buildNimble(latest) buildNimble(latest, op.cmdLineRest)
of "pushcsource", "pushcsources": pushCsources() of "pushcsource", "pushcsources": pushCsources()
of "valgrind": valgrind(op.cmdLineRest) of "valgrind": valgrind(op.cmdLineRest)
of "c2nim": bundleC2nim() of "c2nim": bundleC2nim(op.cmdLineRest)
else: showHelp() else: showHelp()
break break
of cmdEnd: break of cmdEnd: break