OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2013, 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 # Run dartanalyzer.dart on the Dart VM. This script assumes the Dart SDK's | 6 # Run dartanalyzer.dart on the Dart VM. This script assumes the Dart SDK's |
7 # directory structure. | 7 # directory structure. |
8 | 8 |
9 function follow_links() { | 9 function follow_links() { |
10 file="$1" | 10 file="$1" |
11 while [ -h "$file" ]; do | 11 while [ -h "$file" ]; do |
12 # On Mac OS, readlink -f doesn't work. | 12 # On Mac OS, readlink -f doesn't work. |
13 file="$(readlink "$file")" | 13 file="$(readlink "$file")" |
14 done | 14 done |
15 echo "$file" | 15 echo "$file" |
16 } | 16 } |
17 | 17 |
18 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. | 18 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. |
19 PROG_NAME="$(follow_links "$BASH_SOURCE")" | 19 PROG_NAME="$(follow_links "$BASH_SOURCE")" |
20 | 20 |
21 # Handle the case where dart-sdk/bin has been symlinked to. | 21 # Handle the case where dart-sdk/bin has been symlinked to. |
22 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | 22 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" |
23 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" | 23 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" |
24 DART_ROOT="$(cd "${SDK_DIR}/.." ; pwd -P)" | |
ricow1
2014/10/07 06:03:08
this is not true if we are running from the snapsh
Paul Berry
2014/10/07 23:39:17
Acknowledged. I've moved DART_ROOT and ANALYZER i
| |
25 | |
26 ANALYZER="$DART_ROOT/pkg/analyzer/bin/analyzer.dart" | |
24 | 27 |
25 SDK_ARG="--dart-sdk=$SDK_DIR" | 28 SDK_ARG="--dart-sdk=$SDK_DIR" |
26 | 29 |
30 if [ -z "$DART_CONFIGURATION" ]; | |
31 then | |
32 DART_CONFIGURATION="ReleaseIA32" | |
ricow1
2014/10/07 06:03:08
I really don't like this, and I don't think we nee
Paul Berry
2014/10/07 23:39:17
I've tried doing this but it's proving to be diffi
| |
33 fi | |
34 | |
35 DART="$BIN_DIR/dart" | |
36 | |
27 SNAPSHOT="$BIN_DIR/snapshots/dartanalyzer.dart.snapshot" | 37 SNAPSHOT="$BIN_DIR/snapshots/dartanalyzer.dart.snapshot" |
28 | 38 |
29 # We are running the snapshot in the built SDK. | 39 if [[ `uname` == 'Darwin' ]]; then |
ricow1
2014/10/07 06:03:08
see comment above
| |
30 DART="$BIN_DIR/dart" | 40 BUILD_DIR="$DART_ROOT/xcodebuild/$DART_CONFIGURATION" |
31 exec "$DART" "$SNAPSHOT" "$SDK_ARG" "$@" | 41 else |
42 BUILD_DIR="$DART_ROOT/out/$DART_CONFIGURATION" | |
43 fi | |
44 | |
45 PACKAGE_ROOT="$BUILD_DIR/packages/" | |
46 | |
47 unset EXTRA_VM_OPTIONS | |
48 declare -a EXTRA_VM_OPTIONS | |
49 | |
50 # Set some optimization options that speed up analysis. | |
51 EXTRA_VM_OPTIONS+=("--heap_growth_rate=512") | |
52 EXTRA_VM_OPTIONS+=("--inlining_hotness=90") | |
53 EXTRA_VM_OPTIONS+=("--optimization_counter_threshold=5000") | |
54 | |
55 case $0 in | |
56 *_developer) | |
57 EXTRA_VM_OPTIONS+=('--checked') | |
58 ;; | |
59 esac | |
60 | |
61 # We allow extra vm options to be passed in through an environment variable. | |
62 if [[ $DART_VM_OPTIONS ]]; then | |
63 read -a OPTIONS <<< "$DART_VM_OPTIONS" | |
64 EXTRA_VM_OPTIONS+=("${OPTIONS[@]}") | |
65 fi | |
66 | |
67 if test -f "$SNAPSHOT"; then | |
68 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "$SDK_ARG" "$@" | |
69 else | |
70 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "--package-root=$PACKAGE_ROOT" "$ANALYZE R" "$SDK_ARG" "$@" | |
71 fi | |
OLD | NEW |