Unverified Commit 4c6a9dcb authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate a few tool libraries to null safety (#83862)

parent 0acf53e3
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
...@@ -30,7 +28,7 @@ class DartPluginRegistrantTarget extends Target { ...@@ -30,7 +28,7 @@ class DartPluginRegistrantTarget extends Target {
DartPluginRegistrantTarget._(this._project); DartPluginRegistrantTarget._(this._project);
final FlutterProject _project; final FlutterProject? _project;
@override @override
Future<void> build(Environment environment) async { Future<void> build(Environment environment) async {
...@@ -66,11 +64,11 @@ class DartPluginRegistrantTarget extends Target { ...@@ -66,11 +64,11 @@ class DartPluginRegistrantTarget extends Target {
if (!environment.generateDartPluginRegistry) { if (!environment.generateDartPluginRegistry) {
return true; return true;
} }
final String platformName = environment.defines[kTargetPlatform]; final String? platformName = environment.defines[kTargetPlatform];
if (platformName == null) { if (platformName == null) {
return true; return true;
} }
final TargetPlatform targetPlatform = getTargetPlatformForName(platformName); final TargetPlatform? targetPlatform = getTargetPlatformForName(platformName);
// TODO(egarciad): Support Android and iOS. // TODO(egarciad): Support Android and iOS.
// https://github.com/flutter/flutter/issues/52267 // https://github.com/flutter/flutter/issues/52267
return targetPlatform != TargetPlatform.darwin && return targetPlatform != TargetPlatform.darwin &&
......
...@@ -9,7 +9,6 @@ import 'device.dart'; ...@@ -9,7 +9,6 @@ import 'device.dart';
import 'doctor.dart'; import 'doctor.dart';
import 'fuchsia/fuchsia_sdk.dart'; import 'fuchsia/fuchsia_sdk.dart';
import 'ios/simulators.dart'; import 'ios/simulators.dart';
import 'macos/cocoapods_validator.dart';
import 'macos/xcdevice.dart'; import 'macos/xcdevice.dart';
import 'reporting/crash_reporting.dart'; import 'reporting/crash_reporting.dart';
import 'runner/local_engine.dart'; import 'runner/local_engine.dart';
...@@ -20,8 +19,6 @@ CrashReporter get crashReporter => context.get<CrashReporter>(); ...@@ -20,8 +19,6 @@ CrashReporter get crashReporter => context.get<CrashReporter>();
Doctor get doctor => context.get<Doctor>(); Doctor get doctor => context.get<Doctor>();
DeviceManager get deviceManager => context.get<DeviceManager>(); DeviceManager get deviceManager => context.get<DeviceManager>();
CocoaPodsValidator get cocoapodsValidator => context.get<CocoaPodsValidator>();
LocalEngineLocator get localEngineLocator => context.get<LocalEngineLocator>(); LocalEngineLocator get localEngineLocator => context.get<LocalEngineLocator>();
FuchsiaArtifacts get fuchsiaArtifacts => context.get<FuchsiaArtifacts>(); FuchsiaArtifacts get fuchsiaArtifacts => context.get<FuchsiaArtifacts>();
IOSSimulatorUtils get iosSimulatorUtils => context.get<IOSSimulatorUtils>(); IOSSimulatorUtils get iosSimulatorUtils => context.get<IOSSimulatorUtils>();
......
...@@ -30,6 +30,7 @@ import 'ios/ios_workflow.dart'; ...@@ -30,6 +30,7 @@ import 'ios/ios_workflow.dart';
import 'ios/plist_parser.dart'; import 'ios/plist_parser.dart';
import 'ios/xcodeproj.dart'; import 'ios/xcodeproj.dart';
import 'macos/cocoapods.dart'; import 'macos/cocoapods.dart';
import 'macos/cocoapods_validator.dart';
import 'macos/xcode.dart'; import 'macos/xcode.dart';
import 'persistent_tool_state.dart'; import 'persistent_tool_state.dart';
import 'project.dart'; import 'project.dart';
...@@ -39,6 +40,7 @@ import 'version.dart'; ...@@ -39,6 +40,7 @@ import 'version.dart';
Artifacts? get artifacts => context.get<Artifacts>(); Artifacts? get artifacts => context.get<Artifacts>();
BuildSystem? get buildSystem => context.get<BuildSystem>(); BuildSystem? get buildSystem => context.get<BuildSystem>();
Cache get cache => context.get<Cache>()!; Cache get cache => context.get<Cache>()!;
CocoaPodsValidator? get cocoapodsValidator => context.get<CocoaPodsValidator>();
Config get config => context.get<Config>()!; Config get config => context.get<Config>()!;
HttpClientFactory? get httpClientFactory => context.get<HttpClientFactory>(); HttpClientFactory? get httpClientFactory => context.get<HttpClientFactory>();
Logger get logger => context.get<Logger>()!; Logger get logger => context.get<Logger>()!;
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:meta/meta.dart';
import '../application_package.dart'; import '../application_package.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../build_info.dart'; import '../build_info.dart';
...@@ -14,7 +10,7 @@ import '../globals_null_migrated.dart' as globals; ...@@ -14,7 +10,7 @@ import '../globals_null_migrated.dart' as globals;
import '../project.dart'; import '../project.dart';
abstract class LinuxApp extends ApplicationPackage { abstract class LinuxApp extends ApplicationPackage {
LinuxApp({@required String projectBundleId}) : super(id: projectBundleId); LinuxApp({required String projectBundleId}) : super(id: projectBundleId);
/// Creates a new [LinuxApp] from a linux sub project. /// Creates a new [LinuxApp] from a linux sub project.
factory LinuxApp.fromLinuxProject(LinuxProject project) { factory LinuxApp.fromLinuxProject(LinuxProject project) {
...@@ -40,7 +36,7 @@ abstract class LinuxApp extends ApplicationPackage { ...@@ -40,7 +36,7 @@ abstract class LinuxApp extends ApplicationPackage {
class PrebuiltLinuxApp extends LinuxApp { class PrebuiltLinuxApp extends LinuxApp {
PrebuiltLinuxApp({ PrebuiltLinuxApp({
@required String executable, required String executable,
}) : _executable = executable, }) : _executable = executable,
super(projectBundleId: executable); super(projectBundleId: executable);
...@@ -54,13 +50,13 @@ class PrebuiltLinuxApp extends LinuxApp { ...@@ -54,13 +50,13 @@ class PrebuiltLinuxApp extends LinuxApp {
} }
class BuildableLinuxApp extends LinuxApp { class BuildableLinuxApp extends LinuxApp {
BuildableLinuxApp({this.project}) : super(projectBundleId: project.parent.manifest.appName); BuildableLinuxApp({required this.project}) : super(projectBundleId: project.parent.manifest.appName);
final LinuxProject project; final LinuxProject project;
@override @override
String executable(BuildMode buildMode) { String executable(BuildMode buildMode) {
final String binaryName = getCmakeExecutableName(project); final String? binaryName = getCmakeExecutableName(project);
return globals.fs.path.join( return globals.fs.path.join(
getLinuxBuildDirectory(), getLinuxBuildDirectory(),
getNameForBuildMode(buildMode), getNameForBuildMode(buildMode),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../artifacts.dart'; import '../artifacts.dart';
import '../base/analyze_size.dart'; import '../base/analyze_size.dart';
import '../base/common.dart'; import '../base/common.dart';
...@@ -32,7 +30,7 @@ Future<void> buildLinux( ...@@ -32,7 +30,7 @@ Future<void> buildLinux(
LinuxProject linuxProject, LinuxProject linuxProject,
BuildInfo buildInfo, { BuildInfo buildInfo, {
String target = 'lib/main.dart', String target = 'lib/main.dart',
SizeAnalyzer sizeAnalyzer, SizeAnalyzer? sizeAnalyzer,
bool needCrossBuild = false, bool needCrossBuild = false,
TargetPlatform targetPlatform = TargetPlatform.linux_x64, TargetPlatform targetPlatform = TargetPlatform.linux_x64,
String targetSysroot = '/', String targetSysroot = '/',
...@@ -56,13 +54,14 @@ Future<void> buildLinux( ...@@ -56,13 +54,14 @@ Future<void> buildLinux(
// step. // step.
final Map<String, String> environmentConfig = buildInfo.toEnvironmentConfig(); final Map<String, String> environmentConfig = buildInfo.toEnvironmentConfig();
environmentConfig['FLUTTER_TARGET'] = target; environmentConfig['FLUTTER_TARGET'] = target;
if (globals.artifacts is LocalEngineArtifacts) { final Artifacts? artifacts = globals.artifacts;
final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts; if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts;
final String engineOutPath = localEngineArtifacts.engineOutPath; final String engineOutPath = localEngineArtifacts.engineOutPath;
environmentConfig['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath)); environmentConfig['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
environmentConfig['LOCAL_ENGINE'] = globals.fs.path.basename(engineOutPath); environmentConfig['LOCAL_ENGINE'] = globals.fs.path.basename(engineOutPath);
} }
writeGeneratedCmakeConfig(Cache.flutterRoot, linuxProject, environmentConfig); writeGeneratedCmakeConfig(Cache.flutterRoot!, linuxProject, environmentConfig);
createPluginSymlinks(linuxProject.parent); createPluginSymlinks(linuxProject.parent);
...@@ -70,7 +69,7 @@ Future<void> buildLinux( ...@@ -70,7 +69,7 @@ Future<void> buildLinux(
'Building Linux application...', 'Building Linux application...',
); );
try { try {
final String buildModeName = getNameForBuildMode(buildInfo.mode ?? BuildMode.release); final String buildModeName = getNameForBuildMode(buildInfo.mode);
final Directory buildDirectory = final Directory buildDirectory =
globals.fs.directory(getLinuxBuildDirectory(targetPlatform)).childDirectory(buildModeName); globals.fs.directory(getLinuxBuildDirectory(targetPlatform)).childDirectory(buildModeName);
await _runCmake(buildModeName, linuxProject.cmakeFile.parent, buildDirectory, await _runCmake(buildModeName, linuxProject.cmakeFile.parent, buildDirectory,
...@@ -85,7 +84,7 @@ Future<void> buildLinux( ...@@ -85,7 +84,7 @@ Future<void> buildLinux(
.childFile('snapshot.$arch.json'); .childFile('snapshot.$arch.json');
final File precompilerTrace = globals.fs.directory(buildInfo.codeSizeDirectory) final File precompilerTrace = globals.fs.directory(buildInfo.codeSizeDirectory)
.childFile('trace.$arch.json'); .childFile('trace.$arch.json');
final Map<String, Object> output = await sizeAnalyzer.analyzeAotSnapshot( final Map<String, Object?> output = await sizeAnalyzer.analyzeAotSnapshot(
aotSnapshot: codeSizeFile, aotSnapshot: codeSizeFile,
// This analysis is only supported for release builds. // This analysis is only supported for release builds.
outputDirectory: globals.fs.directory( outputDirectory: globals.fs.directory(
......
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../base/fingerprint.dart'; import '../base/fingerprint.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
import '../flutter_plugins.dart'; import '../flutter_plugins.dart';
import '../globals.dart' as globals; import '../globals_null_migrated.dart' as globals;
import '../project.dart'; import '../project.dart';
/// For a given build, determines whether dependencies have changed since the /// For a given build, determines whether dependencies have changed since the
...@@ -32,7 +30,7 @@ Future<void> processPodsIfNeeded( ...@@ -32,7 +30,7 @@ Future<void> processPodsIfNeeded(
xcodeProject.podfile.path, xcodeProject.podfile.path,
xcodeProject.generatedXcodePropertiesFile.path, xcodeProject.generatedXcodePropertiesFile.path,
globals.fs.path.join( globals.fs.path.join(
Cache.flutterRoot, Cache.flutterRoot!,
'packages', 'packages',
'flutter_tools', 'flutter_tools',
'bin', 'bin',
...@@ -43,11 +41,11 @@ Future<void> processPodsIfNeeded( ...@@ -43,11 +41,11 @@ Future<void> processPodsIfNeeded(
logger: globals.logger, logger: globals.logger,
); );
final bool didPodInstall = await globals.cocoaPods.processPods( final bool didPodInstall = await globals.cocoaPods?.processPods(
xcodeProject: xcodeProject, xcodeProject: xcodeProject,
buildMode: buildMode, buildMode: buildMode,
dependenciesChanged: !fingerprinter.doesFingerprintMatch(), dependenciesChanged: !fingerprinter.doesFingerprintMatch(),
); ) == true;
if (didPodInstall) { if (didPodInstall) {
fingerprinter.writeFingerprint(); fingerprinter.writeFingerprint();
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../base/user_messages.dart'; import '../base/user_messages.dart';
import '../doctor_validator.dart'; import '../doctor_validator.dart';
import 'cocoapods.dart'; import 'cocoapods.dart';
...@@ -32,7 +30,7 @@ class CocoaPodsValidator extends DoctorValidator { ...@@ -32,7 +30,7 @@ class CocoaPodsValidator extends DoctorValidator {
ValidationType status = ValidationType.installed; ValidationType status = ValidationType.installed;
if (cocoaPodsStatus == CocoaPodsStatus.recommended) { if (cocoaPodsStatus == CocoaPodsStatus.recommended) {
messages.add(ValidationMessage(_userMessages.cocoaPodsVersion(await _cocoaPods.cocoaPodsVersionText))); messages.add(ValidationMessage(_userMessages.cocoaPodsVersion((await _cocoaPods.cocoaPodsVersionText).toString())));
} else { } else {
if (cocoaPodsStatus == CocoaPodsStatus.notInstalled) { if (cocoaPodsStatus == CocoaPodsStatus.notInstalled) {
status = ValidationType.missing; status = ValidationType.missing;
...@@ -50,7 +48,7 @@ class CocoaPodsValidator extends DoctorValidator { ...@@ -50,7 +48,7 @@ class CocoaPodsValidator extends DoctorValidator {
_userMessages.cocoaPodsUnknownVersion(unknownCocoaPodsConsequence, cocoaPodsInstallInstructions))); _userMessages.cocoaPodsUnknownVersion(unknownCocoaPodsConsequence, cocoaPodsInstallInstructions)));
} else { } else {
status = ValidationType.partial; status = ValidationType.partial;
final String currentVersionText = await _cocoaPods.cocoaPodsVersionText; final String currentVersionText = (await _cocoaPods.cocoaPodsVersionText).toString();
messages.add(ValidationMessage.hint( messages.add(ValidationMessage.hint(
_userMessages.cocoaPodsOutdated(currentVersionText, cocoaPodsRecommendedVersion.toString(), noCocoaPodsConsequence, cocoaPodsInstallInstructions))); _userMessages.cocoaPodsOutdated(currentVersionText, cocoaPodsRecommendedVersion.toString(), noCocoaPodsConsequence, cocoaPodsInstallInstructions)));
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../../base/common.dart'; import '../../base/common.dart';
import '../../base/file_system.dart'; import '../../base/file_system.dart';
import '../../base/logger.dart'; import '../../base/logger.dart';
...@@ -38,7 +36,7 @@ class RemoveMacOSFrameworkLinkAndEmbeddingMigration extends ProjectMigrator { ...@@ -38,7 +36,7 @@ class RemoveMacOSFrameworkLinkAndEmbeddingMigration extends ProjectMigrator {
} }
@override @override
String migrateLine(String line) { String? migrateLine(String line) {
// App.framework Frameworks reference. // App.framework Frameworks reference.
// isa = PBXFrameworksBuildPhase; // isa = PBXFrameworksBuildPhase;
// files = ( // files = (
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/project_migrator.dart'; import '../base/project_migrator.dart';
...@@ -51,8 +49,8 @@ class CmakeCustomCommandMigration extends ProjectMigrator { ...@@ -51,8 +49,8 @@ class CmakeCustomCommandMigration extends ProjectMigrator {
final Iterable<RegExpMatch> matches = addCustomCommand.allMatches(originalProjectContents); final Iterable<RegExpMatch> matches = addCustomCommand.allMatches(originalProjectContents);
for (final RegExpMatch match in matches) { for (final RegExpMatch match in matches) {
final String addCustomCommandOriginal = match.group(1); final String? addCustomCommandOriginal = match.group(1);
if (addCustomCommandOriginal?.contains('VERBATIM') == false) { if (addCustomCommandOriginal != null && addCustomCommandOriginal.contains('VERBATIM') == false) {
final String addCustomCommandReplacement = '$addCustomCommandOriginal\n VERBATIM'; final String addCustomCommandReplacement = '$addCustomCommandOriginal\n VERBATIM';
newProjectContents = newProjectContents.replaceAll(addCustomCommandOriginal, addCustomCommandReplacement); newProjectContents = newProjectContents.replaceAll(addCustomCommandOriginal, addCustomCommandReplacement);
} }
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
import '../artifacts.dart'; import '../artifacts.dart';
...@@ -31,11 +28,11 @@ import '../dart/package_map.dart'; ...@@ -31,11 +28,11 @@ import '../dart/package_map.dart';
/// For more information on local engines, see CONTRIBUTING.md. /// For more information on local engines, see CONTRIBUTING.md.
class LocalEngineLocator { class LocalEngineLocator {
LocalEngineLocator({ LocalEngineLocator({
@required Platform platform, required Platform platform,
@required Logger logger, required Logger logger,
@required FileSystem fileSystem, required FileSystem fileSystem,
@required String flutterRoot, required String flutterRoot,
@required UserMessages userMessages, required UserMessages userMessages,
}) : _platform = platform, }) : _platform = platform,
_logger = logger, _logger = logger,
_fileSystem = fileSystem, _fileSystem = fileSystem,
...@@ -49,7 +46,7 @@ class LocalEngineLocator { ...@@ -49,7 +46,7 @@ class LocalEngineLocator {
final UserMessages _userMessages; final UserMessages _userMessages;
/// Returns the engine build path of a local engine if one is located, otherwise `null`. /// Returns the engine build path of a local engine if one is located, otherwise `null`.
Future<EngineBuildPaths> findEnginePath(String engineSourcePath, String localEngine, String packagePath) async { Future<EngineBuildPaths?> findEnginePath(String? engineSourcePath, String? localEngine, String? packagePath) async {
engineSourcePath ??= _platform.environment[kFlutterEngineEnvironmentVariableName]; engineSourcePath ??= _platform.environment[kFlutterEngineEnvironmentVariableName];
if (engineSourcePath == null && localEngine != null) { if (engineSourcePath == null && localEngine != null) {
...@@ -89,15 +86,15 @@ class LocalEngineLocator { ...@@ -89,15 +86,15 @@ class LocalEngineLocator {
return null; return null;
} }
String _findEngineSourceByLocalEngine(String localEngine) { String? _findEngineSourceByLocalEngine(String localEngine) {
// When the local engine is an absolute path to a variant inside the // When the local engine is an absolute path to a variant inside the
// out directory, parse the engine source. // out directory, parse the engine source.
// --local-engine /path/to/cache/builder/src/out/host_debug_unopt // --local-engine /path/to/cache/builder/src/out/host_debug_unopt
if (_fileSystem.path.isAbsolute(localEngine)) { if (_fileSystem.path.isAbsolute(localEngine)) {
final Directory localEngineDirectory = _fileSystem.directory(localEngine); final Directory localEngineDirectory = _fileSystem.directory(localEngine);
final Directory outDirectory = localEngineDirectory?.parent; final Directory outDirectory = localEngineDirectory.parent;
final Directory srcDirectory = outDirectory?.parent; final Directory srcDirectory = outDirectory.parent;
if (localEngineDirectory.existsSync() && outDirectory?.basename == 'out' && srcDirectory?.basename == 'src') { if (localEngineDirectory.existsSync() && outDirectory.basename == 'out' && srcDirectory.basename == 'src') {
_logger.printTrace('Parsed engine source from local engine as ${srcDirectory.path}.'); _logger.printTrace('Parsed engine source from local engine as ${srcDirectory.path}.');
return srcDirectory.path; return srcDirectory.path;
} }
...@@ -105,7 +102,7 @@ class LocalEngineLocator { ...@@ -105,7 +102,7 @@ class LocalEngineLocator {
return null; return null;
} }
Future<String> _findEngineSourceByPackageConfig(String packagePath) async { Future<String?> _findEngineSourceByPackageConfig(String? packagePath) async {
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
_fileSystem.file( _fileSystem.file(
// TODO(jonahwilliams): update to package_config // TODO(jonahwilliams): update to package_config
...@@ -115,7 +112,7 @@ class LocalEngineLocator { ...@@ -115,7 +112,7 @@ class LocalEngineLocator {
throwOnError: false, throwOnError: false,
); );
// Skip if sky_engine is the version in bin/cache. // Skip if sky_engine is the version in bin/cache.
Uri engineUri = packageConfig[kFlutterEnginePackageName]?.packageUriRoot; Uri? engineUri = packageConfig[kFlutterEnginePackageName]?.packageUriRoot;
final String cachedPath = _fileSystem.path.join(_flutterRoot, 'bin', 'cache', 'pkg', kFlutterEnginePackageName, 'lib'); final String cachedPath = _fileSystem.path.join(_flutterRoot, 'bin', 'cache', 'pkg', kFlutterEnginePackageName, 'lib');
if (engineUri != null && _fileSystem.identicalSync(cachedPath, engineUri.path)) { if (engineUri != null && _fileSystem.identicalSync(cachedPath, engineUri.path)) {
_logger.printTrace('Local engine auto-detection sky_engine in $packagePath is the same version in bin/cache.'); _logger.printTrace('Local engine auto-detection sky_engine in $packagePath is the same version in bin/cache.');
...@@ -125,16 +122,17 @@ class LocalEngineLocator { ...@@ -125,16 +122,17 @@ class LocalEngineLocator {
// determine the engineSourcePath by sky_engine setting. A typical engine Uri // determine the engineSourcePath by sky_engine setting. A typical engine Uri
// looks like: // looks like:
// file://flutter-engine-local-path/src/out/host_debug_unopt/gen/dart-pkg/sky_engine/lib/ // file://flutter-engine-local-path/src/out/host_debug_unopt/gen/dart-pkg/sky_engine/lib/
String engineSourcePath; String? engineSourcePath;
if (engineUri?.path != null) { final String? engineUriPath = engineUri?.path;
engineSourcePath = _fileSystem.directory(engineUri.path) if (engineUriPath != null) {
?.parent engineSourcePath = _fileSystem.directory(engineUriPath)
?.parent .parent
?.parent .parent
?.parent .parent
?.parent .parent
?.parent .parent
?.path; .parent
.path;
if (engineSourcePath != null && (engineSourcePath == _fileSystem.path.dirname(engineSourcePath) || engineSourcePath.isEmpty)) { if (engineSourcePath != null && (engineSourcePath == _fileSystem.path.dirname(engineSourcePath) || engineSourcePath.isEmpty)) {
engineSourcePath = null; engineSourcePath = null;
throwToolExit( throwToolExit(
...@@ -166,7 +164,7 @@ class LocalEngineLocator { ...@@ -166,7 +164,7 @@ class LocalEngineLocator {
return 'host_$tmpBasename'; return 'host_$tmpBasename';
} }
EngineBuildPaths _findEngineBuildPath(String localEngine, String enginePath) { EngineBuildPaths _findEngineBuildPath(String? localEngine, String enginePath) {
if (localEngine == null) { if (localEngine == null) {
throwToolExit(_userMessages.runnerLocalEngineRequired, exitCode: 2); throwToolExit(_userMessages.runnerLocalEngineRequired, exitCode: 2);
} }
...@@ -188,7 +186,7 @@ class LocalEngineLocator { ...@@ -188,7 +186,7 @@ class LocalEngineLocator {
return EngineBuildPaths(targetEngine: engineBuildPath, hostEngine: engineHostBuildPath); return EngineBuildPaths(targetEngine: engineBuildPath, hostEngine: engineHostBuildPath);
} }
String _tryEnginePath(String enginePath) { String? _tryEnginePath(String enginePath) {
if (_fileSystem.isDirectorySync(_fileSystem.path.join(enginePath, 'out'))) { if (_fileSystem.isDirectorySync(_fileSystem.path.join(enginePath, 'out'))) {
return enginePath; return enginePath;
} }
......
...@@ -2,11 +2,8 @@ ...@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:meta/meta.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import '../artifacts.dart'; import '../artifacts.dart';
...@@ -21,9 +18,9 @@ import '../base/process.dart'; ...@@ -21,9 +18,9 @@ import '../base/process.dart';
/// apps. /// apps.
class UwpTool { class UwpTool {
UwpTool({ UwpTool({
@required Artifacts artifacts, required Artifacts artifacts,
@required Logger logger, required Logger logger,
@required ProcessManager processManager, required ProcessManager processManager,
}) : _artifacts = artifacts, }) : _artifacts = artifacts,
_logger = logger, _logger = logger,
_processUtils = ProcessUtils(processManager: processManager, logger: logger); _processUtils = ProcessUtils(processManager: processManager, logger: logger);
...@@ -58,7 +55,7 @@ class UwpTool { ...@@ -58,7 +55,7 @@ class UwpTool {
/// ///
/// If no installed application on the system matches the specified package /// If no installed application on the system matches the specified package
/// name, returns null. /// name, returns null.
Future<String/*?*/> getPackageFamilyName(String packageName) async { Future<String?> getPackageFamilyName(String packageName) async {
for (final String packageFamily in await listApps()) { for (final String packageFamily in await listApps()) {
if (packageFamily.startsWith(packageName)) { if (packageFamily.startsWith(packageName)) {
return packageFamily; return packageFamily;
...@@ -70,7 +67,7 @@ class UwpTool { ...@@ -70,7 +67,7 @@ class UwpTool {
/// Launches the app with the specified package family name. /// Launches the app with the specified package family name.
/// ///
/// On success, returns the process ID of the launched app, otherwise null. /// On success, returns the process ID of the launched app, otherwise null.
Future<int/*?*/> launchApp(String packageFamily, List<String> args) async { Future<int?> launchApp(String packageFamily, List<String> args) async {
final List<String> launchCommand = <String>[ final List<String> launchCommand = <String>[
_binaryPath, _binaryPath,
'launch', 'launch',
...@@ -82,7 +79,7 @@ class UwpTool { ...@@ -82,7 +79,7 @@ class UwpTool {
return null; return null;
} }
// Read the process ID from stdout. // Read the process ID from stdout.
final int processId = int.tryParse(result.stdout.trim()); final int? processId = int.tryParse(result.stdout.trim());
_logger.printTrace('Launched application $packageFamily with process ID $processId'); _logger.printTrace('Launched application $packageFamily with process ID $processId');
return processId; return processId;
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/user_messages.dart'; import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/doctor_validator.dart'; import 'package:flutter_tools/src/doctor_validator.dart';
import 'package:flutter_tools/src/macos/cocoapods.dart'; import 'package:flutter_tools/src/macos/cocoapods.dart';
...@@ -15,7 +13,7 @@ import '../../src/common.dart'; ...@@ -15,7 +13,7 @@ import '../../src/common.dart';
void main() { void main() {
group('CocoaPods validation', () { group('CocoaPods validation', () {
testWithoutContext('Emits installed status when CocoaPods is installed', () async { testWithoutContext('Emits installed status when CocoaPods is installed', () async {
final CocoaPodsValidator workflow = CocoaPodsValidator(FakeCocoaPods(CocoaPodsStatus.recommended), UserMessages()); final CocoaPodsValidator workflow = CocoaPodsValidator(FakeCocoaPods(CocoaPodsStatus.recommended, '1000.0.0'), UserMessages());
final ValidationResult result = await workflow.validate(); final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.installed); expect(result.type, ValidationType.installed);
}); });
...@@ -55,6 +53,6 @@ class FakeCocoaPods extends Fake implements CocoaPods { ...@@ -55,6 +53,6 @@ class FakeCocoaPods extends Fake implements CocoaPods {
final CocoaPodsStatus _evaluateCocoaPodsInstallation; final CocoaPodsStatus _evaluateCocoaPodsInstallation;
@override @override
Future<String> get cocoaPodsVersionText async => _cocoaPodsVersionText; Future<String?> get cocoaPodsVersionText async => _cocoaPodsVersionText;
final String _cocoaPodsVersionText; final String? _cocoaPodsVersionText;
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -11,17 +9,16 @@ import 'package:flutter_tools/src/base/project_migrator.dart'; ...@@ -11,17 +9,16 @@ import 'package:flutter_tools/src/base/project_migrator.dart';
import 'package:flutter_tools/src/macos/migrations/remove_macos_framework_link_and_embedding_migration.dart'; import 'package:flutter_tools/src/macos/migrations/remove_macos_framework_link_and_embedding_migration.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
void main() { void main() {
TestUsage testUsage; late TestUsage testUsage;
MemoryFileSystem memoryFileSystem; late MemoryFileSystem memoryFileSystem;
BufferLogger testLogger; late BufferLogger testLogger;
FakeMacOSProject macOSProject; late FakeMacOSProject macOSProject;
File xcodeProjectInfoFile; late File xcodeProjectInfoFile;
setUp(() { setUp(() {
testUsage = TestUsage(); testUsage = TestUsage();
...@@ -160,11 +157,11 @@ keep this 2 ...@@ -160,11 +157,11 @@ keep this 2
class FakeMacOSProject extends Fake implements MacOSProject { class FakeMacOSProject extends Fake implements MacOSProject {
@override @override
File xcodeProjectInfoFile; File xcodeProjectInfoFile = MemoryFileSystem.test().file('xcodeProjectInfoFile');
} }
class FakeMacOSMigrator extends ProjectMigrator { class FakeMacOSMigrator extends ProjectMigrator {
FakeMacOSMigrator({@required this.succeeds}) : super(null); FakeMacOSMigrator({required this.succeeds}) : super(BufferLogger.test());
final bool succeeds; final bool succeeds;
......
...@@ -2,17 +2,13 @@ ...@@ -2,17 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/project_migrator.dart'; import 'package:flutter_tools/src/base/project_migrator.dart';
import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/migrations/cmake_custom_command_migration.dart'; import 'package:flutter_tools/src/migrations/cmake_custom_command_migration.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
...@@ -32,20 +28,17 @@ void main () { ...@@ -32,20 +28,17 @@ void main () {
}); });
group('migrate add_custom_command() to use VERBATIM', () { group('migrate add_custom_command() to use VERBATIM', () {
MemoryFileSystem memoryFileSystem; late MemoryFileSystem memoryFileSystem;
BufferLogger testLogger; late BufferLogger testLogger;
FakeCmakeProject mockCmakeProject; late FakeCmakeProject mockCmakeProject;
File managedCmakeFile; late File managedCmakeFile;
setUp(() { setUp(() {
memoryFileSystem = MemoryFileSystem.test(); memoryFileSystem = MemoryFileSystem.test();
managedCmakeFile = memoryFileSystem.file('CMakeLists.txtx'); managedCmakeFile = memoryFileSystem.file('CMakeLists.txtx');
testLogger = BufferLogger( testLogger = BufferLogger(
terminal: AnsiTerminal( terminal: Terminal.test(),
stdio: null,
platform: const LocalPlatform(),
),
outputPreferences: OutputPreferences.test(), outputPreferences: OutputPreferences.test(),
); );
...@@ -186,8 +179,8 @@ class FakeCmakeProject extends Fake implements CmakeBasedProject { ...@@ -186,8 +179,8 @@ class FakeCmakeProject extends Fake implements CmakeBasedProject {
} }
class FakeCmakeMigrator extends ProjectMigrator { class FakeCmakeMigrator extends ProjectMigrator {
FakeCmakeMigrator({@required this.succeeds}) FakeCmakeMigrator({required this.succeeds})
: super(null); : super(BufferLogger.test());
final bool succeeds; final bool succeeds;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -246,8 +244,8 @@ void main() { ...@@ -246,8 +244,8 @@ void main() {
} }
Matcher matchesEngineBuildPaths({ Matcher matchesEngineBuildPaths({
String hostEngine, String? hostEngine,
String targetEngine, String? targetEngine,
}) { }) {
return const TypeMatcher<EngineBuildPaths>() return const TypeMatcher<EngineBuildPaths>()
.having((EngineBuildPaths paths) => paths.hostEngine, 'hostEngine', hostEngine) .having((EngineBuildPaths paths) => paths.hostEngine, 'hostEngine', hostEngine)
......
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