Reland double gzip wrapping NOTICES to reduce on-disk installed space (#80897)

This commit is contained in:
xster
2021-04-26 22:35:45 -07:00
committed by GitHub
parent a8e41f8206
commit ff2dde2c7f
19 changed files with 202 additions and 13 deletions

View File

@@ -18,6 +18,7 @@ dependencies:
_fe_analyzer_shared: 21.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
analyzer: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
archive: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
async: 2.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
charcode: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -61,4 +62,4 @@ dependencies:
dev_dependencies:
test_api: 0.3.0
# PUBSPEC CHECKSUM: 4292
# PUBSPEC CHECKSUM: a6c4

View File

@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:archive/archive.dart';
import 'package:flutter_devicelab/framework/apk_utils.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/task_result.dart';
@@ -314,6 +317,24 @@ Future<void> main() async {
'lib/armeabi-v7a/libflutter.so',
], await getFilesInApk(releaseHostApk));
section('Check the NOTICE file is correct');
await inDirectory(hostApp, () async {
final File apkFile = File(releaseHostApk);
final Archive apk = ZipDecoder().decodeBytes(apkFile.readAsBytesSync());
// Shouldn't be missing since we already checked it exists above.
final ArchiveFile noticesFile = apk.findFile('assets/flutter_assets/NOTICES.Z');
final Uint8List licenseData = noticesFile.content as Uint8List;
if (licenseData == null) {
return TaskResult.failure('Invalid license file.');
}
final String licenseString = utf8.decode(gzip.decode(licenseData));
if (!licenseString.contains('skia') || !licenseString.contains('Flutter Authors')) {
return TaskResult.failure('License content missing.');
}
});
section('Check release AndroidManifest.xml');
final String androidManifestRelease = await getAndroidManifest(debugHostApk);

View File

@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/host_agent.dart';
@@ -214,6 +216,8 @@ Future<void> main() async {
final File objectiveCAnalyticsOutputFile = File(path.join(tempDir.path, 'analytics-objc.log'));
final Directory objectiveCBuildDirectory = Directory(path.join(tempDir.path, 'build-objc'));
section('Build iOS Objective-C host app');
await inDirectory(objectiveCHostApp, () async {
await exec(
'pod',
@@ -282,6 +286,28 @@ Future<void> main() async {
'isolate_snapshot_data',
));
section('Check the NOTICE file is correct');
final String licenseFilePath = path.join(
objectiveCBuildDirectory.path,
'Host.app',
'Frameworks',
'App.framework',
'flutter_assets',
'NOTICES.Z',
);
checkFileExists(licenseFilePath);
await inDirectory(objectiveCBuildDirectory, () async {
final Uint8List licenseData = File(licenseFilePath).readAsBytesSync();
final String licenseString = utf8.decode(gzip.decode(licenseData));
if (!licenseString.contains('skia') || !licenseString.contains('Flutter Authors')) {
return TaskResult.failure('License content missing');
}
});
section('Check that the host build sends the correct analytics');
final String objectiveCAnalyticsOutput = objectiveCAnalyticsOutputFile.readAsStringSync();
if (!objectiveCAnalyticsOutput.contains('cd24: ios')
|| !objectiveCAnalyticsOutput.contains('cd25: true')

View File

@@ -13,7 +13,7 @@ final String platformLineSep = Platform.isWindows ? '\r\n' : '\n';
final List<String> flutterAssets = <String>[
'assets/flutter_assets/AssetManifest.json',
'assets/flutter_assets/NOTICES',
'assets/flutter_assets/NOTICES.Z',
'assets/flutter_assets/fonts/MaterialIcons-Regular.otf',
'assets/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf',
];

View File

@@ -1186,7 +1186,7 @@ class CompileTest {
final _UnzipListEntry libflutter = fileToMetadata['lib/armeabi-v7a/libflutter.so'];
final _UnzipListEntry libapp = fileToMetadata['lib/armeabi-v7a/libapp.so'];
final _UnzipListEntry license = fileToMetadata['assets/flutter_assets/NOTICES'];
final _UnzipListEntry license = fileToMetadata['assets/flutter_assets/NOTICES.Z'];
return <String, dynamic>{
'libflutter_uncompressed_bytes': libflutter.uncompressedSize,

View File

@@ -7,6 +7,7 @@ environment:
sdk: ">=2.3.0 <3.0.0"
dependencies:
archive: 3.1.2
args: 2.1.0
file: 6.1.0
http: 0.13.1
@@ -20,6 +21,7 @@ dependencies:
charcode: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
collection: 1.15.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 3.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_parser: 4.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pedantic: 1.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.8.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -37,7 +39,6 @@ dev_dependencies:
cli_util: 0.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
convert: 3.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
coverage: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 3.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
glob: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_multi_server: 3.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
io: 1.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -63,4 +64,4 @@ dev_dependencies:
webkit_inspection_protocol: 1.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
yaml: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: 4292
# PUBSPEC CHECKSUM: a6c4