Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve to install with group #4882 #4885

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions xmake/actions/install/install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,21 @@ end

-- install targets
function main(targetname, group_pattern)

-- install the given target?
local targets = {}
if targetname and not targetname:startswith("__") then
local target = project.target(targetname)
_install_targets(target:orderdeps())
_install_target(target)
table.join2(targets, target:orderdeps())
table.insert(targets, target)
else
-- install default or all targets
for _, target in ipairs(project.ordertargets()) do
local group = target:get("group")
if (target:is_default() and not group_pattern) or targetname == "__all" or (group_pattern and group and group:match(group_pattern)) then
_install_target(target)
table.join2(targets, target:orderdeps())
table.insert(targets, target)
end
end
end
if #targets > 0 then
_install_targets(table.unique(targets))
end
end
19 changes: 13 additions & 6 deletions xmake/actions/uninstall/uninstall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,21 @@ end

-- uninstall
function main(targetname)

-- uninstall the given target?
local targets = {}
if targetname and not targetname:startswith("__") then
local target = project.target(targetname)
_uninstall_targets(target:orderdeps())
_uninstall_target(target)
table.join2(targets, target:orderdeps())
table.insert(targets, target)
else
-- uninstall all targets
_uninstall_targets(project.ordertargets())
for _, target in ipairs(project.ordertargets()) do
local group = target:get("group")
if (target:is_default() and not group_pattern) or targetname == "__all" or (group_pattern and group and group:match(group_pattern)) then
table.join2(targets, target:orderdeps())
table.insert(targets, target)
end
end
end
if #targets > 0 then
_uninstall_targets(table.unique(targets))
end
end
5 changes: 5 additions & 0 deletions xmake/actions/uninstall/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ task("uninstall")
" $ xmake uninstall -o /usr/local",
"or $ DESTDIR=/usr/local xmake uninstall",
"or $ INSTALLDIR=/usr/local xmake uninstall" }
, {'g', "group", "kv", nil , "Uninstall all targets of the given group. It support path pattern matching.",
"e.g.",
" xmake uninstall -g test",
" xmake uninstall -g test_*",
" xmake uninstall --group=benchmark/*" }
, {'p', "prefix", "kv", nil , "Set the prefix directory.",
"e.g.",
" $ xmake uninstall --prefix=local",
Expand Down
Loading