Caching fixes, wchar_t
This commit is contained in:
parent
d7c94bb70b
commit
27fcecaa26
2 changed files with 39 additions and 7 deletions
|
|
@ -142,15 +142,35 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
|
||||||
for fullpath in fullpaths:
|
for fullpath in fullpaths:
|
||||||
cmd.add &" {fullpath.sanitizePath}"
|
cmd.add &" {fullpath.sanitizePath}"
|
||||||
|
|
||||||
result = if outFile.nBl: fixRelFile(outFile) else:
|
let
|
||||||
# Generate filename for toast output if not specified
|
cacheFile = getNimteropCacheDir() / "toastCache" / "nimterop_" &
|
||||||
getNimteropCacheDir() / "toastCache" / "nimterop_" &
|
|
||||||
($(cmd & cacheKey).hash().abs()).addFileExt(ext)
|
($(cmd & cacheKey).hash().abs()).addFileExt(ext)
|
||||||
|
|
||||||
|
if outFile.nBl:
|
||||||
|
result = fixRelFile(outFile)
|
||||||
|
else:
|
||||||
|
result = cacheFile
|
||||||
|
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
result = result.replace(DirSep, '/')
|
result = result.replace(DirSep, '/')
|
||||||
|
|
||||||
if not fileExists(result) or gStateCT.nocache or compileOption("forceBuild"):
|
let
|
||||||
|
# When to regenerate the wrapper
|
||||||
|
regen =
|
||||||
|
if gStateCT.nocache or compileOption("forceBuild"):
|
||||||
|
# No caching or forced
|
||||||
|
true
|
||||||
|
elif not fileExists(result):
|
||||||
|
# Cache or outfile doesn't exist
|
||||||
|
true
|
||||||
|
elif outFile.nBl and (not fileExists(cacheFile) or
|
||||||
|
result.getFileDate() > cacheFile.getFileDate()):
|
||||||
|
# Outfile exists but cache doesn't or outdated
|
||||||
|
true
|
||||||
|
else:
|
||||||
|
false
|
||||||
|
|
||||||
|
if regen:
|
||||||
let
|
let
|
||||||
dir = result.parentDir()
|
dir = result.parentDir()
|
||||||
if not dirExists(dir):
|
if not dirExists(dir):
|
||||||
|
|
@ -160,7 +180,19 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
|
||||||
|
|
||||||
var
|
var
|
||||||
(output, ret) = execAction(cmd, die = false)
|
(output, ret) = execAction(cmd, die = false)
|
||||||
doAssert ret == 0, "\n\n" & (if result.fileExists(): result.readFile() else: "") & output
|
if ret != 0:
|
||||||
|
# If toast fails, print failure to output and delete any generated files
|
||||||
|
let errout = if result.fileExists(): result.readFile() & output else: output
|
||||||
|
rmFile(result)
|
||||||
|
doAssert false, "\n\n" & errout & "\n"
|
||||||
|
|
||||||
|
# Write empty cache file to track changes when outFile specified
|
||||||
|
if outFile.nBl:
|
||||||
|
let dir = cacheFile.parentDir()
|
||||||
|
if not dirExists(dir):
|
||||||
|
mkdir(dir)
|
||||||
|
|
||||||
|
writeFile(cacheFile, "")
|
||||||
|
|
||||||
macro cOverride*(body): untyped =
|
macro cOverride*(body): untyped =
|
||||||
## When the wrapper code generated by nimterop is missing certain symbols or not
|
## When the wrapper code generated by nimterop is missing certain symbols or not
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ when defined(cpp):
|
||||||
# not defined in <cwchar> nor any other header).
|
# not defined in <cwchar> nor any other header).
|
||||||
type wchar_t* {.importc.} = object
|
type wchar_t* {.importc.} = object
|
||||||
else:
|
else:
|
||||||
type wchar_t* {.importc, header:"<cwchar>".} = object
|
type wchar_t* {.importc, header:"stddef.h".} = object
|
||||||
""",
|
""",
|
||||||
|
|
||||||
"va_list": """
|
"va_list": """
|
||||||
|
|
@ -417,4 +417,4 @@ proc expandSymlinkAbs*(path: string): string =
|
||||||
result = path.expandFilename().normalizedPath()
|
result = path.expandFilename().normalizedPath()
|
||||||
except:
|
except:
|
||||||
result = path
|
result = path
|
||||||
result = result.sanitizePath(noQuote = true)
|
result = result.sanitizePath(noQuote = true)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue