Revert "let NOTICES be double gzip wrapped to reduce on-disk installed space (#71899)" (#72438)

This commit is contained in:
xster
2020-12-16 10:58:19 -08:00
committed by GitHub
parent a665dd1cab
commit ca82c572b7
17 changed files with 20 additions and 166 deletions

View File

@@ -7,7 +7,6 @@ import 'package:flutter_tools/src/asset.dart' hide defaultManifestPath;
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart' as libfs;
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/devfs.dart';
@@ -60,7 +59,6 @@ Future<void> run(List<String> args) async {
manifestPath: argResults[_kOptionManifest] as String ?? defaultManifestPath,
assetDirPath: assetDir,
packagesPath: argResults[_kOptionPackages] as String,
targetPlatform: TargetPlatform.fuchsia_arm64 // This is not arch specific.
);
if (assets == null) {

View File

@@ -7,7 +7,6 @@ import 'package:package_config/package_config.dart';
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/io.dart';
import 'base/logger.dart';
import 'base/platform.dart';
import 'build_info.dart';
@@ -73,7 +72,6 @@ abstract class AssetBundle {
String manifestPath = defaultManifestPath,
String assetDirPath,
@required String packagesPath,
TargetPlatform targetPlatform,
});
}
@@ -124,13 +122,6 @@ class ManifestAssetBundle implements AssetBundle {
static const String _kAssetManifestJson = 'AssetManifest.json';
static const String _kNoticeFile = 'NOTICES';
// Comically, this can't be name with the more common .gz file extension
// because when it's part of an AAR and brought into another APK via gradle,
// gradle individually traverses all the files of the AAR and unzips .gz
// files (b/37117906). A less common .Z extension still describes how the
// file is formatted if users want to manually inspect the application
// bundle and is recognized by default file handlers on OS such as macOS.˚
static const String _kNoticeZippedFile = 'NOTICES.Z';
@override
bool wasBuiltOnce() => _lastBuildTimestamp != null;
@@ -169,7 +160,6 @@ class ManifestAssetBundle implements AssetBundle {
String manifestPath = defaultManifestPath,
String assetDirPath,
@required String packagesPath,
TargetPlatform targetPlatform,
}) async {
assetDirPath ??= getAssetBuildDirectory();
FlutterProject flutterProject;
@@ -330,6 +320,7 @@ class ManifestAssetBundle implements AssetBundle {
final DevFSStringContent assetManifest = _createAssetManifest(assetVariants);
final DevFSStringContent fontManifest = DevFSStringContent(json.encode(fonts));
final LicenseResult licenseResult = _licenseCollector.obtainLicenses(packageConfig);
final DevFSStringContent licenses = DevFSStringContent(licenseResult.combinedLicenses);
additionalDependencies = licenseResult.dependencies;
if (wildcardDirectories.isNotEmpty) {
@@ -347,27 +338,7 @@ class ManifestAssetBundle implements AssetBundle {
_setIfChanged(_kAssetManifestJson, assetManifest);
_setIfChanged(kFontManifestJson, fontManifest);
if (targetPlatform == TargetPlatform.web_javascript) {
// Don't compress the NOTICES file on web since the client doesn't have
// dart:io to decompress it.
_setIfChanged(_kNoticeFile, DevFSStringContent(licenseResult.combinedLicenses));
} else {
final List<int> licenseBytes = utf8.encode(licenseResult.combinedLicenses);
if (entries[_kNoticeZippedFile] == null ||
gzip.decode((entries[_kNoticeZippedFile] as DevFSByteContent).bytes)
!= licenseBytes) {
entries[_kNoticeZippedFile] = DevFSByteContent(
ZLibEncoder(
// A zlib dictionary is a hinting string sequence with the most
// likely string occurrences at the end. This ends up just being
// common English words with domain specific words like copyright.
dictionary: utf8.encode('copyrightsoftwaretothisinandorofthe'),
gzip: true,
level: 9,
).convert(licenseBytes)
);
}
}
_setIfChanged(_kNoticeFile, licenses);
return 0;
}

View File

@@ -102,8 +102,7 @@ export 'dart:io'
systemEncoding,
WebSocket,
WebSocketException,
WebSocketTransformer,
ZLibEncoder;
WebSocketTransformer;
/// Exits the process with the given [exitCode].
typedef ExitFunction = void Function(int exitCode);

View File

@@ -54,7 +54,6 @@ Future<Depfile> copyAssets(Environment environment, Directory outputDirectory, {
manifestPath: pubspecFile.path,
packagesPath: environment.projectDir.childFile('.packages').path,
assetDirPath: null,
targetPlatform: targetPlatform,
);
if (resultCode != 0) {
throw Exception('Failed to bundle asset files.');

View File

@@ -192,7 +192,6 @@ Future<AssetBundle> buildAssets({
String manifestPath,
String assetDirPath,
@required String packagesPath,
TargetPlatform targetPlatform,
}) async {
assetDirPath ??= getAssetBuildDirectory();
packagesPath ??= globals.fs.path.absolute(packagesPath);
@@ -203,7 +202,6 @@ Future<AssetBundle> buildAssets({
manifestPath: manifestPath,
assetDirPath: assetDirPath,
packagesPath: packagesPath,
targetPlatform: targetPlatform,
);
if (result != 0) {
return null;

View File

@@ -705,10 +705,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
final bool rebuildBundle = assetBundle.needsBuild();
if (rebuildBundle) {
globals.printTrace('Updating assets');
final int result = await assetBundle.build(
packagesPath: debuggingOptions.buildInfo.packagesPath,
targetPlatform: TargetPlatform.web_javascript,
);
final int result = await assetBundle.build(packagesPath: debuggingOptions.buildInfo.packagesPath);
if (result != 0) {
return UpdateFSReport(success: false);
}

View File

@@ -88,7 +88,7 @@ flutter:
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/AssetManifest.json'), exists);
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/FontManifest.json'), exists);
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/NOTICES.Z'), exists);
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/NOTICES'), exists);
// See https://github.com/flutter/flutter/issues/35293
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/assets/foo/bar.png'), exists);
// See https://github.com/flutter/flutter/issues/46163