Skip to content

Commit

Permalink
Remove bundled clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlocke committed Jul 25, 2023
1 parent 097c0a5 commit 7f7a251
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Binary file removed Format/clang-format
Binary file not shown.
33 changes: 30 additions & 3 deletions Format/format_files.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
#!/bin/bash

# e.g. `format_files.sh <srcs_path>`
#

srcs_path=$1
set -euo pipefail

exit_with_message() {
local message=$1
local retcode="${2:-0}"

echo 1>&2 "$message"
exit "$retcode"
}

exit_with_clang_format_install_message() {
exit_with_message "Skipping code formatting. Please install clang-format version 16 or greater: 'brew install clang-format'"
}

if ! [ -x "$(command -v clang-format)" ]; then
exit_with_clang_format_install_message
fi

if ! [ "$(uname -s)" == "Darwin" ]; then
exit 0
fi

if [[ "$OSTYPE" == "darwin"* ]]; then
find "$srcs_path" -type f -name "*[.h|.m]" | xargs ./clang-format -i -style=file
clang_format_version="$(clang-format --version | cut -f3 -w | tail)"
clang_format_version_major=$(awk -F. '{print $1}' <<<"$clang_format_version")

if [ "$clang_format_version_major" -lt 16 ]; then
exit_with_clang_format_install_message
fi

srcs_path=$1
find "$srcs_path" -type f -name "*[.h|.m]" -exec clang-format -i -style=file "{}" \;

0 comments on commit 7f7a251

Please sign in to comment.