at 23.05-pre 198 lines 11 kB view raw
1diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart 2diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart 3index 9dd7272fbe..642c8e48e4 100644 4--- a/packages/flutter_tools/lib/src/asset.dart 5+++ b/packages/flutter_tools/lib/src/asset.dart 6@@ -16,6 +16,7 @@ import 'convert.dart'; 7 import 'dart/package_map.dart'; 8 import 'devfs.dart'; 9 import 'flutter_manifest.dart'; 10+import 'globals.dart' as globals; 11 import 'license_collector.dart'; 12 import 'project.dart'; 13 14@@ -530,8 +531,7 @@ class ManifestAssetBundle implements AssetBundle { 15 final Uri entryUri = _fileSystem.path.toUri(asset); 16 result.add(_Asset( 17 baseDir: _fileSystem.path.join( 18- Cache.flutterRoot!, 19- 'bin', 'cache', 'artifacts', 'material_fonts', 20+ globals.fsUtils.homeDirPath!, '.cache', 'flutter', 'artifacts', 'material_fonts', 21 ), 22 relativeUri: Uri(path: entryUri.pathSegments.last), 23 entryUri: entryUri, 24diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart 25index dd80b1e46e..8e54517765 100644 26--- a/packages/flutter_tools/lib/src/cache.dart 27+++ b/packages/flutter_tools/lib/src/cache.dart 28@@ -22,6 +22,7 @@ import 'base/user_messages.dart'; 29 import 'build_info.dart'; 30 import 'convert.dart'; 31 import 'features.dart'; 32+import 'globals.dart' as globals; 33 34 const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo) 35 const String kFlutterEngineEnvironmentVariableName = 'FLUTTER_ENGINE'; // should point to //engine/src/ (root of flutter/engine repo) 36@@ -318,8 +319,13 @@ class Cache { 37 return; 38 } 39 assert(_lock == null); 40+ final Directory dir = _fileSystem.directory(_fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter')); 41+ if (!dir.existsSync()) { 42+ dir.createSync(recursive: true); 43+ globals.os.chmod(dir, '755'); 44+ } 45 final File lockFile = 46- _fileSystem.file(_fileSystem.path.join(flutterRoot!, 'bin', 'cache', 'lockfile')); 47+ _fileSystem.file(_fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter', 'lockfile')); 48 try { 49 _lock = lockFile.openSync(mode: FileMode.write); 50 } on FileSystemException catch (e) { 51@@ -378,8 +384,7 @@ class Cache { 52 53 String get devToolsVersion { 54 if (_devToolsVersion == null) { 55- const String devToolsDirPath = 'dart-sdk/bin/resources/devtools'; 56- final Directory devToolsDir = getCacheDir(devToolsDirPath, shouldCreate: false); 57+ final Directory devToolsDir = _fileSystem.directory(_fileSystem.path.join(flutterRoot!, 'bin/cache/dart-sdk/bin/resources/devtools')); 58 if (!devToolsDir.existsSync()) { 59 throw Exception('Could not find directory at ${devToolsDir.path}'); 60 } 61@@ -532,7 +537,7 @@ class Cache { 62 if (_rootOverride != null) { 63 return _fileSystem.directory(_fileSystem.path.join(_rootOverride!.path, 'bin', 'cache')); 64 } else { 65- return _fileSystem.directory(_fileSystem.path.join(flutterRoot!, 'bin', 'cache')); 66+ return _fileSystem.directory(_fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter')); 67 } 68 } 69 70index c539d67156..4e0a64f7a9 100644 71--- a/packages/flutter_tools/lib/src/artifacts.dart 72+++ b/packages/flutter_tools/lib/src/artifacts.dart 73@@ -346,10 +346,10 @@ class CachedArtifacts implements Artifacts { 74 ) { 75 switch (artifact) { 76 case HostArtifact.engineDartSdkPath: 77- final String path = _dartSdkPath(_cache); 78+ final String path = _dartSdkPath(_fileSystem); 79 return _fileSystem.directory(path); 80 case HostArtifact.engineDartBinary: 81- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', _hostArtifactToFileName(artifact, _platform)); 82+ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', _hostArtifactToFileName(artifact, _platform)); 83 return _fileSystem.file(path); 84 case HostArtifact.flutterWebSdk: 85 final String path = _getFlutterWebSdkPath(); 86@@ -398,7 +398,7 @@ class CachedArtifacts implements Artifacts { 87 case HostArtifact.dart2jsSnapshot: 88 case HostArtifact.dartdevcSnapshot: 89 case HostArtifact.kernelWorkerSnapshot: 90- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); 91+ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); 92 return _fileSystem.file(path); 93 case HostArtifact.iosDeploy: 94 final String artifactFileName = _hostArtifactToFileName(artifact, _platform); 95@@ -465,11 +465,13 @@ class CachedArtifacts implements Artifacts { 96 String _getAndroidArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) { 97 final String engineDir = _getEngineArtifactsPath(platform, mode)!; 98 switch (artifact) { 99+ case Artifact.frontendServerSnapshotForEngineDartSdk: 100+ assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.'); 101+ return _fileSystem.path.join(engineDir, _artifactToFileName(artifact)); 102 case Artifact.genSnapshot: 103 assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.'); 104 final String hostPlatform = getNameForHostPlatform(getCurrentHostPlatform()); 105 return _fileSystem.path.join(engineDir, hostPlatform, _artifactToFileName(artifact)); 106- case Artifact.frontendServerSnapshotForEngineDartSdk: 107 case Artifact.constFinder: 108 case Artifact.flutterFramework: 109 case Artifact.flutterMacOSFramework: 110@@ -497,13 +499,13 @@ class CachedArtifacts implements Artifacts { 111 switch (artifact) { 112 case Artifact.genSnapshot: 113 case Artifact.flutterXcframework: 114+ case Artifact.frontendServerSnapshotForEngineDartSdk: 115 final String artifactFileName = _artifactToFileName(artifact)!; 116 final String engineDir = _getEngineArtifactsPath(platform, mode)!; 117 return _fileSystem.path.join(engineDir, artifactFileName); 118 case Artifact.flutterFramework: 119 final String engineDir = _getEngineArtifactsPath(platform, mode)!; 120 return _getIosEngineArtifactPath(engineDir, environmentType, _fileSystem); 121- case Artifact.frontendServerSnapshotForEngineDartSdk: 122 case Artifact.constFinder: 123 case Artifact.flutterMacOSFramework: 124 case Artifact.flutterPatchedSdkPath: 125@@ -586,14 +588,10 @@ class CachedArtifacts implements Artifacts { 126 // For script snapshots any gen_snapshot binary will do. Returning gen_snapshot for 127 // android_arm in profile mode because it is available on all supported host platforms. 128 return _getAndroidArtifactPath(artifact, TargetPlatform.android_arm, BuildMode.profile); 129- case Artifact.frontendServerSnapshotForEngineDartSdk: 130- return _fileSystem.path.join( 131- _dartSdkPath(_cache), 'bin', 'snapshots', 132- _artifactToFileName(artifact), 133- ); 134 case Artifact.flutterTester: 135 case Artifact.vmSnapshotData: 136 case Artifact.isolateSnapshotData: 137+ case Artifact.frontendServerSnapshotForEngineDartSdk: 138 case Artifact.icuData: 139 final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path; 140 final String platformDirName = _enginePlatformDirectoryName(platform); 141@@ -776,7 +774,7 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts { 142 final String path = _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); 143 return _fileSystem.file(path); 144 case HostArtifact.dartdevcSnapshot: 145- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); 146+ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); 147 return _fileSystem.file(path); 148 case HostArtifact.kernelWorkerSnapshot: 149 final String path = _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); 150@@ -901,9 +899,7 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts { 151 case Artifact.windowsCppClientWrapper: 152 return _fileSystem.path.join(_hostEngineOutPath, artifactFileName); 153 case Artifact.frontendServerSnapshotForEngineDartSdk: 154- return _fileSystem.path.join( 155- _hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName, 156- ); 157+ return _fileSystem.path.join(_hostEngineOutPath, 'gen', artifactFileName); 158 } 159 } 160 161@@ -1011,8 +1007,8 @@ class OverrideArtifacts implements Artifacts { 162 } 163 164 /// Locate the Dart SDK. 165-String _dartSdkPath(Cache cache) { 166- return cache.getRoot().childDirectory('dart-sdk').path; 167+String _dartSdkPath(FileSystem fileSystem) { 168+ return fileSystem.path.join(Cache.flutterRoot!, 'bin', 'cache', 'dart-sdk'); 169 } 170 171 class _TestArtifacts implements Artifacts { 172diff --git a/packages/flutter_tools/test/general.shard/artifacts_test.dart b/packages/flutter_tools/test/general.shard/artifacts_test.dart 173index aed3eb9285..81b8362648 100644 174--- a/packages/flutter_tools/test/general.shard/artifacts_test.dart 175+++ b/packages/flutter_tools/test/general.shard/artifacts_test.dart 176@@ -141,10 +141,6 @@ void main() { 177 artifacts.getArtifactPath(Artifact.flutterTester, platform: TargetPlatform.linux_arm64), 178 fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-arm64', 'flutter_tester'), 179 ); 180- expect( 181- artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), 182- fileSystem.path.join('root', 'bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'frontend_server.dart.snapshot') 183- ); 184 }); 185 186 testWithoutContext('precompiled web artifact paths are correct', () { 187@@ -310,11 +306,6 @@ void main() { 188 artifacts.getHostArtifact(HostArtifact.engineDartSdkPath).path, 189 fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk'), 190 ); 191- expect( 192- artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), 193- fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk', 'bin', 194- 'snapshots', 'frontend_server.dart.snapshot') 195- ); 196 expect( 197 artifacts.getHostArtifact(HostArtifact.impellerc).path, 198 fileSystem.path.join('/out', 'host_debug_unopt', 'impellerc'),