Fix for mingw cross-compilation
This commit is contained in:
parent
ad90b586c4
commit
ec4e7aa5ba
2 changed files with 21 additions and 17 deletions
|
|
@ -42,7 +42,7 @@ proc walkDirImpl(indir, inext: string, file=true): seq[string] =
|
||||||
dir = joinPathIfRel(getProjectPath(), indir)
|
dir = joinPathIfRel(getProjectPath(), indir)
|
||||||
ext =
|
ext =
|
||||||
if inext.len != 0:
|
if inext.len != 0:
|
||||||
when not defined(Windows):
|
if hostOS != "windows":
|
||||||
"-name " & inext
|
"-name " & inext
|
||||||
else:
|
else:
|
||||||
"\\" & inext
|
"\\" & inext
|
||||||
|
|
@ -51,7 +51,7 @@ proc walkDirImpl(indir, inext: string, file=true): seq[string] =
|
||||||
|
|
||||||
let
|
let
|
||||||
cmd =
|
cmd =
|
||||||
when defined(Windows):
|
if hostOS == "windows":
|
||||||
if file:
|
if file:
|
||||||
"cmd /c dir /s/b/a-d " & dir.replace("/", "\\") & ext
|
"cmd /c dir /s/b/a-d " & dir.replace("/", "\\") & ext
|
||||||
else:
|
else:
|
||||||
|
|
@ -70,13 +70,17 @@ proc walkDirImpl(indir, inext: string, file=true): seq[string] =
|
||||||
proc getFileDate(fullpath: string): string =
|
proc getFileDate(fullpath: string): string =
|
||||||
var
|
var
|
||||||
ret = 0
|
ret = 0
|
||||||
cmd =
|
cmd = ""
|
||||||
when defined(Windows):
|
|
||||||
&"cmd /c for %a in ({fullpath.quoteShell}) do echo %~ta"
|
case hostOS
|
||||||
elif defined(Linux):
|
of "windows":
|
||||||
&"stat -c %y {fullpath.quoteShell}"
|
cmd = &"cmd /c for %a in ({fullpath.quoteShell}) do echo %~ta"
|
||||||
elif defined(OSX):
|
of "linux":
|
||||||
&"stat -f %m {fullpath.quoteShell}"
|
cmd = &"stat -c %y {fullpath.quoteShell}"
|
||||||
|
of "macosx":
|
||||||
|
cmd = &"stat -f %m {fullpath.quoteShell}"
|
||||||
|
else:
|
||||||
|
doAssert false
|
||||||
|
|
||||||
(result, ret) = gorgeEx(cmd)
|
(result, ret) = gorgeEx(cmd)
|
||||||
|
|
||||||
|
|
@ -115,7 +119,7 @@ proc getNimCheckError(output: string): tuple[tmpFile, errors: string] =
|
||||||
proc getToast(fullpath: string, recurse: bool = false): string =
|
proc getToast(fullpath: string, recurse: bool = false): string =
|
||||||
var
|
var
|
||||||
ret = 0
|
ret = 0
|
||||||
cmd = when defined(Windows): "cmd /c " else: ""
|
cmd = if hostOS == "windows": "cmd /c " else: ""
|
||||||
|
|
||||||
let toastExe = toastExePath()
|
let toastExe = toastExePath()
|
||||||
doAssert fileExists(toastExe), "toast not compiled: " & toastExe.quoteShell &
|
doAssert fileExists(toastExe), "toast not compiled: " & toastExe.quoteShell &
|
||||||
|
|
@ -146,7 +150,7 @@ proc getToast(fullpath: string, recurse: bool = false): string =
|
||||||
proc getGccPaths(mode = "c"): string =
|
proc getGccPaths(mode = "c"): string =
|
||||||
var
|
var
|
||||||
ret = 0
|
ret = 0
|
||||||
nul = when defined(Windows): "nul" else: "/dev/null"
|
nul = if hostOS == "windows": "nul" else: "/dev/null"
|
||||||
mmode = if mode == "cpp": "c++" else: mode
|
mmode = if mode == "cpp": "c++" else: mode
|
||||||
|
|
||||||
(result, ret) = gorgeEx("gcc -Wp,-v -x" & mmode & " " & nul)
|
(result, ret) = gorgeEx("gcc -Wp,-v -x" & mmode & " " & nul)
|
||||||
|
|
@ -452,7 +456,7 @@ macro cCompile*(path: static string, mode = "c", exclude = ""): untyped =
|
||||||
if mode.strVal().contains("cpp"):
|
if mode.strVal().contains("cpp"):
|
||||||
for i in @["*.cpp", "*.c++", "*.cc", "*.cxx"]:
|
for i in @["*.cpp", "*.c++", "*.cc", "*.cxx"]:
|
||||||
stmt &= dcompile(fpath, exclude.strVal(), i)
|
stmt &= dcompile(fpath, exclude.strVal(), i)
|
||||||
when not defined(Windows):
|
if hostOS != "windows":
|
||||||
stmt &= dcompile(fpath, exclude.strVal(), "*.C")
|
stmt &= dcompile(fpath, exclude.strVal(), "*.C")
|
||||||
else:
|
else:
|
||||||
stmt &= dcompile(fpath, exclude.strVal(), "*.c")
|
stmt &= dcompile(fpath, exclude.strVal(), "*.c")
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ proc execAction*(cmd: string, nostderr=false): string =
|
||||||
var
|
var
|
||||||
ccmd = ""
|
ccmd = ""
|
||||||
ret = 0
|
ret = 0
|
||||||
when defined(Windows):
|
when hostOS == "windows":
|
||||||
ccmd = "cmd /c " & cmd
|
ccmd = "cmd /c " & cmd
|
||||||
elif defined(posix):
|
elif defined(posix):
|
||||||
ccmd = cmd
|
ccmd = cmd
|
||||||
|
|
@ -23,7 +23,7 @@ proc execAction*(cmd: string, nostderr=false): string =
|
||||||
proc mkDir*(dir: string) =
|
proc mkDir*(dir: string) =
|
||||||
if not dirExists(dir):
|
if not dirExists(dir):
|
||||||
let
|
let
|
||||||
flag = when not defined(Windows): "-p" else: ""
|
flag = if hostOS != "windows": "-p" else: ""
|
||||||
discard execAction(&"mkdir {flag} {dir.quoteShell}")
|
discard execAction(&"mkdir {flag} {dir.quoteShell}")
|
||||||
|
|
||||||
proc cpFile*(source, dest: string, move=false) =
|
proc cpFile*(source, dest: string, move=false) =
|
||||||
|
|
@ -31,7 +31,7 @@ proc cpFile*(source, dest: string, move=false) =
|
||||||
source = source.replace("/", $DirSep)
|
source = source.replace("/", $DirSep)
|
||||||
dest = dest.replace("/", $DirSep)
|
dest = dest.replace("/", $DirSep)
|
||||||
cmd =
|
cmd =
|
||||||
when defined(Windows):
|
if hostOS == "windows":
|
||||||
if move:
|
if move:
|
||||||
"move /y"
|
"move /y"
|
||||||
else:
|
else:
|
||||||
|
|
@ -49,7 +49,7 @@ proc mvFile*(source, dest: string) =
|
||||||
|
|
||||||
proc extractZip*(zipfile, outdir: string) =
|
proc extractZip*(zipfile, outdir: string) =
|
||||||
var cmd = "unzip -o $#"
|
var cmd = "unzip -o $#"
|
||||||
if defined(Windows):
|
if hostOS == "windows":
|
||||||
cmd = "powershell -nologo -noprofile -command \"& { Add-Type -A " &
|
cmd = "powershell -nologo -noprofile -command \"& { Add-Type -A " &
|
||||||
"'System.IO.Compression.FileSystem'; " &
|
"'System.IO.Compression.FileSystem'; " &
|
||||||
"[IO.Compression.ZipFile]::ExtractToDirectory('$#', '.'); }\""
|
"[IO.Compression.ZipFile]::ExtractToDirectory('$#', '.'); }\""
|
||||||
|
|
@ -65,7 +65,7 @@ proc downloadUrl*(url, outdir: string) =
|
||||||
if not (ext == ".zip" and fileExists(outdir/file)):
|
if not (ext == ".zip" and fileExists(outdir/file)):
|
||||||
echo "Downloading " & file
|
echo "Downloading " & file
|
||||||
mkDir(outdir)
|
mkDir(outdir)
|
||||||
var cmd = if defined(Windows):
|
var cmd = if hostOS == "windows":
|
||||||
"powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; wget $# -OutFile $#"
|
"powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; wget $# -OutFile $#"
|
||||||
else:
|
else:
|
||||||
"curl $# -o $#"
|
"curl $# -o $#"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue