2023-03-21 01:51:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\linux\library;
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\FileSystemException;
|
2023-03-21 01:51:52 +08:00
|
|
|
use SPC\exception\RuntimeException;
|
|
|
|
|
use SPC\store\FileSystem;
|
|
|
|
|
|
|
|
|
|
class libxml2 extends LinuxLibraryBase
|
|
|
|
|
{
|
|
|
|
|
public const NAME = 'libxml2';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
2023-08-20 19:51:45 +08:00
|
|
|
* @throws FileSystemException
|
2023-03-21 01:51:52 +08:00
|
|
|
*/
|
2023-08-20 19:51:45 +08:00
|
|
|
public function build(): void
|
2023-03-21 01:51:52 +08:00
|
|
|
{
|
|
|
|
|
$enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
|
2023-10-16 19:26:29 +02:00
|
|
|
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
2023-03-21 01:51:52 +08:00
|
|
|
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
|
|
|
|
|
2023-04-29 18:59:47 +08:00
|
|
|
FileSystem::resetDir($this->source_dir . '/build');
|
|
|
|
|
shell()->cd($this->source_dir . '/build')
|
2023-03-26 22:27:51 +08:00
|
|
|
->exec(
|
2023-10-23 00:37:28 +08:00
|
|
|
'cmake ' .
|
2024-01-03 13:40:48 +08:00
|
|
|
'-DCMAKE_BUILD_TYPE=Release ' .
|
|
|
|
|
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
|
|
|
|
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
2023-03-26 22:27:51 +08:00
|
|
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
|
|
|
|
'-DIconv_IS_BUILT_IN=OFF ' .
|
2023-10-16 19:26:29 +02:00
|
|
|
'-DLIBXML2_WITH_ICONV=ON ' .
|
2023-03-26 22:27:51 +08:00
|
|
|
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
|
2023-10-16 19:26:29 +02:00
|
|
|
"-DLIBXML2_WITH_ICU={$enable_icu} " .
|
2023-03-26 22:27:51 +08:00
|
|
|
"-DLIBXML2_WITH_LZMA={$enable_xz} " .
|
|
|
|
|
'-DLIBXML2_WITH_PYTHON=OFF ' .
|
|
|
|
|
'-DLIBXML2_WITH_PROGRAMS=OFF ' .
|
|
|
|
|
'-DLIBXML2_WITH_TESTS=OFF ' .
|
|
|
|
|
'..'
|
|
|
|
|
)
|
|
|
|
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
2024-01-03 13:40:48 +08:00
|
|
|
->exec('make install');
|
2023-10-16 21:03:26 +02:00
|
|
|
|
|
|
|
|
FileSystem::replaceFileStr(
|
|
|
|
|
BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc',
|
|
|
|
|
'-licudata -licui18n -licuuc',
|
|
|
|
|
'-licui18n -licuuc -licudata'
|
|
|
|
|
);
|
2023-03-21 01:51:52 +08:00
|
|
|
}
|
|
|
|
|
}
|