koch.nim: use new nimble branch setup
This commit is contained in:
parent
8413c9f15e
commit
ef6029d3a9
1 changed files with 24 additions and 34 deletions
58
koch.nim
58
koch.nim
|
|
@ -23,7 +23,7 @@ when defined(i386) and defined(windows) and defined(vcc):
|
||||||
import
|
import
|
||||||
os, strutils, parseopt, osproc, streams
|
os, strutils, parseopt, osproc, streams
|
||||||
|
|
||||||
const VersionAsString = system.NimVersion #"0.10.2"
|
const VersionAsString = system.NimVersion
|
||||||
|
|
||||||
const
|
const
|
||||||
HelpText = """
|
HelpText = """
|
||||||
|
|
@ -54,8 +54,8 @@ Possible Commands:
|
||||||
tests [options] run the testsuite
|
tests [options] run the testsuite
|
||||||
temp options creates a temporary compiler for testing
|
temp options creates a temporary compiler for testing
|
||||||
winrelease creates a release (for coredevs only)
|
winrelease creates a release (for coredevs only)
|
||||||
nimble [--latest] builds the Nimble tool
|
nimble builds the Nimble tool
|
||||||
tools [--latest] builds Nim related tools
|
tools builds Nim related tools
|
||||||
pushcsource push generated C sources to its repo! Only for devs!
|
pushcsource push generated C sources to its repo! Only for devs!
|
||||||
Boot options:
|
Boot options:
|
||||||
-d:release produce a release version of the compiler
|
-d:release produce a release version of the compiler
|
||||||
|
|
@ -75,6 +75,14 @@ proc exe(f: string): string =
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
result = result.replace('/','\\')
|
result = result.replace('/','\\')
|
||||||
|
|
||||||
|
template withDir(dir, body) =
|
||||||
|
let old = getCurrentDir(dir)
|
||||||
|
try:
|
||||||
|
setCurrentDir(dir)
|
||||||
|
body
|
||||||
|
finally:
|
||||||
|
setCurrentdir(old)
|
||||||
|
|
||||||
proc findNim(): string =
|
proc findNim(): string =
|
||||||
var nim = "nim".exe
|
var nim = "nim".exe
|
||||||
result = "bin" / nim
|
result = "bin" / nim
|
||||||
|
|
@ -159,23 +167,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 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() =
|
proc bundleNimbleSrc() =
|
||||||
## bunldeNimbleSrc() bundles a specific Nimble commit with the tarball. We
|
## bunldeNimbleSrc() bundles a specific Nimble commit with the tarball. We
|
||||||
## always bundle the latest official release.
|
## always bundle the latest official release.
|
||||||
if dirExists("dist/nimble/.git"):
|
if not dirExists("dist/nimble/.git"):
|
||||||
exec("git --git-dir dist/nimble/.git checkout -f master")
|
|
||||||
exec("git --git-dir dist/nimble/.git pull")
|
|
||||||
else:
|
|
||||||
exec("git clone https://github.com/nim-lang/nimble.git dist/nimble")
|
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() =
|
proc bundleNimbleExe() =
|
||||||
bundleNimbleSrc()
|
bundleNimbleSrc()
|
||||||
|
|
@ -186,13 +184,7 @@ proc bundleNimbleExe() =
|
||||||
|
|
||||||
proc buildNimble(latest: bool) =
|
proc buildNimble(latest: bool) =
|
||||||
var installDir = "dist/nimble"
|
var installDir = "dist/nimble"
|
||||||
if dirExists("dist/nimble/.git"):
|
if not 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 dist/nimble exist, but is not a git repo, don't mess with it:
|
# if dist/nimble exist, but is not a git repo, don't mess with it:
|
||||||
if dirExists(installDir):
|
if dirExists(installDir):
|
||||||
var id = 0
|
var id = 0
|
||||||
|
|
@ -200,9 +192,12 @@ proc buildNimble(latest: bool) =
|
||||||
inc id
|
inc id
|
||||||
installDir = "dist/nimble" & $id
|
installDir = "dist/nimble" & $id
|
||||||
exec("git clone https://github.com/nim-lang/nimble.git " & installDir)
|
exec("git clone https://github.com/nim-lang/nimble.git " & installDir)
|
||||||
if not latest:
|
if latest:
|
||||||
latestTaggedCommit(installDir)
|
exec("git --git-dir " & installDir & "/.git checkout -f master")
|
||||||
nimexec("c " & installDir / "src/nimble.nim")
|
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)
|
copyExe(installDir / "src/nimble".exe, "bin/nimble".exe)
|
||||||
|
|
||||||
proc bundleNimsuggest(buildExe: bool) =
|
proc bundleNimsuggest(buildExe: bool) =
|
||||||
|
|
@ -245,12 +240,7 @@ proc buildTools(latest: bool) =
|
||||||
|
|
||||||
let nimgrepExe = "bin/nimgrep".exe
|
let nimgrepExe = "bin/nimgrep".exe
|
||||||
nimexec "c -o:" & nimgrepExe & " tools/nimgrep.nim"
|
nimexec "c -o:" & nimgrepExe & " tools/nimgrep.nim"
|
||||||
if dirExists"dist/nimble":
|
buildNimble(latest)
|
||||||
let nimbleExe = "bin/nimble".exe
|
|
||||||
nimexec "c --noNimblePath -p:compiler -o:" & nimbleExe &
|
|
||||||
" dist/nimble/src/nimble.nim"
|
|
||||||
else:
|
|
||||||
buildNimble(latest)
|
|
||||||
|
|
||||||
proc nsis(args: string) =
|
proc nsis(args: string) =
|
||||||
bundleNimbleExe()
|
bundleNimbleExe()
|
||||||
|
|
@ -488,8 +478,8 @@ of cmdArgument:
|
||||||
of "test", "tests": tests(op.cmdLineRest)
|
of "test", "tests": tests(op.cmdLineRest)
|
||||||
of "temp": temp(op.cmdLineRest)
|
of "temp": temp(op.cmdLineRest)
|
||||||
of "winrelease": winRelease()
|
of "winrelease": winRelease()
|
||||||
of "nimble": buildNimble(op.cmdLineRest == "--latest")
|
of "nimble": buildNimble(existsDir(".git"))
|
||||||
of "tools": buildTools(op.cmdLineRest == "--latest")
|
of "tools": buildTools(existsDir(".git"))
|
||||||
of "pushcsource", "pushcsources": pushCsources()
|
of "pushcsource", "pushcsources": pushCsources()
|
||||||
else: showHelp()
|
else: showHelp()
|
||||||
of cmdEnd: showHelp()
|
of cmdEnd: showHelp()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue