mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Use already downloaded dart sdk for frontend_server. (#14702)
* Use already downloaded dart sdk for frontend_server. This is follow-up to https://github.com/flutter/flutter/pull/14610 * Remove reference to engine dart-sdk from artifacts * Remove unused imports * WIP to switch back to solution where dart sdk is downloaded into bin/cache/dart-sdk, but it is 'flutter precache -a' that can download all dart sdks for other platforms under bin/cache/artifacts/engine/<platform>/dart-sdk * Download all dart sdks when 'flutter precache -a'
This commit is contained in:
parent
08db0d83d7
commit
c0c6c60b8f
@ -1 +0,0 @@
|
||||
2.0.0-dev.22.0
|
@ -24,7 +24,6 @@ enum Artifact {
|
||||
platformLibrariesJson,
|
||||
flutterPatchedSdkPath,
|
||||
frontendServerSnapshotForEngineDartSdk,
|
||||
engineDartSdkPath,
|
||||
}
|
||||
|
||||
String _artifactToFileName(Artifact artifact) {
|
||||
@ -52,8 +51,6 @@ String _artifactToFileName(Artifact artifact) {
|
||||
case Artifact.flutterPatchedSdkPath:
|
||||
assert(false, 'No filename for sdk path, should not be invoked');
|
||||
return null;
|
||||
case Artifact.engineDartSdkPath:
|
||||
return 'dart-sdk';
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
return 'frontend_server.dart.snapshot';
|
||||
}
|
||||
@ -164,7 +161,6 @@ class CachedArtifacts extends Artifacts {
|
||||
case Artifact.vmSnapshotData:
|
||||
case Artifact.isolateSnapshotData:
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
case Artifact.engineDartSdkPath:
|
||||
final String engineArtifactsPath = cache.getArtifactDirectory('engine').path;
|
||||
final String platformDirName = getNameForTargetPlatform(platform);
|
||||
return fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact));
|
||||
@ -248,8 +244,6 @@ class LocalEngineArtifacts extends Artifacts {
|
||||
return _getFlutterPatchedSdkPath();
|
||||
case Artifact.frontendServerSnapshotForEngineDartSdk:
|
||||
return fs.path.join(_hostEngineOutPath, 'gen', _artifactToFileName(artifact));
|
||||
case Artifact.engineDartSdkPath:
|
||||
return fs.path.join(_hostEngineOutPath, 'dart-sdk');
|
||||
}
|
||||
assert(false, 'Invalid artifact $artifact.');
|
||||
return null;
|
||||
|
@ -8,12 +8,10 @@ import 'package:meta/meta.dart';
|
||||
|
||||
import 'base/context.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/io.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/net.dart';
|
||||
import 'base/os.dart';
|
||||
import 'base/platform.dart';
|
||||
import 'base/process_manager.dart';
|
||||
import 'globals.dart';
|
||||
|
||||
/// A wrapper around the `bin/cache/` directory.
|
||||
@ -118,32 +116,6 @@ class Cache {
|
||||
return _engineRevision;
|
||||
}
|
||||
|
||||
String _engineDartVersion;
|
||||
|
||||
String get engineDartVersion {
|
||||
if (_engineDartVersion == null) {
|
||||
final Directory engineDirectory = getArtifactDirectory('engine');
|
||||
|
||||
List<String> dartSdkBinParts;
|
||||
if (platform.isLinux) {
|
||||
dartSdkBinParts = <String>['linux-x64', 'dart-sdk', 'bin', 'dart'];
|
||||
} else if (platform.isMacOS) {
|
||||
dartSdkBinParts = <String>['darwin-x64', 'dart-sdk', 'bin', 'dart'];
|
||||
} else if (platform.isWindows) {
|
||||
dartSdkBinParts = <String>['windows-x64', 'dart-sdk', 'bin', 'dart.exe'];
|
||||
} else {
|
||||
// Unknown platform, we can't derive version.
|
||||
return null;
|
||||
}
|
||||
final File dartSdkBin = engineDirectory.childFile(fs.path.joinAll(dartSdkBinParts));
|
||||
final ProcessResult result = processManager.runSync(<String>[dartSdkBin.path, '--version']);
|
||||
// https://github.com/dart-lang/sdk/issues/31481
|
||||
// We can use the process utils directly when this is fixed instead of parsing stderr.
|
||||
_engineDartVersion = result.stderr.trim().replaceAll('Dart VM version: ', '');
|
||||
}
|
||||
return _engineDartVersion;
|
||||
}
|
||||
|
||||
static Cache get instance => context[Cache];
|
||||
|
||||
/// Return the top-level directory in the cache; this is `bin/cache`.
|
||||
@ -364,7 +336,8 @@ class FlutterEngine extends CachedArtifact {
|
||||
..addAll(_linuxBinaryDirs)
|
||||
..addAll(_windowsBinaryDirs)
|
||||
..addAll(_androidBinaryDirs)
|
||||
..addAll(_iosBinaryDirs);
|
||||
..addAll(_iosBinaryDirs)
|
||||
..addAll(_dartSdks);
|
||||
else if (platform.isLinux)
|
||||
binaryDirs
|
||||
..addAll(_linuxBinaryDirs)
|
||||
@ -384,7 +357,6 @@ class FlutterEngine extends CachedArtifact {
|
||||
|
||||
List<List<String>> get _osxBinaryDirs => <List<String>>[
|
||||
<String>['darwin-x64', 'darwin-x64/artifacts.zip'],
|
||||
<String>['darwin-x64', 'dart-sdk-darwin-x64.zip'],
|
||||
<String>['android-arm-profile/darwin-x64', 'android-arm-profile/darwin-x64.zip'],
|
||||
<String>['android-arm-release/darwin-x64', 'android-arm-release/darwin-x64.zip'],
|
||||
<String>['android-arm64-profile/darwin-x64', 'android-arm64-profile/darwin-x64.zip'],
|
||||
@ -393,7 +365,6 @@ class FlutterEngine extends CachedArtifact {
|
||||
|
||||
List<List<String>> get _linuxBinaryDirs => <List<String>>[
|
||||
<String>['linux-x64', 'linux-x64/artifacts.zip'],
|
||||
<String>['linux-x64', 'dart-sdk-linux-x64.zip'],
|
||||
<String>['android-arm-profile/linux-x64', 'android-arm-profile/linux-x64.zip'],
|
||||
<String>['android-arm-release/linux-x64', 'android-arm-release/linux-x64.zip'],
|
||||
<String>['android-arm64-profile/linux-x64', 'android-arm64-profile/linux-x64.zip'],
|
||||
@ -402,7 +373,6 @@ class FlutterEngine extends CachedArtifact {
|
||||
|
||||
List<List<String>> get _windowsBinaryDirs => <List<String>>[
|
||||
<String>['windows-x64', 'windows-x64/artifacts.zip'],
|
||||
<String>['windows-x64', 'dart-sdk-windows-x64.zip'],
|
||||
<String>['android-arm-profile/windows-x64', 'android-arm-profile/windows-x64.zip'],
|
||||
<String>['android-arm-release/windows-x64', 'android-arm-release/windows-x64.zip'],
|
||||
<String>['android-arm64-profile/windows-x64', 'android-arm64-profile/windows-x64.zip'],
|
||||
@ -426,6 +396,12 @@ class FlutterEngine extends CachedArtifact {
|
||||
<String>['ios-release', 'ios-release/artifacts.zip'],
|
||||
];
|
||||
|
||||
List<List<String>> get _dartSdks => <List<String>> [
|
||||
<String>['darwin-x64', 'dart-sdk-darwin-x64.zip'],
|
||||
<String>['linux-x64', 'dart-sdk-linux-x64.zip'],
|
||||
<String>['windows-x64', 'dart-sdk-windows-x64.zip'],
|
||||
];
|
||||
|
||||
@override
|
||||
bool isUpToDateInner() {
|
||||
final Directory pkgDir = cache.getCacheDir('pkg');
|
||||
|
@ -8,22 +8,14 @@ import 'dart:convert';
|
||||
import 'package:usage/uuid/uuid.dart';
|
||||
|
||||
import 'artifacts.dart';
|
||||
import 'base/common.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/io.dart';
|
||||
import 'base/process_manager.dart';
|
||||
import 'dart/sdk.dart';
|
||||
import 'globals.dart';
|
||||
|
||||
String _dartExecutable() {
|
||||
final String engineDartSdkPath = artifacts.getArtifactPath(
|
||||
Artifact.engineDartSdkPath
|
||||
);
|
||||
if (!fs.isDirectorySync(engineDartSdkPath)) {
|
||||
throwToolExit('No dart sdk Flutter host engine build found at $engineDartSdkPath.\n'
|
||||
'Note that corresponding host engine build is required even when targeting particular device platforms.',
|
||||
exitCode: 2);
|
||||
}
|
||||
return fs.path.join(engineDartSdkPath, 'bin', 'dart');
|
||||
return fs.path.join(dartSdkPath, 'bin', 'dart');
|
||||
}
|
||||
|
||||
class _StdoutHandler {
|
||||
|
@ -258,8 +258,7 @@ class _FlutterValidator extends DoctorValidator {
|
||||
'(${version.frameworkAge}), ${version.frameworkDate}'
|
||||
));
|
||||
messages.add(new ValidationMessage('Engine revision ${version.engineRevisionShort}'));
|
||||
messages.add(new ValidationMessage('Tools Dart version ${version.dartSdkVersion}'));
|
||||
messages.add(new ValidationMessage('Engine Dart version ${version.engineDartVersion}'));
|
||||
messages.add(new ValidationMessage('Dart version ${version.dartSdkVersion}'));
|
||||
final String genSnapshotPath =
|
||||
artifacts.getArtifactPath(Artifact.genSnapshot);
|
||||
|
||||
|
@ -83,7 +83,6 @@ class FlutterVersion {
|
||||
String get frameworkDate => frameworkCommitDate;
|
||||
|
||||
String get dartSdkVersion => Cache.instance.dartSdkVersion.split(' ')[0];
|
||||
String get engineDartVersion => Cache.instance.engineDartVersion.split(' ')[0];
|
||||
|
||||
String get engineRevision => Cache.instance.engineRevision;
|
||||
String get engineRevisionShort => _shortGitRevision(engineRevision);
|
||||
|
@ -89,10 +89,6 @@ void main() {
|
||||
artifacts.getArtifactPath(Artifact.flutterTester),
|
||||
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'flutter_tester')
|
||||
);
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.engineDartSdkPath),
|
||||
fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk')
|
||||
);
|
||||
}, overrides: <Type, Generator> {
|
||||
Platform: () => new FakePlatform(operatingSystem: 'linux')
|
||||
});
|
||||
|
@ -61,12 +61,6 @@ void main() {
|
||||
_expectVersionMessage('');
|
||||
});
|
||||
|
||||
testFlutterVersion('prints non-empty version for engine Dart SDK', () async {
|
||||
final FlutterVersion version = FlutterVersion.instance;
|
||||
final String engineDartVersion = version.engineDartVersion;
|
||||
expect(engineDartVersion.length, greaterThan(0));
|
||||
});
|
||||
|
||||
testFlutterVersion('does not ping server when version stamp is up-to-date', () async {
|
||||
final FlutterVersion version = FlutterVersion.instance;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user