dart-sdk/sdk/bin/dart
Stan Manilov ac8a228d0b sdk/dart now detects an available build
The shell scripts in sdk/sdk are using ReleaseIA32 as the default build
configuration in the case one is not provided as an environment
variable. This is arbitrary so a check of the available builds is
performed and if ReleaseIA32 is available it is selected. Otherwise, an
arbitrary configuration is selected (currently the last one
lexicographically). In the case where there are no subfolders in the
"out" folder, ReleaseIA32 is selected, in order to produce the same
error that used to be produced before (this can be changed to a custom
message for user-friendliness).

Currently only the "dart" shell script is changed and if the change is
accepted, the others will be changed too.

R=floitsch@google.com, zerny@google.com

Review URL: https://codereview.chromium.org//1276333002 .
2015-08-12 15:19:23 +02:00

58 lines
1.5 KiB
Bash
Executable file

#!/bin/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=("ReleaseIA32" "ReleaseX64" "DebugIA32" "DebugX64"
"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 "$@"