updateRustDependencies.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2018 The Tor Project, Inc.
  4. # Copyright (c) 2018 isis agora lovecruft
  5. # See LICENSE for license information
  6. #
  7. # updateRustDependencies.sh
  8. # -------------------------
  9. # Update our vendored Rust dependencies, either adding/removing
  10. # dependencies and/or upgrading current dependencies to newer
  11. # versions.
  12. #
  13. # To use this script, first add your dependencies, exactly specifying
  14. # their versions, into the appropriate *crate-level* Cargo.toml in
  15. # src/rust/ (i.e. *not* /src/rust/Cargo.toml, but instead the one for
  16. # your crate).
  17. #
  18. # Next, run this script. Then, go into src/ext/rust and commit the
  19. # changes to the tor-rust-dependencies repo.
  20. set -e
  21. HERE=$(dirname "$(realpath "$0")")
  22. TOPLEVEL=$(dirname "$(dirname "$HERE")")
  23. TOML="$TOPLEVEL/src/rust/Cargo.toml"
  24. VENDORED="$TOPLEVEL/src/ext/rust/crates"
  25. CARGO=$(command -v cargo)
  26. if ! test -f "$TOML" ; then
  27. printf "Error: Couldn't find workspace Cargo.toml in expected location: %s\\n" "$TOML"
  28. fi
  29. if ! test -d "$VENDORED" ; then
  30. printf "Error: Couldn't find directory for Rust dependencies! Expected location: %s\\n" "$VENDORED"
  31. fi
  32. if test -z "$CARGO" ; then
  33. printf "Error: cargo must be installed and in your \$PATH\\n"
  34. fi
  35. if test -z "$(cargo --list | grep vendor)" ; then
  36. printf "Error: cargo-vendor not installed\\n"
  37. fi
  38. $CARGO vendor -v --locked --explicit-version --no-delete --sync "$TOML" "$VENDORED"