blob: 65c1bb607cab7b463df5c22d83dd0043e7a15483 [file] [log] [blame]
#!/bin/bash
# Copyright 2020 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.
# We walk the parent directories looking for .jiri_root rather than using
# BASH_SOURCE so that we find the fuchsia_dir enclosing the current working
# directory instead of the one containing this file in case the user has
# multiple source trees and is picking up this file from another one.
#
# NOTE: The FUCHSIA_DIR environment variable is ignored here because it
# could point to a different Fuchsia checkout in some developer setups.
#
# This logic is replicated in //scripts/fx, //scripts/hermetic_env,
# //scripts/zsh_completion/_fx, and //src/developer/ffx/scripts. For
# consistency, copy any changes here to those files as well.
fuchsia_dir="$(pwd)"
while [[ ! -d "${fuchsia_dir}/.jiri_root" ]]; do
fuchsia_dir="$(dirname "${fuchsia_dir}")"
if [[ "${fuchsia_dir}" == "/" ]]; then
echo "Cannot find the Platform Source Tree in a parent of directory: $(pwd)"
exit 1
fi
done
exec "${fuchsia_dir}"/scripts/fx ffx "$@"