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 function follow_links() { |
7 file="$1" | 7 file="$1" |
8 while [ -h "$file" ]; do | 8 while [ -h "$file" ]; do |
9 # On Mac OS, readlink -f doesn't work. | 9 # On Mac OS, readlink -f doesn't work. |
10 file="$(readlink "$file")" | 10 file="$(readlink "$file")" |
11 done | 11 done |
12 echo "$file" | 12 echo "$file" |
13 } | 13 } |
14 | 14 |
15 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. | 15 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. |
16 PROG_NAME="$(follow_links "$BASH_SOURCE")" | 16 PROG_NAME="$(follow_links "$BASH_SOURCE")" |
17 | 17 |
18 # Handle the case where dart-sdk/bin has been symlinked to. | 18 # Handle the case where dart-sdk/bin has been symlinked to. |
19 CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | 19 CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" |
20 | 20 |
| 21 if [[ `uname` == 'Darwin' ]]; |
| 22 then |
| 23 OUT_DIR="$CUR_DIR"/../../xcodebuild/ |
| 24 else |
| 25 OUT_DIR="$CUR_DIR"/../../out/ |
| 26 fi |
| 27 |
21 if [ -z "$DART_CONFIGURATION" ]; | 28 if [ -z "$DART_CONFIGURATION" ]; |
22 then | 29 then |
23 DART_CONFIGURATION="ReleaseIA32" | 30 DIRS=$( ls "$OUT_DIR" ) |
| 31 # list of possible configurations in decreasing desirability |
| 32 CONFIGS=("ReleaseIA32" "ReleaseX64" "DebugIA32" "DebugX64" |
| 33 "ReleaseARM" "ReleaseARM64" "ReleaseARMV5TE" "ReleaseMIPS" |
| 34 "DebugARM" "DebugARM64" "DebugARMV5TE" "DebugMIPS") |
| 35 DART_CONFIGURATION="None" |
| 36 for CONFIG in ${CONFIGS[*]} |
| 37 do |
| 38 for DIR in $DIRS; |
| 39 do |
| 40 if [ "$CONFIG" = "$DIR" ]; |
| 41 then |
| 42 # choose most desirable configuration that is available and break |
| 43 DART_CONFIGURATION="$DIR" |
| 44 break 2 |
| 45 fi |
| 46 done |
| 47 done |
| 48 if [ "$DART_CONFIGURATION" = "None" ] |
| 49 then |
| 50 echo "No valid dart configuration found in $OUT_DIR" |
| 51 exit 1 |
| 52 fi |
24 fi | 53 fi |
25 | 54 |
26 if [[ `uname` == 'Darwin' ]]; | 55 BIN_DIR="$OUT_DIR$DART_CONFIGURATION" |
27 then | |
28 BIN_DIR="$CUR_DIR"/../../xcodebuild/$DART_CONFIGURATION | |
29 else | |
30 BIN_DIR="$CUR_DIR"/../../out/$DART_CONFIGURATION | |
31 fi | |
32 | 56 |
33 exec "$BIN_DIR"/dart "$@" | 57 exec "$BIN_DIR"/dart "$@" |
OLD | NEW |