Improve compile
This commit is contained in:
parent
1e26d3e6eb
commit
7e21b2799e
2 changed files with 11 additions and 15 deletions
|
|
@ -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 != "":
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue