Cmake version check (#400)

* add cmake version checker for doctor

* fix linux distro checker message
This commit is contained in:
Jerry Ma 2024-04-02 15:05:49 +08:00 committed by GitHub
parent d3a001d808
commit da6d9ffb4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -74,6 +74,22 @@ class LinuxToolCheckList
return CheckResult::ok();
}
#[AsCheckItem('if cmake version >= 3.18', limit_os: 'Linux')]
public function checkCMakeVersion(): ?CheckResult
{
$check_cmd = 'cmake --version';
$pattern = '/cmake version (.*)/m';
$out = shell()->execWithResult($check_cmd, false)[1][0];
if (preg_match($pattern, $out, $match)) {
$ver = $match[1];
if (version_compare($ver, '3.18.0') <= 0) {
return CheckResult::fail('cmake version is too low (' . $ver . '), please update it manually!');
}
return CheckResult::ok($match[1]);
}
return CheckResult::fail('Failed to get cmake version');
}
/** @noinspection PhpUnused */
#[AsCheckItem('if necessary linux headers are installed', limit_os: 'Linux')]
public function checkSystemOSPackages(): ?CheckResult

View File

@ -20,7 +20,7 @@ class OSCheckList
return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY);
}
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
$known_distro = PHP_OS_FAMILY === 'Linux' && in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros());
$known_distro = PHP_OS_FAMILY !== 'Linux' || in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros());
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported' . ($known_distro ? '' : ' (but not tested on this distro)'));
}
}