Skip to content

Commit 29fecb5

Browse files
author
Anna Gringauze
authored
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
1 parent 7c82231 commit 29fecb5

File tree

5 files changed

+105
-19
lines changed

5 files changed

+105
-19
lines changed

packages/flutter_tools/lib/src/isolated/devfs_web.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import '../web/chrome.dart';
4343
import '../web/compile.dart';
4444
import '../web/flutter_js.dart' as flutter_js;
4545
import '../web/memory_fs.dart';
46+
import 'sdk_web_configuration.dart';
4647

4748
typedef DwdsLauncher = Future<Dwds> Function({
4849
@required AssetReader assetReader,
@@ -300,6 +301,7 @@ class WebAssetServer implements AssetReader {
300301
).strategy,
301302
expressionCompiler: expressionCompiler,
302303
spawnDds: enableDds,
304+
sdkConfigurationProvider: SdkWebConfigurationProvider(globals.artifacts),
303305
);
304306
shelf.Pipeline pipeline = const shelf.Pipeline();
305307
if (enableDwds) {
@@ -1011,16 +1013,6 @@ void log(logging.LogRecord event) {
10111013
if (event.level >= logging.Level.SEVERE) {
10121014
globals.printError('${event.loggerName}: ${event.message}$error', stackTrace: event.stackTrace);
10131015
} else if (event.level == logging.Level.WARNING) {
1014-
// TODO(elliette): Remove the following message suppressions after DWDS is
1015-
// >13.1.0, https://github.com/flutter/flutter/issues/101639
1016-
const String dartUri = 'DartUri';
1017-
if (event.loggerName == dartUri) {
1018-
const String webSqlWarning = 'Unresolved uri: dart:web_sql';
1019-
const String uiWarning = 'Unresolved uri: dart:ui';
1020-
if (event.message == webSqlWarning || event.message == uiWarning) {
1021-
return;
1022-
}
1023-
}
10241016
globals.printWarning('${event.loggerName}: ${event.message}$error');
10251017
} else {
10261018
globals.printTrace('${event.loggerName}: ${event.message}$error');
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// @dart = 2.8
6+
7+
import 'dart:async';
8+
9+
import 'package:dwds/dwds.dart';
10+
11+
import '../artifacts.dart';
12+
import '../base/file_system.dart';
13+
14+
/// Provides paths to SDK files for dart SDK used in flutter.
15+
class SdkWebConfigurationProvider extends SdkConfigurationProvider {
16+
17+
SdkWebConfigurationProvider(this._artifacts);
18+
19+
final Artifacts _artifacts;
20+
SdkConfiguration _configuration;
21+
22+
/// Create and validate configuration matching the default SDK layout.
23+
/// Create configuration matching the default SDK layout.
24+
@override
25+
Future<SdkConfiguration> get configuration async {
26+
if (_configuration == null) {
27+
final String sdkDir = _artifacts.getHostArtifact(HostArtifact.flutterWebSdk).path;
28+
final String unsoundSdkSummaryPath = _artifacts.getHostArtifact(HostArtifact.webPlatformKernelDill).path;
29+
final String soundSdkSummaryPath = _artifacts.getHostArtifact(HostArtifact.webPlatformSoundKernelDill).path;
30+
final String librariesPath = _artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson).path;
31+
32+
_configuration = SdkConfiguration(
33+
sdkDirectory: sdkDir,
34+
unsoundSdkSummaryPath: unsoundSdkSummaryPath,
35+
soundSdkSummaryPath: soundSdkSummaryPath,
36+
librariesPath: librariesPath,
37+
);
38+
}
39+
return _configuration;
40+
}
41+
42+
/// Validate that SDK configuration exists on disk.
43+
static void validate(SdkConfiguration configuration, { FileSystem fileSystem }) {
44+
configuration.validateSdkDir(fileSystem: fileSystem);
45+
configuration.validateSummaries(fileSystem: fileSystem);
46+
configuration.validateLibrariesSpec(fileSystem: fileSystem);
47+
}
48+
}

packages/flutter_tools/test/general.shard/web/devfs_web_test.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,26 @@ void main() {
7676
});
7777
});
7878

