parent
84894bfa0c
commit
2e894dc907
1 changed files with 17 additions and 2 deletions
19
nimgen.nim
19
nimgen.nim
|
|
@ -224,6 +224,8 @@ proc search(file: string): string =
|
||||||
echo "File doesn't exist: " & file
|
echo "File doesn't exist: " & file
|
||||||
quit(1)
|
quit(1)
|
||||||
|
|
||||||
|
# Only keep relative directory
|
||||||
|
result = result.replace(gProjectDir & $DirSep, "")
|
||||||
return result.replace(re"[\\/]", $DirSep)
|
return result.replace(re"[\\/]", $DirSep)
|
||||||
|
|
||||||
# ###
|
# ###
|
||||||
|
|
@ -376,12 +378,25 @@ proc getIncls(file: string, inline=false): seq[string] =
|
||||||
if inline and file in gDoneInline:
|
if inline and file in gDoneInline:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
let curPath = splitFile(expandFileName(file)).dir
|
||||||
withFile(file):
|
withFile(file):
|
||||||
for f in content.findIter(re"(?m)^\s*#\s*include\s+(.*?)$"):
|
for f in content.findIter(re"(?m)^\s*#\s*include\s+(.*?)$"):
|
||||||
var inc = f.captures[0].strip()
|
var inc = f.captures[0].strip()
|
||||||
if ((gQuotes and inc.contains("\"")) or (gFilter != "" and gFilter in inc)) and (not exclude(inc)):
|
if ((gQuotes and inc.contains("\"")) or (gFilter != "" and gFilter in inc)) and (not exclude(inc)):
|
||||||
result.add(
|
let addInc = inc.replace(re"""[<>"]""", "").replace(re"\/[\*\/].*$", "").strip()
|
||||||
inc.replace(re"""[<>"]""", "").replace(re"\/[\*\/].*$", "").strip())
|
try:
|
||||||
|
# Try searching for a local library. expandFilename will throw
|
||||||
|
# OSError if the file does not exist
|
||||||
|
let
|
||||||
|
finc = expandFileName(curPath / addInc)
|
||||||
|
fname = extractFileName(finc).search()
|
||||||
|
|
||||||
|
if fname.len() > 0:
|
||||||
|
# only add if the file is non-empty
|
||||||
|
result.add(fname.search())
|
||||||
|
except OSError:
|
||||||
|
# If it's a system library
|
||||||
|
result.add(addInc)
|
||||||
|
|
||||||
result = result.deduplicate()
|
result = result.deduplicate()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue