aboutsummaryrefslogtreecommitdiff
path: root/tools/install-build-tools.sh
blob: b9256761cf720989232dc40ffea5e2f460f805bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

uname="$(uname -s)"
case "${uname}" in
    Linux*)     env="linux64";;
    Darwin*)    env="mac";;
esac

echo "Assuming we are running in $env..."

ninja_version="v1.9.0"
ninja_zipfile=""
case "$env" in
  linux64)    ninja_zipfile="ninja-linux.zip";;
  mac)        ninja_zipfile="ninja-mac.zip";;
esac

BUILDTOOLS_REPO_URL="https://chromium.googlesource.com/chromium/src/buildtools"
GOOGLE_STORAGE_URL="https://storage.googleapis.com"
BUILDTOOLS_ROOT=$(git rev-parse --show-toplevel)/buildtools/$env
if [ ! -d $BUILDTOOLS_ROOT ]; then
  mkdir -p $BUILDTOOLS_ROOT
fi

pushd $BUILDTOOLS_ROOT
set -x  # echo on
sha1=$(curl "$BUILDTOOLS_REPO_URL/+/master/$env/clang-format.sha1?format=TEXT" | base64 --decode)
curl -Lo clang-format "$GOOGLE_STORAGE_URL/chromium-clang-format/$sha1"
chmod +x clang-format
curl -L "https://github.com/ninja-build/ninja/releases/download/${ninja_version}/${ninja_zipfile}" | funzip > ninja
chmod +x ninja
set +x  # echo off
popd