koch --nim:pathto/nim boot and koch boot --hint:cc:off now work (#13516)

* `koch boot --hint:cc:off` now works

* `koch --nim:pathto/nim boot` now works; code cleanup
This commit is contained in:
Timothee Cour 2020-03-10 16:31:34 -07:00 • committed by GitHub
commit e64f1c7ee4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 28 deletions

View file

@ -18,15 +18,19 @@ proc exe*(f: string): string =
when defined(windows):
result = result.replace('/','\\')
proc findNim*(): string =
if nimExe.len > 0: return nimExe
var nim = "nim".exe
result = "bin" / nim
if existsFile(result): return
proc findNimImpl*(): tuple[path: string, ok: bool] =
if nimExe.len > 0: return (nimExe, true)
let nim = "nim".exe
result.path = "bin" / nim
result.ok = true
if existsFile(result.path): return
for dir in split(getEnv("PATH"), PathSep):
if existsFile(dir / nim): return dir / nim
result.path = dir / nim
if existsFile(result.path): return
# assume there is a symlink to the exe or something:
return nim
return (nim, false)
proc findNim*(): string = findNimImpl().path
proc exec*(cmd: string, errorcode: int = QuitFailure, additionalPath = "") =
let prevPath = getEnv("PATH")