| 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 # Setting BIN_DIR this way is ugly, but is needed to handle the case where | 6 function follow_links() { |
| 7 # dart-sdk/bin has been symlinked to. On MacOS, readlink doesn't work | 7 while [ -h "$1" ]; do |
| 8 # with this case. | 8 # On Mac OS, readlink -f doesn't work. |
| 9 BIN_DIR="$(cd "${0%/*}" ; pwd -P)" | 9 1="$(readlink "$1")" |
| 10 done |
| 11 echo "$1" |
| 12 } |
| 10 | 13 |
| 11 unset COLORS | 14 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. |
| 15 PROG_NAME="$(follow_links "$BASH_SOURCE")" |
| 16 |
| 17 # Handle the case where dart-sdk/bin has been symlinked to. |
| 18 BIN_DIR="$(follow_links "$(cd "${PROG_NAME%/*}" ; pwd -P)")" |
| 19 |
| 20 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" |
| 21 |
| 22 DART2JS="$SDK_DIR/lib/_internal/compiler/implementation/dart2js.dart" |
| 23 DART="$BIN_DIR/dart" |
| 24 |
| 25 unset EXTRA_OPTIONS |
| 26 declare -a EXTRA_OPTIONS |
| 27 |
| 12 if test -t 1; then | 28 if test -t 1; then |
| 13 # Stdout is a terminal. | 29 # Stdout is a terminal. |
| 14 if test 8 -le `tput colors`; then | 30 if test 8 -le `tput colors`; then |
| 15 # Stdout has at least 8 colors, so enable colors. | 31 # Stdout has at least 8 colors, so enable colors. |
| 16 COLORS="--enable-diagnostic-colors" | 32 EXTRA_OPTIONS[${#EXTRA_OPTIONS[@]}]='--enable-diagnostic-colors' |
| 17 fi | 33 fi |
| 18 fi | 34 fi |
| 19 | 35 |
| 20 unset SNAPSHOT | 36 unset EXTRA_VM_OPTIONS |
| 21 if test -f "$BIN_DIR/../lib/_internal/compiler/implementation/dart2js.dart.snaps
hot"; then | 37 declare -a EXTRA_VM_OPTIONS |
| 38 |
| 39 SNAPSHOT="$SDK_DIR/_internal/compiler/implementation/dart2js.dart.snapshot" |
| 40 if test -f "$SNAPSHOT"; then |
| 22 # TODO(ahe): Remove the following line when we are relatively sure it works. | 41 # TODO(ahe): Remove the following line when we are relatively sure it works. |
| 23 echo Using snapshot "$BIN_DIR/../lib/_internal/compiler/implementation/dart2js
.dart.snapshot" 1>&2 | 42 echo Using snapshot "$SNAPSHOT" 1>&2 |
| 24 SNAPSHOT="--use_script_snapshot=$BIN_DIR/../lib/_internal/compiler/implementat
ion/dart2js.dart.snapshot" | 43 EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]="--use_script_snapshot=$SNAPSHOT" |
| 25 fi | 44 fi |
| 26 exec "$BIN_DIR"/dart --no_use_inlining --heap_growth_rate=32 $SNAPSHOT "$BIN_DIR
/../lib/_internal/compiler/implementation/dart2js.dart" $COLORS "$@" | 45 |
| 46 # Tell the VM to grow the heap more aggressively. This should only |
| 47 # be necessary temporarily until the VM is better at detecting how |
| 48 # applications use memory. |
| 49 # TODO(ahe): Remove this option (http://dartbug.com/6495). |
| 50 EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--heap_growth_rate=512' |
| 51 |
| 52 # Tell the VM to don't bother inlining methods. So far inlining isn't |
| 53 # paying off but the VM team is working on fixing that. |
| 54 # TODO(ahe): Remove this option (http://dartbug.com/6495). |
| 55 EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--no_use_inlining' |
| 56 |
| 57 case $0 in |
| 58 *_developer) |
| 59 EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--checked' |
| 60 ;; |
| 61 esac |
| 62 |
| 63 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$DART2JS" "${EXTRA_OPTIONS[@]}" "$@" |
| OLD | NEW |