mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Update validation to support Xcode11 version (#39463)
This commit is contained in:
parent
d2f70a6d20
commit
632526aab9
@ -226,19 +226,20 @@ Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform)
|
||||
}
|
||||
|
||||
Version _parseVersionFromClang(String clangVersion) {
|
||||
const String prefix = 'Apple LLVM version ';
|
||||
final RegExp pattern = RegExp(r'Apple (LLVM|clang) version (\d+\.\d+\.\d+) ');
|
||||
void _invalid() {
|
||||
throwToolExit('Unable to parse Clang version from "$clangVersion". '
|
||||
'Expected a string like "$prefix #.#.# (clang-####.#.##.#)".');
|
||||
'Expected a string like "Apple (LLVM|clang) #.#.# (clang-####.#.##.#)".');
|
||||
}
|
||||
if (clangVersion == null || clangVersion.length <= prefix.length || !clangVersion.startsWith(prefix)) {
|
||||
|
||||
if (clangVersion == null || clangVersion.isEmpty) {
|
||||
_invalid();
|
||||
}
|
||||
final int lastSpace = clangVersion.lastIndexOf(' ');
|
||||
if (lastSpace == -1) {
|
||||
final RegExpMatch match = pattern.firstMatch(clangVersion);
|
||||
if (match == null || match.groupCount != 2) {
|
||||
_invalid();
|
||||
}
|
||||
final Version version = Version.parse(clangVersion.substring(prefix.length, lastSpace));
|
||||
final Version version = Version.parse(match.group(2));
|
||||
if (version == null) {
|
||||
_invalid();
|
||||
}
|
||||
|
@ -43,6 +43,80 @@ void main() {
|
||||
FileSystem: () => memoryFileSystem,
|
||||
});
|
||||
|
||||
testUsingContext('build aot prints error if Clang version invalid', () async {
|
||||
final Directory flutterFramework = memoryFileSystem.directory('ios_profile/Flutter.framework')
|
||||
..createSync(recursive: true);
|
||||
flutterFramework.childFile('Flutter').createSync();
|
||||
final File infoPlist = flutterFramework.childFile('Info.plist')..createSync();
|
||||
|
||||
final RunResult clangResult = RunResult(
|
||||
FakeProcessResult(stdout: 'Apple pie version 10.1.0 (clang-4567.1.1.1)\nBlahBlah\n', stderr: ''),
|
||||
const <String>['foo'],
|
||||
);
|
||||
when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(clangResult));
|
||||
when(mockPlistUtils.getValueFromFile(infoPlist.path, 'ClangVersion')).thenReturn('Apple LLVM version 10.0.1 (clang-1234.1.12.1)');
|
||||
|
||||
await expectToolExitLater(
|
||||
validateBitcode(BuildMode.profile, TargetPlatform.ios),
|
||||
equals('Unable to parse Clang version from "Apple pie version 10.1.0 (clang-4567.1.1.1)". '
|
||||
'Expected a string like "Apple (LLVM|clang) #.#.# (clang-####.#.##.#)".'),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => LocalEngineArtifacts('/engine', 'ios_profile', 'host_profile'),
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Xcode: () => mockXcode,
|
||||
Logger: () => bufferLogger,
|
||||
PlistParser: () => mockPlistUtils,
|
||||
});
|
||||
|
||||
testUsingContext('build aot can parse valid Xcode Clang version (10)', () async {
|
||||
final Directory flutterFramework = memoryFileSystem.directory('ios_profile/Flutter.framework')
|
||||
..createSync(recursive: true);
|
||||
flutterFramework.childFile('Flutter').createSync();
|
||||
final File infoPlist = flutterFramework.childFile('Info.plist')..createSync();
|
||||
|
||||
final RunResult clangResult = RunResult(
|
||||
FakeProcessResult(stdout: 'Apple LLVM version 10.1.0 (clang-4567.1.1.1)\nBlahBlah\n', stderr: ''),
|
||||
const <String>['foo'],
|
||||
);
|
||||
when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(clangResult));
|
||||
when(mockPlistUtils.getValueFromFile(infoPlist.path, 'ClangVersion')).thenReturn('Apple LLVM version 10.0.1 (clang-1234.1.12.1)');
|
||||
|
||||
await validateBitcode(BuildMode.profile, TargetPlatform.ios);
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => LocalEngineArtifacts('/engine', 'ios_profile', 'host_profile'),
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Xcode: () => mockXcode,
|
||||
Logger: () => bufferLogger,
|
||||
PlistParser: () => mockPlistUtils,
|
||||
});
|
||||
|
||||
testUsingContext('build aot can parse valid Xcode Clang version (11)', () async {
|
||||
final Directory flutterFramework = memoryFileSystem.directory('ios_profile/Flutter.framework')
|
||||
..createSync(recursive: true);
|
||||
flutterFramework.childFile('Flutter').createSync();
|
||||
final File infoPlist = flutterFramework.childFile('Info.plist')..createSync();
|
||||
|
||||
final RunResult clangResult = RunResult(
|
||||
FakeProcessResult(stdout: 'Apple clang version 11.0.0 (clang-4567.1.1.1)\nBlahBlah\n', stderr: ''),
|
||||
const <String>['foo'],
|
||||
);
|
||||
when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(clangResult));
|
||||
when(mockPlistUtils.getValueFromFile(infoPlist.path, 'ClangVersion')).thenReturn('Apple LLVM version 10.0.1 (clang-1234.1.12.1)');
|
||||
|
||||
await validateBitcode(BuildMode.profile, TargetPlatform.ios);
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => LocalEngineArtifacts('/engine', 'ios_profile', 'host_profile'),
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Xcode: () => mockXcode,
|
||||
Logger: () => bufferLogger,
|
||||
PlistParser: () => mockPlistUtils,
|
||||
});
|
||||
|
||||
testUsingContext('build aot validates Flutter.framework/Flutter was built with same toolchain', () async {
|
||||
final Directory flutterFramework = memoryFileSystem.directory('ios_profile/Flutter.framework')
|
||||
..createSync(recursive: true);
|
||||
|
Loading…
Reference in New Issue
Block a user