summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/has_flags.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-07-05 21:49:06 +0800
committerruki <[email protected]>2017-07-05 21:49:06 +0800
commit5a1c8b7a4938745c40f7ad14de4823b09e979b7c (patch)
treed7a0b17eee2efdcadbfe544c916735b779715ce5 /xmake/modules/lib/detect/has_flags.lua
parent6e0271d2e38f9b4d48ec271af225f71a0faa4f49 (diff)
add detect.features and improve has_flags
Diffstat (limited to 'xmake/modules/lib/detect/has_flags.lua')
-rw-r--r--xmake/modules/lib/detect/has_flags.lua18
1 files changed, 10 insertions, 8 deletions
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index f307fc40f..ef6d1b1d1 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -90,12 +90,12 @@ end
-- @param flags the flags
-- @param opt the argument options, .e.g {verbose = false, program = "", toolkind = "[cc|cxx|ld|ar|sh|gc|rc|dc|mm|mxx]"}
--
--- @return true or false
+-- @return the supported flags or nil
--
-- @code
--- local ok = has_flags("clang", "-g")
--- local ok = has_flags("clang", {"-g", "-O0"}, {program = "xcrun -sdk macosx clang"})
--- local ok = has_flags("clang", "-g", {toolkind = "cxx"})
+-- local flags = has_flags("clang", "-g")
+-- local flags = has_flags("clang", {"-g", "-O0"}, {program = "xcrun -sdk macosx clang"})
+-- local flags = has_flags("clang", "-g", {toolkind = "cxx"})
-- @endcode
--
function main(name, flags, opt)
@@ -104,12 +104,14 @@ function main(name, flags, opt)
opt = opt or {}
-- has all flags?
+ local results = nil
for _, flag in ipairs(flags) do
- if not _has_flag(name, flag, opt) then
- return false
+ if _has_flag(name, flag, opt) then
+ results = results or {}
+ table.insert(results, flag)
end
end
- -- ok
- return true
+ -- ok?
+ return results
end