diff options
| author | ruki <[email protected]> | 2018-04-14 00:54:38 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-04-13 23:27:52 +0800 |
| commit | 7467328ac81ac59a95125420b4dbca1bc3abc5f3 (patch) | |
| tree | 3f5bdaa14fdb149f27489be4493e7a0d35fdf8a1 /xmake/core/base/os.lua | |
| parent | 9e80cf8b5075b5eb4af1a2a0b652b486ddfe2da9 (diff) | |
add is_mode is_plat and is_arch builtin apis
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 70af9c6bb..a3b66b674 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -692,6 +692,36 @@ function os.arch() return xmake._ARCH end +-- the current host is belong to the given hosts? +function os.is_host(...) + + -- get the current host + local host = os.host() + if not host then return false end + + -- exists this host? and escape '-' + for _, h in ipairs(table.join(...)) do + if h and type(h) == "string" and host:find(h:gsub("%-", "%%-")) then + return true + end + end +end + +-- the current platform is belong to the given architectures? +function os.is_arch(...) + + -- get the host architecture + local arch = os.arch() + if not arch then return false end + + -- exists this architecture? and escape '-' + for _, a in ipairs(table.join(...)) do + if a and type(a) == "string" and arch:find("^" .. a:gsub("%-", "%%-") .. "$") then + return true + end + end +end + -- get the system null device function os.nuldev(input) |
