diff options
| author | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2018-06-18 19:53:54 +0900 |
|---|---|---|
| committer | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2018-07-08 12:39:27 +0900 |
| commit | 2fc12b8577c42d7fb23e8f7d1fea2591ef0e5da9 (patch) | |
| tree | 3ae84ca3af44475450b6aa5d1e57adb3104a164c | |
| parent | 44294a7513985dafd5aabca790648e85fa5789ef (diff) | |
| download | nimgen-2fc12b8577c42d7fb23e8f7d1fea2591ef0e5da9.tar.gz nimgen-2fc12b8577c42d7fb23e8f7d1fea2591ef0e5da9.zip | |
Only include necessary file for include libs
The previous behavior caused a "Too many files open" error when
referrencing lots of libs because of the call to "gorge". This
modification retains the old behavior and also works if the library is
compiled locally.
Fixes #12
| -rw-r--r-- | nimgen.nim | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -488,13 +488,14 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) = outpragma = "" passC = "import strutils\n" - for inc in gIncludes: - passC &= ("""{.passC: "-I\"" & gorge("nimble path $#").strip() & "/$#\"".}""" % [gOutput, inc]) & "\n" + passC &= "import ospaths\n" for prag in c2nimConfig.pragma: outpragma &= "{." & prag & ".}\n" let fname = file.splitFile().name.replace(re"[\.\-]", "_") + let fincl = file.replace(gOutput, "") + if c2nimConfig.dynlib.len() != 0: let win = "when defined(Windows):\n" @@ -524,7 +525,12 @@ proc c2nim(fl, outfile: string, c2nimConfig: c2nimConfigObj) = if outlib != "": extflags &= " --dynlib:dynlib$#" % fname else: - passC &= "const header$# = \"$#\"\n" % [fname, fl] + if file.isAbsolute(): + passC &= "const header$# = \"$#\"\n" % [fname, fincl] + else: + # based on the current source directory, get the include path + # works for nimble installations and local repo clones + passC &= "const header$# = currentSourcePath().splitPath().head & \"/$#\"\n" % [fname, fincl] extflags = "--header:header$#" % fname # Run c2nim on generated file |
