mirror of
https://github.com/flutter/flutter.git
synced 2026-02-11 13:22:46 +08:00
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
54 lines
1.9 KiB
Bash
Executable File
54 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright 2015 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.
|
|
|
|
set -e
|
|
|
|
export FLUTTER_ROOT=$(dirname $(dirname "${BASH_SOURCE[0]}"))
|
|
FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools"
|
|
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"
|
|
|
|
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
|
|
"$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" "$@"
|
|
|
|
# The VM exits with code 253 if the snapshot version is out-of-date.
|
|
# If it is, we need to snapshot it again.
|
|
EXIT_CODE=$?
|
|
if [ $EXIT_CODE != 253 ]; then
|
|
exit $EXIT_CODE
|
|
fi
|
|
|
|
set -e
|
|
|
|
"$DART" --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
|
|
"$DART" "$SNAPSHOT_PATH" "$@"
|