aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Yakimowich-Payne <jyapayne@gmail.com>2018-07-11 07:02:36 +0900
committerJoey Yakimowich-Payne <jyapayne@gmail.com>2018-07-11 07:36:40 +0900
commit14b119f433f7584f2b9a529f388b4f298f3da874 (patch)
tree9f11c1fd09e039ebb661df2c1507b85e2f972a31
parent0d0506675c6fc91de1fd6ac59faeece0f248ac4a (diff)
downloadnimgen-14b119f433f7584f2b9a529f388b4f298f3da874.tar.gz
nimgen-14b119f433f7584f2b9a529f388b4f298f3da874.zip
Move remove static and reset after processing
-rw-r--r--nimgen.nim22
1 files changed, 18 insertions, 4 deletions
diff --git a/nimgen.nim b/nimgen.nim
index e520309..32e640b 100644
--- a/nimgen.nim
+++ b/nimgen.nim
@@ -25,7 +25,7 @@ var
type
c2nimConfigObj = object
flags, ppflags: string
- recurse, inline, preprocess, ctags, defines, remove_static: bool
+ recurse, inline, preprocess, ctags, defines, removeStatic: bool
dynlib, compile, pragma: seq[string]
const DOC = """
@@ -126,6 +126,16 @@ proc gitReset() =
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) =
if dirExists(gOutput/".git"):
if pull:
@@ -528,7 +538,7 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
if c2nimConfig.defines and (c2nimConfig.preprocess or c2nimConfig.ctags):
prepend(cfile, getDefines(file, c2nimConfig.inline))
- if c2nimConfig.remove_static:
+ if c2nimConfig.removeStatic:
removeStatic(cfile)
var
@@ -659,6 +669,9 @@ proc runFile(file: string, cfgin: OrderedTableRef) =
if action == "create":
createDir(file.splitPath().head)
writeFile(file, cfg[act])
+ elif action == "removestatic":
+ removeStatic(sfile)
+ c2nimConfig.removeStatic = true
elif action in @["prepend", "append", "replace", "comment",
"rename", "compile", "dynlib", "pragma",
"pipe"] and sfile != "":
@@ -709,8 +722,6 @@ proc runFile(file: string, cfgin: OrderedTableRef) =
c2nimConfig.ctags = true
elif action == "defines":
c2nimConfig.defines = true
- elif act == "remove_static":
- c2nimConfig.remove_static = true
elif action == "noprocess":
noprocess = true
elif action == "flags":
@@ -725,6 +736,9 @@ proc runFile(file: string, cfgin: OrderedTableRef) =
if not noprocess:
c2nim(file, getNimout(sfile), c2nimConfig)
+ if c2nimConfig.removeStatic:
+ gitCheckout(sfile)
+
proc runCfg(cfg: string) =
if not fileExists(cfg):
echo "Config doesn't exist: " & cfg