Refactor clang runtime bits support for zig integration

This commit is contained in:
crazywhalecc
2026-05-18 10:55:39 +08:00
parent ce70c0df6a
commit f27ec773a1
4 changed files with 197 additions and 147 deletions

View File

@@ -39,4 +39,34 @@ class ZigCheck
$installer->run(true);
return $installer->isPackageInstalled('zig');
}
/** @noinspection PhpUnused */
#[CheckItem('if clang runtime bits are built', limit_os: 'Linux', level: 799)]
public function checkClangRuntimeBits(): ?CheckResult
{
// Skip if zig is not installed yet (zig check runs at level 800)
if (!new PackageInstaller()->addInstallPackage('zig')->isPackageInstalled('zig')) {
return null;
}
$libDir = PKG_ROOT_PATH . '/zig/lib';
if (file_exists("{$libDir}/libclang_rt.profile.a")
&& file_exists("{$libDir}/clang_rt.crtbegin.o")
&& file_exists("{$libDir}/clang_rt.crtend.o")
) {
return CheckResult::ok("{$libDir}/libclang_rt.profile.a");
}
return CheckResult::fail('clang runtime bits are not built', 'build-clang-runtime-bits');
}
#[FixItem('build-clang-runtime-bits')]
public function fixClangRuntimeBits(): bool
{
$installer = new PackageInstaller(interactive: false);
$installer->addInstallPackage('clang-runtime-bits');
$installer->run(true);
$libDir = PKG_ROOT_PATH . '/zig/lib';
return file_exists("{$libDir}/libclang_rt.profile.a")
&& file_exists("{$libDir}/clang_rt.crtbegin.o")
&& file_exists("{$libDir}/clang_rt.crtend.o");
}
}