@@ -9,6 +9,7 @@ import 'base/common.dart';
99import 'base/file_system.dart' ;
1010import 'base/os.dart' ;
1111import 'base/platform.dart' ;
12+ import 'base/user_messages.dart' ;
1213import 'base/utils.dart' ;
1314import 'build_info.dart' ;
1415import 'cache.dart' ;
@@ -62,6 +63,9 @@ enum Artifact {
6263 /// Tools related to subsetting or icon font files.
6364 fontSubset,
6465 constFinder,
66+
67+ /// The location of file generators.
68+ flutterToolsFileGenerators,
6569}
6670
6771/// A subset of [Artifact] s that are platform and build mode independent
@@ -202,6 +206,8 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod
202206 return 'font-subset$exe ' ;
203207 case Artifact .constFinder:
204208 return 'const_finder.dart.snapshot' ;
209+ case Artifact .flutterToolsFileGenerators:
210+ return '' ;
205211 }
206212}
207213
@@ -525,6 +531,8 @@ class CachedArtifacts implements Artifacts {
525531 case Artifact .windowsCppClientWrapper:
526532 case Artifact .windowsDesktopPath:
527533 return _getHostArtifactPath (artifact, platform, mode);
534+ case Artifact .flutterToolsFileGenerators:
535+ return _getFileGeneratorsPath ();
528536 }
529537 }
530538
@@ -562,6 +570,8 @@ class CachedArtifacts implements Artifacts {
562570 case Artifact .windowsCppClientWrapper:
563571 case Artifact .windowsDesktopPath:
564572 return _getHostArtifactPath (artifact, platform, mode);
573+ case Artifact .flutterToolsFileGenerators:
574+ return _getFileGeneratorsPath ();
565575 }
566576 }
567577
@@ -611,6 +621,8 @@ class CachedArtifacts implements Artifacts {
611621 case Artifact .windowsCppClientWrapper:
612622 case Artifact .windowsDesktopPath:
613623 return _getHostArtifactPath (artifact, platform, mode);
624+ case Artifact .flutterToolsFileGenerators:
625+ return _getFileGeneratorsPath ();
614626 }
615627 }
616628
@@ -685,6 +697,8 @@ class CachedArtifacts implements Artifacts {
685697 case Artifact .fuchsiaFlutterRunner:
686698 case Artifact .fuchsiaKernelCompiler:
687699 throw StateError ('Artifact $artifact not available for platform $platform .' );
700+ case Artifact .flutterToolsFileGenerators:
701+ return _getFileGeneratorsPath ();
688702 }
689703 }
690704
@@ -952,6 +966,8 @@ class CachedLocalEngineArtifacts implements Artifacts {
952966 case Artifact .dart2wasmSnapshot:
953967 case Artifact .frontendServerSnapshotForEngineDartSdk:
954968 return _fileSystem.path.join (_getDartSdkPath (), 'bin' , 'snapshots' , artifactFileName);
969+ case Artifact .flutterToolsFileGenerators:
970+ return _getFileGeneratorsPath ();
955971 }
956972 }
957973
@@ -1099,6 +1115,7 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
10991115 case Artifact .fuchsiaFlutterRunner:
11001116 case Artifact .fontSubset:
11011117 case Artifact .constFinder:
1118+ case Artifact .flutterToolsFileGenerators:
11021119 break ;
11031120 }
11041121 }
@@ -1298,6 +1315,11 @@ class _TestArtifacts implements Artifacts {
12981315 BuildMode ? mode,
12991316 EnvironmentType ? environmentType,
13001317 }) {
1318+ // The path to file generators is the same even in the test environment.
1319+ if (artifact == Artifact .flutterToolsFileGenerators) {
1320+ return _getFileGeneratorsPath ();
1321+ }
1322+
13011323 final StringBuffer buffer = StringBuffer ();
13021324 buffer.write (artifact);
13031325 if (platform != null ) {
@@ -1340,3 +1362,20 @@ class _TestLocalEngine extends _TestArtifacts {
13401362 @override
13411363 final LocalEngineInfo localEngineInfo;
13421364}
1365+
1366+ String _getFileGeneratorsPath () {
1367+ final String flutterRoot = Cache .defaultFlutterRoot (
1368+ fileSystem: globals.localFileSystem,
1369+ platform: const LocalPlatform (),
1370+ userMessages: UserMessages (),
1371+ );
1372+ return globals.localFileSystem.path.join (
1373+ flutterRoot,
1374+ 'packages' ,
1375+ 'flutter_tools' ,
1376+ 'lib' ,
1377+ 'src' ,
1378+ 'web' ,
1379+ 'file_generators' ,
1380+ );
1381+ }
0 commit comments