Switch script/tools over to the new analysis options (#3777)

Removes the legacy analysis options override and fixes all resulting issues. This is a combination of dart fix and manual changes (mostly mechanical, but some small restructuring to address warnings more cleanly, such as creating typed structs from args when they are used repeatedly to avoid repeated casting, or making things that were unnecessarily public private).

One small opportunistic extra cleanup is that the handling of null-safety prerelease versions is removed, as any new plugin would be written null-safe from the start, so we no longer need to allow those versions.

Part of flutter/flutter#76229
This commit is contained in:
stuartmorgan
2021-04-06 13:04:25 -07:00
committed by GitHub
parent 5ea4d5fdfc
commit 3d9e523218
35 changed files with 675 additions and 652 deletions

View File

@ -11,7 +11,9 @@ import 'package:platform/platform.dart';
import 'common.dart';
/// A command to build the example applications for packages.
class BuildExamplesCommand extends PluginCommand {
/// Creates an instance of the build command.
BuildExamplesCommand(
Directory packagesDir,
FileSystem fileSystem, {
@ -39,33 +41,40 @@ class BuildExamplesCommand extends PluginCommand {
'This command requires "flutter" to be in your path.';
@override
Future<Null> run() async {
if (!argResults[kIpa] &&
!argResults[kApk] &&
!argResults[kLinux] &&
!argResults[kMacos] &&
!argResults[kWeb] &&
!argResults[kWindows]) {
print('None of --linux, --macos, --web, --windows, --apk, or --ipa were '
'specified, so not building anything.');
Future<void> run() async {
final List<String> platformSwitches = <String>[
kApk,
kIpa,
kLinux,
kMacos,
kWeb,
kWindows,
];
final Map<String, bool> platforms = <String, bool>{
for (final String platform in platformSwitches)
platform: argResults[platform] as bool
};
if (!platforms.values.any((bool enabled) => enabled)) {
print(
'None of ${platformSwitches.map((String platform) => '--$platform').join(', ')} '
'were specified, so not building anything.');
return;
}
final String flutterCommand =
LocalPlatform().isWindows ? 'flutter.bat' : 'flutter';
const LocalPlatform().isWindows ? 'flutter.bat' : 'flutter';
final String enableExperiment = argResults[kEnableExperiment];
final String enableExperiment = argResults[kEnableExperiment] as String;
checkSharding();
final List<String> failingPackages = <String>[];
await for (Directory plugin in getPlugins()) {
for (Directory example in getExamplesForPlugin(plugin)) {
await for (final Directory plugin in getPlugins()) {
for (final Directory example in getExamplesForPlugin(plugin)) {
final String packageName =
p.relative(example.path, from: packagesDir.path);
if (argResults[kLinux]) {
if (platforms[kLinux]) {
print('\nBUILDING Linux for $packageName');
if (isLinuxPlugin(plugin, fileSystem)) {
int buildExitCode = await processRunner.runAndStream(
final int buildExitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
@ -82,10 +91,10 @@ class BuildExamplesCommand extends PluginCommand {
}
}
if (argResults[kMacos]) {
if (platforms[kMacos]) {
print('\nBUILDING macOS for $packageName');
if (isMacOsPlugin(plugin, fileSystem)) {
int exitCode = await processRunner.runAndStream(
final int exitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
@ -102,10 +111,10 @@ class BuildExamplesCommand extends PluginCommand {
}
}
if (argResults[kWeb]) {
if (platforms[kWeb]) {
print('\nBUILDING web for $packageName');
if (isWebPlugin(plugin, fileSystem)) {
int buildExitCode = await processRunner.runAndStream(
final int buildExitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
@ -122,10 +131,10 @@ class BuildExamplesCommand extends PluginCommand {
}
}
if (argResults[kWindows]) {
if (platforms[kWindows]) {
print('\nBUILDING Windows for $packageName');
if (isWindowsPlugin(plugin, fileSystem)) {
int buildExitCode = await processRunner.runAndStream(
final int buildExitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
@ -142,7 +151,7 @@ class BuildExamplesCommand extends PluginCommand {
}
}
if (argResults[kIpa]) {
if (platforms[kIpa]) {
print('\nBUILDING IPA for $packageName');
if (isIosPlugin(plugin, fileSystem)) {
final int exitCode = await processRunner.runAndStream(
@ -163,7 +172,7 @@ class BuildExamplesCommand extends PluginCommand {
}
}
if (argResults[kApk]) {
if (platforms[kApk]) {
print('\nBUILDING APK for $packageName');
if (isAndroidPlugin(plugin, fileSystem)) {
final int exitCode = await processRunner.runAndStream(
@ -188,7 +197,7 @@ class BuildExamplesCommand extends PluginCommand {
if (failingPackages.isNotEmpty) {
print('The following build are failing (see above for details):');
for (String package in failingPackages) {
for (final String package in failingPackages) {
print(' * $package');
}
throw ToolExit(1);