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