Unverified Commit 44b22c7b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Fix cache location, artifacts, and re-enable dart2js test (#29783)

parent 7cf4a6df
...@@ -213,22 +213,21 @@ Future<void> _runBuildTests() async { ...@@ -213,22 +213,21 @@ Future<void> _runBuildTests() async {
await _flutterBuildApk(path); await _flutterBuildApk(path);
await _flutterBuildIpa(path); await _flutterBuildIpa(path);
} }
// TODO(jonahwilliams): re-enable when engine rolls. await _flutterBuildDart2js(path.join('dev', 'integration_tests', 'web'));
//await _flutterBuildDart2js(path.join('dev', 'integration_tests', 'web'));
print('${bold}DONE: All build tests successful.$reset'); print('${bold}DONE: All build tests successful.$reset');
} }
// Future<void> _flutterBuildDart2js(String relativePathToApplication) async { Future<void> _flutterBuildDart2js(String relativePathToApplication) async {
// print('Running Dart2JS build tests...'); print('Running Dart2JS build tests...');
// await runCommand(flutter, await runCommand(flutter,
// <String>['build', 'web', '-v'], <String>['build', 'web', '-v'],
// workingDirectory: path.join(flutterRoot, relativePathToApplication), workingDirectory: path.join(flutterRoot, relativePathToApplication),
// expectNonZeroExit: false, expectNonZeroExit: false,
// timeout: _kShortTimeout, timeout: _kShortTimeout,
// ); );
// print('Done.'); print('Done.');
// } }
Future<void> _flutterBuildAot(String relativePathToApplication) async { Future<void> _flutterBuildAot(String relativePathToApplication) async {
print('Running AOT build tests...'); print('Running AOT build tests...');
......
...@@ -28,6 +28,7 @@ enum Artifact { ...@@ -28,6 +28,7 @@ enum Artifact {
engineDartBinary, engineDartBinary,
dart2jsSnapshot, dart2jsSnapshot,
kernelWorkerSnapshot, kernelWorkerSnapshot,
flutterWebSdk,
} }
String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) {
...@@ -66,6 +67,9 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo ...@@ -66,6 +67,9 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
case Artifact.flutterPatchedSdkPath: case Artifact.flutterPatchedSdkPath:
assert(false, 'No filename for sdk path, should not be invoked'); assert(false, 'No filename for sdk path, should not be invoked');
return null; return null;
case Artifact.flutterWebSdk:
assert(false, 'No filename for web sdk path, should not be invoked');
return null;
case Artifact.engineDartSdkPath: case Artifact.engineDartSdkPath:
return 'dart-sdk'; return 'dart-sdk';
case Artifact.frontendServerSnapshotForEngineDartSdk: case Artifact.frontendServerSnapshotForEngineDartSdk:
...@@ -73,9 +77,9 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo ...@@ -73,9 +77,9 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
case Artifact.engineDartBinary: case Artifact.engineDartBinary:
return 'dart'; return 'dart';
case Artifact.dart2jsSnapshot: case Artifact.dart2jsSnapshot:
return 'flutter_dart2js.dart.snapshot'; return 'dart2js.dart.snapshot';
case Artifact.kernelWorkerSnapshot: case Artifact.kernelWorkerSnapshot:
return 'flutter_kernel_worker.dart.snapshot'; return 'kernel_worker.dart.snapshot';
} }
assert(false, 'Invalid artifact $artifact.'); assert(false, 'Invalid artifact $artifact.');
return null; return null;
...@@ -174,6 +178,10 @@ class CachedArtifacts extends Artifacts { ...@@ -174,6 +178,10 @@ class CachedArtifacts extends Artifacts {
return fs.path.join(engineArtifactsPath, 'common', 'flutter_patched_sdk'); return fs.path.join(engineArtifactsPath, 'common', 'flutter_patched_sdk');
} }
String _getFlutterWebSdkPath() {
return cache.getWebSdkDirectory().path;
}
String _getHostArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) { String _getHostArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
switch (artifact) { switch (artifact) {
case Artifact.genSnapshot: case Artifact.genSnapshot:
...@@ -197,6 +205,8 @@ class CachedArtifacts extends Artifacts { ...@@ -197,6 +205,8 @@ class CachedArtifacts extends Artifacts {
return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact)); return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact));
case Artifact.flutterPatchedSdkPath: case Artifact.flutterPatchedSdkPath:
return _getFlutterPatchedSdkPath(); return _getFlutterPatchedSdkPath();
case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath();
case Artifact.dart2jsSnapshot: case Artifact.dart2jsSnapshot:
return fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact)); return fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
case Artifact.kernelWorkerSnapshot: case Artifact.kernelWorkerSnapshot:
...@@ -271,6 +281,8 @@ class LocalEngineArtifacts extends Artifacts { ...@@ -271,6 +281,8 @@ class LocalEngineArtifacts extends Artifacts {
return fs.path.join(engineOutPath, _artifactToFileName(artifact)); return fs.path.join(engineOutPath, _artifactToFileName(artifact));
case Artifact.flutterPatchedSdkPath: case Artifact.flutterPatchedSdkPath:
return _getFlutterPatchedSdkPath(); return _getFlutterPatchedSdkPath();
case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath();
case Artifact.frontendServerSnapshotForEngineDartSdk: case Artifact.frontendServerSnapshotForEngineDartSdk:
return fs.path.join(_hostEngineOutPath, 'gen', _artifactToFileName(artifact)); return fs.path.join(_hostEngineOutPath, 'gen', _artifactToFileName(artifact));
case Artifact.engineDartSdkPath: case Artifact.engineDartSdkPath:
...@@ -295,6 +307,10 @@ class LocalEngineArtifacts extends Artifacts { ...@@ -295,6 +307,10 @@ class LocalEngineArtifacts extends Artifacts {
return fs.path.join(engineOutPath, 'flutter_patched_sdk'); return fs.path.join(engineOutPath, 'flutter_patched_sdk');
} }
String _getFlutterWebSdkPath() {
return fs.path.join(engineOutPath, 'flutter_web_sdk');
}
String _genSnapshotPath() { String _genSnapshotPath() {
const List<String> clangDirs = <String>['.', 'clang_x86', 'clang_x64', 'clang_i386']; const List<String> clangDirs = <String>['.', 'clang_x86', 'clang_x64', 'clang_i386'];
final String genSnapshotName = _artifactToFileName(Artifact.genSnapshot); final String genSnapshotName = _artifactToFileName(Artifact.genSnapshot);
......
...@@ -378,7 +378,7 @@ class FlutterWebSdk extends CachedArtifact { ...@@ -378,7 +378,7 @@ class FlutterWebSdk extends CachedArtifact {
String get version => cache.getVersionFor('engine'); String get version => cache.getVersionFor('engine');
@override @override
Future<void> updateInner() { Future<void> updateInner() async {
String platformName = 'flutter-web-sdk-'; String platformName = 'flutter-web-sdk-';
if (platform.isMacOS) { if (platform.isMacOS) {
platformName += 'darwin-x64'; platformName += 'darwin-x64';
...@@ -388,7 +388,20 @@ class FlutterWebSdk extends CachedArtifact { ...@@ -388,7 +388,20 @@ class FlutterWebSdk extends CachedArtifact {
platformName += 'windows-x64'; platformName += 'windows-x64';
} }
final Uri url = Uri.parse('$_storageBaseUrl/flutter_infra/flutter/$version/$platformName.zip'); final Uri url = Uri.parse('$_storageBaseUrl/flutter_infra/flutter/$version/$platformName.zip');
return _downloadZipArchive('Downloading Web SDK...', url, location); await _downloadZipArchive('Downloading Web SDK...', url, location);
// This is a temporary work-around for not being able to safely download into a shared directory.
for (FileSystemEntity entity in location.listSync(recursive: true)) {
if (entity is File) {
final List<String> segments = fs.path.split(entity.path);
segments.remove('flutter_web_sdk');
final String newPath = fs.path.joinAll(segments);
final File newFile = fs.file(newPath);
if (!newFile.existsSync()) {
newFile.createSync(recursive: true);
}
entity.copySync(newPath);
}
}
} }
} }
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
import 'dart:async'; import 'dart:async';
import '../base/common.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command.dart' show ExitStatus, FlutterCommandResult; import '../runner/flutter_command.dart' show FlutterCommandResult;
import '../web/compile.dart'; import '../web/compile.dart';
import 'build.dart'; import 'build.dart';
...@@ -33,6 +34,9 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -33,6 +34,9 @@ class BuildWebCommand extends BuildSubCommand {
final Status status = logger.startProgress('Compiling $target to JavaScript...', timeout: null); final Status status = logger.startProgress('Compiling $target to JavaScript...', timeout: null);
final int result = await webCompiler.compile(target: target); final int result = await webCompiler.compile(target: target);
status.stop(); status.stop();
return FlutterCommandResult(result == 0 ? ExitStatus.success : ExitStatus.fail); if (result == 1) {
throwToolExit('Failed to compile $target to JavaScript.');
}
return null;
} }
} }
...@@ -28,8 +28,8 @@ class WebCompiler { ...@@ -28,8 +28,8 @@ class WebCompiler {
Future<int> compile({@required String target, bool minify = true, bool enabledAssertions = false}) async { Future<int> compile({@required String target, bool minify = true, bool enabledAssertions = false}) async {
final String engineDartPath = artifacts.getArtifactPath(Artifact.engineDartBinary); final String engineDartPath = artifacts.getArtifactPath(Artifact.engineDartBinary);
final String dart2jsPath = artifacts.getArtifactPath(Artifact.dart2jsSnapshot); final String dart2jsPath = artifacts.getArtifactPath(Artifact.dart2jsSnapshot);
final String flutterPatchedSdkPath = artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath); final String flutterWebSdkPath = artifacts.getArtifactPath(Artifact.flutterWebSdk);
final String librariesPath = fs.path.join(flutterPatchedSdkPath, 'libraries.json'); final String librariesPath = fs.path.join(flutterWebSdkPath, 'libraries.json');
final Directory outputDir = fs.directory(getWebBuildDirectory()); final Directory outputDir = fs.directory(getWebBuildDirectory());
if (!outputDir.existsSync()) { if (!outputDir.existsSync()) {
outputDir.createSync(recursive: true); outputDir.createSync(recursive: true);
...@@ -46,7 +46,6 @@ class WebCompiler { ...@@ -46,7 +46,6 @@ class WebCompiler {
'-o', '-o',
'$outputPath', '$outputPath',
'--libraries-spec=$librariesPath', '--libraries-spec=$librariesPath',
'--platform-binaries=$flutterPatchedSdkPath',
]; ];
if (minify) { if (minify) {
command.add('-m'); command.add('-m');
......
...@@ -22,8 +22,8 @@ void main() { ...@@ -22,8 +22,8 @@ void main() {
const WebCompiler webCompiler = WebCompiler(); const WebCompiler webCompiler = WebCompiler();
final String engineDartPath = artifacts.getArtifactPath(Artifact.engineDartBinary); final String engineDartPath = artifacts.getArtifactPath(Artifact.engineDartBinary);
final String dart2jsPath = artifacts.getArtifactPath(Artifact.dart2jsSnapshot); final String dart2jsPath = artifacts.getArtifactPath(Artifact.dart2jsSnapshot);
final String flutterPatchedSdkPath = artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath); final String flutterWebSdkPath = artifacts.getArtifactPath(Artifact.flutterWebSdk);
final String librariesPath = fs.path.join(flutterPatchedSdkPath, 'libraries.json'); final String librariesPath = fs.path.join(flutterWebSdkPath, 'libraries.json');
when(mockProcess.stdout).thenAnswer((Invocation invocation) => const Stream<List<int>>.empty()); when(mockProcess.stdout).thenAnswer((Invocation invocation) => const Stream<List<int>>.empty());
when(mockProcess.stderr).thenAnswer((Invocation invocation) => const Stream<List<int>>.empty()); when(mockProcess.stderr).thenAnswer((Invocation invocation) => const Stream<List<int>>.empty());
...@@ -41,7 +41,6 @@ void main() { ...@@ -41,7 +41,6 @@ void main() {
'-o', '-o',
outputPath, outputPath,
'--libraries-spec=$librariesPath', '--libraries-spec=$librariesPath',
'--platform-binaries=$flutterPatchedSdkPath',
'-m', '-m',
])).called(1); ])).called(1);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment