diff options
| author | ruki <[email protected]> | 2020-05-13 22:49:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-13 10:55:19 +0800 |
| commit | fca9ba9a046d4b6fc940b6a147528921a41e02a7 (patch) | |
| tree | 92ebbc3656f662492d37fa47fe80153528fc9dd6 /xmake/core/base/utils.lua | |
| parent | 33049b3e71655463b5975d9992cf9db6f0c5c693 (diff) | |
add wprint
Diffstat (limited to 'xmake/core/base/utils.lua')
| -rw-r--r-- | xmake/core/base/utils.lua | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua index 605a4d028..d19be86b7 100644 --- a/xmake/core/base/utils.lua +++ b/xmake/core/base/utils.lua @@ -235,27 +235,42 @@ function utils.error(format, ...) end end --- the warning function +-- add warning message function utils.warning(format, ...) -- check assert(format) -- format message - local msg = "${bright color.warning}${text.warning}: ${color.warning}" .. string.tryformat(format, ...) + local args = table.pack(...) + local msg = (args.n > 0 and string.tryformat(format, ...) or format) -- init warnings - utils._WARNINGS = utils._WARNINGS or {} local warnings = utils._WARNINGS - - -- trace only once - if not warnings[msg] then - utils.cprint(msg) - warnings[msg] = true + if not warnings then + warnings = {} + utils._WARNINGS = warnings end - -- flush - log:flush() + -- add warning msg + table.insert(warnings, msg) +end + +-- show warnings +function utils.show_warnings() + local warnings = utils._WARNINGS + if warnings then + for idx, msg in ipairs(table.unique(warnings)) do + if idx == 1 then + print("") + end + if not option.get("verbose") and idx > 1 then + utils.cprint("${bright color.warning}${text.warning}: ${color.warning}add -v for getting more warnings ..") + break + end + utils.cprint("${bright color.warning}${text.warning}: ${color.warning}%s", msg) + end + end end -- ifelse, a? b : c |
