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 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | 19 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" |
20 | 20 |
21 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" | 21 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" |
22 | 22 |
23 DART2JS="$SDK_DIR/lib/_internal/compiler/implementation/dart2js.dart" | |
24 | |
25 DART="$BIN_DIR/dart" | 23 DART="$BIN_DIR/dart" |
26 | 24 |
27 SNAPSHOT_DIR="$BIN_DIR/snapshots" | |
28 SNAPSHOT="$SNAPSHOT_DIR/dart2js.dart.snapshot" | |
29 | |
30 unset EXTRA_OPTIONS | 25 unset EXTRA_OPTIONS |
31 declare -a EXTRA_OPTIONS | 26 declare -a EXTRA_OPTIONS |
32 | 27 |
33 if test -t 1; then | 28 if test -t 1; then |
34 # Stdout is a terminal. | 29 # Stdout is a terminal. |
35 if test 8 -le `tput colors`; then | 30 if test 8 -le `tput colors`; then |
36 # Stdout has at least 8 colors, so enable colors. | 31 # Stdout has at least 8 colors, so enable colors. |
37 EXTRA_OPTIONS+=('--enable-diagnostic-colors') | 32 EXTRA_OPTIONS+=('--enable-diagnostic-colors') |
38 fi | 33 fi |
39 fi | 34 fi |
40 | 35 |
41 unset EXTRA_VM_OPTIONS | 36 unset EXTRA_VM_OPTIONS |
42 declare -a EXTRA_VM_OPTIONS | 37 declare -a EXTRA_VM_OPTIONS |
43 | 38 |
44 if test -f "$SNAPSHOT"; then | |
45 EXTRA_OPTIONS+=("--library-root=$SDK_DIR") | |
46 fi | |
47 | |
48 # Tell the VM to grow the heap more aggressively. This should only | 39 # Tell the VM to grow the heap more aggressively. This should only |
49 # be necessary temporarily until the VM is better at detecting how | 40 # be necessary temporarily until the VM is better at detecting how |
50 # applications use memory. | 41 # applications use memory. |
51 # TODO(ahe): Remove this option (http://dartbug.com/6495). | 42 # TODO(ahe): Remove this option (http://dartbug.com/6495). |
52 EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--heap_growth_rate=512' | 43 EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--heap_growth_rate=512' |
53 | 44 |
54 case $0 in | 45 case $0 in |
55 *_developer) | 46 *_developer) |
56 EXTRA_VM_OPTIONS+=('--checked') | 47 EXTRA_VM_OPTIONS+=('--checked') |
57 ;; | 48 ;; |
58 esac | 49 esac |
59 | 50 |
60 # We allow extra vm options to be passed in through an environment variable. | 51 # We allow extra vm options to be passed in through an environment variable. |
61 if [[ $DART_VM_OPTIONS ]]; then | 52 if [[ $DART_VM_OPTIONS ]]; then |
62 read -a OPTIONS <<< "$DART_VM_OPTIONS" | 53 read -a OPTIONS <<< "$DART_VM_OPTIONS" |
63 EXTRA_VM_OPTIONS+=("${OPTIONS[@]}") | 54 EXTRA_VM_OPTIONS+=("${OPTIONS[@]}") |
64 fi | 55 fi |
65 | 56 |
66 if test -f "$SNAPSHOT"; then | 57 DART_ROOT="$(cd "${SDK_DIR}/.." ; pwd -P)" |
67 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "${EXTRA_OPTIONS[@]}" "$@" | 58 |
| 59 DART2JS="$DART_ROOT/pkg/compiler/lib/src/dart2js.dart" |
| 60 |
| 61 if [ -z "$DART_CONFIGURATION" ]; |
| 62 then |
| 63 DART_CONFIGURATION="ReleaseIA32" |
| 64 fi |
| 65 |
| 66 if [[ `uname` == 'Darwin' ]]; then |
| 67 BUILD_DIR="$DART_ROOT/xcodebuild/$DART_CONFIGURATION" |
68 else | 68 else |
69 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$DART2JS" "${EXTRA_OPTIONS[@]}" "$@" | 69 BUILD_DIR="$DART_ROOT/out/$DART_CONFIGURATION" |
70 fi | 70 fi |
| 71 |
| 72 PACKAGE_ROOT="$BUILD_DIR/packages/" |
| 73 |
| 74 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "--package-root=$PACKAGE_ROOT" "$DART2JS"
"${EXTRA_OPTIONS[@]}" "$@" |
OLD | NEW |