diff options
| author | ruki <[email protected]> | 2017-05-18 10:48:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-05-18 10:48:09 +0800 |
| commit | c334bada03f7259ef16e223cd7f9190eb0f1f4f4 (patch) | |
| tree | 7c0e682b5f7ebcc11d0f841214530bfbc413002c /xmake/tools/gcc.lua | |
| parent | 0b46e6458c1bed9cf104195d3b83845c3c86589e (diff) | |
fix try-catch and improve gcc error info
Diffstat (limited to 'xmake/tools/gcc.lua')
| -rw-r--r-- | xmake/tools/gcc.lua | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua index 7cd135215..94bc201ed 100644 --- a/xmake/tools/gcc.lua +++ b/xmake/tools/gcc.lua @@ -319,33 +319,21 @@ function _compile1(sourcefile, objectfile, incdepfile, flags) local outdata, errdata = os.iorun(_compcmd1(sourcefile, objectfile, flags)) return (outdata or "") .. (errdata or "") end, - finally + catch { - function (ok, errors) + function (errors) - -- parse warnings and errors - local errinfos = nil - local warnings = nil - for _, errline in ipairs(errors:split('\n')) do - if errinfos or errline:find("%serror:") or errline:find("错误") then - errinfos = errinfos or {} - table.insert(errinfos, errline) - else - warnings = warnings or {} - if #warnings < 8 then - table.insert(warnings, errline) - end - end - end + -- compiling errors + os.raise(errors) + end + }, + finally + { + function (ok, warnings) -- print some warnings - if warnings and option.get("verbose") then - cprint("${yellow}%s", table.concat(warnings, '\n')) - end - - -- raise errors - if errinfos then - os.raise(table.concat(errinfos, '\n')) + if warnings and #warnings > 0 and option.get("verbose") then + cprint("${yellow}%s", table.concat(table.slice(warnings:split('\n'), 1, 8), '\n')) end end } |
