Use Nim binary if it exists.

This commit is contained in:
Dominik Picheta 2014-09-09 16:59:06 +01:00
commit 3c1248c1b2
2 changed files with 9 additions and 3 deletions

View file

@ -404,7 +404,7 @@ proc buildFromDir(pkgInfo: TPackageInfo, paths: seq[string]) =
for bin in pkgInfo.bin:
echo("Building ", pkginfo.name, "/", bin, " using ", pkgInfo.backend,
" backend...")
doCmd("nimrod $# -d:release --noBabelPath $# \"$#\"" %
doCmd(getNimBin() & " $# -d:release --noBabelPath $# \"$#\"" %
[pkgInfo.backend, args, realDir / bin.changeFileExt("nim")])
proc saveBabelMeta(pkgDestDir, url: string, filesInstalled: TSet[string]) =

View file

@ -31,11 +31,17 @@ template cd*(dir: string, body: stmt) =
body
setCurrentDir(lastDir)
proc getNimBin*: string =
result = "nim"
if findExe("nim") != "": result = "nim"
elif findExe("nimrod") != "": result = "nimrod"
proc getNimrodVersion*: TVersion =
let vOutput = execProcess("nimrod -v")
let nimBin = getNimBin()
let vOutput = doCmdEx(nimBin & " -v").output
var matches: array[0..MaxSubpatterns, string]
if vOutput.find(peg"'Version'\s{(\d\.)+\d}", matches) == -1:
quit("Couldn't find Nimrod version.", QuitFailure)
quit("Couldn't find Nim version.", QuitFailure)
newVersion(matches[0])
proc samePaths*(p1, p2: string): bool =