From 0449f548dc951eca59bb6681709c9d555149e143 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Mon, 18 Jun 2018 19:53:54 +0900 Subject: [PATCH] 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. --- nimgen.nim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nimgen.nim b/nimgen.nim index 94407cb..7f7c957 100644 --- a/nimgen.nim +++ b/nimgen.nim @@ -501,13 +501,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" @@ -537,7 +538,10 @@ 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: + passC &= "const header$# = currentSourcePath().splitPath().head & \"/$#\"\n" % [fname, fincl] extflags = "--header:header$#" % fname # Run c2nim on generated file