Skip to content

Commit

Permalink
Merge pull request #4761 from A2va/all-option-format
Browse files Browse the repository at this point in the history
Add all option to format
  • Loading branch information
waruqi authored Feb 23, 2024
2 parents 67412d4 + a089eec commit ff4b2b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
16 changes: 3 additions & 13 deletions xmake/plugins/format/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,18 @@ end

-- get all the targets that match the group or targetname
function _get_targets(targetname, group_pattern)
local targets_root = {}
local targets = {}
if targetname then
table.insert(targets_root, project.target(targetname))
table.insert(targets, project.target(targetname))
else
local depset = hashset.new()
local targets = {}
for _, target in pairs(project.targets()) do
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
for _, depname in ipairs(target:get("deps")) do
depset:insert(depname)
end
table.insert(targets, target)
end
end
for _, target in pairs(targets) do
if not depset:has(target:name()) then
table.insert(targets_root, target)
end
end
end
return targets_root
return targets
end

-- main
Expand Down
3 changes: 2 additions & 1 deletion xmake/plugins/format/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ task("format")
{'s', "style", "kv", nil, "Set the path of .clang-format file, a coding style",
values = {"LLVM", "Google", "Chromium", "Mozilla", "WebKit"}},
{nil, "create", "k", nil, "Create a .clang-format file from a coding style"},
{'g', "group", "kv", nil, "Format all targets of the given group. It support path pattern matching.",
{'a', "all", "k", nil, "Format all targets."},
{'g', "group", "kv", nil, "Format all targets of the given group. It support path pattern matching.",
"e.g.",
" xmake format -g test",
" xmake format -g test_*",
Expand Down

0 comments on commit ff4b2b0

Please sign in to comment.