Unverified Commit 8f536ec1 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Default --no-tree-shake-icons to false for 'flutter build bundle' (#82773)

parent 2acd0007
...@@ -16,7 +16,6 @@ import 'build.dart'; ...@@ -16,7 +16,6 @@ import 'build.dart';
class BuildBundleCommand extends BuildSubCommand { class BuildBundleCommand extends BuildSubCommand {
BuildBundleCommand({bool verboseHelp = false, this.bundleBuilder}) { BuildBundleCommand({bool verboseHelp = false, this.bundleBuilder}) {
addTreeShakeIconsFlag();
usesTargetOption(); usesTargetOption();
usesFilesystemOptions(hide: !verboseHelp); usesFilesystemOptions(hide: !verboseHelp);
usesBuildNumberOption(); usesBuildNumberOption();
...@@ -48,6 +47,13 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -48,6 +47,13 @@ class BuildBundleCommand extends BuildSubCommand {
defaultsTo: getAssetBuildDirectory(), defaultsTo: getAssetBuildDirectory(),
help: 'The output directory for the kernel_blob.bin file, the native snapshet, the assets, etc. ' help: 'The output directory for the kernel_blob.bin file, the native snapshet, the assets, etc. '
'Can be used to redirect the output when driving the Flutter toolchain from another build system.', 'Can be used to redirect the output when driving the Flutter toolchain from another build system.',
)
..addFlag(
'tree-shake-icons',
negatable: true,
defaultsTo: false,
hide: !verboseHelp,
help: '(deprecated) Icon font tree shaking is not supported by this command.',
); );
usesPubOption(); usesPubOption();
usesTrackWidgetCreation(verboseHelp: verboseHelp); usesTrackWidgetCreation(verboseHelp: verboseHelp);
...@@ -81,6 +87,14 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -81,6 +87,14 @@ class BuildBundleCommand extends BuildSubCommand {
); );
} }
@override
Future<void> validateCommand() async {
if (argResults['tree-shake-icons'] as bool) {
throwToolExit('The "--tree-shake-icons" flag is deprecated for "build bundle" and will be removed in a future version of Flutter.');
}
return super.validateCommand();
}
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final String targetPlatform = stringArg('target-platform'); final String targetPlatform = stringArg('target-platform');
......
...@@ -132,6 +132,24 @@ void main() { ...@@ -132,6 +132,24 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false), FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
}); });
testUsingContext('bundle --tree-shake-icons fails', () async {
globals.fs.file('lib/main.dart').createSync(recursive: true);
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
..bundleBuilder = FakeBundleBuilder());
expect(() => runner.run(<String>[
'bundle',
'--no-pub',
'--release',
'--tree-shake-icons',
]), throwsToolExit(message: 'tree-shake-icons'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('bundle can build for Windows if feature is enabled', () async { testUsingContext('bundle can build for Windows if feature is enabled', () async {
globals.fs.file('lib/main.dart').createSync(recursive: true); globals.fs.file('lib/main.dart').createSync(recursive: true);
globals.fs.file('pubspec.yaml').createSync(); globals.fs.file('pubspec.yaml').createSync();
...@@ -369,6 +387,84 @@ void main() { ...@@ -369,6 +387,84 @@ void main() {
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
}); });
testUsingContext('passes profile options through', () async {
globals.fs.file('lib/main.dart').createSync(recursive: true);
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand());
await runner.run(<String>[
'bundle',
'--no-pub',
'--profile',
'--dart-define=foo=bar',
'--target-platform=android-arm',
'--track-widget-creation',
'--filesystem-scheme=org-dartlang-root',
'--filesystem-root=test1,test2',
'--extra-gen-snapshot-options=--testflag,--testflag2',
'--extra-front-end-options=--testflagFront,--testflagFront2',
]);
}, overrides: <Type, Generator>{
BuildSystem: () => TestBuildSystem.all(BuildResult(success: true), (Target target, Environment environment) {
expect(environment.defines, <String, String>{
kBuildMode: 'profile',
kTargetPlatform: 'android-arm',
kTargetFile: globals.fs.path.join('lib', 'main.dart'),
kDartDefines: 'Zm9vPWJhcg==',
kTrackWidgetCreation: 'true',
kFileSystemScheme: 'org-dartlang-root',
kFileSystemRoots: 'test1,test2',
kExtraGenSnapshotOptions: '--testflag,--testflag2',
kExtraFrontEndOptions: '--testflagFront,--testflagFront2',
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
});
}),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('passes release options through', () async {
globals.fs.file('lib/main.dart').createSync(recursive: true);
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand());
await runner.run(<String>[
'bundle',
'--no-pub',
'--release',
'--dart-define=foo=bar',
'--target-platform=android-arm',
'--track-widget-creation',
'--filesystem-scheme=org-dartlang-root',
'--filesystem-root=test1,test2',
'--extra-gen-snapshot-options=--testflag,--testflag2',
'--extra-front-end-options=--testflagFront,--testflagFront2',
]);
}, overrides: <Type, Generator>{
BuildSystem: () => TestBuildSystem.all(BuildResult(success: true), (Target target, Environment environment) {
expect(environment.defines, <String, String>{
kBuildMode: 'release',
kTargetPlatform: 'android-arm',
kTargetFile: globals.fs.path.join('lib', 'main.dart'),
kDartDefines: 'Zm9vPWJhcg==',
kTrackWidgetCreation: 'true',
kFileSystemScheme: 'org-dartlang-root',
kFileSystemRoots: 'test1,test2',
kExtraGenSnapshotOptions: '--testflag,--testflag2',
kExtraFrontEndOptions: '--testflagFront,--testflagFront2',
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
});
}),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
} }
class FakeBundleBuilder extends Fake implements BundleBuilder { class FakeBundleBuilder extends Fake implements BundleBuilder {
......
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