summary refs log tree commit diff stats
path: root/koch.nim
diff options
context:
space:
mode:
Diffstat (limited to 'koch.nim')
-rw-r--r--koch.nim105
1 files changed, 56 insertions, 49 deletions
diff --git a/koch.nim b/koch.nim
index 0c24f70de..34b980912 100644
--- a/koch.nim
+++ b/koch.nim
@@ -16,9 +16,9 @@ when defined(gcc) and defined(windows):
     {.link: "icons/koch_icon.o".}
 
 when defined(amd64) and defined(windows) and defined(vcc):
-  {.link: "icons/koch-amd64-windows-vcc.res" .}
+  {.link: "icons/koch-amd64-windows-vcc.res".}
 when defined(i386) and defined(windows) and defined(vcc):
-  {.link: "icons/koch-i386-windows-vcc.res" .}
+  {.link: "icons/koch-i386-windows-vcc.res".}
 
 import
   os, strutils, parseopt, osproc, streams
@@ -40,6 +40,7 @@ Usage:
   koch [options] command [options for command]
 Options:
   --help, -h               shows this help and quits
+  --latest                 bundle the installers with a bleeding edge Nimble
 Possible Commands:
   boot [options]           bootstraps with given command line options
   distrohelper [bindir]    helper for distro packagers
@@ -98,17 +99,18 @@ proc csource(args: string) =
            "--main:compiler/nim.nim compiler/installer.ini $1") %
        [args, VersionAsString, compileNimInst])
 
-proc bundleNimbleSrc() =
+proc bundleNimbleSrc(latest: bool) =
   ## bunldeNimbleSrc() bundles a specific Nimble commit with the tarball. We
   ## always bundle the latest official release.
   if not dirExists("dist/nimble/.git"):
     exec("git clone https://github.com/nim-lang/nimble.git dist/nimble")
-  withDir("dist/nimble"):
-    exec("git checkout -f stable")
-    exec("git pull")
+  if not latest:
+    withDir("dist/nimble"):
+      exec("git checkout -f stable")
+      exec("git pull")
 
-proc bundleNimbleExe() =
-  bundleNimbleSrc()
+proc bundleNimbleExe(latest: bool) =
+  bundleNimbleSrc(latest)
   # now compile Nimble and copy it to $nim/bin for the installer.ini
   # to pick it up:
   nimexec("c -d:release --nilseqs:on dist/nimble/src/nimble.nim")
@@ -162,8 +164,8 @@ proc bundleWinTools() =
     nimexec(r"c --cc:vcc --app:gui -o:bin\downloader.exe -d:ssl --noNimblePath " &
             r"--path:..\ui tools\downloader.nim")
 
-proc zip(args: string) =
-  bundleNimbleExe()
+proc zip(latest: bool; args: string) =
+  bundleNimbleExe(latest)
   bundleNimsuggest(true)
   bundleWinTools()
   nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
@@ -178,9 +180,9 @@ proc ensureCleanGit() =
    if status != 0:
      quit "Not a clean git repository; 'git diff' returned non-zero!"
 
-proc xz(args: string) =
+proc xz(latest: bool; args: string) =
   ensureCleanGit()
-  bundleNimbleSrc()
+  bundleNimbleSrc(latest)
   bundleNimsuggest(false)
   nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
        [VersionAsString, compileNimInst])
@@ -202,8 +204,8 @@ proc buildTools(latest: bool) =
 
   buildNimble(latest)
 
-proc nsis(args: string) =
-  bundleNimbleExe()
+proc nsis(latest: bool; args: string) =
+  bundleNimbleExe(latest)
   bundleNimsuggest(true)
   bundleWinTools()
   # make sure we have generated the niminst executables:
@@ -349,7 +351,7 @@ proc winReleaseArch(arch: string) =
     # determine which mingw link to put in the NSIS installer.
     nimexec "c --cpu:$# koch" % cpu
     exec "koch boot -d:release --cpu:$#" % cpu
-    exec "koch zip -d:release"
+    exec "koch --latest zip -d:release"
     overwriteFile r"build\nim-$#.zip" % VersionAsString,
              r"web\upload\download\nim-$#_x$#.zip" % [VersionAsString, arch]
 
