From e10b74cd24557202109e8891e9364e77e3f40aef Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 23 Mar 2016 10:51:23 -0700 Subject: [PATCH] Set FLUTTER_ROOT to an absolute path This implementation was taken from the Dart SDK shell scripts. BUG=https://github.com/flutter/flutter/issues/2795 --- bin/flutter | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/flutter b/bin/flutter index 08182b37578..883e48f9181 100755 --- a/bin/flutter +++ b/bin/flutter @@ -5,7 +5,19 @@ set -e -export FLUTTER_ROOT=$(dirname $(dirname "${BASH_SOURCE[0]}")) +function follow_links() { + file="$1" + while [ -h "$file" ]; do + # On Mac OS, readlink -f doesn't work. + file="$(readlink "$file")" + done + echo "$file" +} + +PROG_NAME="$(follow_links "$BASH_SOURCE")" +BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" +export FLUTTER_ROOT="$(cd "${BIN_DIR}/.." ; pwd -P)" + FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools" SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp"