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 | |
| parent | 0b46e6458c1bed9cf104195d3b83845c3c86589e (diff) | |
fix try-catch and improve gcc error info
| -rw-r--r-- | CHANGELOG.md | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/try.lua | 5 | ||||
| -rw-r--r-- | xmake/tools/gcc.lua | 34 |
3 files changed, 22 insertions, 27 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 795dd7dc2..00b1e4720 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ * [#87](https://github.com/tboox/xmake/issues/87): Add includes and links from target deps automatically * Improve `import` to load user extension and global modules * [#93](https://github.com/tboox/xmake/pull/93): Improve `xmake lua` to run a single line command +* Improve to print gcc error and warning info + +### Bugs fixed + +* Fix `try-catch-finally` ## v2.1.4 @@ -295,6 +300,11 @@ * [#87](https://github.com/tboox/xmake/issues/87): 为依赖库目标自动添加:`includes` 和 `links` * 改进`import`接口,去加载用户扩展模块 * [#93](https://github.com/tboox/xmake/pull/93): 改进 `xmake lua`,支持运行单行命令和模块 +* 改进编译错误提示信息输出 + +### Bugs修复 + +* 修复`try-catch-finally` ## v2.1.4 diff --git a/xmake/core/sandbox/modules/try.lua b/xmake/core/sandbox/modules/try.lua index 8abcd0293..c339f4abc 100644 --- a/xmake/core/sandbox/modules/try.lua +++ b/xmake/core/sandbox/modules/try.lua @@ -93,10 +93,7 @@ function sandbox_try.try(block) assert(try) -- get catch and finally functions - local funcs = block[2] - if funcs and block[3] then - table.join2(funcs, block[2]) - end + local funcs = table.join(block[2] or {}, block[3] or {}) -- try to call it local ok, errors = xpcall(try, sandbox_try._traceback) 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 } |
