diff options
| author | ruki <[email protected]> | 2015-12-03 09:25:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-12-03 09:25:41 +0800 |
| commit | 8ac451453097e9637f02fb043f86eaf916929e65 (patch) | |
| tree | 5da21bdbfdd294866b3be5e780d2ae81e3db096a | |
| parent | 65be932e7f4212e56fabf232d95498b3b783d945 (diff) | |
fix show long error info bug
| -rw-r--r-- | xmake/scripts/action/_build.lua | 2 | ||||
| -rw-r--r-- | xmake/scripts/base/io.lua | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/xmake/scripts/action/_build.lua b/xmake/scripts/action/_build.lua index 33e356e1f..7fea4be22 100644 --- a/xmake/scripts/action/_build.lua +++ b/xmake/scripts/action/_build.lua @@ -84,7 +84,7 @@ function _build.done() if not makefile.build(target_name) then -- error print("") - io.cat(rule.logfile(), 16) + io.tail(rule.logfile(), 32) utils.error("build target: %s failed!\n", target_name) return false end diff --git a/xmake/scripts/base/io.lua b/xmake/scripts/base/io.lua index 9c0ece688..66b23911a 100644 --- a/xmake/scripts/base/io.lua +++ b/xmake/scripts/base/io.lua @@ -273,5 +273,52 @@ function io.cat(filepath, linecount) end end +-- tail the given file +function io.tail(filepath, linecount) + + -- open file + local file = io.open(filepath, "r") + if file then + + -- read lines + local lines = {} + for line in file:lines() do + table.insert(lines, line) + end + + -- tail lines + local tails = {} + if #lines ~= 0 then + local count = 1 + for index = #lines, 1, -1 do + + -- show line + table.insert(tails, lines[index]) + + -- end? + if linecount and count >= linecount then + break + end + + -- update the line count + count = count + 1 + end + end + + -- show tails + if #tails ~= 0 then + for index = #tails, 1, -1 do + + -- show tail + print(tails[index]) + + end + end + + -- exit file + file:close() + end +end + -- return module: io return io |