@@ -449,7 +451,7 @@ proc pushCsources() =
 
 proc testUnixInstall(cmdLineRest: string) =
   csource("-d:release " & cmdLineRest)
-  xz(cmdLineRest)
+  xz(false, cmdLineRest)
   let oldCurrentDir = getCurrentDir()
   try:
     let destDir = getTempDir()
@@ -468,7 +470,7 @@ proc testUnixInstall(cmdLineRest: string) =
       # check the docs build:
       execCleanPath("./koch docs", destDir / "bin")
       # check nimble builds:
-      execCleanPath("./koch testtools")
+      execCleanPath("./koch --latest tools")
       # check the tests work:
       putEnv("NIM_EXE_NOT_IN_PATH", "NOT_IN_PATH")
       execCleanPath("./koch tests", destDir / "bin")
@@ -506,35 +508,40 @@ proc showHelp() =
 
 when isMainModule:
   var op = initOptParser()
-  op.next()
-  case op.kind
-  of cmdLongOption, cmdShortOption: showHelp()
-  of cmdArgument:
-    case normalize(op.key)
-    of "boot": boot(op.cmdLineRest)
-    of "clean": clean(op.cmdLineRest)
-    of "doc", "docs": buildDocs(op.cmdLineRest)
-    of "doc0", "docs0":
-      # undocumented command for Araq-the-merciful:
-      buildDocs(op.cmdLineRest & gaCode)
-    of "pdf": buildPdfDoc(op.cmdLineRest, "doc/pdf")
-    of "csource", "csources": csource(op.cmdLineRest)
-    of "zip": zip(op.cmdLineRest)
-    of "xz": xz(op.cmdLineRest)
-    of "nsis": nsis(op.cmdLineRest)
-    of "geninstall": geninstall(op.cmdLineRest)
-    of "distrohelper": geninstall()
-    of "install": install(op.cmdLineRest)
-    of "testinstall": testUnixInstall(op.cmdLineRest)
-    of "test", "tests": tests(op.cmdLineRest)
-    of "temp": temp(op.cmdLineRest)
-    of "xtemp": xtemp(op.cmdLineRest)
-    of "wintools": bundleWinTools()
-    of "nimble": buildNimble(existsDir(".git"))
-    of "nimsuggest": bundleNimsuggest(buildExe=true)
-    of "tools": buildTools(existsDir(".git"))
-    of "testtools": buildTools(true)
-    of "pushcsource", "pushcsources": pushCsources()
-    of "valgrind": valgrind(op.cmdLineRest)
-    else: showHelp()
-  of cmdEnd: showHelp()
+  var latest = false
+  while true:
+    op.next()
+    case op.kind
+    of cmdLongOption, cmdShortOption:
+      case normalize(op.key)
+      of "latest": latest = true
+      else: showHelp()
+    of cmdArgument:
+      case normalize(op.key)
+      of "boot": boot(op.cmdLineRest)
+      of "clean": clean(op.cmdLineRest)
+      of "doc", "docs": buildDocs(op.cmdLineRest)
+      of "doc0", "docs0":
+        # undocumented command for Araq-the-merciful:
+        buildDocs(op.cmdLineRest & gaCode)
+      of "pdf": buildPdfDoc(op.cmdLineRest, "doc/pdf")
+      of "csource", "csources": csource(op.cmdLineRest)
+      of "zip": zip(latest, op.cmdLineRest)
+      of "xz": xz(latest, op.cmdLineRest)
+      of "nsis": nsis(latest, op.cmdLineRest)
+      of "geninstall": geninstall(op.cmdLineRest)
+      of "distrohelper": geninstall()
+      of "install": install(op.cmdLineRest)
+      of "testinstall": testUnixInstall(op.cmdLineRest)
+      of "test", "tests": tests(op.cmdLineRest)
+      of "temp": temp(op.cmdLineRest)
+      of "xtemp": xtemp(op.cmdLineRest)
+      of "wintools": bundleWinTools()
+      of "nimble": buildNimble(existsDir(".git") or latest)
+      of "nimsuggest": bundleNimsuggest(buildExe=true)
+      of "tools": buildTools(existsDir(".git") or latest)
+      of "pushcsource", "pushcsources": pushCsources()
+      of "valgrind": valgrind(op.cmdLineRest)
+      else: showHelp()
+      break
+    of cmdEnd: break
' href='#n430'>430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547