2024-01-03 10:31:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
|
|
|
|
use SPC\exception\RuntimeException;
|
2024-06-04 12:24:52 +08:00
|
|
|
use SPC\store\FileSystem;
|
2024-01-03 10:31:21 +08:00
|
|
|
|
|
|
|
|
trait libcares
|
|
|
|
|
{
|
2024-06-04 12:24:52 +08:00
|
|
|
public function patchBeforeBuild(): bool
|
|
|
|
|
{
|
|
|
|
|
if (!file_exists($this->source_dir . '/src/lib/thirdparty/apple/dnsinfo.h')) {
|
|
|
|
|
FileSystem::createDir($this->source_dir . '/src/lib/thirdparty/apple');
|
|
|
|
|
copy(ROOT_DIR . '/src/globals/extra/libcares_dnsinfo.h', $this->source_dir . '/src/lib/thirdparty/apple/dnsinfo.h');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 10:31:21 +08:00
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2025-06-09 10:24:06 +08:00
|
|
|
shell()->cd($this->source_dir)->initLibBuildEnv($this)
|
|
|
|
|
->exec('./configure --prefix= --enable-static --disable-shared --disable-tests --with-pic')
|
|
|
|
|
->exec("make -j {$this->builder->concurrency}")
|
|
|
|
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
2024-07-09 11:21:20 +08:00
|
|
|
|
|
|
|
|
$this->patchPkgconfPrefix(['libcares.pc'], PKGCONF_PATCH_PREFIX);
|
2024-01-03 10:31:21 +08:00
|
|
|
}
|
|
|
|
|
}
|