[flutter_tools] migrate tool_backend.dart to null safety and add testing of exit conditions (#78988)

This commit is contained in:
Jonah Williams
2021-03-24 15:23:21 -07:00
committed by GitHub
parent 5398c34cfe
commit 2eabb17215
2 changed files with 79 additions and 12 deletions

View File

@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
// Do not add package imports to this file.
import 'dart:convert'; // flutter_ignore: dart_convert_import.
import 'dart:io'; // flutter_ignore: dart_io_import.
@@ -13,24 +11,33 @@ Future<void> main(List<String> arguments) async {
final String targetPlatform = arguments[0];
final String buildMode = arguments[1].toLowerCase();
final String dartDefines = Platform.environment['DART_DEFINES'];
final String? dartDefines = Platform.environment['DART_DEFINES'];
final bool dartObfuscation = Platform.environment['DART_OBFUSCATION'] == 'true';
final String extraFrontEndOptions = Platform.environment['EXTRA_FRONT_END_OPTIONS'];
final String extraGenSnapshotOptions = Platform.environment['EXTRA_GEN_SNAPSHOT_OPTIONS'];
final String flutterEngine = Platform.environment['FLUTTER_ENGINE'];
final String flutterRoot = Platform.environment['FLUTTER_ROOT'];
final String? extraFrontEndOptions = Platform.environment['EXTRA_FRONT_END_OPTIONS'];
final String? extraGenSnapshotOptions = Platform.environment['EXTRA_GEN_SNAPSHOT_OPTIONS'];
final String? flutterEngine = Platform.environment['FLUTTER_ENGINE'];
final String? flutterRoot = Platform.environment['FLUTTER_ROOT'];
final String flutterTarget = Platform.environment['FLUTTER_TARGET']
?? pathJoin(<String>['lib', 'main.dart']);
final String codeSizeDirectory = Platform.environment['CODE_SIZE_DIRECTORY'];
final String localEngine = Platform.environment['LOCAL_ENGINE'];
final String projectDirectory = Platform.environment['PROJECT_DIR'];
final String splitDebugInfo = Platform.environment['SPLIT_DEBUG_INFO'];
final String bundleSkSLPath = Platform.environment['BUNDLE_SKSL_PATH'];
final String? codeSizeDirectory = Platform.environment['CODE_SIZE_DIRECTORY'];
final String? localEngine = Platform.environment['LOCAL_ENGINE'];
final String? projectDirectory = Platform.environment['PROJECT_DIR'];
final String? splitDebugInfo = Platform.environment['SPLIT_DEBUG_INFO'];
final String? bundleSkSLPath = Platform.environment['BUNDLE_SKSL_PATH'];
final bool trackWidgetCreation = Platform.environment['TRACK_WIDGET_CREATION'] == 'true';
final bool treeShakeIcons = Platform.environment['TREE_SHAKE_ICONS'] == 'true';
final bool verbose = Platform.environment['VERBOSE_SCRIPT_LOGGING'] == 'true';
final bool prefixedErrors = Platform.environment['PREFIXED_ERROR_LOGGING'] == 'true';
if (projectDirectory == null) {
stderr.write('PROJECT_DIR environment variable must be set to the location of Flutter project to be built.');
exit(1);
}
if (flutterRoot == null || flutterRoot.isEmpty) {
stderr.write('FLUTTER_ROOT environment variable must be set to the location of the Flutter SDK.');
exit(1);
}
Directory.current = projectDirectory;
if (localEngine != null && !localEngine.contains(buildMode)) {