better error messages for finish.nim
This commit is contained in:
parent
7cea3b6a35
commit
fb3b5bc5ad
1 changed files with 12 additions and 5 deletions
17
finish.nim
17
finish.nim
|
|
@ -93,15 +93,17 @@ when defined(windows):
|
||||||
except OSError, IOError:
|
except OSError, IOError:
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
proc tryDirs(dirs: varargs[string]): string =
|
proc tryDirs(incompat: var seq[string]; dirs: varargs[string]): string =
|
||||||
let bits = $(sizeof(pointer)*8)
|
let bits = $(sizeof(pointer)*8)
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
if dirExists d:
|
if dirExists d:
|
||||||
let x = expandFilename(d / "bin")
|
let x = expandFilename(d / "bin")
|
||||||
if checkGccArch(x): return x
|
if checkGccArch(x): return x
|
||||||
|
else: incompat.add x
|
||||||
elif dirExists(d & bits):
|
elif dirExists(d & bits):
|
||||||
let x = expandFilename((d & bits) / "bin")
|
let x = expandFilename((d & bits) / "bin")
|
||||||
if checkGccArch(x): return x
|
if checkGccArch(x): return x
|
||||||
|
else: incompat.add x
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
|
|
@ -110,13 +112,15 @@ proc main() =
|
||||||
HKEY_CURRENT_USER)
|
HKEY_CURRENT_USER)
|
||||||
var alreadyInPath = false
|
var alreadyInPath = false
|
||||||
var mingWchoices: seq[string] = @[]
|
var mingWchoices: seq[string] = @[]
|
||||||
|
var incompat: seq[string] = @[]
|
||||||
for x in p.split(';'):
|
for x in p.split(';'):
|
||||||
let y = expandFilename(if x[0] == '"' and x[^1] == '"':
|
let y = expandFilename(if x[0] == '"' and x[^1] == '"':
|
||||||
substr(x, 1, x.len-2) else: x)
|
substr(x, 1, x.len-2) else: x)
|
||||||
if y == desiredPath: alreadyInPath = true
|
if y == desiredPath: alreadyInPath = true
|
||||||
if y.toLowerAscii.contains("mingw"):
|
if y.toLowerAscii.contains("mingw"):
|
||||||
if dirExists(y) and checkGccArch(y):
|
if dirExists(y):
|
||||||
mingWchoices.add y
|
if checkGccArch(y): mingWchoices.add y
|
||||||
|
else: incompat.add y
|
||||||
|
|
||||||
if alreadyInPath:
|
if alreadyInPath:
|
||||||
echo "bin/nim.exe is already in your PATH [Skipping]"
|
echo "bin/nim.exe is already in your PATH [Skipping]"
|
||||||
|
|
@ -126,9 +130,12 @@ proc main() =
|
||||||
addToPathEnv(desiredPath)
|
addToPathEnv(desiredPath)
|
||||||
if mingWchoices.len == 0:
|
if mingWchoices.len == 0:
|
||||||
# No mingw in path, so try a few locations:
|
# No mingw in path, so try a few locations:
|
||||||
let alternative = tryDirs("dist/mingw", "../mingw", r"C:\mingw")
|
let alternative = tryDirs(incompat, "dist/mingw", "../mingw", r"C:\mingw")
|
||||||
if alternative.len == 0:
|
if alternative.len == 0:
|
||||||
echo "No MingW found in PATH and no candidate found " &
|
if incompat.len > 0:
|
||||||
|
echo "The following *incompatible* MingW installations exist"
|
||||||
|
for x in incompat: echo x
|
||||||
|
echo "No compatible MingW candidates found " &
|
||||||
"in the standard locations [Error]"
|
"in the standard locations [Error]"
|
||||||
else:
|
else:
|
||||||
if askBool("Found a MingW directory that is not in your PATH.\n" &
|
if askBool("Found a MingW directory that is not in your PATH.\n" &
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue