mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-05 07:45:39 +08:00
refactor and add more linux extensions and libraries
This commit is contained in:
@@ -42,6 +42,7 @@ abstract class LinuxLibraryBase extends LibraryBase
|
||||
{
|
||||
// 传入 true,表明直接编译
|
||||
if ($force_build) {
|
||||
logger()->info('Building required library ' . static::NAME);
|
||||
$this->build();
|
||||
return BUILD_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -32,28 +32,28 @@ class brotli extends LinuxLibraryBase
|
||||
public function build()
|
||||
{
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
f_passthru(
|
||||
"{$this->builder->set_x} && " .
|
||||
"cd {$this->source_dir} && " .
|
||||
'rm -rf build && ' .
|
||||
'mkdir -p build && ' .
|
||||
'cd build && ' .
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'.. && ' .
|
||||
"cmake --build . -j {$this->builder->concurrency} --target brotlicommon-static && " .
|
||||
"cmake --build . -j {$this->builder->concurrency} --target brotlidec-static && " .
|
||||
"cmake --build . -j {$this->builder->concurrency} --target brotlienc-static && " .
|
||||
'cp libbrotlidec-static.a ' . BUILD_LIB_PATH . ' && ' .
|
||||
'cp libbrotlienc-static.a ' . BUILD_LIB_PATH . ' && ' .
|
||||
'cp libbrotlicommon-static.a ' . BUILD_LIB_PATH . ' && ' .
|
||||
'cp -r ../c/include/brotli ' . BUILD_INCLUDE_PATH
|
||||
);
|
||||
// 清理旧的编译文件
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build');
|
||||
// 使用 cmake 编译
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
$this->builder->configure_env . ' cmake ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlicommon-static")
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlidec-static")
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target brotlienc-static")
|
||||
->exec('cp libbrotlidec-static.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp libbrotlienc-static.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp libbrotlicommon-static.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp -r ../c/include/brotli ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,15 +33,11 @@ class bzip2 extends LinuxLibraryBase
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
f_passthru(
|
||||
$this->builder->set_x . ' && ' .
|
||||
"cd {$this->source_dir} && " .
|
||||
"make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean" . ' && ' .
|
||||
"make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a" . ' && ' .
|
||||
// make install may fail when cross-compiling, so we copy files.
|
||||
'cp libbz2.a ' . BUILD_LIB_PATH . ' && ' .
|
||||
'cp bzlib.h ' . BUILD_INCLUDE_PATH
|
||||
);
|
||||
// $this->makeFakePkgconfs();
|
||||
shell()
|
||||
->cd($this->source_dir)
|
||||
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->exec("make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
|
||||
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,11 +76,8 @@ EOF
|
||||
$extra = '';
|
||||
// lib:openssl
|
||||
$openssl = $this->builder->getLib('openssl');
|
||||
if ($openssl instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DCURL_USE_OPENSSL=ON -DCURL_ENABLE_SSL=ON ';
|
||||
} else {
|
||||
$extra .= '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF ';
|
||||
}
|
||||
$use_openssl = $openssl instanceof LinuxLibraryBase ? 'ON' : 'OFF';
|
||||
$extra .= "-DCURL_USE_OPENSSL={$use_openssl} -DCURL_ENABLE_SSL={$use_openssl} ";
|
||||
// lib:zlib
|
||||
$zlib = $this->builder->getLib('zlib');
|
||||
if ($zlib instanceof LinuxLibraryBase) {
|
||||
@@ -140,24 +137,21 @@ EOF
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
// compile!
|
||||
f_passthru(
|
||||
$this->builder->set_x . ' && ' .
|
||||
"cd {$this->source_dir} && " .
|
||||
'rm -rf build && ' .
|
||||
'mkdir -p build && ' .
|
||||
'cd build && ' .
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
$extra .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'.. && ' .
|
||||
"make -j{$this->builder->concurrency} && " .
|
||||
'make install DESTDIR="' . $destdir . '"'
|
||||
);
|
||||
shell()
|
||||
->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec("{$this->builder->configure_env} cmake " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
$extra .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR='{$destdir}'");
|
||||
}
|
||||
}
|
||||
|
||||
28
src/SPC/builder/linux/library/gmp.php
Normal file
28
src/SPC/builder/linux/library/gmp.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
/**
|
||||
* gmp is a template library class for unix
|
||||
*/
|
||||
class gmp extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'gmp';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static --disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
@@ -35,16 +35,15 @@ class libiconv extends LinuxLibraryBase
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
f_passthru(
|
||||
$this->builder->set_x . ' && ' .
|
||||
"cd {$this->source_dir} && " .
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--prefix= && ' . // use prefix=/
|
||||
'make clean && ' .
|
||||
"make -j{$this->builder->concurrency} && " .
|
||||
'make install DESTDIR=' . $destdir
|
||||
);
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . $destdir);
|
||||
}
|
||||
}
|
||||
|
||||
64
src/SPC/builder/linux/library/libpng.php
Normal file
64
src/SPC/builder/linux/library/libpng.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\Patcher;
|
||||
|
||||
class libpng extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'libpng';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
// 不同架构的专属优化
|
||||
$optimizations = match ($this->builder->arch) {
|
||||
'x86_64' => '--enable-intel-sse ',
|
||||
'arm64' => '--enable-arm-neon ',
|
||||
default => '',
|
||||
};
|
||||
|
||||
// patch configure
|
||||
Patcher::patchUnixLibpng();
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
"--host={$this->builder->gnu_arch}-unknown-linux " .
|
||||
'--disable-shared ' .
|
||||
'--enable-static ' .
|
||||
'--enable-hardware-optimizations ' .
|
||||
'--with-zlib-prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||
$optimizations .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I. -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la")
|
||||
->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH)
|
||||
->cd(BUILD_LIB_PATH)
|
||||
->exec('ln -sf libpng16.a libpng.a');
|
||||
}
|
||||
}
|
||||
60
src/SPC/builder/linux/library/libssh2.php
Normal file
60
src/SPC/builder/linux/library/libssh2.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libssh2 extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'libssh2';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
// lib:zlib
|
||||
$enable_zlib = $this->builder->getLib('zlib') !== null ? 'ON' : 'OFF';
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_EXAMPLES=OFF ' .
|
||||
'-DBUILD_TESTING=OFF ' .
|
||||
"-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency} --target libssh2")
|
||||
->exec('make install DESTDIR="' . $destdir . '"');
|
||||
}
|
||||
}
|
||||
29
src/SPC/builder/linux/library/libuv.php
Normal file
29
src/SPC/builder/linux/library/libuv.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
/**
|
||||
* is a template library class for unix
|
||||
*/
|
||||
class libuv extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'libuv';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('./autogen.sh')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static --disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
@@ -27,34 +27,6 @@ class libxml2 extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'libxml2';
|
||||
|
||||
protected array $static_libs = ['libxml2.a'];
|
||||
|
||||
protected array $headers = [
|
||||
'libxml2',
|
||||
];
|
||||
|
||||
protected array $pkgconfs = [
|
||||
'libxml-2.0.pc' => <<<'EOF'
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
modules=1
|
||||
|
||||
Name: libXML
|
||||
Version: 2.9.14
|
||||
Description: libXML library version2.
|
||||
Requires:
|
||||
Libs: -L${libdir} -lxml2
|
||||
Cflags: -I${includedir}/libxml2
|
||||
EOF
|
||||
];
|
||||
|
||||
protected array $dep_names = [
|
||||
'icu' => true,
|
||||
'xz' => true,
|
||||
'zlib' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
@@ -66,39 +38,39 @@ EOF
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
f_passthru(
|
||||
$this->builder->set_x . ' && ' .
|
||||
"cd {$this->source_dir} && " .
|
||||
'rm -rf build && ' .
|
||||
'mkdir -p build && ' .
|
||||
'cd build && ' .
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
'-DIconv_IS_BUILT_IN=OFF ' .
|
||||
"-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 ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'.. && ' .
|
||||
"cmake --build . -j {$this->builder->concurrency} && " .
|
||||
'make install DESTDIR="' . $destdir . '"'
|
||||
);
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} " . ' cmake ' .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DLIBXML2_WITH_ICONV=ON ' .
|
||||
'-DIconv_IS_BUILT_IN=OFF ' .
|
||||
"-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 ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR="' . $destdir . '"');
|
||||
|
||||
if (is_dir(BUILD_INCLUDE_PATH . '/libxml2/libxml')) {
|
||||
if (is_dir(BUILD_INCLUDE_PATH . '/libxml')) {
|
||||
f_passthru('rm -rf "' . BUILD_INCLUDE_PATH . '/libxml"');
|
||||
shell()->exec('rm -rf "' . BUILD_INCLUDE_PATH . '/libxml"');
|
||||
}
|
||||
$path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/libxml2/libxml');
|
||||
$dst_path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/');
|
||||
f_passthru('mv "' . $path . '" "' . $dst_path . '"');
|
||||
shell()->exec('mv "' . $path . '" "' . $dst_path . '"');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
93
src/SPC/builder/linux/library/libyaml.php
Normal file
93
src/SPC/builder/linux/library/libyaml.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libyaml extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'libyaml';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
// prepare cmake/config.h.in
|
||||
if (!is_file(SOURCE_PATH . '/libyaml/cmake/config.h.in')) {
|
||||
f_mkdir(SOURCE_PATH . '/libyaml/cmake');
|
||||
file_put_contents(
|
||||
SOURCE_PATH . '/libyaml/cmake/config.h.in',
|
||||
<<<'EOF'
|
||||
#define YAML_VERSION_MAJOR @YAML_VERSION_MAJOR@
|
||||
#define YAML_VERSION_MINOR @YAML_VERSION_MINOR@
|
||||
#define YAML_VERSION_PATCH @YAML_VERSION_PATCH@
|
||||
#define YAML_VERSION_STRING "@YAML_VERSION_STRING@"
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
// prepare yamlConfig.cmake.in
|
||||
if (!is_file(SOURCE_PATH . '/libyaml/yamlConfig.cmake.in')) {
|
||||
file_put_contents(
|
||||
SOURCE_PATH . '/libyaml/yamlConfig.cmake.in',
|
||||
<<<'EOF'
|
||||
# Config file for the yaml library.
|
||||
#
|
||||
# It defines the following variables:
|
||||
# yaml_LIBRARIES - libraries to link against
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set_and_check(yaml_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/yamlTargets.cmake")
|
||||
|
||||
if(NOT yaml_TARGETS_IMPORTED)
|
||||
set(yaml_TARGETS_IMPORTED 1)
|
||||
include(${yaml_TARGETS})
|
||||
endif()
|
||||
|
||||
set(yaml_LIBRARIES yaml)
|
||||
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()
|
||||
->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec("{$this->builder->configure_env} cmake " .
|
||||
// '--debug-find ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_TESTING=OFF ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
106
src/SPC/builder/linux/library/libzip.php
Normal file
106
src/SPC/builder/linux/library/libzip.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class libzip extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'libzip';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException|RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$extra = '';
|
||||
// lib:zlib
|
||||
$zlib = $this->builder->getLib('zlib');
|
||||
if ($zlib instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DZLIB_LIBRARY="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
}
|
||||
// lib:bzip2
|
||||
$libbzip2 = $this->builder->getLib('bzip2');
|
||||
if ($libbzip2 instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DENABLE_BZIP2=ON ' .
|
||||
'-DBZIP2_LIBRARIES="' . $libbzip2->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DBZIP2_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_BZIP2=OFF ';
|
||||
}
|
||||
// lib:xz
|
||||
$xz = $this->builder->getLib('xz');
|
||||
if ($xz instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DENABLE_LZMA=ON ' .
|
||||
'-DLIBLZMA_LIBRARY="' . $xz->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DLIBLZMA_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_LZMA=OFF ';
|
||||
}
|
||||
// lib:zstd
|
||||
$libzstd = $this->builder->getLib('zstd');
|
||||
if ($libzstd instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DENABLE_ZSTD=ON ' .
|
||||
'-DZstd_LIBRARY="' . $libzstd->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DZstd_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_ZSTD=OFF ';
|
||||
}
|
||||
// lib:openssl
|
||||
$libopenssl = $this->builder->getLib('openssl');
|
||||
if ($libopenssl instanceof LinuxLibraryBase) {
|
||||
$extra .= '-DENABLE_OPENSSL=ON ' .
|
||||
'-DOpenSSL_LIBRARY="' . $libopenssl->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||
'-DOpenSSL_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
|
||||
} else {
|
||||
$extra .= '-DENABLE_OPENSSL=OFF ';
|
||||
}
|
||||
|
||||
[$lib, $include, $destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()
|
||||
->cd($this->source_dir)
|
||||
->exec('rm -rf build')
|
||||
->exec('mkdir -p build')
|
||||
->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
$this->builder->configure_env . ' cmake ' .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DENABLE_GNUTLS=OFF ' .
|
||||
'-DENABLE_MBEDTLS=OFF ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_DOC=OFF ' .
|
||||
'-DBUILD_EXAMPLES=OFF ' .
|
||||
'-DBUILD_REGRESS=OFF ' .
|
||||
'-DBUILD_TOOLS=OFF ' .
|
||||
$extra .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'..'
|
||||
)
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . $destdir);
|
||||
}
|
||||
}
|
||||
102
src/SPC/builder/linux/library/nghttp2.php
Normal file
102
src/SPC/builder/linux/library/nghttp2.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class nghttp2 extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'nghttp2';
|
||||
|
||||
protected array $static_libs = ['libnghttp2.a'];
|
||||
|
||||
protected array $headers = ['nghttp2'];
|
||||
|
||||
protected array $pkgconfs = [
|
||||
'libnghttp2.pc' => <<<'EOF'
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libnghttp2
|
||||
Description: HTTP/2 C library
|
||||
URL: https://github.com/tatsuhiro-t/nghttp2
|
||||
Version: 1.47.0
|
||||
Libs: -L${libdir} -lnghttp2
|
||||
Cflags: -I${includedir}
|
||||
EOF
|
||||
];
|
||||
|
||||
protected array $dep_names = [
|
||||
'zlib' => false,
|
||||
'openssl' => false,
|
||||
'libxml2' => true,
|
||||
'libev' => true,
|
||||
'libcares' => true,
|
||||
'libngtcp2' => true,
|
||||
'libnghttp3' => true,
|
||||
'libbpf' => true,
|
||||
'libevent-openssl' => true,
|
||||
'jansson' => true,
|
||||
'jemalloc' => true,
|
||||
'systemd' => true,
|
||||
'cunit' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$args = $this->builder->makeAutoconfArgs(static::NAME, [
|
||||
'zlib' => null,
|
||||
'openssl' => null,
|
||||
'libxml2' => null,
|
||||
'libev' => null,
|
||||
'libcares' => null,
|
||||
'libngtcp2' => null,
|
||||
'libnghttp3' => null,
|
||||
'libbpf' => null,
|
||||
'libevent-openssl' => null,
|
||||
'jansson' => null,
|
||||
'jemalloc' => null,
|
||||
'systemd' => null,
|
||||
'cunit' => null,
|
||||
]);
|
||||
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->gnu_arch}-unknown-linux " .
|
||||
'--enable-lib-only ' .
|
||||
'--with-boost=no ' .
|
||||
$args . ' ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
48
src/SPC/builder/linux/library/onig.php
Normal file
48
src/SPC/builder/linux/library/onig.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class onig extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'onig';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->arch}-unknown-linux " .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
@@ -28,53 +28,6 @@ class openssl extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'openssl';
|
||||
|
||||
protected array $static_libs = [
|
||||
'libssl.a',
|
||||
'libcrypto.a',
|
||||
];
|
||||
|
||||
protected array $headers = ['openssl'];
|
||||
|
||||
protected array $pkgconfs = [
|
||||
'openssl.pc' => <<<'EOF'
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: OpenSSL
|
||||
Description: Secure Sockets Layer and cryptography libraries and tools
|
||||
Version: 3.0.3
|
||||
Requires: libssl libcrypto
|
||||
EOF,
|
||||
'libssl.pc' => <<<'EOF'
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: OpenSSL-libssl
|
||||
Description: Secure Sockets Layer and cryptography libraries
|
||||
Version: 3.0.3
|
||||
Requires.private: libcrypto
|
||||
Libs: -L${libdir} -lssl
|
||||
Cflags: -I${includedir}
|
||||
EOF,
|
||||
'libcrypto.pc' => <<<'EOF'
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
enginesdir=${libdir}/engines-3
|
||||
|
||||
Name: OpenSSL-libcrypto
|
||||
Description: OpenSSL cryptography library
|
||||
Version: 3.0.3
|
||||
Libs: -L${libdir} -lcrypto
|
||||
Libs.private: -lz -ldl -pthread
|
||||
Cflags: -I${includedir}
|
||||
EOF,
|
||||
];
|
||||
|
||||
protected array $dep_names = ['zlib' => true];
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
@@ -107,21 +60,18 @@ EOF,
|
||||
|
||||
$clang_postfix = SystemUtil::getCCType($this->builder->cc) === 'clang' ? '-clang' : '';
|
||||
|
||||
f_passthru(
|
||||
$this->builder->set_x . ' && ' .
|
||||
"cd {$this->source_dir} && " .
|
||||
"{$this->builder->configure_env} {$env} ./Configure no-shared {$extra} " .
|
||||
'--prefix=/ ' . // use prefix=/
|
||||
"--libdir={$lib} " .
|
||||
'--static -static ' .
|
||||
"{$zlib_extra}" .
|
||||
'no-legacy ' .
|
||||
"linux-{$this->builder->arch}{$clang_postfix} && " .
|
||||
'make clean && ' .
|
||||
"make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\" && " .
|
||||
'make install_sw DESTDIR=' . $destdir
|
||||
// remove liblegacy
|
||||
// 'ar t lib/libcrypto.a | grep -e \'^liblegacy-\' | xargs ar d lib/libcrypto.a'
|
||||
);
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} {$env} ./Configure no-shared {$extra} " .
|
||||
'--prefix=/ ' .
|
||||
"--libdir={$lib} " .
|
||||
'--static -static ' .
|
||||
"{$zlib_extra}" .
|
||||
'no-legacy ' .
|
||||
"linux-{$this->builder->arch}{$clang_postfix}"
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||
->exec("make install_sw DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
47
src/SPC/builder/linux/library/sqlite.php
Normal file
47
src/SPC/builder/linux/library/sqlite.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class sqlite extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'sqlite';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
56
src/SPC/builder/linux/library/xz.php
Normal file
56
src/SPC/builder/linux/library/xz.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class xz extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'xz';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
// ->exec('autoreconf -i --force')
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
"--host={$this->builder->gnu_arch}-unknown-linux " .
|
||||
'--disable-xz ' .
|
||||
'--disable-xzdec ' .
|
||||
'--disable-lzmadec ' .
|
||||
'--disable-lzmainfo ' .
|
||||
'--disable-scripts ' .
|
||||
'--disable-doc ' .
|
||||
'--with-libiconv ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
@@ -33,15 +33,14 @@ class zlib extends LinuxLibraryBase
|
||||
{
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
f_passthru(
|
||||
$this->builder->set_x . ' && ' .
|
||||
"cd {$this->source_dir} && " .
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--static ' .
|
||||
'--prefix= && ' . // use prefix=/
|
||||
'make clean && ' .
|
||||
"make -j{$this->builder->concurrency} && " .
|
||||
'make install DESTDIR=' . $destdir
|
||||
);
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
"{$this->builder->configure_env} ./configure " .
|
||||
'--static ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
}
|
||||
}
|
||||
|
||||
45
src/SPC/builder/linux/library/zstd.php
Normal file
45
src/SPC/builder/linux/library/zstd.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
||||
*
|
||||
* lwmbs is licensed under Mulan PSL v2. You can use this
|
||||
* software according to the terms and conditions of the
|
||||
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class zstd extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'zstd';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
||||
->exec(
|
||||
"make -j{$this->builder->concurrency} " .
|
||||
"{$this->builder->configure_env} " .
|
||||
"PREFIX='" . BUILD_ROOT_PATH . "' " .
|
||||
'-C lib libzstd.a CPPFLAGS_STATLIB=-DZSTD_MULTITHREAD'
|
||||
)
|
||||
->exec('cp lib/libzstd.a ' . BUILD_LIB_PATH)
|
||||
->exec('cp lib/zdict.h lib/zstd_errors.h lib/zstd.h ' . BUILD_INCLUDE_PATH);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user