mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
fix bzip2, fix curl, add iconv, add libxml2, add and fix openssl
This commit is contained in:
107
ext-support.md
107
ext-support.md
@@ -5,59 +5,60 @@
|
|||||||
> - empty: not supported yet
|
> - empty: not supported yet
|
||||||
> - faulty with issue link: not supported yet due to issue
|
> - faulty with issue link: not supported yet due to issue
|
||||||
|
|
||||||
| | Linux | macOS | Windows |
|
| | Linux | macOS | Windows |
|
||||||
|------------|-------|--------------------------------------------------------------------|---------|
|
|------------|----------|--------------------------------------------------------------------|---------|
|
||||||
| bcmath | yes | yes | |
|
| bcmath | yes | yes | |
|
||||||
| bz2 | yes | untested | |
|
| bz2 | yes | untested | |
|
||||||
| calendar | | yes | |
|
| calendar | yes | yes | |
|
||||||
| ctype | | yes | |
|
| ctype | yes | yes | |
|
||||||
| curl | yes | yes | |
|
| curl | untested | yes | |
|
||||||
| date | | yes | |
|
| date | | yes | |
|
||||||
| dom | | untested | |
|
| dba | yes | yes | |
|
||||||
| event | | | |
|
| dom | untested | untested | |
|
||||||
| exif | | yes | |
|
| event | | | |
|
||||||
| filter | | yes | |
|
| exif | | yes | |
|
||||||
| fileinfo | | | |
|
| filter | | yes | |
|
||||||
| ftp | | yes | |
|
| fileinfo | | | |
|
||||||
| gd | | untested | |
|
| ftp | | yes | |
|
||||||
| gmp | | untested | |
|
| gd | | untested | |
|
||||||
| hash | | yes | |
|
| gmp | | untested | |
|
||||||
| iconv | | | |
|
| hash | yes | yes | |
|
||||||
| inotify | | | |
|
| iconv | untested | | |
|
||||||
| json | | yes | |
|
| inotify | | | |
|
||||||
| libxml | | yes | |
|
| json | yes | yes | |
|
||||||
| mbstring | | yes | |
|
| libxml | | yes | |
|
||||||
| mcrypt | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
| mbstring | | yes | |
|
||||||
| mongodb | | | |
|
| mcrypt | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
||||||
| mysqli | | | |
|
| mongodb | | | |
|
||||||
| mysqlnd | | yes | |
|
| mysqli | | | |
|
||||||
| openssl | | yes | |
|
| mysqlnd | | yes | |
|
||||||
| pcntl | | untested | |
|
| openssl | untested | yes | |
|
||||||
| pcre | | yes | |
|
| pcntl | untested | untested | |
|
||||||
| pdo | | yes | |
|
| pcre | | yes | |
|
||||||
| pdo_mysql | | yes | |
|
| pdo | | yes | |
|
||||||
| pdo_sqlite | | yes | |
|
| pdo_mysql | | yes | |
|
||||||
| pdo_pgsql | | | |
|
| pdo_sqlite | | yes | |
|
||||||
| phar | | yes | |
|
| pdo_pgsql | | | |
|
||||||
| posix | | yes | |
|
| phar | yes | yes | |
|
||||||
| protobuf | | | |
|
| posix | yes | yes | |
|
||||||
| readline | | | |
|
| protobuf | | | |
|
||||||
| redis | | yes | |
|
| readline | | | |
|
||||||
| Reflection | | yes | |
|
| redis | | yes | |
|
||||||
| session | | yes | |
|
| Reflection | | yes | |
|
||||||
| shmop | | | |
|
| session | | yes | |
|
||||||
| simplexml | | untested | |
|
| shmop | | | |
|
||||||
| soap | | | |
|
| simplexml | | untested | |
|
||||||
| sockets | | | |
|
| soap | | | |
|
||||||
| sqlite3 | | untested | |
|
| sockets | | | |
|
||||||
| swow | | | |
|
| sqlite3 | | untested | |
|
||||||
| swoole | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
| swow | | | |
|
||||||
| tokenizer | | yes | |
|
| swoole | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
|
||||||
| xml | | yes | |
|
| tokenizer | | yes | |
|
||||||
| xmlreader | | untested | |
|
| xml | | yes | |
|
||||||
| xmlwriter | | untested | |
|
| xmlreader | | untested | |
|
||||||
| zip | | yes | |
|
| xmlwriter | | untested | |
|
||||||
| zlib | | yes | |
|
| zip | | yes | |
|
||||||
|
| zlib | yes | yes | |
|
||||||
|
|
||||||
## Additional Requirements
|
## Additional Requirements
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,6 @@ class bzip2 extends LinuxLibraryBase
|
|||||||
'cp libbz2.a ' . BUILD_LIB_PATH . ' && ' .
|
'cp libbz2.a ' . BUILD_LIB_PATH . ' && ' .
|
||||||
'cp bzlib.h ' . BUILD_INCLUDE_PATH
|
'cp bzlib.h ' . BUILD_INCLUDE_PATH
|
||||||
);
|
);
|
||||||
$this->makeFakePkgconfs();
|
// $this->makeFakePkgconfs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,15 +77,15 @@ EOF
|
|||||||
// lib:openssl
|
// lib:openssl
|
||||||
$openssl = $this->builder->getLib('openssl');
|
$openssl = $this->builder->getLib('openssl');
|
||||||
if ($openssl instanceof LinuxLibraryBase) {
|
if ($openssl instanceof LinuxLibraryBase) {
|
||||||
$extra .= '-DCURL_USE_OPENSSL=ON ';
|
$extra .= '-DCURL_USE_OPENSSL=ON -DCURL_ENABLE_SSL=ON ';
|
||||||
} else {
|
} else {
|
||||||
$extra .= '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF ';
|
$extra .= '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF ';
|
||||||
}
|
}
|
||||||
// lib:zlib
|
// lib:zlib
|
||||||
$zlib = $this->builder->getLib('zlib');
|
$zlib = $this->builder->getLib('zlib');
|
||||||
if ($zlib instanceof LinuxLibraryBase) {
|
if ($zlib instanceof LinuxLibraryBase) {
|
||||||
$extra .= '-DZLIB_LIBRARY="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' .
|
$extra .= '-DZLIB_LIBRARIES="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' .
|
||||||
'-DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ';
|
'-DZLIB_INCLUDE_DIRS="' . BUILD_INCLUDE_PATH . '" ';
|
||||||
}
|
}
|
||||||
// lib:libssh2
|
// lib:libssh2
|
||||||
$libssh2 = $this->builder->getLib('libssh2');
|
$libssh2 = $this->builder->getLib('libssh2');
|
||||||
|
|||||||
50
src/SPC/builder/linux/library/libiconv.php
Normal file
50
src/SPC/builder/linux/library/libiconv.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?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 libiconv extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
public const NAME = 'libiconv';
|
||||||
|
|
||||||
|
protected array $dep_names = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
[,,$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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
104
src/SPC/builder/linux/library/libxml2.php
Normal file
104
src/SPC/builder/linux/library/libxml2.php
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<?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;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
public 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;
|
||||||
|
|
||||||
|
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 . '"'
|
||||||
|
);
|
||||||
|
if (is_dir(BUILD_INCLUDE_PATH . '/libxml2/libxml')) {
|
||||||
|
if (is_dir(BUILD_INCLUDE_PATH . '/libxml')) {
|
||||||
|
f_passthru('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 . '"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
127
src/SPC/builder/linux/library/openssl.php
Normal file
127
src/SPC/builder/linux/library/openssl.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<?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\builder\linux\SystemUtil;
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
[$lib,$include,$destdir] = SEPARATED_PATH;
|
||||||
|
|
||||||
|
$extra = '';
|
||||||
|
$ex_lib = '-ldl -pthread';
|
||||||
|
|
||||||
|
$env = $this->builder->pkgconf_env . " CFLAGS='{$this->builder->arch_c_flags}'";
|
||||||
|
$env .= " CC='{$this->builder->cc} --static -static-libgcc -idirafter " . BUILD_INCLUDE_PATH .
|
||||||
|
' -idirafter /usr/include/ ' .
|
||||||
|
' -idirafter /usr/include/' . $this->builder->arch . '-linux-gnu/ ' .
|
||||||
|
"' ";
|
||||||
|
// lib:zlib
|
||||||
|
$zlib = $this->builder->getLib('zlib');
|
||||||
|
if ($zlib instanceof LinuxLibraryBase) {
|
||||||
|
$extra = 'zlib';
|
||||||
|
$ex_lib = trim($zlib->getStaticLibFiles() . ' ' . $ex_lib);
|
||||||
|
$zlib_extra =
|
||||||
|
'--with-zlib-include=' . BUILD_INCLUDE_PATH . ' ' .
|
||||||
|
'--with-zlib-lib=' . BUILD_LIB_PATH . ' ';
|
||||||
|
} else {
|
||||||
|
$zlib_extra = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$ex_lib = trim($ex_lib);
|
||||||
|
|
||||||
|
$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'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user