@@ -163,15 +163,15 @@ class Dart2JSTarget extends Dart2WebTarget {
163
163
}
164
164
final BuildMode buildMode = BuildMode .fromCliName (buildModeEnvironment);
165
165
final JsCompilerConfig compilerConfig = JsCompilerConfig .fromBuildSystemEnvironment (environment.defines);
166
- final Artifacts artifacts = globals .artifacts! ;
166
+ final Artifacts artifacts = environment .artifacts;
167
167
final String platformBinariesPath = getWebPlatformBinariesDirectory (artifacts, webRenderer).path;
168
168
final List <String > sharedCommandOptions = < String > [
169
169
artifacts.getArtifactPath (Artifact .engineDartBinary, platform: TargetPlatform .web_javascript),
170
170
'--disable-dart-dev' ,
171
171
artifacts.getArtifactPath (Artifact .dart2jsSnapshot, platform: TargetPlatform .web_javascript),
172
172
'--platform-binaries=$platformBinariesPath ' ,
173
- ...decodeCommaSeparated (environment.defines, kExtraFrontEndOptions),
174
173
'--invoker=flutter_tool' ,
174
+ ...decodeCommaSeparated (environment.defines, kExtraFrontEndOptions),
175
175
if (buildMode == BuildMode .profile)
176
176
'-Ddart.vm.profile=true'
177
177
else
@@ -214,7 +214,7 @@ class Dart2JSTarget extends Dart2WebTarget {
214
214
final File dart2jsDeps = environment.buildDir
215
215
.childFile ('app.dill.deps' );
216
216
if (! dart2jsDeps.existsSync ()) {
217
- globals .printWarning ('Warning: dart2js did not produced expected deps list at '
217
+ environment.logger .printWarning ('Warning: dart2js did not produced expected deps list at '
218
218
'${dart2jsDeps .path }' );
219
219
return ;
220
220
}
@@ -241,7 +241,7 @@ class Dart2WasmTarget extends Dart2WebTarget {
241
241
}
242
242
final WasmCompilerConfig compilerConfig = WasmCompilerConfig .fromBuildSystemEnvironment (environment.defines);
243
243
final BuildMode buildMode = BuildMode .fromCliName (buildModeEnvironment);
244
- final Artifacts artifacts = globals .artifacts! ;
244
+ final Artifacts artifacts = environment .artifacts;
245
245
final File outputWasmFile = environment.buildDir.childFile (
246
246
compilerConfig.runWasmOpt ? 'main.dart.unopt.wasm' : 'main.dart.wasm'
247
247
);
@@ -253,14 +253,6 @@ class Dart2WasmTarget extends Dart2WebTarget {
253
253
artifacts.getArtifactPath (Artifact .engineDartAotRuntime, platform: TargetPlatform .web_javascript),
254
254
'--disable-dart-dev' ,
255
255
artifacts.getArtifactPath (Artifact .dart2wasmSnapshot, platform: TargetPlatform .web_javascript),
256
- if (buildMode == BuildMode .profile)
257
- '-Ddart.vm.profile=true'
258
- else
259
- '-Ddart.vm.product=true' ,
260
- ...decodeCommaSeparated (environment.defines, kExtraFrontEndOptions),
261
- for (final String dartDefine in decodeDartDefines (environment.defines, kDartDefines))
262
- '-D$dartDefine ' ,
263
- ...compilerConfig.toCommandOptions (),
264
256
'--packages=.dart_tool/package_config.json' ,
265
257
'--dart-sdk=$dartSdkPath ' ,
266
258
'--multi-root-scheme' ,
@@ -271,6 +263,14 @@ class Dart2WasmTarget extends Dart2WebTarget {
271
263
dartSdkRoot,
272
264
'--libraries-spec' ,
273
265
artifacts.getHostArtifact (HostArtifact .flutterWebLibrariesJson).path,
266
+ if (buildMode == BuildMode .profile)
267
+ '-Ddart.vm.profile=true'
268
+ else
269
+ '-Ddart.vm.product=true' ,
270
+ ...decodeCommaSeparated (environment.defines, kExtraFrontEndOptions),
271
+ for (final String dartDefine in decodeDartDefines (environment.defines, kDartDefines))
272
+ '-D$dartDefine ' ,
273
+ ...compilerConfig.toCommandOptions (),
274
274
if (webRenderer == WebRendererMode .skwasm)
275
275
...< String > [
276
276
'--import-shared-memory' ,
@@ -383,10 +383,10 @@ class WebReleaseBundle extends Target {
383
383
@override
384
384
Future <void > build (Environment environment) async {
385
385
for (final File outputFile in environment.buildDir.listSync (recursive: true ).whereType <File >()) {
386
- final String basename = globals.fs .path.basename (outputFile.path);
386
+ final String basename = environment.fileSystem .path.basename (outputFile.path);
387
387
if (shouldCopy (basename)) {
388
388
outputFile.copySync (
389
- environment.outputDir.childFile (globals.fs .path.basename (outputFile.path)).path
389
+ environment.outputDir.childFile (environment.fileSystem .path.basename (outputFile.path)).path
390
390
);
391
391
}
392
392
}
@@ -422,9 +422,9 @@ class WebReleaseBundle extends Target {
422
422
// Copy other resource files out of web/ directory.
423
423
final List <File > outputResourcesFiles = < File > [];
424
424
for (final File inputFile in inputResourceFiles) {
425
- final File outputFile = globals.fs .file (globals.fs .path.join (
425
+ final File outputFile = environment.fileSystem .file (environment.fileSystem .path.join (
426
426
environment.outputDir.path,
427
- globals.fs .path.relative (inputFile.path, from: webResources.path)));
427
+ environment.fileSystem .path.relative (inputFile.path, from: webResources.path)));
428
428
if (! outputFile.parent.existsSync ()) {
429
429
outputFile.parent.createSync (recursive: true );
430
430
}
@@ -535,7 +535,7 @@ class WebBuiltInAssets extends Target {
535
535
// Write the flutter.js file
536
536
final File flutterJsFile = environment.outputDir.childFile ('flutter.js' );
537
537
final String fileGeneratorsPath =
538
- globals .artifacts! .getArtifactPath (Artifact .flutterToolsFileGenerators);
538
+ environment .artifacts.getArtifactPath (Artifact .flutterToolsFileGenerators);
539
539
flutterJsFile.writeAsStringSync (
540
540
flutter_js.generateFlutterJsFile (fileGeneratorsPath));
541
541
}
@@ -576,7 +576,7 @@ class WebServiceWorker extends Target {
576
576
.listSync (recursive: true )
577
577
.whereType <File >()
578
578
.where ((File file) => ! file.path.endsWith ('flutter_service_worker.js' )
579
- && ! globals.fs .path.basename (file.path).startsWith ('.' ))
579
+ && ! environment.fileSystem .path.basename (file.path).startsWith ('.' ))
580
580
.toList ();
581
581
582
582
final Map <String , String > urlToHash = < String , String > {};
@@ -586,15 +586,15 @@ class WebServiceWorker extends Target {
586
586
file.path.endsWith ('.part.js.map' )) {
587
587
continue ;
588
588
}
589
- final String url = globals.fs .path.toUri (
590
- globals.fs .path.relative (
589
+ final String url = environment.fileSystem .path.toUri (
590
+ environment.fileSystem .path.relative (
591
591
file.path,
592
592
from: environment.outputDir.path),
593
593
).toString ();
594
594
final String hash = md5.convert (await file.readAsBytes ()).toString ();
595
595
urlToHash[url] = hash;
596
596
// Add an additional entry for the base URL.
597
- if (globals.fs .path.basename (url) == 'index.html' ) {
597
+ if (environment.fileSystem .path.basename (url) == 'index.html' ) {
598
598
urlToHash['/' ] = hash;
599
599
}
600
600
}
@@ -605,7 +605,7 @@ class WebServiceWorker extends Target {
605
605
final ServiceWorkerStrategy serviceWorkerStrategy =
606
606
ServiceWorkerStrategy .fromCliName (environment.defines[kServiceWorkerStrategy]);
607
607
final String fileGeneratorsPath =
608
- globals .artifacts! .getArtifactPath (Artifact .flutterToolsFileGenerators);
608
+ environment .artifacts.getArtifactPath (Artifact .flutterToolsFileGenerators);
609
609
final String serviceWorker = generateServiceWorker (
610
610
fileGeneratorsPath,
611
611
urlToHash,
0 commit comments