summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-01-12 00:30:58 +0800
committerruki <[email protected]>2022-01-12 00:30:58 +0800
commit5cf6e9dc9132d6eda0b6018e3fa42bc9e1c39abf (patch)
tree9eccef315cb3ce1855522b2641c9e9c88d76e6d9
parentcdebf2062b41239f4146d32ebd9464cee7921cee (diff)
add default option description
-rw-r--r--xmake/core/project/option.lua9
-rw-r--r--xmake/core/project/project.lua10
2 files changed, 12 insertions, 7 deletions
diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua
index 0364b3b47..40fd43f1a 100644
--- a/xmake/core/project/option.lua
+++ b/xmake/core/project/option.lua
@@ -414,13 +414,13 @@ function _instance:add(name, ...)
self:_invalidate()
end
--- remove the value to the option info
+-- remove the value to the option info (deprecated)
function _instance:del(name, ...)
self._INFO:apival_del(name, ...)
self:_invalidate()
end
--- remove the value to the option info (deprecated)
+-- remove the value to the option info
function _instance:remove(name, ...)
self._INFO:apival_remove(name, ...)
self:_invalidate()
@@ -454,6 +454,11 @@ function _instance:name()
return self._NAME
end
+-- get the option description
+function _instance:description()
+ return self:get("description") or ("The " .. self:name() .. " option")
+end
+
-- get the cache key
function _instance:cachekey()
return string.format("%s_%d", tostring(self), self._CACHEID)
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 3aee363a3..cd5171599 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -1161,15 +1161,15 @@ function project.menu()
-- append it
local longname = name
- local descriptions = opt:get("description")
- if descriptions then
+ local description = opt:description()
+ if description then
-- define menu option
- local menu_options = {nil, longname, "kv", default, descriptions}
+ local menu_options = {nil, longname, "kv", default, description}
-- handle set_description("xx", "xx")
- if type(descriptions) == "table" then
- for i, description in ipairs(descriptions) do
+ if type(description) == "table" then
+ for i, description in ipairs(description) do
menu_options[4 + i] = description
end
end