diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18d66cd2e4cc24b324c3bda2f472da0d6fd0c0c4..1c3d0d46b105e117da33112a777b32cabc402858 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,8 +24,8 @@ format: <<: *global_tag_def stage: build script: - - clang-format --version # we use clang-format-10 exclusively - - ./scripts/format_code.py + - clang-format --version + - ./ext/amfe/scripts/format_code.py - mkdir -p patches - if git diff --patch --exit-code > patches/clang-format.patch; then echo "Clang format changed nothing"; else echo "Clang format found changes to make!"; false; fi artifacts: diff --git a/scripts/format_code.py b/scripts/format_code.py deleted file mode 100755 index 120dd5f0c07e64fdc49a6f03c99a4399eb574080..0000000000000000000000000000000000000000 --- a/scripts/format_code.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# This script runs "clang-format" recursively on all C/C++ files - -import sys -import os -import fnmatch -import re -import subprocess - - -def all_files(root, - patterns='*', - skips='*.git*;*build*', - 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(): - - # loop over all files and format them - encs = {} - for f in all_files(os.getcwd(), patterns='*.cpp;*.c;*.h;*.hpp'): - # print(f) - cmd = ['clang-format-10', "-style=file", "-i", f] - retcode = subprocess.call(cmd) - if retcode != 0: - print(f'ERROR: retcode = {retcode}') - break - - -if __name__ == "__main__": - # print('running format_code.py...') - main()