summaryrefslogtreecommitdiff
path: root/xmake/core/base/utils.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-02-14 21:27:34 +0800
committerruki <[email protected]>2016-02-15 19:10:27 +0800
commit52c273079851f2b83b9c632aec8e37b7482f6a83 (patch)
tree039d06330552a10a5b456969dc88c43aac7bd833 /xmake/core/base/utils.lua
parente056e25f57d12010ad5c5db4d6abd64e3450643f (diff)
warning only once and deprecate set/add_ api
Diffstat (limited to 'xmake/core/base/utils.lua')
-rw-r--r--xmake/core/base/utils.lua34
1 files changed, 32 insertions, 2 deletions
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua
index 1ee861922..6717b6045 100644
--- a/xmake/core/base/utils.lua
+++ b/xmake/core/base/utils.lua
@@ -69,8 +69,38 @@ function utils.warning(msg, ...)
-- check
assert(msg)
- -- trace
- print("warning: " .. string.format(msg, ...))
+ -- format message
+ msg = "warning: " .. string.format(msg, ...)
+
+ -- init warnings
+ utils._WARNINGS = utils._WARNINGS or {}
+ local warnings = utils._WARNINGS
+
+ -- the cached file path
+ local cachedpath = path.translate(xmake._PROJECT_DIR .. "/.xmake/warnings")
+
+ -- load warnings from the cached file
+ local cachedfile = io.open(cachedpath, "r")
+ if cachedfile then
+ for line in cachedfile:lines() do
+ warnings[line] = true
+ end
+ end
+
+ -- trace only once
+ if not warnings[msg] then
+ print(msg)
+ warnings[msg] = true
+ end
+
+ -- cache warnings
+ cachedfile = io.open(cachedpath, "w")
+ if cachedfile then
+ for line, _ in pairs(warnings) do
+ cachedfile:write(line .. "\n")
+ end
+ cachedfile:close()
+ end
end
-- ifelse, a? b : c