Skip to content

Commit

Permalink
support native for selecting script #4657
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Feb 15, 2024
1 parent c3031d5 commit 963f544
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/apis/xxx_script/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions xmake/core/base/private/select_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 963f544

Please sign in to comment.