summary refs log tree commit diff stats
path: root/koch.nim
diff options
context:
space:
mode:
authorIvan Bobev <bobeff@gmail.com>2019-06-28 19:06:43 +0300
committerAndreas Rumpf <rumpf_a@web.de>2019-06-28 18:06:43 +0200
commit5be5bf0222535d2096d43517aa61b2b2e8781651 (patch)
treeb31bceb896ed6e67a231244665c0d8f0ca7859ed /koch.nim
parent284a8cb58ac8abee54d7ed2ba95c82ad9179004f (diff)
downloadNim-5be5bf0222535d2096d43517aa61b2b2e8781651.tar.gz
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
Diffstat (limited to 'koch.nim')
-rw-r--r--koch.nim80
1 files changed, 44 insertions, 36 deletions
diff --git a/koch.nim b/koch.nim
index 9f2e23290..ac1388d9e 100644
--- a/koch.nim
+++ b/koch.nim
@@ -121,12 +121,13 @@ proc csource(args: string) =
            "--main:compiler/nim.nim compiler/installer.ini $1") %
        [args, VersionAsString, compileNimInst])
 
-proc bundleC2nim() =
+proc bundleC2nim(args: string) =
   if not dirExists("dist/c2nim/.git"):
     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"):
     exec("git clone https://github.com/nim-lang/nimble.git dist/nimble")
   if not latest:
@@ -134,9 +135,10 @@ proc bundleNimbleExe(latest: bool) =
       exec("git fetch")
       exec("git checkout " & NimbleStableCommit)
   # 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
   # with the tarball:
   var installDir = "dist/nimble"
@@ -157,29 +159,32 @@ proc buildNimble(latest: bool) =
       else:
         exec("git fetch")
         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() =
-  nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", options = "-d:release -d:danger")
+proc bundleNimsuggest(args: string) =
+  nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim",
+                 options = "-d:release -d:danger " & args)
 
-proc buildVccTool() =
-  nimCompileFold("Compile Vcc", "tools/vccexe/vccexe.nim")
+proc buildVccTool(args: string) =
+  nimCompileFold("Compile Vcc", "tools/vccexe/vccexe.nim ", options = args)
 
-proc bundleWinTools() =
-  nimCompile("tools/finish.nim", outputDir = "")
+proc bundleWinTools(args: string) =
+  nimCompile("tools/finish.nim", outputDir = "", options = args)
 
-  buildVccTool()
-  nimCompile("tools/nimgrab.nim", options = "-d:ssl")
-  nimCompile("tools/nimgrep.nim")
-  bundleC2nim()
+  buildVccTool(args)
+  nimCompile("tools/nimgrab.nim", options = "-d:ssl " & args)
+  nimCompile("tools/nimgrep.nim", options = args)
+  bundleC2nim(args)
   when false:
     # 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) =
-  bundleNimbleExe(latest)
-  bundleNimsuggest()
-  bundleWinTools()
+  bundleNimbleExe(latest, args)
+  bundleNimsuggest(args)
+  bundleWinTools(args)
   nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
        [VersionAsString, compileNimInst])
   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])
   copyFile(dest="bin" / splitFile(toolname).name.exe, source=toolname.exe)
 
-proc buildTools() =
-  bundleNimsuggest()
-  nimCompileFold("Compile nimgrep", "tools/nimgrep.nim", options = "-d:release")
-  when defined(windows): buildVccTool()
-  nimCompileFold("Compile nimpretty", "nimpretty/nimpretty.nim", options = "-d:release")
-  nimCompileFold("Compile nimfind", "tools/nimfind.nim", options = "-d:release")
+proc buildTools(args: string = "") =
+  bundleNimsuggest(args)
+  nimCompileFold("Compile nimgrep", "tools/nimgrep.nim",
+                 options = "-d:release " & args)
+  when defined(windows): buildVccTool(args)
+  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) =
-  bundleNimbleExe(latest)
-  bundleNimsuggest()
-  bundleWinTools()
+  bundleNimbleExe(latest, args)
+  bundleNimsuggest(args)
+  bundleWinTools(args)
   # make sure we have generated the niminst executables:
   buildTool("tools/niminst/niminst", args)
   #buildTool("tools/nimgrep", args)
@@ -603,17 +611,17 @@ when isMainModule:
       of "test", "tests": tests(op.cmdLineRest)
       of "temp": temp(op.cmdLineRest)
       of "xtemp": xtemp(op.cmdLineRest)
-      of "wintools": bundleWinTools()
-      of "nimble": buildNimble(latest)
-      of "nimsuggest": bundleNimsuggest()
+      of "wintools": bundleWinTools(op.cmdLineRest)
+      of "nimble": buildNimble(latest, op.cmdLineRest)
+      of "nimsuggest": bundleNimsuggest(op.cmdLineRest)
       of "toolsnonimble":
-        buildTools()
+        buildTools(op.cmdLineRest)
       of "tools":
-        buildTools()
-        buildNimble(latest)
+        buildTools(op.cmdLineRest)
+        buildNimble(latest, op.cmdLineRest)
       of "pushcsource", "pushcsources": pushCsources()
       of "valgrind": valgrind(op.cmdLineRest)
-      of "c2nim": bundleC2nim()
+      of "c2nim": bundleC2nim(op.cmdLineRest)
       else: showHelp()
       break
     of cmdEnd: break