summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/opentelemetry-cpp/tools/format.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/jaegertracing/opentelemetry-cpp/tools/format.sh
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/opentelemetry-cpp/tools/format.sh')
-rwxr-xr-xsrc/jaegertracing/opentelemetry-cpp/tools/format.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/jaegertracing/opentelemetry-cpp/tools/format.sh b/src/jaegertracing/opentelemetry-cpp/tools/format.sh
new file mode 100755
index 000000000..6f5ae40d5
--- /dev/null
+++ b/src/jaegertracing/opentelemetry-cpp/tools/format.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+if [[ ! -e tools/format.sh ]]; then
+ echo "This tool must be run from the topmost directory." >&2
+ exit 1
+fi
+
+set -e
+
+FIND="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"
+
+# GNU syntax.
+SED=(sed -i)
+if [[ "$(uname)" = "Darwin" ]]; then
+ SED=(sed -i "")
+fi
+
+# Correct common miscapitalizations.
+"${SED[@]}" 's/Open[t]elemetry/OpenTelemetry/g' $($FIND -type f -print)
+# No CRLF line endings, except Windows files.
+"${SED[@]}" 's/\r$//' $($FIND -name '*.ps1' -prune -o \
+ -name '*.cmd' -prune -o -type f -print)
+# No trailing spaces.
+"${SED[@]}" 's/ \+$//' $($FIND -type f -print)
+
+# If not overridden, try to use clang-format-8 or clang-format.
+if [[ -z "$CLANG_FORMAT" ]]; then
+ CLANG_FORMAT=clang-format
+ if which clang-format-10 >/dev/null; then
+ CLANG_FORMAT=clang-format-10
+ fi
+fi
+
+$CLANG_FORMAT -version
+$CLANG_FORMAT -i -style=file \
+ $($FIND -name '*.cc' -print -o -name '*.h' -print)
+
+if which cmake-format >/dev/null; then
+ echo "Running cmake-format $(cmake-format --version 2>&1)."
+ cmake-format -i $($FIND -name 'CMakeLists.txt' -print -name '*.cmake' -print -name '*.cmake.in' -print)
+else
+ echo "Can't find cmake-format. It can be installed with:"
+ echo " pip install --user cmake_format"
+ exit 1
+fi
+
+if [[ -z "$BUILDIFIER" ]]; then
+ BUILDIFIER="$HOME/go/bin/buildifier"
+ if ! which "$BUILDIFIER" >/dev/null; then
+ BUILDIFIER=buildifier
+ fi
+fi
+if which "$BUILDIFIER" >/dev/null; then
+ echo "Running $BUILDIFIER"
+ "$BUILDIFIER" $($FIND -name WORKSPACE -print -o -name BUILD -print -o \
+ -name '*.BUILD' -o -name '*.bzl' -print)
+else
+ echo "Can't find buildifier. It can be installed with:"
+ echo " go get github.com/bazelbuild/buildtools/buildifier"
+ exit 1
+fi