Fixes for #7747 - finish.exe issues (#7748)

This commit is contained in:
genotrance 2018-05-02 12:16:44 -05:00 • committed by Andreas Rumpf
commit 452321874d

View file

@ -52,6 +52,7 @@ when defined(windows):
proc askBool(m: string): bool = proc askBool(m: string): bool =
stdout.write m stdout.write m
while true: while true:
try:
let answer = stdin.readLine().normalize let answer = stdin.readLine().normalize
case answer case answer
of "y", "yes": of "y", "yes":
@ -60,6 +61,8 @@ when defined(windows):
return false return false
else: else:
echo "Please type 'y' or 'n'" echo "Please type 'y' or 'n'"
except EOFError:
quit(1)
proc askNumber(m: string; a, b: int): int = proc askNumber(m: string; a, b: int): int =
stdout.write m stdout.write m
@ -99,10 +102,6 @@ when defined(windows):
proc addToPathEnv*(e: string) = proc addToPathEnv*(e: string) =
var p = tryGetUnicodeValue(r"Environment", "Path", HKEY_CURRENT_USER) var p = tryGetUnicodeValue(r"Environment", "Path", HKEY_CURRENT_USER)
if p.len == 0:
p = tryGetUnicodeValue(
r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment",
"Path", HKEY_LOCAL_MACHINE)
let x = if e.contains(Whitespace): "\"" & e & "\"" else: e let x = if e.contains(Whitespace): "\"" & e & "\"" else: e
if p.len > 0: if p.len > 0:
p.add ";" p.add ";"
@ -189,8 +188,10 @@ when defined(windows):
proc main() = proc main() =
when defined(windows): when defined(windows):
let desiredPath = expandFilename(getCurrentDir() / "bin") let desiredPath = expandFilename(getCurrentDir() / "bin")
let p = getUnicodeValue(r"Environment", "Path", let p = tryGetUnicodeValue(r"Environment", "Path",
HKEY_CURRENT_USER) HKEY_CURRENT_USER) & ";" & tryGetUnicodeValue(
r"System\CurrentControlSet\Control\Session Manager\Environment", "Path",
HKEY_LOCAL_MACHINE)
var alreadyInPath = false var alreadyInPath = false
var mingWchoices: seq[string] = @[] var mingWchoices: seq[string] = @[]
var incompat: seq[string] = @[] var incompat: seq[string] = @[]
@ -199,7 +200,7 @@ proc main() =
let y = try: expandFilename(if x[0] == '"' and x[^1] == '"': let y = try: expandFilename(if x[0] == '"' and x[^1] == '"':
substr(x, 1, x.len-2) else: x) substr(x, 1, x.len-2) else: x)
except: "" except: ""
if y == desiredPath: alreadyInPath = true if y.cmpIgnoreCase(desiredPath) == 0: alreadyInPath = true
if y.toLowerAscii.contains("mingw"): if y.toLowerAscii.contains("mingw"):
if dirExists(y): if dirExists(y):
if checkGccArch(y): mingWchoices.add y if checkGccArch(y): mingWchoices.add y