deprecate install_tools.nims in favor of 'koch tools'; refs #4934

This commit is contained in:
Araq 2016-10-24 16:21:52 +02:00
commit 41f32f5fb6
2 changed files with 46 additions and 24 deletions

View file

@ -3,6 +3,8 @@ import ospaths
mode = ScriptMode.Verbose mode = ScriptMode.Verbose
echo "This script is deprecated. Use 'koch tools' instead."
if not dirExists"dist/nimble": if not dirExists"dist/nimble":
echo "[Error] This script only works for the tarball." echo "[Error] This script only works for the tarball."
else: else:
@ -11,8 +13,8 @@ else:
" dist/nimble/src/nimble.nim" " dist/nimble/src/nimble.nim"
let nimsugExe = "./bin/nimsuggest".toExe let nimsugExe = "./bin/nimsuggest".toExe
selfExec "c --noNimblePath -p:compiler -o:" & nimsugExe & selfExec "c --noNimblePath -d:release -p:compiler -o:" & nimsugExe &
" dist/nimsuggest/nimsuggest.nim" " dist/nimsuggest/nimsuggest.nim"
let nimgrepExe = "./bin/nimgrep".toExe let nimgrepExe = "./bin/nimgrep".toExe
selfExec "c -o:./bin/nimgrep tools/nimgrep.nim" selfExec "c -d:release -o:" & nimgrepExe & " tools/nimgrep.nim"

View file

