mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
fadca3983a
This parallels the change to sdk/bin/dart made by commit
ac8a228d0b
.
R=floitsch@google.com
Review URL: https://codereview.chromium.org/1650383002 .
92 lines
2.3 KiB
Bash
Executable file
92 lines
2.3 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.
|
|
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
|
|
|
SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)"
|
|
|
|
DART="$BIN_DIR/dart"
|
|
|
|
unset EXTRA_OPTIONS
|
|
declare -a EXTRA_OPTIONS
|
|
|
|
if test -t 1; then
|
|
# Stdout is a terminal.
|
|
if test 8 -le `tput colors`; then
|
|
# Stdout has at least 8 colors, so enable colors.
|
|
EXTRA_OPTIONS+=('--enable-diagnostic-colors')
|
|
fi
|
|
fi
|
|
|
|
unset EXTRA_VM_OPTIONS
|
|
declare -a EXTRA_VM_OPTIONS
|
|
|
|
case $0 in
|
|
*_developer)
|
|
EXTRA_VM_OPTIONS+=('--checked')
|
|
;;
|
|
esac
|
|
|
|
# We allow extra vm options to be passed in through an environment variable.
|
|
if [[ $DART_VM_OPTIONS ]]; then
|
|
read -a OPTIONS <<< "$DART_VM_OPTIONS"
|
|
EXTRA_VM_OPTIONS+=("${OPTIONS[@]}")
|
|
fi
|
|
|
|
DART_ROOT="$(cd "${SDK_DIR}/.." ; pwd -P)"
|
|
|
|
DART2JS="$DART_ROOT/pkg/compiler/lib/src/dart2js.dart"
|
|
|
|
if [[ `uname` == 'Darwin' ]]; then
|
|
OUT_DIR="$DART_ROOT/xcodebuild/"
|
|
else
|
|
OUT_DIR="$DART_ROOT/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
|
|
|
|
BUILD_DIR="$OUT_DIR$DART_CONFIGURATION"
|
|
|
|
PACKAGE_ROOT="$BUILD_DIR/packages/"
|
|
|
|
exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "--package-root=$PACKAGE_ROOT" "$DART2JS" "${EXTRA_OPTIONS[@]}" "$@"
|