aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Yakimowich-Payne <jyapayne@gmail.com>2018-07-14 22:04:03 +0900
committerJoey Yakimowich-Payne <jyapayne@gmail.com>2018-07-14 22:04:03 +0900
commit0473e79c0bbc56c41814f6fb41d91da1bf5ed79a (patch)
tree6797d9108b8b55798afe272afe6520f83e74baba
parent2fae7453782c770875f9e1cb46632b47e9f08248 (diff)
downloadnimgen-0473e79c0bbc56c41814f6fb41d91da1bf5ed79a.tar.gz
nimgen-0473e79c0bbc56c41814f6fb41d91da1bf5ed79a.zip
Fix miscellaneous windows issues with building
-rw-r--r--src/nimgen/c2nim.nim5
-rw-r--r--src/nimgen/external.nim5
-rw-r--r--src/nimgen/gencore.nim2
-rw-r--r--src/nimgen/runcfg.nim3
4 files changed, 10 insertions, 5 deletions
diff --git a/src/nimgen/c2nim.nim b/src/nimgen/c2nim.nim
index 4d721b4..bca56d1 100644
--- a/src/nimgen/c2nim.nim
+++ b/src/nimgen/c2nim.nim
@@ -38,7 +38,7 @@ proc c2nim*(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
for inc in gIncludes:
if inc.isAbsolute():
- passC &= ("""{.passC: "-I\"$#\"".}""" % [inc]) & "\n"
+ passC &= ("""{.passC: "-I\"$#\"".}""" % [inc.sanitizePath()]) & "\n"
else:
passC &= (
"""{.passC: "-I\"" & currentSourcePath().splitPath().head & "$#\"".}""" %
@@ -85,11 +85,10 @@ proc c2nim*(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
passC &= "const header$# = currentSourcePath().splitPath().head & \"$#\"\n" %
[fname, file.relativePath()]
extflags = "--header:header$#" % fname
-
# Run c2nim on generated file
var cmd = "c2nim $# $# --out:$# $#" % [c2nimConfig.flags, extflags, outfile, cfile]
when defined(windows):
- cmd = "cmd /c " & cmd
+ cmd = "cmd /c " & cmd.quoteShell
discard execProc(cmd)
if c2nimConfig.preprocess or c2nimConfig.ctags:
diff --git a/src/nimgen/external.nim b/src/nimgen/external.nim
index 79426f6..096753c 100644
--- a/src/nimgen/external.nim
+++ b/src/nimgen/external.nim
@@ -2,6 +2,9 @@ import os, osproc, regex, ropes, streams, strutils
import globals
+proc sanitizePath*(path: string): string =
+ path.multiReplace([("\\", "/"), ("//", "/")])
+
proc execProc*(cmd: string): string =
result = ""
var
@@ -106,7 +109,7 @@ proc runPreprocess*(file, ppflags, flags: string, inline: bool): string =
cmd = "$# -E $# $#" % [pproc, ppflags, file]
for inc in gIncludes:
- cmd &= " -I " & inc
+ cmd &= " -I " & inc.quoteShell
# Run preprocessor
var data = execProc(cmd)
diff --git a/src/nimgen/gencore.nim b/src/nimgen/gencore.nim
index f794991..382fa59 100644
--- a/src/nimgen/gencore.nim
+++ b/src/nimgen/gencore.nim
@@ -20,7 +20,7 @@ proc addEnv*(str: string): string =
discard
# if there are still format args, print a warning
- if newStr.contains("${"):
+ if newStr.contains("$") and not newStr.contains("$replace("):
echo "WARNING: \"", newStr, "\" still contains an uninterpolated value!"
return newStr
diff --git a/src/nimgen/runcfg.nim b/src/nimgen/runcfg.nim
index 105cede..7255c52 100644
--- a/src/nimgen/runcfg.nim
+++ b/src/nimgen/runcfg.nim
@@ -196,6 +196,9 @@ proc runCfg*(cfg: string) =
# Reset on a per project basis
gCCompiler = getEnv(cCompilerEnv, defaultCCompiler)
+ gCppCompiler = gCppCompiler.quoteShell
+ gCCompiler = gCCompiler.quoteShell
+
if gConfig["n.global"].hasKey("filter"):
gFilter = gConfig["n.global"]["filter"]
if gConfig["n.global"].hasKey("quotes"):