From 6f9a4541c9de2bfd4a287bbbc98011c8c19c7120 Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Sat, 27 Aug 2022 22:31:01 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20clang-formater.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/ClangFormater/clang-formater.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/ClangFormater/clang-formater.py b/tools/ClangFormater/clang-formater.py index f7e1533661..a9a8deb64f 100644 --- a/tools/ClangFormater/clang-formater.py +++ b/tools/ClangFormater/clang-formater.py @@ -3,18 +3,26 @@ import os def ArgParser(): parser = ArgumentParser() - parser.add_argument("--input", help="input dir", metavar="I", dest="src", required=True) + parser.add_argument("--input", help="input dir", metavar="I", dest="src") + parser.add_argument("--clang-format", help="the path of clang-format.exe", metavar="PATH", dest="exe", default="clang-format") return parser args = ArgParser().parse_args() +clang_format_exe = args.exe input_dir = args.src +os.system(f"{clang_format_exe} --version"); + +if not input_dir: + print("No input dir, exit.") + exit() + for root, dirs, files in os.walk(input_dir): for f in files: file = os.path.join(root, f) if os.path.splitext(file)[-1] in [".c", ".h", ".cpp", ".hpp"]: print(file) - os.system(f"clang-format -i -style=file \"{file}\""); + os.system(f"{clang_format_exe} -i -style=file \"{file}\""); # example: python tools\ClangFormater\clang-formater.py --input=src\MeoAssistant