Merge branch 'refactor' into libargon2-support

This commit is contained in:
Marcel Pociot 2023-06-02 22:47:47 +02:00
commit 47d068e6d3
23 changed files with 206 additions and 84 deletions

13
.github/FUNDING.yml vendored Normal file
View File

@ -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']

View File

@ -154,7 +154,7 @@ cd buildroot/bin/
### micro.sfx Usage ### 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). > provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro).
> It can put php runtime and your source code together. > 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. 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. - 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 ## Open-Source License
This project is based on the tradition of using the MIT License for old versions, 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, 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. 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. and comply with the corresponding project's LICENSE.
## Advanced ## Advanced

View File

@ -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 开源,自身的部分代码引用或修改自以下项目: 本项目依据旧版本惯例采用 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 - [swoole/swoole-cli](https://github.com/swoole/swoole-cli)Apache 2.0 LICENSE、SWOOLE-CLI LICENSE
因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。 因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。
请在编译完成后,使用命令 `dump-license`(TODO) 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。 请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。
## 进阶 ## 进阶

View File

@ -165,7 +165,14 @@
"mongodb": { "mongodb": {
"type": "external", "type": "external",
"source": "mongodb", "source": "mongodb",
"arg-type": "custom" "arg-type": "custom",
"lib-depends": [
"zstd"
],
"lib-suggests": [
"icu",
"openssl"
]
}, },
"mysqli": { "mysqli": {
"type": "builtin", "type": "builtin",
@ -428,4 +435,4 @@
"zstd" "zstd"
] ]
} }
} }

View File

