mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
Refactor remaining cmake libs
This commit is contained in:
parent
37b9ccfaa8
commit
42943b315c
@ -4,50 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libxml2 extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libxml2;
|
||||
|
||||
public const NAME = 'libxml2';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function build(): void
|
||||
{
|
||||
$enable_zlib = $this->builder->getLib('zlib') ? ('ON -DZLIB_LIBRARY=' . BUILD_LIB_PATH . '/libz.a -DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH) : 'OFF';
|
||||
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
||||
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
||||
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
'cmake ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DCMAKE_INSTALL_LIBDIR=' . BUILD_LIB_PATH . ' ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DIconv_IS_BUILT_IN=OFF ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
|
||||
"-DLIBXML2_WITH_ICU={$enable_icu} " .
|
||||
"-DLIBXML2_WITH_LZMA={$enable_xz} " .
|
||||
'-DLIBXML2_WITH_PYTHON=OFF ' .
|
||||
'-DLIBXML2_WITH_PROGRAMS=OFF ' .
|
||||
'-DLIBXML2_WITH_TESTS=OFF ' .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install');
|
||||
|
||||
FileSystem::replaceFileStr(
|
||||
BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc',
|
||||
'-licudata -licui18n -licuuc',
|
||||
'-licui18n -licuuc -licudata'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\builder\unix\executor\UnixCMakeExecutor;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
@ -17,11 +18,14 @@ class glfw extends MacOSLibraryBase
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
// compile!
|
||||
shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw')
|
||||
->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF")
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install');
|
||||
UnixCMakeExecutor::create($this)
|
||||
->setCMakeBuildDir("{$this->source_dir}/vendor/glfw")
|
||||
->setReset(false)
|
||||
->addConfigureArgs(
|
||||
'-DGLFW_BUILD_EXAMPLES=OFF',
|
||||
'-DGLFW_BUILD_TESTS=OFF',
|
||||
)
|
||||
->build('.');
|
||||
// patch pkgconf
|
||||
$this->patchPkgconfPrefix(['glfw3.pc']);
|
||||
}
|
||||
|
||||
@ -4,44 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libxml2 extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libxml2;
|
||||
|
||||
public const NAME = 'libxml2';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
$enable_zlib = $this->builder->getLib('zlib') ? ('ON -DZLIB_LIBRARY=' . BUILD_LIB_PATH . '/libz.a -DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH) : 'OFF';
|
||||
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
|
||||
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
|
||||
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
'cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DCMAKE_INSTALL_LIBDIR=' . BUILD_LIB_PATH . ' ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
|
||||
"-DLIBXML2_WITH_ICU={$enable_icu} " .
|
||||
"-DLIBXML2_WITH_LZMA={$enable_xz} " .
|
||||
'-DLIBXML2_WITH_PYTHON=OFF ' .
|
||||
'-DLIBXML2_WITH_PROGRAMS=OFF ' .
|
||||
'-DLIBXML2_WITH_TESTS=OFF ' .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install');
|
||||
}
|
||||
}
|
||||
|
||||
42
src/SPC/builder/unix/library/libxml2.php
Normal file
42
src/SPC/builder/unix/library/libxml2.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||
use SPC\builder\unix\executor\UnixCMakeExecutor;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait libxml2
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function build(): void
|
||||
{
|
||||
$cmake = UnixCMakeExecutor::create($this)
|
||||
->optionalLib('zlib', "-DLIBXML2_WITH_ZLIB=ON -DZLIB_LIBRARY={$this->getLibDir()}/libz.a -DZLIB_INCLUDE_DIR={$this->getIncludeDir()}", '-DLIBXML2_WITH_ZLIB=OFF')
|
||||
->optionalLib('icu', ...cmake_boolean_args('LIBXML2_WITH_ICU'))
|
||||
->optionalLib('xz', ...cmake_boolean_args('LIBXML2_WITH_LZMA'))
|
||||
->addConfigureArgs(
|
||||
'-DLIBXML2_WITH_ICONV=ON',
|
||||
'-DLIBXML2_WITH_PYTHON=OFF',
|
||||
'-DLIBXML2_WITH_PROGRAMS=OFF',
|
||||
'-DLIBXML2_WITH_TESTS=OFF',
|
||||
);
|
||||
|
||||
if ($this instanceof LinuxLibraryBase) {
|
||||
$cmake->addConfigureArgs('-DIconv_IS_BUILD_IN=OFF');
|
||||
}
|
||||
|
||||
$cmake->build();
|
||||
|
||||
FileSystem::replaceFileStr(
|
||||
BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc',
|
||||
'-licudata -licui18n -licuuc',
|
||||
'-licui18n -licuuc -licudata'
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user