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;
|
2025-06-23 12:57:00 +07:00
|
|
|
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
|
|
|
|
|
{
|
2025-06-24 22:56:48 +07:00
|
|
|
FileSystem::replaceFileStr(
|
|
|
|
|
$this->source_dir . '/lds-gen.py',
|
|
|
|
|
"funcs.append('rd_ut_coverage_check')",
|
|
|
|
|
''
|
|
|
|
|
);
|
|
|
|
|
FileSystem::replaceFileStr(
|
|
|
|
|
$this->source_dir . '/src/rd.h',
|
|
|
|
|
'#error "IOV_MAX not defined"',
|
|
|
|
|
'#define IOV_MAX 1024' . "\n#define __GNU__"
|
|
|
|
|
);
|
2025-06-09 19:32:31 +08:00
|
|
|
UnixAutoconfExecutor::create($this)
|
2025-06-24 22:56:48 +07:00
|
|
|
->appendEnv(['CFLAGS' => '-Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-variable'])
|
2025-06-09 19:32:31 +08:00
|
|
|
->optionalLib(
|
|
|
|
|
'zstd',
|
|
|
|
|
function ($lib) {
|
|
|
|
|
putenv("STATIC_LIB_libzstd={$lib->getLibDir()}/libzstd.a");
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
'--disable-zstd'
|
|
|
|
|
)
|
2025-06-10 15:39:14 +08:00
|
|
|
->removeConfigureArgs(
|
2025-06-10 12:42:37 +08:00
|
|
|
'--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
|
|
|
}
|
|
|
|
|
}
|