Move remove static and reset after processing
This commit is contained in:
parent
797fa20fca
commit
410977bb71
1 changed files with 37 additions and 21 deletions
58
nimgen.nim
58
nimgen.nim
|
|
@ -22,7 +22,7 @@ var
|
||||||
type
|
type
|
||||||
c2nimConfigObj = object
|
c2nimConfigObj = object
|
||||||
flags, ppflags: string
|
flags, ppflags: string
|
||||||
recurse, inline, preprocess, ctags, defines, remove_static: bool
|
recurse, inline, preprocess, ctags, defines, removeStatic: bool
|
||||||
dynlib, compile, pragma: seq[string]
|
dynlib, compile, pragma: seq[string]
|
||||||
|
|
||||||
const DOC = """
|
const DOC = """
|
||||||
|
|
@ -125,6 +125,16 @@ proc gitReset() =
|
||||||
|
|
||||||
discard execProc("git reset --hard HEAD")
|
discard execProc("git reset --hard HEAD")
|
||||||
|
|
||||||
|
proc gitCheckout(filename: string) =
|
||||||
|
echo "Resetting file: $#" % [filename]
|
||||||
|
|
||||||
|
setCurrentDir(gOutput)
|
||||||
|
defer: setCurrentDir(gProjectDir)
|
||||||
|
|
||||||
|
let adjustedFile = filename.replace(gOutput & $DirSep, "")
|
||||||
|
|
||||||
|
discard execProc("git checkout $#" % [adjustedFile])
|
||||||
|
|
||||||
proc gitRemotePull(url: string, pull=true) =
|
proc gitRemotePull(url: string, pull=true) =
|
||||||
if dirExists(gOutput/".git"):
|
if dirExists(gOutput/".git"):
|
||||||
if pull:
|
if pull:
|
||||||
|
|
@ -531,7 +541,7 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
|
||||||
if c2nimConfig.defines and (c2nimConfig.preprocess or c2nimConfig.ctags):
|
if c2nimConfig.defines and (c2nimConfig.preprocess or c2nimConfig.ctags):
|
||||||
prepend(cfile, getDefines(file, c2nimConfig.inline))
|
prepend(cfile, getDefines(file, c2nimConfig.inline))
|
||||||
|
|
||||||
if c2nimConfig.remove_static:
|
if c2nimConfig.removeStatic:
|
||||||
removeStatic(cfile)
|
removeStatic(cfile)
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -646,6 +656,9 @@ proc doActions(file: string, c2nimConfig: var c2nimConfigObj, cfg: OrderedTableR
|
||||||
if action == "create":
|
if action == "create":
|
||||||
createDir(file.splitPath().head)
|
createDir(file.splitPath().head)
|
||||||
writeFile(file, cfg[act])
|
writeFile(file, cfg[act])
|
||||||
|
elif action == "removestatic":
|
||||||
|
removeStatic(sfile)
|
||||||
|
c2nimConfig.removeStatic = true
|
||||||
elif action in @["prepend", "append", "replace", "comment",
|
elif action in @["prepend", "append", "replace", "comment",
|
||||||
"rename", "compile", "dynlib", "pragma",
|
"rename", "compile", "dynlib", "pragma",
|
||||||
"pipe"] and sfile != "":
|
"pipe"] and sfile != "":
|
||||||
|
|
@ -728,25 +741,25 @@ proc runFile(file: string, cfgin: OrderedTableRef) =
|
||||||
var noprocess = false
|
var noprocess = false
|
||||||
|
|
||||||
for act in cfg.keys():
|
for act in cfg.keys():
|
||||||
if cfg[act] == "true":
|
let (action, val) = getKey(act)
|
||||||
if act == "recurse":
|
if val == true:
|
||||||
c2nimConfig.recurse = true
|
if cfg[act] == "true":
|
||||||
elif act == "inline":
|
if action == "recurse":
|
||||||
c2nimConfig.inline = true
|
c2nimConfig.recurse = true
|
||||||
elif act == "preprocess":
|
elif action == "inline":
|
||||||
c2nimConfig.preprocess = true
|
c2nimConfig.inline = true
|
||||||
elif act == "ctags":
|
elif action == "preprocess":
|
||||||
c2nimConfig.ctags = true
|
c2nimConfig.preprocess = true
|
||||||
elif act == "defines":
|
elif action == "ctags":
|
||||||
c2nimConfig.defines = true
|
c2nimConfig.ctags = true
|
||||||
elif act == "remove_static":
|
elif action == "defines":
|
||||||
c2nimConfig.remove_static = true
|
c2nimConfig.defines = true
|
||||||
elif act == "noprocess":
|
elif action == "noprocess":
|
||||||
noprocess = true
|
noprocess = true
|
||||||
elif act == "flags":
|
elif action == "flags":
|
||||||
c2nimConfig.flags = cfg[act]
|
c2nimConfig.flags = cfg[act]
|
||||||
elif act == "ppflags":
|
elif action == "ppflags":
|
||||||
c2nimConfig.ppflags = cfg[act]
|
c2nimConfig.ppflags = cfg[act]
|
||||||
|
|
||||||
if c2nimConfig.recurse and c2nimConfig.inline:
|
if c2nimConfig.recurse and c2nimConfig.inline:
|
||||||
raise newException(Exception, "Cannot use recurse and inline simultaneously")
|
raise newException(Exception, "Cannot use recurse and inline simultaneously")
|
||||||
|
|
@ -756,6 +769,9 @@ proc runFile(file: string, cfgin: OrderedTableRef) =
|
||||||
|
|
||||||
processAfter(nimFile, c2nimConfig)
|
processAfter(nimFile, c2nimConfig)
|
||||||
|
|
||||||
|
if c2nimConfig.removeStatic:
|
||||||
|
gitCheckout(sfile)
|
||||||
|
|
||||||
proc runCfg(cfg: string) =
|
proc runCfg(cfg: string) =
|
||||||
if not fileExists(cfg):
|
if not fileExists(cfg):
|
||||||
raise newException(Exception, "Config doesn't exist: " & cfg)
|
raise newException(Exception, "Config doesn't exist: " & cfg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue