remove clang-format (#172)

This commit is contained in:
lepelog 2022-01-04 18:03:48 +01:00 committed by GitHub
parent 15808a2011
commit 31c937124b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 135 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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: