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

This commit is contained in:
Jenn Magder
2021-06-04 10:49:04 -07:00
committed by GitHub
parent 0acf53e310
commit 4c6a9dcb40
15 changed files with 75 additions and 110 deletions

View File

@@ -2,10 +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
import 'package:meta/meta.dart';
import '../application_package.dart';
import '../base/file_system.dart';
import '../build_info.dart';
@@ -14,7 +10,7 @@ import '../globals_null_migrated.dart' as globals;
import '../project.dart';
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.
factory LinuxApp.fromLinuxProject(LinuxProject project) {
@@ -40,7 +36,7 @@ abstract class LinuxApp extends ApplicationPackage {
class PrebuiltLinuxApp extends LinuxApp {
PrebuiltLinuxApp({
@required String executable,
required String executable,
}) : _executable = executable,
super(projectBundleId: executable);
@@ -54,13 +50,13 @@ class PrebuiltLinuxApp 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;
@override
String executable(BuildMode buildMode) {
final String binaryName = getCmakeExecutableName(project);
final String? binaryName = getCmakeExecutableName(project);
return globals.fs.path.join(
getLinuxBuildDirectory(),
getNameForBuildMode(buildMode),

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
import '../artifacts.dart';
import '../base/analyze_size.dart';
import '../base/common.dart';
@@ -32,7 +30,7 @@ Future<void> buildLinux(
LinuxProject linuxProject,
BuildInfo buildInfo, {
String target = 'lib/main.dart',
SizeAnalyzer sizeAnalyzer,
SizeAnalyzer? sizeAnalyzer,
bool needCrossBuild = false,
TargetPlatform targetPlatform = TargetPlatform.linux_x64,
String targetSysroot = '/',
@@ -56,13 +54,14 @@ Future<void> buildLinux(
// step.
final Map<String, String> environmentConfig = buildInfo.toEnvironmentConfig();
environmentConfig['FLUTTER_TARGET'] = target;
if (globals.artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
final Artifacts? artifacts = globals.artifacts;
if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts;
final String engineOutPath = localEngineArtifacts.engineOutPath;
environmentConfig['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
environmentConfig['LOCAL_ENGINE'] = globals.fs.path.basename(engineOutPath);
}
writeGeneratedCmakeConfig(Cache.flutterRoot, linuxProject, environmentConfig);
writeGeneratedCmakeConfig(Cache.flutterRoot!, linuxProject, environmentConfig);
createPluginSymlinks(linuxProject.parent);
@@ -70,7 +69,7 @@ Future<void> buildLinux(
'Building Linux application...',
);
try {
final String buildModeName = getNameForBuildMode(buildInfo.mode ?? BuildMode.release);
final String buildModeName = getNameForBuildMode(buildInfo.mode);
final Directory buildDirectory =
globals.fs.directory(getLinuxBuildDirectory(targetPlatform)).childDirectory(buildModeName);
await _runCmake(buildModeName, linuxProject.cmakeFile.parent, buildDirectory,
@@ -85,7 +84,7 @@ Future<void> buildLinux(
.childFile('snapshot.$arch.json');
final File precompilerTrace = globals.fs.directory(buildInfo.codeSizeDirectory)
.childFile('trace.$arch.json');
final Map<String, Object> output = await sizeAnalyzer.analyzeAotSnapshot(
final Map<String, Object?> output = await sizeAnalyzer.analyzeAotSnapshot(
aotSnapshot: codeSizeFile,
// This analysis is only supported for release builds.
outputDirectory: globals.fs.directory(