79-
test('.log() filters events', () => testbed.run(() {
80-
// harmless warning that should be filtered out
81-
const String harmlessMessage = 'Unresolved uri: dart:ui';
82-
// serious warning
83-
const String seriousMessage = 'Something bad happened';
79+
test('.log() reports warnings', () => testbed.run(() {
80+
const String unresolvedUriMessage = 'Unresolved uri:';
81+
const String otherMessage = 'Something bad happened';
8482

8583
final List<logging.LogRecord> events = <logging.LogRecord>[
8684
logging.LogRecord(
8785
logging.Level.WARNING,
88-
harmlessMessage,
86+
unresolvedUriMessage,
8987
'DartUri',
9088
),
9189
logging.LogRecord(
9290
logging.Level.WARNING,
93-
seriousMessage,
91+
otherMessage,
9492
'DartUri',
9593
),
9694
];
9795

9896
events.forEach(log);
99-
expect(logger.warningText, contains(seriousMessage));
100-
expect(logger.warningText, isNot(contains(harmlessMessage)));
97+
expect(logger.warningText, contains(unresolvedUriMessage));
98+
expect(logger.warningText, contains(otherMessage));
10199
}));
102100

103101
test('Handles against malformed manifest', () => testbed.run(() async {

packages/flutter_tools/test/web.shard/expression_evaluation_web_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ void main() {
2323
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
2424
await project.setUpIn(tempDir);
2525
flutter = FlutterRunTestDriver(tempDir);
26+
flutter.stdout.listen((String line) {
27+
expect(line, isNot(contains('Unresolved uri:')));
28+
});
2629
});
2730

2831
tearDown(() async {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// @dart = 2.8
6+
7+
import 'package:dwds/dwds.dart';
8+
import 'package:file/file.dart';
9+
import 'package:file/memory.dart';
10+
import 'package:flutter_tools/src/artifacts.dart';
11+
import 'package:flutter_tools/src/isolated/sdk_web_configuration.dart';
12+
13+
import '../src/common.dart';
14+
15+
void main() {
16+
FileSystem fileSystem;
17+
18+
group('Flutter SDK configuration for web', () {
19+
SdkConfiguration configuration;
20+
21+
setUp(() async {
22+
fileSystem = MemoryFileSystem.test();
23+
fileSystem.directory('HostArtifact.flutterWebSdk').createSync();
24+
fileSystem.file('HostArtifact.webPlatformKernelDill').createSync();
25+
fileSystem.file('HostArtifact.webPlatformSoundKernelDill').createSync();
26+
fileSystem.file('HostArtifact.flutterWebLibrariesJson').createSync();
27+
28+
final SdkWebConfigurationProvider provider =
29+
SdkWebConfigurationProvider(Artifacts.test(fileSystem: fileSystem));
30+
configuration = await provider.configuration;
31+
});
32+
33+
testWithoutContext('can be validated', () {
34+
SdkWebConfigurationProvider.validate(configuration, fileSystem: fileSystem);
35+
});
36+
37+
testWithoutContext('is correct', () {
38+
expect(configuration.sdkDirectory, 'HostArtifact.flutterWebSdk');
39+
expect(configuration.unsoundSdkSummaryPath, 'HostArtifact.webPlatformKernelDill');
40+
expect(configuration.soundSdkSummaryPath, 'HostArtifact.webPlatformSoundKernelDill');
41+
expect(configuration.librariesPath, 'HostArtifact.flutterWebLibrariesJson');
42+
expect(configuration.compilerWorkerPath, isNull);
43+
});
44+
});
45+
}

0 commit comments

Comments
 (0)