diff --git a/ext-support.md b/ext-support.md index a609a54d..64743713 100644 --- a/ext-support.md +++ b/ext-support.md @@ -5,59 +5,60 @@ > - empty: not supported yet > - faulty with issue link: not supported yet due to issue -| | Linux | macOS | Windows | -|------------|-------|--------------------------------------------------------------------|---------| -| bcmath | yes | yes | | -| bz2 | yes | untested | | -| calendar | | yes | | -| ctype | | yes | | -| curl | yes | yes | | -| date | | yes | | -| dom | | untested | | -| event | | | | -| exif | | yes | | -| filter | | yes | | -| fileinfo | | | | -| ftp | | yes | | -| gd | | untested | | -| gmp | | untested | | -| hash | | yes | | -| iconv | | | | -| inotify | | | | -| json | | yes | | -| libxml | | yes | | -| mbstring | | yes | | -| mcrypt | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | | -| mongodb | | | | -| mysqli | | | | -| mysqlnd | | yes | | -| openssl | | yes | | -| pcntl | | untested | | -| pcre | | yes | | -| pdo | | yes | | -| pdo_mysql | | yes | | -| pdo_sqlite | | yes | | -| pdo_pgsql | | | | -| phar | | yes | | -| posix | | yes | | -| protobuf | | | | -| readline | | | | -| redis | | yes | | -| Reflection | | yes | | -| session | | yes | | -| shmop | | | | -| simplexml | | untested | | -| soap | | | | -| sockets | | | | -| sqlite3 | | untested | | -| swow | | | | -| swoole | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | | -| tokenizer | | yes | | -| xml | | yes | | -| xmlreader | | untested | | -| xmlwriter | | untested | | -| zip | | yes | | -| zlib | | yes | | +| | Linux | macOS | Windows | +|------------|----------|--------------------------------------------------------------------|---------| +| bcmath | yes | yes | | +| bz2 | yes | untested | | +| calendar | yes | yes | | +| ctype | yes | yes | | +| curl | untested | yes | | +| date | | yes | | +| dba | yes | yes | | +| dom | untested | untested | | +| event | | | | +| exif | | yes | | +| filter | | yes | | +| fileinfo | | | | +| ftp | | yes | | +| gd | | untested | | +| gmp | | untested | | +| hash | yes | yes | | +| iconv | untested | | | +| inotify | | | | +| json | yes | yes | | +| libxml | | yes | | +| mbstring | | yes | | +| mcrypt | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | | +| mongodb | | | | +| mysqli | | | | +| mysqlnd | | yes | | +| openssl | untested | yes | | +| pcntl | untested | untested | | +| pcre | | yes | | +| pdo | | yes | | +| pdo_mysql | | yes | | +| pdo_sqlite | | yes | | +| pdo_pgsql | | | | +| phar | yes | yes | | +| posix | yes | yes | | +| protobuf | | | | +| readline | | | | +| redis | | yes | | +| Reflection | | yes | | +| session | | yes | | +| shmop | | | | +| simplexml | | untested | | +| soap | | | | +| sockets | | | | +| sqlite3 | | untested | | +| swow | | | | +| swoole | | [faulty](https://github.com/crazywhalecc/static-php-cli/issues/32) | | +| tokenizer | | yes | | +| xml | | yes | | +| xmlreader | | untested | | +| xmlwriter | | untested | | +| zip | | yes | | +| zlib | yes | yes | | ## Additional Requirements diff --git a/src/SPC/builder/linux/library/bzip2.php b/src/SPC/builder/linux/library/bzip2.php index bf59d740..d3668517 100644 --- a/src/SPC/builder/linux/library/bzip2.php +++ b/src/SPC/builder/linux/library/bzip2.php @@ -42,6 +42,6 @@ class bzip2 extends LinuxLibraryBase 'cp libbz2.a ' . BUILD_LIB_PATH . ' && ' . 'cp bzlib.h ' . BUILD_INCLUDE_PATH ); - $this->makeFakePkgconfs(); + // $this->makeFakePkgconfs(); } } diff --git a/src/SPC/builder/linux/library/curl.php b/src/SPC/builder/linux/library/curl.php index 8032242a..f286df54 100644 --- a/src/SPC/builder/linux/library/curl.php +++ b/src/SPC/builder/linux/library/curl.php @@ -77,15 +77,15 @@ EOF // lib:openssl $openssl = $this->builder->getLib('openssl'); if ($openssl instanceof LinuxLibraryBase) { - $extra .= '-DCURL_USE_OPENSSL=ON '; + $extra .= '-DCURL_USE_OPENSSL=ON -DCURL_ENABLE_SSL=ON '; } else { $extra .= '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF '; } // lib:zlib $zlib = $this->builder->getLib('zlib'); if ($zlib instanceof LinuxLibraryBase) { - $extra .= '-DZLIB_LIBRARY="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' . - '-DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' '; + $extra .= '-DZLIB_LIBRARIES="' . $zlib->getStaticLibFiles(style: 'cmake') . '" ' . + '-DZLIB_INCLUDE_DIRS="' . BUILD_INCLUDE_PATH . '" '; } // lib:libssh2 $libssh2 = $this->builder->getLib('libssh2'); diff --git a/src/SPC/builder/linux/library/libiconv.php b/src/SPC/builder/linux/library/libiconv.php new file mode 100644 index 00000000..0c7fbae0 --- /dev/null +++ b/src/SPC/builder/linux/library/libiconv.php @@ -0,0 +1,50 @@ + + * + * 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 + ); + } +} diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php new file mode 100644 index 00000000..5c14c0e2 --- /dev/null +++ b/src/SPC/builder/linux/library/libxml2.php @@ -0,0 +1,104 @@ + + * + * 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 . '"'); + } + } +} diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php new file mode 100644 index 00000000..07d6bf1e --- /dev/null +++ b/src/SPC/builder/linux/library/openssl.php @@ -0,0 +1,127 @@ + + * + * 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' + ); + } +}