aboutsummaryrefslogtreecommitdiff
path: root/crate_universe/tools/vendor.sh
blob: 8fe934f8a16610ac9aeb2b1347702e1a0d39d367 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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