err, we need to install zig of course

This commit is contained in:
DubbleClick 2025-07-01 16:25:08 +07:00
parent 408b3b4060
commit f6c6011061
3 changed files with 8 additions and 4 deletions

View File

@ -6,6 +6,8 @@ namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException; use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException; use SPC\exception\RuntimeException;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libaom trait libaom
@ -16,8 +18,8 @@ trait libaom
*/ */
protected function build(): void protected function build(): void
{ {
if (getenv('SPC_LIBC') === 'musl' && str_contains(getenv('CC'), 'zig')) { if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
f_putenv('COMPILER_EXTRA=-D_POSIX_SOURCE'); f_putenv('COMPILER_EXTRA=-D_GNU_SOURCE');
} }
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)
->setBuildDir("{$this->source_dir}/builddir") ->setBuildDir("{$this->source_dir}/builddir")

View File

@ -5,6 +5,8 @@ declare(strict_types=1);
namespace SPC\command; namespace SPC\command;
use SPC\exception\ValidationException; use SPC\exception\ValidationException;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\ConfigValidator; use SPC\util\ConfigValidator;
use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
@ -76,7 +78,7 @@ class CraftCommand extends BuildCommand
} }
} }
// install zig if requested // install zig if requested
if (str_contains(getenv('CC'), 'zig')) { if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
$retcode = $this->runCommand('install-pkg', 'zig'); $retcode = $this->runCommand('install-pkg', 'zig');
if ($retcode !== 0) { if ($retcode !== 0) {
$this->output->writeln('<error>craft zig failed</error>'); $this->output->writeln('<error>craft zig failed</error>');

View File

@ -47,7 +47,7 @@ class ZigCheck
'BSD' => 'freebsd', 'BSD' => 'freebsd',
default => 'linux', default => 'linux',
}; };
PackageManager::installPackage("musl-toolchain-{$arch}-{$os}"); PackageManager::installPackage("zig-{$arch}-{$os}");
return Zig::isInstalled(); return Zig::isInstalled();
} }
} }