44 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\store\FileSystem;
2025-11-04 13:35:43 +08:00
use SPC\util\executor\UnixCMakeExecutor;
2023-11-05 17:09:48 +08:00
trait librdkafka
{
2025-07-30 10:24:21 +07:00
public function patchBeforeBuild(): bool
2023-11-05 17:09:48 +08:00
{
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"',
2025-06-24 22:57:12 +07:00
"#define IOV_MAX 1024\n#define __GNU__"
2025-06-24 22:56:48 +07:00
);
2025-07-30 10:24:21 +07:00
return true;
}
protected function build(): void
{
2025-11-04 13:35:43 +08:00
UnixCMakeExecutor::create($this)
->optionalLib('zstd', ...cmake_boolean_args('WITH_ZSTD'))
->optionalLib('curl', ...cmake_boolean_args('WITH_CURL'))
->optionalLib('openssl', ...cmake_boolean_args('WITH_SSL'))
->optionalLib('zlib', ...cmake_boolean_args('WITH_ZLIB'))
->optionalLib('liblz4', ...cmake_boolean_args('ENABLE_LZ4_EXT'))
2025-11-04 13:35:43 +08:00
->addConfigureArgs(
'-DWITH_SASL=OFF',
'-DRDKAFKA_BUILD_STATIC=ON',
'-DRDKAFKA_BUILD_EXAMPLES=OFF',
'-DRDKAFKA_BUILD_TESTS=OFF',
2025-06-09 19:32:31 +08:00
)
2025-11-04 13:35:43 +08:00
->build();
2023-11-05 17:09:48 +08:00
}
}