diff options
author | Araq <rumpf_a@web.de> | 2016-12-29 19:20:23 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2016-12-29 19:20:23 +0100 |
commit | 4134240b42ff8fe91d898c3748f3bb6f22ea866a (patch) | |
tree | 47376e9a2710caf1a9b7b0e2bbf31e4594dee41e /tools/finish.nim | |
parent | 7148f6f10487416d06f88b20ab2d87029d9fba2f (diff) | |
download | Nim-4134240b42ff8fe91d898c3748f3bb6f22ea866a.tar.gz |
finish tool: Check for installations in 'program files' et al
Diffstat (limited to 'tools/finish.nim')
-rw-r--r-- | tools/finish.nim | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tools/finish.nim b/tools/finish.nim index cac001d79..afb3d9fc1 100644 --- a/tools/finish.nim +++ b/tools/finish.nim @@ -85,14 +85,33 @@ when defined(windows): let arch = execProcess(gccExe, ["-dumpmachine"], nil, {poStdErrToStdOut, poUsePath}) when hostCPU == "i386": - result = arch.startsWith("i686-") + result = arch.contains("i686-") elif hostCPU == "amd64": - result = arch.startsWith("x86_64-") + result = arch.contains("x86_64-") else: {.error: "Unknown CPU for Windows.".} except OSError, IOError: result = false + proc defaultMingwLocations(): seq[string] = + proc probeDir(dir: string; result: var seq[string]) = + for k, x in walkDir(dir, relative=true): + if k in {pcDir, pcLinkToDir}: + if x.contains("mingw") or x.contains("posix"): + let dest = dir / x + probeDir(dest, result) + result.add(dest) + + result = @["dist/mingw", "../mingw", r"C:\mingw"] + let pfx86 = getEnv("programfiles(x86)") + let pf = getEnv("programfiles") + when hostCPU == "i386": + probeDir(pfx86, result) + probeDir(pf, result) + else: + probeDir(pf, result) + probeDir(pfx86, result) + proc tryDirs(incompat: var seq[string]; dirs: varargs[string]): string = let bits = $(sizeof(pointer)*8) for d in dirs: @@ -132,7 +151,7 @@ proc main() = addToPathEnv(desiredPath) if mingWchoices.len == 0: # No mingw in path, so try a few locations: - let alternative = tryDirs(incompat, "dist/mingw", "../mingw", r"C:\mingw") + let alternative = tryDirs(incompat, defaultMingwLocations()) if alternative.len == 0: if incompat.len > 0: echo "The following *incompatible* MingW installations exist" |