summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2016-10-22 11:11:50 +0200
committerAraq <rumpf_a@web.de>2016-10-22 11:11:50 +0200
commitfb3b5bc5adacfd46844d87b0bc035f6ac865400d (patch)
treec732fe21dadb603f32d8e22c058c0688b5d1ba29
parent7cea3b6a351e799acb6d19d4ac4d9ea59b33d01b (diff)
downloadNim-fb3b5bc5adacfd46844d87b0bc035f6ac865400d.tar.gz
better error messages for finish.nim
-rw-r--r--finish.nim17
1 files changed, 12 insertions, 5 deletions
diff --git a/finish.nim b/finish.nim
index 79f6dbd49..18216cfb2 100644
--- a/finish.nim
+++ b/finish.nim
@@ -93,15 +93,17 @@ when defined(windows):
       except OSError, IOError:
         result = false
 
-  proc tryDirs(dirs: varargs[string]): string =
+  proc tryDirs(incompat: var seq[string]; dirs: varargs[string]): string =
     let bits = $(sizeof(pointer)*8)
     for d in dirs:
       if dirExists d:
         let x = expandFilename(d / "bin")
         if checkGccArch(x): return x
+        else: incompat.add x
       elif dirExists(d & bits):
         let x = expandFilename((d & bits) / "bin")
         if checkGccArch(x): return x
+        else: incompat.add x
 
 proc main() =
   when defined(windows):
@@ -110,13 +112,15 @@ proc main() =
       HKEY_CURRENT_USER)
     var alreadyInPath = false
     var mingWchoices: seq[string] = @[]
+    var incompat: seq[string] = @[]
     for x in p.split(';'):
       let y = expandFilename(if x[0] == '"' and x[^1] == '"':
                   substr(x, 1, x.len-2) else: x)
       if y == desiredPath: alreadyInPath = true
       if y.toLowerAscii.contains("mingw"):
-        if dirExists(y) and checkGccArch(y):
-          mingWchoices.add y
+        if dirExists(y):
+          if checkGccArch(y): mingWchoices.add y
+          else: incompat.add y
 
     if alreadyInPath:
       echo "bin/nim.exe is already in your PATH [Skipping]"
@@ -126,9 +130,12 @@ proc main() =
         addToPathEnv(desiredPath)
     if mingWchoices.len == 0:
       # 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:
-        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]"
       else:
         if askBool("Found a MingW directory that is not in your PATH.\n" &