Caching cImport content
This commit is contained in:
parent
abbd08d6de
commit
7bc53080e8
2 changed files with 16 additions and 2 deletions
|
|
@ -59,7 +59,7 @@ Detailed documentation is still forthcoming.
|
||||||
|
|
||||||
`cIncludeDir("XXX")` - add an include directory that is forwarded to the compiler using `{.passC: "-IXXX".}`
|
`cIncludeDir("XXX")` - add an include directory that is forwarded to the compiler using `{.passC: "-IXXX".}`
|
||||||
|
|
||||||
`cImport("header.h")` - import all supported definitions from header file
|
`cImport("header.h")` - import all supported definitions from header file. Output is cached in nimcache unless header.h changes or by using `nim -f`
|
||||||
|
|
||||||
`cImport("header.h", recurse=true)` - import all supported definitions from header file and #includes
|
`cImport("header.h", recurse=true)` - import all supported definitions from header file and #includes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,20 @@ proc walkDirImpl(indir, inext: string, file=true): seq[string] =
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
result = output.splitLines()
|
result = output.splitLines()
|
||||||
|
|
||||||
|
proc getFileDate(fullpath: string): string =
|
||||||
|
var
|
||||||
|
ret = 0
|
||||||
|
cmd =
|
||||||
|
when defined(Windows):
|
||||||
|
&"cmd /c for %a in ({fullpath.quoteShell}) do echo %~ta"
|
||||||
|
else:
|
||||||
|
&"stat -c %y {fullpath.quoteShell}"
|
||||||
|
|
||||||
|
(result, ret) = gorgeEx(cmd)
|
||||||
|
|
||||||
|
if ret != 0:
|
||||||
|
doAssert false, "File date error: " & fullpath & "\n" & result
|
||||||
|
|
||||||
proc getToast(fullpath: string, recurse: bool = false): string =
|
proc getToast(fullpath: string, recurse: bool = false): string =
|
||||||
var
|
var
|
||||||
cmd = when defined(Windows): "cmd /c " else: ""
|
cmd = when defined(Windows): "cmd /c " else: ""
|
||||||
|
|
@ -70,7 +84,7 @@ proc getToast(fullpath: string, recurse: bool = false): string =
|
||||||
|
|
||||||
cmd.add &"{fullpath.quoteShell}"
|
cmd.add &"{fullpath.quoteShell}"
|
||||||
echo cmd
|
echo cmd
|
||||||
var (output, exitCode) = gorgeEx(cmd)
|
var (output, exitCode) = gorgeEx(cmd, cache=getFileDate(fullpath))
|
||||||
doAssert exitCode == 0, $exitCode
|
doAssert exitCode == 0, $exitCode
|
||||||
result = output
|
result = output
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue