summaryrefslogtreecommitdiff
path: root/xmake/actions/require/impl/package.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-01-04 22:36:09 +0800
committerruki <[email protected]>2021-01-04 22:36:09 +0800
commit5c52736f8dbda0a44e85aea22d949e0d01113ef6 (patch)
treea754312afe4bab37bf0099b09b7f3e0d71b2dc2b /xmake/actions/require/impl/package.lua
parenta9bd137d0b0770fed55f4486edca3b733dd28161 (diff)
fix exclude pattern for packageconf
Diffstat (limited to 'xmake/actions/require/impl/package.lua')
-rw-r--r--xmake/actions/require/impl/package.lua43
1 files changed, 18 insertions, 25 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index ebd87bf9c..f1ed4c779 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -321,39 +321,32 @@ end
-- match require path
function _match_requirepath(requirepath, requireconf)
+ -- get pattern
+ local function _get_pattern(pattern)
+ pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1")
+ pattern = pattern:gsub("%*%*", "\001")
+ pattern = pattern:gsub("%*", "\002")
+ pattern = pattern:gsub("\001", ".*")
+ pattern = pattern:gsub("\002", "[^.]*")
+ pattern = string.ipattern(pattern, true)
+ return pattern
+ end
+
-- get the excludes
local excludes = requireconf:match("|.*$")
if excludes then excludes = excludes:split("|", {plain = true}) end
- -- translate excludes
- if excludes then
- local _excludes = {}
- for _, exclude in ipairs(excludes) do
- exclude = exclude:gsub("([%+%.%-%^%$%(%)%%])", "%%%1")
- exclude = exclude:gsub("%*%*", "\001")
- exclude = exclude:gsub("%*", "\002")
- exclude = exclude:gsub("\001", ".*")
- exclude = exclude:gsub("\002", "[^.]*")
- exclude = string.ipattern(exclude, true)
- table.insert(_excludes, exclude)
- end
- excludes = _excludes
- end
-
-- do match
local pattern = requireconf:gsub("|.*$", "")
- pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1")
- pattern = pattern:gsub("%*%*", "\001")
- pattern = pattern:gsub("%*", "\002")
- pattern = pattern:gsub("\001", ".*")
- pattern = pattern:gsub("\002", "[^.]*")
- pattern = string.ipattern(pattern, true)
+ pattern = _get_pattern(pattern)
if (requirepath:match('^' .. pattern .. '$')) then
- local splitinfo = requireconf:split("*", {plain = true, limit = 2})
- if #splitinfo == 2 then
+ -- exclude sub-deps, e.g. "libwebp.**|cmake|autoconf"
+ local splitinfo = requirepath:split(".", {plain = true})
+ if #splitinfo > 0 then
+ local name = splitinfo[#splitinfo]
for _, exclude in ipairs(excludes) do
- pattern = splitinfo[1] .. exclude
- if (requirepath:match('^' .. pattern .. '$')) then
+ pattern = _get_pattern(exclude)
+ if (name:match('^' .. pattern .. '$')) then
return false
end
end