summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-02-16 00:45:21 +0800
committerruki <[email protected]>2024-02-16 00:45:21 +0800
commit963f544355305376c66e8fc9a98af19396c2a4a5 (patch)
tree1cf7ac63b22b3c2abf778f78001afc6b799b362b
parentc3031d579ae4f7603d44ef9669a6bb00a2c90c52 (diff)
support native for selecting script #4657
-rw-r--r--tests/apis/xxx_script/xmake.lua4
-rw-r--r--xmake/core/base/private/select_script.lua11
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/apis/xxx_script/xmake.lua b/tests/apis/xxx_script/xmake.lua
index 9bfb456b0..d0052368c 100644
--- a/tests/apis/xxx_script/xmake.lua
+++ b/tests/apis/xxx_script/xmake.lua
@@ -8,6 +8,10 @@ target("test")
print("before_build")
end)
+ on_build("macosx|native", function (target)
+ print("build macosx:native")
+ end)
+
on_build(function (target)
print("build")
end)
diff --git a/xmake/core/base/private/select_script.lua b/xmake/core/base/private/select_script.lua
index cac17251f..b1039d061 100644
--- a/xmake/core/base/private/select_script.lua
+++ b/xmake/core/base/private/select_script.lua
@@ -24,6 +24,17 @@ local utils = require("base/utils")
-- match pattern, matched mode: plat|arch, excluded mode: !plat|arch
function _match_pattern(pattern, plat, arch, excluded)
+ -- support native arch, e.g. macosx|native
+ -- @see https://github.com/xmake-io/xmake/issues/4657
+ if pattern:find("native", 1, true) then
+ local splitinfo = pattern:split("|")
+ local pattern_plat = splitinfo[1]
+ local pattern_arch = splitinfo[2]
+ if pattern_arch and pattern_plat:trim("!") == os.subhost() then
+ pattern_arch = pattern_arch:gsub("native", os.subarch())
+ pattern = pattern_plat .. "|" .. pattern_arch
+ end
+ end
local is_excluded_pattern = pattern:find('!', 1, true)
if excluded and is_excluded_pattern then
return not ('!' .. plat .. '|' .. arch):match('^' .. pattern .. '$') and