summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-25 12:59:23 +0800
committerruki <[email protected]>2016-05-25 12:59:23 +0800
commitaf0d4247f488cdec9f0ba0a05f484e8f9fcfa59b (patch)
tree556816ba5df8a1ca41780dcee1d36b9480c0d31b
parentc8f23de807e6efcd6b797a6dde6366d67f64906d (diff)
dump deprecated entries
-rw-r--r--xmake/core/base/deprecated.lua59
-rw-r--r--xmake/core/base/deprecated/interpreter.lua25
-rw-r--r--xmake/core/base/option.lua35
-rw-r--r--xmake/core/base/utils.lua20
-rw-r--r--xmake/core/main.lua4
-rw-r--r--xmake/core/project/deprecated/project.lua25
6 files changed, 107 insertions, 61 deletions
diff --git a/xmake/core/base/deprecated.lua b/xmake/core/base/deprecated.lua
new file mode 100644
index 000000000..b676b0bfa
--- /dev/null
+++ b/xmake/core/base/deprecated.lua
@@ -0,0 +1,59 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file deprecated.lua
+--
+
+-- define module
+local deprecated = deprecated or {}
+
+-- load modules
+local utils = require("base/utils")
+local table = require("base/table")
+local string = require("base/string")
+
+-- add deprecated entry
+function deprecated.add(newformat, oldformat, ...)
+
+ -- the entries
+ deprecated._ENTRIES = deprecated._ENTRIES or {}
+
+ -- the old and new entries
+ local old = string.format(oldformat, ...)
+ local new = string.format(newformat, ...)
+
+ -- add it
+ deprecated._ENTRIES[old] = new
+end
+
+-- dump all deprecated entries
+function deprecated.dump()
+
+ -- the entries
+ deprecated._ENTRIES = deprecated._ENTRIES or {}
+
+ -- dump all
+ print("")
+ for old, new in pairs(deprecated._ENTRIES) do
+ utils.printf("deprecated: please uses %s instead of %s", new, old)
+ end
+end
+
+-- return module
+return deprecated
diff --git a/xmake/core/base/deprecated/interpreter.lua b/xmake/core/base/deprecated/interpreter.lua
index ec06d8866..1c4f8e18e 100644
--- a/xmake/core/base/deprecated/interpreter.lua
+++ b/xmake/core/base/deprecated/interpreter.lua
@@ -24,12 +24,13 @@
local deprecated_interpreter = deprecated_interpreter or {}
-- load modules
-local os = require("base/os")
-local path = require("base/path")
-local table = require("base/table")
-local utils = require("base/utils")
-local string = require("base/string")
-local sandbox = require("sandbox/sandbox")
+local os = require("base/os")
+local path = require("base/path")
+local table = require("base/table")
+local utils = require("base/utils")
+local string = require("base/string")
+local deprecated = require("base/deprecated")
+local sandbox = require("sandbox/sandbox")
-- register api for set_scope()
function deprecated_interpreter:api_register_set_scope(...)
@@ -44,9 +45,9 @@ function deprecated_interpreter:api_register_set_scope(...)
local scope_for_kind = scopes[scope_kind] or {}
scopes[scope_kind] = scope_for_kind
- -- warning
+ -- deprecated
if not scope_name:startswith("__") then
- utils.warning("please uses %s(\"%s\"), \"set_%s\" has been deprecated!", scope_kind, scope_name, scope_kind)
+ deprecated.add("%s(\"%s\")", "set_%s(\"%s\")", scope_kind, scope_name)
end
-- check
@@ -83,9 +84,9 @@ function deprecated_interpreter:api_register_add_scope(...)
local scope_for_kind = scopes[scope_kind] or {}
scopes[scope_kind] = scope_for_kind
- -- warning
+ -- deprecated
if not scope_name:startswith("__") then
- utils.warning("please uses %s(\"%s\"), \"add_%s\" has been deprecated!", scope_kind, scope_name, scope_kind)
+ deprecated.add("%s(\"%s\")", "add_%s(\"%s\")", scope_kind, scope_name)
end
-- check
@@ -118,8 +119,8 @@ function deprecated_interpreter:api_register_set_script(scope_kind, prefix, ...)
-- define implementation
local implementation = function (self, scope, name, script)
- -- warning
- utils.warning("please uses on_%s(), \"set_%s()\" has been deprecated!", name, name, scope)
+ -- deprecated
+ deprecated.add("on_%s()", "set_%s()", name)
-- make sandbox instance with the given script
local instance, errors = sandbox.new(script, self:filter(), self:rootdir())
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index eedeec158..9acf1b48b 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -175,12 +175,12 @@ function option.init(argv, menu)
-- check key
if prefix and #key == 0 then
- -- invalid option
- print("invalid option: " .. arg)
-
-- print menu
option.show_menu(context.taskname)
+ -- invalid option
+ print("\nerror: invalid option: " .. arg)
+
-- failed
return false
end
@@ -209,12 +209,12 @@ function option.init(argv, menu)
-- not found?
if not opt then
- -- invalid option
- print("invalid option: " .. arg)
-
-- print menu
option.show_menu(context.taskname)
+ -- invalid option
+ print("\nerror: invalid option: " .. arg)
+
-- failed
return false
end
@@ -229,12 +229,12 @@ function option.init(argv, menu)
_k = idx
if idx == nil or arg:startswith("-") then
- -- invalid option
- print("invalid option: " .. option._ifelse(idx, arg, key))
-
-- print menu
option.show_menu(context.taskname)
+ -- invalid option
+ print("\nerror: invalid option: " .. option._ifelse(idx, arg, key))
+
-- failed
return false
end
@@ -246,12 +246,12 @@ function option.init(argv, menu)
-- check mode
if (opt[3] == "k" and type(value) ~= "boolean") or (opt[3] == "kv" and type(value) ~= "string") then
- -- invalid option
- print("invalid option: " .. arg)
-
-- print menu
option.show_menu(context.taskname)
+ -- invalid option
+ print("\nerror: invalid option: " .. arg)
+
-- failed
return false
end
@@ -283,12 +283,12 @@ function option.init(argv, menu)
-- not found?
if not context.taskname or not menu[context.taskname] then
- -- invalid task
- print("invalid task: " .. key)
-
-- print the main menu
option.show_main()
+ -- invalid task
+ print("\nerror: invalid task: " .. key)
+
-- failed
return false
@@ -345,12 +345,13 @@ function option.init(argv, menu)
table.insert(o, key)
end
else
- -- invalid option
- print("invalid option: " .. arg)
-- print menu
option.show_menu(context.taskname)
+ -- invalid option
+ print("\nerror: invalid option: " .. arg)
+
-- failed
return false
end
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua
index 5d69bdcd0..f5c863c97 100644
--- a/xmake/core/base/utils.lua
+++ b/xmake/core/base/utils.lua
@@ -68,31 +68,11 @@ function utils.warning(msg, ...)
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
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index 589f1ae1c..b2177db57 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -29,6 +29,7 @@ local path = require("base/path")
local utils = require("base/utils")
local option = require("base/option")
local profiler = require("base/profiler")
+local deprecated = require("base/deprecated")
local task = require("project/task")
-- init the option menu
@@ -123,6 +124,9 @@ function main.done()
return -1
end
+ -- dump deprecated entries
+ deprecated.dump()
+
-- stop profiling
-- profiler:stop()
diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua
index a9c04a007..480aaba81 100644
--- a/xmake/core/project/deprecated/project.lua
+++ b/xmake/core/project/deprecated/project.lua
@@ -30,6 +30,7 @@ local utils = require("base/utils")
local table = require("base/table")
local config = require("project/config")
local platform = require("platform/platform")
+local deprecated = require("base/deprecated")
local deprecated_interpreter = require("base/deprecated/interpreter")
-- the current os is belong to the given os?
@@ -133,8 +134,8 @@ function deprecated_project._api_os(interp, ...)
end
end
- -- warning
- utils.warning("please uses is_os(\"%s\"), \"os()\" has been deprecated!", values)
+ -- deprecated
+ deprecated.add("is_os(\"%s\")", "os(\"%s\")", values)
-- done
return deprecated_project._api_is_os(interp, ...)
@@ -155,8 +156,8 @@ function deprecated_project._api_modes(interp, ...)
end
end
- -- warning
- utils.warning("please uses is_mode(\"%s\"), \"modes()\" has been deprecated!", values)
+ -- deprecated
+ deprecated.add("is_mode(\"%s\")", "modes(\"%s\")", values)
-- done
return deprecated_project._api_is_mode(interp, ...)
@@ -177,8 +178,8 @@ function deprecated_project._api_plats(interp, ...)
end
end
- -- warning
- utils.warning("please uses is_plat(\"%s\"), \"plats()\" has been deprecated!", values)
+ -- deprecated
+ deprecated.add("is_plat(\"%s\")", "plats(\"%s\")", values)
-- done
return deprecated_project._api_is_plat(interp, ...)
@@ -199,8 +200,8 @@ function deprecated_project._api_archs(interp, ...)
end
end
- -- warning
- utils.warning("please uses is_arch(\"%s\"), \"archs()\" has been deprecated!", values)
+ -- deprecated
+ deprecated.add("is_arch(\"%s\")", "archs(\"%s\")", values)
-- done
return deprecated_project._api_is_arch(interp, ...)
@@ -221,8 +222,8 @@ function deprecated_project._api_kinds(interp, ...)
end
end
- -- warning
- utils.warning("please uses is_kind(\"%s\"), \"kinds()\" has been deprecated!", values)
+ -- deprecated
+ deprecated.add("is_kind(\"%s\")", "kinds(\"%s\")", values)
-- done
return deprecated_project._api_is_kind(interp, ...)
@@ -243,8 +244,8 @@ function deprecated_project._api_options(interp, ...)
end
end
- -- warning
- utils.warning("please uses is_option(\"%s\"), \"options()\" has been deprecated!", values)
+ -- deprecated
+ deprecated.add("is_option(\"%s\")", "options(\"%s\")", values)
-- done
return deprecated_project._api_is_option(interp, ...)