40 lines
1.2 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;
trait librdkafka
{
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
$builddir = BUILD_ROOT_PATH;
$zstd_option = $this->builder->getLib('zstd') ? ("STATIC_LIB_libzstd={$builddir}/lib/libzstd.a ") : '';
2023-11-05 17:09:48 +08:00
shell()->cd($this->source_dir)
->exec(
$zstd_option .
2023-11-05 17:09:48 +08:00
'./configure ' .
'--enable-static --disable-shared --disable-curl --disable-sasl --disable-valgrind --disable-zlib --disable-ssl ' .
($zstd_option == '' ? '--disable-zstd ' : '') .
2023-11-05 17:09:48 +08:00
'--prefix='
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec("make install DESTDIR={$builddir}");
2023-11-05 17:09:48 +08:00
$this->patchPkgconfPrefix(['rdkafka.pc', 'rdkafka-static.pc', 'rdkafka++.pc', 'rdkafka++-static.pc']);
// remove dynamic libs
shell()
->exec("rm -rf {$builddir}/lib/*.so.*")
->exec("rm -rf {$builddir}/lib/*.so")
->exec("rm -rf {$builddir}/lib/*.dylib");
}
}