summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-02-18 09:31:15 +0800
committerruki <[email protected]>2016-02-18 09:31:15 +0800
commitfd9f0efb0d5886481ea4f6f398807eae56c6c6fa (patch)
tree5beb3d8229ae084ca2717ca8e32b6854c63dd1ea
parent259f527327b19d5760bf3010b45f9cde52208066 (diff)
move deprecated codes
-rw-r--r--xmake/core/base/deprecated/interpreter.lua115
-rw-r--r--xmake/core/base/deprecated/project.lua272
-rw-r--r--xmake/core/base/interpreter.lua82
-rw-r--r--xmake/core/base/project.lua179
4 files changed, 402 insertions, 246 deletions
diff --git a/xmake/core/base/deprecated/interpreter.lua b/xmake/core/base/deprecated/interpreter.lua
new file mode 100644
index 000000000..c68ad065a
--- /dev/null
+++ b/xmake/core/base/deprecated/interpreter.lua
@@ -0,0 +1,115 @@
+--!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) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file deprecated_interpreter.lua
+--
+
+-- define module: deprecated_interpreter
+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("base/sandbox")
+
+-- register api for set_scope()
+function deprecated_interpreter.api_register_set_scope(self, ...)
+
+ -- check
+ assert(self)
+
+ -- define implementation
+ local implementation = function (self, scopes, scope_kind, scope_name)
+
+ -- init scope for kind
+ local scope_for_kind = scopes[scope_kind] or {}
+ scopes[scope_kind] = scope_for_kind
+
+ -- warning
+ if not scope_name:startswith("__") then
+ utils.warning("please uses %s(\"%s\"), \"set_%s\" has been deprecated!", scope_kind, scope_name, scope_kind)
+ end
+
+ -- check
+ if not scope_for_kind[scope_name] then
+ utils.error("set_%s(\"%s\") failed, %s not found!", scope_kind, scope_name, scope_name)
+ utils.error("please uses add_%s(\"%s\") first!", scope_kind, scope_name)
+ utils.abort()
+ end
+
+ -- init scope for name
+ scope_for_kind[scope_name] = scope_for_kind[scope_name] or {}
+
+ -- save the current scope
+ scopes._CURRENT = scope_for_kind[scope_name]
+
+ -- update the current scope kind
+ scopes._CURRENT_KIND = scope_kind
+
+ end
+
+ -- register implementation
+ self:_api_register_xxx_scope("set", implementation, ...)
+end
+
+-- register api for add_scope()
+function deprecated_interpreter.api_register_add_scope(self, ...)
+
+ -- check
+ assert(self)
+
+ -- define implementation
+ local implementation = function (self, scopes, scope_kind, scope_name)
+
+ -- init scope for kind
+ local scope_for_kind = scopes[scope_kind] or {}
+ scopes[scope_kind] = scope_for_kind
+
+ -- warning
+ if not scope_name:startswith("__") then
+ utils.warning("please uses %s(\"%s\"), \"add_%s\" has been deprecated!", scope_kind, scope_name, scope_kind)
+ end
+
+ -- check
+ if scope_for_kind[scope_name] then
+ utils.error("add_%s(\"%s\") failed, %s have been defined!", scope_kind, scope_name, scope_name)
+ utils.error("please uses set_%s(\"%s\")!", scope_kind, scope_name)
+ utils.abort()
+ end
+
+ -- init scope for name
+ scope_for_kind[scope_name] = scope_for_kind[scope_name] or {}
+
+ -- save the current scope
+ scopes._CURRENT = scope_for_kind[scope_name]
+
+ -- update the current scope kind
+ scopes._CURRENT_KIND = scope_kind
+
+ end
+
+ -- register implementation
+ self:_api_register_xxx_scope("add", implementation, ...)
+end
+
+-- return module: deprecated_interpreter
+return deprecated_interpreter
diff --git a/xmake/core/base/deprecated/project.lua b/xmake/core/base/deprecated/project.lua
new file mode 100644
index 000000000..cc4f341a0
--- /dev/null
+++ b/xmake/core/base/deprecated/project.lua
@@ -0,0 +1,272 @@
+--!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) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file deprecated_project.lua
+--
+
+-- define module: deprecated_project
+local deprecated_project = deprecated_project or {}
+
+-- load modules
+local os = require("base/os")
+local rule = require("base/rule")
+local path = require("base/path")
+local utils = require("base/utils")
+local table = require("base/table")
+local config = require("base/config")
+local platform = require("base/platform")
+local deprecated_interpreter = require("base/deprecated/interpreter")
+
+-- the current os is belong to the given os?
+function deprecated_project._api_is_os(interp, ...)
+
+ -- get the current os
+ local os = platform.os()
+ if not os then return false end
+
+ -- exists this os?
+ for _, o in ipairs(table.join(...)) do
+ if o and type(o) == "string" and o == os then
+ return true
+ end
+ end
+end
+
+-- the current mode is belong to the given modes?
+function deprecated_project._api_is_mode(interp, ...)
+
+ -- get the current mode
+ local mode = config.get("mode")
+ if not mode then return false end
+
+ -- exists this mode?
+ for _, m in ipairs(table.join(...)) do
+ if m and type(m) == "string" and m == mode then
+ return true
+ end
+ end
+end
+
+-- the current platform is belong to the given platforms?
+function deprecated_project._api_is_plat(interp, ...)
+
+ -- get the current platform
+ local plat = config.get("plat")
+ if not plat then return false end
+
+ -- exists this platform? and escape '-'
+ for _, p in ipairs(table.join(...)) do
+ if p and type(p) == "string" and plat:find(p:gsub("%-", "%%-")) then
+ return true
+ end
+ end
+end
+
+-- the current platform is belong to the given architectures?
+function deprecated_project._api_is_arch(interp, ...)
+
+ -- get the current architecture
+ local arch = config.get("arch")
+ if not arch then return false end
+
+ -- exists this architecture? and escape '-'
+ for _, a in ipairs(table.join(...)) do
+ if a and type(a) == "string" and arch:find(a:gsub("%-", "%%-")) then
+ return true
+ end
+ end
+end
+
+-- the current kind is belong to the given kinds?
+function deprecated_project._api_is_kind(interp, ...)
+
+ -- get the current kind
+ local kind = config.get("kind")
+ if not kind then return false end
+
+ -- exists this kind?
+ for _, k in ipairs(table.join(...)) do
+ if k and type(k) == "string" and k == kind then
+ return true
+ end
+ end
+end
+
+-- enable options?
+function deprecated_project._api_is_option(interp, ...)
+
+ -- some options are enabled?
+ for _, o in ipairs(table.join(...)) do
+ if o and type(o) == "string" and config.get(o) then
+ return true
+ end
+ end
+end
+
+-- the current os is belong to the given os?
+function deprecated_project._api_os(interp, ...)
+
+ -- make values
+ local values = ""
+ for _, v in ipairs(table.join(...)) do
+ if v and type(v) == "string" then
+ if #values == 0 then
+ values = v
+ else
+ values = values .. ", " .. v
+ end
+ end
+ end
+
+ -- warning
+ utils.warning("please uses is_os(\"%s\"), \"os()\" has been deprecated!", values)
+
+ -- done
+ return deprecated_project._api_is_os(interp, ...)
+end
+
+-- the current mode is belong to the given modes?
+function deprecated_project._api_modes(interp, ...)
+
+ -- make values
+ local values = ""
+ for _, v in ipairs(table.join(...)) do
+ if v and type(v) == "string" then
+ if #values == 0 then
+ values = v
+ else
+ values = values .. ", " .. v
+ end
+ end
+ end
+
+ -- warning
+ utils.warning("please uses is_mode(\"%s\"), \"modes()\" has been deprecated!", values)
+
+ -- done
+ return deprecated_project._api_is_mode(interp, ...)
+end
+
+-- the current platform is belong to the given platforms?
+function deprecated_project._api_plats(interp, ...)
+
+ -- make values
+ local values = ""
+ for _, v in ipairs(table.join(...)) do
+ if v and type(v) == "string" then
+ if #values == 0 then
+ values = v
+ else
+ values = values .. ", " .. v
+ end
+ end
+ end
+
+ -- warning
+ utils.warning("please uses is_plat(\"%s\"), \"plats()\" has been deprecated!", values)
+
+ -- done
+ return deprecated_project._api_is_plat(interp, ...)
+end
+
+-- the current platform is belong to the given architectures?
+function deprecated_project._api_archs(interp, ...)
+
+ -- make values
+ local values = ""
+ for _, v in ipairs(table.join(...)) do
+ if v and type(v) == "string" then
+ if #values == 0 then
+ values = v
+ else
+ values = values .. ", " .. v
+ end
+ end
+ end
+
+ -- warning
+ utils.warning("please uses is_arch(\"%s\"), \"archs()\" has been deprecated!", values)
+
+ -- done
+ return deprecated_project._api_is_arch(interp, ...)
+end
+
+-- the current kind is belong to the given kinds?
+function deprecated_project._api_kinds(interp, ...)
+
+ -- make values
+ local values = ""
+ for _, v in ipairs(table.join(...)) do
+ if v and type(v) == "string" then
+ if #values == 0 then
+ values = v
+ else
+ values = values .. ", " .. v
+ end
+ end
+ end
+
+ -- warning
+ utils.warning("please uses is_kind(\"%s\"), \"kinds()\" has been deprecated!", values)
+
+ -- done
+ return deprecated_project._api_is_kind(interp, ...)
+end
+
+-- enable options?
+function deprecated_project._api_options(interp, ...)
+
+ -- make values
+ local values = ""
+ for _, v in ipairs(table.join(...)) do
+ if v and type(v) == "string" then
+ if #values == 0 then
+ values = v
+ else
+ values = values .. ", " .. v
+ end
+ end
+ end
+
+ -- warning
+ utils.warning("please uses is_option(\"%s\"), \"options()\" has been deprecated!", values)
+
+ -- done
+ return deprecated_project._api_is_option(interp, ...)
+end
+
+-- register api
+function deprecated_project.api_register(interp)
+
+ -- register api: set_target() and set_option()
+ deprecated_interpreter.api_register_set_scope(interp, "target", "option")
+ deprecated_interpreter.api_register_add_scope(interp, "target", "option")
+
+ -- register api: os(), kinds(), modes(), plats(), archs(), options()
+ interp:api_register("os", deprecated_project._api_os)
+ interp:api_register("kinds", deprecated_project._api_kinds)
+ interp:api_register("modes", deprecated_project._api_modes)
+ interp:api_register("plats", deprecated_project._api_plats)
+ interp:api_register("archs", deprecated_project._api_archs)
+ interp:api_register("options", deprecated_project._api_options)
+
+end
+
+-- return module: deprecated_project
+return deprecated_project
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index f5d454dc2..7f8d8fcb4 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -606,88 +606,6 @@ function interpreter.api_register_scope(self, ...)
self:_api_register_xxx_scope(nil, implementation, ...)
end
--- TODO: deprecated
--- register api for set_scope()
-function interpreter.api_register_set_scope(self, ...)
-
- -- check
- assert(self)
-
- -- define implementation
- local implementation = function (self, scopes, scope_kind, scope_name)
-
- -- init scope for kind
- local scope_for_kind = scopes[scope_kind] or {}
- scopes[scope_kind] = scope_for_kind
-
- -- warning
- if not scope_name:startswith("__") then
- utils.warning("please uses %s(\"%s\"), \"set_%s\" has been deprecated!", scope_kind, scope_name, scope_kind)
- end
-
- -- check
- if not scope_for_kind[scope_name] then
- utils.error("set_%s(\"%s\") failed, %s not found!", scope_kind, scope_name, scope_name)
- utils.error("please uses add_%s(\"%s\") first!", scope_kind, scope_name)
- utils.abort()
- end
-
- -- init scope for name
- scope_for_kind[scope_name] = scope_for_kind[scope_name] or {}
-
- -- save the current scope
- scopes._CURRENT = scope_for_kind[scope_name]
-
- -- update the current scope kind
- scopes._CURRENT_KIND = scope_kind
-
- end
-
- -- register implementation
- self:_api_register_xxx_scope("set", implementation, ...)
-end
-
--- TODO: deprecated
--- register api for add_scope()
-function interpreter.api_register_add_scope(self, ...)
-
- -- check
- assert(self)
-
- -- define implementation
- local implementation = function (self, scopes, scope_kind, scope_name)
-
- -- init scope for kind
- local scope_for_kind = scopes[scope_kind] or {}
- scopes[scope_kind] = scope_for_kind
-
- -- warning
- if not scope_name:startswith("__") then
- utils.warning("please uses %s(\"%s\"), \"add_%s\" has been deprecated!", scope_kind, scope_name, scope_kind)
- end
-
- -- check
- if scope_for_kind[scope_name] then
- utils.error("add_%s(\"%s\") failed, %s have been defined!", scope_kind, scope_name, scope_name)
- utils.error("please uses set_%s(\"%s\")!", scope_kind, scope_name)
- utils.abort()
- end
-
- -- init scope for name
- scope_for_kind[scope_name] = scope_for_kind[scope_name] or {}
-
- -- save the current scope
- scopes._CURRENT = scope_for_kind[scope_name]
-
- -- update the current scope kind
- scopes._CURRENT_KIND = scope_kind
-
- end
-
- -- register implementation
- self:_api_register_xxx_scope("add", implementation, ...)
-end
-
-- register api for set_values
--
-- interp:api_register_set_values("scope_kind", "name1", "name2", ...)
diff --git a/xmake/core/base/project.lua b/xmake/core/base/project.lua
index d50afe4cc..58daf394f 100644
--- a/xmake/core/base/project.lua
+++ b/xmake/core/base/project.lua
@@ -24,18 +24,19 @@
local project = project or {}
-- load modules
-local os = require("base/os")
-local io = require("base/io")
-local rule = require("base/rule")
-local path = require("base/path")
-local utils = require("base/utils")
-local table = require("base/table")
-local config = require("base/config")
-local filter = require("base/filter")
-local linker = require("base/linker")
-local compiler = require("base/compiler")
-local platform = require("base/platform")
-local interpreter = require("base/interpreter")
+local os = require("base/os")
+local io = require("base/io")
+local rule = require("base/rule")
+local path = require("base/path")
+local utils = require("base/utils")
+local table = require("base/table")
+local config = require("base/config")
+local filter = require("base/filter")
+local linker = require("base/linker")
+local compiler = require("base/compiler")
+local platform = require("base/platform")
+local interpreter = require("base/interpreter")
+local deprecated_project = require("base/deprecated/project")
-- the current os is belong to the given os?
function project._api_is_os(interp, ...)
@@ -123,144 +124,6 @@ function project._api_is_option(interp, ...)
end
end
--- TODO: deprecated
--- the current os is belong to the given os?
-function project._api_os(interp, ...)
-
- -- make values
- local values = ""
- for _, v in ipairs(table.join(...)) do
- if v and type(v) == "string" then
- if #values == 0 then
- values = v
- else
- values = values .. ", " .. v
- end
- end
- end
-
- -- warning
- utils.warning("please uses is_os(\"%s\"), \"os()\" has been deprecated!", values)
-
- -- done
- return project._api_is_os(interp, ...)
-end
-
--- TODO: deprecated
--- the current mode is belong to the given modes?
-function project._api_modes(interp, ...)
-
- -- make values
- local values = ""
- for _, v in ipairs(table.join(...)) do
- if v and type(v) == "string" then
- if #values == 0 then
- values = v
- else
- values = values .. ", " .. v
- end
- end
- end
-
- -- warning
- utils.warning("please uses is_mode(\"%s\"), \"modes()\" has been deprecated!", values)
-
- -- done
- return project._api_is_mode(interp, ...)
-end
-
--- TODO: deprecated
--- the current platform is belong to the given platforms?
-function project._api_plats(interp, ...)
-
- -- make values
- local values = ""
- for _, v in ipairs(table.join(...)) do
- if v and type(v) == "string" then
- if #values == 0 then
- values = v
- else
- values = values .. ", " .. v
- end
- end
- end
-
- -- warning
- utils.warning("please uses is_plat(\"%s\"), \"plats()\" has been deprecated!", values)
-
- -- done
- return project._api_is_plat(interp, ...)
-end
-
--- TODO: deprecated
--- the current platform is belong to the given architectures?
-function project._api_archs(interp, ...)
-
- -- make values
- local values = ""
- for _, v in ipairs(table.join(...)) do
- if v and type(v) == "string" then
- if #values == 0 then
- values = v
- else
- values = values .. ", " .. v
- end
- end
- end
-
- -- warning
- utils.warning("please uses is_arch(\"%s\"), \"archs()\" has been deprecated!", values)
-
- -- done
- return project._api_is_arch(interp, ...)
-end
-
--- TODO: deprecated
--- the current kind is belong to the given kinds?
-function project._api_kinds(interp, ...)
-
- -- make values
- local values = ""
- for _, v in ipairs(table.join(...)) do
- if v and type(v) == "string" then
- if #values == 0 then
- values = v
- else
- values = values .. ", " .. v
- end
- end
- end
-
- -- warning
- utils.warning("please uses is_kind(\"%s\"), \"kinds()\" has been deprecated!", values)
-
- -- done
- return project._api_is_kind(interp, ...)
-end
-
--- TODO: deprecated
--- enable options?
-function project._api_options(interp, ...)
-
- -- make values
- local values = ""
- for _, v in ipairs(table.join(...)) do
- if v and type(v) == "string" then
- if #values == 0 then
- values = v
- else
- values = values .. ", " .. v
- end
- end
- end
-
- -- warning
- utils.warning("please uses is_option(\"%s\"), \"options()\" has been deprecated!", values)
-
- -- done
- return project._api_is_option(interp, ...)
-end
-
-- add c function
function project._api_add_cfunc(interp, module, alias, links, includes, cfunc)
@@ -464,10 +327,8 @@ function project._interpreter()
-- set root directory
interp:rootdir_set(xmake._PROJECT_DIR)
- -- TODO: deprecated
- -- register api: set_target() and set_option()
- interp:api_register_set_scope("target", "option")
- interp:api_register_add_scope("target", "option")
+ -- register api: deprecated
+ deprecated_project.api_register(interp)
-- register api: target() and option()
interp:api_register_scope("target", "option")
@@ -553,16 +414,6 @@ function project._interpreter()
interp:api_register_add_pathes("option", "option", "linkdirs"
, "includedirs")
-
- -- TODO: deprecated
- -- register api: os(), kinds(), modes(), plats(), archs(), options()
- interp:api_register("os", project._api_os)
- interp:api_register("kinds", project._api_kinds)
- interp:api_register("modes", project._api_modes)
- interp:api_register("plats", project._api_plats)
- interp:api_register("archs", project._api_archs)
- interp:api_register("options", project._api_options)
-
-- register api: is_os(), is_kind(), is_mode(), is_plat(), is_arch(), is_option()
interp:api_register("is_os", project._api_is_os)
interp:api_register("is_kind", project._api_is_kind)