summaryrefslogtreecommitdiff
path: root/xmake/actions/install/main.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-06-13 22:43:03 +0800
committerruki <[email protected]>2022-06-13 22:43:03 +0800
commit736d72fc583f3a7c5f8f97c6079db2847da7757e (patch)
tree8a33445497209f03a90620f9eb2d9fce9157fa16 /xmake/actions/install/main.lua
parentb871678de09d8185e6e13b05e726e56b72ad696a (diff)
support group for xmake install
Diffstat (limited to 'xmake/actions/install/main.lua')
-rw-r--r--xmake/actions/install/main.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua
index 2504f3338..7f9a0dd33 100644
--- a/xmake/actions/install/main.lua
+++ b/xmake/actions/install/main.lua
@@ -33,12 +33,13 @@ function _check_targets(targetname)
-- get targets
local targets = {}
- if targetname and not targetname:startswith("__") then
+ if targetname then
table.insert(targets, project.target(targetname))
else
-- install default or all targets
for _, target in pairs(project.targets()) do
- if target:is_default() or targetname == "__all" then
+ local group = target:get("group")
+ if (target:is_default() and not group_pattern) or option.get("all") or (group_pattern and group and group:match(group_pattern)) then
table.insert(targets, target)
end
end
@@ -68,14 +69,20 @@ function main()
config.load()
-- check targets first
- local targetname = option.get("target")
- _check_targets(targetname)
+ local targetname
+ local group_pattern = option.get("group")
+ if group_pattern then
+ group_pattern = "^" .. path.pattern(group_pattern) .. "$"
+ else
+ targetname = option.get("target")
+ end
+ _check_targets(targetname, group_pattern)
-- attempt to install directly
try
{
function ()
- install(targetname or (option.get("all") and "__all" or "__def"))
+ install(targetname or (option.get("all") and "__all" or "__def"), group_pattern)
cprint("${color.success}install ok!")
end,
@@ -89,7 +96,7 @@ function main()
local ok = try
{
function ()
- install(targetname or (option.get("all") and "__all" or "__def"))
+ install(targetname or (option.get("all") and "__all" or "__def"), group_pattern)
cprint("${color.success}install ok!")
return true
end
@@ -105,7 +112,7 @@ function main()
if sudo.has() and option.get("admin") then
-- install target with administrator permission
- sudo.execl(path.join(os.scriptdir(), "install_admin.lua"), {targetname or (option.get("all") and "__all" or "__def"), option.get("installdir"), option.get("prefix")})
+ sudo.execl(path.join(os.scriptdir(), "install_admin.lua"), {targetname or (option.get("all") and "__all" or "__def"), group_pattern, option.get("installdir"), option.get("prefix")})
cprint("${color.success}install ok!")
ok = true
end