| #!/bin/bash |
| |
| # Copyright 2022 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 |
| |
| # This script is used to fetch the prebuilt that is needed by driver build. |
| |
| readonly REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/.. |
| readonly BAZELISK_TOOL="${REPO_ROOT}/bazel" |
| |
| function get_os { |
| uname -s | tr '[:upper:]' '[:lower:]' |
| } |
| |
| function get_arch { |
| local ARCH="$(uname -m)" |
| case "${ARCH}" in |
| x86_64) |
| ARCH=amd64 |
| ;; |
| aarch64) |
| ARCH=arm64 |
| ;; |
| esac |
| echo "$ARCH" |
| } |
| |
| create_bazel_symlink() { |
| local BAZELISK_BIN="${REPO_ROOT}/vendor/bazelisk/bazelisk-$(get_os)-$(get_arch)" |
| if [[ ! -x "${BAZELISK_BIN}" ]]; then |
| >&2 echo "Bazel wrapper not supported in this OS/architecture. Could not find executable: ${BAZELISK_BIN}" |
| exit 1 |
| fi |
| ln -f -s "${BAZELISK_BIN}" "${BAZELISK_TOOL}" |
| } |
| |
| main() { |
| create_bazel_symlink |
| } |
| |
| main "$@" |