diff options
| author | data-man <datamanrb@gmail.com> | 2018-07-15 07:47:10 +0300 |
|---|---|---|
| committer | data-man <datamanrb@gmail.com> | 2018-07-15 07:47:10 +0300 |
| commit | 43320e31a17079754150f51c44543ec7033e35ed (patch) | |
| tree | ebe675f3498ef55fbe3dd5e82c7426c70e9dd67f | |
| parent | 2d06bdcccfcc41d42949f22aa7b96624cc7df130 (diff) | |
| parent | 6b38a558034367725dd0564b9ac7d2cfd29b6096 (diff) | |
| download | nimgen-43320e31a17079754150f51c44543ec7033e35ed.tar.gz nimgen-43320e31a17079754150f51c44543ec7033e35ed.zip | |
Merge branch 'master' of https://github.com/genotrance/nimgen into multireplace
| -rw-r--r-- | src/nimgen/c2nim.nim | 5 | ||||
| -rw-r--r-- | src/nimgen/external.nim | 5 | ||||
| -rw-r--r-- | src/nimgen/gencore.nim | 2 | ||||
| -rw-r--r-- | src/nimgen/runcfg.nim | 5 |
4 files changed, 11 insertions, 6 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 39c963e..c336f0a 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..cafb48e 100644 --- a/src/nimgen/runcfg.nim +++ b/src/nimgen/runcfg.nim @@ -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"): |
