Use existing pkg-config builds and pre-built contents for packages

This commit is contained in:
crazywhalecc
2025-08-31 15:04:34 +08:00
parent f2c131a2cc
commit 0fa38bad6d
14 changed files with 157 additions and 145 deletions

View File

@@ -9,7 +9,7 @@ use SPC\doctor\AsFixItem;
use SPC\doctor\CheckResult;
use SPC\doctor\OptionalCheck;
use SPC\store\PackageManager;
use SPC\store\pkg\PkgConfig;
use SPC\util\PkgConfigUtil;
#[OptionalCheck([self::class, 'optionalCheck'])]
class PkgConfigCheck
@@ -20,26 +20,19 @@ class PkgConfigCheck
}
/** @noinspection PhpUnused */
#[AsCheckItem('if pkg-config is installed', level: 800)]
#[AsCheckItem('if pkg-config is installed or built', level: 800)]
public function checkPkgConfig(): CheckResult
{
if (PkgConfig::isInstalled()) {
return CheckResult::ok();
if (!($pkgconf = PkgConfigUtil::findPkgConfig())) {
return CheckResult::fail('pkg-config is not installed', 'install-pkgconfig');
}
return CheckResult::fail('pkg-config is not installed', 'install-pkgconfig');
return CheckResult::ok($pkgconf);
}
#[AsFixItem('install-pkgconfig')]
public function installPkgConfig(): bool
{
$arch = arch2gnu(php_uname('m'));
$os = match (PHP_OS_FAMILY) {
'Windows' => 'win',
'Darwin' => 'macos',
'BSD' => 'freebsd',
default => 'linux',
};
PackageManager::installPackage("pkg-config-{$arch}-{$os}");
return PkgConfig::isInstalled();
PackageManager::installPackage('pkg-config');
return true;
}
}