Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 2f1e36d

Browse files
committed
chore(scripts): fix detection of DART_SDK/DART/DARTIUM
Sets the stage to get rid of obsolete DARTSDK.
1 parent 6705183 commit 2f1e36d

File tree

3 files changed

+61
-34
lines changed

3 files changed

+61
-34
lines changed

scripts/env.sh

+59-31
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,79 @@ set -e
44
if [[ -z $ENV_SET ]]; then
55
export ENV_SET=1
66

7-
if [ -n "$DART_SDK" ]; then
8-
DARTSDK=$DART_SDK
7+
# Map DART_SDK and DARTSDK to each other if only one is specified.
8+
#
9+
# TODO(chirayu): Remove this legacy DARTSDK variable support. Check with Misko
10+
# to see if he's using it on this Mac.
11+
if [[ -z "$DART_SDK" ]]; then
12+
: "${DARTSDK:=$DART_SDK}"
913
else
10-
echo "sdk=== $DARTSDK"
11-
DART=`which dart|cat` # pipe to cat to ignore the exit code
12-
DARTSDK=`which dart | sed -e 's/\/dart\-sdk\/.*$/\/dart-sdk/'`
13-
14-
if [ "$DARTSDK" = "/Applications/dart/dart-sdk" ]; then
15-
# Assume we are a mac machine with standard dart setup
16-
export DARTIUM="/Applications/dart/chromium/Chromium.app/Contents/MacOS/Chromium"
17-
else
18-
DARTSDK="`pwd`/dart-sdk"
19-
case $( uname -s ) in
20-
Darwin)
21-
export DARTIUM=${DARTIUM:-./dartium/Chromium.app/Contents/MacOS/Chromium}
22-
;;
23-
Linux)
24-
export DARTIUM=${DARTIUM:-./dartium/chrome}
25-
;;
26-
esac
27-
fi
14+
: "${DART_SDK:=$DARTSDK}"
2815
fi
2916

30-
case $( uname -s ) in
31-
Darwin)
17+
unset DART
18+
PLATFORM="$(uname -s)"
19+
20+
case "$PLATFORM" in
21+
(Darwin)
3222
path=$(readlink ${BASH_SOURCE[0]}||echo './scripts/env.sh')
3323
export NGDART_SCRIPT_DIR=$(dirname $path)
3424
;;
35-
Linux)
25+
(Linux)
3626
export NGDART_SCRIPT_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
3727
;;
28+
(*)
29+
echo Unsupported platform $PLATFORM. Exiting ... >&2
30+
exit 3
31+
;;
3832
esac
33+
3934
export NGDART_BASE_DIR=$(dirname $NGDART_SCRIPT_DIR)
4035

41-
export DART_SDK="$DARTSDK"
36+
# Try to find the SDK alongside the dart command first.
37+
if [[ -z "$DART_SDK" ]]; then
38+
DART=$(which dart) || true
39+
if [[ -x "$DART" ]]; then
40+
DART_SDK="${DART/dart-sdk\/*/dart-sdk}"
41+
if [[ ! -e "$DART_SDK" ]]; then
42+
unset DART DART_SDK
43+
fi
44+
fi
45+
fi
46+
# Fallback: Assume it's alongside the current directory (e.g. Travis).
47+
if [[ -z "$DART_SDK" ]]; then
48+
DART_SDK="$(pwd)/dart-sdk"
49+
fi
50+
51+
: "${DART:=$DART_SDK/bin/dart}"
52+
53+
if [[ ! -x "$DART" ]]; then
54+
echo Unable to locate the dart binary / SDK. Exiting >&2
55+
exit 3
56+
fi
57+
58+
if [[ -z "$DARTIUM" ]]; then
59+
dartiumRoot="$DART_SDK/../chromium"
60+
if [[ -e "$dartiumRoot" ]]; then
61+
case "$PLATFORM" in
62+
(Linux) export DARTIUM="$dartiumRoot/chrome" ;;
63+
(Darwin) export DARTIUM="$dartiumRoot/Chromium.app/Contents/MacOS/Chromium" ;;
64+
(*) echo Unsupported platform $PLATFORM. Exiting ... >&2 ; exit 3 ;;
65+
esac
66+
fi
67+
fi
68+
69+
export DART_SDK
4270
export DARTSDK
43-
export DART=${DART:-"$DARTSDK/bin/dart"}
44-
export PUB=${PUB:-"$DARTSDK/bin/pub"}
45-
export DARTANALYZER=${DARTANALYZER:-"$DARTSDK/bin/dartanalyzer"}
46-
export DARTDOC=${DARTDOC:-"$DARTSDK/bin/dartdoc"}
47-
export DART_DOCGEN=${DART_DOCGEN:-"$DARTSDK/bin/docgen"}
71+
export DART
72+
export PUB=${PUB:-"$DART_SDK/bin/pub"}
73+
export DARTANALYZER=${DARTANALYZER:-"$DART_SDK/bin/dartanalyzer"}
74+
export DARTDOC=${DARTDOC:-"$DART_SDK/bin/dartdoc"}
75+
export DART_DOCGEN=${DART_DOCGEN:-"$DART_SDK/bin/docgen"}
4876
export DART_VM_OPTIONS="--old_gen_heap_size=2048"
4977
export DARTIUM_BIN=${DARTIUM_BIN:-"$DARTIUM"}
5078
export CHROME_BIN=${CHROME_BIN:-"google-chrome"}
51-
export PATH=$PATH:$DARTSDK/bin
79+
export PATH=$PATH:$DART_SDK/bin
5280

5381
echo '*********'
5482
echo '** ENV **'
@@ -66,4 +94,4 @@ if [[ -z $ENV_SET ]]; then
6694
echo NGDART_SCRIPT_DIR=$NGDART_SCRIPT_DIR
6795
$DART --version 2>&1
6896

69-
fi
97+
fi

scripts/generate-documentation.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fi;
5454

5555
# Create a version file from the current build version
5656
doc_version=`head CHANGELOG.md | awk 'NR==2' | sed 's/^# //'`
57-
dartsdk_version=`cat $DARTSDK/version`
57+
dartsdk_version=`cat $DART_SDK/version`
5858
head_sha=`git rev-parse --short HEAD`
5959

6060
echo $doc_version at $head_sha \(with Dart SDK $dartsdk_version\) > docs/VERSION

scripts/travis/install.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ if [[ $BROWSERS =~ "dartium" ]]; then
1616
unzip dartium.zip > /dev/null
1717
rm -rf dartium
1818
rm dartium.zip
19-
mv dartium-* dartium
19+
mv dartium-* chromium
2020
fi
21-

0 commit comments

Comments
 (0)