Chromium Code Reviews| 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 function link_dir() { |
| 6 function follow_links() { | 6 a="$1" |
| 7 while [ -h "$1" ]; do | 7 while [ -h "$a" ]; do |
| 8 # On Mac OS, readlink -f doesn't work. | 8 # On Mac OS, readlink -f doesn't work. |
| 9 1="$(readlink "$1")" | 9 a="$(readlink "$a")" |
| 10 done | 10 done |
| 11 echo "$1" | 11 # if dir linked, not file, need to follow dir path: |
|
ahe
2013/05/30 10:00:19
This comment does not make sense to me.
yarkot1
2013/05/31 22:22:17
if $a (filename) is a file, readlink handles follo
ahe
2013/06/03 10:29:01
Could you change the comment to:
# If the parent
| |
| 12 echo "$(cd $(dirname "$a"); pwd -P)" | |
|
ahe
2013/05/30 10:00:19
This invokes the external command dirname. That a
yarkot1
2013/05/31 22:22:17
yes - you are correct. Timing this confirms.
| |
| 12 } | 13 } |
| 13 | 14 |
| 14 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. | |
| 15 PROG_NAME="$(follow_links "$BASH_SOURCE")" | |
| 16 | |
| 17 # Handle the case where dart-sdk/bin has been symlinked to. | 15 # Handle the case where dart-sdk/bin has been symlinked to. |
|
ahe
2013/05/30 10:00:19
You're still not handling this case.
nweiz
2013/05/31 19:35:21
This case is handled by the "pwd -P" call in link_
ahe
2013/06/03 10:29:01
Thank you. I just studied the man page, and you'r
| |
| 18 BIN_DIR="$(follow_links "$(cd "${PROG_NAME%/*}" ; pwd -P)")" | 16 BIN_DIR="$(link_dir "$0")" |
|
ahe
2013/05/30 10:00:19
$0 is not the right thing to use. See the differe
yarkot1
2013/05/31 22:22:17
yes - this is true in the case of sourced scripts;
| |
| 19 | 17 SDK_DIR="${BIN_DIR%/*}" |
| 20 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" | |
| 21 | 18 |
| 22 DART2JS="$SDK_DIR/lib/_internal/compiler/implementation/dart2js.dart" | 19 DART2JS="$SDK_DIR/lib/_internal/compiler/implementation/dart2js.dart" |
| 23 | 20 |
| 24 DART="$BIN_DIR/dart" | 21 DART="$BIN_DIR/dart" |
| 25 | 22 |
| 26 SNAPSHOT_DIR="$BIN_DIR/snapshots" | 23 SNAPSHOT_DIR="$BIN_DIR/snapshots" |
| 27 SNAPSHOT="$SNAPSHOT_DIR/utils_wrapper.dart.snapshot" | 24 SNAPSHOT="$SNAPSHOT_DIR/utils_wrapper.dart.snapshot" |
| 28 | 25 |
| 29 unset EXTRA_OPTIONS | 26 unset EXTRA_OPTIONS |
| 30 declare -a EXTRA_OPTIONS | 27 declare -a EXTRA_OPTIONS |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 58 EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--checked' | 55 EXTRA_VM_OPTIONS[${#EXTRA_VM_OPTIONS[@]}]='--checked' |
| 59 ;; | 56 ;; |
| 60 esac | 57 esac |
| 61 | 58 |
| 62 if test -f "$SNAPSHOT"; then | 59 if test -f "$SNAPSHOT"; then |
| 63 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "dart2js" \ | 60 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "dart2js" \ |
| 64 "${EXTRA_OPTIONS[@]}" "$@" | 61 "${EXTRA_OPTIONS[@]}" "$@" |
| 65 else | 62 else |
| 66 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$DART2JS" "${EXTRA_OPTIONS[@]}" "$@" | 63 exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$DART2JS" "${EXTRA_OPTIONS[@]}" "$@" |
| 67 fi | 64 fi |
| OLD | NEW |