flutter 1.32 KB
Newer Older
1 2 3 4 5
#!/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.

6 7
set -e

8
export FLUTTER_ROOT=$(dirname $(dirname "${BASH_SOURCE[0]}"))
9 10 11
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"
12
SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart"
13 14 15 16 17

# TODO(abarth): We shouldn't require dart to be on the user's path.
DART=dart

REVISION=`(cd "$FLUTTER_ROOT"; git rev-parse HEAD)`
18
if [ ! -f "$SNAPSHOT_PATH" ] || [ ! -f "$STAMP_PATH" ] || [ `cat "$STAMP_PATH"` != "$REVISION" ] || [ "$FLUTTER_TOOLS_DIR/pubspec.yaml" -nt "$FLUTTER_TOOLS_DIR/pubspec.lock" ]; then
Hixie's avatar
Hixie committed
19
  echo Updating flutter tool...
20
  (cd "$FLUTTER_TOOLS_DIR"; pub get > /dev/null)
21
  $DART --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
22 23 24
  echo -n $REVISION > "$STAMP_PATH"
fi

25 26
set +e

27
$DART "$SNAPSHOT_PATH" "$@"
28 29 30 31 32 33 34 35

# 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

36 37
set -e

38 39
$DART --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
$DART "$SNAPSHOT_PATH" "$@"