aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2018-08-15 14:41:41 -0500
committerGanesh Viswanathan <dev@genotrance.com>2018-08-15 14:41:41 -0500
commit1e26d3e6eb9ab1036d4992476b71ac02616af4ed (patch)
treec6850948c153ab15784f9d252e58d051cbe9d0fe /src
parent1a29b9f0f8fc08e2d6eba283026320d1aef04cc2 (diff)
downloadnimgen-1e26d3e6eb9ab1036d4992476b71ac02616af4ed.tar.gz
nimgen-1e26d3e6eb9ab1036d4992476b71ac02616af4ed.zip
More flexibility in compile flag
Diffstat (limited to 'src')
-rw-r--r--src/nimgen/c2nim.nim6
-rw-r--r--src/nimgen/gencore.nim19
2 files changed, 18 insertions, 7 deletions
diff --git a/src/nimgen/c2nim.nim b/src/nimgen/c2nim.nim
index 05954e6..e887b29 100644
--- a/src/nimgen/c2nim.nim
+++ b/src/nimgen/c2nim.nim
@@ -29,7 +29,7 @@ proc c2nim*(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
outlib = ""
outpragma = ""
- passC = "import ospaths, strutils\n"
+ passC = "import strutils\n"
passC &= """const sourcePath = currentSourcePath().split({'\\', '/'})[0..^2].join("/")""" & "\n"
@@ -102,9 +102,9 @@ proc c2nim*(fl, outfile: string, c2nimConfig: c2nimConfigObj) =
for cpl in c2nimConfig.compile:
let fcpl = search(cpl)
if getFileInfo(fcpl).kind == pcFile:
- prepend(outfile, compile(file=fcpl))
+ prepend(outfile, compile(c2nimConfig.flags, file=fcpl))
else:
- prepend(outfile, compile(dir=fcpl))
+ prepend(outfile, compile(c2nimConfig.flags, dir=fcpl))
# Add any pragmas
if outpragma != "":
diff --git a/src/nimgen/gencore.nim b/src/nimgen/gencore.nim
index 4e79d04..42b82c0 100644
--- a/src/nimgen/gencore.nim
+++ b/src/nimgen/gencore.nim
@@ -17,15 +17,26 @@ proc addEnv*(str: string): string =
return newStr
-proc compile*(dir="", file=""): string =
+proc compile*(flags: string, dir="", file=""): string =
+ var data = ""
+
proc fcompile(file: string): string =
return "{.compile: \"$#\".}" % file.replace("\\", "/")
- var data = ""
- if dir != "" and dirExists(dir):
- for f in walkFiles(dir / "*.c"):
+ proc dcompile(dir: string) =
+ for f in walkFiles(dir):
data &= fcompile(f) & "\n"
+ if dir != "":
+ if dir.contains("*") or dir.contains("?"):
+ dcompile(dir)
+ elif dirExists(dir):
+ if flags.contains("cpp"):
+ for i in @["*.C", "*.cpp", "*.c++", "*.cc", "*.cxx"]:
+ dcompile(dir / i)
+ else:
+ dcompile(dir / "*.c")
+
if file != "" and fileExists(file):
data &= fcompile(file) & "\n"