blob: 76177c569a35cf2304c2b761118fd06bd333f830 [file] [log] [blame]
Adam Barth94c59492016-02-15 00:07:42 -08001#!/bin/bash
2# Copyright 2016 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
Ian Hickson9a00bec2016-02-15 11:01:30 -08006set -e
7
Chris Brackenab939ec2016-10-28 08:32:30 -07008FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
Adam Barth4aae7182016-02-20 10:13:05 -08009
Adam Barth94c59492016-02-15 00:07:42 -080010DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
11DART_SDK_STAMP_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk.stamp"
Dan Rubel94a83af2016-10-07 15:24:19 -040012DART_SDK_VERSION=`cat "$FLUTTER_ROOT/bin/internal/dart-sdk.version"`
Adam Barth94c59492016-02-15 00:07:42 -080013
14if [ ! -f "$DART_SDK_STAMP_PATH" ] || [ "$DART_SDK_VERSION" != `cat "$DART_SDK_STAMP_PATH"` ]; then
Ian Hickson9a00bec2016-02-15 11:01:30 -080015 echo "Downloading Dart SDK $DART_SDK_VERSION..."
Adam Barth94c59492016-02-15 00:07:42 -080016
17 case "$(uname -s)" in
18 Darwin)
19 DART_ZIP_NAME="dartsdk-macos-x64-release.zip"
20 ;;
21 Linux)
22 DART_ZIP_NAME="dartsdk-linux-x64-release.zip"
23 ;;
24 *)
25 echo "Unknown operating system. Cannot install Dart SDK."
26 exit 1
27 ;;
28 esac
29
John McCutchan4e63ce52016-02-29 10:53:19 -080030 DART_CHANNEL="stable"
31
32 if [[ $DART_SDK_VERSION == *"-dev."* ]]
33 then
34 DART_CHANNEL="dev"
35 fi
36
Eric Seidel5dae8202016-07-06 13:10:56 -070037 DART_SDK_URL="https://storage.googleapis.com/dart-archive/channels/$DART_CHANNEL/raw/$DART_SDK_VERSION/sdk/$DART_ZIP_NAME"
Adam Barth94c59492016-02-15 00:07:42 -080038
Ian Hickson9a00bec2016-02-15 11:01:30 -080039 rm -rf -- "$DART_SDK_PATH"
40 mkdir -p -- "$DART_SDK_PATH"
Adam Barth94c59492016-02-15 00:07:42 -080041 DART_SDK_ZIP="$FLUTTER_ROOT/bin/cache/dart-sdk.zip"
42
Ian Hickson9a00bec2016-02-15 11:01:30 -080043 curl --progress-bar -continue-at=- --location --output "$DART_SDK_ZIP" "$DART_SDK_URL"
Dan Rubel1b9c1bd2016-10-06 15:32:03 -040044 unzip -o -q "$DART_SDK_ZIP" -d "$FLUTTER_ROOT/bin/cache" || {
45 echo
46 echo "It appears that the downloaded file is corrupt; please try the operation again later."
47 echo "If this problem persists, please report the problem at"
48 echo "https://github.com/flutter/flutter/issues/new"
49 echo
50 rm -f -- "$DART_SDK_ZIP"
51 exit 1
52 }
Ian Hickson9a00bec2016-02-15 11:01:30 -080053 rm -f -- "$DART_SDK_ZIP"
54 echo "$DART_SDK_VERSION" > "$DART_SDK_STAMP_PATH"
Adam Barth94c59492016-02-15 00:07:42 -080055fi