summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-17 22:53:22 +0800
committerruki <[email protected]>2024-04-17 22:53:22 +0800
commit2346d257b7d3a8d9be845eeea7763113647611df (patch)
treed6d0739aaf61eedbc0dd4959927fd01d94d0b336
parent08250fcd9265cc7fe10f890199c5847a79491bef (diff)
improve exclude pattern
-rw-r--r--tests/modules/private/select_script/test.lua9
-rw-r--r--xmake/core/base/private/select_script.lua16
2 files changed, 7 insertions, 18 deletions
diff --git a/tests/modules/private/select_script/test.lua b/tests/modules/private/select_script/test.lua
index 3e9128f01..ff9b25e59 100644
--- a/tests/modules/private/select_script/test.lua
+++ b/tests/modules/private/select_script/test.lua
@@ -22,8 +22,6 @@ function test_plat_only(t)
t:require_not(_match_patterns("!mac*", {plat = "macosx"}))
t:require(_match_patterns("!macosx", {plat = "linux"}))
t:require(_match_patterns("!macosx,!android", {plat = "linux"}))
- t:require_not(_match_patterns("!macosx,!android", {plat = "android"}))
- t:require_not(_match_patterns("!macosx,!android", {plat = "macosx"}))
t:require(_match_patterns("!mac*", {plat = "linux"}))
end
@@ -39,7 +37,6 @@ function test_plat_arch(t)
t:require_not(_match_patterns("!macosx|x86_64", {plat = "macosx", arch = "x86_64"}))
t:require_not(_match_patterns("!mac*|x86_64", {plat = "macosx", arch = "x86_64"}))
t:require(_match_patterns("!macosx|x86_64", {plat = "linux", arch = "x86_64"}))
- t:require_not(_match_patterns("!macosx|x86_64,!linux|x86_64", {plat = "linux", arch = "x86_64"}))
t:require(_match_patterns("!mac*|x86_64", {plat = "linux", arch = "x86_64"}))
t:require(_match_patterns("macosx|!i386", {plat = "macosx", arch = "x86_64"}))
t:require(_match_patterns("!macosx|!i386", {plat = "linux", arch = "x86_64"}))
@@ -119,6 +116,7 @@ function test_plat_arch_subhost_subarch(t)
end
function test_logical_expr(t)
+ t:require(_match_patterns("!macosx|x86_64,!iphoneos|arm64", {plat = "linux", arch = "x86_64"}))
t:require(_match_patterns("!wasm|!arm* and !cross|!arm*", {plat = "linux", arch = "x86_64"}))
t:require_not(_match_patterns("!wasm|!arm* and !cross|!arm*", {plat = "linux", arch = "arm64"}))
t:require_not(_match_patterns("!wasm|!arm* and !cross|!arm*", {plat = "wasm", arch = "x86_64"}))
@@ -126,5 +124,10 @@ function test_logical_expr(t)
t:require_not(_match_patterns("!android@macosx or !android@linux", {plat = "android", subhost = "macosx"}))
t:require(_match_patterns("@macosx|x86_64 or @linux|x86_64", {subhost = "macosx", subarch = "x86_64"}))
t:require(_match_patterns("@macosx or @linux", {subhost = "macosx"}))
+ t:require(_match_patterns("!wasm|!arm* or (!cross|!arm* or linux)", {plat = "linux", arch = "arm64"}))
+ t:require_not(_match_patterns("!wasm|!arm* or (!cross|!arm* and !linux)", {plat = "linux", arch = "arm64"}))
+ t:require_not(_match_patterns("!macosx|x86_64 and !linux|x86_64", {plat = "linux", arch = "x86_64"}))
+ t:require_not(_match_patterns("!macosx and !android", {plat = "android"}))
+ t:require_not(_match_patterns("!macosx and !android", {plat = "macosx"}))
end
diff --git a/xmake/core/base/private/select_script.lua b/xmake/core/base/private/select_script.lua
index 35722edd9..619a5eef2 100644
--- a/xmake/core/base/private/select_script.lua
+++ b/xmake/core/base/private/select_script.lua
@@ -69,25 +69,11 @@ end
-- match patterns
function _match_patterns(patterns, plat, arch, opt)
- local patterns_excluded = {}
for _, pattern in ipairs(patterns) do
- if pattern:startswith("!") then
- table.insert(patterns_excluded, pattern)
- else
- if _match_pattern(pattern, plat, arch, opt) then
- return true
- end
- end
- end
- local matched = 0
- for _, pattern in ipairs(patterns_excluded) do
if _match_pattern(pattern, plat, arch, opt) then
- matched = matched + 1
+ return true
end
end
- if #patterns_excluded > 0 and #patterns_excluded == matched then
- return true
- end
end
-- mattch the script pattern