| #!/bin/bash |
| |
| set -eufo pipefail |
| |
| usage() { |
| cat <<EOS |
| Usage: $0 [-h] |
| |
| This script copies files needed by fidlbolt from \$FUCHSIA_DIR into ./support. |
| It creates the following directories: |
| |
| ./support/bin binaries (fidlc, fidl-format, etc.) |
| ./support/etc configuration files |
| ./support/sdk/fidl sdk fidl libraries |
| ./support/zircon/system/fidl zircon fidl libraries |
| |
| It preserves the directory structure for FIDL libraries, rather than simply |
| placing them all in a ./support/fidl directory, so that paths displayed in |
| fidlbolt (e.g. import tooltips) resemble Fuchsia source tree paths. |
| EOS |
| } |
| |
| die() { |
| echo "$0: $*" >&2 |
| exit 1 |
| } |
| |
| while getopts "h" opt; do |
| case $opt in |
| h) usage; exit 0 ;; |
| *) exit 1 ;; |
| esac |
| done |
| shift $((OPTIND - 1)) |
| if [[ $# -gt 0 ]]; then |
| die "unexpected arguments: $*" |
| fi |
| |
| if [[ -z "$FUCHSIA_DIR" ]]; then |
| die "FUCHSIA_DIR not set" |
| fi |
| |
| # Source vars.sh for FUCHSIA_BUILD_DIR, ZIRCON_TOOLS_DIR, and PREBUILT_RUST_DIR. |
| # (Reset shell options before sourcing since vars.sh does not expect them.) |
| set +ufo pipefail |
| source "$FUCHSIA_DIR/tools/devshell/lib/vars.sh" || exit $? |
| fx-config-read |
| set -ufo pipefail |
| |
| cd "$(dirname "$0")" |
| rm -rf support/ |
| mkdir -p support/{bin,etc,sdk/fidl,zircon/system/fidl} |
| cp \ |
| "$FUCHSIA_BUILD_DIR/host_x64/"{fidlc,fidlgen_{llcpp,hlcpp,rust,go,dart}} \ |
| "$ZIRCON_TOOLS_DIR/fidl-"{format,lint} \ |
| "$PREBUILT_RUST_DIR/bin/rustfmt" \ |
| support/bin |
| cp \ |
| "$FUCHSIA_DIR/rustfmt.toml" \ |
| support/etc |
| find "$FUCHSIA_DIR/sdk/fidl" -mindepth 1 -maxdepth 1 -type d -print0 \ |
| | xargs -0 -I% cp -r % support/sdk/fidl |
| find "$FUCHSIA_DIR/zircon/system/fidl" -mindepth 1 -maxdepth 1 -type d -print0 \ |
| | xargs -0 -I% cp -r % support/zircon/system/fidl |
| # Remove the non-fidl files. This is easier and less error-prone than |
| # manipulating paths to call mkdir -p and only copying the .fidl files. |
| find support/{sdk,zircon} -type f -not -name '*.fidl' -delete |
| |
| hash() { |
| git rev-parse --verify HEAD |
| } |
| |
| timestamp() { |
| git show -s --format=%ct HEAD |
| } |
| |
| rustfmt_version=$( |
| "$PREBUILT_RUST_DIR/bin/rustfmt" --version \ |
| | awk 'NR==1{sub(/-.*/, "", $2); print $2}' |
| ) |
| |
| cat <<EOS > support/etc/fidlbolt_deployment.json |
| { |
| "fidlbolt": { |
| "hash": "$(hash)", |
| "timestamp": $(timestamp) |
| }, |
| "fuchsia": { |
| "hash": "$(cd "$FUCHSIA_DIR" && hash)", |
| "timestamp": $(cd "$FUCHSIA_DIR" && timestamp) |
| }, |
| "topaz": { |
| "hash": "$(cd "$FUCHSIA_DIR/topaz" && hash)", |
| "timestamp": $(cd "$FUCHSIA_DIR/topaz" && timestamp) |
| }, |
| "rustfmt": { |
| "version": "$rustfmt_version" |
| } |
| } |
| EOS |