diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2018-08-15 15:19:59 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2018-08-15 15:19:59 -0500 |
| commit | 7e21b2799eafaad9662bf2d754e94d25eea25100 (patch) | |
| tree | 53ef1c90504e7830435a18dea9fd0eb2c98150b7 | |
| parent | 1e26d3e6eb9ab1036d4992476b71ac02616af4ed (diff) | |
| download | nimgen-7e21b2799eafaad9662bf2d754e94d25eea25100.tar.gz nimgen-7e21b2799eafaad9662bf2d754e94d25eea25100.zip | |
Improve compile
| -rw-r--r-- | src/nimgen/c2nim.nim | 6 | ||||
| -rw-r--r-- | src/nimgen/gencore.nim | 20 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/nimgen/c2nim.nim b/src/nimgen/c2nim.nim index e887b29..30f23f0 100644 --- a/src/nimgen/c2nim.nim +++ b/src/nimgen/c2nim.nim @@ -100,11 +100,7 @@ proc c2nim*(fl, outfile: string, c2nimConfig: c2nimConfigObj) = # Include {.compile.} directives for cpl in c2nimConfig.compile: - let fcpl = search(cpl) - if getFileInfo(fcpl).kind == pcFile: - prepend(outfile, compile(c2nimConfig.flags, file=fcpl)) - else: - prepend(outfile, compile(c2nimConfig.flags, dir=fcpl)) + prepend(outfile, compile(cpl, c2nimConfig.flags)) # Add any pragmas if outpragma != "": diff --git a/src/nimgen/gencore.nim b/src/nimgen/gencore.nim index 42b82c0..000651e 100644 --- a/src/nimgen/gencore.nim +++ b/src/nimgen/gencore.nim @@ -17,7 +17,7 @@ proc addEnv*(str: string): string = return newStr -proc compile*(flags: string, dir="", file=""): string = +proc compile*(cpl, flags: string): string = var data = "" proc fcompile(file: string): string = @@ -27,18 +27,18 @@ proc compile*(flags: string, dir="", file=""): string = for f in walkFiles(dir): data &= fcompile(f) & "\n" - if dir != "": - if dir.contains("*") or dir.contains("?"): - dcompile(dir) - elif dirExists(dir): + if cpl.contains("*") or cpl.contains("?"): + dcompile(cpl) + else: + let fcpl = search(cpl) + if getFileInfo(fcpl).kind == pcFile: + data &= fcompile(fcpl) & "\n" + elif getFileInfo(fcpl).kind == pcDir: if flags.contains("cpp"): for i in @["*.C", "*.cpp", "*.c++", "*.cc", "*.cxx"]: - dcompile(dir / i) + dcompile(fcpl / i) else: - dcompile(dir / "*.c") - - if file != "" and fileExists(file): - data &= fcompile(file) & "\n" + dcompile(fcpl / "*.c") return data |
