Inline fixes
This commit is contained in:
parent
2c3cc71540
commit
1dbff5cbd1
5 changed files with 36 additions and 35 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
author = "genotrance"
|
||||
description = "c2nim helper to simplify and automate the wrapping of C libraries"
|
||||
license = "MIT"
|
||||
|
|
|
|||
|
|
@ -10,12 +10,7 @@ proc c2nim*(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
|
|||
if file.len() == 0:
|
||||
return
|
||||
|
||||
echo " Generating " & outfile
|
||||
|
||||
# Remove static inline function bodies
|
||||
removeStatic(file)
|
||||
|
||||
fixFuncProtos(file)
|
||||
echo "Generating " & outfile
|
||||
|
||||
var cfile = file
|
||||
if c2nimConfig.preprocess:
|
||||
|
|
@ -121,7 +116,4 @@ proc c2nim*(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
|
|||
|
||||
# Add dynamic library
|
||||
if outlib != "":
|
||||
prepend(outfile, outlib)
|
||||
|
||||
# Add back static functions for compilation
|
||||
reAddStatic(file)
|
||||
prepend(outfile, outlib)
|
||||
|
|
@ -50,7 +50,10 @@ proc gitReset*() =
|
|||
setCurrentDir(gOutput)
|
||||
defer: setCurrentDir(gProjectDir)
|
||||
|
||||
discard execProc("git reset --hard HEAD")
|
||||
let cmd = "git reset --hard HEAD"
|
||||
while execCmdEx(cmd)[0].contains("Permission denied"):
|
||||
sleep(1000)
|
||||
echo " Retrying ..."
|
||||
|
||||
proc gitCheckout*(file: string) =
|
||||
echo "Resetting " & file
|
||||
|
|
@ -59,9 +62,9 @@ proc gitCheckout*(file: string) =
|
|||
defer: setCurrentDir(gProjectDir)
|
||||
|
||||
let cmd = "git checkout $#" % file.replace(gOutput & "/", "")
|
||||
if execCmdEx(cmd)[0].contains("Permission denied"):
|
||||
while execCmdEx(cmd)[0].contains("Permission denied"):
|
||||
sleep(500)
|
||||
discard execProc(cmd)
|
||||
echo " Retrying ..."
|
||||
|
||||
proc gitRemotePull*(url: string, pull=true) =
|
||||
if dirExists(gOutput/".git"):
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ proc getDefines*(file: string, inline=false): string =
|
|||
for incl in incls:
|
||||
let sincl = search(incl)
|
||||
if sincl != "":
|
||||
echo "Inlining " & sincl
|
||||
result &= getDefines(sincl)
|
||||
withFile(file):
|
||||
for def in content.findAll(re"(?m)^(\s*#\s*define\s+[\w\d_]+\s+[\d\-.xf]+)(?:\r|//|/*).*?$"):
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ proc runFile*(file: string, cfgin: OrderedTableRef = newOrderedTable[string, str
|
|||
writeFileFlush(file, cfg[act])
|
||||
if file in gExcludes:
|
||||
gExcludes.delete(gExcludes.find(file))
|
||||
sfile = search(file)
|
||||
sfile = file
|
||||
gDoneRecursive.add(sfile)
|
||||
elif action in @["prepend", "append", "replace", "comment",
|
||||
"rename", "compile", "dynlib", "pragma",
|
||||
|
|
@ -127,31 +127,38 @@ proc runFile*(file: string, cfgin: OrderedTableRef = newOrderedTable[string, str
|
|||
echo "Cannot use recurse and inline simultaneously"
|
||||
quit(1)
|
||||
|
||||
if not noprocess:
|
||||
let outfile = getNimout(sfile)
|
||||
c2nim(file, outfile, c2nimConfig)
|
||||
removeStatic(sfile)
|
||||
fixFuncProtos(sfile)
|
||||
|
||||
if c2nimConfig.recurse:
|
||||
var
|
||||
cfg = newOrderedTable[string, string]()
|
||||
incls = getIncls(sfile)
|
||||
incout = ""
|
||||
let outfile = getNimout(sfile)
|
||||
if c2nimConfig.recurse or c2nimConfig.inline:
|
||||
var
|
||||
cfg = newOrderedTable[string, string]()
|
||||
incls = getIncls(sfile)
|
||||
incout = ""
|
||||
|
||||
for name, value in c2nimConfig.fieldPairs:
|
||||
when value is string:
|
||||
cfg[name] = value
|
||||
when value is bool:
|
||||
cfg[name] = $value
|
||||
for name, value in c2nimConfig.fieldPairs:
|
||||
when value is string:
|
||||
cfg[name] = value
|
||||
when value is bool:
|
||||
cfg[name] = $value
|
||||
|
||||
for i in c2nimConfig.dynlib:
|
||||
cfg["dynlib." & i] = i
|
||||
for i in c2nimConfig.dynlib:
|
||||
cfg["dynlib." & i] = i
|
||||
|
||||
for inc in incls:
|
||||
runFile(inc, cfg)
|
||||
if c2nimConfig.inline:
|
||||
cfg["noprocess"] = "true"
|
||||
|
||||
for inc in incls:
|
||||
runFile(inc, cfg)
|
||||
if c2nimConfig.recurse:
|
||||
incout &= "import $#\n" % inc.search().getNimout()[0 .. ^5]
|
||||
|
||||
if incout.len() != 0:
|
||||
prepend(outfile, incout)
|
||||
if c2nimConfig.recurse and incout.len() != 0:
|
||||
prepend(outfile, incout)
|
||||
|
||||
if not noprocess:
|
||||
c2nim(file, outfile, c2nimConfig)
|
||||
|
||||
if reset:
|
||||
gitCheckout(sfile)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue