diff options
author | Araq <rumpf_a@web.de> | 2017-05-18 13:07:36 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-05-18 13:07:36 +0200 |
commit | ecdc478dac2db5a75304e2797516cb8301a18fa5 (patch) | |
tree | e259bd5d610a4f655e175b59b010019505a5a7a0 | |
parent | d3f0f87e81e262ee25fd528aae5b6db0bdf78d5e (diff) | |
download | Nim-ecdc478dac2db5a75304e2797516cb8301a18fa5.tar.gz |
fixes 'koch winrelease'
-rw-r--r-- | koch.nim | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/koch.nim b/koch.nim index 0fa06f273..743445094 100644 --- a/koch.nim +++ b/koch.nim @@ -152,6 +152,10 @@ proc tryExec(cmd: string): bool = proc safeRemove(filename: string) = if existsFile(filename): removeFile(filename) +proc overwriteFile(source, dest: string) = + safeRemove(dest) + moveFile(source, dest) + proc copyExe(source, dest: string) = safeRemove(dest) copyFile(dest=dest, source=source) @@ -388,33 +392,17 @@ 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) + let prevPath = getEnv("PATH") + putEnv("PATH", path & PathSep & prevPath) try: body finally: - patchConfig(replacePattern, orig) + putEnv("PATH", prevPath) withMingw r"..\mingw" & arch & r"\bin": # Rebuilding koch is necessary because it uses its pointer size to @@ -422,7 +410,7 @@ proc winReleaseArch(arch: string) = nimexec "c --out:koch_temp --cpu:$# koch" % cpu exec "koch_temp boot -d:release --cpu:$#" % cpu exec "koch_temp zip -d:release" - moveFile r"build\nim-$#.zip" % VersionAsString, + overwriteFile r"build\nim-$#.zip" % VersionAsString, r"web\upload\download\nim-$#_x$#.zip" % [VersionAsString, arch] proc winRelease() = @@ -431,8 +419,8 @@ proc winRelease() = 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 + overwriteFile "web/upload/$1/docs-$1.zip" % VersionAsString, + "web/upload/download/docs-$1.zip" % VersionAsString when true: csource("-d:release") when true: |