@ -96,6 +96,15 @@
"gmp.h" "gmp.h"
] ]
}, },
"icu": {
"source": "icu",
"static-libs-unix": [
"libicui18n.a",
"libicuio.a",
"libicuuc.a",
"libicudata.a"
]
},
"imagemagick": { "imagemagick": {
"source": "imagemagick", "source": "imagemagick",
"static-libs-unix": [ "static-libs-unix": [
@ -200,6 +209,12 @@
"zlib" "zlib"
] ]
}, },
"libsodium": {
"source": "libsodium",
"static-libs-unix": [
"libsodium.a"
]
},
"libssh2": { "libssh2": {
"source": "libssh2", "source": "libssh2",
"static-libs-unix": [ "static-libs-unix": [
@ -455,12 +470,6 @@
"zstd_errors.h" "zstd_errors.h"
] ]
}, },
"libsodium": {
"source": "libsodium",
"static-libs-unix": [
"libsodium.a"
]
},
"libargon2": { "libargon2": {
"source": "libargon2", "source": "libargon2",
"static-libs-unix": [ "static-libs-unix": [

View File

@ -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." "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": { "imagemagick": {
"type": "ghtar", "type": "ghtar",
"repo": "ImageMagick/ImageMagick", "repo": "ImageMagick/ImageMagick",
@ -186,6 +194,14 @@
"path": "COPYING" "path": "COPYING"
} }
}, },
"libsodium": {
"type": "url",
"url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libssh2": { "libssh2": {
"type": "ghrel", "type": "ghrel",
"repo": "libssh2/libssh2", "repo": "libssh2/libssh2",
@ -412,14 +428,6 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"libsodium": {
"type": "url",
"url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libargon2": { "libargon2": {
"type": "ghtar", "type": "ghtar",
"repo": "P-H-C/phc-winner-argon2", "repo": "P-H-C/phc-winner-argon2",

View File

@ -29,6 +29,7 @@
| iconv | yes | yes | | | iconv | yes | yes | |
| imagick | yes | yes | | | imagick | yes | yes | |
| inotify | yes | yes | | | inotify | yes | yes | |
| intl | | | |
| mbstring | yes | yes | | | mbstring | yes | yes | |
| mbregex | yes | yes | | | mbregex | yes | yes | |
| mcrypt | | [no](https://github.com/crazywhalecc/static-php-cli/issues/32) | | | mcrypt | | [no](https://github.com/crazywhalecc/static-php-cli/issues/32) | |
@ -36,6 +37,7 @@
| mysqli | yes | yes | | | mysqli | yes | yes | |
| mysqlnd | yes | yes | | | mysqlnd | yes | yes | |
| openssl | yes | yes | | | openssl | yes | yes | |
| password-argon2 | | | |
| pcntl | yes | yes | | | pcntl | yes | yes | |
| pdo | yes | yes | | | pdo | yes | yes | |
| pdo_mysql | yes | yes | | | pdo_mysql | yes | yes | |
@ -57,6 +59,7 @@
| swow | yes | yes | | | swow | yes | yes | |
| swoole | [partial](https://github.com/crazywhalecc/static-php-cli/issues/51) | yes | | | swoole | [partial](https://github.com/crazywhalecc/static-php-cli/issues/51) | yes | |
| tokenizer | yes | yes | | | tokenizer | yes | yes | |
| xlswriter | | | |
| xml | yes | yes | | | xml | yes | yes | |
| xmlreader | yes, untested | yes, untested | | | xmlreader | yes, untested | yes, untested | |
| xmlwriter | 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"` - For static-php-cli self (with dev dependencies): `"posix,pcntl,phar,tokenizer,iconv,zlib,xml,dom,xmlwriter,xmlreader,fileinfo"`
- Minimum, with no extension: `""` - 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 ```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 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

View File

@ -8,13 +8,13 @@
```bash ```bash
# 启动 debian 11 容器环境 # 启动 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 ```bash
# 启动 alpine 容器环境 # 启动 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
``` ```

View File

@ -36,3 +36,5 @@ esac
apk update apk update
apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils 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

View File

@ -36,7 +36,6 @@ esac
apt update -y apt update -y
apt install -y git curl wget ca-certificates 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 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 musl-tools g++
apt install -y clang apt install -y clang

View File

@ -6,7 +6,7 @@ __DIR__=$(
pwd pwd
) )
__PROJECT__=$( __PROJECT__=$(
cd ${__DIR__}/../../../ cd ${__DIR__}/../../
pwd pwd
) )
cd ${__DIR__} cd ${__DIR__}

View File

@ -6,7 +6,7 @@ __DIR__=$(
pwd pwd
) )
__PROJECT__=$( __PROJECT__=$(
cd ${__DIR__}/../../../ cd ${__DIR__}/../../
pwd pwd
) )
cd ${__DIR__} cd ${__DIR__}

View File

@ -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

View File

@ -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

52
quickstart/prepare.sh Normal file
View File

@ -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

View File

@ -31,13 +31,13 @@ class BuilderProvider
cc: $input->getOption('cc'), cc: $input->getOption('cc'),
cxx: $input->getOption('cxx'), cxx: $input->getOption('cxx'),
arch: $input->getOption('arch'), arch: $input->getOption('arch'),
zts: $input->getOption('enable-zts'), zts: $input->hasOption('enable-zts') ? $input->getOption('enable-zts') : false,
), ),
'Linux' => new LinuxBuilder( 'Linux' => new LinuxBuilder(
cc: $input->getOption('cc'), cc: $input->getOption('cc'),
cxx: $input->getOption('cxx'), cxx: $input->getOption('cxx'),
arch: $input->getOption('arch'), 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'), default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
}; };

View File

@ -12,6 +12,17 @@ class mongodb extends Extension
{ {
public function getUnixConfigureArg(): string 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;
} }
} }

View File

@ -139,7 +139,7 @@ class LinuxBuilder extends BuilderBase
) )
); );
} }
if ($this->getExt('swoole')) { if ($this->getExt('swoole') || $this->getExt('intl')) {
$extra_libs .= ' -lstdc++'; $extra_libs .= ' -lstdc++';
} }
if ($this->getExt('imagick')) { if ($this->getExt('imagick')) {

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class icu extends LinuxLibraryBase
{
public const NAME = 'icu';
protected function build()
{
$root = BUILD_ROOT_PATH;
$cppflag = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"';
shell()->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');
}
}

View File

@ -123,7 +123,7 @@ class MacOSBuilder extends BuilderBase
*/ */
public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void 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) { if (!$bloat) {
$extra_libs .= implode(' ', $this->getAllStaticLibFiles()); $extra_libs .= implode(' ', $this->getAllStaticLibFiles());
} else { } else {

View File

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class icu extends MacOSLibraryBase
{
public const NAME = 'icu';
protected function build()
{
$root = BUILD_ROOT_PATH;
shell()->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');
}
}

View File

@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
assert(class_exists(NumberFormatter::class));