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" | 25 SNAPSHOT_DIR="$BIN_DIR/snapshots" |
28 SNAPSHOT="$SNAPSHOT_DIR/dart2js.dart.snapshot" | 26 SNAPSHOT="$SNAPSHOT_DIR/dart2js.dart.snapshot" |
29 | 27 |
30 unset EXTRA_OPTIONS | 28 unset EXTRA_OPTIONS |
31 declare -a EXTRA_OPTIONS | 29 declare -a EXTRA_OPTIONS |
32 | 30 |
33 if test -t 1; then | 31 if test -t 1; then |
34 # Stdout is a terminal. | 32 # Stdout is a terminal. |
(...skipping 21 matching lines...) Expand all Loading... |
56 EXTRA_VM_OPTIONS+=('--checked') | 54 EXTRA_VM_OPTIONS+=('--checked') |
57 ;; | 55 ;; |
58 esac | 56 esac |
59 | 57 |
60 # We allow extra vm options to be passed in through an environment variable. | 58 # We allow extra vm options to be passed in through an environment variable. |
61 if [[ $DART_VM_OPTIONS ]]; then | 59 if [[ $DART_VM_OPTIONS ]]; then |
62 read -a OPTIONS <<< "$DART_VM_OPTIONS" | 60 read -a OPTIONS <<< "$DART_VM_OPTIONS" |
63 EXTRA_VM_OPTIONS+=("${OPTIONS[@]}") | 61 EXTRA_VM_OPTIONS+=("${OPTIONS[@]}") |
64 fi | 62 fi |
65 | 63 |
66 if test -f "$SNAPSHOT"; then | 64 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "${EXTRA_OPTIONS[@]}" "$@" |
67 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "${EXTRA_OPTIONS[@]}" "$@" | |
68 else | |
69 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$DART2JS" "${EXTRA_OPTIONS[@]}" "$@" | |
70 fi | |
OLD | NEW |