Unverified Commit 32b22b85 authored by Jesús S Guerrero's avatar Jesús S Guerrero Committed by GitHub

parse build version on xcodeproj (#105908)

parent ddeb0b99
...@@ -47,6 +47,7 @@ class XcodeProjectInterpreter { ...@@ -47,6 +47,7 @@ class XcodeProjectInterpreter {
required FileSystem fileSystem, required FileSystem fileSystem,
required Usage usage, required Usage usage,
Version? version, Version? version,
String? build,
}) : _platform = platform, }) : _platform = platform,
_fileSystem = fileSystem, _fileSystem = fileSystem,
_logger = logger, _logger = logger,
...@@ -58,6 +59,7 @@ class XcodeProjectInterpreter { ...@@ -58,6 +59,7 @@ class XcodeProjectInterpreter {
processManager: processManager, processManager: processManager,
), ),
_version = version, _version = version,
_build = build,
_versionText = version?.toString(), _versionText = version?.toString(),
_usage = usage; _usage = usage;
...@@ -70,6 +72,7 @@ class XcodeProjectInterpreter { ...@@ -70,6 +72,7 @@ class XcodeProjectInterpreter {
factory XcodeProjectInterpreter.test({ factory XcodeProjectInterpreter.test({
required ProcessManager processManager, required ProcessManager processManager,
Version? version = const Version.withText(1000, 0, 0, '1000.0.0'), Version? version = const Version.withText(1000, 0, 0, '1000.0.0'),
String? build = '13C100',
}) { }) {
final Platform platform = FakePlatform( final Platform platform = FakePlatform(
operatingSystem: 'macos', operatingSystem: 'macos',
...@@ -82,6 +85,7 @@ class XcodeProjectInterpreter { ...@@ -82,6 +85,7 @@ class XcodeProjectInterpreter {
usage: TestUsage(), usage: TestUsage(),
logger: BufferLogger.test(), logger: BufferLogger.test(),
version: version, version: version,
build: build,
); );
} }
...@@ -91,8 +95,7 @@ class XcodeProjectInterpreter { ...@@ -91,8 +95,7 @@ class XcodeProjectInterpreter {
final OperatingSystemUtils _operatingSystemUtils; final OperatingSystemUtils _operatingSystemUtils;
final Logger _logger; final Logger _logger;
final Usage _usage; final Usage _usage;
static final RegExp _versionRegex = RegExp(r'Xcode ([0-9.]+).*Build version (\w+)');
static final RegExp _versionRegex = RegExp(r'Xcode ([0-9.]+)');
void _updateVersion() { void _updateVersion() {
if (!_platform.isMacOS || !_fileSystem.file('/usr/bin/xcodebuild').existsSync()) { if (!_platform.isMacOS || !_fileSystem.file('/usr/bin/xcodebuild').existsSync()) {
...@@ -118,6 +121,7 @@ class XcodeProjectInterpreter { ...@@ -118,6 +121,7 @@ class XcodeProjectInterpreter {
final int minorVersion = components.length < 2 ? 0 : int.parse(components[1]); final int minorVersion = components.length < 2 ? 0 : int.parse(components[1]);
final int patchVersion = components.length < 3 ? 0 : int.parse(components[2]); final int patchVersion = components.length < 3 ? 0 : int.parse(components[2]);
_version = Version(majorVersion, minorVersion, patchVersion); _version = Version(majorVersion, minorVersion, patchVersion);
_build = match.group(2);
} on ProcessException { } on ProcessException {
// Ignored, leave values null. // Ignored, leave values null.
} }
...@@ -134,6 +138,7 @@ class XcodeProjectInterpreter { ...@@ -134,6 +138,7 @@ class XcodeProjectInterpreter {
} }
Version? _version; Version? _version;
String? _build;
Version? get version { Version? get version {
if (_version == null) { if (_version == null) {
_updateVersion(); _updateVersion();
...@@ -141,6 +146,13 @@ class XcodeProjectInterpreter { ...@@ -141,6 +146,13 @@ class XcodeProjectInterpreter {
return _version; return _version;
} }
String? get build {
if (_build == null) {
_updateVersion();
}
return _build;
}
/// The `xcrun` Xcode command to run or locate development /// The `xcrun` Xcode command to run or locate development
/// tools and properties. /// tools and properties.
/// ///
......
...@@ -101,6 +101,8 @@ class Xcode { ...@@ -101,6 +101,8 @@ class Xcode {
Version? get currentVersion => _xcodeProjectInterpreter.version; Version? get currentVersion => _xcodeProjectInterpreter.version;
String? get buildVersion => _xcodeProjectInterpreter.build;
String? get versionText => _xcodeProjectInterpreter.versionText; String? get versionText => _xcodeProjectInterpreter.versionText;
bool? _eulaSigned; bool? _eulaSigned;
......
...@@ -37,6 +37,9 @@ class XcodeValidator extends DoctorValidator { ...@@ -37,6 +37,9 @@ class XcodeValidator extends DoctorValidator {
xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(',')); xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(','));
} }
} }
if (_xcode.buildVersion != null) {
messages.add(ValidationMessage('Build ${_xcode.buildVersion}'));
}
if (!_xcode.isInstalledAndMeetsVersionCheck) { if (!_xcode.isInstalledAndMeetsVersionCheck) {
xcodeStatus = ValidationType.partial; xcodeStatus = ValidationType.partial;
messages.add(ValidationMessage.error(_userMessages.xcodeOutdated(xcodeRequiredVersion.toString()))); messages.add(ValidationMessage.error(_userMessages.xcodeOutdated(xcodeRequiredVersion.toString())));
......
...@@ -146,6 +146,7 @@ void main() { ...@@ -146,6 +146,7 @@ void main() {
]); ]);
expect(xcodeProjectInterpreter.version, Version(11, 4, 1)); expect(xcodeProjectInterpreter.version, Version(11, 4, 1));
expect(xcodeProjectInterpreter.build, '11N111s');
expect(fakeProcessManager, hasNoRemainingExpectations); expect(fakeProcessManager, hasNoRemainingExpectations);
}); });
...@@ -173,6 +174,7 @@ void main() { ...@@ -173,6 +174,7 @@ void main() {
), ),
]); ]);
expect(xcodeProjectInterpreter.version, isNull); expect(xcodeProjectInterpreter.version, isNull);
expect(xcodeProjectInterpreter.build, isNull);
expect(fakeProcessManager, hasNoRemainingExpectations); expect(fakeProcessManager, hasNoRemainingExpectations);
}); });
......
...@@ -183,11 +183,12 @@ void main() { ...@@ -183,11 +183,12 @@ void main() {
final XcodeValidator validator = XcodeValidator(xcode: xcode, userMessages: UserMessages()); final XcodeValidator validator = XcodeValidator(xcode: xcode, userMessages: UserMessages());
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
expect(result.type, ValidationType.installed); expect(result.type, ValidationType.installed);
expect(result.messages.length, 1); expect(result.messages.length, 2);
final ValidationMessage firstMessage = result.messages.first; final ValidationMessage firstMessage = result.messages.first;
expect(firstMessage.type, ValidationMessageType.information); expect(firstMessage.type, ValidationMessageType.information);
expect(firstMessage.message, 'Xcode at /Library/Developer/CommandLineTools'); expect(firstMessage.message, 'Xcode at /Library/Developer/CommandLineTools');
expect(result.statusInfo, '1000.0.0'); expect(result.statusInfo, '1000.0.0');
expect(result.messages[1].message, 'Build 13C100');
}); });
}); });
} }
...@@ -296,6 +296,9 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter { ...@@ -296,6 +296,9 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
@override @override
Version get version => Version(13, null, null); Version get version => Version(13, null, null);
@override
String get build => '13C100';
@override @override
Future<Map<String, String>> getBuildSettings( Future<Map<String, String>> getBuildSettings(
String projectPath, { String projectPath, {
......
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