blob: c615c343eb5da1c2f3f4bb7c5792a68e65b7c8bc [file] [log] [blame]
#!/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.
### configure jiri to manage a specific fuchsia layer cake
## usage: fx set-layer zircon|garnet|peridot|topaz
## Configures jiri to fetch the source code for the given layer and its
## dependencies.
set -e
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/lib/vars.sh
if [[ "$#" -ne 1 ]]; then
fx-command-help
exit 1
fi
layer="$1"
if [[ "${layer}" != "zircon" ]] &&
[[ "${layer}" != "garnet" ]] &&
[[ "${layer}" != "peridot" ]] &&
[[ "${layer}" != "topaz" ]]; then
fx-command-help
exit 1
fi
# If jiri is not found which will return an err which will cause bash to exit.
# "|| echo" catches that.
jiri=$(which jiri || echo)
if [[ -z ${jiri} ]]; then
jiri="${FUCHSIA_DIR}/.jiri_root/bin/jiri"
if [[ ! -f ${jiri} ]]; then
echo >&2 "error: Cannot find \"jiri\" in your PATH nor at ${jiri}."
exit 1
fi
fi
cd "${FUCHSIA_DIR}"
function remove-import {
local -r name=$1
local -r manifest=$2
${jiri} -q import -delete=true -name="${name}" "${manifest}"
}
remove-import zircon manifest/zircon
remove-import garnet manifest/garnet
remove-import peridot manifest/peridot
remove-import topaz manifest/topaz
# TODO(abarth): Remove this step eventually once everyone has had a change to
# remove this import from their manifest.
remove-import manifest fuchsia
${jiri} import -name="${layer}" "manifest/${layer}" "https://fuchsia.googlesource.com/${layer}"
cat <<END
Configured jiri for ${layer}. Run these commands to update your build:
* jiri update -gc # Updates your source tree to contain ${layer} and
# removes unneeded repositories.
* fx set x64 # Updates your build directory to build ${layer}.
* fx full-build # Actually builds ${layer}.
END