diff options
| author | ruki <[email protected]> | 2021-04-07 00:57:07 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-04-07 00:57:07 +0800 |
| commit | a564206622f4276f000f390d021f64038a4a96c3 (patch) | |
| tree | 80d0075f19cb98901bd2045ba0cb9fdec7542d51 | |
| parent | 8b41be4b0f8fa86168a9f6d9d74abdf8f0fa3660 (diff) | |
add has feature for cpu
| -rw-r--r-- | xmake/core/base/cpu.lua | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/xmake/core/base/cpu.lua b/xmake/core/base/cpu.lua index 224b43ba3..a09aea4c9 100644 --- a/xmake/core/base/cpu.lua +++ b/xmake/core/base/cpu.lua @@ -22,9 +22,10 @@ local cpu = cpu or {} -- load modules -local os = require("base/os") -local winos = require("base/winos") -local io = require("base/io") +local os = require("base/os") +local winos = require("base/winos") +local io = require("base/io") +local hashset = require("base/hashset") -- get cpu micro architecture for Intel -- @@ -285,6 +286,19 @@ function cpu.features() return cpu._info().cpu_features end +-- has the given feature? +function cpu.has_feature(name) + local features = cpu._FEATURES + if not features then + features = cpu.features() + if features then + features = hashset.from(features:split('%s')) + end + cpu._FEATURES = features + end + return features:has(name) +end + -- get cpu micro architecture function cpu.march() local march = cpu._MARCH |
