|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +[[ -x bin/deps ]] && source bin/deps |
| 4 | +[[ -z "${BashMatic}" ]] && { |
| 5 | + echo "Failed to initialize BASH library." |
| 6 | + exit 1 |
| 7 | +} |
| 8 | + |
| 9 | +#—————————————————————————————— OS-X SPECIFIC INSTALLERS ————————————————————————— |
| 10 | + |
| 11 | +function setup::brew-validate() { |
| 12 | + # Homebrew is required to install Bazel |
| 13 | + if ! brew help >/dev/null; then |
| 14 | + echo "brew is not installed, please install from https://brew.sh" |
| 15 | + fi |
| 16 | +} |
| 17 | + |
| 18 | +function setup::brew-install-jdk() { |
| 19 | + # The JDK homebrew cask is a required to install the java dependencies for Bazel |
| 20 | + if ! brew cask list | grep -q openjdk; then |
| 21 | + brew cask install homebrew/cask-versions/adoptopenjdk8 |
| 22 | + fi |
| 23 | +} |
| 24 | + |
| 25 | +function setup::brew-deps() { |
| 26 | + if ! brew list | grep -q xz; then |
| 27 | + brew install xz |
| 28 | + fi |
| 29 | +} |
| 30 | + |
| 31 | +function setup::osx-deps() { |
| 32 | + # xcode command line tools are required, specifically gcc |
| 33 | + # if xcode already exists, this command will error, otherwise prompt the user |
| 34 | + if [[ -n $(xcode-select --install 2>&1 | grep 'already installed') ]]; then |
| 35 | + echo "xcode-select tools are already installed." |
| 36 | + fi |
| 37 | +} |
| 38 | + |
| 39 | +function setup::bazelisk-install() { |
| 40 | + brew install bazelbuild/tap/bazelisk |
| 41 | +} |
| 42 | + |
| 43 | +function setup::darwin() { |
| 44 | + setup::brew-validate |
| 45 | + setup::brew-install-jdk |
| 46 | + setup::brew-deps |
| 47 | + setup::osx-deps |
| 48 | + setup::bazelisk-install |
| 49 | +} |
| 50 | + |
| 51 | +setup::darwin "$@" |
0 commit comments