47 lines
1.5 KiB
PHP
Raw Normal View History

2023-03-18 17:32:21 +08:00
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
2023-03-18 17:32:21 +08:00
class libxml2 extends MacOSLibraryBase
{
public const NAME = 'libxml2';
/**
* @throws RuntimeException
*/
protected function build()
{
$enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
[$lib, $include, $destdir] = SEPARATED_PATH;
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
2023-04-03 20:47:24 +08:00
->exec(
"{$this->builder->configure_env} " . ' cmake ' .
// '--debug-find ' .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DLIBXML2_WITH_ICONV=ON ' .
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
2023-07-23 22:54:32 +08:00
'-DLIBXML2_WITH_ICU=OFF ' .
2023-04-03 20:47:24 +08:00
"-DLIBXML2_WITH_LZMA={$enable_xz} " .
'-DLIBXML2_WITH_PYTHON=OFF ' .
'-DLIBXML2_WITH_PROGRAMS=OFF ' .
'-DLIBXML2_WITH_TESTS=OFF ' .
2023-07-23 22:54:32 +08:00
"-DCMAKE_INSTALL_PREFIX={$destdir} " .
2023-04-03 20:47:24 +08:00
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
2023-07-23 22:54:32 +08:00
->exec('make install');
2023-03-18 17:32:21 +08:00
}
}