@ -50,6 +50,7 @@ Possible Commands:
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 builds the Nimble tool nimble builds the Nimble tool
tools builds Nim related tools
Boot options: Boot options:
-d:release produce a release version of the compiler -d:release produce a release version of the compiler
-d:tinyc include the Tiny C backend (not supported on Windows) -d:tinyc include the Tiny C backend (not supported on Windows)
@ -89,6 +90,9 @@ proc exec(cmd: string, errorcode: int = QuitFailure, additionalPath = "") =
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode) if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
putEnv("PATH", prevPath) putEnv("PATH", prevPath)
proc nimexec(cmd: string) =
exec findNim() & " " & cmd
proc execCleanPath(cmd: string, proc execCleanPath(cmd: string,
additionalPath = ""; errorcode: int = QuitFailure) = additionalPath = ""; errorcode: int = QuitFailure) =
# simulate a poor man's virtual environment # simulate a poor man's virtual environment
@ -145,8 +149,9 @@ const
compileNimInst = "tools/niminst/niminst" compileNimInst = "tools/niminst/niminst"
proc csource(args: string) = proc csource(args: string) =
exec("$4 cc $1 -r $3 --var:version=$2 --var:mingw=none csource --main:compiler/nim.nim compiler/installer.ini $1" % nimexec(("cc $1 -r $3 --var:version=$2 --var:mingw=none csource " &
[args, VersionAsString, compileNimInst, findNim()]) "--main:compiler/nim.nim compiler/installer.ini $1") %
[args, VersionAsString, compileNimInst])
proc bundleNimbleSrc() = proc bundleNimbleSrc() =
## bunldeNimbleSrc() bundles a specific Nimble commit with the tarball. We ## bunldeNimbleSrc() bundles a specific Nimble commit with the tarball. We
@ -163,7 +168,7 @@ proc bundleNimbleExe() =
bundleNimbleSrc() bundleNimbleSrc()
# now compile Nimble and copy it to $nim/bin for the installer.ini # now compile Nimble and copy it to $nim/bin for the installer.ini
# to pick it up: # to pick it up:
exec(findNim() & " c dist/nimble/src/nimble.nim") nimexec("c dist/nimble/src/nimble.nim")
copyExe("dist/nimble/src/nimble".exe, "bin/nimble".exe) copyExe("dist/nimble/src/nimble".exe, "bin/nimble".exe)
proc buildNimble() = proc buildNimble() =
@ -180,7 +185,7 @@ proc buildNimble() =
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)
exec(findNim() & " c " & installDir / "src/nimble.nim") nimexec("c " & 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) =
@ -189,11 +194,12 @@ proc bundleNimsuggest(buildExe: bool) =
else: else:
exec("git clone https://github.com/nim-lang/nimsuggest.git dist/nimsuggest") exec("git clone https://github.com/nim-lang/nimsuggest.git dist/nimsuggest")
if buildExe: if buildExe:
exec(findNim() & " c --noNimblePath -p:compiler dist/nimsuggest/nimsuggest.nim") nimexec("c --noNimblePath -d:release -p:compiler dist/nimsuggest/nimsuggest.nim")
copyExe("dist/nimsuggest/nimsuggest".exe, "bin/nimsuggest".exe) copyExe("dist/nimsuggest/nimsuggest".exe, "bin/nimsuggest".exe)
removeFile("dist/nimsuggest/nimsuggest".exe)
proc bundleFinishExe() = proc bundleFinishExe() =
exec(findNim() & " c tools/finish.nim") nimexec("c tools/finish.nim")
copyExe("tools/finish".exe, "finish".exe) copyExe("tools/finish".exe, "finish".exe)
removeFile("tools/finish".exe) removeFile("tools/finish".exe)
@ -201,23 +207,38 @@ proc zip(args: string) =
bundleNimbleSrc() bundleNimbleSrc()
bundleNimsuggest(false) bundleNimsuggest(false)
bundleFinishExe() bundleFinishExe()
exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
[VersionAsString, compileNimInst, findNim()]) [VersionAsString, compileNimInst])
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" % exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" %
["tools/niminst/niminst".exe, VersionAsString]) ["tools/niminst/niminst".exe, VersionAsString])
proc xz(args: string) = proc xz(args: string) =
bundleNimbleSrc() bundleNimbleSrc()
bundleNimsuggest(false) bundleNimsuggest(false)
exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
[VersionAsString, compileNimInst, findNim()]) [VersionAsString, compileNimInst])
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim xz compiler/installer.ini" % exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim xz compiler/installer.ini" %
["tools" / "niminst" / "niminst".exe, VersionAsString]) ["tools" / "niminst" / "niminst".exe, VersionAsString])
proc buildTool(toolname, args: string) = proc buildTool(toolname, args: string) =
exec("$# cc $# $#" % [findNim(), args, toolname]) nimexec("cc $# $#" % [args, toolname])
copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe) copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe)
proc buildTools() =
if not dirExists"dist/nimble":
echo "[Error] 'koch tools' only works for the tarball."
else:
let nimbleExe = "bin/nimble".exe
nimexec "c --noNimblePath -p:compiler -o:" & nimbleExe &
" dist/nimble/src/nimble.nim"
let nimsugExe = "bin/nimsuggest".exe
nimexec "c --noNimblePath -p:compiler -d:release -o:" & nimsugExe &
" dist/nimsuggest/nimsuggest.nim"
let nimgrepExe = "bin/nimgrep".exe
nimexec "c -o:" & nimgrepExe & " tools/nimgrep.nim"
proc nsis(args: string) = proc nsis(args: string) =
bundleNimbleExe() bundleNimbleExe()
bundleNimsuggest(true) bundleNimsuggest(true)
@ -232,21 +253,21 @@ proc nsis(args: string) =
" nsis compiler/installer.ini") % [VersionAsString, $(sizeof(pointer)*8)]) " nsis compiler/installer.ini") % [VersionAsString, $(sizeof(pointer)*8)])
proc geninstall(args="") = proc geninstall(args="") =
exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini $#" % nimexec("cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini $#" %
[findNim(), compileNimInst, VersionAsString, args]) [compileNimInst, VersionAsString, args])
proc install(args: string) = proc install(args: string) =
geninstall() geninstall()
exec("sh ./install.sh $#" % args) exec("sh ./install.sh $#" % args)
proc web(args: string) = proc web(args: string) =
exec("$# js tools/dochack/dochack.nim" % findNim()) nimexec("js tools/dochack/dochack.nim")
exec("$# cc -r tools/nimweb.nim $# web/website.ini --putenv:nimversion=$#" % nimexec("cc -r tools/nimweb.nim $# web/website.ini --putenv:nimversion=$#" %
[findNim(), args, VersionAsString]) [args, VersionAsString])
proc website(args: string) = proc website(args: string) =
exec("$# cc -r tools/nimweb.nim $# --website web/website.ini --putenv:nimversion=$#" % nimexec("cc -r tools/nimweb.nim $# --website web/website.ini --putenv:nimversion=$#" %
[findNim(), args, VersionAsString]) [args, VersionAsString])
proc pdf(args="") = proc pdf(args="") =
exec("$# cc -r tools/nimweb.nim $# --pdf web/website.ini --putenv:nimversion=$#" % exec("$# cc -r tools/nimweb.nim $# --pdf web/website.ini --putenv:nimversion=$#" %
@ -336,7 +357,6 @@ proc removePattern(pattern: string) =
removeFile(f) removeFile(f)
proc clean(args: string) = proc clean(args: string) =
if existsFile("koch.dat"): removeFile("koch.dat")
removePattern("web/*.html") removePattern("web/*.html")
removePattern("doc/*.html") removePattern("doc/*.html")
cleanAux(getCurrentDir()) cleanAux(getCurrentDir())
@ -357,11 +377,10 @@ template `|`(a, b): string = (if a.len > 0: a else: b)
proc tests(args: string) = proc tests(args: string) =
# we compile the tester with taintMode:on to have a basic # we compile the tester with taintMode:on to have a basic
# taint mode test :-) # taint mode test :-)
let nimexe = findNim() nimexec "cc --taintMode:on tests/testament/tester"
exec nimexe & " cc --taintMode:on tests/testament/tester"
# Since tests take a long time (on my machine), and we want to defy Murhpys # Since tests take a long time (on my machine), and we want to defy Murhpys
# law - lets make sure the compiler really is freshly compiled! # law - lets make sure the compiler really is freshly compiled!
exec nimexe & " c --lib:lib -d:release --opt:speed compiler/nim.nim" nimexec "c --lib:lib -d:release --opt:speed compiler/nim.nim"
let tester = quoteShell(getCurrentDir() / "tests/testament/tester".exe) let tester = quoteShell(getCurrentDir() / "tests/testament/tester".exe)
let success = tryExec tester & " " & (args|"all") let success = tryExec tester & " " & (args|"all")
if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"): if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"):
@ -410,5 +429,6 @@ of cmdArgument:
of "temp": temp(op.cmdLineRest) of "temp": temp(op.cmdLineRest)
of "winrelease": winRelease() of "winrelease": winRelease()
of "nimble": buildNimble() of "nimble": buildNimble()
of "tools": buildTools()
else: showHelp() else: showHelp()
of cmdEnd: showHelp() of cmdEnd: showHelp()