feat: migrate ios/bitcode.dart to null safety (#92557)
This commit is contained in:
@@ -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/common.dart';
|
||||
import '../base/context.dart';
|
||||
@@ -16,21 +14,23 @@ import '../macos/xcode.dart';
|
||||
const bool kBitcodeEnabledDefault = false;
|
||||
|
||||
Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform, EnvironmentType environmentType) async {
|
||||
final Artifacts localArtifacts = globals.artifacts;
|
||||
final String flutterFrameworkPath = localArtifacts.getArtifactPath(
|
||||
final Artifacts? localArtifacts = globals.artifacts;
|
||||
final String? flutterFrameworkPath = localArtifacts?.getArtifactPath(
|
||||
Artifact.flutterFramework,
|
||||
mode: buildMode,
|
||||
platform: targetPlatform,
|
||||
environmentType: environmentType,
|
||||
);
|
||||
final Xcode xcode = context.get<Xcode>();
|
||||
final Xcode? xcode = context.get<Xcode>();
|
||||
|
||||
final RunResult clangResult = await xcode.clang(<String>['--version']);
|
||||
final String clangVersion = clangResult.stdout.split('\n').first;
|
||||
final String engineClangVersion = globals.plistParser.getValueFromFile(
|
||||
globals.fs.path.join(flutterFrameworkPath, 'Info.plist'),
|
||||
'ClangVersion',
|
||||
);
|
||||
final RunResult? clangResult = await xcode?.clang(<String>['--version']);
|
||||
final String? clangVersion = clangResult?.stdout.split('\n').first;
|
||||
final String? engineClangVersion = flutterFrameworkPath == null
|
||||
? null
|
||||
: globals.plistParser.getValueFromFile(
|
||||
globals.fs.path.join(flutterFrameworkPath, 'Info.plist'),
|
||||
'ClangVersion',
|
||||
);
|
||||
final Version engineClangSemVer = _parseVersionFromClang(engineClangVersion);
|
||||
final Version clangSemVer = _parseVersionFromClang(clangVersion);
|
||||
if (engineClangSemVer > clangSemVer) {
|
||||
@@ -44,9 +44,9 @@ Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform,
|
||||
}
|
||||
}
|
||||
|
||||
Version _parseVersionFromClang(String clangVersion) {
|
||||
Version _parseVersionFromClang(String? clangVersion) {
|
||||
final RegExp pattern = RegExp(r'Apple (LLVM|clang) version (\d+\.\d+\.\d+) ');
|
||||
void _invalid() {
|
||||
Never _invalid() {
|
||||
throwToolExit('Unable to parse Clang version from "$clangVersion". '
|
||||
'Expected a string like "Apple (LLVM|clang) #.#.# (clang-####.#.##.#)".');
|
||||
}
|
||||
@@ -54,11 +54,11 @@ Version _parseVersionFromClang(String clangVersion) {
|
||||
if (clangVersion == null || clangVersion.isEmpty) {
|
||||
_invalid();
|
||||
}
|
||||
final RegExpMatch match = pattern.firstMatch(clangVersion);
|
||||
final RegExpMatch? match = pattern.firstMatch(clangVersion);
|
||||
if (match == null || match.groupCount != 2) {
|
||||
_invalid();
|
||||
}
|
||||
final Version version = Version.parse(match.group(2));
|
||||
final Version? version = Version.parse(match.group(2));
|
||||
if (version == null) {
|
||||
_invalid();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user