Provide flutter sdk kernel files to dwds launcher instead of dart ones (#103436)

* Provide flutter sdk kernel files to dwds launcher instead of dart ones

* Update log test to report all warnings

* Update licences for new files

* Addressed CR comments

* Addressed CR comments
This commit is contained in:
Anna Gringauze
2022-05-11 08:52:43 -07:00
committed by GitHub
parent 7c822310ee
commit 29fecb5980
5 changed files with 105 additions and 19 deletions

View File

@@ -43,6 +43,7 @@ import '../web/chrome.dart';
import '../web/compile.dart';
import '../web/flutter_js.dart' as flutter_js;
import '../web/memory_fs.dart';
import 'sdk_web_configuration.dart';
typedef DwdsLauncher = Future<Dwds> Function({
@required AssetReader assetReader,
@@ -300,6 +301,7 @@ class WebAssetServer implements AssetReader {
).strategy,
expressionCompiler: expressionCompiler,
spawnDds: enableDds,
sdkConfigurationProvider: SdkWebConfigurationProvider(globals.artifacts),
);
shelf.Pipeline pipeline = const shelf.Pipeline();
if (enableDwds) {
@@ -1011,16 +1013,6 @@ void log(logging.LogRecord event) {
if (event.level >= logging.Level.SEVERE) {
globals.printError('${event.loggerName}: ${event.message}$error', stackTrace: event.stackTrace);
} else if (event.level == logging.Level.WARNING) {
// TODO(elliette): Remove the following message suppressions after DWDS is
// >13.1.0, https://github.com/flutter/flutter/issues/101639
const String dartUri = 'DartUri';
if (event.loggerName == dartUri) {
const String webSqlWarning = 'Unresolved uri: dart:web_sql';
const String uiWarning = 'Unresolved uri: dart:ui';
if (event.message == webSqlWarning || event.message == uiWarning) {
return;
}
}
globals.printWarning('${event.loggerName}: ${event.message}$error');
} else {
globals.printTrace('${event.loggerName}: ${event.message}$error');

View File

@@ -0,0 +1,48 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'package:dwds/dwds.dart';
import '../artifacts.dart';
import '../base/file_system.dart';
/// Provides paths to SDK files for dart SDK used in flutter.
class SdkWebConfigurationProvider extends SdkConfigurationProvider {
SdkWebConfigurationProvider(this._artifacts);
final Artifacts _artifacts;
SdkConfiguration _configuration;
/// Create and validate configuration matching the default SDK layout.
/// Create configuration matching the default SDK layout.
@override
Future<SdkConfiguration> get configuration async {
if (_configuration == null) {
final String sdkDir = _artifacts.getHostArtifact(HostArtifact.flutterWebSdk).path;
final String unsoundSdkSummaryPath = _artifacts.getHostArtifact(HostArtifact.webPlatformKernelDill).path;
final String soundSdkSummaryPath = _artifacts.getHostArtifact(HostArtifact.webPlatformSoundKernelDill).path;
final String librariesPath = _artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson).path;
_configuration = SdkConfiguration(
sdkDirectory: sdkDir,
unsoundSdkSummaryPath: unsoundSdkSummaryPath,
soundSdkSummaryPath: soundSdkSummaryPath,
librariesPath: librariesPath,
);
}
return _configuration;
}
/// Validate that SDK configuration exists on disk.
static void validate(SdkConfiguration configuration, { FileSystem fileSystem }) {
configuration.validateSdkDir(fileSystem: fileSystem);
configuration.validateSummaries(fileSystem: fileSystem);
configuration.validateLibrariesSpec(fileSystem: fileSystem);
}
}