fixes #10039 : CI now runs buildTools (eg, nimfind wasn't being compiled before); refactoring (#10242)

This commit is contained in:
Timothee Cour 2019-01-10 00:35:37 -08:00 • committed by Andreas Rumpf
commit d2b95cb476
2 changed files with 34 additions and 28 deletions

View file

@ -26,7 +26,6 @@ import
import tools / kochdocs import tools / kochdocs
const VersionAsString = system.NimVersion const VersionAsString = system.NimVersion
const env_NIM_COMPILE_TO_CPP = "NIM_COMPILE_TO_CPP"
const const
HelpText = """ HelpText = """
@ -47,6 +46,8 @@ Possible Commands:
boot [options] bootstraps with given command line options boot [options] bootstraps with given command line options
distrohelper [bindir] helper for distro packagers distrohelper [bindir] helper for distro packagers
tools builds Nim related tools tools builds Nim related tools
toolsNoNimble builds Nim related tools (except nimble)
doesn't require network connectivity
nimble builds the Nimble tool nimble builds the Nimble tool
Boot options: Boot options:
-d:release produce a release version of the compiler -d:release produce a release version of the compiler
@ -73,6 +74,11 @@ Web options:
build the official docs, use UA-48159761-1 build the official docs, use UA-48159761-1
""" """
let kochExe* = os.getAppFilename()
proc kochExec*(cmd: string) =
exec kochExe.quoteShell & " " & cmd
template withDir(dir, body) = template withDir(dir, body) =
let old = getCurrentDir() let old = getCurrentDir()
try: try:
@ -123,9 +129,6 @@ proc bundleNimbleExe(latest: bool) =
# installer.ini expects it under $nim/bin # installer.ini expects it under $nim/bin
nimCompile("dist/nimble/src/nimble.nim", options = "-d:release --nilseqs:on") nimCompile("dist/nimble/src/nimble.nim", options = "-d:release --nilseqs:on")
proc buildNimfind() =
nimCompile("tools/nimfind.nim", options = "-d:release")
proc buildNimble(latest: bool) = proc buildNimble(latest: bool) =
# old installations created nim/nimblepkg/*.nim files. We remove these # old installations created nim/nimblepkg/*.nim files. We remove these
# here so that it cannot cause problems (nimble bug #306): # here so that it cannot cause problems (nimble bug #306):
@ -199,13 +202,12 @@ proc buildTool(toolname, args: string) =
nimexec("cc $# $#" % [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(latest: bool) = proc buildTools() =
bundleNimsuggest() bundleNimsuggest()
nimCompile("tools/nimgrep.nim", options = "-d:release") nimCompile("tools/nimgrep.nim", options = "-d:release")
when defined(windows): buildVccTool() when defined(windows): buildVccTool()
nimCompile("nimpretty/nimpretty.nim", options = "-d:release") nimCompile("nimpretty/nimpretty.nim", options = "-d:release")
buildNimble(latest) nimCompile("tools/nimfind.nim", options = "-d:release")
buildNimfind()
proc nsis(latest: bool; args: string) = proc nsis(latest: bool; args: string) =
bundleNimbleExe(latest) bundleNimbleExe(latest)
@ -274,7 +276,7 @@ proc boot(args: string) =
var output = "compiler" / "nim".exe var output = "compiler" / "nim".exe
var finalDest = "bin" / "nim".exe var finalDest = "bin" / "nim".exe
# default to use the 'c' command: # default to use the 'c' command:
let defaultCommand = if getEnv(env_NIM_COMPILE_TO_CPP, "false") == "true": "cpp" else: "c" let defaultCommand = if getEnv("NIM_COMPILE_TO_CPP", "false") == "true": "cpp" else: "c"
let bootOptions = if args.len == 0 or args.startsWith("-"): defaultCommand else: "" let bootOptions = if args.len == 0 or args.startsWith("-"): defaultCommand else: ""
echo "boot: defaultCommand: ", defaultCommand, " bootOptions: ", bootOptions echo "boot: defaultCommand: ", defaultCommand, " bootOptions: ", bootOptions
let smartNimcache = (if "release" in args: "nimcache/r_" else: "nimcache/d_") & let smartNimcache = (if "release" in args: "nimcache/r_" else: "nimcache/d_") &
@ -440,32 +442,38 @@ proc runCI(cmd: string) =
# todo: implement `execWithEnv` # todo: implement `execWithEnv`
exec("env NIM_COMPILE_TO_CPP=false $1 boot" % kochExe.quoteShell) exec("env NIM_COMPILE_TO_CPP=false $1 boot" % kochExe.quoteShell)
kochExec "boot -d:release" kochExec "boot -d:release"
## build nimble early on to enable remainder to depend on it if needed
kochExec "nimble" kochExec "nimble"
exec "nim e tests/test_nimscript.nims"
when false: when false:
for pkg in "zip opengl sdl1 jester@#head niminst".split: for pkg in "zip opengl sdl1 jester@#head niminst".split:
exec "nimble install -y" & pkg exec "nimble install -y" & pkg
buildTools() # altenatively, kochExec "tools --toolsNoNimble"
## run tests
exec "nim e tests/test_nimscript.nims"
when defined(windows): when defined(windows):
# note: will be over-written below # note: will be over-written below
exec "nim c -d:nimCoroutines --os:genode -d:posix --compileOnly testament/tester" exec "nim c -d:nimCoroutines --os:genode -d:posix --compileOnly testament/tester"
when false:
kochExec "csource"
kochExec "zip"
# main bottleneck: runs all main tests # main bottleneck here
exec "nim c -r -d:nimCoroutines testament/tester --pedantic all -d:nimCoroutines" exec "nim c -r -d:nimCoroutines testament/tester --pedantic all -d:nimCoroutines"
exec "nim c -r nimdoc/tester" exec "nim c -r nimdoc/tester"
nimCompile "nimpretty/nimpretty.nim"
exec "nim c -r nimpretty/tester.nim" exec "nim c -r nimpretty/tester.nim"
when defined(posix):
exec "nim c -r nimsuggest/tester"
## remaining actions
when defined(posix): when defined(posix):
kochExec "docs --git.commit:devel" kochExec "docs --git.commit:devel"
kochExec "csource" kochExec "csource"
kochExec "nimsuggest" elif defined(windows):
exec "nim c -r nimsuggest/tester" when false:
kochExec "csource"
kochExec "zip"
proc pushCsources() = proc pushCsources() =
if not dirExists("../csources/.git"): if not dirExists("../csources/.git"):
@ -550,6 +558,10 @@ when isMainModule:
var op = initOptParser() var op = initOptParser()
var latest = false var latest = false
var stable = false var stable = false
template isLatest(): bool =
if stable: false
else:
existsDir(".git") or latest
while true: while true:
op.next() op.next()
case op.kind case op.kind
@ -580,13 +592,13 @@ when isMainModule:
of "temp": temp(op.cmdLineRest) of "temp": temp(op.cmdLineRest)
of "xtemp": xtemp(op.cmdLineRest) of "xtemp": xtemp(op.cmdLineRest)
of "wintools": bundleWinTools() of "wintools": bundleWinTools()
of "nimble": of "nimble": buildNimble(isLatest())
if stable: buildNimble(false)
else: buildNimble(existsDir(".git") or latest)
of "nimsuggest": bundleNimsuggest() of "nimsuggest": bundleNimsuggest()
of "toolsnonimble":
buildTools()
of "tools": of "tools":
if stable: buildTools(false) buildTools()
else: buildTools(existsDir(".git") or latest) buildNimble(isLatest())
of "pushcsource", "pushcsources": pushCsources() of "pushcsource", "pushcsources": pushCsources()
of "valgrind": valgrind(op.cmdLineRest) of "valgrind": valgrind(op.cmdLineRest)
else: showHelp() else: showHelp()

View file

@ -51,12 +51,6 @@ proc execCleanPath*(cmd: string,
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode) if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
putEnv("PATH", prevPath) putEnv("PATH", prevPath)
let kochExe* = os.getAppFilename()
# note: assumes `kochdocs` is only used by koch.nim
proc kochExec*(cmd: string) =
exec kochExe.quoteShell & " " & cmd
proc nimexec*(cmd: string) = proc nimexec*(cmd: string) =
# Consider using `nimCompile` instead # Consider using `nimCompile` instead
exec findNim() & " " & cmd exec findNim() & " " & cmd