summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-02-12 22:33:42 +0800
committerruki <[email protected]>2019-02-12 09:22:17 +0800
commitd7194331ea134b0e1b54a5e09a59824b9c399d83 (patch)
treeac95a37d84e5b489a2a619d1b393283bfa1a6c52
parent25bd4311c541cbf6329b8a309d8d47ceeaee5184 (diff)
improve diagnosis info
-rw-r--r--xmake/actions/build/main.lua2
-rw-r--r--xmake/core/base/interpreter.lua2
-rw-r--r--xmake/core/sandbox/modules/try.lua9
-rw-r--r--xmake/core/sandbox/sandbox.lua11
-rw-r--r--xmake/includes/check_cfuncs.lua10
-rw-r--r--xmake/includes/check_cincludes.lua10
-rw-r--r--xmake/includes/check_csnippets.lua10
-rw-r--r--xmake/includes/check_ctypes.lua10
-rw-r--r--xmake/includes/check_cxxfuncs.lua10
-rw-r--r--xmake/includes/check_cxxincludes.lua10
-rw-r--r--xmake/includes/check_cxxsnippets.lua10
-rw-r--r--xmake/includes/check_cxxtypes.lua10
-rw-r--r--xmake/includes/check_features.lua10
-rw-r--r--xmake/includes/check_links.lua10
14 files changed, 75 insertions, 49 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index 8f09a83d6..1ff43e8cc 100644
--- a/xmake/actions/build/main.lua
+++ b/xmake/actions/build/main.lua
@@ -66,8 +66,6 @@ function main()
catch
{
function (errors)
-
- -- failed
if errors then
raise(errors)
elseif targetname then
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 4938a8ce1..6e8c3bd40 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -36,7 +36,7 @@ local sandbox = require("sandbox/sandbox")
-- traceback
function interpreter._traceback(errors)
- -- not verbose?
+ -- disable backtrace?
if errors then
local _, pos = errors:find("[nobacktrace]: ", 1, true)
if pos then
diff --git a/xmake/core/sandbox/modules/try.lua b/xmake/core/sandbox/modules/try.lua
index 434f45ae6..aadcfefcf 100644
--- a/xmake/core/sandbox/modules/try.lua
+++ b/xmake/core/sandbox/modules/try.lua
@@ -34,18 +34,23 @@ local sandbox_try = sandbox_try or {}
-- traceback
function sandbox_try._traceback(errors)
- -- not verbose?
+ -- no diagnosis info?
if not option.get("diagnosis") then
if errors then
-- remove the prefix info
local _, pos = errors:find(":%d+: ")
if pos then
- return errors:sub(pos + 1)
+ errors = errors:sub(pos + 1)
end
end
return errors
end
+ -- traceback exists?
+ if errors and errors:find("stack traceback:", 1, true) then
+ return errors
+ end
+
-- init results
local results = ""
if errors then
diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua
index fcf5ef4cf..4051f85af 100644
--- a/xmake/core/sandbox/sandbox.lua
+++ b/xmake/core/sandbox/sandbox.lua
@@ -36,18 +36,23 @@ local option = require("base/option")
-- traceback
function sandbox._traceback(errors)
- -- only print error info without backtrace if not diagnosis?
+ -- no diagnosis info?
if not option.get("diagnosis") then
if errors then
-- remove the prefix info
local _, pos = errors:find(":%d+: ")
if pos then
- return errors:sub(pos + 1)
+ errors = errors:sub(pos + 1)
end
end
return errors
end
+ -- traceback exists?
+ if errors and errors:find("stack traceback:", 1, true) then
+ return errors
+ end
+
-- init results
local results = ""
if errors then
@@ -176,8 +181,6 @@ end
-- load script in the sandbox
function sandbox.load(script, ...)
-
- -- load script
return xpcall(script, sandbox._traceback, ...)
end
diff --git a/xmake/includes/check_cfuncs.lua b/xmake/includes/check_cfuncs.lua
index 3690e32bc..5769976ff 100644
--- a/xmake/includes/check_cfuncs.lua
+++ b/xmake/includes/check_cfuncs.lua
@@ -37,7 +37,8 @@
--
function check_cfuncs(definition, funcs, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cfuncs(funcs)
add_defines(definition)
if opt.links then
@@ -56,7 +57,7 @@ function check_cfuncs(definition, funcs, opt)
add_cxflags(opt.cxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check c funcs and add macro definition to the configuration files
@@ -68,7 +69,8 @@ end
--
function configvar_check_cfuncs(definition, funcs, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cfuncs(funcs)
set_configvar(definition, 1)
if opt.links then
@@ -87,5 +89,5 @@ function configvar_check_cfuncs(definition, funcs, opt)
add_cxflags(opt.cxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_cincludes.lua b/xmake/includes/check_cincludes.lua
index 2fbf1f737..b812d9c64 100644
--- a/xmake/includes/check_cincludes.lua
+++ b/xmake/includes/check_cincludes.lua
@@ -31,11 +31,12 @@
--
function check_cincludes(definition, includes, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cincludes(includes)
add_defines(definition)
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check include c files and add macro definition to the configuration files
@@ -47,9 +48,10 @@ end
--
function configvar_check_cincludes(definition, includes, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cincludes(includes)
set_configvar(definition, 1)
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_csnippets.lua b/xmake/includes/check_csnippets.lua
index 367d1e3b1..a6fe448d9 100644
--- a/xmake/includes/check_csnippets.lua
+++ b/xmake/includes/check_csnippets.lua
@@ -30,7 +30,8 @@
--
function check_csnippets(definition, snippets, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_csnippets(definition, snippets)
add_defines(definition)
if opt.links then
@@ -49,7 +50,7 @@ function check_csnippets(definition, snippets, opt)
add_cxflags(opt.cxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check c snippets and add macro definition to the configuration snippets
@@ -60,7 +61,8 @@ end
--
function configvar_check_csnippets(definition, snippets, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_csnippets(definition, snippets)
set_configvar(definition, 1)
if opt.links then
@@ -79,5 +81,5 @@ function configvar_check_csnippets(definition, snippets, opt)
add_cxflags(opt.cxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_ctypes.lua b/xmake/includes/check_ctypes.lua
index 00c0ac952..a6178c7c0 100644
--- a/xmake/includes/check_ctypes.lua
+++ b/xmake/includes/check_ctypes.lua
@@ -31,7 +31,8 @@
--
function check_ctypes(definition, types, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_ctypes(types)
add_defines(definition)
if opt.languages then
@@ -44,7 +45,7 @@ function check_ctypes(definition, types, opt)
add_cxflags(opt.cxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check c types and add macro definition to the configuration types
@@ -56,7 +57,8 @@ end
--
function configvar_check_ctypes(definition, types, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_ctypes(types)
set_configvar(definition, 1)
if opt.languages then
@@ -69,5 +71,5 @@ function configvar_check_ctypes(definition, types, opt)
add_cxflags(opt.cxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_cxxfuncs.lua b/xmake/includes/check_cxxfuncs.lua
index 5f861c5b8..b42b34cd0 100644
--- a/xmake/includes/check_cxxfuncs.lua
+++ b/xmake/includes/check_cxxfuncs.lua
@@ -37,7 +37,8 @@
--
function check_cxxfuncs(definition, funcs, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cxxfuncs(funcs)
add_defines(definition)
if opt.links then
@@ -56,7 +57,7 @@ function check_cxxfuncs(definition, funcs, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check c++ funcs and add macro definition to the configuration files
@@ -68,7 +69,8 @@ end
--
function configvar_check_cxxfuncs(definition, funcs, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cxxfuncs(funcs)
set_configvar(definition, 1)
if opt.links then
@@ -87,5 +89,5 @@ function configvar_check_cxxfuncs(definition, funcs, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_cxxincludes.lua b/xmake/includes/check_cxxincludes.lua
index e2e6627b6..f1f63ea2e 100644
--- a/xmake/includes/check_cxxincludes.lua
+++ b/xmake/includes/check_cxxincludes.lua
@@ -31,11 +31,12 @@
--
function check_cxxincludes(definition, includes, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cxxincludes(includes)
add_defines(definition)
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check include c++ files and add macro definition to the configuration files
@@ -47,9 +48,10 @@ end
--
function configvar_check_cxxincludes(definition, includes, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cxxincludes(includes)
set_configvar(definition, 1)
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_cxxsnippets.lua b/xmake/includes/check_cxxsnippets.lua
index 65b833276..d64747569 100644
--- a/xmake/includes/check_cxxsnippets.lua
+++ b/xmake/includes/check_cxxsnippets.lua
@@ -30,7 +30,8 @@
--
function check_cxxsnippets(definition, snippets, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cxxsnippets(definition, snippets)
add_defines(definition)
if opt.links then
@@ -49,7 +50,7 @@ function check_cxxsnippets(definition, snippets, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check c++ snippets and add macro definition to the configuration snippets
@@ -60,7 +61,8 @@ end
--
function configvar_check_cxxsnippets(definition, snippets, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cxxsnippets(definition, snippets)
set_configvar(definition, 1)
if opt.links then
@@ -79,5 +81,5 @@ function configvar_check_cxxsnippets(definition, snippets, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_cxxtypes.lua b/xmake/includes/check_cxxtypes.lua
index 78e0ced37..d361f14f4 100644
--- a/xmake/includes/check_cxxtypes.lua
+++ b/xmake/includes/check_cxxtypes.lua
@@ -31,7 +31,8 @@
--
function check_cxxtypes(definition, types, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cxxtypes(types)
add_defines(definition)
if opt.languages then
@@ -44,7 +45,7 @@ function check_cxxtypes(definition, types, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check c++ types and add macro definition to the configuration types
@@ -56,7 +57,8 @@ end
--
function configvar_check_cxxtypes(definition, types, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_cxxtypes(types)
set_configvar(definition, 1)
if opt.languages then
@@ -69,5 +71,5 @@ function configvar_check_cxxtypes(definition, types, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_features.lua b/xmake/includes/check_features.lua
index 56b3b9dcf..987749f98 100644
--- a/xmake/includes/check_features.lua
+++ b/xmake/includes/check_features.lua
@@ -31,7 +31,8 @@
--
function check_features(definition, features, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_features(features)
add_defines(definition)
if opt.languages then
@@ -47,7 +48,7 @@ function check_features(definition, features, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check features and add macro definition to the configuration files
@@ -59,7 +60,8 @@ end
--
function configvar_check_features(definition, features, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_features(features)
set_configvar(definition, 1)
if opt.languages then
@@ -75,5 +77,5 @@ function configvar_check_features(definition, features, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
diff --git a/xmake/includes/check_links.lua b/xmake/includes/check_links.lua
index 37a289ef6..02a2b0678 100644
--- a/xmake/includes/check_links.lua
+++ b/xmake/includes/check_links.lua
@@ -31,11 +31,12 @@
--
function check_links(definition, links, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_links(links)
add_defines(definition)
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end
-- check links and add macro definition to the configuration files
@@ -47,9 +48,10 @@ end
--
function configvar_check_links(definition, links, opt)
opt = opt or {}
- option(opt.name or definition)
+ local optname = "__" .. (opt.name or definition)
+ option(optname)
add_links(links)
set_configvar(definition, 1)
option_end()
- add_options(opt.name or definition)
+ add_options(optname)
end