summaryrefslogtreecommitdiff
path: root/xmake/plugins/format
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/plugins/format')
-rw-r--r--xmake/plugins/format/main.lua7
-rw-r--r--xmake/plugins/format/xmake.lua2
2 files changed, 7 insertions, 2 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua
index 19fca6b73..733b9b59f 100644
--- a/xmake/plugins/format/main.lua
+++ b/xmake/plugins/format/main.lua
@@ -190,9 +190,14 @@ function main()
end
end
else
+ -- Default source file filter when not specifying "--files" option
+ -- **.c, **.cc, **.cxx, **.cpp
+ local source_filepatterns = _get_file_patterns("**.c" .. path.envsep() .. "**.cc" .. path.envsep() .. "**.cxx" .. path.envsep() .. "**.cpp")
for _, target in ipairs(targets) do
for _, source in ipairs(target:sourcefiles()) do
- table.insert(argv, path.join(projectdir, source))
+ if _match_sourcefiles(source, source_filepatterns) then
+ table.insert(argv, path.join(projectdir, source))
+ end
end
for _, header in ipairs(target:headerfiles()) do
table.insert(argv, path.join(projectdir, header))
diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua
index feafc3864..1b31ff9b3 100644
--- a/xmake/plugins/format/xmake.lua
+++ b/xmake/plugins/format/xmake.lua
@@ -40,7 +40,7 @@ task("format")
"e.g.",
" - xmake format --files=src/main.c",
" - xmake format --files='src/*.c' [target]",
- " - xmake format --files='src/**.c|excluded_file.c",
+ " - xmake format --files='src/**.c|excluded_file.c'",
" - xmake format --files='src/main.c" .. path.envsep() .. "src/test.c'" },
{},
{nil, "target", "v", nil, "The target name. It will format all default targets if this parameter is not specified."