From 3bf168a2d202e69989302ad1699c6e0d60af5f3f Mon Sep 17 00:00:00 2001 From: A2va <49582555+A2va@users.noreply.github.com> Date: Thu, 22 Feb 2024 21:59:06 +0100 Subject: [PATCH 1/4] Add all option to format --- xmake/plugins/format/main.lua | 10 ---------- xmake/plugins/format/xmake.lua | 1 + 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index 57c63dda76e..66bcebcb382 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -96,19 +96,9 @@ function _get_targets(targetname, group_pattern) if targetname then table.insert(targets_root, 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 diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua index 7979bb21132..2acdf717667 100644 --- a/xmake/plugins/format/xmake.lua +++ b/xmake/plugins/format/xmake.lua @@ -28,6 +28,7 @@ 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"}, + {'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", From f137fce1fd26460ee993218bd676e9095f239ebe Mon Sep 17 00:00:00 2001 From: A2va <49582555+A2va@users.noreply.github.com> Date: Thu, 22 Feb 2024 22:02:18 +0100 Subject: [PATCH 2/4] format --- xmake/plugins/format/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua index 2acdf717667..62cb99950a9 100644 --- a/xmake/plugins/format/xmake.lua +++ b/xmake/plugins/format/xmake.lua @@ -28,7 +28,7 @@ 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"}, - {'a', "all", "k", nil , "Format all targets."}, + {'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", From 2ea998a51ab8327571da3c113d333d5fc0276e13 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 23 Feb 2024 08:59:28 +0800 Subject: [PATCH 3/4] Update xmake.lua --- xmake/plugins/format/xmake.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua index 62cb99950a9..4d1b2a6f8fa 100644 --- a/xmake/plugins/format/xmake.lua +++ b/xmake/plugins/format/xmake.lua @@ -28,8 +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"}, - {'a', "all", "k", nil, "Format all targets."}, - {'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_*", From a089eec876484f7cbdc14612ddc4aecf0714ac4d Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 23 Feb 2024 09:00:15 +0800 Subject: [PATCH 4/4] Update main.lua --- xmake/plugins/format/main.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index 66bcebcb382..52c64d3b0ec 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -92,18 +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 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 - table.insert(targets_root, target) + table.insert(targets, target) end end end - return targets_root + return targets end -- main