Skip to content
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

Fix clang-format to specific version #7350

Merged
merged 15 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,26 @@ devdoc-update:
### Protobuf ###
###############################################################################

# Get clang-format binary name
ifeq ($(UNAME_S),Linux)
# Checking debian release or not
ifneq ("$(wildcard /etc/debian_version)","")
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
CLANG_FORMAT_BIN ?= clang-format-6.0
else
CLANG_FORMAT_BIN ?= clang-format
endif
endif
ifeq ($(UNAME_OS),Darwin)
CLANG_FORMAT_BIN ?= clang-format
endif

proto-all: proto-tools proto-gen proto-lint proto-check-breaking proto-swagger-gen proto-format

proto-gen:
@./scripts/protocgen.sh

proto-format:
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
find ./ -not -path "./third_party/*" -name *.proto -exec ${CLANG_FORMAT_BIN} -i {} \;
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved

# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
proto-gen-any:
Expand Down
21 changes: 16 additions & 5 deletions contrib/devtools/proto-tools-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ case "${UNAME_S}" in
Linux)
PROTOC_ZIP="protoc-${PROTOC_VERSION}-linux-x86_64.zip"
PROTOC_GRPC_GATEWAY_BIN="protoc-gen-grpc-gateway-v${PROTOC_GRPC_GATEWAY_VERSION}-linux-x86_64"
if [ -e /etc/debian_version ]; then
CLANG_FORMAT_BIN="clang-format-6.0"
else
CLANG_FORMAT_BIN="clang-format"
fi
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
;;
Darwin)
PROTOC_ZIP="protoc-${PROTOC_VERSION}-osx-x86_64.zip"
PROTOC_GRPC_GATEWAY_BIN="protoc-gen-grpc-gateway-v${PROTOC_GRPC_GATEWAY_VERSION}-darwin-x86_64"
CLANG_FORMAT_BIN="clang-format"
;;
*)
f_abort 1 "Unknown kernel name. Exiting."
Expand Down Expand Up @@ -116,28 +122,33 @@ f_install_protoc_gen_swagger() {
}

f_install_clang_format() {
f_print_installing_with_padding clang-format
f_print_installing_with_padding ${CLANG_FORMAT_BIN}

if which clang-format &>/dev/null ; then
if which ${CLANG_FORMAT_BIN} &>/dev/null ; then
echo -e "\talready installed. Skipping."
return 0
fi

case "${UNAME_S}" in
Linux)
if [ -e /etc/debian_version ]; then
echo -e "\tRun: sudo apt-get install clang-format" >&2
echo -e "\tRun :\n wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - ; \
sudo apt-add-repository \"deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main\"; \
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
sudo apt update ; sudo apt-get install clang-format-6.0 ;" >&2
elif [ -e /etc/fedora-release ]; then
echo -e "\tRun: sudo dnf install clang" >&2
else
echo -e "\tRun (as root): subscription-manager repos --enable rhel-7-server-devtools-rpms ; yum install llvm-toolset-7" >&2
fi
;;
Darwin)
echo "\tRun: brew install clang-format" >&2
echo -e "\tRun: \n curl https://gist.githubusercontent.com/bvigueras/daf11aee6876fb9ba4c925c2c31bc04b/raw/\
526ff0eebbc0476f568c852a8cc5d4cc48281475/[email protected] -o \
\$(brew --repo)/Library/Taps/homebrew/homebrew-core/Formula/[email protected] ; \
brew install clang-format@6 ;" >&2
;;
*)
echo "\tunknown operating system. Skipping." >&2
echo -e "\tunknown operating system. Skipping." >&2
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
esac
}

Expand Down