Implement #10 - per file reset
This commit is contained in:
parent
1a2ef87087
commit
9e0eb25685
3 changed files with 18 additions and 9 deletions
|
|
@ -160,6 +160,8 @@ The following keys apply to library source code and help with generating the .ni
|
|||
|
||||
```noprocess``` = do not process this source file with c2nim [default: false] - this is useful if a file only needs to be manipulated
|
||||
|
||||
```reset``` = reset the file back to original state after all processing [default: false]
|
||||
|
||||
Multiple entries for the all following keys are possible by appending any .string to the key. E.g. dynlib.win, compile.dir
|
||||
|
||||
```compile``` = file or dir of files of source code to {.compile.} into generated .nim
|
||||
|
|
|
|||
|
|
@ -60,15 +60,13 @@ proc gitReset*() =
|
|||
|
||||
discard execProc("git reset --hard HEAD")
|
||||
|
||||
proc gitCheckout*(filename: string) {.used.} =
|
||||
echo "Resetting file: $#" % [filename]
|
||||
proc gitCheckout*(file: string) =
|
||||
echo " Resetting " & file
|
||||
|
||||
setCurrentDir(gOutput)
|
||||
defer: setCurrentDir(gProjectDir)
|
||||
|
||||
let adjustedFile = filename.replace(gOutput & $DirSep, "")
|
||||
|
||||
discard execProc("git checkout $#" % [adjustedFile])
|
||||
discard execProc("git checkout $#" % file.replace(gOutput & "/", ""))
|
||||
|
||||
proc gitRemotePull*(url: string, pull=true) =
|
||||
if dirExists(gOutput/".git"):
|
||||
|
|
|
|||
|
|
@ -24,11 +24,12 @@ proc runFile*(file: string, cfgin: OrderedTableRef = newOrderedTable[string, str
|
|||
cfg = cfgin
|
||||
sfile = search(file)
|
||||
|
||||
if sfile.len() == 0 or sfile in gDoneRecursive:
|
||||
if sfile in gDoneRecursive:
|
||||
return
|
||||
|
||||
echo "Processing " & sfile
|
||||
gDoneRecursive.add(sfile)
|
||||
if sfile.len() != 0:
|
||||
echo "Processing " & sfile
|
||||
gDoneRecursive.add(sfile)
|
||||
|
||||
for pattern in gWildcards.keys():
|
||||
var m: RegexMatch
|
||||
|
|
@ -51,6 +52,7 @@ proc runFile*(file: string, cfgin: OrderedTableRef = newOrderedTable[string, str
|
|||
let (action, val) = getKey(act)
|
||||
if val == true:
|
||||
if action == "create":
|
||||
echo "Creating " & file
|
||||
createDir(file.splitPath().head)
|
||||
writeFile(file, cfg[act])
|
||||
elif action in @["prepend", "append", "replace", "comment",
|
||||
|
|
@ -87,7 +89,9 @@ proc runFile*(file: string, cfgin: OrderedTableRef = newOrderedTable[string, str
|
|||
srch = act
|
||||
|
||||
if file.splitFile().ext != ".nim":
|
||||
var noprocess = false
|
||||
var
|
||||
noprocess = false
|
||||
reset = false
|
||||
|
||||
for act in cfg.keys():
|
||||
let (action, val) = getKey(act)
|
||||
|
|
@ -105,6 +109,8 @@ proc runFile*(file: string, cfgin: OrderedTableRef = newOrderedTable[string, str
|
|||
c2nimConfig.defines = true
|
||||
elif action == "noprocess":
|
||||
noprocess = true
|
||||
elif action == "reset":
|
||||
reset = true
|
||||
elif action == "flags":
|
||||
c2nimConfig.flags = cfg[act]
|
||||
elif action == "ppflags":
|
||||
|
|
@ -140,6 +146,9 @@ proc runFile*(file: string, cfgin: OrderedTableRef = newOrderedTable[string, str
|
|||
if incout.len() != 0:
|
||||
prepend(outfile, incout)
|
||||
|
||||
if reset:
|
||||
gitCheckout(sfile)
|
||||
|
||||
proc runCfg*(cfg: string) =
|
||||
if not fileExists(cfg):
|
||||
echo "Config doesn't exist: " & cfg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue