| #!/usr/bin/env bash |
| |
| # Copyright 2021 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| set -e -o pipefail |
| |
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/.. |
| readonly REPO_ROOT="${REPO_ROOT}" |
| |
| ARCH= |
| OS= |
| |
| KERNEL_NAME=$(uname -s | tr '[:upper:]' '[:lower:]') |
| case "${KERNEL_NAME}" in |
| linux) |
| OS="linux" |
| ;; |
| darwin) |
| OS="darwin" |
| ;; |
| *) |
| >&2 echo "bazelisk not supported on ${KERNEL_NAME}" |
| exit 1 |
| esac |
| |
| if [ -z "$ARCH" ]; then |
| MACHINE=$(uname -m | tr '[:upper:]' '[:lower:]') |
| case "${MACHINE}" in |
| x86_64|amd64) |
| ARCH=amd64 |
| ;; |
| aarch64) |
| ARCH=arm64 |
| ;; |
| arm*) |
| ARCH="${MACHINE}" |
| ;; |
| *86) |
| ARCH=386 |
| ;; |
| *) |
| >&2 echo "UNKNOWN Machine architecture: ${MACHINE}" |
| exit 1 |
| esac |
| fi |
| |
| |
| |
| main() { |
| local BAZELISK_BIN="${REPO_ROOT}/vendor/bazelisk/bazelisk-${OS}-${ARCH}" |
| exec "${BAZELISK_BIN}" "${@}" |
| } |
| |
| main "$@" |