summaryrefslogtreecommitdiff
path: root/xmake/plugins/format
diff options
context:
space:
mode:
authorruki <[email protected]>2024-02-23 09:00:24 +0800
committerGitHub <[email protected]>2024-02-23 09:00:24 +0800
commitff4b2b09ea46e80c110ac327c4909032669d809e (patch)
treeb6dd77489b09f8286cbbe184fcea94061fb4836c /xmake/plugins/format
parent67412d490d1e88a17b4e873de75ae19c284cb7bc (diff)
parenta089eec876484f7cbdc14612ddc4aecf0714ac4d (diff)
Merge pull request #4761 from A2va/all-option-format
Add all option to format
Diffstat (limited to 'xmake/plugins/format')
-rw-r--r--xmake/plugins/format/main.lua16
-rw-r--r--xmake/plugins/format/xmake.lua3
2 files changed, 5 insertions, 14 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua
index 57c63dda7..52c64d3b0 100644
--- a/xmake/plugins/format/main.lua
+++ b/xmake/plugins/format/main.lua
@@ -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
diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua
index 7979bb211..4d1b2a6f8 100644
--- a/xmake/plugins/format/xmake.lua
+++ b/xmake/plugins/format/xmake.lua
@@ -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_*",