diff options
| author | ruki <[email protected]> | 2019-05-23 00:46:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-05-22 22:40:27 +0800 |
| commit | 744ce235235533e695430daa1f96cbd35c69ac01 (patch) | |
| tree | 8ed3e616bbc31655eb6d8a369c5eafcba187a528 /xmake/core/base/utils.lua | |
| parent | b91f9e89bed5bf3db0f7a0e78b6c69666eab21eb (diff) | |
add ndk_stdcxx option for ndk
Diffstat (limited to 'xmake/core/base/utils.lua')
| -rw-r--r-- | xmake/core/base/utils.lua | 30 |
1 files changed, 30 insertions, 0 deletions
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 |
