Improve compile

This commit is contained in:
Ganesh Viswanathan 2018-08-15 15:19:59 -05:00
commit 7e21b2799e
2 changed files with 11 additions and 15 deletions

View file

@ -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 != "":

View file

@ -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