summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-05 16:28:47 +0800
committerruki <[email protected]>2017-09-05 16:28:47 +0800
commit59d673ea76a08ae2cbab83eaad82de915c8ee803 (patch)
treee5d60c357c6f3861add09014639df1f16a8dfb45
parent3df59e7a2ed5c0c5cf6951695434a33784179567 (diff)
remove deprecated bindings
-rw-r--r--CHANGELOG.md2
-rw-r--r--xmake/core/base/option.lua99
-rw-r--r--xmake/core/project/project.lua39
3 files changed, 36 insertions, 104 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4fda050f8..20a71bc36 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
* Improve install and uninstall actions and support DESTDIR and PREFIX envirnoment variables
* Optimize to detect flags
* Add `COLORTERM=nocolor` to disable color output
+* Remove `and_bindings` and `add_rbindings` api
### Bugs fixed
@@ -362,6 +363,7 @@
* 改进安装和卸载脚本,支持DESTDIR和PREFIX环境变量设置
* 通过缓存优化flags探测,加速编译效率
* 添加`COLORTERM=nocolor`环境变量开关,禁用彩色输出
+* 移除`add_rbindings`和`add_bindings`接口
### Bugs修复
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index 7f3ef2ad8..6ecc2163c 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -96,41 +96,6 @@ function option._context()
end
end
--- get longname
-function option._longname(name)
-
- -- the long name and bindings
- --
- -- .e.g test:xxx1,xxx2,xxx3
- --
- -- longname: test
- -- bindings: xxx1 xxx2 xxx3
- --
- if name ~= nil then
- return name:split(':')[1]
- end
-end
-
--- get bindings
-function option._bindings(name)
-
- -- the long name and bindings
- --
- -- .e.g test:xxx1,xxx2,xxx3
- --
- -- longname: test
- -- bindings: xxx1 xxx2 xxx3
- --
- if name ~= nil then
- local names = name:split(':')
- if names then
- if names[2] then
- return names[2]:split(',')
- end
- end
- end
-end
-
-- get line length
function option._get_linelen(st)
local poss = st:reverse():find("\n")
@@ -305,14 +270,8 @@ function option.init(menu)
-- the short name
local shortname = o[1]
- -- the long name and bindings
- --
- -- .e.g test:xxx1,xxx2,xxx3
- --
- -- longname: test
- -- bindings: xxx1 xxx2 xxx3
- --
- longname = option._longname(o[2])
+ -- the long name
+ longname = o[2]
-- --key?
if prefix == 2 and key == longname then
@@ -376,20 +335,6 @@ function option.init(menu)
-- save option
context.options[longname] = value
- -- save bindings
- local bindings = option._bindings(opt[2])
- if bindings then
- for _, bindname in ipairs(bindings) do
- if bindname:startswith("!") then
- if type(value) == "boolean" then
- context.options[bindname:sub(2, -1)] = not value
- end
- else
- context.options[bindname] = value
- end
- end
- end
-
-- task?
elseif idx == 1 then
@@ -428,7 +373,7 @@ function option.init(menu)
local mode = o[3]
-- the name
- local name = option._longname(o[2])
+ local name = o[2]
-- check
assert(o and ((mode ~= "v" and mode ~= "vs") or name))
@@ -451,7 +396,7 @@ function option.init(menu)
local mode = opt[3]
-- the name
- local name = option._longname(opt[2])
+ local name = opt[2]
-- save value
if mode == "v" then
@@ -482,7 +427,7 @@ function option.init(menu)
for _, o in ipairs(table.wrap(option._taskmenu().options)) do
-- the long name
- local longname = option._longname(o[2])
+ local longname = o[2]
-- key=value?
if o[3] == "kv" then
@@ -600,14 +545,8 @@ function option.parse(argv, options)
-- the short name
local shortname = o[1]
- -- the long name and bindings
- --
- -- .e.g test:xxx1,xxx2,xxx3
- --
- -- longname: test
- -- bindings: xxx1 xxx2 xxx3
- --
- longname = option._longname(o[2])
+ -- the long name
+ longname = o[2]
-- --key?
if prefix == 2 and key == longname then
@@ -662,20 +601,6 @@ function option.parse(argv, options)
-- save option
results[longname] = value
- -- save bindings
- local bindings = option._bindings(opt[2])
- if bindings then
- for _, bindname in ipairs(bindings) do
- if bindname:startswith("!") then
- if type(value) == "boolean" then
- results[bindname:sub(2, -1)] = not value
- end
- else
- results[bindname] = value
- end
- end
- end
-
-- value?
else
@@ -690,7 +615,7 @@ function option.parse(argv, options)
local mode = o[3]
-- the name
- local name = option._longname(o[2])
+ local name = o[2]
-- check
assert(o and ((mode ~= "v" and mode ~= "vs") or name))
@@ -713,7 +638,7 @@ function option.parse(argv, options)
local mode = opt[3]
-- the name
- local name = option._longname(opt[2])
+ local name = opt[2]
-- save value
if mode == "v" then
@@ -742,7 +667,7 @@ function option.parse(argv, options)
for _, o in ipairs(options) do
-- the long name
- local longname = option._longname(o[2])
+ local longname = o[2]
-- key=value?
if o[3] == "kv" then
@@ -849,7 +774,7 @@ function option.defaults(task)
for _, o in ipairs(taskmenu.options) do
-- the long name
- local longname = option._longname(o[2])
+ local longname = o[2]
-- key=value?
if o[3] == "kv" then
@@ -1061,7 +986,7 @@ function option.show_options(options)
-- append the shortname
local shortname = opt[1]
- local name = option._longname(opt[2])
+ local name = opt[2]
local mode = opt[3]
if shortname then
option_info = option_info .. " -" .. shortname
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 1e2935586..bd853ab7e 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -238,8 +238,6 @@ function project.interpreter()
-- option.add_xxx
, "option.add_deps"
, "option.add_vectorexts"
- , "option.add_bindings" -- deprecated
- , "option.add_rbindings" -- deprecated
}
, pathes =
{
@@ -505,6 +503,27 @@ function project._load_options(disable_filter)
if not ok then
return nil, errors
end
+
+ -- load the options from the project requires
+ for _, require_str in ipairs(table.wrap(project.get("requires"))) do
+
+ -- get the package name
+ local splitinfo = require_str:split('%s+')
+ local packageinfo = splitinfo[1]
+ local packagename = nil
+ local pos = packageinfo:find_last('@', true)
+ if pos then
+ packagename = packageinfo:sub(pos + 1)
+ else
+ packagename = packageinfo
+ end
+
+ -- check
+ assert(not results[packagename], "requires(\"" .. packagename .. "\") and option(\"" .. packagename .. "\") conflicts!")
+
+ -- add option
+ results[packagename] = {category = "requires", default = true, showmenu = true, description = "The " .. packagename .. " package"}
+ end
-- check options
local options = {}
@@ -741,22 +760,8 @@ function project.menu()
first = false
end
- -- deprecated: make bindings
- local bindings = nil
- if opt:get("bindings") then
- bindings = string.join(table.wrap(opt:get("bindings")), ',')
- end
- if opt:get("rbindings") then
- bindings = "!" .. string.join(table.wrap(opt:get("rbindings")), ",!")
- end
-
- -- make longname
- local longname = name
- if bindings ~= nil then
- longname = longname .. ":" .. bindings
- end
-
-- append it
+ local longname = name
local descriptions = opt:get("description")
if descriptions then