diff options
author | Araq <rumpf_a@web.de> | 2017-01-03 22:09:39 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-01-03 22:09:39 +0100 |
commit | ef6029d3a9d72fa1a5631fc49f5f93832c63e3d5 (patch) | |
tree | d068e1a024a6dff6ab59a92b78c256d6eb5dd181 /koch.nim | |
parent | 8413c9f15ebd50a50cd2c668597161c0f197ec8c (diff) | |
download | Nim-ef6029d3a9d72fa1a5631fc49f5f93832c63e3d5.tar.gz |
koch.nim: use new nimble branch setup
Diffstat (limited to 'koch.nim')
-rw-r--r-- | koch.nim | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/koch.nim b/koch.nim index ccc30dd67..d06f7d809 100644 --- a/koch.nim +++ b/koch.nim @@ -23,7 +23,7 @@ when defined(i386) and defined(windows) and defined(vcc): import os, strutils, parseopt, osproc, streams -const VersionAsString = system.NimVersion #"0.10.2" +const VersionAsString = system.NimVersion const HelpText = """ @@ -54,8 +54,8 @@ Possible Commands: tests [options] run the testsuite temp options creates a temporary compiler for testing winrelease creates a release (for coredevs only) - nimble [--latest] builds the Nimble tool - tools [--latest] builds Nim related tools + nimble builds the Nimble tool + tools builds Nim related tools pushcsource push generated C sources to its repo! Only for devs! Boot options: -d:release produce a release version of the compiler @@ -75,6 +75,14 @@ proc exe(f: string): string = when defined(windows): result = result.replace('/','\\') +template withDir(dir, body) = + let old = getCurrentDir(dir) + try: + setCurrentDir(dir) + body + finally: + setCurrentdir(old) + proc findNim(): string = var nim = "nim".exe result = "bin" / nim @@ -159,23 +167,13 @@ proc csource(args: string) = "--main:compiler/nim.nim compiler/installer.ini $1") % [args, VersionAsString, compileNimInst]) -proc latestTaggedCommit(dir: string) = - let tags = execProcess("git --git-dir " & dir & "/.git tag -l v*").splitLines - var i = 1 - while tags[^i].len == 0: inc i - let tag = tags[^i] - doAssert tag.len > 0 - exec("git --git-dir " & dir & "/.git checkout -f " & tag) - proc bundleNimbleSrc() = ## bunldeNimbleSrc() bundles a specific Nimble commit with the tarball. We ## always bundle the latest official release. - if dirExists("dist/nimble/.git"): - exec("git --git-dir dist/nimble/.git checkout -f master") - exec("git --git-dir dist/nimble/.git pull") - else: + if not dirExists("dist/nimble/.git"): exec("git clone https://github.com/nim-lang/nimble.git dist/nimble") - latestTaggedCommit("dist/nimble") + exec("git --git-dir dist/nimble/.git checkout -f stable") + exec("git --git-dir dist/nimble/.git pull") proc bundleNimbleExe() = bundleNimbleSrc() @@ -186,13 +184,7 @@ proc bundleNimbleExe() = proc buildNimble(latest: bool) = var installDir = "dist/nimble" - if dirExists("dist/nimble/.git"): - if latest: - exec("git --git-dir dist/nimble/.git checkout -f master") - exec("git --git-dir dist/nimble/.git pull") - else: - bundleNimbleSrc() - else: + if not dirExists("dist/nimble/.git"): # if dist/nimble exist, but is not a git repo, don't mess with it: if dirExists(installDir): var id = 0 @@ -200,9 +192,12 @@ proc buildNimble(latest: bool) = inc id installDir = "dist/nimble" & $id exec("git clone https://github.com/nim-lang/nimble.git " & installDir) - if not latest: - latestTaggedCommit(installDir) - nimexec("c " & installDir / "src/nimble.nim") + if latest: + exec("git --git-dir " & installDir & "/.git checkout -f master") + else: + exec("git --git-dir " & installDir & ".git checkout -f stable") + exec("git --git-dir " & installDir & "/.git pull") + nimexec("c --noNimblePath -p:compiler " & installDir / "src/nimble.nim") copyExe(installDir / "src/nimble".exe, "bin/nimble".exe) proc bundleNimsuggest(buildExe: bool) = @@ -245,12 +240,7 @@ proc buildTools(latest: bool) = let nimgrepExe = "bin/nimgrep".exe nimexec "c -o:" & nimgrepExe & " tools/nimgrep.nim" - if dirExists"dist/nimble": - let nimbleExe = "bin/nimble".exe - nimexec "c --noNimblePath -p:compiler -o:" & nimbleExe & - " dist/nimble/src/nimble.nim" - else: - buildNimble(latest) + buildNimble(latest) proc nsis(args: string) = bundleNimbleExe() @@ -488,8 +478,8 @@ of cmdArgument: of "test", "tests": tests(op.cmdLineRest) of "temp": temp(op.cmdLineRest) of "winrelease": winRelease() - of "nimble": buildNimble(op.cmdLineRest == "--latest") - of "tools": buildTools(op.cmdLineRest == "--latest") + of "nimble": buildNimble(existsDir(".git")) + of "tools": buildTools(existsDir(".git")) of "pushcsource", "pushcsources": pushCsources() else: showHelp() of cmdEnd: showHelp() |