| OLD | NEW |
| 1 #!/usr/bin/env bash | 1 #!/usr/bin/env 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 # Run pub.dart on the Dart VM. This script is only used when running pub from | 6 # Run pub.dart on the Dart VM. This script is only used when running pub from |
| 7 # within the Dart source repo. The shipped SDK instead uses "pub_sdk", which is | 7 # within the Dart source repo. The shipped SDK instead uses "pub_sdk", which is |
| 8 # renamed to "pub" when the SDK is built. | 8 # renamed to "pub" when the SDK is built. |
| 9 | 9 |
| 10 function follow_links() { | 10 function follow_links() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 # Handle the case where dart-sdk/bin has been symlinked to. | 22 # Handle the case where dart-sdk/bin has been symlinked to. |
| 23 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | 23 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" |
| 24 | 24 |
| 25 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" | 25 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" |
| 26 | 26 |
| 27 SNAPSHOT="$BIN_DIR/snapshots/pub.dart.snapshot" | 27 SNAPSHOT="$BIN_DIR/snapshots/pub.dart.snapshot" |
| 28 | 28 |
| 29 unset VM_OPTIONS | 29 unset VM_OPTIONS |
| 30 declare -a VM_OPTIONS | 30 declare -a VM_OPTIONS |
| 31 | 31 |
| 32 if [[ `uname` == 'Darwin' ]]; |
| 33 then |
| 34 OUT_DIR="$BIN_DIR"/../../xcodebuild/ |
| 35 else |
| 36 OUT_DIR="$BIN_DIR"/../../out/ |
| 37 fi |
| 38 |
| 32 # Allow extra VM options to be passed in through an environment variable. | 39 # Allow extra VM options to be passed in through an environment variable. |
| 33 if [[ $DART_VM_OPTIONS ]]; then | 40 if [[ $DART_VM_OPTIONS ]]; then |
| 34 read -a OPTIONS <<< "$DART_VM_OPTIONS" | 41 read -a OPTIONS <<< "$DART_VM_OPTIONS" |
| 35 VM_OPTIONS+=("${OPTIONS[@]}") | 42 VM_OPTIONS+=("${OPTIONS[@]}") |
| 36 fi | 43 fi |
| 37 | 44 |
| 38 if [ -z "$DART_CONFIGURATION" ]; | 45 if [ -z "$DART_CONFIGURATION" ]; |
| 39 then | 46 then |
| 40 DART_CONFIGURATION="ReleaseX64" | 47 DIRS=$( ls "$OUT_DIR" ) |
| 48 # list of possible configurations in decreasing desirability |
| 49 CONFIGS=("ReleaseX64" "ReleaseIA32" "DebugX64" "DebugIA32" |
| 50 "ReleaseARM" "ReleaseARM64" "ReleaseARMV5TE" "ReleaseMIPS" |
| 51 "DebugARM" "DebugARM64" "DebugARMV5TE" "DebugMIPS") |
| 52 DART_CONFIGURATION="None" |
| 53 for CONFIG in ${CONFIGS[*]} |
| 54 do |
| 55 for DIR in $DIRS; |
| 56 do |
| 57 if [ "$CONFIG" = "$DIR" ]; |
| 58 then |
| 59 # choose most desirable configuration that is available and break |
| 60 DART_CONFIGURATION="$DIR" |
| 61 break 2 |
| 62 fi |
| 63 done |
| 64 done |
| 65 if [ "$DART_CONFIGURATION" = "None" ] |
| 66 then |
| 67 echo "No valid dart configuration found in $OUT_DIR" |
| 68 exit 1 |
| 69 fi |
| 41 fi | 70 fi |
| 42 | 71 |
| 43 if [[ `uname` == 'Darwin' ]]; | 72 if [[ `uname` == 'Darwin' ]]; |
| 44 then | 73 then |
| 45 BUILD_DIR="$SDK_DIR/../xcodebuild/$DART_CONFIGURATION" | 74 BUILD_DIR="$SDK_DIR/../xcodebuild/$DART_CONFIGURATION" |
| 46 else | 75 else |
| 47 BUILD_DIR="$SDK_DIR/../out/$DART_CONFIGURATION" | 76 BUILD_DIR="$SDK_DIR/../out/$DART_CONFIGURATION" |
| 48 fi | 77 fi |
| 49 | 78 |
| 50 # Use the Dart binary in the built SDK so pub can find the version file next | 79 # Use the Dart binary in the built SDK so pub can find the version file next |
| 51 # to it. | 80 # to it. |
| 52 DART="$BUILD_DIR/dart-sdk/bin/dart" | 81 DART="$BUILD_DIR/dart-sdk/bin/dart" |
| 53 PACKAGES_DIR="$BUILD_DIR/packages/" | 82 PACKAGES_DIR="$BUILD_DIR/packages/" |
| 54 | 83 |
| 55 # Run pub. | 84 # Run pub. |
| 56 PUB="$SDK_DIR/../third_party/pkg/pub/bin/pub.dart" | 85 PUB="$SDK_DIR/../third_party/pkg/pub/bin/pub.dart" |
| 57 exec "$DART" "${VM_OPTIONS[@]}" "--package-root=$PACKAGES_DIR" "$PUB" "$@" | 86 exec "$DART" "${VM_OPTIONS[@]}" "--package-root=$PACKAGES_DIR" "$PUB" "$@" |
| OLD | NEW |