Remove fixed asset bundles - they're no longer used. (#14729)
This commit is contained in:
@@ -30,9 +30,6 @@ abstract class AssetBundleFactory {
|
||||
}
|
||||
|
||||
abstract class AssetBundle {
|
||||
factory AssetBundle.fixed(String projectRoot, String projectAssets) =>
|
||||
new _ManifestAssetBundle.fixed(projectRoot, projectAssets);
|
||||
|
||||
Map<String, DevFSContent> get entries;
|
||||
|
||||
bool wasBuiltOnce();
|
||||
@@ -66,38 +63,17 @@ class _ManifestAssetBundle implements AssetBundle {
|
||||
static const String _kFontSetMaterial = 'material';
|
||||
static const String _kLICENSE = 'LICENSE';
|
||||
|
||||
bool _fixed = false;
|
||||
DateTime _lastBuildTimestamp;
|
||||
|
||||
/// Constructs an [_ManifestAssetBundle] that gathers the set of assets from the
|
||||
/// pubspec.yaml manifest.
|
||||
_ManifestAssetBundle();
|
||||
|
||||
/// Constructs an [_ManifestAssetBundle] with a fixed set of assets.
|
||||
/// [projectRoot] The absolute path to the project root.
|
||||
/// [projectAssets] comma separated list of assets.
|
||||
_ManifestAssetBundle.fixed(String projectRoot, String projectAssets) {
|
||||
_fixed = true;
|
||||
if ((projectRoot == null) || (projectAssets == null))
|
||||
return;
|
||||
|
||||
final List<String> assets = projectAssets.split(',');
|
||||
for (String asset in assets) {
|
||||
if (asset == '')
|
||||
continue;
|
||||
final String assetPath = fs.path.join(projectRoot, asset);
|
||||
final String archivePath = asset;
|
||||
entries[archivePath] = new DevFSFileContent(fs.file(assetPath));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool wasBuiltOnce() => _lastBuildTimestamp != null;
|
||||
|
||||
@override
|
||||
bool needsBuild({String manifestPath: defaultManifestPath}) {
|
||||
if (_fixed)
|
||||
return false;
|
||||
if (_lastBuildTimestamp == null)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -350,7 +350,6 @@ class AppDomain extends Domain {
|
||||
bool previewDart2: false,
|
||||
String projectRootPath,
|
||||
String packagesFilePath,
|
||||
String projectAssets,
|
||||
bool ipv6: false,
|
||||
}) async {
|
||||
if (await device.isLocalEmulator && !options.buildInfo.supportsEmulator) {
|
||||
@@ -375,7 +374,6 @@ class AppDomain extends Domain {
|
||||
previewDart2: previewDart2,
|
||||
projectRootPath: projectRootPath,
|
||||
packagesFilePath: packagesFilePath,
|
||||
projectAssets: projectAssets,
|
||||
ipv6: ipv6,
|
||||
hostIsIde: true,
|
||||
);
|
||||
|
||||
@@ -116,9 +116,6 @@ class RunCommand extends RunCommandBase {
|
||||
argParser.addOption('project-root',
|
||||
hide: !verboseHelp,
|
||||
help: 'Specify the project root directory.');
|
||||
argParser.addOption('project-assets',
|
||||
hide: !verboseHelp,
|
||||
help: 'Specify the project assets relative to the root directory.');
|
||||
argParser.addFlag('machine',
|
||||
hide: !verboseHelp,
|
||||
negatable: false,
|
||||
@@ -260,7 +257,6 @@ class RunCommand extends RunCommandBase {
|
||||
previewDart2: argResults['preview-dart-2'],
|
||||
projectRootPath: argResults['project-root'],
|
||||
packagesFilePath: globalResults['packages'],
|
||||
projectAssets: argResults['project-assets'],
|
||||
ipv6: ipv6,
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -314,7 +310,6 @@ class RunCommand extends RunCommandBase {
|
||||
previewDart2: argResults['preview-dart-2'],
|
||||
projectRootPath: argResults['project-root'],
|
||||
packagesFilePath: globalResults['packages'],
|
||||
projectAssets: argResults['project-assets'],
|
||||
stayResident: stayResident,
|
||||
ipv6: ipv6,
|
||||
);
|
||||
|
||||
@@ -413,7 +413,6 @@ abstract class ResidentRunner {
|
||||
this.usesTerminalUI: true,
|
||||
String projectRootPath,
|
||||
String packagesFilePath,
|
||||
String projectAssets,
|
||||
this.stayResident,
|
||||
this.ipv6,
|
||||
}) {
|
||||
@@ -421,10 +420,7 @@ abstract class ResidentRunner {
|
||||
_projectRootPath = projectRootPath ?? fs.currentDirectory.path;
|
||||
_packagesFilePath =
|
||||
packagesFilePath ?? fs.path.absolute(PackageMap.globalPackagesPath);
|
||||
if (projectAssets != null)
|
||||
_assetBundle = new AssetBundle.fixed(_projectRootPath, projectAssets);
|
||||
else
|
||||
_assetBundle = AssetBundleFactory.instance.createBundle();
|
||||
_assetBundle = AssetBundleFactory.instance.createBundle();
|
||||
}
|
||||
|
||||
final List<FlutterDevice> flutterDevices;
|
||||
|
||||
@@ -43,7 +43,6 @@ class HotRunner extends ResidentRunner {
|
||||
this.hostIsIde: false,
|
||||
String projectRootPath,
|
||||
String packagesFilePath,
|
||||
String projectAssets,
|
||||
bool stayResident: true,
|
||||
bool ipv6: false,
|
||||
}) : super(devices,
|
||||
@@ -52,7 +51,6 @@ class HotRunner extends ResidentRunner {
|
||||
usesTerminalUI: usesTerminalUI,
|
||||
projectRootPath: projectRootPath,
|
||||
packagesFilePath: packagesFilePath,
|
||||
projectAssets: projectAssets,
|
||||
stayResident: stayResident,
|
||||
ipv6: ipv6);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/asset.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/devfs.dart';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -21,59 +20,6 @@ void main() {
|
||||
Cache.flutterRoot = getFlutterRoot();
|
||||
});
|
||||
|
||||
// Fixed asset bundle tests.
|
||||
group('AssetBundle.fixed', () {
|
||||
test('empty strings', () async {
|
||||
expect(new AssetBundle.fixed(null, null), isNotNull);
|
||||
expect(new AssetBundle.fixed('', ''), isNotNull);
|
||||
expect(new AssetBundle.fixed(null, null).entries, isEmpty);
|
||||
});
|
||||
test('does not need a rebuild', () async {
|
||||
expect(new AssetBundle.fixed(null, null).needsBuild(), isFalse);
|
||||
});
|
||||
test('empty string', () async {
|
||||
final AssetBundle ab = new AssetBundle.fixed('', '');
|
||||
expect(ab.entries, isEmpty);
|
||||
});
|
||||
test('single entry', () async {
|
||||
final AssetBundle ab = new AssetBundle.fixed('', 'apple.txt');
|
||||
expect(ab.entries, isNotEmpty);
|
||||
expect(ab.entries.length, 1);
|
||||
final String archivePath = ab.entries.keys.first;
|
||||
expect(archivePath, isNotNull);
|
||||
expect(archivePath, 'apple.txt');
|
||||
});
|
||||
test('two entries', () async {
|
||||
final AssetBundle ab = new AssetBundle.fixed('', 'apple.txt,packages/flutter_gallery_assets/shrine/products/heels.png');
|
||||
expect(ab.entries, isNotEmpty);
|
||||
expect(ab.entries.length, 2);
|
||||
final List<String> archivePaths = ab.entries.keys.toList()..sort();
|
||||
expect(archivePaths[0], 'apple.txt');
|
||||
expect(archivePaths[1], 'packages/flutter_gallery_assets/shrine/products/heels.png');
|
||||
});
|
||||
|
||||
testUsingContext('file contents', () async {
|
||||
// Create a temporary directory and write a single file into it.
|
||||
final Directory tempDir = fs.systemTempDirectory.createTempSync();
|
||||
final String projectRoot = tempDir.path;
|
||||
const String assetPath = 'banana.txt';
|
||||
const String assetContents = 'banana';
|
||||
final File tempFile = fs.file(fs.path.join(projectRoot, assetPath));
|
||||
tempFile.parent.createSync(recursive: true);
|
||||
tempFile.writeAsBytesSync(UTF8.encode(assetContents));
|
||||
|
||||
final AssetBundle ab = new AssetBundle.fixed(projectRoot, assetPath);
|
||||
expect(ab.entries, isNotEmpty);
|
||||
expect(ab.entries.length, 1);
|
||||
final String archivePath = ab.entries.keys.first;
|
||||
final DevFSContent content = ab.entries[archivePath];
|
||||
expect(archivePath, assetPath);
|
||||
expect(assetContents, UTF8.decode(await content.contentsAsBytes()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => const LocalFileSystem(),
|
||||
});
|
||||
});
|
||||
|
||||
group('AssetBundle.build', () {
|
||||
// These tests do not use a memory file system because we want to ensure that
|
||||
// asset bundles work correctly on Windows and Posix systems.
|
||||
|
||||
Reference in New Issue
Block a user