finish tool improvements
This commit is contained in:
parent
1b9270d08b
commit
25fb5be0cb
1 changed files with 14 additions and 11 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
# -------------- post unzip steps ---------------------------------------------
|
# -------------- post unzip steps ---------------------------------------------
|
||||||
|
|
||||||
import strutils, os, osproc, browsers
|
import strutils, os, osproc, streams, browsers
|
||||||
|
|
||||||
const arch = $(sizeof(int)*8)
|
const arch = $(sizeof(int)*8)
|
||||||
|
|
||||||
proc downloadMingw() =
|
proc downloadMingw() =
|
||||||
openDefaultBrowser("http://nim-lang.org/download/mingw$1.zip" % arch)
|
openDefaultBrowser("https://nim-lang.org/download/mingw$1.zip" % arch)
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
import registry
|
import registry
|
||||||
|
|
@ -86,18 +86,21 @@ when defined(windows):
|
||||||
proc checkGccArch(mingw: string): bool =
|
proc checkGccArch(mingw: string): bool =
|
||||||
let gccExe = mingw / r"gcc.exe"
|
let gccExe = mingw / r"gcc.exe"
|
||||||
if fileExists(gccExe):
|
if fileExists(gccExe):
|
||||||
|
const nimCompat = "nim_compat.c"
|
||||||
|
writeFile(nimCompat, """typedef int
|
||||||
|
Nim_and_C_compiler_disagree_on_target_architecture[
|
||||||
|
$# == sizeof(void*) ? 1 : -1];
|
||||||
|
""" % $sizeof(int))
|
||||||
try:
|
try:
|
||||||
let arch = execProcess(gccExe, ["-dumpmachine"], nil, {poStdErrToStdOut,
|
let p = startProcess(gccExe, "", ["-c", nimCompat], nil,
|
||||||
poUsePath}).strip
|
{poStdErrToStdOut, poUsePath})
|
||||||
when hostCPU == "i386":
|
#echo p.outputStream.readAll()
|
||||||
result = (arch.contains("i686-") and not arch.contains("w64")) or
|
result = p.waitForExit() == 0
|
||||||
arch == "mingw32"
|
|
||||||
elif hostCPU == "amd64":
|
|
||||||
result = arch.contains("x86_64-") or arch.contains("i686-w64-mingw32")
|
|
||||||
else:
|
|
||||||
{.error: "Unknown CPU for Windows.".}
|
|
||||||
except OSError, IOError:
|
except OSError, IOError:
|
||||||
result = false
|
result = false
|
||||||
|
finally:
|
||||||
|
removeFile(nimCompat)
|
||||||
|
removeFile(nimCompat.changeFileExt("o"))
|
||||||
|
|
||||||
proc defaultMingwLocations(): seq[string] =
|
proc defaultMingwLocations(): seq[string] =
|
||||||
proc probeDir(dir: string; result: var seq[string]) =
|
proc probeDir(dir: string; result: var seq[string]) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue