summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/has_features.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-17 23:22:36 +0800
committerGitHub <[email protected]>2023-03-17 23:22:36 +0800
commit404a8a5feadef0c56f57895103ff6f9419cdfd41 (patch)
tree73160a76034e3325c952ea33a893a3edf9de6ae2 /xmake/modules/lib/detect/has_features.lua
parent890b52a2b7311315862841b1f5c17fd01bbb7751 (diff)
parentf7bc68f09a8d20fcae1304c9ab70d7f9b7472de5 (diff)
Merge pull request #3521 from xmake-io/hasxxx
add has_xxx for target
Diffstat (limited to 'xmake/modules/lib/detect/has_features.lua')
-rw-r--r--xmake/modules/lib/detect/has_features.lua20
1 files changed, 7 insertions, 13 deletions
diff --git a/xmake/modules/lib/detect/has_features.lua b/xmake/modules/lib/detect/has_features.lua
index 80dbc2ec7..2b879dd1e 100644
--- a/xmake/modules/lib/detect/has_features.lua
+++ b/xmake/modules/lib/detect/has_features.lua
@@ -28,7 +28,7 @@ import("lib.detect.features", {alias = "get_features"})
-- @param features the features
-- @param opt the argument options, e.g. {verbose = false, flags = {}, program = ""}}
--
--- @return the supported features or nil
+-- @return true or false
--
-- @code
-- local features = has_features("clang", "cxx_constexpr")
@@ -37,20 +37,14 @@ import("lib.detect.features", {alias = "get_features"})
-- @endcode
--
function main(name, features, opt)
-
- -- init options
opt = opt or {}
-
- -- get all features
- local all = get_features(name, opt) or {}
-
- -- get results
- local results = nil
+ local allfeatures = get_features(name, opt) or {}
+ local passed = 0
+ features = table.wrap(features)
for _, feature in ipairs(features) do
- if all[feature] then
- results = results or {}
- table.insert(results, feature)
+ if allfeatures[feature] then
+ passed = passed + 1
end
end
- return results
+ return passed == #features
end