Merge branch 'master' of https://github.com/genotrance/nimgen into multireplace

This commit is contained in:
data-man 2018-07-15 07:47:10 +03:00
commit 43320e31a1
4 changed files with 11 additions and 6 deletions

View file

@ -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:

View file

@ -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)

View file

@ -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

View file

@ -25,7 +25,7 @@ proc getKey(ukey: string): tuple[key: string, val: bool] =
proc runFile*(file: string, cfgin: OrderedTableRef = newOrderedTable[string, string]()) =
var
cfg = cfgin
sfile = search(file)
sfile = search(file).sanitizePath
if sfile in gDoneRecursive:
return
@ -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"):