From 1686b6d56dc0f9489195dc560bb4538bf2a5e720 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Fri, 16 Feb 2018 10:22:52 -0800 Subject: [PATCH] Remove fixed asset bundles - they're no longer used. (#14729) --- packages/flutter_tools/lib/src/asset.dart | 24 --------- .../lib/src/commands/daemon.dart | 2 - .../flutter_tools/lib/src/commands/run.dart | 5 -- .../lib/src/resident_runner.dart | 6 +-- packages/flutter_tools/lib/src/run_hot.dart | 2 - .../flutter_tools/test/asset_bundle_test.dart | 54 ------------------- 6 files changed, 1 insertion(+), 92 deletions(-) diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index 8d9a751c78..454a49f74c 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart @@ -30,9 +30,6 @@ abstract class AssetBundleFactory { } abstract class AssetBundle { - factory AssetBundle.fixed(String projectRoot, String projectAssets) => - new _ManifestAssetBundle.fixed(projectRoot, projectAssets); - Map 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 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; diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index 7a6350e150..9d614475eb 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -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, ); diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 658a038dbd..30809bb399 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -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, ); diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 92068c050f..dac555780b 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -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 flutterDevices; diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index ff26daec96..ffa282736b 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -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); diff --git a/packages/flutter_tools/test/asset_bundle_test.dart b/packages/flutter_tools/test/asset_bundle_test.dart index 1cc03b8b51..1f9f053fda 100644 --- a/packages/flutter_tools/test/asset_bundle_test.dart +++ b/packages/flutter_tools/test/asset_bundle_test.dart @@ -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 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: { - 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.