Use cmake executor instead of raw command

This commit is contained in:
crazywhalecc
2025-06-09 01:07:30 +08:00
parent 7d26aa533a
commit 1718806042
23 changed files with 151 additions and 394 deletions

View File

@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\builder\unix\executor\UnixCMakeExecutor;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait libssh2
{
@@ -16,24 +16,14 @@ trait libssh2
*/
protected function build(): void
{
$enable_zlib = $this->builder->getLib('zlib') !== null ? 'ON' : 'OFF';
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
'cmake ' .
'-DCMAKE_BUILD_TYPE=Release ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
'-DCMAKE_INSTALL_LIBDIR=lib ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DBUILD_EXAMPLES=OFF ' .
'-DBUILD_TESTING=OFF ' .
"-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " .
'..'
UnixCMakeExecutor::create($this)
->optionalLib('zlib', ...cmake_boolean_args('ENABLE_ZLIB_COMPRESSION'))
->addConfigureArgs(
'-DBUILD_EXAMPLES=OFF',
'-DBUILD_TESTING=OFF'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
->build();
$this->patchPkgconfPrefix(['libssh2.pc']);
}
}