-
Notifications
You must be signed in to change notification settings - Fork 544
CXX-3198 support clang-format-all.sh
on macOS
#1307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
To permit non-default clang-format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestions; otherwise, LGTM.
etc/clang-format-all.sh
Outdated
CLANG_FORMAT="${CLANG_FORMAT:-clang-format}" | ||
"$CLANG_FORMAT" --version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLANG_FORMAT="${CLANG_FORMAT:-clang-format}" | |
"$CLANG_FORMAT" --version | |
clang_format_binary="${CLANG_FORMAT_BINARY:-clang-format}" | |
"${clang_format_binary:?}" --version |
For consistency with DOXYGEN_BINARY
, POETRY_PYTHON_BINARY
(C Driver), etc. + recommend using separate variables for input env var (UPPER_CASE) and local variable (snake_case) + use ${clang_format_binary:?}
to ensure not-null, not-empty when used below (e.g. catch typoes, etc.).
@@ -21,11 +22,11 @@ source_dirs=( | |||
) | |||
|
|||
mapfile -t source_files < <( | |||
find "${source_dirs[@]:?}" -regextype posix-egrep -regex '.*\.(hpp|hh|cpp)' | |||
find "${source_dirs[@]:?}" | grep -E '.*\.(hpp|hh|cpp)$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I would prefer to use PCRE (-P
) for consistency, IIRC it is not fully supported across all distros/versions, so I am fine with using -E
here for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately -P
does not appear supported on macOS grep
:
% grep -P
grep: invalid option -- P
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
Follow-up to #1299. Verified with this patch build.
Use
grep
instead of-regextype
to fix observed error runningetc/clang-format-all.sh
on macOS:Also allow overriding the used
clang-format
. This is intended to ease my current set-up and can be reverted if desired. I installed LLVM 1.19 withbrew install llvm
, and it is not on a system path to avoid interfering with AppleClang.