Skip to content

Commit f3116cd

Browse files
chirayukDiana Salsbury
authored and
Diana Salsbury
committed
chore(scripts): fix detection of DART_SDK/DART/DARTIUM
Sets the stage to get rid of obsolete DARTSDK.
1 parent f26dcaa commit f3116cd

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
@@ -7,51 +7,79 @@ else
77
export ENV_SET=1
88
fi
99

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

33-
case $( uname -s ) in
34-
Darwin)
20+
unset DART
21+
PLATFORM="$(uname -s)"
22+
23+
case "$PLATFORM" in
24+
(Darwin)
3525
path=$(readlink ${BASH_SOURCE[0]}||echo './scripts/env.sh')
3626
export NGDART_SCRIPT_DIR=$(dirname $path)
3727
;;
38-
Linux)
28+
(Linux)
3929
export NGDART_SCRIPT_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
4030
;;
31+
(*)
32+
echo Unsupported platform $PLATFORM. Exiting ... >&2
33+
exit 3
34+
;;
4135
esac
36+
4237
export NGDART_BASE_DIR=$(dirname $NGDART_SCRIPT_DIR)
4338

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

5684
echo '*********'
5785
echo '** ENV **'
@@ -69,4 +97,4 @@ fi
6997
echo NGDART_SCRIPT_DIR=$NGDART_SCRIPT_DIR
7098
$DART --version 2>&1
7199

72-
fi
100+
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)