| #!/bin/bash | |
| # Copyright 2018 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. | |
| ### Updates rustc_library and rustc_binary third_party dependencies | |
| ## usage: fx update-rustc-third-party | |
| ## Updates third_party/rust-crates/rustc_deps based on the contents of | |
| ## third_party/rust-crates/rustc_deps/Cargo.toml | |
| ## | |
| ## After updating third_party/rust-crates/rustc_deps, the pinned revision of | |
| ## third_party/rust-crates will need to be updated in garnet/manifest/third_party. | |
| ## See https://fuchsia.googlesource.com/docs/+/master/development/languages/rust/third_party.md | |
| ## for more details. | |
| echo "Error: this script is currently broken pending updates." | |
| echo "Contact cramertj@ for a temporary workaround." | |
| echo "Apologies for the inconvenience." | |
| exit 1; | |
| set -e | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/lib/vars.sh | |
| case "$(uname -s)" in | |
| Linux*) OS=linux-x64;; | |
| Darwin*) OS=mac-x64;; | |
| *) echo "Error: unrecognized OS"; exit 1;; | |
| esac | |
| declare -x PATH=$FUCHSIA_DIR/buildtools/$OS/cmake/bin:$PATH | |
| if [[ "$OS" = "mac-x64" ]]; then | |
| if ! [[ -x "$(command -v brew)" ]]; then | |
| echo >&2 "'brew' binary not found" | |
| echo >&2 "A homebrew <https://brew.sh> installation of opensslis required in order to update" echo >&2 "Rust third party crates on the Mac." | |
| exit 1 | |
| fi | |
| declare -x LDFLAGS="-L$(brew --prefix)/opt/openssl/lib" | |
| declare -x CPPFLAGS="-I$(brew --prefix)/opt/openssl/include" | |
| fi | |
| export RUSTC=$FUCHSIA_DIR/buildtools/$OS/rust/bin/rustc | |
| (cd $FUCHSIA_DIR; $FUCHSIA_DIR/buildtools/$OS/rust/bin/cargo run \ | |
| --target-dir $FUCHSIA_DIR/out/cargo_vendor_target \ | |
| --manifest-path $FUCHSIA_DIR/third_party/rust-mirrors/cargo-vendor/Cargo.toml \ | |
| -- vendor --sync $FUCHSIA_DIR/third_party/rust-crates/rustc_deps/Cargo.toml \ | |
| $FUCHSIA_DIR/third_party/rust-crates/rustc_deps/vendor) | |
| python $FUCHSIA_DIR/scripts/rust/check_rust_licenses.py \ | |
| --directory $FUCHSIA_DIR/third_party/rust-crates/rustc_deps/vendor |