diff options
author | Araq <rumpf_a@web.de> | 2018-09-19 15:03:14 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-09-19 15:03:24 +0200 |
commit | 2e477979a41779d1fc22760a978cf38364151410 (patch) | |
tree | ad10278fb7141d34ac593676f3120ceac51872a0 /koch.nim | |
parent | d6c7787e8db2aa1d146e72e2ac1a89f18eeac2f7 (diff) | |
download | Nim-2e477979a41779d1fc22760a978cf38364151410.tar.gz |
koch: code cleanups, easier testing for 'testinstall' and 'winrelease'
Diffstat (limited to 'koch.nim')
-rw-r--r-- | koch.nim | 105 |
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 |