From bbd308cd4dc6618101830f974ee877551facf811 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Sun, 18 Feb 2024 09:40:44 -0800 Subject: [PATCH] Update crates_universe render script to run from Bazel --- crate_universe/DEVELOPMENT.md | 2 +- crate_universe/tools/BUILD.bazel | 5 +++++ {util => crate_universe/tools}/vendor.sh | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) rename {util => crate_universe/tools}/vendor.sh (73%) diff --git a/crate_universe/DEVELOPMENT.md b/crate_universe/DEVELOPMENT.md index 5f52ded0d6..a146daac8f 100644 --- a/crate_universe/DEVELOPMENT.md +++ b/crate_universe/DEVELOPMENT.md @@ -38,5 +38,5 @@ A lot of crates are vendored into this repo, e.g. in examples and tests. To re-vendor them all, a bash script is provided: ```sh -./util/vendor.sh +bazel run //crate_universe/tools:vendor ``` diff --git a/crate_universe/tools/BUILD.bazel b/crate_universe/tools/BUILD.bazel index 1677d9e7ea..cc897fb760 100644 --- a/crate_universe/tools/BUILD.bazel +++ b/crate_universe/tools/BUILD.bazel @@ -5,3 +5,8 @@ filegroup( ], visibility = ["//crate_universe:__subpackages__"], ) + +sh_binary( + name = "vendor", + srcs = ["vendor.sh"], +) diff --git a/util/vendor.sh b/crate_universe/tools/vendor.sh similarity index 73% rename from util/vendor.sh rename to crate_universe/tools/vendor.sh index 79abf4a5fb..9b928186a1 100755 --- a/util/vendor.sh +++ b/crate_universe/tools/vendor.sh @@ -1,5 +1,7 @@ #!/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. @@ -15,7 +17,11 @@ vendor_workspace() { popd >/dev/null } -workspaces="$(find -type f -name WORKSPACE.bazel -o -name WORKSPACE -o -name MODULE.bazel)" +if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then + cd "${BUILD_WORKSPACE_DIRECTORY:-}" +fi + +workspaces="$(find . -type f -name WORKSPACE.bazel -o -o -name MODULE.bazel)" for workspace in $workspaces do