diff options
Diffstat (limited to 'xmake/actions/install/main.lua')
| -rw-r--r-- | xmake/actions/install/main.lua | 21 |
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 |
