summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-27 14:17:22 +0800
committerruki <[email protected]>2016-05-27 14:17:22 +0800
commit7f281a4bcc32519b717f269fd4f2307704f2cd70 (patch)
treeeb1a537f8a0660f9484ce8223d4598fd0c9aef58
parentba420896702097733403ec8e3ce56b8ee4e54e88 (diff)
dispatch the old api for project
-rw-r--r--xmake/core/base/deprecated/interpreter.lua48
-rw-r--r--xmake/core/base/interpreter.lua38
-rw-r--r--xmake/core/project/deprecated/project.lua37
-rw-r--r--xmake/core/project/project.lua6
4 files changed, 112 insertions, 17 deletions
diff --git a/xmake/core/base/deprecated/interpreter.lua b/xmake/core/base/deprecated/interpreter.lua
index b905ff50d..6f94296a3 100644
--- a/xmake/core/base/deprecated/interpreter.lua
+++ b/xmake/core/base/deprecated/interpreter.lua
@@ -138,5 +138,53 @@ function deprecated_interpreter:api_register_set_script(scope_kind, ...)
self:_api_register_xxx_values(scope_kind, "set", implementation, ...)
end
+-- register api: set_xxx_xxx
+function deprecated_interpreter:_api_register_set_xxx_xxx(scope_kind, apiname)
+
+ -- the old api
+ local oldapi = string.format("set_%s_%s", scope_kind, apiname)
+
+ -- the new api
+ local newapi = string.format("set_%s", apiname)
+
+ -- get api function
+ local apifunc = self:_api_within_scope(scope_kind, newapi)
+ assert(apifunc)
+
+ -- register api
+ self:api_register(nil, oldapi, function (...)
+
+ -- deprecated
+ deprecated.add(newapi .. "()", oldapi .. "()")
+
+ -- dispatch it
+ apifunc(...)
+ end)
+end
+
+-- register api: add_xxx_xxx
+function deprecated_interpreter:_api_register_add_xxx_xxx(scope_kind, apiname)
+
+ -- the old api
+ local oldapi = string.format("add_%s_%s", scope_kind, apiname)
+
+ -- the new api
+ local newapi = string.format("add_%s", apiname)
+
+ -- get api function
+ local apifunc = self:_api_within_scope(scope_kind, newapi)
+ assert(apifunc)
+
+ -- register api
+ self:api_register(nil, oldapi, function (...)
+
+ -- deprecated
+ deprecated.add(newapi .. "()", oldapi .. "()")
+
+ -- dispatch it
+ apifunc(...)
+ end)
+end
+
-- return module: deprecated_interpreter
return deprecated_interpreter
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index a9bbadd9a..dd5e7c45f 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -250,6 +250,28 @@ function interpreter:_api_builtin_add_subdirfiles(isdirs, ...)
self._PRIVATE._CURFILE = curfile
end
+-- get api function within scope
+function interpreter:_api_within_scope(scope_kind, apiname)
+
+ -- the private
+ local priv = self._PRIVATE
+ assert(priv)
+
+ -- the scopes
+ local scopes = priv._SCOPES
+ assert(scopes)
+
+ -- done
+ if scope_kind and priv._APIS then
+
+ -- get api function
+ local api_scope = priv._APIS[scope_kind]
+ if api_scope then
+ return api_scope[apiname]
+ end
+ end
+end
+
-- clear results
function interpreter:_clear()
@@ -432,18 +454,12 @@ function interpreter.new()
-- dispatch the api calling for scope
setmetatable(instance._PUBLIC, { __index = function (tbl, key)
- -- get scope kind
- local apifunc = nil
- local priv = instance._PRIVATE
- local scope_kind = priv._SCOPES._CURRENT_KIND or priv._ROOTSCOPE
- if scope_kind and priv._APIS then
-
- -- get api function
- apifunc = priv._APIS[scope_kind][key]
- end
+ -- get the scope kind
+ local priv = instance._PRIVATE
+ local scope_kind = priv._SCOPES._CURRENT_KIND or priv._ROOTSCOPE
- -- ok?
- return apifunc
+ -- get the api function from the given scope
+ return instance:_api_within_scope(scope_kind, key)
end})
-- register the builtin interfaces
diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua
index 74073fd5f..89a3891de 100644
--- a/xmake/core/project/deprecated/project.lua
+++ b/xmake/core/project/deprecated/project.lua
@@ -28,6 +28,7 @@ local os = require("base/os")
local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
+local string = require("base/string")
local config = require("project/config")
local platform = require("platform/platform")
local deprecated = require("base/deprecated")
@@ -259,9 +260,7 @@ function deprecated_project.api_register(interp)
deprecated_interpreter.api_register_add_scope(interp, "target", "option")
-- register api: set_runscript() and set_installscript() and set_packagescript()
- deprecated_interpreter.api_register_set_script(interp, "target", nil, "runscript"
- , "installscript"
- , "packagescript")
+ deprecated_interpreter.api_register_set_script(interp, "target", "runscript", "installscript", "packagescript")
-- register api: os(), kinds(), modes(), plats(), archs(), options()
interp:api_register(nil, "os", deprecated_project._api_os)
@@ -271,6 +270,38 @@ function deprecated_project.api_register(interp)
interp:api_register(nil, "archs", deprecated_project._api_archs)
interp:api_register(nil, "options", deprecated_project._api_options)
+ -- register api: set_values() to option
+ deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "enable")
+ deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "showmenu")
+ deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "category")
+ deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "warnings")
+ deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "optimize")
+ deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "languages")
+ deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "description")
+
+ -- register api: add_values() to option
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "links")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cincludes")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxincludes")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cfuncs")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxfuncs")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "ctypes")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxtypes")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cflags")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxflags")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxflags")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "ldflags")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "vectorexts")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "defines")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "defines_if_ok")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "defines_h_if_ok")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "undefines")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "undefines_if_ok")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "undefines_h_if_ok")
+
+ -- register api: add_pathes() to option
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "linkdirs")
+ deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "includedirs")
end
-- return module: deprecated_project
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index ece70a50e..a0114e730 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -330,9 +330,6 @@ function project._interpreter()
-- set root scope
interp:rootscope_set("target")
- -- register api: deprecated
- deprecated_project.api_register(interp)
-
-- register api: target() and option()
interp:api_register_scope("target", "option")
@@ -462,6 +459,9 @@ function project._interpreter()
-- register api: add_pkgs() to root
interp:api_register(nil, "add_pkgs", interpreter.api_builtin_add_subdirs)
+ -- register api: deprecated
+ deprecated_project.api_register(interp)
+
-- set filter
interp:filter_set(filter.new(function (variable)