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:
|
for fullpath in fullpaths:
|
||||||
result &= getCacheValue(fullpath)
|
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) =
|
proc getNimCheckError(nimFile: string) =
|
||||||
let
|
let
|
||||||
(check, _) = execAction(
|
(check, _) = execAction(
|
||||||
|
|
@ -159,7 +147,7 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
result = result.replace(DirSep, '/')
|
result = result.replace(DirSep, '/')
|
||||||
|
|
||||||
if not fileExists(result) or compileOption("forceBuild"):
|
if not fileExists(result) or gStateCT.nocache or compileOption("forceBuild"):
|
||||||
let
|
let
|
||||||
dir = result.parentDir()
|
dir = result.parentDir()
|
||||||
if not dirExists(dir):
|
if not dirExists(dir):
|
||||||
|
|
@ -168,8 +156,8 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
|
||||||
cmd.add &" -o {result.sanitizePath}"
|
cmd.add &" -o {result.sanitizePath}"
|
||||||
|
|
||||||
var
|
var
|
||||||
(_, ret) = execAction(cmd, die = false)
|
(output, ret) = execAction(cmd, die = false)
|
||||||
doAssert ret == 0, getToastError(result.readFile())
|
doAssert ret == 0, result.readFile() & output
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -577,6 +565,8 @@ macro cImport*(filenames: static seq[string], recurse: static bool = false, dynl
|
||||||
if gStateCT.debug:
|
if gStateCT.debug:
|
||||||
gecho nimFile.readFile()
|
gecho nimFile.readFile()
|
||||||
|
|
||||||
|
gecho "# Saved to " & nimFile
|
||||||
|
|
||||||
try:
|
try:
|
||||||
let
|
let
|
||||||
nimFileNode = newStrLitNode(nimFile.changeFileExt(""))
|
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")
|
nimFile = if nimFile.nBl: fixRelFile(nimFile) else: hFile.changeFileExt("nim")
|
||||||
header = "header" & fullpath.splitFile().name.split(seps = {'-', '.'}).join()
|
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
|
var
|
||||||
cmd = when defined(Windows): "cmd /c " else: ""
|
cmd = when defined(Windows): "cmd /c " else: ""
|
||||||
cmd &= &"c2nim {hFile} --header:{header} --out:{nimFile.sanitizePath}"
|
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:
|
if gStateCT.debug:
|
||||||
gecho nimFile.readFile()
|
gecho nimFile.readFile()
|
||||||
|
|
||||||
|
gecho "# Saved to " & nimFile
|
||||||
|
|
||||||
try:
|
try:
|
||||||
let
|
let
|
||||||
nimFileNode = newStrLitNode(nimFile.changeFileExt(""))
|
nimFileNode = newStrLitNode(nimFile.changeFileExt(""))
|
||||||
|
|
|
||||||
|
|
@ -338,6 +338,10 @@ proc getPreprocessor*(gState: State, fullpath: string) =
|
||||||
start = true
|
start = true
|
||||||
newHeaders.incl line
|
newHeaders.incl line
|
||||||
break
|
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:
|
else:
|
||||||
if start:
|
if start:
|
||||||
if "#undef" in line:
|
if "#undef" in line:
|
||||||
|
|
@ -345,6 +349,9 @@ proc getPreprocessor*(gState: State, fullpath: string) =
|
||||||
gState.code.add line & "\n"
|
gState.code.add line & "\n"
|
||||||
elif not p.running(): break
|
elif not p.running(): break
|
||||||
p.close()
|
p.close()
|
||||||
|
assert p.peekExitCode() == 0,
|
||||||
|
gState.code & "\n\nFailed in preprocessing:\n " &
|
||||||
|
getCompiler() & " " & args.join(" ")
|
||||||
gState.headersProcessed.incl newHeaders
|
gState.headersProcessed.incl newHeaders
|
||||||
|
|
||||||
# Plugin related
|
# Plugin related
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ typedef union sx_ivec3 {
|
||||||
struct {
|
struct {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
struct z {
|
struct {
|
||||||
int z;
|
int z;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue