diff options
| author | ruki <[email protected]> | 2018-01-31 22:35:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-31 09:31:17 +0800 |
| commit | 0389a6137f4aa879433d83cf4e7aa7c309caa5e8 (patch) | |
| tree | ac6fca7a51b3cd95467541481a37ba94e7579f93 | |
| parent | b0c66bcd2f4f029706ddec16bb5c8bb4aae35774 (diff) | |
add config menu category
| -rw-r--r-- | xmake/actions/config/menuconf.lua | 67 | ||||
| -rw-r--r-- | xmake/actions/config/xmake.lua | 15 |
2 files changed, 66 insertions, 16 deletions
diff --git a/xmake/actions/config/menuconf.lua b/xmake/actions/config/menuconf.lua index bca0f98ff..47829b02a 100644 --- a/xmake/actions/config/menuconf.lua +++ b/xmake/actions/config/menuconf.lua @@ -73,6 +73,28 @@ function app:mconfdialog() return self._MCONFDIALOG end +-- filter option +function app:filter_option(name) + local options = + { + target = true + , file = true + , root = true + , yes = true + , quiet = true + , profile = true + , project = true + , verbose = true + , backtrace = true + , require = true + , version = true + , help = true + , clean = true + , menu = true + } + return not options[name] and not project.option(name) +end + -- get basic configs function app:basic_configs(cache) @@ -85,12 +107,40 @@ function app:basic_configs(cache) -- get config menu local menu = option.taskmenu("config") - -- make configs from options - local configs = {} + -- merge options by category + local category = "Root Configuration" local options = menu and menu.options or {} - for _, opt in ipairs(options) do + local options_by_category = {} + for _, opt in pairs(options) do local name = opt[2] or opt[1] - if not project.option(name) then + if name and self:filter_option(name) then + options_by_category[category] = options_by_category[category] or {} + table.insert(options_by_category[category], opt) + elseif opt.category then + category = opt.category + end + end + + -- make configs from options + local configs = {} + for category, opts in pairs(options_by_category) do + + -- insert configs + local first = true + local submenu = nil + for _, opt in ipairs(opts) do + + -- is first? init a sub-menu + if first then + if category ~= "Root Configuration" then + submenu = menuconf.menu {name = category, description = category, configs = {}} + table.insert(configs, submenu) + end + first = false + end + + -- get name + local name = opt[2] or opt[1] -- get kind local kind = opt[3] @@ -98,6 +148,7 @@ function app:basic_configs(cache) -- get default local default = opt[4] + -- TODO -- get description local description = opt[5] @@ -109,10 +160,10 @@ function app:basic_configs(cache) -- key=value? if kind == "kv" then - table.insert(configs, menuconf.string {name = name, value = value, default = default, description = description}) + table.insert(submenu and submenu.configs or configs, menuconf.string {name = name, value = value, default = default, description = description}) -- --key? elseif kind == "k" then - table.insert(configs, menuconf.boolean {name = name, value = value, default = default, description = description}) + table.insert(submenu and submenu.configs or configs, menuconf.boolean {name = name, value = value, default = default, description = description}) end end end @@ -137,7 +188,7 @@ function app:project_configs(cache) for _, opt in pairs(options) do -- make the category - local category = "default" + local category = "__root__" if opt:get("category") then category = table.unwrap(opt:get("category")) end options_by_category[category] = options_by_category[category] or {} @@ -164,7 +215,7 @@ function app:project_configs(cache) -- is first? init a sub-menu if first then - if name ~= "default" then + if category ~= "__root__" then submenu = menuconf.menu {name = category, description = category, configs = {}} table.insert(configs, submenu) end diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua index b1e29b1f8..e443b8cb3 100644 --- a/xmake/actions/config/xmake.lua +++ b/xmake/actions/config/xmake.lua @@ -51,7 +51,7 @@ task("config") " - y: force to enable", " - n: disable" } - , {} + , {category = "Root Configuration"} , {'p', "plat", "kv", "$(host)", "Compile for the given platform." -- show the description of all platforms @@ -112,10 +112,7 @@ task("config") return menu.options() end - , {} - , {nil, "ccache", "kv", true, "Enable or disable the c/c++ compiler cache." } - - , {} + , {category = "Cross Complation Configuration"} , {nil, "cross", "kv", nil, "The cross toolchains prefix" , ".e.g" , " - i386-mingw32-" @@ -129,10 +126,8 @@ task("config") , " - sdk/lib" , " - sdk/include" } - , {} - , {nil, "debugger", "kv", "auto", "The Debugger" } - -- show language menu options + , {category = "Language Options Configuration"} , function () -- import language menu @@ -143,6 +138,7 @@ task("config") end -- show platform menu options + , {category = "Platform Options Configuration"} , function () -- import platform menu @@ -152,6 +148,9 @@ task("config") return menu.options("config") end + , {category = "Other Configuration"} + , {nil, "debugger", "kv", "auto", "The Debugger" } + , {nil, "ccache", "kv", true, "Enable or disable the c/c++ compiler cache." } , {'o', "buildir", "kv", "build", "Set the build directory." } , {} |
