OLD | NEW |
| (Empty) |
1 #!/bin/bash | |
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 | |
4 # BSD-style license that can be found in the LICENSE file. | |
5 | |
6 function follow_links() { | |
7 file="$1" | |
8 while [ -h "$file" ]; do | |
9 # On Mac OS, readlink -f doesn't work. | |
10 file="$(readlink "$file")" | |
11 done | |
12 echo "$file" | |
13 } | |
14 | |
15 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. | |
16 PROG_NAME="$(follow_links "$BASH_SOURCE")" | |
17 | |
18 # Handle the case where dart-sdk/bin has been symlinked to. | |
19 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | |
20 | |
21 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" | |
22 | |
23 DART="$BIN_DIR/dart" | |
24 | |
25 SNAPSHOT_DIR="$BIN_DIR/snapshots" | |
26 SNAPSHOT="$SNAPSHOT_DIR/dart2js.dart.snapshot" | |
27 | |
28 unset EXTRA_OPTIONS | |
29 declare -a EXTRA_OPTIONS | |
30 | |
31 if test -t 1; then | |
32 # Stdout is a terminal. | |
33 if test 8 -le `tput colors`; then | |
34 # Stdout has at least 8 colors, so enable colors. | |
35 EXTRA_OPTIONS+=('--enable-diagnostic-colors') | |
36 fi | |
37 fi | |
38 | |
39 unset EXTRA_VM_OPTIONS | |
40 declare -a EXTRA_VM_OPTIONS | |
41 | |
42 if test -f "$SNAPSHOT"; then | |
43 EXTRA_OPTIONS+=("--library-root=$SDK_DIR") | |
44 fi | |
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 case $0 in | |
53 *_developer) | |
54 EXTRA_VM_OPTIONS+=('--checked') | |
55 ;; | |
56 esac | |
57 | |
58 # We allow extra vm options to be passed in through an environment variable. | |
59 if [[ $DART_VM_OPTIONS ]]; then | |
60 read -a OPTIONS <<< "$DART_VM_OPTIONS" | |
61 EXTRA_VM_OPTIONS+=("${OPTIONS[@]}") | |
62 fi | |
63 | |
64 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "${EXTRA_OPTIONS[@]}" "$@" | |
OLD | NEW |