mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 01:15:37 +08:00
Use existing pkg-config builds and pre-built contents for packages
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user