OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 function follow_links() { | 6 PROG_NAME=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && \ |
7 file="$1" | 7 PROG_NAME=$PROG_NAME/$(basename -- "$0") |
8 while [ -h "$file" ]; do | |
9 # On Mac OS, readlink -f doesn't work. | |
10 file="$(readlink "$file")" | |
11 done | |
12 echo "$file" | |
13 } | |
14 | 8 |
15 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. | 9 # resolve symlinks |
16 PROG_NAME="$(follow_links "$BASH_SOURCE")" | 10 while [ -h $PROG_NAME ]; do |
| 11 DIR=$(dirname -- "$PROG_NAME") |
| 12 SYM=$(readlink $PROG_NAME) |
| 13 PROG_NAME=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") |
| 14 done |
17 | 15 |
18 # Handle the case where dart-sdk/bin has been symlinked to. | 16 # Handle the case where dart-sdk/bin has been symlinked to. |
19 CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | 17 CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" |
20 | 18 |
21 if [ -z "$DART_CONFIGURATION" ]; | 19 if [ -z "$DART_CONFIGURATION" ]; |
22 then | 20 then |
23 DART_CONFIGURATION="ReleaseIA32" | 21 DART_CONFIGURATION="ReleaseIA32" |
24 fi | 22 fi |
25 | 23 |
26 if [[ `uname` == 'Darwin' ]]; | 24 if [[ `uname` == 'Darwin' ]]; |
27 then | 25 then |
28 BIN_DIR="$CUR_DIR"/../../xcodebuild/$DART_CONFIGURATION | 26 BIN_DIR="$CUR_DIR"/../../xcodebuild/$DART_CONFIGURATION |
29 else | 27 else |
30 BIN_DIR="$CUR_DIR"/../../out/$DART_CONFIGURATION | 28 BIN_DIR="$CUR_DIR"/../../out/$DART_CONFIGURATION |
31 fi | 29 fi |
32 | 30 |
33 exec "$BIN_DIR"/dart "$@" | 31 exec "$BIN_DIR"/dart "$@" |
OLD | NEW |