Fix missing preprocessor errors, toast errors, cDisableCache not working, print generated wrapper location
This commit is contained in:
parent
f191ea7244
commit
1ad32e4574
3 changed files with 16 additions and 17 deletions
|
|
@ -82,18 +82,6 @@ proc getCacheValue(fullpaths: seq[string]): string =
|
|||
for fullpath in fullpaths:
|
||||
result &= getCacheValue(fullpath)
|
||||
|
||||
proc getToastError(output: string): string =
|
||||
# Filter out preprocessor errors
|
||||
for line in output.splitLines():
|
||||
if "fatal error:" in line.toLowerAscii:
|
||||
if result.len == 0:
|
||||
result = "\n\nFailed in preprocessing, check if `cIncludeDir()` is needed or compiler `mode` is correct (c/cpp)"
|
||||
result &= "\n\nERROR:$1\n" % line.split("fatal error:")[1]
|
||||
|
||||
# Toast error
|
||||
if result.Bl:
|
||||
result = "\n\n" & output
|
||||
|
||||
proc getNimCheckError(nimFile: string) =
|
||||
let
|
||||
(check, _) = execAction(
|
||||
|
|
@ -159,7 +147,7 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
|
|||
when defined(Windows):
|
||||
result = result.replace(DirSep, '/')
|
||||
|
||||
if not fileExists(result) or compileOption("forceBuild"):
|
||||
if not fileExists(result) or gStateCT.nocache or compileOption("forceBuild"):
|
||||
let
|
||||
dir = result.parentDir()
|
||||
if not dirExists(dir):
|
||||
|
|
@ -168,8 +156,8 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
|
|||
cmd.add &" -o {result.sanitizePath}"
|
||||
|
||||
var
|
||||
(_, ret) = execAction(cmd, die = false)
|
||||
doAssert ret == 0, getToastError(result.readFile())
|
||||
(output, ret) = execAction(cmd, die = false)
|
||||
doAssert ret == 0, result.readFile() & output
|
||||
|
||||
macro cOverride*(body): untyped =
|
||||
## When the wrapper code generated by nimterop is missing certain symbols or not
|
||||
|
|
@ -577,6 +565,8 @@ macro cImport*(filenames: static seq[string], recurse: static bool = false, dynl
|
|||
if gStateCT.debug:
|
||||
gecho nimFile.readFile()
|
||||
|
||||
gecho "# Saved to " & nimFile
|
||||
|
||||
try:
|
||||
let
|
||||
nimFileNode = newStrLitNode(nimFile.changeFileExt(""))
|
||||
|
|
@ -673,7 +663,7 @@ macro c2nImport*(filename: static string, recurse: static bool = false, dynlib:
|
|||
nimFile = if nimFile.nBl: fixRelFile(nimFile) else: hFile.changeFileExt("nim")
|
||||
header = "header" & fullpath.splitFile().name.split(seps = {'-', '.'}).join()
|
||||
|
||||
if not fileExists(nimFile) or compileOption("forceBuild"):
|
||||
if not fileExists(nimFile) or gStateCT.nocache or compileOption("forceBuild"):
|
||||
var
|
||||
cmd = when defined(Windows): "cmd /c " else: ""
|
||||
cmd &= &"c2nim {hFile} --header:{header} --out:{nimFile.sanitizePath}"
|
||||
|
|
@ -699,6 +689,8 @@ macro c2nImport*(filename: static string, recurse: static bool = false, dynlib:
|
|||
if gStateCT.debug:
|
||||
gecho nimFile.readFile()
|
||||
|
||||
gecho "# Saved to " & nimFile
|
||||
|
||||
try:
|
||||
let
|
||||
nimFileNode = newStrLitNode(nimFile.changeFileExt(""))
|
||||
|
|
|
|||
|
|
@ -338,6 +338,10 @@ proc getPreprocessor*(gState: State, fullpath: string) =
|
|||
start = true
|
||||
newHeaders.incl line
|
||||
break
|
||||
elif ": fatal error:" in line:
|
||||
doAssert false,
|
||||
"\n\nFailed in preprocessing, check if `cIncludeDir()` is needed or compiler `mode` is correct (c/cpp)" &
|
||||
"\n\nERROR:$1\n" % line.split(": fatal error:")[1]
|
||||
else:
|
||||
if start:
|
||||
if "#undef" in line:
|
||||
|
|
@ -345,6 +349,9 @@ proc getPreprocessor*(gState: State, fullpath: string) =
|
|||
gState.code.add line & "\n"
|
||||
elif not p.running(): break
|
||||
p.close()
|
||||
assert p.peekExitCode() == 0,
|
||||
gState.code & "\n\nFailed in preprocessing:\n " &
|
||||
getCompiler() & " " & args.join(" ")
|
||||
gState.headersProcessed.incl newHeaders
|
||||
|
||||
# Plugin related
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ typedef union sx_ivec3 {
|
|||
struct {
|
||||
int x;
|
||||
int y;
|
||||
struct z {
|
||||
struct {
|
||||
int z;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue