OLD | NEW |
| (Empty) |
1 #!/usr/bin/env bash | |
2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
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. | |
5 | |
6 # Run dev compiler on the Dart VM. This script assumes the Dart repo's | |
7 # directory structure. | |
8 | |
9 function follow_links() { | |
10 file="$1" | |
11 while [ -h "$file" ]; do | |
12 # On Mac OS, readlink -f doesn't work. | |
13 file="$(readlink "$file")" | |
14 done | |
15 echo "$file" | |
16 } | |
17 | |
18 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. | |
19 PROG_NAME="$(follow_links "$BASH_SOURCE")" | |
20 | |
21 # Handle the case where dart-sdk/bin has been symlinked to. | |
22 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | |
23 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" | |
24 | |
25 SDK_ARG="--dart-sdk=$SDK_DIR" | |
26 | |
27 DART="$BIN_DIR/dart" | |
28 | |
29 unset EXTRA_VM_OPTIONS | |
30 declare -a EXTRA_VM_OPTIONS | |
31 | |
32 case $0 in | |
33 *_developer) | |
34 EXTRA_VM_OPTIONS+=('--checked') | |
35 ;; | |
36 esac | |
37 | |
38 # We allow extra vm options to be passed in through an environment variable. | |
39 if [[ $DART_VM_OPTIONS ]]; then | |
40 read -a OPTIONS <<< "$DART_VM_OPTIONS" | |
41 EXTRA_VM_OPTIONS+=("${OPTIONS[@]}") | |
42 fi | |
43 | |
44 DART_ROOT="$(cd "${SDK_DIR}/.." ; pwd -P)" | |
45 | |
46 DEV_COMPILER="$DART_ROOT/third_party/pkg/dev_compiler/bin/dartdevc.dart" | |
47 | |
48 if [[ `uname` == 'Darwin' ]]; | |
49 then | |
50 OUT_DIR="$DART_ROOT/xcodebuild/" | |
51 else | |
52 OUT_DIR="$DART_ROOT/out/" | |
53 fi | |
54 | |
55 if [ -z "$DART_CONFIGURATION" ]; | |
56 then | |
57 DIRS=$( ls "$OUT_DIR" ) | |
58 # list of possible configurations in decreasing desirability | |
59 CONFIGS=("ReleaseX64" "ReleaseIA32" "DebugX64" "DebugIA32" | |
60 "ReleaseARM" "ReleaseARM64" "ReleaseARMV5TE" "ReleaseMIPS" | |
61 "DebugARM" "DebugARM64" "DebugARMV5TE" "DebugMIPS") | |
62 DART_CONFIGURATION="None" | |
63 for CONFIG in ${CONFIGS[*]} | |
64 do | |
65 for DIR in $DIRS; | |
66 do | |
67 if [ "$CONFIG" = "$DIR" ]; | |
68 then | |
69 # choose most desirable configuration that is available and break | |
70 DART_CONFIGURATION="$DIR" | |
71 break 2 | |
72 fi | |
73 done | |
74 done | |
75 if [ "$DART_CONFIGURATION" = "None" ] | |
76 then | |
77 echo "No valid dart configuration found in $OUT_DIR" | |
78 exit 1 | |
79 fi | |
80 fi | |
81 | |
82 BUILD_DIR="$OUT_DIR$DART_CONFIGURATION" | |
83 | |
84 PACKAGE_ROOT="$BUILD_DIR/packages/" | |
85 | |
86 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "--package-root=$PACKAGE_ROOT" "$DEV_COMPI
LER" "$SDK_ARG" "$@" | |
OLD | NEW |