diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2018-07-08 16:01:54 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2018-07-08 16:01:54 -0500 |
| commit | c846bf106a2b32ab6a0113fd8ce31f2d31463280 (patch) | |
| tree | 6038447dfde63b6c3e26a4283aa29f92905e2d36 | |
| parent | 512cdd3a9f64d2be1a6fd338fe6d7fddeceaebae (diff) | |
| download | nimgen-c846bf106a2b32ab6a0113fd8ce31f2d31463280.tar.gz nimgen-c846bf106a2b32ab6a0113fd8ce31f2d31463280.zip | |
Fixes to work with all wrappers
| -rw-r--r-- | nimgen.nim | 27 |
1 files changed, 10 insertions, 17 deletions
@@ -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,24 +490,18 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) = outlib = "" outpragma = "" - passC = "import strutils\n" - passC &= "import ospaths\n" + passC = "import ospaths, strutils\n" for inc in gIncludes: - if inc.isAbsolute: - passC &= ("""{.passC: "-I\"$#\"".}""" % [inc]) & "\n" - else: - let relativeInc = inc.replace(gOutput, "") - passC &= ( - """{.passC: "-I\"" & currentSourcePath().splitPath().head & "/$#\"".}""" % - [relativeInc] - ) & "\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"[\.\-]", "_") - let fincl = file.replace(gOutput, "") if c2nimConfig.dynlib.len() != 0: let @@ -535,12 +532,8 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) = if outlib != "": extflags &= " --dynlib:dynlib$#" % fname else: - if file.isAbsolute(): - passC &= "const header$# = \"$#\"\n" % [fname, fincl] - else: - # based on the current source directory, get the include path - # works for nimble installations and local repo clones - passC &= "const header$# = currentSourcePath().splitPath().head & \"/$#\"\n" % [fname, fincl] + passC &= "const header$# = currentSourcePath().splitPath().head & \"$#\"\n" % + [fname, file.relativePath()] extflags = "--header:header$#" % fname # Run c2nim on generated file |
