| #!/bin/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. |
| |
| # TODO(https://fxbug.dev/90066): Delete this file once we don't need a generated |
| # c++ toolchain from //third_party/sdk-integration/bazel_rules_generator/... anymore. |
| |
| set -e |
| |
| # This script is used to fetch the prebuilt that is needed by flutter embedder build. |
| |
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/.. |
| readonly REPO_ROOT="${REPO_ROOT}" |
| |
| # The following is temporary to support the transition to the generated |
| # Bazel SDK |
| SDK_DOWNLOAD_URL= |
| |
| # Note: This tag needs to be kept in sync with the version in WORKSPACE.bazel until |
| # the transition of the rules out of this repo is complete. |
| SDK_VERSION_TAG="version:6.20211029.2.1" |
| KERNEL_NAME=$(uname -s | tr '[:upper:]' '[:lower:]') |
| case "${KERNEL_NAME}" in |
| linux) |
| SDK_DOWNLOAD_URL="https://chrome-infra-packages.appspot.com/dl/fuchsia/sdk/core/linux-amd64/+/${SDK_VERSION_TAG}" |
| ;; |
| darwin) |
| SDK_DOWNLOAD_URL="https://chrome-infra-packages.appspot.com/dl/fuchsia/sdk/core/mac-amd64/+/${SDK_VERSION_TAG}" |
| ;; |
| *) |
| >&2 echo "The fuchsia sdk not supported on ${KERNEL_NAME}" |
| exit 1 |
| esac |
| |
| TMP_DOWNLOAD_DIR="$(mktemp -d)" |
| trap 'rm -rf "${TMP_DOWNLOAD_DIR}"' EXIT |
| |
| generate_rules_fuchsia() { |
| echo "Downloading prebuilt SDK" |
| curl -sL "${SDK_DOWNLOAD_URL}" -o "${TMP_DOWNLOAD_DIR}/sdk.zip" |
| |
| echo "Unzipping SDK Archive" |
| unzip -q "${TMP_DOWNLOAD_DIR}/sdk.zip" -d "${REPO_ROOT}/sdk" |
| |
| echo "Generating rules fuchsia!" |
| |
| pushd "${REPO_ROOT}/third_party/sdk-integration/bazel_rules_generator/" > /dev/null || exit |
| ./generate.py \ |
| --directory "${REPO_ROOT}/sdk" \ |
| --output "${REPO_ROOT}/rules_fuchsia_transitional" |
| |
| popd > /dev/null || exit |
| |
| echo "Done generating rules fuchsia." |
| } |
| |
| main() { |
| generate_rules_fuchsia |
| } |
| |
| main "$@" |