Internalize our dependency on the Dart SDK
This patch teaches the flutter command to download the Dart SDK into cache, removing another step from the Getting Started workflow. The version of the Dart SDK is controlled by the "dart-sdk.version" file in the bin/cache directory. Fixes #54
This commit is contained in:
1
bin/cache/.gitignore
vendored
1
bin/cache/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
*.snapshot
|
||||
*.stamp
|
||||
artifacts
|
||||
dart-sdk
|
||||
|
||||
1
bin/cache/dart-sdk.version
vendored
Normal file
1
bin/cache/dart-sdk.version
vendored
Normal file
@@ -0,0 +1 @@
|
||||
1.14.1
|
||||
36
bin/cache/update_dart_sdk.sh
vendored
Executable file
36
bin/cache/update_dart_sdk.sh
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
|
||||
DART_SDK_STAMP_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk.stamp"
|
||||
DART_SDK_VERSION=`cat "$FLUTTER_ROOT/bin/cache/dart-sdk.version"`
|
||||
|
||||
if [ ! -f "$DART_SDK_STAMP_PATH" ] || [ "$DART_SDK_VERSION" != `cat "$DART_SDK_STAMP_PATH"` ]; then
|
||||
echo Downloading Dart SDK $DART_SDK_VERSION...
|
||||
|
||||
case "$(uname -s)" in
|
||||
Darwin)
|
||||
DART_ZIP_NAME="dartsdk-macos-x64-release.zip"
|
||||
;;
|
||||
Linux)
|
||||
DART_ZIP_NAME="dartsdk-linux-x64-release.zip"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown operating system. Cannot install Dart SDK."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
DART_SDK_URL="http://gsdview.appspot.com/dart-archive/channels/stable/raw/$DART_SDK_VERSION/sdk/$DART_ZIP_NAME"
|
||||
|
||||
rm -rf "$DART_SDK_PATH"
|
||||
mkdir -p "$DART_SDK_PATH"
|
||||
DART_SDK_ZIP="$FLUTTER_ROOT/bin/cache/dart-sdk.zip"
|
||||
|
||||
curl -C - --location -o "$DART_SDK_ZIP" "$DART_SDK_URL"
|
||||
unzip -o -q "$DART_SDK_ZIP" -d "$FLUTTER_ROOT/bin/cache"
|
||||
rm "$DART_SDK_ZIP"
|
||||
echo $DART_SDK_VERSION > "$DART_SDK_STAMP_PATH"
|
||||
fi
|
||||
34
bin/flutter
34
bin/flutter
@@ -7,26 +7,38 @@ set -e
|
||||
|
||||
export FLUTTER_ROOT=$(dirname $(dirname "${BASH_SOURCE[0]}"))
|
||||
FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools"
|
||||
FLUTTER_DIR="$FLUTTER_ROOT/packages/flutter"
|
||||
SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot"
|
||||
STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp"
|
||||
SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart"
|
||||
DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
|
||||
|
||||
# TODO(abarth): We shouldn't require dart to be on the user's path.
|
||||
DART=dart
|
||||
DART="$DART_SDK_PATH/bin/dart"
|
||||
|
||||
REVISION=`(cd "$FLUTTER_ROOT"; git rev-parse HEAD)`
|
||||
if [ ! -f "$SNAPSHOT_PATH" ] || [ ! -f "$STAMP_PATH" ] || [ `cat "$STAMP_PATH"` != "$REVISION" ] || [ "$FLUTTER_TOOLS_DIR/pubspec.yaml" -nt "$FLUTTER_TOOLS_DIR/pubspec.lock" ]; then
|
||||
echo Updating flutter tool...
|
||||
(cd "$FLUTTER_TOOLS_DIR"; pub get > /dev/null)
|
||||
(cd "$FLUTTER_DIR"; pub get > /dev/null) # Allows us to check if sky_engine's REVISION is correct
|
||||
$DART --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
|
||||
echo -n $REVISION > "$STAMP_PATH"
|
||||
"$FLUTTER_ROOT/bin/cache/update_dart_sdk.sh"
|
||||
|
||||
echo Building flutter tool...
|
||||
FLUTTER_DIR="$FLUTTER_ROOT/packages/flutter"
|
||||
PUB="$DART_SDK_PATH/bin/pub"
|
||||
|
||||
(cd "$FLUTTER_TOOLS_DIR"; "$PUB" get > /dev/null)
|
||||
(cd "$FLUTTER_DIR"; "$PUB" get > /dev/null) # Allows us to check if sky_engine's REVISION is correct
|
||||
"$DART" --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
|
||||
echo $REVISION > "$STAMP_PATH"
|
||||
fi
|
||||
|
||||
# Add our internalized version of the Dart SDK to the path ahead of any other
|
||||
# versions that might be installed on this machine.
|
||||
#
|
||||
# TODO(abarth): We should teach flutter_tools to our version of the Dart SDK
|
||||
# explicitly instead of relying upon the PATH.
|
||||
#
|
||||
export PATH="$DART_SDK_PATH/bin:$PATH"
|
||||
|
||||
set +e
|
||||
|
||||
$DART "$SNAPSHOT_PATH" "$@"
|
||||
"$DART" "$SNAPSHOT_PATH" "$@"
|
||||
|
||||
# The VM exits with code 253 if the snapshot version is out-of-date.
|
||||
# If it is, we need to snapshot it again.
|
||||
@@ -37,5 +49,5 @@ fi
|
||||
|
||||
set -e
|
||||
|
||||
$DART --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
|
||||
$DART "$SNAPSHOT_PATH" "$@"
|
||||
"$DART" --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
|
||||
"$DART" "$SNAPSHOT_PATH" "$@"
|
||||
|
||||
Reference in New Issue
Block a user