koch.nim: winrelease without nasty batch files

This commit is contained in:
Araq
2017-02-07 01:04:38 +01:00
parent 2e65b48b62
commit 2d3385c222
2 changed files with 59 additions and 4 deletions

View File

@@ -46,7 +46,7 @@ Start: "doc/html/overview.html"
[Other]
Files: "readme.txt;install.txt;contributors.txt;copying.txt"
Files: "readme.txt;copying.txt"
Files: "makefile"
Files: "koch.nim"
Files: "install_nimble.nims"

View File

@@ -70,6 +70,8 @@ Web options:
build the official docs, use UA-48159761-1
"""
const gaCode = " --googleAnalytics:UA-48159761-1"
proc exe(f: string): string =
result = addFileExt(f, ExeExt)
when defined(windows):
@@ -380,8 +382,61 @@ proc clean(args: string) =
# -------------- builds a release ---------------------------------------------
proc patchConfig(lookFor, replaceBy: string) =
const
cfgFile = "config/nim.cfg"
try:
let cfg = readFile(cfgFile)
let newCfg = cfg.replace(lookFor, replaceBy)
if newCfg == cfg:
echo "Could not patch 'config/nim.cfg' [Error]"
echo "Reason: patch substring not found:"
echo lookFor
else:
writeFile(cfgFile, newCfg)
except IOError:
quit "Could not access 'config/nim.cfg' [Error]"
proc winReleaseArch(arch: string) =
doAssert arch in ["32", "64"]
let cpu = if arch == "32": "i386" else: "amd64"
template withMingw(path, body) =
const orig = """#gcc.path = r"$nim\dist\mingw\bin""""
let replacePattern = """gcc.path = r"..\mingw$1\bin" # winrelease""" % arch
patchConfig(orig, replacePattern)
try:
body
finally:
patchConfig(replacePattern, orig)
withMingw r"..\mingw" & arch & r"\bin":
# Rebuilding koch is necessary because it uses its pointer size to
# determine which mingw link to put in the NSIS installer.
nimexec "c --out:koch_temp --cpu:$# koch" % cpu
exec "koch_temp boot -d:release --cpu:$#" % cpu
exec "koch_temp nsis -d:release"
exec "koch_temp zip -d:release"
moveFile r"build\nim_$#.exe" % VersionAsString,
r"web\upload\download\nim-$#_x$#.exe" % [VersionAsString, arch]
moveFile r"build\nim-$#.zip" % VersionAsString,
r"web\upload\download\nim-$#_x$#.zip" % [VersionAsString, arch]
proc winRelease() =
exec(r"call ci\nsis_build.bat " & VersionAsString)
# Build -docs file:
when true:
web(gaCode)
withDir "web/upload/" & VersionAsString:
exec "7z a -tzip docs-$#.zip *.html" % VersionAsString
moveFile "web/upload/$1/docs-$1.zip" % VersionAsString,
"web/upload/download/docs-$1.zip" % VersionAsString
when true:
csource("-d:release")
when true:
winReleaseArch "32"
when true:
winReleaseArch "64"
# -------------- tests --------------------------------------------------------
@@ -463,10 +518,10 @@ of cmdArgument:
of "web": web(op.cmdLineRest)
of "doc", "docs": web("--onlyDocs " & op.cmdLineRest)
of "json2": web("--json2 " & op.cmdLineRest)
of "website": website(op.cmdLineRest & " --googleAnalytics:UA-48159761-1")
of "website": website(op.cmdLineRest & gaCode)
of "web0":
# undocumented command for Araq-the-merciful:
web(op.cmdLineRest & " --googleAnalytics:UA-48159761-1")
web(op.cmdLineRest & gaCode)
of "pdf": pdf()
of "csource", "csources": csource(op.cmdLineRest)
of "zip": zip(op.cmdLineRest)