Unverified Commit 7dceec21 authored by Kaushik Iska's avatar Kaushik Iska Committed by GitHub

[flutter_tool] --flutter_runner will download the debug symbols (#44119)

This makes the flutter tool download the debug symbols for Flutter and Dart runners to be used in Fuchsia dev environment.
parent ba26f926
......@@ -106,6 +106,7 @@ class Cache {
_artifacts.add(LinuxFuchsiaSDKArtifacts(this));
_artifacts.add(MacOSFuchsiaSDKArtifacts(this));
_artifacts.add(FlutterRunnerSDKArtifacts(this));
_artifacts.add(FlutterRunnerDebugSymbols(this));
for (String artifactName in IosUsbArtifacts.artifactNames) {
_artifacts.add(IosUsbArtifacts(artifactName, this));
}
......@@ -1058,6 +1059,62 @@ class FlutterRunnerSDKArtifacts extends CachedArtifact {
}
}
/// Implementations of this class can resolve URLs for packages that are versioned.
///
/// See also [CipdArchiveResolver].
abstract class VersionedPackageResolver {
const VersionedPackageResolver();
/// Returns the URL for the artifact.
String resolveUrl(String packageName, String version);
}
/// Resolves the CIPD archive URL for a given package and version.
class CipdArchiveResolver extends VersionedPackageResolver {
const CipdArchiveResolver();
@override
String resolveUrl(String packageName, String version) {
return '$_cipdBaseUrl/flutter/$packageName/+/git_revision:$version';
}
}
/// The debug symbols for flutter runner for Fuchsia development.
class FlutterRunnerDebugSymbols extends CachedArtifact {
FlutterRunnerDebugSymbols(Cache cache, {this.packageResolver = const CipdArchiveResolver(), this.dryRun = false})
: super('flutter_runner_debug_symbols', cache, DevelopmentArtifact.flutterRunner);
final VersionedPackageResolver packageResolver;
final bool dryRun;
@override
Directory get location => cache.getArtifactDirectory(name);
@override
String get version => cache.getVersionFor('engine');
Future<void> _downloadDebugSymbols(String targetArch) async {
final String packageName = 'fuchsia-debug-symbols-$targetArch';
final String url = packageResolver.resolveUrl(packageName, version);
if (!dryRun) {
await _downloadZipArchive(
'Downloading debug symbols for flutter runner - arch:$targetArch...',
Uri.parse(url),
location);
}
}
@override
Future<void> updateInner() async {
if (!platform.isLinux && !platform.isMacOS) {
return Future<void>.value();
}
await _downloadDebugSymbols('x64');
await _downloadDebugSymbols('arm64');
}
}
/// The Fuchsia core SDK for Linux.
class LinuxFuchsiaSDKArtifacts extends _FuchsiaSDKArtifacts {
LinuxFuchsiaSDKArtifacts(Cache cache) : super(cache, 'linux');
......
......@@ -387,6 +387,28 @@ void main() {
Cache: () => mockCache,
});
});
group('Flutter runner debug symbols', () {
MockCache mockCache;
MockVersionedPackageResolver mockPackageResolver;
setUp(() {
mockCache = MockCache();
mockPackageResolver = MockVersionedPackageResolver();
});
testUsingContext('Downloads Flutter runner debug symbols', () async {
final FlutterRunnerDebugSymbols flutterRunnerDebugSymbols =
FlutterRunnerDebugSymbols(mockCache, packageResolver: mockPackageResolver, dryRun: true);
await flutterRunnerDebugSymbols.updateInner();
verifyInOrder(<void>[
mockPackageResolver.resolveUrl('fuchsia-debug-symbols-x64', any),
mockPackageResolver.resolveUrl('fuchsia-debug-symbols-arm64', any),
]);
});
}, skip: !platform.isLinux);
}
class FakeCachedArtifact extends EngineCachedArtifact {
......@@ -425,3 +447,4 @@ class MockInternetAddress extends Mock implements InternetAddress {}
class MockCache extends Mock implements Cache {}
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {}
class MockPlatform extends Mock implements Platform {}
class MockVersionedPackageResolver extends Mock implements VersionedPackageResolver {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment