diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..36b494a8 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/README-en.md b/README-en.md index 4bd3120a..6627e9d9 100755 --- a/README-en.md +++ b/README-en.md @@ -154,7 +154,7 @@ cd buildroot/bin/ ### micro.sfx Usage -> phpmicro is a Self-Extracted Executable SAPI module, +> phpmicro is a SelF-extracted eXecutable SAPI module, > provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro). > It can put php runtime and your source code together. @@ -215,6 +215,10 @@ The basic principles for contributing are as follows: camelCase and underscore formats should be followed, and mixing within the same module is prohibited. - When compiling external libraries and creating patches, compatibility with different operating systems should be considered. +## Sponsor this project + +You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). + ## Open-Source License This project is based on the tradition of using the MIT License for old versions, @@ -227,7 +231,7 @@ Due to the special nature of this project, many other open source projects such as curl and protobuf will be used during the project compilation process, and they all have their own open source licenses. -Please use the `dump-license`(TODO) command to export the open source licenses used in the project after compilation, +Please use the `bin/spc dump-license` command to export the open source licenses used in the project after compilation, and comply with the corresponding project's LICENSE. ## Advanced diff --git a/README.md b/README.md index 84e93f0f..d4f436ff 100755 --- a/README.md +++ b/README.md @@ -200,6 +200,10 @@ cat micro.sfx code.php > single-app && chmod +x single-app 另外,添加新扩展的贡献方式,可以参考下方 `进阶`。 +## 赞助本项目 + +你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。 + ## 开源协议 本项目依据旧版本惯例采用 MIT License 开源,自身的部分代码引用或修改自以下项目: @@ -208,7 +212,7 @@ cat micro.sfx code.php > single-app && chmod +x single-app - [swoole/swoole-cli](https://github.com/swoole/swoole-cli)(Apache 2.0 LICENSE、SWOOLE-CLI LICENSE) 因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。 -请在编译完成后,使用命令 `dump-license`(TODO) 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。 +请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。 ## 进阶 diff --git a/config/ext.json b/config/ext.json index f6d2d93c..59e07925 100644 --- a/config/ext.json +++ b/config/ext.json @@ -165,7 +165,14 @@ "mongodb": { "type": "external", "source": "mongodb", - "arg-type": "custom" + "arg-type": "custom", + "lib-depends": [ + "zstd" + ], + "lib-suggests": [ + "icu", + "openssl" + ] }, "mysqli": { "type": "builtin", @@ -428,4 +435,4 @@ "zstd" ] } -} \ No newline at end of file +} diff --git a/config/lib.json b/config/lib.json index 4c2c0cae..6f5d0682 100644 --- a/config/lib.json +++ b/config/lib.json @@ -96,6 +96,15 @@ "gmp.h" ] }, + "icu": { + "source": "icu", + "static-libs-unix": [ + "libicui18n.a", + "libicuio.a", + "libicuuc.a", + "libicudata.a" + ] + }, "imagemagick": { "source": "imagemagick", "static-libs-unix": [ @@ -200,6 +209,12 @@ "zlib" ] }, + "libsodium": { + "source": "libsodium", + "static-libs-unix": [ + "libsodium.a" + ] + }, "libssh2": { "source": "libssh2", "static-libs-unix": [ @@ -455,12 +470,6 @@ "zstd_errors.h" ] }, - "libsodium": { - "source": "libsodium", - "static-libs-unix": [ - "libsodium.a" - ] - }, "libargon2": { "source": "libargon2", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index d9784cba..977ae8ad 100644 --- a/config/source.json +++ b/config/source.json @@ -99,6 +99,14 @@ "text": "Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 and GNU GPL v2. These licenses make the library free to use, share, and improve, and allow you to pass on the result. The GNU licenses give freedoms, but also set firm restrictions on the use with non-free programs." } }, + "icu": { + "type": "url", + "url": "https://github.com/unicode-org/icu/releases/download/release-73-1/icu4c-73_1-src.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "imagemagick": { "type": "ghtar", "repo": "ImageMagick/ImageMagick", @@ -186,6 +194,14 @@ "path": "COPYING" } }, + "libsodium": { + "type": "url", + "url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libssh2": { "type": "ghrel", "repo": "libssh2/libssh2", @@ -412,14 +428,6 @@ "path": "LICENSE" } }, - "libsodium": { - "type": "url", - "url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "libargon2": { "type": "ghtar", "repo": "P-H-C/phc-winner-argon2", diff --git a/ext-support.md b/ext-support.md index 9af15a0d..5889ff1e 100644 --- a/ext-support.md +++ b/ext-support.md @@ -29,6 +29,7 @@ | iconv | yes | yes | | | imagick | yes | yes | | | inotify | yes | yes | | +| intl | | | | | mbstring | yes | yes | | | mbregex | yes | yes | | | mcrypt | | [no](https://github.com/crazywhalecc/static-php-cli/issues/32) | | @@ -36,6 +37,7 @@ | mysqli | yes | yes | | | mysqlnd | yes | yes | | | openssl | yes | yes | | +| password-argon2 | | | | | pcntl | yes | yes | | | pdo | yes | yes | | | pdo_mysql | yes | yes | | @@ -57,6 +59,7 @@ | swow | yes | yes | | | swoole | [partial](https://github.com/crazywhalecc/static-php-cli/issues/51) | yes | | | tokenizer | yes | yes | | +| xlswriter | | | | | xml | yes | yes | | | xmlreader | yes, untested | yes, untested | | | xmlwriter | yes, untested | yes, untested | | @@ -79,7 +82,7 @@ Here are some extension list example for different use. - For static-php-cli self (with dev dependencies): `"posix,pcntl,phar,tokenizer,iconv,zlib,xml,dom,xmlwriter,xmlreader,fileinfo"` - Minimum, with no extension: `""` -Compile with all supported extensions (exclude `swow`, `swoole` due to c++ extension): +Compile with all supported extensions (exclude `swow`, `swoole`, because these will change the default behavior of php): ```bash bin/spc build --build-all bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,mbregex,mbstring,mongodb,mysqli,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,protobuf,redis,session,shmop,simplexml,soap,sockets,sqlite3,tokenizer,xml,xmlreader,xmlwriter,yaml,zip,zlib,zstd --with-libs=libjpeg,freetype,libwebp,libavif --debug diff --git a/quickstart/linux/x86_64/README.md b/quickstart/linux/README.md similarity index 51% rename from quickstart/linux/x86_64/README.md rename to quickstart/linux/README.md index deb80a2b..c6090a30 100644 --- a/quickstart/linux/x86_64/README.md +++ b/quickstart/linux/README.md @@ -8,13 +8,13 @@ ```bash # 启动 debian 11 容器环境 -sh quickstart/linux/x86_64/run-debian-11-container.sh +sh quickstart/linux/run-debian-11-container.sh # 进入容器 -sh quickstart/linux/x86_64/connection-static-php-cli.sh +sh quickstart/linux/connection-static-php-cli.sh # 准备构建基础软件 -sh quickstart/linux/x86_64/debian-11-init.sh +sh quickstart/linux/debian-11-init.sh ``` @@ -23,12 +23,12 @@ sh quickstart/linux/x86_64/debian-11-init.sh ```bash # 启动 alpine 容器环境 -sh quickstart/linux/x86_64/run-alpine-3.16-container.sh +sh quickstart/linux/run-alpine-3.16-container.sh # 进入容器 -sh sh quickstart/linux/x86_64/connection-static-php-cli.sh +sh sh quickstart/linux/connection-static-php-cli.sh # 准备构建基础软件 -sh quickstart/linux/x86_64/alpine-3.16-init.sh +sh quickstart/linux/alpine-3.16-init.sh ``` \ No newline at end of file diff --git a/quickstart/linux/x86_64/alpine-3.16-init.sh b/quickstart/linux/alpine-3.16-init.sh similarity index 89% rename from quickstart/linux/x86_64/alpine-3.16-init.sh rename to quickstart/linux/alpine-3.16-init.sh index 2ad2d6e6..8aed86b6 100644 --- a/quickstart/linux/x86_64/alpine-3.16-init.sh +++ b/quickstart/linux/alpine-3.16-init.sh @@ -36,3 +36,5 @@ esac apk update apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils +apk add bash p7zip zip unzip flex pkgconf ca-certificates +apk add wget git curl \ No newline at end of file diff --git a/quickstart/linux/x86_64/connection-static-php-cli.sh b/quickstart/linux/connection-static-php-cli.sh similarity index 100% rename from quickstart/linux/x86_64/connection-static-php-cli.sh rename to quickstart/linux/connection-static-php-cli.sh diff --git a/quickstart/linux/x86_64/debian-11-init.sh b/quickstart/linux/debian-11-init.sh similarity index 95% rename from quickstart/linux/x86_64/debian-11-init.sh rename to quickstart/linux/debian-11-init.sh index 1ff044a9..dbd8478c 100644 --- a/quickstart/linux/x86_64/debian-11-init.sh +++ b/quickstart/linux/debian-11-init.sh @@ -36,7 +36,6 @@ esac apt update -y apt install -y git curl wget ca-certificates apt install -y xz-utils autoconf automake lld libtool cmake bison re2c gettext coreutils lzip zip unzip -apt install -y pkg-config bzip2 flex +apt install -y pkg-config bzip2 flex p7zip apt install -y musl-tools g++ apt install -y clang - diff --git a/quickstart/linux/x86_64/run-alpine-3.16-container.sh b/quickstart/linux/run-alpine-3.16-container.sh similarity index 92% rename from quickstart/linux/x86_64/run-alpine-3.16-container.sh rename to quickstart/linux/run-alpine-3.16-container.sh index b53d9cd4..fa3ea0e5 100644 --- a/quickstart/linux/x86_64/run-alpine-3.16-container.sh +++ b/quickstart/linux/run-alpine-3.16-container.sh @@ -6,7 +6,7 @@ __DIR__=$( pwd ) __PROJECT__=$( - cd ${__DIR__}/../../../ + cd ${__DIR__}/../../ pwd ) cd ${__DIR__} diff --git a/quickstart/linux/x86_64/run-debian-11-container.sh b/quickstart/linux/run-debian-11-container.sh similarity index 92% rename from quickstart/linux/x86_64/run-debian-11-container.sh rename to quickstart/linux/run-debian-11-container.sh index a9239727..c00ae1a6 100644 --- a/quickstart/linux/x86_64/run-debian-11-container.sh +++ b/quickstart/linux/run-debian-11-container.sh @@ -6,7 +6,7 @@ __DIR__=$( pwd ) __PROJECT__=$( - cd ${__DIR__}/../../../ + cd ${__DIR__}/../../ pwd ) cd ${__DIR__} diff --git a/quickstart/linux/x86_64/prepare.sh b/quickstart/linux/x86_64/prepare.sh deleted file mode 100644 index bd278330..00000000 --- a/quickstart/linux/x86_64/prepare.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../ - pwd -) -cd ${__PROJECT__} - -composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ - -chmod +x bin/spc - -./bin/spc fetch --all --debug - -./bin/spc list-ext - - -#./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=gcc --cxx=g++ --debug - -./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=clang --cxx=clang++ --debug diff --git a/quickstart/macOS/x86_64/prepare.sh b/quickstart/macOS/x86_64/prepare.sh deleted file mode 100644 index 93b83560..00000000 --- a/quickstart/macOS/x86_64/prepare.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../ - pwd -) -cd ${__PROJECT__} - -export PATH=${__PROJECT__}/bin/runtime:$PATH - -composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ - -chmod +x bin/spc - -./bin/spc fetch --all --debug - -./bin/spc list-ext - -./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=clang --cxx=clang++ --debug diff --git a/quickstart/prepare.sh b/quickstart/prepare.sh new file mode 100644 index 00000000..9f4669d1 --- /dev/null +++ b/quickstart/prepare.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../ + pwd +) +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +if [[ $OS = "Linux" && -f /etc/os-release ]]; then + OS_NAME=$(cat /etc/os-release | grep '^ID=' | awk -F '=' '{print $2}') + # debian ubuntu alpine +fi + +composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ + +chmod +x bin/spc + +./bin/spc fetch --all --debug + +./bin/spc list-ext + +EXTENSIONS="calendar,ctype,exif,fileinfo,filter,ftp" +EXTENSIONS="${EXTENSIONS},session,tokenizer" +EXTENSIONS="${EXTENSIONS},phar,posix" +EXTENSIONS="${EXTENSIONS},iconv" +EXTENSIONS="${EXTENSIONS},xml,dom,simplexml,xmlwriter,xmlreader" +EXTENSIONS="${EXTENSIONS},phar,posix" +EXTENSIONS="${EXTENSIONS},soap" +EXTENSIONS="${EXTENSIONS},mbstring,mbregex" +EXTENSIONS="${EXTENSIONS},openssl" +EXTENSIONS="${EXTENSIONS},sockets,gmp,bcmath" +EXTENSIONS="${EXTENSIONS},pcntl" +EXTENSIONS="${EXTENSIONS},curl" +EXTENSIONS="${EXTENSIONS},zlib,zip,bz2" +EXTENSIONS="${EXTENSIONS},gd" +EXTENSIONS="${EXTENSIONS},redis" +EXTENSIONS="${EXTENSIONS},pdo,pdo_mysql,pdo_sqlite" +EXTENSIONS="${EXTENSIONS},mysqlnd,sqlite3" +EXTENSIONS="${EXTENSIONS},mongodb" +# EXTENSIONS="${EXTENSIONS},swoole" +EXTENSIONS="${EXTENSIONS},swow" + +./bin/spc build "${EXTENSIONS}" --build-cli --cc=clang --cxx=clang++ --debug +# ./bin/spc build "${EXTENSIONS}" --build-cli --cc=gcc --cxx=g++ --debug diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index 879153f8..a4e54032 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -31,13 +31,13 @@ class BuilderProvider cc: $input->getOption('cc'), cxx: $input->getOption('cxx'), arch: $input->getOption('arch'), - zts: $input->getOption('enable-zts'), + zts: $input->hasOption('enable-zts') ? $input->getOption('enable-zts') : false, ), 'Linux' => new LinuxBuilder( cc: $input->getOption('cc'), cxx: $input->getOption('cxx'), arch: $input->getOption('arch'), - zts: $input->getOption('enable-zts'), + zts: $input->hasOption('enable-zts') ? $input->getOption('enable-zts') : false, ), default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'), }; diff --git a/src/SPC/builder/extension/mongodb.php b/src/SPC/builder/extension/mongodb.php index 843ee39b..a33b1b9e 100644 --- a/src/SPC/builder/extension/mongodb.php +++ b/src/SPC/builder/extension/mongodb.php @@ -12,6 +12,17 @@ class mongodb extends Extension { public function getUnixConfigureArg(): string { - return '--enable-mongodb --without-mongodb-sasl'; + $arg = ' --enable-mongodb '; + $arg .= ' --with-mongodb-system-libs=no '; + $arg .= ' --with-mongodb-sasl=no '; + if ($this->builder->getLib('openssl')) { + $arg .= '--with-mongodb-ssl=openssl'; + } + if ($this->builder->getLib('icu')) { + $arg .= ' --with-mongodb-icu=yes '; + } else { + $arg .= ' --with-mongodb-icu=no '; + } + return $arg; } } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index b8d8757d..8aee51ce 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -139,7 +139,7 @@ class LinuxBuilder extends BuilderBase ) ); } - if ($this->getExt('swoole')) { + if ($this->getExt('swoole') || $this->getExt('intl')) { $extra_libs .= ' -lstdc++'; } if ($this->getExt('imagick')) { diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php new file mode 100644 index 00000000..c6ef6c37 --- /dev/null +++ b/src/SPC/builder/linux/library/icu.php @@ -0,0 +1,34 @@ +cd($this->source_dir . '/source') + ->exec( + "{$this->builder->configure_env} {$cppflag} ./runConfigureICU Linux " . + '--enable-static ' . + '--disable-shared ' . + '--with-data-packaging=static ' . + '--enable-release=yes ' . + '--enable-extras=yes ' . + '--enable-icuio=yes ' . + '--enable-dyload=no ' . + '--enable-tools=yes ' . + '--enable-tests=no ' . + '--enable-samples=no ' . + "--prefix={$root}" + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index cb7f9f56..65b1a7f6 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -123,7 +123,7 @@ class MacOSBuilder extends BuilderBase */ public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void { - $extra_libs = $this->getFrameworks(true) . ' ' . ($this->getExt('swoole') ? '-lc++ ' : ''); + $extra_libs = $this->getFrameworks(true) . ' ' . ($this->getExt('swoole') || $this->getExt('intl') ? '-lc++ ' : ''); if (!$bloat) { $extra_libs .= implode(' ', $this->getAllStaticLibFiles()); } else { diff --git a/src/SPC/builder/macos/library/icu.php b/src/SPC/builder/macos/library/icu.php new file mode 100644 index 00000000..dd7967a1 --- /dev/null +++ b/src/SPC/builder/macos/library/icu.php @@ -0,0 +1,20 @@ +cd($this->source_dir . '/source') + ->exec("{$this->builder->configure_env} ./runConfigureICU MacOSX --enable-static --disable-shared --prefix={$root}") + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/globals/tests/intl.php b/src/globals/tests/intl.php new file mode 100644 index 00000000..32ccd568 --- /dev/null +++ b/src/globals/tests/intl.php @@ -0,0 +1,5 @@ +