OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 # Run pub.dart on the Dart VM. This script assumes the Dart SDK's directory |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # structure. |
4 # BSD-style license that can be found in the LICENSE file. | |
5 | 4 |
6 function follow_links() { | 5 # Setting BIN_DIR this way is ugly, but is needed to handle the case where |
7 while [ -h "$1" ]; do | 6 # dart-sdk/bin has been symlinked to. On MacOS, readlink doesn't work |
8 # On Mac OS, readlink -f doesn't work. | 7 # with this case. |
9 1="$(readlink "$1")" | 8 BIN_DIR="$(cd "${0%/*}" ; pwd -P)" |
10 done | 9 DART_SDK="$(cd "${BIN_DIR%/*}" ; pwd -P)" |
11 echo "$1" | |
12 } | |
13 | 10 |
14 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. | 11 exec "$BIN_DIR"/dart "$DART_SDK"/bin/snapshots/pub.dart.snapshot $@ |
15 PROG_NAME="$(follow_links "$BASH_SOURCE")" | |
16 | |
17 # Handle the case where dart-sdk/bin has been symlinked to. | |
18 BIN_DIR="$(follow_links "$(cd "${PROG_NAME%/*}" ; pwd -P)")" | |
19 | |
20 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" | |
21 | |
22 DART="$BIN_DIR/dart" | |
23 | |
24 SNAPSHOT="$BIN_DIR/snapshots/pub.dart.snapshot" | |
25 | |
26 if test -f "$SNAPSHOT"; then | |
27 # We are running the snapshot in the built SDK. | |
28 exec "$DART" "--checked" "$SNAPSHOT" "$@" | |
29 else | |
30 # We are running pub from source in the development repo. | |
31 if [ -z "$DART_CONFIGURATION" ]; | |
32 then | |
33 DART_CONFIGURATION="ReleaseIA32" | |
34 fi | |
35 | |
36 if [[ `uname` == 'Darwin' ]]; | |
37 then | |
38 PACKAGES_DIR="$SDK_DIR"/../xcodebuild/$DART_CONFIGURATION/packages/ | |
39 else | |
40 PACKAGES_DIR="$SDK_DIR"/../out/$DART_CONFIGURATION/packages/ | |
41 fi | |
42 | |
43 PUB="$SDK_DIR/lib/_internal/pub/bin/pub.dart" | |
44 | |
45 exec "$DART" "--checked" "--package-root=$PACKAGES_DIR" "$PUB" "$@" | |
46 fi | |
OLD | NEW |