summaryrefslogtreecommitdiff
path: root/xmake/core/base/utils.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-13 22:49:13 +0800
committerruki <[email protected]>2020-05-13 10:55:19 +0800
commitfca9ba9a046d4b6fc940b6a147528921a41e02a7 (patch)
tree92ebbc3656f662492d37fa47fe80153528fc9dd6 /xmake/core/base/utils.lua
parent33049b3e71655463b5975d9992cf9db6f0c5c693 (diff)
add wprint
Diffstat (limited to 'xmake/core/base/utils.lua')
-rw-r--r--xmake/core/base/utils.lua35
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