1#!/bin/sh
2
3# Copyright 2016 The Fuchsia Authors
4#
5# Use of this source code is governed by a MIT-style
6# license that can be found in the LICENSE file or at
7# https://opensource.org/licenses/MIT
8
9HASH=
10
11# hashes saved from
12#
13# https://chromium.googlesource.com/chromium/buildtools/+/master/linux64/clang-format.sha1
14# https://chromium.googlesource.com/chromium/buildtools/+/master/mac/clang-format.sha1
15
16case `uname` in
17Linux)
18    HASH=8b68e8093516183b8f38626740eeaff97f112f7e
19    ;;
20Darwin)
21    HASH=afe0942b94fe33619361efe1510ae081c3070dc1
22    ;;
23*)
24    echo "OS not understood"
25    exit 1
26esac
27
28if [ -f clang-format ]; then
29    echo "clang-format already exists in local directory"
30    exit 1
31fi
32
33# fetch clang-format into the local directory
34curl https://storage.googleapis.com/chromium-clang-format/$HASH > clang-format.fetch &&
35chmod +x clang-format.fetch &&
36mv clang-format.fetch clang-format
37