update_engine.sh 2.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/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.

set -e

FLUTTER_ROOT=$(dirname $(dirname $(dirname "${BASH_SOURCE[0]}")))

ENGINE_STAMP_PATH="$FLUTTER_ROOT/bin/cache/engine.stamp"
ENGINE_VERSION=`cat "$FLUTTER_ROOT/bin/cache/engine.version"`

if [ ! -f "$ENGINE_STAMP_PATH" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP_PATH"` ]; then

  BASE_URL="https://storage.googleapis.com/flutter_infra/flutter/$ENGINE_VERSION"
  PKG_PATH="$FLUTTER_ROOT/bin/cache/pkg"
  mkdir -p -- "$PKG_PATH"

  # sky_engine Package

21
  echo "Downloading Flutter engine $ENGINE_VERSION..."
22 23 24 25 26 27 28 29 30
  ENGINE_PKG_URL="$BASE_URL/sky_engine.zip"
  ENGINE_PKG_ZIP="$FLUTTER_ROOT/bin/cache/sky_engine.zip"
  curl --progress-bar -continue-at=- --location --output "$ENGINE_PKG_ZIP" "$ENGINE_PKG_URL"
  rm -rf -- "$PKG_PATH/sky_engine"
  unzip -o -q "$ENGINE_PKG_ZIP" -d "$PKG_PATH"
  rm -f -- "$ENGINE_PKG_ZIP"

  # sky_services Package

31
  echo "  And corresponding services package..."
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
  SERVICES_PKG_URL="$BASE_URL/sky_services.zip"
  SERVICES_PKG_ZIP="$FLUTTER_ROOT/bin/cache/sky_services.zip"
  curl --progress-bar -continue-at=- --location --output "$SERVICES_PKG_ZIP" "$SERVICES_PKG_URL"
  rm -rf -- "$PKG_PATH/sky_services"
  unzip -o -q "$SERVICES_PKG_ZIP" -d "$PKG_PATH"
  rm -f -- "$SERVICES_PKG_ZIP"

  # Binary artifacts

  ENGINE_ARTIFACT_PATH="$FLUTTER_ROOT/bin/cache/artifacts/engine"
  rm -rf -- "$ENGINE_ARTIFACT_PATH"

  download_artifacts() {
    PLATFORM="$1"

47
    PLATFORM_PATH="$ENGINE_ARTIFACT_PATH/$PLATFORM"
48 49
    mkdir -p -- "$PLATFORM_PATH"

50
    echo "  And corresponding toolchain for $PLATFORM..."
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
    ARTIFACTS_URL="$BASE_URL/$PLATFORM/artifacts.zip"
    ARTIFACTS_ZIP="$PLATFORM_PATH/artifacts.zip"
    curl --progress-bar -continue-at=- --location --output "$ARTIFACTS_ZIP" "$ARTIFACTS_URL"
    unzip -o -q "$ARTIFACTS_ZIP" -d "$PLATFORM_PATH"
    rm -f -- "$ARTIFACTS_ZIP"
  }

  download_artifacts android-arm

  case "$(uname -s)" in
    Darwin)
      download_artifacts darwin-x64
      chmod a+x "$ENGINE_ARTIFACT_PATH/darwin-x64/sky_snapshot"
      ;;
    Linux)
      download_artifacts linux-x64
      chmod a+x "$ENGINE_ARTIFACT_PATH/linux-x64/sky_shell"
      chmod a+x "$ENGINE_ARTIFACT_PATH/linux-x64/sky_snapshot"
      ;;
  esac

  echo "$ENGINE_VERSION" > "$ENGINE_STAMP_PATH"
fi