[web] Add --local-web-sdk flag and use precompiled platform kernels for dart2js and ddc (#114639)

* Dart2JS build step looks for compiled platform binaries.

* Use new locations of platform binaries.

* Added --local-web-sdk command line flag.

* Need to use the matching frontend server when doing ddc stuff.

* Update packages/flutter_tools/lib/src/test/web_test_compiler.dart

Co-authored-by: Mouad Debbar <mouad.debbar@gmail.com>

* Update packages/flutter_tools/lib/src/runner/flutter_command_runner.dart

Co-authored-by: Mouad Debbar <mouad.debbar@gmail.com>

* Formatting issues.

* Need to use URI format for platform dill.

* Fix resident runner tests.

* Fix analysis issue.

* Fix and add unit tests.

* Add some useful comments.

* Refine doc comments for flags.

Co-authored-by: Mouad Debbar <mouad.debbar@gmail.com>
This commit is contained in:
Jackson Gardner
2022-11-11 17:31:10 -08:00
committed by GitHub
parent 0a5b531ccc
commit 0e9ee3679c
21 changed files with 602 additions and 230 deletions

View File

@@ -50,22 +50,29 @@ class WebTestCompiler {
required BuildInfo buildInfo,
}) async {
LanguageVersion languageVersion = LanguageVersion(2, 8);
HostArtifact platformDillArtifact = HostArtifact.webPlatformSoundKernelDill;
late final String platformDillName;
// TODO(zanderso): to support autodetect this would need to partition the source code into a
// a sound and unsound set and perform separate compilations.
// a sound and unsound set and perform separate compilations
final List<String> extraFrontEndOptions = List<String>.of(buildInfo.extraFrontEndOptions);
if (buildInfo.nullSafetyMode == NullSafetyMode.unsound || buildInfo.nullSafetyMode == NullSafetyMode.autodetect) {
platformDillArtifact = HostArtifact.webPlatformKernelDill;
platformDillName = 'ddc_outline.dill';
if (!extraFrontEndOptions.contains('--no-sound-null-safety')) {
extraFrontEndOptions.add('--no-sound-null-safety');
}
} else if (buildInfo.nullSafetyMode == NullSafetyMode.sound) {
languageVersion = currentLanguageVersion(_fileSystem, Cache.flutterRoot!);
platformDillName = 'ddc_outline_sound.dill';
if (!extraFrontEndOptions.contains('--sound-null-safety')) {
extraFrontEndOptions.add('--sound-null-safety');
}
}
final String platformDillPath = _fileSystem.path.join(
getWebPlatformBinariesDirectory(_artifacts, buildInfo.webRenderer).path,
platformDillName
);
final Directory outputDirectory = _fileSystem.directory(testOutputDir)
..createSync(recursive: true);
final List<File> generatedFiles = <File>[];
@@ -116,9 +123,7 @@ class WebTestCompiler {
initializeFromDill: cachedKernelPath,
targetModel: TargetModel.dartdevc,
extraFrontEndOptions: extraFrontEndOptions,
platformDill: _artifacts
.getHostArtifact(platformDillArtifact)
.absolute.uri.toString(),
platformDill: platformDillPath,
dartDefines: buildInfo.dartDefines,
librariesSpec: _artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson).uri.toString(),
packagesPath: buildInfo.packagesPath,