summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-07-23 00:42:43 +0800
committerruki <[email protected]>2021-07-23 00:42:43 +0800
commit049460cc578b7d74b99ef3cffe3fe1d3e9eb6439 (patch)
treedd9f0fcd9cd6b6463f502d096565fcc42754d8c0
parent161aae37144ebeba16c70956d30c0792de5fa328 (diff)
improve modes
-rw-r--r--xmake/core/project/project.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index d2f8f7489..114b1557d 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -1203,16 +1203,23 @@ end
-- get all modes
function project.modes()
- local modes = table.copy(table.wrap(project.get("allowedmodes")))
- for _, target in pairs(table.wrap(project.targets())) do
- for _, rule in ipairs(target:orderules()) do
- local name = rule:name()
- if name:startswith("mode.") then
- table.insert(modes, name:sub(6))
+ local modes
+ local allowed_modes = project.allowed_modes()
+ if allowed_modes then
+ modes = allowed_modes:to_array()
+ else
+ modes = {}
+ for _, target in pairs(table.wrap(project.targets())) do
+ for _, rule in ipairs(target:orderules()) do
+ local name = rule:name()
+ if name:startswith("mode.") then
+ table.insert(modes, name:sub(6))
+ end
end
end
+ modes = table.unique(modes)
end
- return table.unique(modes)
+ return modes
end
-- get default architectures from the given platform