| #!/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. |
| |
| ### re-use a previous build directory set up by `fx set` |
| |
| ## usage: fx use DIR |
| ## |
| ## Switches further `fx` commands to using a different build directory. |
| ## This only works if `fx set ... --build-dir DIR` succeeded previously |
| ## (and DIR has not been removed since). The next `fx build` or other |
| ## such command will now refer to DIR. The previous build directory is |
| ## left in place, so you can switch back again with `fx use` later. |
| |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? |
| |
| function main { |
| if [[ $# -ne 1 ]]; then |
| fx-command-help |
| return 1 |
| fi |
| |
| local -r build_dir="$1" |
| |
| if [[ "$build_dir" == /* ]]; then |
| local -r full_build_dir="${build_dir}" |
| else |
| local -r full_build_dir="${FUCHSIA_DIR}/${build_dir}" |
| fi |
| |
| if [[ -e "${full_build_dir}/args.gn" ]]; then |
| fx-config-write "${build_dir}" |
| else |
| echo "\"${build_dir}\" is not a valid build dir." |
| echo "" |
| fx-command-help |
| return 1 |
| fi |
| } |
| |
| main "$@" |