diff options
| author | A2va <[email protected]> | 2022-12-02 18:22:30 +0100 |
|---|---|---|
| committer | A2va <[email protected]> | 2022-12-02 18:22:30 +0100 |
| commit | 8096de60f4aac3fa3fa69de9e399f3a148203b4a (patch) | |
| tree | e25f58c88b67dfd600252e968f5a7a7406d710b9 | |
| parent | df25bc8dfac8cbf690f6dff8dd263421a7ca795a (diff) | |
Improve file argument
| -rw-r--r-- | xmake/plugins/format/main.lua | 21 | ||||
| -rw-r--r-- | xmake/plugins/format/xmake.lua | 2 |
2 files changed, 21 insertions, 2 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index 17ce73066..add8a7663 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -73,7 +73,26 @@ function main() -- set file to format if option.get("file") then - table.insert(argv, option.get("file")) + -- list of files/path to format + local files = option.get("file"):split(" ") + for _, f in ipairs(files) do + local p = path.join(project, f) + for _, filepath in ipairs(os.files(p)) do + table.insert(argv, filepath) + end + end + else + -- format all source files of all targets + for targetname, target in pairs(project.targets()) do + -- source files + for _, source in ipairs(target:sourcefiles()) do + table.insert(argv, path.join(projectdir,source)) + end + -- header files + for _, header in ipairs(target:sourcefiles()) do + table.insert(argv, path.join(projectdir,header)) + end + end end -- format files diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua index 16710524a..1958efb97 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".. "(LLVM, Google, Chromium, Mozilla, WebKit) or key value string" }, {nil, "create", "k", nil, "Create a .clang-format file from a coding style" }, - {'f', "file", "v", "*.cpp *.h *.hpp", "Set file path or glob pattern"} + {'f', "file", "v", "*.cpp *.h *.hpp", "Set file path or glob pattern (*.cpp)"} } } |
