Index: dart/sdk/bin/dart2js |
diff --git a/dart/sdk/bin/dart2js b/dart/sdk/bin/dart2js |
index 79a857be83efe500109c4f7c760fa2a9c008f2f9..63d55f933e1acc65741d4ea2a89a250a12094cb6 100755 |
--- a/dart/sdk/bin/dart2js |
+++ b/dart/sdk/bin/dart2js |
@@ -3,12 +3,25 @@ |
# for details. All rights reserved. Use of this source code is governed by a |
# BSD-style license that can be found in the LICENSE file. |
+# The GNU version of readlink which has a -f option isn't available by default |
+# on Mac OS X. So we provide our own version. We try to avoid calling external |
+# programs such as dirname and readlink in the common case (not a symlink). The |
+# reason for this is that we notice an overhead in calling external programs and |
+# this affects script startup time which becomes notiable when running many |
+# compilations in parallel (as it happens, for example, during testing). |
function follow_links() { |
file="$1" |
while [ -h "$file" ]; do |
kustermann
2013/12/06 13:50:41
I think, this doesn't work in all cases, e.g.
/ho
|
- # On Mac OS, readlink -f doesn't work. |
- file="$(readlink "$file")" |
+ target="$(readlink "$file")" |
+ if [[ "$target" != /* ]]; then |
kustermann
2013/12/06 13:50:41
What does this do?
|
+ target="$(dirname "$file")/$target" |
+ fi |
+ file="$target" |
done |
+ # Make sure that ${foo%/*} can be used instead of dirname. |
+ if [ "${file%/*}" = "$file" ]; then |
+ file="./$file" |
+ fi |
kustermann
2013/12/06 13:50:41
Why is that necessary?
(IMHO, a function follow_l
|
echo "$file" |
} |