| #!/bin/bash |
| |
| set -eufo pipefail |
| |
| usage() { |
| cat <<EOS |
| Usage: $0 [-h] |
| |
| This script copies files needed by fidlbolt from \$FUCHSIA_DIR into ./fuchsia. |
| It creates the following directories: |
| |
| ./fuchsia/bin binaries (fidlc, fidl-format, etc.) |
| ./fuchsia/etc configuration files |
| ./fuchsia/sdk/fidl sdk fidl libraries |
| ./fuchsia/zircon/system/fidl zircon fidl libraries |
| 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 fuchsia/ |
| mkdir -p fuchsia/{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" \ |
| fuchsia/bin |
| cp \ |
| "$FUCHSIA_DIR/rustfmt.toml" \ |
| fuchsia/etc |
| find "$FUCHSIA_DIR/sdk/fidl" -mindepth 1 -maxdepth 1 -type d -print0 \ |
| | xargs -0 -I% cp -r % fuchsia/sdk/fidl |
| find "$FUCHSIA_DIR/zircon/system/fidl" -mindepth 1 -maxdepth 1 -type d -print0 \ |
| | xargs -0 -I% cp -r % fuchsia/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 fuchsia/{sdk,zircon} -type f -not -name '*.fidl' -delete |