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