summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-15 16:14:15 +0800
committerruki <[email protected]>2015-06-15 16:14:15 +0800
commit8b3ec0b07a3cdcd3e946c6916091e7ec2fcda1a7 (patch)
treedb62b99e7f2514f23d12f6f2b368d40bb9d65104
parent351b402b8d0f5ee48097742c7b59a53054dd10ef (diff)
add option category
-rw-r--r--xmake/scripts/base/project.lua41
1 files changed, 32 insertions, 9 deletions
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index af37ef50f..5e5318236 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -723,6 +723,7 @@ function project._load_options(file)
-- register interfaces for setting option values
local interfaces = { "enable"
, "showmenu"
+ , "category"
, "description"}
for _, interface in ipairs(interfaces) do
@@ -959,19 +960,41 @@ function project.menu()
local options = configs._OPTIONS
if not options then return {} end
- -- make menu
- local menu = {{}}
+ -- arrange options by category
+ local options_by_category = {}
for name, opt in pairs(options) do
- -- show menu?
- if opt.showmenu then
+ -- make the category
+ local category = "default"
+ if opt.category then category = utils.unwrap(opt.category) end
+ options_by_category[category] = options_by_category[category] or {}
- -- the default value
- local default = utils.unwrap(opt.enable)
- if not default then default = "auto" end
+ -- append option to the current category
+ options_by_category[category][name] = opt
+ end
+
+ -- make menu by category
+ local menu = {}
+ for k, opts in pairs(options_by_category) do
+
+ -- insert a separator
+ table.insert(menu, {})
+
+ -- insert options
+ for name, opt in pairs(opts) do
- -- append it
- table.insert(menu, {nil, name, "kv", default, utils.unwrap(opt.description)})
+ -- show menu?
+ if opt.showmenu then
+
+ -- the default value
+ local default = "auto"
+ if opt.enable and utils.unwrap(opt.enable) then
+ default = true
+ end
+
+ -- append it
+ table.insert(menu, {nil, name, "kv", default, utils.unwrap(opt.description)})
+ end
end
end