diff options
| author | ruki <[email protected]> | 2016-12-14 09:37:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-12-14 09:37:32 +0800 |
| commit | 904e8c1e0a5ae2f0d6df767f41cf0a3a13a087e4 (patch) | |
| tree | d34101d00578631f428ec521d88efa1145c2ce19 | |
| parent | 4ea08c92f616bd2c126c36d2bebb5f322ee21c9b (diff) | |
improve gcc error and warning tips
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rwxr-xr-x | xmake/actions/build/kinds/binary.lua | 2 | ||||
| -rwxr-xr-x | xmake/actions/build/kinds/object.lua | 6 | ||||
| -rwxr-xr-x | xmake/actions/build/kinds/shared.lua | 2 | ||||
| -rwxr-xr-x | xmake/actions/build/kinds/static.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/try.lua | 2 | ||||
| -rwxr-xr-x | xmake/tools/gcc.lua | 39 |
7 files changed, 47 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index be9bee4bd..4b1020690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Changes * Support vs2017 for the project plugin +* Improve gcc error and warning tips ### Bugs fixed @@ -192,6 +193,7 @@ ### 改进 * 工程生成插件支持vs2017 +* 改进gcc/clang编译器警告和错误提示 ### Bugs修复 diff --git a/xmake/actions/build/kinds/binary.lua b/xmake/actions/build/kinds/binary.lua index c2736d8ae..2cbbf79b6 100755 --- a/xmake/actions/build/kinds/binary.lua +++ b/xmake/actions/build/kinds/binary.lua @@ -51,7 +51,7 @@ function build(target, g) local verbose = option.get("verbose") -- trace percent into - cprintf("${yellow}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount) + cprintf("${green}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount) if verbose then cprint("${dim magenta}linking.$(mode) %s", path.filename(targetfile)) else diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua index 6fee1ef37..057dfc630 100755 --- a/xmake/actions/build/kinds/object.lua +++ b/xmake/actions/build/kinds/object.lua @@ -34,7 +34,7 @@ function _build_from_object(target, sourcefile, objectfile, percent) local verbose = option.get("verbose") -- trace percent info - cprintf("${yellow}[%02d%%]:${clear} ", percent) + cprintf("${green}[%02d%%]:${clear} ", percent) if verbose then cprint("${dim magenta}inserting.$(mode) %s", sourcefile) else @@ -57,7 +57,7 @@ function _build_from_static(target, sourcefile, objectfile, percent) local verbose = option.get("verbose") -- trace percent info - cprintf("${yellow}[%02d%%]:${clear} ", percent) + cprintf("${green}[%02d%%]:${clear} ", percent) if verbose then cprint("${dim magenta}inserting.$(mode) %s", sourcefile) else @@ -152,7 +152,7 @@ function _build(target, g, index) local verbose = option.get("verbose") -- trace percent info - cprintf("${yellow}[%02d%%]:${clear} ", percent) + cprintf("${green}[%02d%%]:${clear} ", percent) if verbose then cprint("${dim}%scompiling.$(mode) %s", ifelse(config.get("ccache"), "ccache ", ""), sourcefile) else diff --git a/xmake/actions/build/kinds/shared.lua b/xmake/actions/build/kinds/shared.lua index 67fa81963..0559c4ed4 100755 --- a/xmake/actions/build/kinds/shared.lua +++ b/xmake/actions/build/kinds/shared.lua @@ -64,7 +64,7 @@ function build(target, g) local verbose = option.get("verbose") -- trace percent info - cprintf("${yellow}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount) + cprintf("${green}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount) if verbose then cprint("${dim magenta}linking.$(mode) %s", path.filename(targetfile)) else diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua index 7385da750..8753fb125 100755 --- a/xmake/actions/build/kinds/static.lua +++ b/xmake/actions/build/kinds/static.lua @@ -64,7 +64,7 @@ function build(target, g) local verbose = option.get("verbose") -- trace percent info - cprintf("${yellow}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount) + cprintf("${green}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount) if verbose then cprint("${dim magenta}archiving.$(mode) %s", path.filename(targetfile)) else diff --git a/xmake/core/sandbox/modules/try.lua b/xmake/core/sandbox/modules/try.lua index a85008269..dead086a8 100644 --- a/xmake/core/sandbox/modules/try.lua +++ b/xmake/core/sandbox/modules/try.lua @@ -108,7 +108,7 @@ function sandbox_try.try(block) -- run the finally function if funcs and funcs.finally then - funcs.finally(utils.ifelse(ok, errors, nil)) + funcs.finally(ok, errors) end -- ok? diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua index f049fe32e..83d388721 100755 --- a/xmake/tools/gcc.lua +++ b/xmake/tools/gcc.lua @@ -22,6 +22,7 @@ -- imports import("core.tool.tool") +import("core.base.option") import("core.project.config") import("core.project.project") @@ -271,7 +272,43 @@ function compile(sourcefile, objectfile, incdepfile, flags) os.mkdir(path.directory(objectfile)) -- compile it - os.run(compcmd(sourcefile, objectfile, flags)) + try + { + function () + local outdata, errdata = os.iorun(compcmd(sourcefile, objectfile, flags)) + return (outdata or "") .. (errdata or "") + end, + finally + { + function (ok, 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:") then + errinfos = errinfos or {} + table.insert(errinfos, errline) + else + warnings = warnings or {} + if #warnings < 8 then + table.insert(warnings, errline) + end + end + end + + -- print some warnings + if warnings and (not ok or option.get("verbose")) then + cprint("${yellow}%s", table.concat(warnings, '\n')) + end + + -- raise errors + if errinfos then + os.raise(table.concat(errinfos, '\n')) + end + end + } + } -- generate includes file if incdepfile and _g.kind ~= "as" then |
