Skip to content

Commit

Permalink
Cmake version check (#400)
Browse files Browse the repository at this point in the history
* add cmake version checker for doctor

* fix linux distro checker message
  • Loading branch information
crazywhalecc authored Apr 2, 2024
1 parent d3a001d commit da6d9ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/SPC/doctor/item/LinuxToolCheckList.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ public function checkCliTools(): ?CheckResult
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
Expand Down
2 changes: 1 addition & 1 deletion src/SPC/doctor/item/OSCheckList.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function checkOS(): ?CheckResult
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)'));
}
}

0 comments on commit da6d9ff

Please sign in to comment.