From 31c937124bd28ba753724011d0abaab309960a85 Mon Sep 17 00:00:00 2001 From: lepelog <25211966+lepelog@users.noreply.github.com> Date: Tue, 4 Jan 2022 18:03:48 +0100 Subject: [PATCH] remove clang-format (#172) --- .github/workflows/clang-format-check.yml | 15 ---- tools/clang-format-all.sh | 14 ---- tools/clang-format-check.sh | 11 --- tools/tp.py | 95 ------------------------ 4 files changed, 135 deletions(-) delete mode 100644 .github/workflows/clang-format-check.yml delete mode 100755 tools/clang-format-all.sh delete mode 100755 tools/clang-format-check.sh diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml deleted file mode 100644 index 5cc17399d83..00000000000 --- a/.github/workflows/clang-format-check.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Clang Format Check - -on: pull_request - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Install clang-format - run: sudo apt-get install clang-format-10 - - name: Run clang-format-check - run: sh tools/clang-format-check.sh - \ No newline at end of file diff --git a/tools/clang-format-all.sh b/tools/clang-format-all.sh deleted file mode 100755 index 000a3b605af..00000000000 --- a/tools/clang-format-all.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -if [[ -z "${CLANG_FORMAT_EXE}" ]]; then - CF="clang-format-10" -else - CF="${CLANG_FORMAT_EXE}" -fi - -echo "formatting src/*" -find ./src -iname "*.h" -o -iname "*.cpp" | xargs $CF -i -echo "formatting libs/*" -find ./libs -iname "*.h" -o -iname "*.cpp" | xargs $CF -i -echo "formatting include/*" -find ./include -iname "*.h" -o -iname "*.cpp" | xargs $CF -i -echo "done" diff --git a/tools/clang-format-check.sh b/tools/clang-format-check.sh deleted file mode 100755 index e6279d268d3..00000000000 --- a/tools/clang-format-check.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -clangFormatTargets=$(find . -type f -regex '.*\.\(cpp\|hpp\|h\|cc\|cxx\)') - -for inputFile in $clangFormatTargets -do - clang-format-10 --dry-run --Werror -style=file $inputFile - if [ $? != 0 ] ; then - exit 1 - fi -done diff --git a/tools/tp.py b/tools/tp.py index bc94d11ea2d..ff70a71a413 100644 --- a/tools/tp.py +++ b/tools/tp.py @@ -741,51 +741,6 @@ def remove_unused_asm(check): return len(unused_files) -# -# Format -# -@tp.command(name="format") -@click.option("--debug/--no-debug") -@click.option( - "--thread-count", - "-j", - "thread_count", - help="This option is passed forward to all 'make' commands.", - default=4, -) -@click.option( - "--game-path", - type=PathPath(file_okay=False, dir_okay=True), - default=DEFAULT_GAME_PATH, - required=True, -) -@click.option( - "--build-path", - type=PathPath(file_okay=False, dir_okay=True), - default=DEFAULT_BUILD_PATH, - required=True, -) -def format(debug, thread_count, game_path, build_path): - """Format all .cpp/.h files using clang-format""" - - if debug: - LOG.setLevel(logging.DEBUG) - - text = Text("--- Clang-Format") - text.stylize("bold magenta") - CONSOLE.print(text) - - if clang_format(thread_count): - text = Text(" OK") - text.stylize("bold green") - CONSOLE.print(text) - else: - text = Text(" ERR") - text.stylize("bold red") - CONSOLE.print(text) - sys.exit(1) - - # # Pull-Request # @@ -833,21 +788,6 @@ def pull_request(debug, rels, thread_count, game_path, build_path): remove_unused_asm(False) - # - text = Text("--- Clang-Format") - text.stylize("bold magenta") - CONSOLE.print(text) - - if clang_format(thread_count): - text = Text(" OK") - text.stylize("bold green") - CONSOLE.print(text) - else: - text = Text(" ERR") - text.stylize("bold red") - CONSOLE.print(text) - sys.exit(1) - # text = Text("--- Full Rebuild") text.stylize("bold magenta") @@ -1045,41 +985,6 @@ def find_used_asm_files(non_matching, use_progress_bar=True): return includes -def clang_format_impl(file): - cmd = ["clang-format-10", "-i", str(file)] - cf = subprocess.run(args=cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - - -def clang_format(thread_count): - - cpp_files = find_all_cpp_files() - h_files = find_all_header_files() - files = cpp_files | h_files - - with mp.Pool(processes=2 * thread_count) as pool: - result = pool.map_async(clang_format_impl, files) - jobs_left = len(files) - with Progress( - console=CONSOLE, transient=True, refresh_per_second=5 - ) as progress: - task = progress.add_task(f"clang-formating...", total=len(files)) - - while result._number_left > 0: - left = result._number_left * result._chunksize - change = jobs_left - left - jobs_left = left - progress.update( - task, - description=f"clang-formating... ({left} left)", - advance=change, - ) - time.sleep(1 / 5) - - progress.update(task, advance=jobs_left) - - return True - - def rebuild(thread_count, include_rels): LOG.debug("make clean") with Progress(console=CONSOLE, transient=True, refresh_per_second=5) as progress: