2023-04-30 14:22:59 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\exception\RuntimeException;
|
2023-04-30 14:22:59 +08:00
|
|
|
use SPC\store\FileSystem;
|
|
|
|
|
|
|
|
|
|
trait libevent
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
2023-04-30 14:22:59 +08:00
|
|
|
{
|
|
|
|
|
// CMake needs a clean build directory
|
|
|
|
|
FileSystem::resetDir($this->source_dir . '/build');
|
|
|
|
|
// Start build
|
|
|
|
|
shell()->cd($this->source_dir . '/build')
|
2024-04-07 15:52:24 +08:00
|
|
|
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
|
|
|
|
->execWithEnv(
|
2023-10-23 00:37:28 +08:00
|
|
|
'cmake ' .
|
2023-04-30 14:22:59 +08:00
|
|
|
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
|
|
|
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
|
|
|
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
|
|
|
|
'-DEVENT__LIBRARY_TYPE=STATIC ' .
|
|
|
|
|
'-DEVENT__DISABLE_BENCHMARK=ON ' .
|
|
|
|
|
'-DEVENT__DISABLE_THREAD_SUPPORT=ON ' .
|
2023-07-26 00:07:54 +08:00
|
|
|
'-DEVENT__DISABLE_MBEDTLS=ON ' .
|
2023-04-30 14:22:59 +08:00
|
|
|
'-DEVENT__DISABLE_TESTS=ON ' .
|
|
|
|
|
'-DEVENT__DISABLE_SAMPLES=ON ' .
|
|
|
|
|
'..'
|
|
|
|
|
)
|
2024-04-07 15:52:24 +08:00
|
|
|
->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
|
2023-04-30 14:22:59 +08:00
|
|
|
->exec('make install');
|
|
|
|
|
}
|
|
|
|
|
}
|