| #!/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 by infra to validate that the driver can be built and |
| # tests pass. |
| |
| readonly REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd)" |
| readonly BAZELISK_TOOL="${REPO_ROOT}/tools/bazel" |
| readonly OVERRIDE_SDK="${REPO_ROOT}/fuchsia_sdk.tar.gz" |
| readonly DEFAULT_TARGET="third_party/iwlwifi/platform:fuchsia_device" |
| |
| main() { |
| target="$DEFAULT_TARGET" |
| args=() |
| while [[ "$#" -gt 0 ]]; do |
| if ! [[ "$1" =~ ^-- ]]; then |
| target="$1" |
| else |
| args+=( "$1" ) |
| fi |
| shift |
| done |
| |
| if [[ -f "$OVERRIDE_SDK" && -z "$BAZEL_FUCHSIA_SDK_ARCHIVE" ]]; then |
| export BAZEL_FUCHSIA_SDK_ARCHIVE="$OVERRIDE_SDK" |
| fi |
| if [[ -n "$BAZEL_FUCHSIA_SDK_ARCHIVE" ]]; then |
| if [[ ! -f "$BAZEL_FUCHSIA_SDK_ARCHIVE" ]]; then |
| echo -e >&2 "\033[1;31mERROR:\033[0m Local SDK does not exist, please fix or unset variable BAZEL_FUCHSIA_SDK_ARCHIVE: ${BAZEL_FUCHSIA_SDK_ARCHIVE}" |
| exit 1 |
| fi |
| echo -e >&2 "\033[1;33mINFO:\033[0m Using a local SDK: ${BAZEL_FUCHSIA_SDK_ARCHIVE##$REPO_ROOT/}" |
| "$BAZELISK_TOOL" build --config=fuchsia_x64 "$target" "${args[@]}" |
| echo "Everything build and all tests passed." |
| else |
| # TODO(mangini): handle this appropriately when the DDK is published by |
| # infra in an accessible way. We need to keep this fallback state to avoid |
| # triggering CI/CQ since the build bot cannot build the driver until it has |
| # access to a valid DDK. |
| "$BAZELISK_TOOL" --version |
| echo "Not building now since the DDK is not available. Please re-run scripts/bootstrap.sh with the appropriate flag to generate the Blaze build rules." |
| fi |
| } |
| |
| main "$@" |