aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2018-07-08 16:02:16 -0500
committerGanesh Viswanathan <dev@genotrance.com>2018-07-08 16:02:16 -0500
commit0bda8084dd2cc0222cd12b62176fe73fe16e0da6 (patch)
tree6038447dfde63b6c3e26a4283aa29f92905e2d36
parent44294a7513985dafd5aabca790648e85fa5789ef (diff)
parentc846bf106a2b32ab6a0113fd8ce31f2d31463280 (diff)
downloadnimgen-0bda8084dd2cc0222cd12b62176fe73fe16e0da6.tar.gz
nimgen-0bda8084dd2cc0222cd12b62176fe73fe16e0da6.zip
Merge branch 'jyapayne-fix_includes'
-rw-r--r--nimgen.nim15
1 files changed, 12 insertions, 3 deletions
diff --git a/nimgen.nim b/nimgen.nim
index acf94da..2bb3e16 100644
--- a/nimgen.nim
+++ b/nimgen.nim
@@ -438,6 +438,9 @@ proc runCtags(file: string): string =
proc runFile(file: string, cfgin: OrderedTableRef)
+template relativePath(path: untyped): untyped =
+ path.multiReplace([(gOutput, ""), ("\\", "/"), ("//", "/")])
+
proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
var file = search(fl)
if file == "":
@@ -487,14 +490,19 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
outlib = ""
outpragma = ""
- passC = "import strutils\n"
+ passC = "import ospaths, strutils\n"
+
for inc in gIncludes:
- passC &= ("""{.passC: "-I\"" & gorge("nimble path $#").strip() & "/$#\"".}""" % [gOutput, inc]) & "\n"
+ passC &= (
+ """{.passC: "-I\"" & currentSourcePath().splitPath().head & "$#\"".}""" %
+ inc.relativePath()
+ ) & "\n"
for prag in c2nimConfig.pragma:
outpragma &= "{." & prag & ".}\n"
let fname = file.splitFile().name.replace(re"[\.\-]", "_")
+
if c2nimConfig.dynlib.len() != 0:
let
win = "when defined(Windows):\n"
@@ -524,7 +532,8 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
if outlib != "":
extflags &= " --dynlib:dynlib$#" % fname
else:
- passC &= "const header$# = \"$#\"\n" % [fname, fl]
+ passC &= "const header$# = currentSourcePath().splitPath().head & \"$#\"\n" %
+ [fname, file.relativePath()]
extflags = "--header:header$#" % fname
# Run c2nim on generated file