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:
parent
7c822310ee
commit
29fecb5980
@ -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');
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -76,28 +76,26 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
test('.log() filters events', () => testbed.run(() {
|
||||
// harmless warning that should be filtered out
|
||||
const String harmlessMessage = 'Unresolved uri: dart:ui';
|
||||
// serious warning
|
||||
const String seriousMessage = 'Something bad happened';
|
||||
test('.log() reports warnings', () => testbed.run(() {
|
||||
const String unresolvedUriMessage = 'Unresolved uri:';
|
||||
const String otherMessage = 'Something bad happened';
|
||||
|
||||
final List<logging.LogRecord> events = <logging.LogRecord>[
|
||||
logging.LogRecord(
|
||||
logging.Level.WARNING,
|
||||
harmlessMessage,
|
||||
unresolvedUriMessage,
|
||||
'DartUri',
|
||||
),
|
||||
logging.LogRecord(
|
||||
logging.Level.WARNING,
|
||||
seriousMessage,
|
||||
otherMessage,
|
||||
'DartUri',
|
||||
),
|
||||
];
|
||||
|
||||
events.forEach(log);
|
||||
expect(logger.warningText, contains(seriousMessage));
|
||||
expect(logger.warningText, isNot(contains(harmlessMessage)));
|
||||
expect(logger.warningText, contains(unresolvedUriMessage));
|
||||
expect(logger.warningText, contains(otherMessage));
|
||||
}));
|
||||
|
||||
test('Handles against malformed manifest', () => testbed.run(() async {
|
||||
|
@ -23,6 +23,9 @@ void main() {
|
||||
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
|
||||
await project.setUpIn(tempDir);
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
flutter.stdout.listen((String line) {
|
||||
expect(line, isNot(contains('Unresolved uri:')));
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
|
@ -0,0 +1,45 @@
|
||||
// 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 'package:dwds/dwds.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/isolated/sdk_web_configuration.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
|
||||
void main() {
|
||||
FileSystem fileSystem;
|
||||
|
||||
group('Flutter SDK configuration for web', () {
|
||||
SdkConfiguration configuration;
|
||||
|
||||
setUp(() async {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.directory('HostArtifact.flutterWebSdk').createSync();
|
||||
fileSystem.file('HostArtifact.webPlatformKernelDill').createSync();
|
||||
fileSystem.file('HostArtifact.webPlatformSoundKernelDill').createSync();
|
||||
fileSystem.file('HostArtifact.flutterWebLibrariesJson').createSync();
|
||||
|
||||
final SdkWebConfigurationProvider provider =
|
||||
SdkWebConfigurationProvider(Artifacts.test(fileSystem: fileSystem));
|
||||
configuration = await provider.configuration;
|
||||
});
|
||||
|
||||
testWithoutContext('can be validated', () {
|
||||
SdkWebConfigurationProvider.validate(configuration, fileSystem: fileSystem);
|
||||
});
|
||||
|
||||
testWithoutContext('is correct', () {
|
||||
expect(configuration.sdkDirectory, 'HostArtifact.flutterWebSdk');
|
||||
expect(configuration.unsoundSdkSummaryPath, 'HostArtifact.webPlatformKernelDill');
|
||||
expect(configuration.soundSdkSummaryPath, 'HostArtifact.webPlatformSoundKernelDill');
|
||||
expect(configuration.librariesPath, 'HostArtifact.flutterWebLibrariesJson');
|
||||
expect(configuration.compilerWorkerPath, isNull);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user