summaryrefslogtreecommitdiff
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
parent9d22026291016915298cd4cf8b004bef4b6faaec (diff)
improve diagnosis info
-rw-r--r--CHANGELOG.md2
-rw-r--r--xmake/actions/build/statistics.lua2
-rw-r--r--xmake/actions/config/main.lua2
-rw-r--r--xmake/actions/config/menuconf.lua2
-rw-r--r--xmake/core/base/coroutine.lua2
-rw-r--r--xmake/core/base/task.lua29
-rw-r--r--xmake/core/base/utils.lua45
-rw-r--r--xmake/core/main.lua5
-rw-r--r--xmake/core/sandbox/modules/coroutine.lua2
-rw-r--r--xmake/core/sandbox/modules/import/core/base/task.lua2
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua4
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_programver.lua8
-rw-r--r--xmake/core/sandbox/modules/try.lua2
-rw-r--r--xmake/core/sandbox/modules/utils.lua4
-rw-r--r--xmake/core/sandbox/sandbox.lua4
-rw-r--r--xmake/modules/core/tools/gcc.lua2
-rw-r--r--xmake/modules/lib/detect/check_cxsnippets.lua8
-rw-r--r--xmake/modules/lib/detect/has_flags.lua8
-rw-r--r--xmake/modules/package/tools/xmake.lua12
-rw-r--r--xmake/modules/privilege/sudo.lua2
20 files changed, 62 insertions, 85 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a17c85f4b..e7710c947 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@
* Improve compilation dependences
* Support *.xz for extractor
* [#249](https://github.com/tboox/xmake/pull/249): revise progress formatting to space-leading three digit percentages
+* [#247](https://github.com/tboox/xmake/pull/247): Add `-D` and `--diagnosis` instead of `--backtrace`
## v2.2.2
@@ -511,6 +512,7 @@
* 改进编译依赖,对源文件列表的改动进行依赖判断
* 支持解压*.xz文件
* [#249](https://github.com/tboox/xmake/pull/249): 改进编译进度信息显示格式
+* [#247](https://github.com/tboox/xmake/pull/247): 添加`-D`和`--diagnosis`去替换`--backtrace`,改进诊断信息显示
## v2.2.2
diff --git a/xmake/actions/build/statistics.lua b/xmake/actions/build/statistics.lua
index 9acd65661..29ffa17bb 100644
--- a/xmake/actions/build/statistics.lua
+++ b/xmake/actions/build/statistics.lua
@@ -74,7 +74,7 @@ function post()
-- init argument list
local argv = {"lua", path.join(os.scriptdir(), "statistics.lua")}
- for _, name in ipairs({"root", "file", "project", "backtrace", "verbose", "quiet", "yes"}) do
+ for _, name in ipairs({"root", "file", "project", "diagnosis", "verbose", "quiet", "yes"}) do
local value = option.get(name)
if type(value) == "string" then
table.insert(argv, "--" .. name .. "=" .. value)
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index fb3ddd1bd..fa396358e 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -47,7 +47,7 @@ function _option_filter(name)
, profile = true
, project = true
, verbose = true
- , backtrace = true
+ , diagnosis = true
, require = true
}
return not options[name]
diff --git a/xmake/actions/config/menuconf.lua b/xmake/actions/config/menuconf.lua
index 9b847d312..4d87b3e29 100644
--- a/xmake/actions/config/menuconf.lua
+++ b/xmake/actions/config/menuconf.lua
@@ -84,7 +84,7 @@ function app:_filter_option(name)
, profile = true
, project = true
, verbose = true
- , backtrace = true
+ , diagnosis = true
, require = true
, version = true
, help = true
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
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index f724cfa2d..a5e7b269b 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -197,6 +197,11 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
end
end
+ -- check deprecated options, TODO it will be removed after v2.3.0
+ if option.get("backtrace") then
+ deprecated.add("-D or --diagnosis", "--backtrace")
+ end
+
-- start profiling
if option.get("profile") then
profiler:start()
diff --git a/xmake/core/sandbox/modules/coroutine.lua b/xmake/core/sandbox/modules/coroutine.lua
index 680543937..949b08ee9 100644
--- a/xmake/core/sandbox/modules/coroutine.lua
+++ b/xmake/core/sandbox/modules/coroutine.lua
@@ -45,7 +45,7 @@ function sandbox_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/sandbox/modules/import/core/base/task.lua b/xmake/core/sandbox/modules/import/core/base/task.lua
index 3b33f5fbd..c0a82a784 100644
--- a/xmake/core/sandbox/modules/import/core/base/task.lua
+++ b/xmake/core/sandbox/modules/import/core/base/task.lua
@@ -42,7 +42,7 @@ function sandbox_core_base_task.run(taskname, options, ...)
options = table.wrap(options)
-- inherit some parent options
- for _, name in ipairs({"file", "project", "backtrace", "verbose", "quiet", "yes", "root", "profile"}) do
+ for _, name in ipairs({"file", "project", "diagnosis", "verbose", "quiet", "yes", "root", "profile"}) do
if not options[name] and option.get(name) then
options[name] = option.get(name)
end
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index dbeb4a47e..c5690dd3c 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -69,8 +69,8 @@ function sandbox_lib_detect_find_program._check(program, opt)
end
-- check failed? print verbose error info
- if not ok then
- utils.verror(errors)
+ if not ok and option.get("diagnosis") then
+ utils.cprint("${yellow}checkinfo: ${clear dim}" .. errors)
end
-- ok?
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
index 276cd7a1d..ef616e8cd 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
@@ -77,8 +77,8 @@ function sandbox_lib_detect_find_programver.main(program, opt)
local command = opt.command
if type(command) == "function" then
ok, outdata = sandbox.load(command)
- if not ok then
- utils.verror(outdata)
+ if not ok and outdata and option.get("diagnosis") then
+ utils.cprint("${yellow}checkinfo: ${clear dim}" .. outdata)
end
else
ok, outdata = os.iorunv(program, {command or "--version"})
@@ -89,8 +89,8 @@ function sandbox_lib_detect_find_programver.main(program, opt)
local parse = opt.parse
if type(parse) == "function" then
ok, result = sandbox.load(parse, outdata)
- if not ok then
- utils.verror(result)
+ if not ok and result and option.get("diagnosis") then
+ utils.cprint("${yellow}checkinfo: ${clear dim}" .. result)
result = nil
end
elseif parse == nil or type(parse) == "string" then
diff --git a/xmake/core/sandbox/modules/try.lua b/xmake/core/sandbox/modules/try.lua
index 4b8206bc9..b257e1af8 100644
--- a/xmake/core/sandbox/modules/try.lua
+++ b/xmake/core/sandbox/modules/try.lua
@@ -35,7 +35,7 @@ local sandbox_try = sandbox_try or {}
function sandbox_try._traceback(errors)
-- not verbose?
- if not option.get("backtrace") then
+ if not option.get("diagnosis") then
if errors then
-- remove the prefix info
local _, pos = errors:find(":%d+: ")
diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua
index 5e3ae6113..3516c7990 100644
--- a/xmake/core/sandbox/modules/utils.lua
+++ b/xmake/core/sandbox/modules/utils.lua
@@ -143,14 +143,14 @@ function sandbox_utils.cprintf(format, ...)
end
end
--- print() if enable verbose
+-- print the verbose information
function sandbox_utils.vprint(format, ...)
if option.get("verbose") then
sandbox_utils.print(format, ...)
end
end
--- vprintf() if enable verbose
+-- print the verbose information without newline
function sandbox_utils.vprintf(format, ...)
if option.get("verbose") then
sandbox_utils.printf(format, ...)
diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua
index 2ac54b827..d1a6c8c55 100644
--- a/xmake/core/sandbox/sandbox.lua
+++ b/xmake/core/sandbox/sandbox.lua
@@ -36,8 +36,8 @@ local option = require("base/option")
-- traceback
function sandbox._traceback(errors)
- -- not verbose?
- if not option.get("backtrace") then
+ -- only print error info without backtrace if not diagnosis?
+ if not option.get("diagnosis") then
if errors then
-- remove the prefix info
local _, pos = errors:find(":%d+: ")
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index b1608b5ba..551a158e3 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -491,7 +491,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
function (ok, warnings)
-- print some warnings
- if warnings and #warnings > 0 and (option.get("verbose") or option.get("warning")) then
+ if warnings and #warnings > 0 and (option.get("diagnosis") or option.get("warning")) then
cprint("${yellow}%s", table.concat(table.slice(warnings:split('\n'), 1, 8), '\n'))
end
end
diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua
index 0cbee0153..d2e272714 100644
--- a/xmake/modules/lib/detect/check_cxsnippets.lua
+++ b/xmake/modules/lib/detect/check_cxsnippets.lua
@@ -197,7 +197,7 @@ function main(snippets, opt)
os.tryrm(binaryfile)
-- trace
- if opt.verbose or option.get("verbose") then
+ if opt.verbose or option.get("verbose") or option.get("diagnosis") then
local kind = ifelse(sourcekind == "cc", "c", "c++")
if #includes > 0 then
cprint("checking for the %s includes %s ... %s", kind, table.concat(includes, ", "), ifelse(ok, "${green}ok", "${red}no"))
@@ -214,9 +214,9 @@ function main(snippets, opt)
for _, snippet in ipairs(snippets) do
cprint("checking for the %s snippet %s ... %s", kind, snippet:sub(1, 16), ifelse(ok, "${green}ok", "${red}no"))
end
- if errors and #errors > 0 then
- cprint("${dim red}check error:${clear}${dim} %s", errors)
- end
+ end
+ if errors and #errors > 0 and option.get("diagnosis") then
+ cprint("${yellow}checkinfo:${clear dim} %s", errors)
end
-- ok?
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index 6398e62e6..66bdcfece 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -115,11 +115,11 @@ function main(name, flags, opt)
_g._checking = nil
-- trace
- if option.get("verbose") or opt.verbose then
+ if option.get("verbose") or option.get("diagnosis") or opt.verbose then
cprint("checking for the flags(%s) %s ... %s", path.filename(tool.program), table.concat(flags, " "), ifelse(result, "${green}ok", "${red}no"))
- if errors and #errors > 0 then
- cprint("${dim red}check error:${clear}${dim} %s", errors:trim())
- end
+ end
+ if errors and #errors > 0 and option.get("diagnosis") then
+ cprint("${yellow}checkinfo:${clear dim} %s", errors:trim())
end
-- save result to cache
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua
index 6a5772e8f..4b625342b 100644
--- a/xmake/modules/package/tools/xmake.lua
+++ b/xmake/modules/package/tools/xmake.lua
@@ -54,8 +54,8 @@ function install(package, configs)
if option.get("verbose") then
table.insert(argv, "-v")
end
- if option.get("backtrace") then
- table.insert(argv, "--backtrace")
+ if option.get("diagnosis") then
+ table.insert(argv, "--diagnosis")
end
os.vrunv("xmake", argv)
@@ -64,8 +64,8 @@ function install(package, configs)
if option.get("verbose") then
table.insert(argv, "-v")
end
- if option.get("backtrace") then
- table.insert(argv, "--backtrace")
+ if option.get("diagnosis") then
+ table.insert(argv, "--diagnosis")
end
os.vrunv("xmake", argv)
@@ -74,8 +74,8 @@ function install(package, configs)
if option.get("verbose") then
table.insert(argv, "-v")
end
- if option.get("backtrace") then
- table.insert(argv, "--backtrace")
+ if option.get("diagnosis") then
+ table.insert(argv, "--diagnosis")
end
os.vrunv("xmake", argv)
end
diff --git a/xmake/modules/privilege/sudo.lua b/xmake/modules/privilege/sudo.lua
index bd53ff187..6e6863745 100644
--- a/xmake/modules/privilege/sudo.lua
+++ b/xmake/modules/privilege/sudo.lua
@@ -79,7 +79,7 @@ function _lua(runner, luafile, luaargv)
-- init argv
local argv = {"lua", "--root"}
- for _, name in ipairs({"file", "project", "backtrace", "verbose", "quiet", "yes"}) do
+ for _, name in ipairs({"file", "project", "diagnosis", "verbose", "quiet", "yes"}) do
local value = option.get(name)
if type(value) == "string" then
table.insert(argv, "--" .. name .. "=" .. value)