diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2018-07-07 16:57:23 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2018-07-07 16:57:23 -0500 |
| commit | a0369758afda24a0332f776c7a9d52a4ea9275ce (patch) | |
| tree | 06dce71891769fc5e03ee80885ae2c11a8d79671 | |
| parent | bb881a2e653d231ec036db6883ed42d8984eb576 (diff) | |
| download | nimgen-a0369758afda24a0332f776c7a9d52a4ea9275ce.tar.gz nimgen-a0369758afda24a0332f776c7a9d52a4ea9275ce.zip | |
Support 0.17.0 onwards, fix IOErrorv0.2.2
| -rw-r--r-- | nimgen.nim | 24 | ||||
| -rw-r--r-- | nimgen.nimble | 2 |
2 files changed, 11 insertions, 15 deletions
@@ -194,15 +194,17 @@ proc search(file: string): string = # ### # Loading / unloading +proc openRetry(file: string, mode: FileMode = fmRead): File = + while true: + try: + result = open(file, mode) + break + except IOError: + sleep(100) + template withFile(file: string, body: untyped): untyped = if fileExists(file): - var f: File - while true: - try: - f = open(file) - break - except: - sleep(100) + var f = openRetry(file) var contentOrig = f.readAll() f.close() @@ -211,7 +213,7 @@ template withFile(file: string, body: untyped): untyped = body if content != contentOrig: - var f = open(file, fmWrite) + f = openRetry(file, fmWrite) write(f, content) f.close() else: @@ -476,9 +478,6 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) = cfile = "temp-$#.c" % [outfile.extractFilename()] writeFile(cfile, runCtags(file)) - while not fileExists(cfile): - sleep(10) - if c2nimConfig.defines and (c2nimConfig.preprocess or c2nimConfig.ctags): prepend(cfile, getDefines(file, c2nimConfig.inline)) @@ -534,9 +533,6 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) = cmd = "cmd /c " & cmd discard execProc(cmd) - while not fileExists(outfile): - sleep(10) - if c2nimConfig.preprocess or c2nimConfig.ctags: try: removeFile(cfile) diff --git a/nimgen.nimble b/nimgen.nimble index e0833ef..2a048b9 100644 --- a/nimgen.nimble +++ b/nimgen.nimble @@ -1,6 +1,6 @@ # Package -version = "0.2.1" +version = "0.2.2" author = "genotrance" description = "c2nim helper to simplify and automate the wrapping of C libraries" license = "MIT" |
