From b40bc697d9ce4e20836b60941daabfeaae080b28 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 3 Aug 2017 09:09:17 +0800 Subject: improve errors tips --- xmake/core/sandbox/modules/os.lua | 12 ++++++++++-- xmake/core/sandbox/modules/utils.lua | 1 - xmake/modules/core/tools/gcc.lua | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index adeb2874f..839d5cbba 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -302,7 +302,11 @@ function sandbox_os.iorun(cmd, ...) -- run it local ok, outdata, errdata = os.iorun(cmd) if not ok then - os.raise((outdata or "") .. (errdata or "")) + local errors = errdata or "" + if #errors:trim() == 0 then + errors = outdata or "" + end + os.raise(errors) end -- ok @@ -318,7 +322,11 @@ function sandbox_os.iorunv(program, argv) -- run it local ok, outdata, errdata = os.iorunv(program, argv) if not ok then - os.raise((outdata or "") .. (errdata or "")) + local errors = errdata or "" + if #errors:trim() == 0 then + errors = outdata or "" + end + os.raise(errors) end -- ok diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua index f72da0423..40d2c6170 100644 --- a/xmake/core/sandbox/modules/utils.lua +++ b/xmake/core/sandbox/modules/utils.lua @@ -77,7 +77,6 @@ function sandbox_utils.print(format, ...) catch { function (errors) - print(errors) -- print multi-variables with raw lua action sandbox_utils._print(format, unpack(args)) end diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 7fbe4aa3e..4d63e4837 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -400,6 +400,14 @@ function _compile1(self, sourcefile, objectfile, depinfo, flags) -- try removing the old object file for forcing to rebuild this source file os.tryrm(objectfile) + -- get last 16 lines + if not option.get("verbose") then + local lines = errors:split("\n") + if #lines > 32 then + errors = table.concat(table.slice(lines, #lines - 16), "\n") + end + end + -- raise compiling errors os.raise(errors) end -- cgit v1.3.1