diff options
| -rw-r--r-- | xmake/core/base/interpreter.lua | 76 | ||||
| -rw-r--r-- | xmake/core/base/scopeinfo.lua | 14 |
2 files changed, 20 insertions, 70 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 62325b2ad..e8e379e08 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -22,13 +22,14 @@ local interpreter = 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 scopeinfo = require("base/scopeinfo") -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 scopeinfo = require("base/scopeinfo") +local deprecated = require("base/deprecated") +local sandbox = require("sandbox/sandbox") -- traceback function interpreter._traceback(errors) @@ -160,8 +161,6 @@ end -- register scope end: scopename_end() function interpreter:_api_register_scope_end(...) - - -- check assert(self and self._PUBLIC and self._PRIVATE) -- done @@ -191,8 +190,6 @@ end -- register scope api: xxx_apiname() function interpreter:_api_register_scope_api(scope_kind, action, apifunc, ...) - - -- check assert(self and self._PUBLIC and self._PRIVATE) assert(apifunc) @@ -226,8 +223,6 @@ end -- register api: xxx_values() function interpreter:_api_register_xxx_values(scope_kind, action, apifunc, ...) - - -- check assert(self and self._PUBLIC and self._PRIVATE) assert(action and apifunc) @@ -372,8 +367,6 @@ end -- get api function within scope function interpreter:_api_within_scope(scope_kind, apiname) - - -- the private local priv = self._PRIVATE assert(priv) @@ -394,8 +387,6 @@ end -- set api function within scope function interpreter:_api_within_scope_set(scope_kind, apiname, apifunc) - - -- the private local priv = self._PRIVATE assert(priv) @@ -416,8 +407,6 @@ end -- clear results function interpreter:_clear() - - -- check assert(self and self._PRIVATE) -- clear it @@ -427,8 +416,6 @@ end -- filter values function interpreter:_filter(values, level) - - -- check assert(self and values ~= nil) -- return values directly if no filter @@ -482,8 +469,6 @@ end -- handle scope data function interpreter:_handle(scope, deduplicate, enable_filter) - - -- check assert(scope) -- remove repeat values and unwrap it @@ -518,8 +503,6 @@ end -- make results function interpreter:_make(scope_kind, deduplicate, enable_filter) - - -- check assert(self and self._PRIVATE) -- the scopes @@ -719,8 +702,6 @@ end -- @param opt {on_load_data = function (data) return data end} -- function interpreter:load(file, opt) - - -- check assert(self and self._PUBLIC and self._PRIVATE and file) -- load the script @@ -847,8 +828,6 @@ end -- get apis function interpreter:apis(scope_kind) - - -- check assert(self and self._PRIVATE) -- get apis from the given scope kind @@ -889,8 +868,6 @@ end -- } -- function interpreter:api_register(scope_kind, name, func) - - -- check assert(self and self._PUBLIC and self._PRIVATE) assert(name and func) @@ -924,11 +901,7 @@ end -- register api for builtin function interpreter:api_register_builtin(name, func) - - -- check assert(self and self._PUBLIC and func) - - -- register it self._PUBLIC[name] = func end @@ -974,9 +947,6 @@ end -- function interpreter:api_register_scope(...) - -- check - assert(self) - -- define implementation local implementation = function (self, scopes, scope_kind, scope_name, scope_info) @@ -1259,9 +1229,6 @@ end -- register api for set_dictionary function interpreter:api_register_set_dictionary(scope_kind, ...) - -- check - assert(self) - -- define implementation local implementation = function (self, scope, name, dict_or_key, value, extra_config) @@ -1289,9 +1256,6 @@ end -- register api for add_dictionary function interpreter:api_register_add_dictionary(scope_kind, ...) - -- check - assert(self) - -- define implementation local implementation = function (self, scope, name, dict_or_key, value, extra_config) @@ -1321,9 +1285,6 @@ end -- register api for set_paths function interpreter:api_register_set_paths(scope_kind, ...) - -- check - assert(self) - -- define implementation local implementation = function (self, scope, name, ...) @@ -1363,9 +1324,6 @@ end -- register api for del_paths (deprecated) function interpreter:api_register_del_paths(scope_kind, ...) - -- check - assert(self) - -- define implementation local implementation = function (self, scope, name, ...) @@ -1373,6 +1331,9 @@ function interpreter:api_register_del_paths(scope_kind, ...) local values = table.join(...) local paths = self:_api_translate_paths(values, "del_" .. name) + -- it has been marked as deprecated + deprecated.add("remove_" .. name .. "(%s)", "del_" .. name .. "(%s)", table.concat(values, ", "), table.concat(values, ", ")) + -- mark these paths as deleted local paths_deleted = {} for _, pathname in ipairs(paths) do @@ -1393,9 +1354,6 @@ end -- register api for remove_paths function interpreter:api_register_remove_paths(scope_kind, ...) - -- check - assert(self) - -- define implementation local implementation = function (self, scope, name, ...) @@ -1423,9 +1381,6 @@ end -- register api for add_paths function interpreter:api_register_add_paths(scope_kind, ...) - -- check - assert(self) - -- define implementation local implementation = function (self, scope, name, ...) @@ -1764,27 +1719,18 @@ end -- get api function function interpreter:api_func(apiname) - - -- check assert(self and self._PUBLIC and apiname) - - -- get api function return self._PUBLIC[apiname] end -- call api function interpreter:api_call(apiname, ...) - - -- check assert(self and apiname) - -- get api function local apifunc = self:api_func(apiname) if not apifunc then os.raise("call %s() failed, this api not found!", apiname) end - - -- call api function return apifunc(...) end diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua index 7141482bc..26be325eb 100644 --- a/xmake/core/base/scopeinfo.lua +++ b/xmake/core/base/scopeinfo.lua @@ -23,11 +23,12 @@ local scopeinfo = scopeinfo or {} local _instance = _instance or {} -- load modules -local io = require("base/io") -local os = require("base/os") -local path = require("base/path") -local table = require("base/table") -local utils = require("base/utils") +local io = require("base/io") +local os = require("base/os") +local path = require("base/path") +local table = require("base/table") +local utils = require("base/utils") +local deprecated = require("base/deprecated") -- new an instance function _instance.new(kind, info, opt) @@ -388,6 +389,9 @@ function _instance:_api_del_paths(name, ...) -- expand values values = table.join(...) + -- it has been marked as deprecated + deprecated.add("remove_" .. name .. "(%s)", "del_" .. name .. "(%s)", table.concat(values, ", "), table.concat(values, ", ")) + -- translate paths local paths = interp:_api_translate_paths(values, "del_" .. name, 5) |
