2023-04-29 18:59:47 +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-29 18:59:47 +08:00
|
|
|
use SPC\store\FileSystem;
|
|
|
|
|
|
|
|
|
|
trait libssh2
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
2023-04-29 18:59:47 +08:00
|
|
|
{
|
|
|
|
|
$enable_zlib = $this->builder->getLib('zlib') !== null ? 'ON' : 'OFF';
|
|
|
|
|
|
|
|
|
|
FileSystem::resetDir($this->source_dir . '/build');
|
|
|
|
|
shell()->cd($this->source_dir . '/build')
|
|
|
|
|
->exec(
|
2023-10-23 00:37:28 +08:00
|
|
|
'cmake ' .
|
2025-03-10 00:39:20 +08:00
|
|
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
|
|
|
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
|
|
|
|
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
|
|
|
|
'-DCMAKE_INSTALL_LIBDIR=lib ' .
|
2023-04-29 18:59:47 +08:00
|
|
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
|
|
|
|
'-DBUILD_EXAMPLES=OFF ' .
|
|
|
|
|
'-DBUILD_TESTING=OFF ' .
|
|
|
|
|
"-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " .
|
|
|
|
|
'..'
|
|
|
|
|
)
|
2023-09-12 00:08:00 +08:00
|
|
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
2025-03-10 00:39:20 +08:00
|
|
|
->exec('make install');
|
2023-04-29 18:59:47 +08:00
|
|
|
$this->patchPkgconfPrefix(['libssh2.pc']);
|
|
|
|
|
}
|
|
|
|
|
}
|