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