From f3148ac2064f6db8fd1f83d47c727e9e157340b4 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 2 Jun 2024 19:38:22 +0800 Subject: [PATCH] some fix --- .clang-format | 4 ++++ scripts/format.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 .clang-format create mode 100644 scripts/format.py diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..4dc17e9b --- /dev/null +++ b/.clang-format @@ -0,0 +1,4 @@ +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +BasedOnStyle: Google +IndentWidth: 4 +UseTab: Never diff --git a/scripts/format.py b/scripts/format.py new file mode 100644 index 00000000..6975b440 --- /dev/null +++ b/scripts/format.py @@ -0,0 +1,21 @@ +import os +import subprocess + +def get_all_files(root: str): + for path, _, files in os.walk(root): + for file in files: + fullpath = os.path.join(path, file) + # ignore some files + if fullpath.startswith('include/pybind11'): + continue + if file.startswith('_'): + continue + if not file.endswith('.cpp') and not file.endswith('.h') and not file.endswith('.hpp'): + continue + yield fullpath + +if __name__ == '__main__': + files = list(get_all_files('src')) + files.extend(get_all_files('src2')) + files.extend(get_all_files('include')) + subprocess.run(['clang-format-15', '-i'] + files, check=True)