summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-21 13:27:10 +0800
committerruki <[email protected]>2016-05-21 13:27:10 +0800
commit7c793cc7667d9bcc52715fa9c73bb9950d611b90 (patch)
treeb0fc4bd5ae19dad3a88cd897b26b98b1575242fb
parentafc021e2d22fd6b7d8d4b5c7b6904835eef88686 (diff)
format errors for builder
-rwxr-xr-xxmake/actions/build/builder.lua5
-rw-r--r--xmake/core/sandbox/modules/coroutine.lua43
-rw-r--r--xmake/core/sandbox/modules/debug.lua25
3 files changed, 68 insertions, 5 deletions
diff --git a/xmake/actions/build/builder.lua b/xmake/actions/build/builder.lua
index 8681a38aa..3ac966c3d 100755
--- a/xmake/actions/build/builder.lua
+++ b/xmake/actions/build/builder.lua
@@ -115,10 +115,7 @@ function _make_objects(target)
table.insert(finished, i)
else
-- resume it
- local ok, errors = coroutine.resume(job, job_index)
- if not ok then
- raise(errors)
- end
+ coroutine.resume(job, job_index)
end
end
diff --git a/xmake/core/sandbox/modules/coroutine.lua b/xmake/core/sandbox/modules/coroutine.lua
index 29fa20e0f..a704af6c3 100644
--- a/xmake/core/sandbox/modules/coroutine.lua
+++ b/xmake/core/sandbox/modules/coroutine.lua
@@ -20,6 +20,47 @@
-- @file coroutine.lua
--
+-- define module
+local sandbox_coroutine = sandbox_coroutine or {}
+
+-- load modules
+local option = require("base/option")
+local raise = require("sandbox/modules/raise")
+
+-- inherit some builtin interfaces
+sandbox_coroutine.create = coroutine.create
+sandbox_coroutine.wrap = coroutine.wrap
+sandbox_coroutine.yield = coroutine.yield
+sandbox_coroutine.status = coroutine.status
+sandbox_coroutine.running = coroutine.running
+
+-- resume coroutine
+function sandbox_coroutine.resume(co, ...)
+
+ -- resume it
+ local ok, results = coroutine.resume(co, ...)
+ if not ok then
+
+ -- get errors
+ local errors = results
+ if option.get("verbose") then
+ errors = debug.traceback(co, results)
+ elseif type(results) == "string" then
+ -- remove the prefix info
+ local _, pos = results:find(":%d+: ")
+ if pos then
+ errors = results:sub(pos + 1)
+ end
+ end
+
+ -- raise it
+ raise(errors)
+ end
+
+ -- ok
+ return results
+end
+
-- load module
-return coroutine
+return sandbox_coroutine
diff --git a/xmake/core/sandbox/modules/debug.lua b/xmake/core/sandbox/modules/debug.lua
new file mode 100644
index 000000000..cb73fdc37
--- /dev/null
+++ b/xmake/core/sandbox/modules/debug.lua
@@ -0,0 +1,25 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file debug.lua
+--
+
+-- load module
+return debug
+