From 744ce235235533e695430daa1f96cbd35c69ac01 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 23 May 2019 00:46:44 +0800 Subject: add ndk_stdcxx option for ndk --- xmake/core/base/utils.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'xmake/core/base/utils.lua') diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua index 6f0f71f5c..c8743a58f 100644 --- a/xmake/core/base/utils.lua +++ b/xmake/core/base/utils.lua @@ -179,5 +179,35 @@ function utils.ifelse(a, b, c) if a then return b else return c end end +-- try to call script +function utils.trycall(script, traceback, ...) + return xpcall(script, function (errors) + + -- get traceback + traceback = traceback or debug.traceback + + -- decode it if errors is encoded table string + if errors then + local _, pos = errors:find("[@encode(error)]: ", 1, true) + if pos then + local deserrs + local rawerrs = errors:sub(pos + 1) + errors, deserrs = rawerrs:deserialize() + if not errors then + errors = deserrs + end + if type(errors) == "table" then + setmetatable(errors, { __tostring = function (self) + return rawerrs + end + }) + end + return errors + end + end + return traceback(errors) + end, ...) +end + -- return module return utils -- cgit v1.3.1