mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-16 13:25:36 +08:00
turn llvm-tools into a doctor check. llvm-runtime is a target now
This commit is contained in:
35
src/StaticPHP/Doctor/Item/LlvmToolsCheck.php
Normal file
35
src/StaticPHP/Doctor/Item/LlvmToolsCheck.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace StaticPHP\Doctor\Item;
|
||||
|
||||
use Package\Artifact\llvm_tools;
|
||||
use StaticPHP\Attribute\Doctor\CheckItem;
|
||||
use StaticPHP\Attribute\Doctor\FixItem;
|
||||
use StaticPHP\Doctor\CheckResult;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
|
||||
class LlvmToolsCheck
|
||||
{
|
||||
/** @noinspection PhpUnused */
|
||||
#[CheckItem('if llvm-tools (objcopy/strip/profdata) are built', limit_os: 'Linux', level: 798)]
|
||||
public function checkLlvmTools(): CheckResult
|
||||
{
|
||||
$binDir = PKG_ROOT_PATH . '/llvm-tools/bin';
|
||||
if (new llvm_tools()->allBuilt($binDir)) {
|
||||
return CheckResult::ok($binDir);
|
||||
}
|
||||
return CheckResult::fail('llvm-tools are not built', 'build-llvm-tools');
|
||||
}
|
||||
|
||||
#[FixItem('build-llvm-tools')]
|
||||
public function fixLlvmTools(): bool
|
||||
{
|
||||
$installer = new PackageInstaller(interactive: false);
|
||||
$installer->addInstallPackage('llvm-tools');
|
||||
$installer->run(true);
|
||||
new llvm_tools()->buildForHost();
|
||||
return new llvm_tools()->allBuilt(PKG_ROOT_PATH . '/llvm-tools/bin');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user