You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2016/02/14 02:08:08 UTC

trafficserver git commit: Automate clang-format setup.

Repository: trafficserver
Updated Branches:
  refs/heads/6.1.x 3ef0fbed6 -> ec22b6f9f


Automate clang-format setup.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ec22b6f9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ec22b6f9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ec22b6f9

Branch: refs/heads/6.1.x
Commit: ec22b6f9f3c963a22ffbb3ca5bc391123604fd2e
Parents: 3ef0fbe
Author: James Peach <jp...@apache.org>
Authored: Sat Feb 13 17:07:27 2016 -0800
Committer: James Peach <jp...@apache.org>
Committed: Sat Feb 13 17:07:27 2016 -0800

----------------------------------------------------------------------
 tools/clang-format.sh | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec22b6f9/tools/clang-format.sh
----------------------------------------------------------------------
diff --git a/tools/clang-format.sh b/tools/clang-format.sh
index 7f6478d..ba5c44a 100755
--- a/tools/clang-format.sh
+++ b/tools/clang-format.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /usr/bin/env bash
 #
 #  Simple wrapper to run clang-format on a bunch of files
 #
@@ -18,9 +18,42 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
+set -e # exit on error
+
 DIR=${1:-.}
+ROOT=${ROOT:-$(git rev-parse --show-toplevel)/.git/fmt}
+URL=${URL:-https://bintray.com/artifact/download/apache/trafficserver/clang-format-20150331.tar.bz2}
+
+TAR=${TAR:-tar}
+CURL=${CURL:-curl}
+SHASUM=${SHASUM:-shasum}
+
+ARCHIVE=$ROOT/$(basename ${URL})
+
+case $(uname -s) in
+Darwin)
+  FMT=${FMT:-${ROOT}/clang-format/clang-format.osx}
+  ;;
+Linux)
+  FMT=${FMT:-${ROOT}/clang-format/clang-format.linux}
+  ;;
+*)
+  echo "Leif needs to build a clang-format for $(uname -s)"
+  exit 2
+esac
+
+mkdir -p ${ROOT}
+
+if [ ! -e ${FMT} ] ; then
+  ${CURL} -L --progress-bar -o ${ARCHIVE} ${URL}
+  ${TAR} -x -C ${ROOT} -f ${ARCHIVE}
+  cat > ${ROOT}/sha1 << EOF
+7117c5bed99da43be733427970b4239f4bd8063d  ${ARCHIVE}
+EOF
+  ${SHASUM} -a 1 -c ${ROOT}/sha1
+fi
 
 for file in $(find $DIR -iname \*.[ch] -o -iname \*.cc); do
     echo $file
-    clang-format -i $file
+    $FMT -i $file
 done