summaryrefslogtreecommitdiff
path: root/xmake/core/base
diff options
context:
space:
mode:
authorruki <[email protected]>2018-11-04 22:20:13 +0800
committerruki <[email protected]>2018-11-04 22:20:13 +0800
commitd3d05b0c620dbfc318d4c693bc2fb7b556d51d3c (patch)
treea91579ba8362498e531c01081d8fe80906da142d /xmake/core/base
parent9d22026291016915298cd4cf8b004bef4b6faaec (diff)
improve diagnosis info
Diffstat (limited to 'xmake/core/base')
-rw-r--r--xmake/core/base/coroutine.lua2
-rw-r--r--xmake/core/base/task.lua29
-rw-r--r--xmake/core/base/utils.lua45
3 files changed, 23 insertions, 53 deletions
diff --git a/xmake/core/base/coroutine.lua b/xmake/core/base/coroutine.lua
index dca56423d..651294361 100644
--- a/xmake/core/base/coroutine.lua
+++ b/xmake/core/base/coroutine.lua
@@ -42,7 +42,7 @@ function coroutine.resume(co, ...)
-- get errors
local errors = results
- if option.get("backtrace") then
+ if option.get("diagnosis") then
errors = debug.traceback(co, results)
elseif type(results) == "string" then
-- remove the prefix info
diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua
index 63e00d716..b6a5d7d15 100644
--- a/xmake/core/base/task.lua
+++ b/xmake/core/base/task.lua
@@ -130,22 +130,25 @@ function task._translate_menu(menu)
end
-- add common options
- table.insert(options, 1, {'q', "quiet", "k", nil, "Quiet operation." })
- table.insert(options, 2, {'y', "yes", "k", nil, "Input yes by default if need user confirm." })
- table.insert(options, 3, {'v', "verbose", "k", nil, "Print lots of verbose information." })
- table.insert(options, 4, {nil, "root", "k", nil, "Allow to run xmake as root." })
- table.insert(options, 5, {nil, "backtrace", "k", nil, "Print backtrace information for debugging." })
- table.insert(options, 6, {nil, "profile", "k", nil, "Print performance data for debugging." })
- table.insert(options, 7, {nil, "version", "k", nil, "Print the version number and exit." })
- table.insert(options, 8, {'h', "help", "k", nil, "Print this help message and exit." })
- table.insert(options, 9, {})
- table.insert(options, 10, {'F', "file", "kv", nil, "Read a given xmake.lua file." })
- table.insert(options, 11, {'P', "project", "kv", nil, "Change to the given project directory."
+ table.insert(options, 1, {'q', "quiet", "k", nil, "Quiet operation." })
+ table.insert(options, 2, {'y', "yes", "k", nil, "Input yes by default if need user confirm." })
+ table.insert(options, 3, {'v', "verbose", "k", nil, "Print lots of verbose information for users." })
+ table.insert(options, 4, {nil, "root", "k", nil, "Allow to run xmake as root." })
+ table.insert(options, 5, {'D', "diagnosis", "k", nil, "Print lots of diagnosis information (backtrace, check info ..) only for developers."
+ , "And we can append -v to get more whole information."
+ , " e.g. $ xmake -v -D"})
+ table.insert(options, 6, {nil, "profile", "k", nil, "Print performance data only for developers." })
+ table.insert(options, 7, {nil, "version", "k", nil, "Print the version number and exit." })
+ table.insert(options, 8, {'h', "help", "k", nil, "Print this help message and exit." })
+ table.insert(options, 9, {nil, "backtrace", "k", nil, "Please uses -D or --diagnosis instead of it. (deprecated)"})
+ table.insert(options, 10, {})
+ table.insert(options, 11, {'F', "file", "kv", nil, "Read a given xmake.lua file." })
+ table.insert(options, 12, {'P', "project", "kv", nil, "Change to the given project directory."
, "Search priority:"
, " 1. The Given Command Argument"
, " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" })
- table.insert(options, 12, {})
+ , " 3. The Current Directory" })
+ table.insert(options, 13, {})
end
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua
index b3f143ba3..bc1370f3a 100644
--- a/xmake/core/base/utils.lua
+++ b/xmake/core/base/utils.lua
@@ -133,29 +133,22 @@ function utils.cprintf(format, ...)
end
end
--- the verbose function
-function utils.verbose(format, ...)
-
- -- enable verbose?
+-- print the verbose information
+function utils.vprint(format, ...)
if option.get("verbose") and format ~= nil then
utils.print(format, ...)
end
end
--- the verbose error function
-function utils.verror(format, ...)
-
- -- enable verbose?
+-- print the verbose information without newline
+function utils.vprintf(format, ...)
if option.get("verbose") and format ~= nil then
- utils.cprint("${bright red}error: ${clear}" .. string.tryformat(format, ...))
- log:flush()
+ utils.printf(format, ...)
end
end
--- the error function
+-- print the error information
function utils.error(format, ...)
-
- -- trace
if format ~= nil then
utils.cprint("${bright red}error: ${clear}" .. string.tryformat(format, ...))
log:flush()
@@ -190,31 +183,5 @@ function utils.ifelse(a, b, c)
if a then return b else return c end
end
--- call functions
-function utils.call(funcs, pred, ...)
-
- -- check
- assert(funcs)
-
- -- call all
- for _, func in ipairs(table.wrap(funcs)) do
-
- -- check
- assert(type(func) == "function")
-
- -- call it
- local result = func(...)
-
- -- exists predicate?
- if pred and type(pred) == "function" then
- if not pred(name, result) then return false end
- -- failed?
- elseif not result then return false end
- end
-
- -- ok
- return true
-end
-
-- return module
return utils