mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Simplify format-cpp.sh to batch files for both Docker and native
This commit is contained in:
parent
557967fa1e
commit
3b9fcaefbd
@ -88,34 +88,13 @@ done
|
|||||||
|
|
||||||
echo "Found ${#files[@]} C/C++ files to format"
|
echo "Found ${#files[@]} C/C++ files to format"
|
||||||
|
|
||||||
# Check if we're using Docker (if clang-format is a script containing 'docker')
|
# Format all files in one call - works for both Docker and native
|
||||||
if file $(which clang-format) | grep -q "shell script"; then
|
echo "Formatting ${#files[@]} files..."
|
||||||
echo "Using Docker clang-format - batching files for performance..."
|
if ! clang-format -i -style=file:".clang-format" "${files[@]}" 2>&1; then
|
||||||
# Format all files in one call when using Docker
|
|
||||||
if ! clang-format -i -style=file:".clang-format" "${files[@]}" 2>&1; then
|
|
||||||
echo "Error: clang-format failed"
|
echo "Error: clang-format failed"
|
||||||
errors=1
|
errors=1
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# Format each file individually for native clang-format (shows progress)
|
|
||||||
count=0
|
|
||||||
errors=0
|
errors=0
|
||||||
for file in "${files[@]}"; do
|
|
||||||
count=$((count + 1))
|
|
||||||
# Show progress every 10 files or for the last file
|
|
||||||
if [ $((count % 10)) -eq 0 ] || [ $count -eq ${#files[@]} ]; then
|
|
||||||
printf "\r[$count/${#files[@]}] Formatting: %-80s" "$(basename "$file")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Format the file and capture any errors
|
|
||||||
if ! clang-format -i -style=file:".clang-format" "$file" 2>&1; then
|
|
||||||
printf "\nError formatting: $file\n"
|
|
||||||
errors=$((errors + 1))
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Clear the progress line
|
|
||||||
printf "\r%-100s\r" " "
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $errors -gt 0 ]; then
|
if [ $errors -gt 0 ]; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user