blob: 1c69326248c68e50dac85161b6cbc11d73bdb52b [file] [log] [blame] [edit]
#!/bin/bash
# Copyright 2025 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.
#### CATEGORY=Build
### Update the Bazel vendor directory to include all necessary Bazel deps.
## usage: fx update-bazel-vendor-dir
##
## Versions of vendored repositories are based on the content of
## //build/bazel/toplevel.MODULE.bazel. If any of the direct or transitive
## dependencies there are updated to newer versions, make sure to rerun this
## script to update content of the Bazel vendor directory, otherwise the build
## will fail.
##
## NOTE: It's possible for transitive dependencies to change when local
## repositories (e.g. rules_fuchsia) update their dependencies, which will
## require a rerun of this script.
##
## NOTE: When new dependencies are introduced (either added directly with a
## bazel_dep in toplevel.MODULE.bazel, or picked up by a newer version of an
## existing dependency), you can add it to the Bazel vendor directory in two
## ways:
##
## 1. Add a `--repo='@@canonical_repo_name'` below, to download this
## dependency from upstream (Bazel Central Registry, BCR). Please follow
## the OSRB process [0] if it is the first time this repository is added
## to fuchsia.git.
##
## 2. Or, manually create a stub directory with necessary Bazel targets
## stubbed out at `//third_party/canonical_repo_name`, and add
## `--stub-repo='@@canonical_repo_name'` below. Contents of stub repos
## stay untouched by this script.
##
## [0] https://fuchsia.dev/fuchsia-src/contribute/governance/policy/osrb-process
##
# shellcheck source=/dev/null
source "${FUCHSIA_DIR}/tools/devshell/lib/vars.sh" || exit $?
fx-config-read
if [[ ! -d "${FUCHSIA_BUILD_DIR}" ]]; then
fx-error "No Fuchsia build directory, please run 'fx set' or 'fx use'."
fi
# shellcheck source=/dev/null
source "${FUCHSIA_DIR}/tools/devshell/lib/bazel_utils.sh" || exit $?
fx-update-bazel-workspace
"${PREBUILT_PYTHON3}" "${FUCHSIA_DIR}"/build/bazel/scripts/update_bazel_vendor_dir.py \
--workspace="$(fx-get-bazel-workspace)" \
--bazel="$(fx-get-bazel)" \
--bazel-vendor-dir="${FUCHSIA_DIR}/third_party/bazel_vendor" \
--repo='@@bazel_features+' \
--repo='@@bazel_skylib+' \
--repo='@@platforms' \
--repo='@@re2+' \
--repo='@@rules_cc+' \
--repo='@@rules_go+' \
--repo='@@rules_java+' \
--repo='@@rules_license+' \
--repo='@@rules_pkg+' \
--repo='@@rules_proto+' \
--repo='@@rules_python+' \
--repo='@@rules_rust+' \
--repo='@@rules_rust++i+rules_rust_tinyjson' \
--repo='@@rules_shell+' \
--stub-repo='@@apple_support+' \
--stub-repo='@@bazel_tools+remote_coverage_tools_extension+remote_coverage_tools' \
--stub-repo='@@rules_kotlin+'