From 8b3ec0b07a3cdcd3e946c6916091e7ec2fcda1a7 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 15 Jun 2015 16:14:15 +0800 Subject: add option category --- xmake/scripts/base/project.lua | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'xmake/scripts/base/project.lua') 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 -- cgit v1.3.1