From 4914b1972c7a31382f4922405ea8040f0414cb36 Mon Sep 17 00:00:00 2001 From: Paul Dechamps <paul.dechamps@uliege.be> Date: Tue, 7 Jan 2025 17:19:51 +0100 Subject: [PATCH] (format) Changed format to clang 14 --- .clang-format | 29 +++++++++++++++++++++++++++ format/format.py | 51 ------------------------------------------------ 2 files changed, 29 insertions(+), 51 deletions(-) create mode 100644 .clang-format delete mode 100755 format/format.py diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..754996e --- /dev/null +++ b/.clang-format @@ -0,0 +1,29 @@ +--- +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html# +# the "Visual Studio" style is similar to: +BasedOnStyle: LLVM +UseTab: Never +IndentWidth: 4 +BreakBeforeBraces: Custom +BraceWrapping: + AfterNamespace: true + AfterClass: true + AfterStruct: true + AfterFunction: true + BeforeLambdaBody: false + AfterControlStatement: Always + BeforeElse: true + AfterCaseLabel: true + BeforeWhile: false + BeforeCatch: true + AfterEnum: true + AfterUnion: true + AfterExternBlock: true + SplitEmptyNamespace: false + SplitEmptyFunction: false + SplitEmptyRecord: false + IndentBraces: false +AccessModifierOffset: -4 +SortIncludes: false +ColumnLimit: 0 +... diff --git a/format/format.py b/format/format.py deleted file mode 100755 index f3568f2..0000000 --- a/format/format.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# This script runs "clang-format" recursively on all C/C++ files -# @authors A. Crovato, R. Boman -# Modified by P. Dechamps - -import os -import fnmatch -import subprocess - -def all_files(root, - patterns='*', - skips='*.git*;*build*;modules*', - single_level=False, - yield_folders=False): - # self.checkPath(root) - patterns = patterns.split(';') - skips = skips.split(';') - for path, subdirs, files in os.walk(root): - if yield_folders: - files.extend(subdirs) - files.sort() - for name in files: - for pattern in patterns: - if fnmatch.fnmatch(name, pattern): - fullname = os.path.join(path, name) - ok = True - for skip in skips: - if fnmatch.fnmatch(os.path.relpath(fullname, start=root), skip): - ok = False - if ok: - yield fullname - break - if single_level: - break - -def main(): - encs = {} - for f in all_files(os.getcwd(), patterns='*.cpp;*.c;*.h;*.hpp'): - print('Checking file', 'blaster'+f.split('blaster', 1)[-1], end='...') - cmd = ['clang-format-11', "-style=file", "-i", f] - retcode = subprocess.call(cmd) - if retcode != 0: - print(f'ERROR: retcode = {retcode}') - break - print('done.') - - -if __name__ == "__main__": - main() -- GitLab