mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Default --no-tree-shake-icons to false for 'flutter build bundle' (#82773)
This commit is contained in:
parent
2acd0007d6
commit
8f536ec17b
@ -16,7 +16,6 @@ import 'build.dart';
|
||||
|
||||
class BuildBundleCommand extends BuildSubCommand {
|
||||
BuildBundleCommand({bool verboseHelp = false, this.bundleBuilder}) {
|
||||
addTreeShakeIconsFlag();
|
||||
usesTargetOption();
|
||||
usesFilesystemOptions(hide: !verboseHelp);
|
||||
usesBuildNumberOption();
|
||||
@ -48,6 +47,13 @@ class BuildBundleCommand extends BuildSubCommand {
|
||||
defaultsTo: getAssetBuildDirectory(),
|
||||
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.',
|
||||
)
|
||||
..addFlag(
|
||||
'tree-shake-icons',
|
||||
negatable: true,
|
||||
defaultsTo: false,
|
||||
hide: !verboseHelp,
|
||||
help: '(deprecated) Icon font tree shaking is not supported by this command.',
|
||||
);
|
||||
usesPubOption();
|
||||
usesTrackWidgetCreation(verboseHelp: verboseHelp);
|
||||
@ -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
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
final String targetPlatform = stringArg('target-platform');
|
||||
|
@ -132,6 +132,24 @@ void main() {
|
||||
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 {
|
||||
globals.fs.file('lib/main.dart').createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml').createSync();
|
||||
@ -369,6 +387,84 @@ void main() {
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user