diff options
| author | ruki <[email protected]> | 2024-04-17 22:51:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-04-17 22:51:45 +0800 |
| commit | 08250fcd9265cc7fe10f890199c5847a79491bef (patch) | |
| tree | 58ec5103f0c6f0f1d567af621193f029a901341e | |
| parent | 2190b08db954738da36feeb820e8771383caa5e0 (diff) | |
improve select_script test
| -rw-r--r-- | tests/modules/private/select_script/test.lua | 8 | ||||
| -rw-r--r-- | xmake/core/base/private/select_script.lua | 9 |
2 files changed, 10 insertions, 7 deletions
diff --git a/tests/modules/private/select_script/test.lua b/tests/modules/private/select_script/test.lua index 50ff3acee..3e9128f01 100644 --- a/tests/modules/private/select_script/test.lua +++ b/tests/modules/private/select_script/test.lua @@ -39,7 +39,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(_match_patterns("!macosx|x86_64,!iphoneos|arm64", {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"})) @@ -55,7 +54,6 @@ end function test_subhost_only(t) t:require(_match_patterns("@*", {subhost = "macosx"})) t:require(_match_patterns("@macosx", {subhost = "macosx"})) - t:require(_match_patterns("@macosx,@linux", {subhost = "macosx"})) t:require(_match_patterns("@mac*", {subhost = "macosx"})) t:require_not(_match_patterns("@macosx", {subhost = "linux"})) t:require_not(_match_patterns("@linux", {subhost = "macosx"})) @@ -68,7 +66,6 @@ end function test_subhost_subarch(t) t:require(_match_patterns("@*|x86_64", {subhost = "macosx", subarch = "x86_64"})) t:require(_match_patterns("@macosx|x86_64", {subhost = "macosx", subarch = "x86_64"})) - t:require(_match_patterns("@macosx|x86_64,@linux|x86_64", {subhost = "macosx", subarch = "x86_64"})) t:require(_match_patterns("@macosx|x86_*", {subhost = "macosx", subarch = "x86_64"})) t:require_not(_match_patterns("@macosx|x86_64", {subhost = "linux", subarch = "x86_64"})) t:require_not(_match_patterns("@macosx|i386", {subhost = "macosx", subarch = "x86_64"})) @@ -89,7 +86,6 @@ end function test_plat_subhost(t) t:require(_match_patterns("*@macosx", {plat = "macosx", subhost = "macosx"})) t:require(_match_patterns("android@macosx", {plat = "android", subhost = "macosx"})) - t:require_not(_match_patterns("!android@macosx,!android@linux", {plat = "android", subhost = "macosx"})) t:require(_match_patterns("android@macosx,linux", {plat = "android", subhost = "linux"})) t:require(_match_patterns("android@mac*", {plat = "android", subhost = "macosx"})) t:require(_match_patterns("android@!macosx", {plat = "android", subhost = "linux"})) @@ -126,5 +122,9 @@ function test_logical_expr(t) 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"})) + t:require(_match_patterns("!macosx|x86_64 or !iphoneos|arm64", {plat = "linux", arch = "x86_64"})) + 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"})) end diff --git a/xmake/core/base/private/select_script.lua b/xmake/core/base/private/select_script.lua index 243e41a60..35722edd9 100644 --- a/xmake/core/base/private/select_script.lua +++ b/xmake/core/base/private/select_script.lua @@ -37,9 +37,6 @@ function _match_pattern(pattern, plat, arch, opt) local is_excluded_pattern = pattern_plat:find('!', 1, true) if excluded and is_excluded_pattern then matched = not ('!' .. plat):match('^' .. pattern_plat .. '$') - if matched then - return true - end elseif not is_excluded_pattern then matched = plat:match('^' .. pattern_plat .. '$') end @@ -158,6 +155,12 @@ function _match_script_pattern(pattern, opt) end -- match the script expression pattern +-- +-- e.g. +-- !wasm|!arm* and !cross|!arm* +-- wasm|!arm* or cross +-- (!macosx and !iphoneos) or (!linux|!arm* and !cross|!arm*) +-- function _match_script(pattern, opt) local idx = 0 local funcs = {} |
