Skip to content

Add Flutter tree min version check #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ image: Visual Studio 2017
platform: x64

install:
- ps: build\ci\install_flutter.ps1 $env:APPVEYOR_BUILD_FOLDER\..
# None of the packaged channels are new enough for the current state
# of FDE, so for now clone master instead.
#- ps: build\ci\install_flutter.ps1 $env:APPVEYOR_BUILD_FOLDER\..
- git clone -b master https://github.com/flutter/flutter.git %APPVEYOR_BUILD_FOLDER%\..\flutter

build_script:
- msbuild "example\windows_fde\Example Embedder.sln"
4 changes: 2 additions & 2 deletions build/ci/install_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

set -e

readonly CHANNEL="stable"
readonly VERSION="1.0.0"
readonly CHANNEL="dev"
readonly VERSION="1.1.8"

if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
readonly FLUTTER_OS="linux"
Expand Down
20 changes: 20 additions & 0 deletions tools/dart_tools/bin/update_flutter_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:path/path.dart' as path;
import 'package:archive/archive.dart';

import '../lib/flutter_utils.dart';
import '../lib/git_utils.dart';

/// The filename stored next to a downloaded engine library to indicate its
/// version.
Expand Down Expand Up @@ -84,6 +85,9 @@ Future<void> main(List<String> arguments) async {
'is present.\n'
'Defaults to a "flutter" directory next to this repository.',
defaultsTo: getDefaultFlutterRoot())
..addFlag('skip_min_version_check',
help: 'If set, skips the initial check that the Flutter tree whose '
'engine version is being fetched is new enough for the framework.')
..addOption(
'hash',
// Note: engine_override takes precedence over this flag so that
Expand Down Expand Up @@ -112,6 +116,22 @@ Future<void> main(List<String> arguments) async {
final String flutterRoot = parsedArguments['flutter_root'];
final outputRoot = path.canonicalize(path.absolute(parsedArguments.rest[0]));

// TODO: Consider making a setup script that should be run after any update,
// which checks/fetches dependencies, and moving this check there. For now,
// do it here since it's a hook that's run on every build.
if (!parsedArguments['skip_min_version_check']) {
bool containsRequiredCommit = await gitHeadContainsCommit(
flutterRoot, lastKnownRequiredFlutterCommit);
if (!containsRequiredCommit) {
print('Flutter engine update aborted: Your Flutter tree is too '
'old for use with this project. Please update to a newer version of '
'Flutter, then try again.\n\n'
'Note that this may require switching to Flutter master. See:\n'
'https://github.com/flutter/flutter/wiki/Flutter-build-release-channels');
exit(1);
}
}

final engineOverrideBuildType = await getEngineOverrideBuildType();
if (engineOverrideBuildType == null) {
final String targetHash =
Expand Down
8 changes: 8 additions & 0 deletions tools/dart_tools/lib/flutter_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import 'dart:io';

import 'package:path/path.dart' as path;

/// The last Flutter hash that's known to be required; a branch that doesn't
/// contain this commit will either fail to build, or fail to run.
///
/// This should be updated whenever a new dependency is introduced (e.g., a
/// required embedder API addition or implementation fix).
const String lastKnownRequiredFlutterCommit =
'390ded9340e529b8475fefd1afdbe59c5b8d4081';

/// Returns the path to the root of this repository.
///
/// Relies on the known location of dart_tools/bin within the repo, and the fact
Expand Down
33 changes: 33 additions & 0 deletions tools/dart_tools/lib/git_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the 'License');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an 'AS IS' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Wrappers for git commands used by the tools.

import 'run_command.dart';

/// Returns true if the current
Future<bool> gitHeadContainsCommit(
String repositoryRoot, String commitHash) async {
final exitCode = await runCommand(
'git',
[
'merge-base',
'--is-ancestor',
commitHash,
'HEAD',
],
workingDirectory: repositoryRoot,
allowFail: true);
return exitCode == 0;
}