51 lines
1.4 KiB
PHP
Raw Normal View History

2023-11-05 17:09:48 +08:00
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
2025-06-09 19:32:31 +08:00
use SPC\util\executor\UnixAutoconfExecutor;
2023-11-05 17:09:48 +08:00
trait librdkafka
{
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
FileSystem::replaceFileStr($this->source_dir . '/lds-gen.py', "funcs.append('rd_ut_coverage_check')", '');
2025-06-09 19:32:31 +08:00
UnixAutoconfExecutor::create($this)
->optionalLib(
'zstd',
function ($lib) {
putenv("STATIC_LIB_libzstd={$lib->getLibDir()}/libzstd.a");
return '';
},
'--disable-zstd'
)
->removeConfigureArgs(
'--with-pic',
'--enable-pic',
)
2025-06-09 19:32:31 +08:00
->configure(
'--disable-curl',
'--disable-sasl',
'--disable-valgrind',
'--disable-zlib',
'--disable-ssl',
2023-11-05 17:09:48 +08:00
)
2025-06-09 19:32:31 +08:00
->make();
2023-11-05 17:09:48 +08:00
$this->patchPkgconfPrefix(['rdkafka.pc', 'rdkafka-static.pc', 'rdkafka++.pc', 'rdkafka++-static.pc']);
// remove dynamic libs
shell()
2025-06-09 19:32:31 +08:00
->exec("rm -rf {$this->getLibDir()}/*.so.*")
->exec("rm -rf {$this->getLibDir()}/*.so")
->exec("rm -rf {$this->getLibDir()}/*.dylib");
2023-11-05 17:09:48 +08:00
}
}