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 {
await _flutterBuildApk(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');
}
// Future<void> _flutterBuildDart2js(String relativePathToApplication) async {
// print('Running Dart2JS build tests...');
// await runCommand(flutter,
// <String>['build', 'web', '-v'],
// workingDirectory: path.join(flutterRoot, relativePathToApplication),
// expectNonZeroExit: false,
// timeout: _kShortTimeout,
// );
// print('Done.');
// }
Future<void> _flutterBuildDart2js(String relativePathToApplication) async {
print('Running Dart2JS build tests...');
await runCommand(flutter,
<String>['build', 'web', '-v'],
workingDirectory: path.join(flutterRoot, relativePathToApplication),
expectNonZeroExit: false,
timeout: _kShortTimeout,
);
print('Done.');
}
Future<void> _flutterBuildAot(String relativePathToApplication) async {
print('Running AOT build tests...');
......
......@@ -28,6 +28,7 @@ enum Artifact {
engineDartBinary,
dart2jsSnapshot,
kernelWorkerSnapshot,
flutterWebSdk,
}
String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) {
......@@ -66,6 +67,9 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
case Artifact.flutterPatchedSdkPath:
assert(false, 'No filename for sdk path, should not be invoked');
return null;
case Artifact.flutterWebSdk:
assert(false, 'No filename for web sdk path, should not be invoked');
return null;
case Artifact.engineDartSdkPath:
return 'dart-sdk';
case Artifact.frontendServerSnapshotForEngineDartSdk:
......@@ -73,9 +77,9 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
case Artifact.engineDartBinary:
return 'dart';
case Artifact.dart2jsSnapshot:
return 'flutter_dart2js.dart.snapshot';
return 'dart2js.dart.snapshot';
case Artifact.kernelWorkerSnapshot:
return 'flutter_kernel_worker.dart.snapshot';
return 'kernel_worker.dart.snapshot';
}
assert(false, 'Invalid artifact $artifact.');
return null;
......@@ -174,6 +178,10 @@ class CachedArtifacts extends Artifacts {
return fs.path.join(engineArtifactsPath, 'common', 'flutter_patched_sdk');
}
String _getFlutterWebSdkPath() {
return cache.getWebSdkDirectory().path;
}
String _getHostArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
switch (artifact) {
case Artifact.genSnapshot:
......@@ -197,6 +205,8 @@ class CachedArtifacts extends Artifacts {
return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact));
case Artifact.flutterPatchedSdkPath:
return _getFlutterPatchedSdkPath();
case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath();
case Artifact.dart2jsSnapshot:
return fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
case Artifact.kernelWorkerSnapshot:
......@@ -271,6 +281,8 @@ class LocalEngineArtifacts extends Artifacts {
return fs.path.join(engineOutPath, _artifactToFileName(artifact));
case Artifact.flutterPatchedSdkPath:
return _getFlutterPatchedSdkPath();
case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath();
case Artifact.frontendServerSnapshotForEngineDartSdk:
return fs.path.join(_hostEngineOutPath, 'gen', _artifactToFileName(artifact));
case Artifact.engineDartSdkPath:
......@@ -295,6 +307,10 @@ class LocalEngineArtifacts extends Artifacts {
return fs.path.join(engineOutPath, 'flutter_patched_sdk');
}
String _getFlutterWebSdkPath() {
return fs.path.join(engineOutPath, 'flutter_web_sdk');
}
String _genSnapshotPath() {
const List<String> clangDirs = <String>['.', 'clang_x86', 'clang_x64', 'clang_i386'];
final String genSnapshotName = _artifactToFileName(Artifact.genSnapshot);
......
......@@ -378,7 +378,7 @@ class FlutterWebSdk extends CachedArtifact {
String get version => cache.getVersionFor('engine');
@override
Future<void> updateInner() {
Future<void> updateInner() async {
String platformName = 'flutter-web-sdk-';
if (platform.isMacOS) {
platformName += 'darwin-x64';
......@@ -388,7 +388,20 @@ class FlutterWebSdk extends CachedArtifact {
platformName += 'windows-x64';
}
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 @@
import 'dart:async';
import '../base/common.dart';
import '../base/logger.dart';
import '../build_info.dart';
import '../globals.dart';
import '../runner/flutter_command.dart' show ExitStatus, FlutterCommandResult;
import '../runner/flutter_command.dart' show FlutterCommandResult;
import '../web/compile.dart';
import 'build.dart';
......@@ -33,6 +34,9 @@ class BuildWebCommand extends BuildSubCommand {
final Status status = logger.startProgress('Compiling $target to JavaScript...', timeout: null);
final int result = await webCompiler.compile(target: target);
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 {
Future<int> compile({@required String target, bool minify = true, bool enabledAssertions = false}) async {
final String engineDartPath = artifacts.getArtifactPath(Artifact.engineDartBinary);
final String dart2jsPath = artifacts.getArtifactPath(Artifact.dart2jsSnapshot);
final String flutterPatchedSdkPath = artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath);
final String librariesPath = fs.path.join(flutterPatchedSdkPath, 'libraries.json');
final String flutterWebSdkPath = artifacts.getArtifactPath(Artifact.flutterWebSdk);
final String librariesPath = fs.path.join(flutterWebSdkPath, 'libraries.json');
final Directory outputDir = fs.directory(getWebBuildDirectory());
if (!outputDir.existsSync()) {
outputDir.createSync(recursive: true);
......@@ -46,7 +46,6 @@ class WebCompiler {
'-o',
'$outputPath',
'--libraries-spec=$librariesPath',
'--platform-binaries=$flutterPatchedSdkPath',
];
if (minify) {
command.add('-m');
......
......@@ -22,8 +22,8 @@ void main() {
const WebCompiler webCompiler = WebCompiler();
final String engineDartPath = artifacts.getArtifactPath(Artifact.engineDartBinary);
final String dart2jsPath = artifacts.getArtifactPath(Artifact.dart2jsSnapshot);
final String flutterPatchedSdkPath = artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath);
final String librariesPath = fs.path.join(flutterPatchedSdkPath, 'libraries.json');
final String flutterWebSdkPath = artifacts.getArtifactPath(Artifact.flutterWebSdk);
final String librariesPath = fs.path.join(flutterWebSdkPath, 'libraries.json');
when(mockProcess.stdout).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() {
'-o',
outputPath,
'--libraries-spec=$librariesPath',
'--platform-binaries=$flutterPatchedSdkPath',
'-m',
])).called(1);
}, 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