mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
added 'koch testinstall' command; more installer related bugfixes
This commit is contained in:
@@ -68,6 +68,7 @@ Files: "web/ticker.html"
|
||||
Files: "web/*.nim"
|
||||
Files: "web/*.txt"
|
||||
Files: "web/*.rst"
|
||||
Files: "web/*.csv"
|
||||
Files: "web/news/*.rst"
|
||||
Files: "bin/nimblepkg/*.nim"
|
||||
Files: "bin/nimblepkg/*.cfg"
|
||||
|
||||
40
koch.nim
40
koch.nim
@@ -42,6 +42,7 @@ Possible Commands:
|
||||
boot [options] bootstraps with given command line options
|
||||
install [bindir] installs to given directory; Unix only!
|
||||
geninstall generate ./install.sh; Unix only!
|
||||
testinstall test tar.xz package; Unix only! Only for devs!
|
||||
clean cleans Nim project; removes generated files
|
||||
web [options] generates the website and the full documentation
|
||||
website [options] generates only the website
|
||||
@@ -91,6 +92,44 @@ proc exec(cmd: string, errorcode: int = QuitFailure, additionalPATH = "") =
|
||||
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
|
||||
putEnv("PATH", prevPATH)
|
||||
|
||||
proc execCleanPath(cmd: string,
|
||||
additionalPath = ""; errorcode: int = QuitFailure) =
|
||||
# simulate a poor man's virtual environment
|
||||
let prevPath = getEnv("PATH")
|
||||
when defined(windows):
|
||||
let CleanPath = r"$1\system32;$1;$1\System32\Wbem" % getEnv"SYSTEMROOT"
|
||||
else:
|
||||
const CleanPath = r"/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"
|
||||
putEnv("PATH", CleanPath & PathSep & additionalPath)
|
||||
echo(cmd)
|
||||
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
|
||||
putEnv("PATH", prevPath)
|
||||
|
||||
proc testUnixInstall() =
|
||||
let oldCurrentDir = getCurrentDir()
|
||||
try:
|
||||
let destDir = getTempDir()
|
||||
copyFile("build/nim-$1.tar.xz" % VersionAsString,
|
||||
destDir / "nim-$1.tar.xz" % VersionAsString)
|
||||
setCurrentDir(destDir)
|
||||
execCleanPath("tar -xzf nim-$1.tar.xz" % VersionAsString)
|
||||
setCurrentDir("nim-$1" % VersionAsString)
|
||||
execCleanPath("sh build.sh")
|
||||
# first test: try if './bin/nim --version' outputs something sane:
|
||||
let output = execProcess("./bin/nim --version").splitLines
|
||||
if output.len > 0 and output[0].contains(VersionAsString):
|
||||
echo "Version check: success"
|
||||
execCleanPath("./bin/nim c koch.nim")
|
||||
execCleanPath("./koch boot -d:release", destDir / "bin")
|
||||
# check the docs build:
|
||||
execCleanPath("./koch web", destDir / "bin")
|
||||
# check the tests work:
|
||||
execCleanPath("./koch tests", destDir / "bin")
|
||||
else:
|
||||
echo "Version check: failure"
|
||||
finally:
|
||||
setCurrentDir oldCurrentDir
|
||||
|
||||
proc tryExec(cmd: string): bool =
|
||||
echo(cmd)
|
||||
result = execShellCmd(cmd) == 0
|
||||
@@ -405,6 +444,7 @@ of cmdArgument:
|
||||
of "nsis": nsis(op.cmdLineRest)
|
||||
of "geninstall": geninstall(op.cmdLineRest)
|
||||
of "install": install(op.cmdLineRest)
|
||||
of "testinstall": testUnixInstall()
|
||||
of "test", "tests": tests(op.cmdLineRest)
|
||||
of "update":
|
||||
when defined(withUpdate):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
discard """
|
||||
file: "tasynceverror.nim"
|
||||
exitcode: 1
|
||||
outputsub: "Error: unhandled exception: Connection reset by peer"
|
||||
outputsub: "Error: unhandled exception: "
|
||||
"""
|
||||
|
||||
# error message is actually different on OSX
|
||||
import
|
||||
asyncdispatch,
|
||||
asyncnet,
|
||||
|
||||
@@ -155,7 +155,11 @@ proc parseSpec*(filename: string): TSpec =
|
||||
result.nimout = e.value
|
||||
of "disabled":
|
||||
if parseCfgBool(e.value): result.err = reIgnored
|
||||
of "cmd": result.cmd = e.value
|
||||
of "cmd":
|
||||
if e.value.startsWith("nim "):
|
||||
result.cmd = "compiler" / e.value
|
||||
else:
|
||||
result.cmd = e.value
|
||||
of "ccodecheck": result.ccodeCheck = e.value
|
||||
of "target", "targets":
|
||||
for v in e.value.normalize.split:
|
||||
|
||||
@@ -284,6 +284,7 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||
return
|
||||
|
||||
let tname = test.name.addFileExt(".nim")
|
||||
#echo "TESTING ", tname
|
||||
inc(r.total)
|
||||
var expected: TSpec
|
||||
if test.action != actionRunNoSpec:
|
||||
|
||||
@@ -635,8 +635,10 @@ proc xzDist(c: var ConfigData) =
|
||||
let oldDir = getCurrentDir()
|
||||
setCurrentDir(tmpDir)
|
||||
try:
|
||||
if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
|
||||
echo("External program failed")
|
||||
if execShellCmd("XZ_OPT=-9 gtar Jcf $1.tar.xz $1 --exclude=.DS_Store" % proj) != 0:
|
||||
# try old 'tar' without --exclude feature:
|
||||
if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
|
||||
echo("External program failed")
|
||||
finally:
|
||||
setCurrentDir(oldDir)
|
||||
|
||||
|
||||
@@ -251,9 +251,22 @@ proc parseIniFile(c: var TConfigData) =
|
||||
|
||||
# ------------------- main ----------------------------------------------------
|
||||
|
||||
|
||||
proc exe(f: string): string = return addFileExt(f, ExeExt)
|
||||
|
||||
proc findNim(): string =
|
||||
var nim = "nim".exe
|
||||
result = "bin" / nim
|
||||
if existsFile(result): return
|
||||
for dir in split(getEnv("PATH"), PathSep):
|
||||
if existsFile(dir / nim): return dir / nim
|
||||
# assume there is a symlink to the exe or something:
|
||||
return nim
|
||||
|
||||
proc exec(cmd: string) =
|
||||
echo(cmd)
|
||||
if os.execShellCmd(cmd) != 0: quit("external program failed")
|
||||
let (_, exitCode) = osproc.execCmdEx(cmd)
|
||||
if exitCode != 0: quit("external program failed")
|
||||
|
||||
proc sexec(cmds: openarray[string]) =
|
||||
## Serial queue wrapper around exec.
|
||||
@@ -275,9 +288,9 @@ proc buildDocSamples(c: var TConfigData, destPath: string) =
|
||||
## it didn't make much sense to integrate into the existing generic
|
||||
## documentation builders.
|
||||
const src = "doc"/"docgen_sample.nim"
|
||||
exec("nim doc $# -o:$# $#" %
|
||||
exec(findNim() & " doc $# -o:$# $#" %
|
||||
[c.nimArgs, destPath / "docgen_sample.html", src])
|
||||
exec("nim doc2 $# -o:$# $#" %
|
||||
exec(findNim() & " doc2 $# -o:$# $#" %
|
||||
[c.nimArgs, destPath / "docgen_sample2.html", src])
|
||||
|
||||
proc pathPart(d: string): string = splitFile(d).dir.replace('\\', '/')
|
||||
@@ -288,30 +301,30 @@ proc buildDoc(c: var TConfigData, destPath: string) =
|
||||
commands = newSeq[string](len(c.doc) + len(c.srcdoc) + len(c.srcdoc2))
|
||||
i = 0
|
||||
for d in items(c.doc):
|
||||
commands[i] = "nim rst2html $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
|
||||
commands[i] = findNim() & " rst2html $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
|
||||
[c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart,
|
||||
destPath / changeFileExt(splitFile(d).name, "html"), d]
|
||||
i.inc
|
||||
for d in items(c.srcdoc):
|
||||
commands[i] = "nim doc $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
|
||||
commands[i] = findNim() & " doc $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
|
||||
[c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart,
|
||||
destPath / changeFileExt(splitFile(d).name, "html"), d]
|
||||
i.inc
|
||||
for d in items(c.srcdoc2):
|
||||
commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
|
||||
commands[i] = findNim() & " doc2 $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
|
||||
[c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart,
|
||||
destPath / changeFileExt(splitFile(d).name, "html"), d]
|
||||
i.inc
|
||||
|
||||
mexec(commands, c.numProcessors)
|
||||
exec("nim buildIndex -o:$1/theindex.html $1" % [destPath])
|
||||
exec(findNim() & " buildIndex -o:$1/theindex.html $1" % [destPath])
|
||||
|
||||
proc buildPdfDoc(c: var TConfigData, destPath: string) =
|
||||
if os.execShellCmd("pdflatex -version") != 0:
|
||||
echo "pdflatex not found; no PDF documentation generated"
|
||||
else:
|
||||
for d in items(c.pdf):
|
||||
exec("nim rst2tex $# $#" % [c.nimArgs, d])
|
||||
exec(findNim() & " rst2tex $# $#" % [c.nimArgs, d])
|
||||
# call LaTeX twice to get cross references right:
|
||||
exec("pdflatex " & changeFileExt(d, "tex"))
|
||||
exec("pdflatex " & changeFileExt(d, "tex"))
|
||||
@@ -331,7 +344,7 @@ proc buildAddDoc(c: var TConfigData, destPath: string) =
|
||||
# build additional documentation (without the index):
|
||||
var commands = newSeq[string](c.webdoc.len)
|
||||
for i, doc in pairs(c.webdoc):
|
||||
commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$# -o:$# $#" %
|
||||
commands[i] = findNim() & " doc2 $# --docSeeSrcUrl:$#/$# -o:$# $#" %
|
||||
[c.nimArgs, c.gitRepo, c.gitCommit,
|
||||
destPath / changeFileExt(splitFile(doc).name, "html"), doc]
|
||||
mexec(commands, c.numProcessors)
|
||||
@@ -415,7 +428,7 @@ proc buildNewsRss(c: var TConfigData, destPath: string) =
|
||||
generateRss(destFilename, parseNewsTitles(srcFilename))
|
||||
|
||||
proc buildJS(destPath: string) =
|
||||
exec("nim js -d:release --out:$1 web/nimblepkglist.nim" %
|
||||
exec(findNim() & " js -d:release --out:$1 web/nimblepkglist.nim" %
|
||||
[destPath / "nimblepkglist.js"])
|
||||
|
||||
proc readSponsors(sponsorsFile: string): seq[Sponsor] =
|
||||
@@ -443,10 +456,10 @@ proc buildSponsors(c: var TConfigData, sponsorsFile: string, outputDir: string)
|
||||
quit("[Error] Cannot write file: " & outFile)
|
||||
|
||||
const
|
||||
cmdRst2Html = "nim rst2html --compileonly $1 -o:web/$2.temp web/$2.rst"
|
||||
cmdRst2Html = " rst2html --compileonly $1 -o:web/$2.temp web/$2.rst"
|
||||
|
||||
proc buildPage(c: var TConfigData, file, title, rss: string, assetDir = "") =
|
||||
exec(cmdRst2Html % [c.nimArgs, file])
|
||||
exec(findNim() & cmdRst2Html % [c.nimArgs, file])
|
||||
var temp = "web" / changeFileExt(file, "temp")
|
||||
var content: string
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user