]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/tools/format.sh
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / format.sh
CommitLineData
1e59de90
TL
1#!/bin/bash
2if [[ ! -e tools/format.sh ]]; then
3 echo "This tool must be run from the topmost directory." >&2
4 exit 1
5fi
6
7set -e
8
9FIND="find . -name third_party -prune -o -name tools -prune -o -name .git -prune -o -name _deps -prune -o -name .build -prune -o -name out -prune -o -name .vs -prune -o -name opentelemetry_logo.png -prune -o -name TraceLoggingDynamic.h -prune -o -name thrift-gen -prune -o"
10
11# GNU syntax.
12SED=(sed -i)
13if [[ "$(uname)" = "Darwin" ]]; then
14 SED=(sed -i "")
15fi
16
17# Correct common miscapitalizations.
18"${SED[@]}" 's/Open[t]elemetry/OpenTelemetry/g' $($FIND -type f -print)
19# No CRLF line endings, except Windows files.
20"${SED[@]}" 's/\r$//' $($FIND -name '*.ps1' -prune -o \
21 -name '*.cmd' -prune -o -type f -print)
22# No trailing spaces.
23"${SED[@]}" 's/ \+$//' $($FIND -type f -print)
24
25# If not overridden, try to use clang-format-8 or clang-format.
26if [[ -z "$CLANG_FORMAT" ]]; then
27 CLANG_FORMAT=clang-format
28 if which clang-format-10 >/dev/null; then
29 CLANG_FORMAT=clang-format-10
30 fi
31fi
32
33$CLANG_FORMAT -version
34$CLANG_FORMAT -i -style=file \
35 $($FIND -name '*.cc' -print -o -name '*.h' -print)
36
37if which cmake-format >/dev/null; then
38 echo "Running cmake-format $(cmake-format --version 2>&1)."
39 cmake-format -i $($FIND -name 'CMakeLists.txt' -print -name '*.cmake' -print -name '*.cmake.in' -print)
40else
41 echo "Can't find cmake-format. It can be installed with:"
42 echo " pip install --user cmake_format"
43 exit 1
44fi
45
46if [[ -z "$BUILDIFIER" ]]; then
47 BUILDIFIER="$HOME/go/bin/buildifier"
48 if ! which "$BUILDIFIER" >/dev/null; then
49 BUILDIFIER=buildifier
50 fi
51fi
52if which "$BUILDIFIER" >/dev/null; then
53 echo "Running $BUILDIFIER"
54 "$BUILDIFIER" $($FIND -name WORKSPACE -print -o -name BUILD -print -o \
55 -name '*.BUILD' -o -name '*.bzl' -print)
56else
57 echo "Can't find buildifier. It can be installed with:"
58 echo " go get github.com/bazelbuild/buildtools/buildifier"
59 exit 1
60fi