summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-02-01 22:55:42 +0800
committerruki <[email protected]>2018-02-01 11:34:17 +0800
commit65b0ab3efb3b7a503804dc412189801431475dcd (patch)
tree6ae16c29302fdc2587a928d8b80a6a8e8e5c8471
parentfa98fd2e588f56713df258b6c5639db8d3bc9ad5 (diff)
improve project option menu
-rw-r--r--xmake/actions/config/menuconf.lua97
-rw-r--r--xmake/languages/asm/xmake.lua32
-rw-r--r--xmake/languages/c++/xmake.lua4
-rw-r--r--xmake/languages/dlang/xmake.lua18
-rw-r--r--xmake/languages/golang/xmake.lua16
-rw-r--r--xmake/languages/msrc/xmake.lua12
-rw-r--r--xmake/languages/objc++/xmake.lua4
-rw-r--r--xmake/languages/rust/xmake.lua16
-rw-r--r--xmake/languages/swift/xmake.lua6
9 files changed, 80 insertions, 125 deletions
diff --git a/xmake/actions/config/menuconf.lua b/xmake/actions/config/menuconf.lua
index 2c9601fe7..0fe0be4f1 100644
--- a/xmake/actions/config/menuconf.lua
+++ b/xmake/actions/config/menuconf.lua
@@ -119,7 +119,7 @@ function app:_menu_by_category(configs, menus, category)
end
-- make configs by category
-function app:_make_configs_by_category(options_by_category)
+function app:_make_configs_by_category(options_by_category, get_option_info)
-- make configs category
--
@@ -139,18 +139,8 @@ function app:_make_configs_by_category(options_by_category)
-- insert options to sub-configs
for _, opt in ipairs(options) do
- -- get name
- local name = opt[2] or opt[1]
-
- -- get kind
- local kind = opt[3]
-
- -- get default
- local default = opt[4]
-
- -- TODO
- -- get description
- local description = opt[5]
+ -- get option info
+ local info = get_option_info(opt)
-- load value
local value = nil
@@ -168,12 +158,10 @@ function app:_make_configs_by_category(options_by_category)
end
-- insert config before all sub-menus
- -- key=value?
- if kind == "kv" then
- table.insert(subconfigs, menu_index, menuconf.string {name = name, value = value, default = default, description = description})
- -- --key?
- elseif kind == "k" then
- table.insert(subconfigs, menu_index, menuconf.boolean {name = name, value = value, default = default, description = description})
+ if info.kind == "string" then
+ table.insert(subconfigs, menu_index, menuconf.string {name = info.name, value = value, default = info.default, description = info.description})
+ elseif info.kind == "boolean" then
+ table.insert(subconfigs, menu_index, menuconf.boolean {name = info.name, value = value, default = info.default, description = info.description})
end
end
end
@@ -209,7 +197,9 @@ function app:_basic_configs(cache)
end
-- make configs by category
- self._BASIC_CONFIGS = self:_make_configs_by_category(options_by_category)
+ self._BASIC_CONFIGS = self:_make_configs_by_category(options_by_category, function (opt)
+ return {name = opt[2] or opt[1], kind = (opt[3] == "k") and "boolean" or "string", default = opt[4], description = opt[5]}
+ end)
return self._BASIC_CONFIGS
end
@@ -226,61 +216,26 @@ function app:_project_configs(cache)
local options = project.options()
local options_by_category = {}
for _, opt in pairs(options) do
-
- -- make the category
- local category = "__root__"
- if opt:get("category") then category = table.unwrap(opt:get("category")) end
- options_by_category[category] = options_by_category[category] or {}
-
- -- append option to the current category
- options_by_category[category][opt:name()] = opt
+ if opt:get("showmenu") then
+ local category = "."
+ if opt:get("category") then category = table.unwrap(opt:get("category")) end
+ options_by_category[category] = options_by_category[category] or {}
+ table.insert(options_by_category[category], opt)
+ 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 name, opt in pairs(opts) do
- if opt:get("showmenu") then
-
- -- TODO
- -- the default value
- local default = "auto"
- if opt:get("default") ~= nil then
- default = opt:get("default")
- end
-
- -- is first? init a sub-menu
- if first then
- if category ~= "__root__" then
- submenu = menuconf.menu {name = category, description = category, configs = {}}
- table.insert(configs, submenu)
- end
- first = false
- end
-
- -- load value
- local value = nil
- if cache then
- value = config.get(value)
- end
+ -- make configs by category
+ self._PROJECT_CONFIGS = self:_make_configs_by_category(options_by_category, function (opt)
- -- insert config
- if type(default) == "string" then
- table.insert(submenu and submenu.configs or configs, menuconf.string {name = name, value = value, default = default, description = opt:get("description")})
- else
- table.insert(submenu and submenu.configs or configs, menuconf.boolean {name = name, value = value, default = default, description = opt:get("description")})
- end
- end
+ -- TODO
+ -- the default value
+ local default = "auto"
+ if opt:get("default") ~= nil then
+ default = opt:get("default")
end
- end
-
- -- cache configs
- self._PROJECT_CONFIGS = configs
- return configs
+ return {name = opt:name(), kind = (type(default) == "string") and "string" or "boolean", default = default, description = opt:get("description")}
+ end)
+ return self._PROJECT_CONFIGS
end
-- save the given configs
diff --git a/xmake/languages/asm/xmake.lua b/xmake/languages/asm/xmake.lua
index 8afe36d10..1a1c0b2a3 100644
--- a/xmake/languages/asm/xmake.lua
+++ b/xmake/languages/asm/xmake.lua
@@ -118,24 +118,24 @@ language("asm")
set_menu {
config =
{
- {category = "Cross Complation Configuration/Compiler and Linker Configuration" }
- , {nil, "as", "kv", nil, "The Assembler" }
- , {nil, "ar", "kv", nil, "The Static Library Linker" }
- , {nil, "ld", "kv", nil, "The Linker" }
- , {nil, "sh", "kv", nil, "The Shared Library Linker" }
+ {category = "Cross Complation Configuration/Compiler and Linker Configuration/Asm" }
+ , {nil, "as", "kv", nil, "The Assembler" }
+ , {nil, "ar", "kv", nil, "The Static Library Linker" }
+ , {nil, "ld", "kv", nil, "The Linker" }
+ , {nil, "sh", "kv", nil, "The Shared Library Linker" }
- , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration" }
- , {nil, "asflags", "kv", nil, "The Assembler Flags" }
- , {nil, "ldflags", "kv", nil, "The Binary Linker Flags" }
- , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" }
- , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" }
+ , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration/Asm" }
+ , {nil, "asflags", "kv", nil, "The Assembler Flags" }
+ , {nil, "ldflags", "kv", nil, "The Binary Linker Flags" }
+ , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" }
+ , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" }
- , { }
- , {nil, "links", "kv", nil, "The Link Libraries" }
- , {nil, "linkdirs", "kv", nil, "The Link Search Directories" }
- , {nil, "includedirs","kv", nil, "The Include Search Directories" }
- }
- }
+ , { }
+ , {nil, "links", "kv", nil, "The Link Libraries" }
+ , {nil, "linkdirs", "kv", nil, "The Link Search Directories" }
+ , {nil, "includedirs","kv", nil, "The Include Search Directories" }
+ }
+ }
diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua
index f0f3c370f..110d2dcb1 100644
--- a/xmake/languages/c++/xmake.lua
+++ b/xmake/languages/c++/xmake.lua
@@ -147,14 +147,14 @@ language("c++")
set_menu {
config =
{
- {category = "Cross Complation Configuration/Compiler and Linker Configuration" }
+ {category = "Cross Complation Configuration/Compiler and Linker Configuration/C++" }
, {nil, "cc", "kv", nil, "The C Compiler" }
, {nil, "cxx", "kv", nil, "The C++ Compiler" }
, {nil, "ld", "kv", nil, "The Linker" }
, {nil, "ar", "kv", nil, "The Static Library Linker" }
, {nil, "sh", "kv", nil, "The Shared Library Linker" }
- , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration" }
+ , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration/C++" }
, {nil, "cflags", "kv", nil, "The C Compiler Flags" }
, {nil, "cxflags", "kv", nil, "The C/C++ compiler Flags" }
, {nil, "cxxflags", "kv", nil, "The C++ Compiler Flags" }
diff --git a/xmake/languages/dlang/xmake.lua b/xmake/languages/dlang/xmake.lua
index d89c47085..07aefcba4 100644
--- a/xmake/languages/dlang/xmake.lua
+++ b/xmake/languages/dlang/xmake.lua
@@ -102,16 +102,16 @@ language("dlang")
set_menu {
config =
{
- {category = "Cross Complation Configuration/Compiler and Linker Configuration" }
- , {nil, "dc", "kv", nil, "The Dlang Compiler" }
- , {nil, "dc-ld", "kv", nil, "The Dlang Linker" }
- , {nil, "dc-ar", "kv", nil, "The Dlang Static Library Archiver" }
- , {nil, "dc-sh", "kv", nil, "The Dlang Shared Library Linker" }
+ {category = "Cross Complation Configuration/Compiler and Linker Configuration/D" }
+ , {nil, "dc", "kv", nil, "The Dlang Compiler" }
+ , {nil, "dc-ld", "kv", nil, "The Dlang Linker" }
+ , {nil, "dc-ar", "kv", nil, "The Dlang Static Library Archiver" }
+ , {nil, "dc-sh", "kv", nil, "The Dlang Shared Library Linker" }
- , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration" }
- , {nil, "links", "kv", nil, "The Link Libraries" }
- , {nil, "linkdirs", "kv", nil, "The Link Search Directories" }
- , {nil, "includedirs","kv", nil, "The Include Search Directories" }
+ , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration/D" }
+ , {nil, "links", "kv", nil, "The Link Libraries" }
+ , {nil, "linkdirs", "kv", nil, "The Link Search Directories" }
+ , {nil, "includedirs","kv", nil, "The Include Search Directories" }
}
}
diff --git a/xmake/languages/golang/xmake.lua b/xmake/languages/golang/xmake.lua
index afef8d641..2a4d7a70d 100644
--- a/xmake/languages/golang/xmake.lua
+++ b/xmake/languages/golang/xmake.lua
@@ -98,15 +98,15 @@ language("golang")
set_menu {
config =
{
- {category = "Cross Complation Configuration/Compiler and Linker Configuration" }
- , {nil, "go", "kv", nil, "The Golang Compiler" }
- , {nil, "gc-ld", "kv", nil, "The Golang Linker" }
- , {nil, "go-ar", "kv", nil, "The Golang Static Library Linker" }
+ {category = "Cross Complation Configuration/Compiler and Linker Configuration/Go" }
+ , {nil, "go", "kv", nil, "The Golang Compiler" }
+ , {nil, "gc-ld", "kv", nil, "The Golang Linker" }
+ , {nil, "go-ar", "kv", nil, "The Golang Static Library Linker" }
- , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration" }
- , {nil, "links", "kv", nil, "The Link Libraries" }
- , {nil, "linkdirs", "kv", nil, "The Link Search Directories" }
- , {nil, "includedirs","kv", nil, "The Include Search Directories" }
+ , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration/Go" }
+ , {nil, "links", "kv", nil, "The Link Libraries" }
+ , {nil, "linkdirs", "kv", nil, "The Link Search Directories" }
+ , {nil, "includedirs","kv", nil, "The Include Search Directories" }
}
}
diff --git a/xmake/languages/msrc/xmake.lua b/xmake/languages/msrc/xmake.lua
index 7d8a7f3c4..8be2990ec 100644
--- a/xmake/languages/msrc/xmake.lua
+++ b/xmake/languages/msrc/xmake.lua
@@ -63,14 +63,14 @@ language("msrc")
set_menu {
config =
{
- {category = "Cross Complation Configuration/Compiler and Linker Configuration" }
- , {nil, "mrc", "kv", nil, "The Microsoft Resource Compiler" }
+ {category = "Cross Complation Configuration/Compiler and Linker Configuration/MSRC" }
+ , {nil, "mrc", "kv", nil, "The Microsoft Resource Compiler" }
- , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration" }
- , {nil, "mrcflags", "kv", nil, "The Microsoft Resource Flags" }
+ , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration/MSRC" }
+ , {nil, "mrcflags", "kv", nil, "The Microsoft Resource Flags" }
- , { }
- , {nil, "includedirs","kv", nil, "The Include Search Directories" }
+ , { }
+ , {nil, "includedirs","kv", nil, "The Include Search Directories" }
}
}
diff --git a/xmake/languages/objc++/xmake.lua b/xmake/languages/objc++/xmake.lua
index c740c52f7..8362dd254 100644
--- a/xmake/languages/objc++/xmake.lua
+++ b/xmake/languages/objc++/xmake.lua
@@ -147,14 +147,14 @@ language("objc++")
set_menu {
config =
{
- {category = "Cross Complation Configuration/Compiler and Linker Configuration" }
+ {category = "Cross Complation Configuration/Compiler and Linker Configuration/Objc++" }
, {nil, "mm", "kv", nil, "The Objc Compiler" }
, {nil, "mxx", "kv", nil, "The Objc++ Compiler" }
, {nil, "ld", "kv", nil, "The Linker" }
, {nil, "ar", "kv", nil, "The Static Library Linker" }
, {nil, "sh", "kv", nil, "The Shared Library Linker" }
- , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration" }
+ , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration/Objc++" }
, {nil, "mflags", "kv", nil, "The Objc Compiler Flags" }
, {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" }
, {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" }
diff --git a/xmake/languages/rust/xmake.lua b/xmake/languages/rust/xmake.lua
index 2525a4db6..5b01d45de 100644
--- a/xmake/languages/rust/xmake.lua
+++ b/xmake/languages/rust/xmake.lua
@@ -91,14 +91,14 @@ language("rust")
set_menu {
config =
{
- {category = "Cross Complation Configuration/Compiler and Linker Configuration" }
- , {nil, "rc", "kv", nil, "The Rust Compiler" }
- , {nil, "rc-ld", "kv", nil, "The Rust Linker" }
- , {nil, "rc-ar", "kv", nil, "The Rust Static Library Archiver" }
- , {nil, "rc-sh", "kv", nil, "The Rust Shared Library Linker" }
+ {category = "Cross Complation Configuration/Compiler and Linker Configuration/Rust" }
+ , {nil, "rc", "kv", nil, "The Rust Compiler" }
+ , {nil, "rc-ld", "kv", nil, "The Rust Linker" }
+ , {nil, "rc-ar", "kv", nil, "The Rust Static Library Archiver" }
+ , {nil, "rc-sh", "kv", nil, "The Rust Shared Library Linker" }
- , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration" }
- , {nil, "linkdirs", "kv", nil, "The Link Search Directories" }
- }
+ , {category = "Cross Complation Configuration/Compiler and Linker Flags Configuration/Rust" }
+ , {nil, "linkdirs", "kv", nil, "The Link Search Directories" }
+ }
}
diff --git a/xmake/languages/swift/xmake.lua b/xmake/languages/swift/xmake.lua
index 8682d979a..f757ec38e 100644
--- a/xmake/languages/swift/xmake.lua
+++ b/xmake/languages/swift/xmake.lua
@@ -142,18 +142,18 @@ language("swift")
set_menu {
config =
{
- {category = "Cross Complation Configuration/Compiler and Linker Configuration" }
+ {category = "Cross Complation Configuration/Compiler and Linker Configuration/Swift" }
, { nil, "sc", "kv", nil, "The Swift Compiler" }
, { nil, "sc-ld", "kv", nil, "The Swift Linker" }
, { nil, "sc-sh", "kv", nil, "The Swift Shared Library Linker" }
- , { category = "Cross Complation Configuration/Compiler and Linker Flags Configuration" }
+ , { category = "Cross Complation Configuration/Compiler and Linker Flags Configuration/Swift" }
, { nil, "links", "kv", nil, "The Link Libraries" }
, { nil, "linkdirs", "kv", nil, "The Link Search Directories" }
, { nil, "includedirs", "kv", nil, "The Include Search Directories" }
, { nil, "frameworks", "kv", nil, "The Include and Link Frameworks" }
, { nil, "frameworkdirs", "kv", nil, "The Include and Link Frameworks Search Directories" }
- }
+ }
}