mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
![William Hesse](/assets/img/avatar_default.png)
BSD systems don't place bash in /bin and a lot of the dart tools hardcode a #!/bin/bash shebang that fails the 'all' target build (not able to execute dart2js since the interpreter is not found). Solve the issue by using #!/usr/bin/env as the shebang. For scripts that need to pass arguments to bash modify the script to use the set command as the first executed line of shell. BUG= R=whesse@google.com Review URL: https://codereview.chromium.org/1552313002 .
58 lines
1.5 KiB
Bash
Executable file
58 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
# 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.
|
|
|
|
function follow_links() {
|
|
file="$1"
|
|
while [ -h "$file" ]; do
|
|
# On Mac OS, readlink -f doesn't work.
|
|
file="$(readlink "$file")"
|
|
done
|
|
echo "$file"
|
|
}
|
|
|
|
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
|
|
PROG_NAME="$(follow_links "$BASH_SOURCE")"
|
|
|
|
# Handle the case where dart-sdk/bin has been symlinked to.
|
|
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
|
|
|
if [[ `uname` == 'Darwin' ]];
|
|
then
|
|
OUT_DIR="$CUR_DIR"/../../xcodebuild/
|
|
else
|
|
OUT_DIR="$CUR_DIR"/../../out/
|
|
fi
|
|
|
|
if [ -z "$DART_CONFIGURATION" ];
|
|
then
|
|
DIRS=$( ls "$OUT_DIR" )
|
|
# list of possible configurations in decreasing desirability
|
|
CONFIGS=("ReleaseX64" "ReleaseIA32" "DebugX64" "DebugIA32"
|
|
"ReleaseARM" "ReleaseARM64" "ReleaseARMV5TE" "ReleaseMIPS"
|
|
"DebugARM" "DebugARM64" "DebugARMV5TE" "DebugMIPS")
|
|
DART_CONFIGURATION="None"
|
|
for CONFIG in ${CONFIGS[*]}
|
|
do
|
|
for DIR in $DIRS;
|
|
do
|
|
if [ "$CONFIG" = "$DIR" ];
|
|
then
|
|
# choose most desirable configuration that is available and break
|
|
DART_CONFIGURATION="$DIR"
|
|
break 2
|
|
fi
|
|
done
|
|
done
|
|
if [ "$DART_CONFIGURATION" = "None" ]
|
|
then
|
|
echo "No valid dart configuration found in $OUT_DIR"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
BIN_DIR="$OUT_DIR$DART_CONFIGURATION"
|
|
|
|
exec "$BIN_DIR"/dart "$@"
|