diff options
Diffstat (limited to 'crate_universe/tools/vendor.sh')
-rwxr-xr-x | crate_universe/tools/vendor.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crate_universe/tools/vendor.sh b/crate_universe/tools/vendor.sh new file mode 100755 index 00000000..8fe934f8 --- /dev/null +++ b/crate_universe/tools/vendor.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# A script to re-vendor all vendors crates in this repository. +# This should be ran whenever any crate rendering changes. + +vendor_workspace() { + workspace="$1" + echo "Vendoring all targets in workspace $workspace" + pushd $workspace >/dev/null + targets="$(bazel query 'kind("crates_vendor", //...)' 2>/dev/null)" + for target in $targets + do + bazel run $target + done + popd >/dev/null +} + +if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then + cd "${BUILD_WORKSPACE_DIRECTORY:-}" +fi + +workspaces="$(find . -type f -name WORKSPACE.bazel -o -name MODULE.bazel)" + +for workspace in $workspaces +do + vendor_workspace "$(dirname "$workspace")" +done |