OLD | NEW |
1 #!/bin/bash --posix | 1 #!/bin/bash --posix |
2 # Copyright (c) 2013, 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 set -e | 6 set -e |
7 | 7 |
8 # Setting SCRIPT_DIR this way is ugly, but is needed to handle the case where | 8 # Setting SCRIPT_DIR this way is ugly, but is needed to handle the case where |
9 # dart-sdk/bin has been symlinked to. On MacOS, readlink doesn't work | 9 # dart-sdk/bin has been symlinked to. On MacOS, readlink doesn't work |
10 # with this case. | 10 # with this case. |
11 SCRIPT_DIR="$(cd "${0%/*}" ; pwd -P)" | 11 SCRIPT_DIR="$(cd "${0%/*}" ; pwd -P)" |
12 DART_ANALYZER_HOME="$(cd "${SCRIPT_DIR%/*}" ; pwd -P)" | 12 DART_ANALYZER_HOME="$(cd "${SCRIPT_DIR%/*}" ; pwd -P)" |
13 | 13 |
14 FOUND_BATCH=0 | 14 FOUND_BATCH=0 |
15 FOUND_SDK=0 | 15 FOUND_SDK=0 |
16 for ARG in "$@" | 16 for ARG in "$@" |
17 do | 17 do |
18 case $ARG in | 18 case $ARG in |
19 -batch|--batch) | 19 -batch|--batch) |
20 FOUND_BATCH=1 | 20 FOUND_BATCH=1 |
21 ;; | 21 ;; |
22 --dart-sdk) | 22 --dart-sdk) |
23 FOUND_SDK=1 | 23 FOUND_SDK=1 |
24 ;; | 24 ;; |
25 *) | 25 *) |
26 ;; | 26 ;; |
27 esac | 27 esac |
28 done | 28 done |
29 | 29 |
30 DART_SDK="" | 30 DART_SDK="" |
31 if [ $FOUND_SDK = 0 ] ; then | 31 if [ $FOUND_SDK = 0 ] ; then |
32 if [ -f "$DART_ANALYZER_HOME/lib/core/core.dart" ] ; then | 32 if [ -f $DART_ANALYZER_HOME/lib/core/core.dart ] ; then |
33 DART_SDK=(--dart-sdk "$DART_ANALYZER_HOME") | 33 DART_SDK="--dart-sdk $DART_ANALYZER_HOME" |
34 else | 34 else |
35 DART_SDK_HOME=$(dirname "$DART_ANALYZER_HOME")/dart-sdk | 35 DART_SDK_HOME=$(dirname $DART_ANALYZER_HOME)/dart-sdk |
36 if [ -d "$DART_SDK_HOME" ] ; then | 36 if [ -d $DART_SDK_HOME ] ; then |
37 DART_SDK=(--dart-sdk "$DART_SDK_HOME") | 37 DART_SDK="--dart-sdk $DART_SDK_HOME" |
38 else | 38 else |
39 DART_SDK_HOME=$(dirname "$DART_SDK_HOME")/dart-sdk | 39 DART_SDK_HOME=$(dirname $DART_SDK_HOME)/dart-sdk |
40 if [ -d "$DART_SDK_HOME" ] ; then | 40 if [ -d $DART_SDK_HOME ] ; then |
41 DART_SDK=(--dart-sdk "$DART_SDK_HOME") | 41 DART_SDK="--dart-sdk $DART_SDK_HOME" |
42 else | 42 else |
43 echo "Couldn't find Dart SDK. Specify with --dart-sdk cmdline argument" | 43 echo "Couldn't find Dart SDK. Specify with --dart-sdk cmdline argument" |
44 fi | 44 fi |
45 fi | 45 fi |
46 fi | 46 fi |
47 fi | 47 fi |
48 | 48 |
49 if [ -f "$DART_SDK_HOME/util/dartanalyzer/dartanalyzer.jar" ] ; then | 49 if [ -f $DART_SDK_HOME/util/analyzer/dart_analyzer.jar ] ; then |
50 DART_ANALYZER_LIBS=$DART_SDK_HOME/util/dartanalyzer | 50 DART_ANALYZER_LIBS=$DART_SDK_HOME/util/analyzer |
51 elif [ -f "$DART_ANALYZER_HOME/util/dartanalyzer/dartanalyzer.jar" ] ; then | 51 elif [ -f $DART_ANALYZER_HOME/util/analyzer/dart_analyzer.jar ] ; then |
52 DART_ANALYZER_LIBS=$DART_ANALYZER_HOME/util/dartanalyzer | 52 DART_ANALYZER_LIBS=$DART_ANALYZER_HOME/util/analyzer |
53 else | 53 else |
54 echo "Configuration problem. Couldn't find dartanalyzer.jar." | 54 echo "Configuration problem. Couldn't find dart_analyzer.jar." |
55 exit 1 | 55 exit 1 |
56 fi | 56 fi |
57 | 57 |
58 if [ -x /usr/libexec/java_home ]; then | 58 if [ -x /usr/libexec/java_home ]; then |
59 export JAVA_HOME=$(/usr/libexec/java_home -v '1.6+') | 59 export JAVA_HOME=$(/usr/libexec/java_home -v '1.6+') |
60 fi | 60 fi |
61 | 61 |
62 EXTRA_JVMARGS="-Xss2M " | 62 EXTRA_JVMARGS="-Xss2M " |
63 OS=`uname | tr "[A-Z]" "[a-z]"` | 63 OS=`uname | tr "[A-Z]" "[a-z]"` |
64 if [ "$OS" == "darwin" ] ; then | 64 if [ "$OS" == "darwin" ] ; then |
65 # Bump up the heap on Mac VMs, some of which default to 128M or less. | 65 # Bump up the heap on Mac VMs, some of which default to 128M or less. |
66 # Users can specify DART_JVMARGS in the environment to override this | 66 # Users can specify DART_JVMARGS in the environment to override this |
67 # setting. | 67 # setting. |
68 EXTRA_JVMARGS+=" -Xmx256M -client " | 68 EXTRA_JVMARGS+=" -Xmx256M -client " |
69 else | 69 else |
70 # On other architectures | 70 # On other architectures |
71 # -batch invocations will do better with a server vm | 71 # -batch invocations will do better with a server vm |
72 # invocations for analyzing a single file do better with a client vm | 72 # invocations for analyzing a single file do better with a client vm |
73 if [ $FOUND_BATCH = 0 ] ; then | 73 if [ $FOUND_BATCH = 0 ] ; then |
74 EXTRA_JVMARGS+=" -client " | 74 EXTRA_JVMARGS+=" -client " |
75 fi | 75 fi |
76 fi | 76 fi |
77 | 77 |
78 exec java $EXTRA_JVMARGS $DART_JVMARGS -ea -jar \ | 78 exec java $EXTRA_JVMARGS $DART_JVMARGS -ea -classpath "@CLASSPATH@" \ |
79 "$DART_ANALYZER_LIBS/dartanalyzer.jar" "${DART_SDK[@]}" $@ | 79 com.google.dart.compiler.DartCompiler ${DART_SDK} $@ |
OLD | NEW |