summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2022-10-08 00:31:10 +0800
committerruki <[email protected]>2022-10-08 00:31:10 +0800
commit0adcc75463e4b745199cf07fcdbd6d27ac39249e (patch)
tree013083e124e4fbff5234766873554d3944ecd4ed /xmake/core
parent458b805a6ebac9cae0f36ac593ececd8e1717444 (diff)
add is_plat/is_arch to tool.lua
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/tool/tool.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua
index 5d8672141..b2bb05659 100644
--- a/xmake/core/tool/tool.lua
+++ b/xmake/core/tool/tool.lua
@@ -92,6 +92,26 @@ function _instance:arch()
return self._ARCH
end
+-- the current target is belong to the given platforms?
+function _instance:is_plat(...)
+ local plat = self:plat()
+ for _, v in ipairs(table.join(...)) do
+ if v and plat == v then
+ return true
+ end
+ end
+end
+
+-- the current target is belong to the given architectures?
+function _instance:is_arch(...)
+ local arch = self:arch()
+ for _, v in ipairs(table.join(...)) do
+ if v and arch:find("^" .. v:gsub("%-", "%%-") .. "$") then
+ return true
+ end
+ end
+end
+
-- get the tool program
function _instance:program()
return self._PROGRAM