Fixes to work with all wrappers
This commit is contained in:
parent
512cdd3a9f
commit
c846bf106a
1 changed files with 10 additions and 17 deletions
27
nimgen.nim
27
nimgen.nim
|
|
@ -438,6 +438,9 @@ proc runCtags(file: string): string =
|
||||||
|
|
||||||
proc runFile(file: string, cfgin: OrderedTableRef)
|
proc runFile(file: string, cfgin: OrderedTableRef)
|
||||||
|
|
||||||
|
template relativePath(path: untyped): untyped =
|
||||||
|
path.multiReplace([(gOutput, ""), ("\\", "/"), ("//", "/")])
|
||||||
|
|
||||||
proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
|
proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
|
||||||
var file = search(fl)
|
var file = search(fl)
|
||||||
if file == "":
|
if file == "":
|
||||||
|
|
@ -487,24 +490,18 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
|
||||||
outlib = ""
|
outlib = ""
|
||||||
outpragma = ""
|
outpragma = ""
|
||||||
|
|
||||||
passC = "import strutils\n"
|
passC = "import ospaths, strutils\n"
|
||||||
passC &= "import ospaths\n"
|
|
||||||
|
|
||||||
for inc in gIncludes:
|
for inc in gIncludes:
|
||||||
if inc.isAbsolute:
|
passC &= (
|
||||||
passC &= ("""{.passC: "-I\"$#\"".}""" % [inc]) & "\n"
|
"""{.passC: "-I\"" & currentSourcePath().splitPath().head & "$#\"".}""" %
|
||||||
else:
|
inc.relativePath()
|
||||||
let relativeInc = inc.replace(gOutput, "")
|
) & "\n"
|
||||||
passC &= (
|
|
||||||
"""{.passC: "-I\"" & currentSourcePath().splitPath().head & "/$#\"".}""" %
|
|
||||||
[relativeInc]
|
|
||||||
) & "\n"
|
|
||||||
|
|
||||||
for prag in c2nimConfig.pragma:
|
for prag in c2nimConfig.pragma:
|
||||||
outpragma &= "{." & prag & ".}\n"
|
outpragma &= "{." & prag & ".}\n"
|
||||||
|
|
||||||
let fname = file.splitFile().name.replace(re"[\.\-]", "_")
|
let fname = file.splitFile().name.replace(re"[\.\-]", "_")
|
||||||
let fincl = file.replace(gOutput, "")
|
|
||||||
|
|
||||||
if c2nimConfig.dynlib.len() != 0:
|
if c2nimConfig.dynlib.len() != 0:
|
||||||
let
|
let
|
||||||
|
|
@ -535,12 +532,8 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
|
||||||
if outlib != "":
|
if outlib != "":
|
||||||
extflags &= " --dynlib:dynlib$#" % fname
|
extflags &= " --dynlib:dynlib$#" % fname
|
||||||
else:
|
else:
|
||||||
if file.isAbsolute():
|
passC &= "const header$# = currentSourcePath().splitPath().head & \"$#\"\n" %
|
||||||
passC &= "const header$# = \"$#\"\n" % [fname, fincl]
|
[fname, file.relativePath()]
|
||||||
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]
|
|
||||||
extflags = "--header:header$#" % fname
|
extflags = "--header:header$#" % fname
|
||||||
|
|
||||||
# Run c2nim on generated file
|
# Run c2nim on generated file
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue