diff options
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 0c8b96226..d07201362 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -400,23 +400,20 @@ function _compile1(self, sourcefile, objectfile, depinfo, flags) -- try removing the old object file for forcing to rebuild this source file os.tryrm(objectfile) - -- attempt to find first error - if not option.get("verbose") then - - -- find the start line of error - local lines = errors:split("\n") - local start = 1 - for index, line in ipairs(lines) do - if line:find("error:", 1, true) then - start = index - break - end + -- find the start line of error + local lines = errors:split("\n") + local start = 0 + for index, line in ipairs(lines) do + if line:find("error:", 1, true) or line:find("错误:", 1, true) then + start = index + break end + end - -- get 16 lines of errors - if #lines - start > 16 then - errors = table.concat(table.slice(lines, start, start + 16), "\n") - end + -- get 16 lines of errors + if start > 0 or not option.get("verbose") then + if start == 0 then start = 1 end + errors = table.concat(table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)), "\n") end -- raise compiling errors |
