| #!/bin/bash | |
| # Copyright 2017 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. | |
| set -e | |
| function usage { | |
| cat <<END | |
| usage: bootstrap [zircon|garnet|peridot|topaz] | |
| Bootstrap a Fuchsia development environment for the given project. Defaults to | |
| boostraping at topaz. For more information about the Fuchsia tree | |
| see <https://fuchsia.googlesource.com/docs/+/master/development/source_code/layers.md>. | |
| END | |
| } | |
| if [[ $# -gt 1 ]]; then | |
| usage | |
| exit 1 | |
| fi | |
| project=${1:-topaz} | |
| if [[ "${project}" != "zircon" ]] && | |
| [[ "${project}" != "garnet" ]] && | |
| [[ "${project}" != "peridot" ]] && | |
| [[ "${project}" != "topaz" ]]; then | |
| usage | |
| exit 1 | |
| fi | |
| # The fetched script will | |
| # - create "fuchsia" directory if it does not exist, | |
| # - download "jiri" command to "fuchsia/.jiri_root/bin" | |
| curl -s "https://fuchsia.googlesource.com/jiri/+/master/scripts/bootstrap_jiri?format=TEXT" | base64 --decode | bash -s fuchsia | |
| cd fuchsia | |
| .jiri_root/bin/jiri import -name="integration" "${project}/${project}" "https://fuchsia.googlesource.com/integration" | |
| .jiri_root/bin/jiri override ${project} "https://fuchsia.googlesource.com/${project}" | |
| .jiri_root/bin/jiri update | |
| echo "Done creating ${project} development environment at \"$(pwd)\"." | |
| echo "Recommended: export PATH=\"$(pwd)/.jiri_root/bin:\$PATH\"" |