Compare commits

...

494 Commits

Author SHA1 Message Date
crazywhalecc
a00f8945ba add glfw support for macOS 2023-08-19 00:27:20 +08:00
crazywhalecc
2bc02bdaac add glfw support for macOS 2023-08-19 00:27:20 +08:00
Chuong
b97327d6d7 mongodb source.json change from tgz to zip
since ver https://github.com/mongodb/mongo-php-driver/releases/tag/1.16.2

they don't support tgz anymore.
2023-08-18 17:57:08 +08:00
crazywhalecc
61d1507a4d add redis-session support 2023-08-09 11:01:36 +08:00
crazywhalecc
a6f07051c3 update readme about version and dependencies 2023-08-08 20:35:25 +08:00
crazywhalecc
75417d15b7 change laravel/prompts version 2023-08-08 20:30:06 +08:00
crazywhalecc
4bab7ecfab add laravel/prompts support, and change deploy commands and exception handlers 2023-08-08 20:30:06 +08:00
crazywhalecc
7298e2441b remove list-ext command, use all-ext and alias to support its function 2023-08-08 19:24:11 +08:00
Jerry Ma
1ed104d2f6 Update README-en.md 2023-08-07 11:38:22 +08:00
Jerry Ma
cf6125b9cc Update README.md 2023-08-07 11:38:12 +08:00
crazywhalecc
f2cfe33cdd remove gotop (Why I needed it?) 2023-08-06 12:33:26 +08:00
crazywhalecc
a1e4125ded replace symfony console return values 2023-08-06 10:44:36 +08:00
Viktor Szépe
7a1433a994 Fix output of ExtractCommand 2023-08-06 10:32:15 +08:00
crazywhalecc
460238a6b0 add hardcoded ini injection on build process 2023-08-02 22:16:33 +08:00
crazywhalecc
2a197487d5 add php 8.3 support for phpmicro 2023-08-01 23:45:51 +08:00
crazywhalecc
51ce2befd8 add library, extension patches in separate classes 2023-08-01 23:42:02 +08:00
crazywhalecc
e909dd15b0 add library, extension patch methods base 2023-08-01 23:42:02 +08:00
crazywhalecc
aaf712be3c add comments 2023-08-01 23:42:02 +08:00
crazywhalecc
725e6b25dc Fix #111 2023-07-29 19:02:19 +08:00
crazywhalecc
ea322c0d3b add extract command, add -U option (custom download source 2023-07-28 00:29:19 +08:00
crazywhalecc
f7730735c0 prepare to release rc3 2023-07-27 23:23:57 +08:00
crazywhalecc
752b88f62d prepare to release rc3, add dev:php-ver command 2023-07-27 23:18:44 +08:00
crazywhalecc
6131e1881b enable compile optimization for other libraries 2023-07-27 22:22:47 +08:00
crazywhalecc
980da4ea0f fix mbregex without mbstring failed check (fix #96) 2023-07-27 18:47:09 +08:00
crazywhalecc
b698ae2f50 add strip option (fix #97) 2023-07-27 18:43:18 +08:00
crazywhalecc
50632f6527 fix libpng build bug for linux 2023-07-27 18:17:06 +08:00
crazywhalecc
6d4755d8c9 fix pgsql dependency 2023-07-27 18:16:51 +08:00
crazywhalecc
75b85c26dc add memcached for macOS 2023-07-26 00:13:27 +08:00
crazywhalecc
1c8bbfbbdf fix libevent bug 2023-07-26 00:13:27 +08:00
crazywhalecc
c5a70f101a fix macOS C++ space 2023-07-26 00:13:27 +08:00
crazywhalecc
956c87a657 add memcache support 2023-07-25 21:46:57 +08:00
crazywhalecc
778b0eadcd add default openssl.cnf path for macOS 2023-07-25 00:31:12 +08:00
crazywhalecc
b8e6f9d1be add hasCppExtension check 2023-07-24 23:49:52 +08:00
crazywhalecc
0e024a8c43 change default to docker (some c++ packages needed) 2023-07-23 23:16:18 +08:00
crazywhalecc
65b0bd01c8 add auto-detect icu support for postgresql 2023-07-23 22:56:04 +08:00
crazywhalecc
3745dfc931 fix #75 2023-07-23 22:54:32 +08:00
crazywhalecc
0186ae5ff2 remove build upload downloads.zip, separated workflow instead 2023-07-23 11:30:54 +08:00
crazywhalecc
f1eacac4fd change extension count 2023-07-22 17:34:33 +08:00
crazywhalecc
4abe0064e6 add dev commands 2023-07-22 17:33:38 +08:00
crazywhalecc
cbc3adbec0 fix pgsql env problem 2023-07-22 16:29:46 +08:00
Jerry Ma
0902f80b46 Merge pull request #84 from jingjingxyk/pgsql
添加pgsql 库
2023-07-22 16:19:43 +08:00
crazywhalecc
47101d058b reformat code 2023-07-22 16:12:12 +08:00
crazywhalecc
bc978ecbde add macOS support for pgsql 2023-07-22 15:07:53 +08:00
Jerry
a2cb5165d3 add english tips 2023-07-21 17:09:11 +08:00
Jerry
e582fa8b22 Merge remote-tracking branch 'origin/refactor' into refactor 2023-07-21 16:34:56 +08:00
Jerry
8ec8838634 bold 2023-07-21 16:34:40 +08:00
Jerry Ma
8f259ffed9 Update README-en.md, add branch rename notes 2023-07-21 14:46:45 +08:00
Jerry Ma
74c2cf824b Update README.md, add branch name change notes 2023-07-21 14:46:12 +08:00
Jerry Ma
9ea3b04e82 Update README-en.md 2023-07-21 09:48:28 +08:00
Jerry Ma
99cb8c77b7 Update README.md 2023-07-21 09:47:39 +08:00
Jerry Ma
7056280c57 Update README-en.md 2023-07-20 11:41:15 +08:00
Jerry Ma
c14421c9ca Update README.md 2023-07-20 11:40:57 +08:00
crazywhalecc
97eff64b5b add micro:combine command 2023-07-20 01:15:28 +08:00
crazywhalecc
e522258693 fix libpng mac source bug 2023-07-20 01:15:05 +08:00
crazywhalecc
b84c68fe11 add doctor linux support 2023-07-17 21:44:17 +08:00
crazywhalecc
8505feaa66 fix createDir not working 2023-07-17 21:41:26 +08:00
crazywhalecc
41f49c20ff add --from-zip command to download locally 2023-07-17 21:36:50 +08:00
crazywhalecc
1912ae36e6 separate system tools list 2023-07-17 21:11:06 +08:00
crazywhalecc
08efc81cf0 add --auto-fix option 2023-07-17 21:10:49 +08:00
crazywhalecc
a3b09c69cc correct alpine build commands 2023-07-17 21:05:39 +08:00
crazywhalecc
5cf105c3a5 fix distro 2023-07-17 20:59:59 +08:00
crazywhalecc
7408781d13 add linux-header installer for alpine 2023-07-17 20:58:48 +08:00
crazywhalecc
0afc8ea2c3 add linux tool check 2023-07-17 20:31:42 +08:00
crazywhalecc
67b073776c add linux tool check 2023-07-17 20:29:02 +08:00
crazywhalecc
8b48cf7f70 add linux tool check 2023-07-17 20:28:08 +08:00
crazywhalecc
63287dd9c4 add linux tool check 2023-07-17 20:26:48 +08:00
crazywhalecc
fc7ac921e2 add document contributing guide 2023-07-17 18:39:34 +08:00
crazywhalecc
57e3193a2a add document 2023-07-17 18:01:45 +08:00
crazywhalecc
388f547878 add document 2023-07-17 17:59:44 +08:00
crazywhalecc
f2e483540b add opcache support 2023-07-16 18:13:11 +08:00
crazywhalecc
7d31c371e0 change gmp to github mirror 2023-07-16 17:59:21 +08:00
crazywhalecc
bc750733d5 mark php version 2023-07-16 17:55:20 +08:00
crazywhalecc
a66e22d9ed fix cron 2023-07-16 17:54:30 +08:00
crazywhalecc
cc5974d07d add download cache builder 2023-07-16 17:53:37 +08:00
jingjingxyk
085437e925 pgsql 禁用 依赖libzstd icu库 2023-07-01 18:04:42 +08:00
jingjingxyk
fa17a48483 pgsql 禁用 依赖libzstd icu库 2023-07-01 17:31:46 +08:00
jingjingxyk
78c1484570 解决debian 环境下 pgsql 构建共享库报错 2023-07-01 13:01:53 +08:00
jingjingxyk
9c2ea79bec update pgsql config 2023-06-30 21:00:49 +08:00
jingjingxyk
b7ffe3fd1f 添加pgsql 配置 2023-06-30 20:53:18 +08:00
jingjingxyk
dac14ae16e 添加pgsql 库 2023-06-30 20:36:51 +08:00
Jerry Ma
4872ff58bb Merge pull request #81 from jingjingxyk/feature_delete_quick_start
移除 quick start
2023-06-30 17:13:30 +08:00
Jerry Ma
755246cb6a Merge pull request #82 from jingjingxyk/feature_fix_pecl_url
解决pecl http下载地址被劫持的问题
2023-06-30 15:08:19 +08:00
jingjingxyk
9806422279 解决pecl http下载地址被劫持的问题 2023-06-30 15:00:25 +08:00
jingjingxyk
d5aea9f7d6 移除 quick start 2023-06-30 14:57:10 +08:00
crazywhalecc
b852471596 add manual doctors 2023-06-28 18:38:14 +08:00
crazywhalecc
fdf36ad726 fix mongodb library dependency 2023-06-27 00:59:10 +08:00
crazywhalecc
c49e6ba0a2 fix libwebp version (imagemagick with webp-1.3.1-rc1 crashed) 2023-06-15 22:22:07 +08:00
Jerry Ma
74a34362c3 Update README-en.md 2023-06-02 23:42:23 +08:00
Jerry Ma
0e33380df5 Update README-en.md 2023-06-02 23:40:49 +08:00
Jerry Ma
3db9c70e1b Update README.md 2023-06-02 23:39:01 +08:00
crazywhalecc
b2f3ffcc00 fix xml and intl depend order 2023-06-02 23:00:48 +08:00
crazywhalecc
aa9ec6e50e add xlswriter support 2023-06-02 21:40:17 +08:00
crazywhalecc
dcb3d91610 update ext-support.md 2023-06-02 21:39:32 +08:00
crazywhalecc
9e71a98eda fix enable-zts option error on build:libs command 2023-06-02 21:19:17 +08:00
Jerry Ma
f2ef783b13 Merge pull request #67 from mpociot/intl-support
Add intl/ICU support
2023-06-02 21:12:53 +08:00
crazywhalecc
874e104570 sort config and change icu libs order 2023-06-02 20:27:25 +08:00
crazywhalecc
1398086c38 add icu configure options for linux 2023-06-02 20:26:19 +08:00
Marcel Pociot
db1586e2ec Remove empty headers array 2023-06-02 11:52:27 +02:00
Marcel Pociot
1158931d91 Add intl/ICU support 2023-06-02 11:47:11 +02:00
Jerry Ma
ee1b03b060 Update README-en.md 2023-06-02 09:59:47 +08:00
Jerry Ma
b99378ea38 Update README-en.md 2023-06-02 09:55:33 +08:00
Jerry Ma
c9692d502c Update README.md 2023-06-02 09:55:13 +08:00
Jerry Ma
3f6e659c6a Update ext-support.md 2023-06-02 09:52:34 +08:00
Jerry Ma
37556c9e02 Update FUNDING.yml 2023-05-29 23:53:50 +08:00
Jerry Ma
34cd9d7cc1 Update README-en.md 2023-05-29 23:53:26 +08:00
Jerry Ma
030ac531a6 Update README.md 2023-05-29 23:49:55 +08:00
Jerry Ma
e19bd39fea Update FUNDING.yml 2023-05-29 22:16:46 +08:00
Jerry Ma
0fe432dd8e Update FUNDING.yml 2023-05-29 22:16:06 +08:00
Jerry Ma
c5b24ab136 Update FUNDING.yml 2023-05-29 22:12:34 +08:00
Jerry Ma
fb06cc1e1a Create FUNDING.yml 2023-05-29 21:57:58 +08:00
Jerry Ma
71e4ea166c Update ext.json 2023-05-26 12:25:53 +08:00
Jerry Ma
fdf8834163 Merge pull request #56 from jingjingxyk/feature_ext_mongodb
mongodb 添加参数
2023-05-25 19:20:34 +08:00
jingjingxyk
1fd70c9a99 验证 swow 2023-05-24 14:40:09 +08:00
jingjingxyk
7c3826f4a4 编译验证 2023-05-24 13:50:23 +08:00
jingjingxyk
7fb3d05b2c 调整quickstart 脚本 2023-05-24 13:30:22 +08:00
jingjingxyk
f831b4d61d 验证 2023-05-24 13:20:56 +08:00
jingjingxyk
56b5c1b138 Merge branch 'refactor' into feature_ext_mongodb 2023-05-24 12:31:12 +08:00
jingjingxyk
1cca826e8a update mongodb extension config 2023-05-24 12:29:57 +08:00
jingjingxyk
41aa129b97 update 2023-05-24 03:48:40 +08:00
crazywhalecc
09ba11affb update README and version 2023-05-17 23:07:39 +08:00
crazywhalecc
c9b47c392e update to rc1 version 2023-05-17 22:42:37 +08:00
crazywhalecc
4a9b171bb4 update to rc1 version 2023-05-17 22:41:04 +08:00
crazywhalecc
1b6d0e35ea add zts support 2023-05-17 22:19:28 +08:00
crazywhalecc
6d638f3721 add ssh2 support for linux 2023-05-17 22:10:28 +08:00
crazywhalecc
125556b73b add imagick for linux 2023-05-17 22:08:13 +08:00
crazywhalecc
db3728bc00 add sodium support in readme 2023-05-17 22:00:59 +08:00
crazywhalecc
f002c8021c fix curl 8.1.0 compile problem 2023-05-17 22:00:41 +08:00
Jerry Ma
e47bd8ae3c Merge pull request #59 from javalaw/refactor
添加sodium扩展支持
2023-05-17 16:32:18 +08:00
javalaw
0b3aefaefe Merge branch 'crazywhalecc:refactor' into refactor 2023-05-17 15:40:13 +08:00
javalaw
f281d5eeb7 fix libsodium. 2023-05-17 07:36:23 +00:00
Jerry Ma
89ad11ebb6 Create opcache.php 2023-05-17 15:24:45 +08:00
Jerry Ma
2e50ee37a9 Update UnixBuilderTrait.php 2023-05-17 15:24:08 +08:00
javalaw
a4204347c1 Merge branch 'crazywhalecc:refactor' into refactor 2023-05-17 13:54:33 +08:00
Jerry Ma
afe81c4306 Update imagemagick.php 2023-05-17 13:40:37 +08:00
javalaw
f0e431dd63 sodium ext support. 2023-05-12 09:47:43 +00:00
crazywhalecc
09f1574264 add macos external extension support 2023-05-10 21:59:33 +08:00
crazywhalecc
b7f64e46c2 add ssh2 support 2023-05-10 02:32:27 +08:00
crazywhalecc
a329445701 add ssh2 support 2023-05-10 02:31:57 +08:00
crazywhalecc
7527f9f099 add imagemagick (imagick) for macos, pkg-config for unix.= 2023-05-10 02:04:08 +08:00
crazywhalecc
9daa10e939 sort config, add imagemagick 2023-05-10 00:46:57 +08:00
crazywhalecc
a59e338438 add upload download artifacts 2023-05-08 21:30:45 +08:00
jingjingxyk
2767ac524f mongodb 添加参数 2023-05-08 11:44:44 +08:00
Jerry Ma
a714482cfb Update SourcePatcher.php 2023-05-04 12:10:36 +08:00
Jerry Ma
0138ab3934 Update build-macos-x86_64.yml 2023-05-04 12:06:27 +08:00
Jerry Ma
a294671cf1 Update build-linux-arm.yml 2023-05-04 12:06:04 +08:00
Jerry Ma
a8825c1f22 Update build-linux-x86_64.yml 2023-05-04 12:05:33 +08:00
Jerry Ma
9abf696725 Update MacOSBuilder.php 2023-05-04 11:29:55 +08:00
Jerry Ma
a1f34a7df9 Update LinuxBuilder.php 2023-05-04 11:29:14 +08:00
Jerry Ma
c83e8eb787 Update ext-support.md 2023-05-02 16:13:01 +08:00
Jerry Ma
4ec9f9b6cd Update README-en.md 2023-05-02 16:08:53 +08:00
Jerry Ma
0a1f200c69 Update README-en.md 2023-05-02 16:05:29 +08:00
Jerry Ma
67e9cba399 Update README-en.md 2023-05-02 16:05:04 +08:00
Jerry Ma
8065b30ba0 Update README.md 2023-05-02 16:04:24 +08:00
Jerry Ma
6af1ba6284 Update README.md 2023-05-02 15:54:52 +08:00
Jerry Ma
a0d817803e Update README-en.md 2023-05-02 15:54:15 +08:00
crazywhalecc
669c7b188b add apcu support 2023-05-02 15:12:58 +08:00
crazywhalecc
1c2343f740 update readme 2023-05-01 12:57:31 +08:00
crazywhalecc
280284e4c2 fix phar patch 2023-05-01 12:50:01 +08:00
crazywhalecc
85ac553ded remove armv7 build, because some dependencies are not supported 2023-04-30 23:23:07 +08:00
crazywhalecc
5bda711500 update ext-support 2023-04-30 22:54:54 +08:00
crazywhalecc
399835e7d1 fix php8.0 openssl 3.x patch strategy 2023-04-30 22:40:48 +08:00
crazywhalecc
75bb66776c change swoole to official build 2023-04-30 21:35:25 +08:00
crazywhalecc
7f952804d0 remove host to fix segment fault 2023-04-30 19:43:10 +08:00
crazywhalecc
289645caa0 update readme 2023-04-30 17:23:05 +08:00
crazywhalecc
b280c0abd8 update readme 2023-04-30 15:49:55 +08:00
crazywhalecc
2d597ed690 add readline support 2023-04-30 15:43:08 +08:00
crazywhalecc
b3296842b7 add readline support 2023-04-30 15:04:50 +08:00
crazywhalecc
d73cefc280 update readme and version 2023-04-30 14:29:56 +08:00
crazywhalecc
6f4aebfc4c update ext-support.md 2023-04-30 14:23:20 +08:00
crazywhalecc
cac3ffc7d7 add event support 2023-04-30 14:22:59 +08:00
crazywhalecc
893fa5bfd6 update README 2023-04-30 12:55:49 +08:00
crazywhalecc
40102a661d update docker interactive 2023-04-30 12:52:24 +08:00
crazywhalecc
d7305c434e update workflow 2023-04-30 12:47:00 +08:00
crazywhalecc
0bed76da11 refactor download 2023-04-30 12:42:19 +08:00
crazywhalecc
117cd93e8f update gitignore 2023-04-30 11:45:34 +08:00
crazywhalecc
0bd62b0d5f fix phpstan 2023-04-29 19:02:41 +08:00
crazywhalecc
8df4ade754 refactor to pkg-config and add some add-on libs for gd 2023-04-29 18:59:47 +08:00
Jerry Ma
ea055afd3c Merge pull request #49 from jingjingxyk/fix_bug
修复 quckstart 脚本 bug
2023-04-25 21:56:20 +08:00
jingjingxyk
9e92b1844a 修复bug 2023-04-25 21:11:35 +08:00
Jerry Ma
297b3a61a0 Merge pull request #46 from jingjingxyk/feature_php_runtime
添加 下载PHP 运行时使用中国镜像 和 linux 使用中国镜像源
2023-04-25 18:31:13 +08:00
jingjingxyk
4b7b2291aa 添加 下载PHP 运行时使用中国镜像;linux 中国镜像源 2023-04-25 15:17:16 +08:00
crazywhalecc
65d66c6073 update ext-support 2023-04-23 21:29:41 +08:00
crazywhalecc
7df46be6eb update ext-support 2023-04-23 21:28:17 +08:00
crazywhalecc
5ce9229e7d update ext-support (date extension is bundled with minimal php) 2023-04-23 21:17:25 +08:00
crazywhalecc
e6c9112575 add option --no-motd 2023-04-23 20:54:51 +08:00
crazywhalecc
f0a987ba3a update README 2023-04-23 20:32:56 +08:00
crazywhalecc
42b2d36319 add fpm 2023-04-23 20:31:58 +08:00
crazywhalecc
5d5ffe8866 fix zlib source 2023-04-23 20:29:59 +08:00
crazywhalecc
8cd45e3f3f update README 2023-04-23 20:29:50 +08:00
crazywhalecc
baf513bd56 change build CI to new builder 2023-04-23 20:29:30 +08:00
Jerry Ma
5333da35cb Update README.md 2023-04-23 13:30:56 +08:00
Jerry Ma
fe85f138df Update README-en.md 2023-04-22 23:59:36 +08:00
crazywhalecc
684149eb50 update setup time 2023-04-22 23:00:30 +08:00
crazywhalecc
8018f2c570 update README, add badge 2023-04-22 22:52:02 +08:00
crazywhalecc
2fdbe6ba8c update README 2023-04-22 22:41:00 +08:00
crazywhalecc
018c76ba41 update README 2023-04-22 22:25:01 +08:00
crazywhalecc
48f40b4304 update README 2023-04-22 22:18:44 +08:00
crazywhalecc
528ad1199a add doctor command 2023-04-22 21:23:12 +08:00
crazywhalecc
4c0d35c723 refactor command as more easily 2023-04-22 17:45:43 +08:00
Jerry Ma
1540af266b Merge pull request #38 from jingjingxyk/dev
添加快速进入编译环境的脚本
2023-04-22 17:24:03 +08:00
crazywhalecc
8fb8b34239 enhancement for prepare-php-runtime: integrate in one file 2023-04-22 17:18:21 +08:00
crazywhalecc
4b7c2fe84f set php 7.4 patch alternative 2023-04-22 16:00:34 +08:00
crazywhalecc
61a76dc0c9 set php 7.4 patch alternative 2023-04-22 15:58:24 +08:00
jingjingxyk
e4de37708b 修改快速运行构建环境脚本 2023-04-22 11:20:36 +08:00
jingjingxyk
ea40d25125 修改快速运行构建环境脚本 2023-04-22 11:12:16 +08:00
jingjingxyk
eacb24a482 修改 linux X86_64 README.md 2023-04-22 02:14:23 +08:00
jingjingxyk
65a32a977f 添加快速进入编译环境脚本 2023-04-22 02:05:26 +08:00
jingjingxyk
40d09bc82e 添加快速构建脚本 2023-04-22 01:32:17 +08:00
crazywhalecc
fa437644f5 update README 2023-04-21 19:10:23 +08:00
crazywhalecc
762f6043c5 update README 2023-04-15 21:44:34 +08:00
crazywhalecc
ab1109df90 update README 2023-04-15 21:29:05 +08:00
crazywhalecc
c40da1a71a update CI 2023-04-15 19:14:15 +08:00
crazywhalecc
05490c1785 update CI 2023-04-15 19:07:08 +08:00
crazywhalecc
103f76e190 update README 2023-04-15 19:05:59 +08:00
crazywhalecc
01bf2ae63b update README 2023-04-15 18:58:29 +08:00
crazywhalecc
03b987c78e update ext-support.md 2023-04-15 18:56:05 +08:00
crazywhalecc
960addc8f2 add license dumper 2023-04-15 18:46:46 +08:00
crazywhalecc
5b09e95e51 fix argument multiple space 2023-04-15 18:46:21 +08:00
crazywhalecc
2bbb66f844 change file system removeDir function 2023-04-15 18:46:02 +08:00
crazywhalecc
4777f86f7e change macos Builder f_passthru 2023-04-15 18:45:34 +08:00
crazywhalecc
f95b3bcd4b change extension to custom 2023-04-15 18:45:11 +08:00
Jerry
6de0d81ea3 Update README-en.md 2023-04-14 13:38:58 +08:00
Jerry
31fee5645d Update README.md 2023-04-14 13:35:44 +08:00
Jerry
651bb747f1 add CI php build verson display 2023-04-14 13:29:43 +08:00
Jerry
52d787c903 Update build.yml 2023-04-12 15:40:49 +08:00
crazywhalecc
0b4253090d remove hash 2023-04-09 14:17:25 +08:00
crazywhalecc
50a1fcfc20 update README 2023-04-09 13:58:09 +08:00
crazywhalecc
e2aa21fbea update README 2023-04-09 13:38:41 +08:00
crazywhalecc
62aeb6dc7b fix gd check 2023-04-09 13:24:52 +08:00
crazywhalecc
a7d500422d add postgresql and custom downloader 2023-04-09 12:12:32 +08:00
crazywhalecc
76e95b8c55 add postgresql and custom downloader 2023-04-09 12:11:14 +08:00
crazywhalecc
9970986a52 fix libpng not executable 2023-04-09 12:10:09 +08:00
crazywhalecc
abfc60511d update README 2023-04-09 10:56:14 +08:00
crazywhalecc
663d0c05c7 update README 2023-04-09 10:41:50 +08:00
crazywhalecc
76c39ef08a update README 2023-04-08 22:35:10 +08:00
crazywhalecc
bcd45e87c8 fix ci 2023-04-08 22:22:52 +08:00
crazywhalecc
5c54434300 fix ci 2023-04-08 22:16:56 +08:00
crazywhalecc
feb20fad83 fix ci 2023-04-08 22:15:48 +08:00
crazywhalecc
bb52b87d2f fix ci 2023-04-08 22:08:20 +08:00
crazywhalecc
40b6980cdc update action and version 2023-04-08 22:05:10 +08:00
crazywhalecc
bbeb399004 fix action 2023-04-08 21:39:51 +08:00
crazywhalecc
bdf99ba9f1 update freetype link 2023-04-08 21:36:39 +08:00
crazywhalecc
9161aff942 update readme 2023-04-08 21:23:30 +08:00
crazywhalecc
298a758166 add linux github ci 2023-04-08 21:20:22 +08:00
crazywhalecc
000ebef28b add inotify 2023-04-08 18:55:23 +08:00
crazywhalecc
54efec60b8 change php download url back to official 2023-04-08 18:46:12 +08:00
crazywhalecc
7f5f15a41d update ext-support.md 2023-04-08 18:45:49 +08:00
crazywhalecc
2766450696 fix openssl with zlib no symbol bug 2023-04-08 18:45:37 +08:00
crazywhalecc
24c6a3a637 adjust curl support, fix curl bug 2023-04-08 18:45:16 +08:00
crazywhalecc
d3b8baa5e7 support swow 2023-04-08 18:44:46 +08:00
crazywhalecc
fd57d40ca9 add extension dependency sort (including suggestion) 2023-04-08 18:42:46 +08:00
crazywhalecc
feae9b59f5 remove libffi support default 2023-04-08 18:36:10 +08:00
crazywhalecc
24ce235ed4 add swow macos support 2023-04-08 12:42:58 +08:00
crazywhalecc
31a02082de sort them 2023-04-08 11:58:24 +08:00
crazywhalecc
f4ebca927b add dist name getter for extension 2023-04-08 11:49:06 +08:00
crazywhalecc
84daa9b151 remove enchant temporarily 2023-04-08 11:48:30 +08:00
Simon Hamp
213a6680dc Add GitHub Action (#35)
* Create build.yml

* Update build.yml

* Update build.yml

* Update FetchSourceCommand.php

Attempt to fix exception reporting error when cURL fails

* Update Downloader.php

Attempt to solve GitHub API requests bailing in the Action runner

* Update Downloader.php

Revert

* Update build.yml

Add env variable

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

Revert. It didn't help :(
2023-04-08 10:35:31 +08:00
crazywhalecc
978b59c0dc fix suggested libs dependency order 2023-04-07 22:11:41 +08:00
crazywhalecc
4063b8454b adjust readme 2023-04-03 21:30:32 +08:00
crazywhalecc
29e0269588 add some tests and iconv support 2023-04-03 21:27:50 +08:00
crazywhalecc
1731cc1202 add bz2 test 2023-04-03 20:51:02 +08:00
crazywhalecc
09e5c16570 refactor macos builder 2023-04-03 20:47:24 +08:00
crazywhalecc
3709bcc5e4 update readme 2023-03-31 00:16:40 +08:00
crazywhalecc
b9b686b9cf Merge remote-tracking branch 'origin/refactor' into refactor 2023-03-29 21:39:47 +08:00
crazywhalecc
b0ac50941f add wrong usage exception 2023-03-29 21:39:36 +08:00
jingjingxyk
b8a58b270c 更正 env 所在目录 2023-03-28 23:51:57 +08:00
jingjingxyk
a20cc5bd26 修复 spc 入口 shell 2023-03-28 23:51:57 +08:00
crazywhalecc
d31e1b00e8 update README.md 2023-03-27 00:13:52 +08:00
crazywhalecc
1f11e25593 remove gzip and change deploy file default name 2023-03-27 00:11:00 +08:00
crazywhalecc
6af40cd92d fix micro build and change deploy command args 2023-03-26 23:59:34 +08:00
crazywhalecc
84b1732683 refactor and add more linux extensions and libraries 2023-03-26 22:27:51 +08:00
crazywhalecc
17e0265ed0 fix realpath getter 2023-03-21 01:52:40 +08:00
crazywhalecc
da03db051d add libiconv source 2023-03-21 01:52:22 +08:00
crazywhalecc
357b25905b fix bzip2, fix curl, add iconv, add libxml2, add and fix openssl 2023-03-21 01:51:52 +08:00
crazywhalecc
e62cefa9e5 add exception handler for command build:libs 2023-03-21 00:28:05 +08:00
crazywhalecc
fd835deb8d add brotli,bzip2,curl,zlib for linux 2023-03-21 00:27:33 +08:00
crazywhalecc
063b55ae0d add brotli,bzip2,curl,zlib for linux 2023-03-21 00:25:46 +08:00
crazywhalecc
79efecb5a9 change error message 2023-03-21 00:21:17 +08:00
crazywhalecc
4fb6d8cafd update README 2023-03-19 14:13:24 +08:00
crazywhalecc
3a5ccb7f8d update composer.json 2023-03-19 14:09:28 +08:00
crazywhalecc
e7c1345dcb update README 2023-03-19 14:05:30 +08:00
crazywhalecc
e4b37b9f9a add libuv dependency for swow, but still not working 2023-03-19 14:04:42 +08:00
crazywhalecc
f06736315d fix download cache problem 2023-03-19 14:03:55 +08:00
crazywhalecc
3c438914c2 update ext-support.md doc 2023-03-19 01:20:16 +08:00
crazywhalecc
d8a1a3c838 adjust swow patch time 2023-03-19 01:17:16 +08:00
crazywhalecc
6b0baa8365 add more extensions support 2023-03-19 01:16:54 +08:00
crazywhalecc
c93a4e843f fix mbstring support 2023-03-19 00:15:13 +08:00
crazywhalecc
3daafa0b0e add freetype support for gd 2023-03-18 21:40:07 +08:00
crazywhalecc
9ce92e39d5 add micro php version limit 2023-03-18 20:08:54 +08:00
crazywhalecc
4edd05f4df update mcrypt bugs 2023-03-18 19:58:36 +08:00
crazywhalecc
3af2811951 remove some copyright 2023-03-18 19:09:59 +08:00
crazywhalecc
cfa89e3003 add gmp extension for macOS 2023-03-18 18:46:10 +08:00
crazywhalecc
b87a633496 update downloader, make download thing cacheable 2023-03-18 18:26:18 +08:00
crazywhalecc
880242ed93 update composer and readme 2023-03-18 17:44:23 +08:00
crazywhalecc
3d33c75a05 format spc 2023-03-18 17:39:08 +08:00
crazywhalecc
65d38d5efc add builder provider 2023-03-18 17:34:37 +08:00
crazywhalecc
db75b18da4 update README 2023-03-18 17:34:25 +08:00
crazywhalecc
7b8b829c21 revert copyright 2023-03-18 17:34:08 +08:00
crazywhalecc
4eee09c390 initial commit for macOS support 2023-03-18 17:32:21 +08:00
crazywhalecc
64054f16c5 remove old version files 2023-03-18 14:24:08 +08:00
crazywhalecc
ae66327e98 update gitignore file 2023-03-18 14:22:52 +08:00
crazywhalecc
d00e3d3129 remove redundant file 2023-03-18 14:22:41 +08:00
crazywhalecc
df609e28ca update LICENSE 2023-03-18 14:22:31 +08:00
crazywhalecc
21c582d309 update README 2023-03-18 14:19:45 +08:00
crazywhalecc
3488bce63d add curl hook 2023-03-15 20:54:33 +08:00
crazywhalecc
5d347adbcf initial framework commit 2023-03-15 20:40:49 +08:00
Jerry
36ce06c3ca Update README.md 2023-03-04 23:49:49 +08:00
Jerry
3071297bd5 Merge pull request #28 from jingjingxyk/feature_libmcrypt
添加aria2快速下载依赖库和扩展;添加依赖库GMP;添加依赖库libmcrypt;
2023-03-04 21:56:43 +08:00
Jerry
0707bcab68 Update README-en.md 2023-03-04 21:54:07 +08:00
Jerry
fe7196f2aa Update README.md 2023-03-04 21:47:05 +08:00
jingjingxyk
220252da74 修改描述 2023-03-03 19:43:05 +08:00
jingjingxyk
65ebe4dfa6 Merge branch 'master' into feature_libmcrypt 2023-03-03 19:22:24 +08:00
jingjingxyk
580565de23 添加爱快速aria2快速下载依赖库和扩展;添加依赖库GMP;添加依赖库libmcrypt; 2023-03-03 19:19:54 +08:00
Jerry
9e8af298d4 Update README.md 2023-02-28 21:51:02 +08:00
Jerry
1ca64d6626 Update README.md 2023-01-16 13:28:35 +08:00
Jerry
1b38f23268 Update README.md 2023-01-16 13:20:38 +08:00
Jerry
1b2ed00cbb Update build-php.yml 2023-01-10 11:29:53 +08:00
Jerry
14a3c28044 revert docker alpine version to 3.16, fix #20 2023-01-10 11:28:16 +08:00
Jerry
5767d9a275 Update build-php.yml 2022-12-28 17:06:43 +08:00
Jerry
da802d5e70 Update build-php.yml 2022-12-28 17:05:52 +08:00
Jerry
50b6f5244d Update extensions.txt 2022-11-09 14:12:53 +08:00
Jerry Ma
7f860e46f3 Merge pull request #13 from ikilobyte/master
add --with-config-file-path=/etc
2022-10-24 11:10:26 +08:00
Jerry Ma
5a354d58fa Update README.md 2022-10-20 16:03:37 +08:00
Sunny
f186c4572b add --with-config-file-path=/etc 2022-10-12 11:14:11 +08:00
Jerry Ma
fb592bf103 Update README.md 2022-10-05 08:47:05 +08:00
Jerry Ma
195c922f4e Update build-php.yml 2022-09-20 15:01:24 +08:00
Jerry Ma
464eca3588 change multiarch version tag 2022-08-16 12:42:22 +08:00
Jerry Ma
0fbef677ca Update compile-php.sh 2022-08-16 10:17:34 +08:00
Jerry Ma
99bdb1fec1 Update build-php.yml 2022-08-15 20:37:54 +08:00
Jerry Ma
f6d777a668 Update build-php.yml 2022-08-08 17:15:05 +08:00
Jerry Ma
1515e9d9d5 Update build-php.yml 2022-08-06 09:23:55 +08:00
Jerry Ma
d164b567bf Update README-en.md 2022-07-15 14:37:36 +08:00
Jerry Ma
38baa371ca Update README.md 2022-07-15 14:36:25 +08:00
Jerry Ma
6c62d032fe Update build-php.yml 2022-07-15 09:57:17 +08:00
Jerry Ma
10541ddcc7 Update build-php.yml 2022-07-14 23:59:54 +08:00
Jerry Ma
f73a02b9a9 Update config.json 2022-07-11 10:05:35 +08:00
Jerry Ma
d755803e90 Update dependencies version 2022-07-09 18:06:56 +08:00
Jerry Ma
23d8a014ce Update PHP build versions 2022-07-08 23:55:12 +08:00
crazywhalecc
09c5cdae11 add libiconv compiler 2022-07-07 05:33:58 +00:00
crazywhalecc
1b88682fcb add libiconv compiler 2022-07-07 05:24:37 +00:00
Jerry Ma
9cc703d424 Update compile-php.sh 2022-06-27 14:06:01 +08:00
Jerry Ma
8fd3cab450 Update README-en.md 2022-06-27 11:14:43 +08:00
Jerry Ma
b2a4fb115c Update README-en.md 2022-06-27 11:13:56 +08:00
Jerry Ma
ace647d6c4 Update README-en.md 2022-06-27 11:11:40 +08:00
Jerry Ma
5048fb5b48 Update README-en.md 2022-06-27 11:09:32 +08:00
crazywhalecc
4c55f4a22b Update to 1.5.2 (Add protobuf support) 2022-06-21 13:49:38 +08:00
crazywhalecc
96bc62b2a9 Update to 1.5.1 version (add readline extension) 2022-06-20 21:17:51 +08:00
crazywhalecc
c5fc6fa9dc Change curl to wget 2022-06-20 20:56:59 +08:00
crazywhalecc
ed2b320271 Add readline support 2022-06-20 20:52:35 +08:00
Jerry Ma
1dd4ad9cc1 Update compile-deps.sh, support caching [skip ci] 2022-06-20 18:55:37 +08:00
Jerry Ma
265fac3ca1 Update download-git.sh, support caching [skip ci] 2022-06-20 18:54:11 +08:00
Jerry Ma
09437d3e91 Update check-extensions.sh [skip ci] 2022-06-20 18:53:19 +08:00
crazywhalecc
1f2be3b484 Update github action CI 2022-06-11 02:27:07 +08:00
crazywhalecc
87ce77cf25 Fix check-extensions.sh syntax 2022-06-11 02:10:27 +08:00
crazywhalecc
dc5bac99b0 Update README 2022-06-11 02:09:18 +08:00
crazywhalecc
6fab3e789d Update github action CI 2022-06-11 01:39:03 +08:00
crazywhalecc
b02fa68683 Update github action CI 2022-06-11 01:37:04 +08:00
crazywhalecc
a07ba59b0f update github action CI 2022-06-11 01:22:34 +08:00
crazywhalecc
8f978dd187 update github action CI 2022-06-11 01:21:36 +08:00
crazywhalecc
a72ed9ca16 Update to 1.6.0 version (dialog selection and multiarch micro) 2022-06-11 01:09:45 +08:00
root
4b750825e9 update to 1.5.1 (add event support) 2022-06-10 18:23:07 +08:00
Jerry Ma
7f04a27f41 Update PHP version
7.4.30, 8.0.20, 8.1.7
2022-06-10 16:34:39 +08:00
Jerry Ma
6b3f973a61 Update compile-micro.sh 2022-06-10 15:42:44 +08:00
Jerry Ma
e3ccf916bf Update README.md 2022-06-04 14:43:39 +08:00
Jerry Ma
de1302c6af Update README.md 2022-05-20 06:39:55 +08:00
Jerry Ma
8055816683 Update README-en.md 2022-05-16 17:05:04 +08:00
Jerry Ma
7e2b390963 Update README.md 2022-05-16 17:04:39 +08:00
crazywhalecc
fbf4016965 update README.md 2022-05-16 17:02:57 +08:00
crazywhalecc
2b802c710f fix micro error bug 2022-05-16 16:19:01 +08:00
crazywhalecc
f7162cbc79 fix micro error bug 2022-05-16 15:51:11 +08:00
crazywhalecc
347419ee53 fix yml syntax 2022-05-16 14:56:59 +08:00
crazywhalecc
e4c8815ba7 debug compile-micro mode 2022-05-16 14:56:02 +08:00
crazywhalecc
09095f48a7 debug compile-micro mode 2022-05-16 14:55:24 +08:00
crazywhalecc
e573f446a5 fix typo 2022-05-16 14:16:20 +08:00
crazywhalecc
b936730e51 fix micro bug for docker 2022-05-16 14:11:00 +08:00
crazywhalecc
6e1c7a09cc Fix mirror site not working 2022-05-16 14:05:47 +08:00
crazywhalecc
74060cbf27 add micro php build 2022-05-16 14:01:00 +08:00
Jerry Ma
4cba2cb8c1 Update README-en.md 2022-05-15 01:41:58 +08:00
Jerry Ma
67ae206b0e Update build-php action trigger events 2022-05-15 01:36:22 +08:00
Jerry Ma
dfc6694dce Fix backup address not working 2022-05-15 01:15:16 +08:00
Jerry Ma
82170b8d50 Update example images [skip ci] 2022-05-15 01:10:07 +08:00
Jerry Ma
523aa0a6d3 Update example image [skip ci] 2022-05-15 01:09:11 +08:00
Jerry Ma
de2a38b5a2 Update README.md 2022-05-15 00:57:14 +08:00
Jerry Ma
212f1de3ae Update versions of dependencies 2022-05-13 19:50:58 +08:00
Jerry Ma
6f7f2f75b0 Update build php versions [skip ci] 2022-05-13 19:47:10 +08:00
Jerry Ma
7a5612ec2b Update README-en.md [skip ci] 2022-05-09 19:30:40 +08:00
Jerry Ma
f8a16ce6c0 Update README.md [skip ci] 2022-05-09 19:28:59 +08:00
Jerry Ma
a14d494bba Update config.json 2022-05-09 19:13:37 +08:00
crazywhalecc
e240183fa0 Add zip extension support 2022-05-09 19:10:59 +08:00
Jerry Ma
d4b6dbfba3 Update README.md [skip ci] 2022-05-09 11:03:31 +08:00
Jerry Ma
0986665d53 Update build PHP version
7.4.29, 8.0.18, 8.1.5
2022-04-18 04:33:04 +08:00
Jerry Ma
e6f4c5e41f Update README-en.md 2022-04-17 22:19:22 +08:00
Jerry Ma
0e9c8ebf61 Update README.md [skip ci] 2022-04-17 22:07:56 +08:00
Jerry Ma
cab1f16734 Create install-runtime.sh [skip ci] 2022-04-17 22:01:23 +08:00
crazywhalecc
4c56797d14 Add exif, pdo_sqlite, shmop, soap extensions 2022-04-12 00:50:58 +08:00
crazywhalecc
247da4010a update README.md [skip ci] 2022-04-11 23:46:00 +08:00
crazywhalecc
6f078b6865 Add fileinfo extension to default 2022-04-11 23:41:27 +08:00
Jerry Ma
bfe986e62a Update PHP extensions version 2022-04-03 21:04:14 +08:00
Jerry Ma
e3bc589d4b Update README-en.md [skip ci] 2022-04-02 16:50:43 +08:00
Jerry Ma
b6d1ecf0e5 Update README.md [skip ci] 2022-04-02 16:48:48 +08:00
Jerry Ma
6151fcfda0 Update download.sh mute progress 2022-04-02 16:13:16 +08:00
Jerry Ma
0c210d088f Update Dockerfile 2022-04-02 16:07:11 +08:00
Jerry Ma
36132012db Update php versions 2022-04-02 15:52:56 +08:00
Jerry Ma
3c96621af4 Simplify build actions 2022-04-02 15:49:08 +08:00
Jerry Ma
da0b052cc2 Update build-php.yml 2022-04-02 15:23:20 +08:00
Jerry Ma
7fae0f3fe9 Update build-php.yml 2022-04-02 01:46:34 +08:00
Jerry Ma
6970500f85 Update build-php.yml 2022-04-02 01:45:23 +08:00
Jerry Ma
1286a9e237 Delete build-php-arm.yml [skip ci] 2022-04-02 01:45:04 +08:00
Jerry Ma
bf085706b0 Update build-php.yml 2022-04-02 01:38:14 +08:00
Jerry Ma
cb1d1cdc5e Update build-php-arm.yml 2022-04-02 00:31:00 +08:00
Jerry Ma
90c6aebac6 Update build-php-arm.yml 2022-04-02 00:30:30 +08:00
Jerry Ma
84ed82d896 Add dynamic CPU compile acceleration [skip ci] 2022-04-01 22:19:11 +08:00
Jerry Ma
da6c2a88b1 Update extension download link & version [skip ci] 2022-04-01 22:16:07 +08:00
Jerry Ma
f87f3c2736 Update Dockerfile 2022-03-21 02:16:22 +08:00
Jerry Ma
c41ca40337 Update build-php-arm.yml 2022-02-25 14:27:43 +08:00
Jerry Ma
f9f27045ee Update english readme [skip ci] 2022-02-20 17:33:19 +08:00
Jerry Ma
3496c3a2e8 Update README.md 2022-02-18 13:48:08 +08:00
Jerry Ma
23d7af5a30 Update build-php-arm.yml 2022-02-11 16:43:18 +08:00
Jerry Ma
01a51c58d8 Update workflows [skip ci]
Change runner on remote ubuntu-latest
2022-02-11 16:41:20 +08:00
Jerry Ma
be777dc848 Update build-php-arm.yml 2022-02-11 16:36:27 +08:00
Jerry Ma
55f866e5c5 Update build-php.yml 2022-02-11 16:35:45 +08:00
Jerry Ma
94f915d36a Update extension library version 2022-02-11 16:32:33 +08:00
Jerry Ma
23aebace18 Update README.md 2022-01-10 10:14:06 +08:00
Jerry Ma
fb2ce8708f Change LICENSE to MIT 2022-01-10 10:12:05 +08:00
Jerry Ma
ac5fb5e763 Update build-php.yml 2021-12-18 17:14:53 +08:00
Jerry Ma
c93fb71709 Create build-php-arm.yml 2021-12-18 17:04:58 +08:00
Jerry Ma
2df9cf2f5f Update build-php.yml 2021-12-18 17:04:33 +08:00
Jerry Ma
7153bd8a57 Update build-php.yml 2021-12-18 15:59:09 +08:00
Jerry Ma
337a8ca820 Update config.json 2021-12-18 14:32:06 +08:00
Jerry Ma
f47c97eb17 Update build-php.yml 2021-12-18 11:58:47 +08:00
Jerry Ma
8dd87eda01 Update download.sh 2021-12-18 02:28:07 +08:00
Jerry Ma
cae4e23872 Update compile-php.sh 2021-12-18 02:17:05 +08:00
Jerry Ma
8b9251bb3a Update build-php.yml 2021-12-18 02:10:54 +08:00
Jerry Ma
96e25d2ff7 Update build-php.yml 2021-12-18 01:28:47 +08:00
Jerry Ma
7d4e95a742 Update build-php.yml 2021-12-18 01:25:27 +08:00
Jerry Ma
ac35981e0e Update build-php.yml 2021-12-17 23:47:16 +08:00
Jerry Ma
d04cecc733 Update check-extensions.sh 2021-11-27 15:24:21 +08:00
Jerry Ma
c2876f28a8 Update build-php.yml 2021-10-24 13:59:45 +08:00
Jerry Ma
05f33ded14 Update build-php.yml 2021-10-13 15:14:24 +08:00
Jerry Ma
02c85139b4 update README.md [skip ci] 2021-10-13 13:56:25 +08:00
Jerry Ma
8ed1945667 test 2021-10-13 09:15:43 +08:00
Jerry Ma
85c54d46b0 Add mongodb extension default 2021-10-13 09:10:48 +08:00
Jerry Ma
31e3788ead Update library version 2021-09-11 15:24:23 +08:00
Jerry Ma
cd460dd352 update README.md [skip ci] 2021-09-03 09:29:40 +08:00
Jerry Ma
8667351378 Update README-en.md 2021-09-01 16:28:14 +08:00
Jerry Ma
e2f5593d91 Update README.md 2021-09-01 16:26:46 +08:00
Jerry Ma
27d255bc40 update README.md [skip ci] 2021-09-01 16:26:01 +08:00
Jerry Ma
753ae2de39 update README.md [skip ci] 2021-08-31 13:36:11 +08:00
9c10e4401f return to 1 file multi build 2021-08-31 13:34:34 +08:00
b57bdaacc6 Merge remote-tracking branch 'origin/master' 2021-08-31 13:04:13 +08:00
851b35ea4f fix mkdir bugs 2021-08-31 13:03:54 +08:00
Jerry Ma
5c981172de Update README.md 2021-08-31 11:17:26 +08:00
0635341f43 separate action scripts 2021-08-31 10:47:03 +08:00
Jerry Ma
65a5cad9cf Update docker-image.yml 2021-08-31 10:16:05 +08:00
Jerry Ma
5aa4c0ea67 Update docker-image.yml 2021-08-31 00:58:17 +08:00
Jerry Ma
839adb9751 Update docker-image.yml 2021-08-31 00:50:41 +08:00
Jerry Ma
f8ab590356 Update docker-image.yml 2021-08-31 00:49:03 +08:00
Jerry Ma
282470ad96 Update docker-image.yml 2021-08-30 20:14:17 +08:00
Jerry Ma
4488ef397b Update Dockerfile 2021-08-30 17:08:37 +08:00
Jerry Ma
69dd9f124d Update docker-image.yml 2021-08-30 17:03:38 +08:00
Jerry Ma
2d3eec300f Update Dockerfile 2021-08-30 17:02:18 +08:00
Jerry Ma
3de37e8e4e Update docker-image.yml 2021-08-30 17:01:01 +08:00
Jerry Ma
8e6cd15101 Update action-deploy.sh 2021-08-30 16:32:22 +08:00
Jerry Ma
2f186e5db9 Update docker-image.yml 2021-08-30 15:42:10 +08:00
Jerry Ma
b52c3a5597 Update docker-image.yml 2021-08-30 15:27:39 +08:00
Jerry Ma
e29de024d2 Delete main.yml 2021-08-30 15:16:07 +08:00
Jerry Ma
5f9c65156d Create action-deploy.sh 2021-08-30 15:15:34 +08:00
Jerry Ma
19b29b4aad Update docker-image.yml 2021-08-30 15:08:35 +08:00
Jerry Ma
02b2f14e6d Create docker-image.yml 2021-08-30 14:41:19 +08:00
Jerry Ma
8a3df3a2a6 Create main.yml 2021-08-30 14:34:31 +08:00
Jerry Ma
5e33b0d84a Update README.md 2021-07-28 14:54:48 +08:00
Jerry Ma
5a47243022 Update README.md 2021-07-28 14:31:41 +08:00
Jerry Ma
d67f765d31 Update README-en.md 2021-07-28 14:28:43 +08:00
Jerry Ma
294e25bf12 Update README-en.md 2021-07-28 14:27:18 +08:00
Jerry Ma
0f99625334 Update README.md 2021-07-28 14:26:28 +08:00
Jerry Ma
918546a090 Update README.md 2021-07-27 14:57:59 +08:00
Jerry Ma
1c8e652797 Fix Issue #2
https://github.com/crazywhalecc/static-php-cli/issues/2#issuecomment-885332238
2021-07-23 14:31:51 +08:00
root
66942f866e update README.md 2021-07-22 12:05:09 +00:00
root
7440fe3936 update to 1.3.3 version, support multi-version build 2021-07-22 12:03:28 +00:00
root
35395538b4 update to 1.3.2 version (support sqlite3) 2021-07-22 05:24:14 +00:00
Jerry Ma
36f4833b71 Update Dockerfile 2021-07-15 22:00:29 +08:00
Whale
33de213a66 Update Dockerfile 2021-06-13 19:08:46 +08:00
Whale
9fa229fa36 Update README-en.md 2021-06-06 11:53:16 +08:00
Whale
6efa11d8af Update README.md 2021-06-06 11:49:07 +08:00
Whale
cc3fa7d1fd Update README-en.md 2021-06-06 11:42:21 +08:00
Whale
de5d92be70 Update README-en.md 2021-06-06 11:41:55 +08:00
Whale
cb679247fc Update README.md 2021-06-06 11:29:37 +08:00
Whale
f7e961c223 Update README.md 2021-06-06 11:16:59 +08:00
jerry
89fc7c6482 update README.md 2021-06-06 01:03:10 +08:00
jerry
12b32ce1a0 update to Dockerfile version(1.3.0) 2021-06-06 01:01:58 +08:00
Whale
cdf4d4999e Delete static-compile-php.sh 2021-06-06 00:59:44 +08:00
Whale
6926a5c989 Delete multi-version-build.sh 2021-06-06 00:59:37 +08:00
Whale
2944eb4a75 Update README.md 2021-06-06 00:59:20 +08:00
Whale
135259e0db Update README.md 2021-06-06 00:49:00 +08:00
213 changed files with 11683 additions and 1512 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']

106
.github/workflows/build-linux-arm.yml vendored Normal file
View File

@@ -0,0 +1,106 @@
name: CI on arm linux
on:
workflow_dispatch:
inputs:
operating-system:
required: true
description: Compile target arch (Linux only)
type: choice
options:
- aarch64
version:
required: true
description: php version to compile
default: '8.2'
type: choice
options:
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
debug:
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on ${{ inputs.operating-system }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Cache downloaded source
- id: cache-download
uses: actions/cache@v3
with:
path: downloads
key: php-${{ inputs.version }}-dependencies
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }}
# Run build command
- run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v3
with:
name: php-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v3
with:
name: micro-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v3
with:
name: php-fpm-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v3
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v3
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

117
.github/workflows/build-linux-x86_64.yml vendored Normal file
View File

@@ -0,0 +1,117 @@
name: CI on x86_64 linux
on:
workflow_dispatch:
inputs:
version:
required: true
description: php version to compile
default: '8.2'
type: choice
options:
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
debug:
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on Linux x86_64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Install Ubuntu missing packages and mark os suffix
- run: |
sudo apt install musl-tools -y
echo "SPC_BUILD_OS=linux" >> $GITHUB_ENV
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v3
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev
# Cache downloaded source
- id: cache-download
uses: actions/cache@v3
with:
path: downloads
key: php-${{ inputs.version }}-dependencies
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }}
# Run build command
- run: ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v3
with:
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v3
with:
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v3
with:
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v3
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v3
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

117
.github/workflows/build-macos-x86_64.yml vendored Normal file
View File

@@ -0,0 +1,117 @@
name: CI on x86_64 macOS
on:
workflow_dispatch:
inputs:
version:
required: true
description: php version to compile
default: '8.2'
type: choice
options:
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
debug:
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on macOS x86_64
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
# Install macOS missing packages and mark os suffix
- run: |
brew install automake gzip
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v3
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev
# Cache downloaded source
- id: cache-download
uses: actions/cache@v3
with:
path: downloads
key: php-${{ inputs.version }}-dependencies
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: ./bin/spc download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }}
# Run build command
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v3
with:
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v3
with:
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v3
with:
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v3
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v3
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

40
.github/workflows/download-cache.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: archive download sources weekly
on:
workflow_dispatch:
schedule:
- cron: "* 14 * * 5"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
download:
name: cache download sources
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ "8.0", "8.1", "8.2" ]
steps:
- uses: actions/checkout@v3
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v3
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: ./bin/spc download --with-php=${{ matrix.php-version }} --all --debug
# Upload downloaded files
- uses: actions/upload-artifact@v3
with:
name: download-files-${{ matrix.php-version }}
path: downloads/

27
.gitignore vendored Normal file
View File

@@ -0,0 +1,27 @@
.idea
runtime/
docker/libraries/
docker/extensions/
docker/source/
# Composer file
composer.lock
/vendor/
# default source extract directory
/source/
# default source download directory
/downloads/
# default source build root directory
/buildroot/
# php cs fixer cache file
.php-cs-fixer.cache
# exclude self-runtime
/bin/*
!/bin/spc
!/bin/setup-runtime
!/bin/spc-alpine-docker

69
.php-cs-fixer.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@Symfony' => true,
'@PhpCsFixer' => true,
'array_syntax' => [
'syntax' => 'short',
],
'list_syntax' => [
'syntax' => 'short',
],
'concat_space' => [
'spacing' => 'one',
],
'blank_line_before_statement' => [
'statements' => [
'declare',
],
],
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'alpha',
],
'single_line_comment_style' => [
'comment_types' => [
],
],
'yoda_style' => [
'always_move_variable' => false,
'equal' => false,
'identical' => false,
],
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'constant_case' => [
'case' => 'lower',
],
'class_attributes_separation' => true,
'combine_consecutive_unsets' => true,
'declare_strict_types' => true,
'linebreak_after_opening_tag' => true,
'lowercase_static_reference' => true,
'no_useless_else' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => false,
'not_operator_with_space' => false,
'ordered_class_elements' => true,
'php_unit_strict' => false,
'phpdoc_separation' => false,
'single_quote' => true,
'standardize_not_equals' => true,
'multiline_comment_opening_closing' => true,
'phpdoc_summary' => false,
'php_unit_test_class_requires_covers' => false,
'phpdoc_var_without_name' => false,
])
->setFinder(
PhpCsFixer\Finder::create()->in(__DIR__ . '/src')
);

695
LICENSE
View File

@@ -1,674 +1,21 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
MIT License
Copyright (c) 2022-2023 Jerry Ma
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

304
README-en.md Normal file → Executable file
View File

@@ -1,74 +1,256 @@
# static-php-swoole
Compile A Statically Linked PHP With Swoole and other Extensions. [English README](/README-en.md)
# static-php-cli
BTW, It's only for CLI mode.
Compile A Statically Linked PHP With Swoole and other Extensions.
[![version](https://img.shields.io/badge/version-1.2.0-green.svg)]()
Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI)
## Requirements
- Tested on `x86_64` and `aarch64` platform, others have not tested.
- Requiring Alpine Linux (version >= 3.13), or requiring musl-libc
- Support WSL2
- Supporting PHP version >= 7.3
<img width="600" alt="截屏2023-05-02 15 53 13" src="https://user-images.githubusercontent.com/20330940/235610282-23e58d68-bd35-4092-8465-171cff2d5ba8.png">
## Start
You can directly download static binary in Release.
You can also use the micro binary file to combine php binary and php source code into one for distribution!
This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro). (micro SAPI)
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
[![Version](https://img.shields.io/badge/Version-2.0--rc4-pink.svg?style=flat-square)]()
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]()
[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]()
[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]()
> The project has renamed the `refactor` branch to the `main` branch, please pay attention to changing the branch name for dependent projects.
## Compilation Requirements
Yes, this project is written in PHP, pretty funny.
But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension.
Here is the architecture support status, where `CI` represents support for GitHub Action builds,
`Local` represents support for local builds, and blank represents not currently supported.
| | x86_64 | aarch64 |
|---------|-----------|-----------|
| macOS | CI, Local | Local |
| Linux | CI, Local | CI, Local |
| Windows | | |
> macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine.
Currently supported PHP versions for compilation are: `7.4`, `8.0`, `8.1`, `8.2`.
## Docs
docs here: <https://static-php-cli.zhamao.me>.
## Simple Usage
Please first select the extension you want to compile based on the extension list below.
### Direct Download
If you don't compile yourself, you can download pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.zhamao.xin/static-php-cli/)
> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip`
### Supported Extensions
[Supported Extension List](https://static-php-cli.zhamao.me/en/guide/extensions.html)
> If there is no extension you need here, you can submit an issue.
### GitHub Actions Build
Use GitHub Action to easily build a statically compiled PHP and phpmicro,
and at the same time define the extensions to be compiled by yourself.
1. Fork me.
2. Go to the Actions of the project and select `CI`.
3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of extensions. (extensions comma separated, e.g. `bcmath,curl,mbstring`)
4. After waiting for about a period of time, enter the corresponding task and get `Artifacts`.
If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting.
- When using ubuntu-latest, it will build linux-x86_64 binary.
- When using macos-latest, it will build macOS-x86_64 binary.
### Manual Build
Clone repo first:
Here's help command to compile it yourself:
```bash
# Compile script
./static-compile-php.sh
# And now you get `php-dist/bin/php` file!
git clone https://github.com/crazywhalecc/static-php-cli.git
```
## Library version
- php: 7.4.18
- libxml2: 2.9.10
- curl: 7.76.1
If you have not installed php on your system, you can use package management to install PHP (such as brew, apt, yum, apk etc.).
## Including PHP extensions
- bcmath
- calendar
- ctype
- filter
- openssl
- pcntl
- iconv
- inotify (3.0.0)
- json
- mbstring
- phar
- curl
- pdo
- gd
- pdo_mysql
- mysqlnd
- sockets
- swoole (4.6.6)
- redis (5.3.4)
- simplexml
- dom
- xml
- xmlwriter
- xmlreader
- posix
- tokenizer
And you can also download single-file php binary and composer using command `bin/setup-runtime`.
The PHP runtime for static-php-cli itself will be downloaded at `bin/php`, and composer is at `bin/composer`.
## Running preview
After-compile status
![image](https://user-images.githubusercontent.com/20330940/116291663-6df47580-a7c7-11eb-8df3-6340c6f87055.png)
```bash
cd static-php-cli
chmod +x bin/setup-runtime
# It will download php-cli from self-hosted server and composer from getcomposer.org
./bin/setup-runtime
Run Swoft framework directly
![image](https://user-images.githubusercontent.com/20330940/116053161-f16d7400-a6ac-11eb-87b8-e510c6454861.png)
# Use this php runtime to run static-php-cli compiler
./bin/php bin/spc
## Todo List
- [X] curl/libcurl extension support
- [ ] Alternative extension compiling
- [ ] php.ini support
- [ ] Make composer together
- [ ] i18n
# Use composer
./bin/php bin/composer
```
## References
- <https://blog.terrywh.net/post/2019/php-static-openssl/>
- <https://stackoverflow.com/a/37245653>
- <http://blog.gaoyuan.xyz/2014/04/09/statically-compile-php/>
Basic usage for building php and micro with some extensions:
```bash
cd static-php-cli
composer update
chmod +x bin/spc
# Check system tool dependencies, fix them automatically
./bin/spc doctor
# fetch all libraries
./bin/spc fetch --all
# with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI
./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro
```
You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.2:
```bash
# Using PHP >= 8.0 is recommended, because 7.4 cannot use phpmicro
./bin/spc fetch --with-php=8.2 --all
```
Now we support `cli`, `micro`, `fpm`, you can use one or more of the following parameters to specify the compiled SAPI:
- `--build-cli`: build static cli executable
- `--build-micro`: build static phpmicro self-extracted executable
- `--build-fpm`: build static fpm binary
- `--build-all`: build all
If anything goes wrong, use `--debug` option to display full terminal output:
```bash
./bin/spc build openssl,pcntl,mbstring --debug --build-all
./bin/spc fetch --all --debug
```
In addition, we build NTS by default. If you are going to build ZTS version, just add `--enable-zts` option.
```bash
./bin/spc build openssl,pcntl --build-all --enable-zts
```
Adding option `--no-strip` can produce binaries with debug symbols, in order to debug (using gdb). Disabling strip will increase the size of static binary.
### php-cli Usage
> php-cli is a single static binary, you can use it like normal php installed on your system.
When using the parameter `--build-cli` or `--build-all`,
the final compilation result will output a binary file named `./php`,
which can be distributed and used directly.
This file will be located in the directory `buildroot/bin/`, copy it out for use.
```bash
cd buildroot/bin/
./php -v # check version
./php -m # check extensions
./php your_code.php # run your php code
./php your_project.phar # run your phar (project archive)
```
### micro.sfx Usage
> 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.
When using the parameter `--build-all` or `--build-micro`,
the final compilation result will output a file named `./micro.sfx`,
which needs to be used with your PHP source code like `code.php`.
This file will be located in the path `buildroot/bin/micro.sfx`, simply copy it out for use.
Prepare your project source code, which can be a single PHP file or a Phar file, for use.
```bash
echo "<?php echo 'Hello world' . PHP_EOL;" > code.php
cat micro.sfx code.php > single-app && chmod +x single-app
./single-app
# If packing a PHAR file, replace code.php with the Phar file path.
```
> In some cases, PHAR files may not run in a micro environment.
### php-fpm Usage
When using the parameter `--build-all` or `--build-fpm`,
the final compilation result will output a file named `./php-fpm`,
This file will be located in the path `buildroot/bin/`, simply copy it out for use.
In normal Linux distributions and macOS systems, the package manager will automatically generate a default fpm configuration file after installing php-fpm.
Because php-fpm must specify a configuration file before running, the php-fpm compiled by this project will not have any configuration files, so you need to write `php-fpm.conf` and `pool.conf` configuration files yourself.
Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`.
## Current Status
- [X] Basic CLI framework (by `symfony/console`)
- [X] Linux support
- [X] macOS support
- [X] Exception handler
- [ ] Windows support
- [X] PHP 7.4 support
- [X] fpm support
More functions and features are coming soon, Bugs and TODOs: https://github.com/crazywhalecc/static-php-cli/issues/32
## Contribution
Currently, there are only a few supported extensions.
If the extension you need is missing, you can create an issue.
If you are familiar with this project, you are also welcome to initiate a pull request.
The basic principles for contributing are as follows:
- This project uses php-cs-fixer and phpstan as code formatting tools. Before contributing, please run `composer analyze` and `composer cs-fix` on the updated code.
- If other open source libraries are involved, the corresponding licenses should be provided.
Also, configuration files should be sorted using the command `sort-config` after modification.
For more information about sorting commands, see the documentation.
- Naming conventions should be followed, such as using the extension name registered in PHP for the extension name itself,
and external library names should follow the project's own naming conventions. For internal logic functions, class names, variables, etc.,
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.
If you want to contribute document content, please go to [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs).
Part of the English document is written by me, and part is translated by Google,
and there may be inaccurate descriptions, strange or offensive expressions.
If you are a native English speaker, some corrections to the documentation are welcome.
## 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,
while the new version references source code from some other projects:
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs) (Mulun Permissive License)
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli) (Apache 2.0 LICENSE+SWOOLE-CLI LICENSE)
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 `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
The refactoring branch of this project is written modularly.
If you are interested in this project and want to join the development,
you can refer to the [Contribution Guide](https://static-php-cli.zhamao.me) of the documentation to contribute code or documentation. (TODO)

272
README.md Normal file → Executable file
View File

@@ -1,85 +1,227 @@
# static-php-cli
Compile A Statically Linked PHP With Swoole and other Extensions. [English README](/README-en.md)
编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!
Compile A Statically Linked PHP With Swoole and other Extensions.
注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式
**If you are using English, see [English README](README-en.md).**
[![版本](https://img.shields.io/badge/script--version-1.2.1-green.svg)]()
编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携cli SAPI
## 环境需求
- 目前在 x86_64 和 aarch64(arm64) 架构上编译成功,其他架构需自行测试
- 需要 Docker或等我将脚本提出来也可以直接在 Alpine Linux 上使用)
- 脚本支持编译的 PHP 版本7.2 ~ 8.0
<img width="600" alt="截屏2023-05-02 15 53 13" src="https://user-images.githubusercontent.com/20330940/235610282-23e58d68-bd35-4092-8465-171cff2d5ba8.png">
## 开始
可以直接在旁边的 Release 中下载编译好的二进制。
同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(由 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 提供支持micro SAPI
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
[![Version](https://img.shields.io/badge/Version-2.0--rc4-pink.svg?style=flat-square)]()
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]()
[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]()
[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]()
> 项目已重命名 `refactor` 分支为 `main` 分支,请依赖的项目注意更改分支名称。
## 编译环境需求
是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。
但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。
下面是架构支持情况,`CI` 代表支持 GitHub Action 构建,`Local` 代表支持本地构建,空 代表暂不支持。
| | x86_64 | aarch64 |
|---------|-----------|-----------|
| macOS | CI, Local | Local |
| Linux | CI, Local | CI, Local |
| Windows | | |
> macOS-arm64 因 GitHub 暂未提供 arm runner如果要构建 arm 二进制,可以使用手动构建。
目前支持编译的 PHP 版本为:`7.4``8.0``8.1``8.2`
## 文档
点击这里查看文档:<https://static-php-cli.zhamao.me>。
## 使用
请先根据下方扩展列表选择你要编译的扩展。
### 自托管直接下载
如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact也可以从自托管的服务器下载[进入](https://dl.zhamao.xin/static-php-cli/)
> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip`
### 支持的扩展情况
[扩展支持列表](https://static-php-cli.zhamao.me/zh/guide/extensions.html)
> 如果这里没有你需要的扩展,可以提交 Issue。
### 使用 Actions 构建
使用 GitHub Action 可以方便地构建一个静态编译的 PHP 和 phpmicro同时可以自行定义要编译的扩展。
1. Fork 本项目。
2. 进入项目的 Actions选择 CI。
3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`
4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`
如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。
### 手动构建
先克隆本项目:
也可以自己使用 Dockerfile 进行编译构建:
```bash
git clone https://github.com/crazywhalecc/static-php-cli.git
cd static-php-cli/docker
docker build -t static-php .
```
编译之后可以使用下方命令将二进制 PHP 提取出来,用以下方式:
如果你本机没有安装 PHP你需要先使用包管理例如 brew、apt、yum、apk 等)安装 php。
你也可以通过 `bin/setup-runtime` 命令下载静态编译好的 php-cli 和 Composer。下载的 php 和 Composer 将保存为 `bin/php``bin/composer`
```bash
mkdir dist
docker run --rm -v $(pwd)/dist:/dist/ -it static cp php-dist/bin/php /dist/
cd static-php-cli
chmod +x bin/setup-runtime
./bin/setup-runtime
# 使用独立的 php 运行 static-php-cli
./bin/php bin/spc
# 使用 composer
./bin/php bin/composer
```
如果要选择安装的扩展,可以修改 `docker/extensions.txt` 文件,具体规则如下
- 文件内使用 `#` 可以注释,表示不安装
- 扩展名一律使用小写,目前默认状态下文件内所列的扩展为支持的扩展,其他扩展暂不支持,如有需求请提 Issue 添加
下面是使用 static-php-cli 编译静态 php 和 micro 的基础用法
## 支持的扩展(对勾为已支持的扩展,未打勾的正在努力兼容)
- [X] bcmath
- [X] calendar
- [X] ctype
- [X] filter
- [X] openssl
- [X] pcntl
- [X] iconv
- [X] inotify
- [X] json
- [X] mbstring
- [X] phar
- [X] curl
- [X] pdo
- [X] gd
- [X] pdo_mysql
- [X] mysqlnd
- [X] sockets
- [X] swoole
- [X] redis
- [X] simplexml
- [X] dom
- [X] xml
- [X] xmlwriter
- [X] xmlreader
- [X] posix
- [X] tokenizer
- [ ] zip
```bash
# 克隆本项目
cd static-php-cli
composer update
chmod +x bin/spc
# 检查环境依赖,并根据提示的命令安装缺失的编译工具
./bin/spc doctor
# 拉取所有依赖库
./bin/spc fetch --all
# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
```
## 目前的问题(待解决的)
- [ ] event 扩展的 sockets 支持不能在静态编译中使用,因为静态内嵌编译暂时没办法调整扩展编译顺序。
- [ ] Swoole 扩展不支持 `--enable-swoole-curl`,也是因为编译顺序和加载顺序的问题。
- [ ] readline 扩展安装后无法正常使用 `php -a`,原因还没有弄清楚,可能是静态编译造成的 ncurses 库出现了问题。
你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.4 ~ 8.2
## Todo List
- [X] curl/libcurl 扩展静态编译
- [X] 可自行选择不需要编译进入的扩展
- [ ] php.ini 内嵌或分发
- [ ] i18n国际化脚本本身和 README
```bash
# 优先考虑使用 >= 8.0 的 PHP 版本
./bin/spc fetch --with-php=8.2 --all
```
## 运行示例
编译后的状态
![image](https://user-images.githubusercontent.com/20330940/116291663-6df47580-a7c7-11eb-8df3-6340c6f87055.png)
其中,目前支持构建 climicrofpm 三种静态二进制,使用以下参数的一个或多个来指定编译的 SAPI
在不同系统直接运行 Swoft
![image](https://user-images.githubusercontent.com/20330940/116053161-f16d7400-a6ac-11eb-87b8-e510c6454861.png)
- `--build-cli`:构建 cli 二进制
- `--build-micro`:构建 phpmicro 自执行二进制
- `--build-fpm`:构建 fpm
- `--build-all`:构建所有
## 参考资料
- <https://blog.terrywh.net/post/2019/php-static-openssl/>
- <https://stackoverflow.com/a/37245653>
- <http://blog.gaoyuan.xyz/2014/04/09/statically-compile-php/>
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
```bash
./bin/spc build openssl,pcntl,mbstring --debug --build-all
./bin/spc fetch --all --debug
```
此外,默认编译的 PHP 为 NTS 版本。如需编译线程安全版本ZTS只需添加参数 `--enable-zts` 即可。
```bash
./bin/spc build openssl,pcntl --build-all --enable-zts
```
同时,你也可以使用参数 `--no-strip` 来关闭裁剪,关闭裁剪后可以使用 gdb 等工具调试,但这样会让静态二进制体积变大。
### 使用 php-cli
> php-cli 是一个静态的二进制文件,类似 Go、Rust 语言编译后的单个可移植的二进制文件。
采用参数 `--build-cli``--build-all` 参数时,最后编译结果会输出一个 `./php` 的二进制文件,此文件可分发、可直接使用。
该文件编译后会存放在 `buildroot/bin/` 目录中,名称为 `php`,拷贝出来即可。
```bash
cd buildroot/bin/
./php -v # 检查版本
./php -m # 检查编译的扩展
./php your_code.php # 运行代码
./php your_project.phar # 运行打包为 phar 单文件的项目
```
### 使用 micro.sfx
> phpmicro 是一个提供自执行二进制 PHP 的项目,本项目依赖 phpmicro 进行编译自执行二进制。详见 [dixyes/phpmicro](https://github.com/dixyes/phpmicro)。
采用项目参数 `--build-micro``--build-all` 时,最后编译结果会输出一个 `./micro.sfx` 的文件,此文件需要配合你的 PHP 源码使用。
该文件编译后会存放在 `buildroot/bin/` 目录中,拷贝出来即可。
使用时应准备好你的项目源码文件,可以是单个 PHP 文件,也可以是 Phar 文件。
```bash
echo "<?php echo 'Hello world' . PHP_EOL;" > code.php
cat micro.sfx code.php > single-app && chmod +x single-app
./single-app
# 如果打包 PHAR 文件,仅需把 code.php 更换为 phar 文件路径即可
```
> 有些情况下的 phar 文件可能无法在 micro 环境下运行。
### 使用 php-fpm
采用项目参数 `--build-fpm``--build-all` 时,最后编译结果会输出一个 `./php-fpm` 的文件。
该文件存放在 `buildroot/bin/` 目录,拷贝出来即可使用。
在正常的 Linux 发行版和 macOS 系统中,安装 php-fpm 后包管理会自动生成默认的 fpm 配置文件。
因为 php-fpm 必须指定配置文件才可启动,本项目编译的 php-fpm 不会带任何配置文件,所以需自行编写 `php-fpm.conf``pool.conf` 配置文件。
指定 `php-fpm.conf` 可以使用命令参数 `-y`,例如:`./php-fpm -y php-fpm.conf`
## 项目支持情况
- [X] 基础结构编写(采用 `symfony/console`
- [X] 错误处理
- [X] macOS 支持
- [ ] Windows 支持
- [X] Linux 支持
- [X] PHP 7.4 支持
- [X] fpm 支持
更多功能和特性正在陆续支持中详见https://github.com/crazywhalecc/static-php-cli/issues/32
## 贡献
目前支持的扩展较少,如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉也欢迎为本项目发起 Pull Request。
贡献基本原则如下:
- 项目采用了 php-cs-fixer、phpstan 作为代码规范工具,贡献前请对更新的代码执行 `composer analyze``composer cs-fix`
- 涉及到其他开源库的部分应提供对应库的协议,同时对配置文件在修改后采用命令 `sort-config` 排序。有关排序的命令,见文档。
- 应遵循命名规范,例如扩展名称应采取 PHP 内注册的扩展名本身,外部库名应遵循项目本身的名称,内部逻辑的函数、类名、变量等应遵循驼峰、下划线等格式,禁止同一模块混用。
- 涉及编译外部库的命令和 Patch 时应注意兼容不同操作系统。
另外,添加新扩展的贡献方式,可以参考下方 `进阶`
如果你想贡献文档内容,请到项目仓库 [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs) 贡献。
## 赞助本项目
你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。
## 开源协议
本项目依据旧版本惯例采用 MIT License 开源,自身的部分代码引用或修改自以下项目:
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)(木兰宽松许可证)
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)Apache 2.0 LICENSE、SWOOLE-CLI LICENSE
因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。
请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。
## 进阶
本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php-cli.zhamao.me) 贡献代码或文档。TODO

71
bin/setup-runtime Executable file
View File

@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# set error-quit, verbose, non-variable-quit
set -eu
# see what system used
__OS__=$(uname -s)
# see what arch used
__ARCH__=$(uname -m)
# format arch name
case $__ARCH__ in
arm64 | aarch64) __ARCH__=aarch64 ;;
x86_64|x64) __ARCH__=x86_64 ;;
*) ;;
esac
# format uname
case $__OS__ in
Darwin) __OS_FIXED__=macos ;;
Linux) __OS_FIXED__=linux ;;
*) echo "Current OS is not supported" && exit 1 ;;
esac
# set project dir
__DIR__=$(cd "$(dirname "$0")" && pwd)
__PROJECT__=$(cd ${__DIR__}/../ && pwd)
# set download dir
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.6-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
# use china mirror
# bash bin/setup-runtime --mirror china
mirror=''
while [ $# -gt 0 ]; do
case "$1" in
--mirror)
mirror="$2"
shift
;;
--*)
echo "Illegal option $1"
;;
esac
shift $(($# > 0 ? 1 : 0))
done
case "$mirror" in
china)
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.6-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar"
;;
esac
test -d ${__PROJECT__}/downloads || mkdir ${__PROJECT__}/downloads
# download static php binary
test -f ${__PROJECT__}/downloads/runtime.tar.gz || { echo "Downloading $__PHP_RUNTIME_URL__ ..." && curl -#fSL -o ${__PROJECT__}/downloads/runtime.tar.gz "$__PHP_RUNTIME_URL__" ; }
test -f ${__DIR__}/php || { tar -xf ${__PROJECT__}/downloads/runtime.tar.gz -C ${__DIR__}/ ; }
chmod +x ${__DIR__}/php
# download composer
test -f ${__DIR__}/composer || curl -#fSL -o ${__DIR__}/composer "$__COMPOSER_URL__"
chmod +x ${__DIR__}/composer
# sanity check for php and composer
${__DIR__}/php -v >/dev/null || { echo "Failed to run php" && exit 1; }
${__DIR__}/php ${__DIR__}/composer --version >/dev/null || { echo "Failed to run composer" && exit 1; }
echo "Setup runtime OK!"
echo "runtime bin path needs to add manually by command below:"
echo ""
echo " export PATH=\"${__DIR__}:\$PATH\""
echo ""

16
bin/spc Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
// 防止 Micro 打包状态下不支持中文的显示(虽然这个项目目前好像没输出过中文?)
if (PHP_OS_FAMILY === 'Windows' && Phar::running()) {
exec('CHCP 65001');
}
// 跑,反正一条命令跑就对了
try {
(new \SPC\ConsoleApplication())->run();
} catch (Exception $e) {
\SPC\exception\ExceptionHandler::getInstance()->handle($e);
}

82
bin/spc-alpine-docker Executable file
View File

@@ -0,0 +1,82 @@
#!/usr/bin/env sh
# This file is using docker to run commands
self_dir=$(cd "$(dirname "$0")";pwd)
# Detect docker can run
if ! which docker >/dev/null; then
echo "Docker is not installed, please install docker first !"
exit 1
fi
DOCKER_EXECUTABLE="docker"
if [ $(id -u) -ne 0 ]; then
if ! docker info > /dev/null 2>&1; then
if [ "$SPC_USE_SUDO" != "yes" ]; then
echo "Docker command requires sudo"
echo -n 'To use sudo to run docker, run "export SPC_USE_SUDO=yes" and run command again'
exit 1
fi
DOCKER_EXECUTABLE="sudo docker"
fi
fi
# to check if qemu-docker run
if [ "$SPC_USE_ARCH" = "" ]; then
SPC_USE_ARCH=x86_64
fi
case $SPC_USE_ARCH in
x86_64)
ALPINE_FROM=alpine:edge
;;
aarch64)
ALPINE_FROM=multiarch/alpine:aarch64-edge
echo -e "\e[033m* Using different arch needs to setup qemu-static for docker !\e[0m"
$DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null
;;
*)
echo "Current arch is not supported to run in docker: $SPC_USE_ARCH"
exit 1
;;
esac
if [ "$SPC_USE_MIRROR" = "yes" ]; then
SPC_USE_MIRROR="RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories"
else
SPC_USE_MIRROR="RUN echo 'Using original repo'"
fi
# Detect docker env is setup
if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-$SPC_USE_ARCH; then
echo "Docker container does not exist. Building docker image ..."
ALPINE_DOCKERFILE=$(cat << EOF
FROM $ALPINE_FROM
$SPC_USE_MIRROR
RUN apk update
RUN apk add bash file wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils bison flex pkgconfig automake curl
RUN apk add build-base xz php81 php81-common php81-pcntl php81-tokenizer php81-phar php81-posix php81-xml composer
RUN mkdir /app
WORKDIR /app
ADD ./src /app/src
ADD ./composer.json /app/composer.json
ADD ./bin /app/bin
RUN composer update --no-dev
EOF
)
echo "$ALPINE_DOCKERFILE" > $(pwd)/Dockerfile
$DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH .
rm $(pwd)/Dockerfile
fi
# Check if in ci (local terminal can execute with -it)
if [ -t 0 ]; then
INTERACT=-it
else
INTERACT=''
fi
# Run docker
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT=$(pwd) -v $(pwd)/config:/app/config -v $(pwd)/src:/app/src -v $(pwd)/buildroot:/app/buildroot -v $(pwd)/source:/app/source -v $(pwd)/downloads:/app/downloads cwcc-spc-$SPC_USE_ARCH bin/spc $@

44
captainhook.json Normal file
View File

@@ -0,0 +1,44 @@
{
"pre-push": {
"enabled": true,
"actions": [
{
"action": "composer analyse"
}
]
},
"pre-commit": {
"enabled": true,
"actions": [
{
"action": "composer cs-fix -- --config=.php-cs-fixer.php --dry-run --diff {$STAGED_FILES|of-type:php}",
"conditions": [
{
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
"args": ["php"]
}
]
}
]
},
"post-change": {
"enabled": true,
"actions": [
{
"action": "composer install",
"options": [],
"conditions": [
{
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any",
"args": [
[
"composer.json",
"composer.lock"
]
]
}
]
}
]
}
}

51
composer.json Normal file
View File

@@ -0,0 +1,51 @@
{
"name": "crazywhalecc/static-php-cli",
"description": "Build single static PHP binary, with PHP project together, with popular extensions included.",
"license": "MIT",
"authors": [
{
"name": "jerry",
"email": "admin@zhamao.me"
}
],
"require": {
"php": ">= 8.1",
"ext-mbstring": "*",
"ext-pcntl": "*",
"laravel/prompts": "^0.1.3",
"symfony/console": "^6 || ^5 || ^4",
"zhamao/logger": "^1.0"
},
"require-dev": {
"nunomaduro/collision": "*",
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
"phpstan/phpstan": "^1.1",
"captainhook/captainhook": "^5.10",
"captainhook/plugin-composer": "^5.3"
},
"autoload": {
"psr-4": {
"SPC\\": "src/SPC"
},
"files": [
"src/globals/defines.php",
"src/globals/functions.php"
]
},
"bin": [
"bin/spc"
],
"scripts": {
"analyse": "phpstan analyse --memory-limit 300M",
"cs-fix": "php-cs-fixer fix",
"test": "bin/phpunit --no-coverage"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true,
"captainhook/plugin-composer": true
},
"optimize-autoloader": true,
"sort-packages": true
}
}

488
config/ext.json Normal file
View File

@@ -0,0 +1,488 @@
{
"apcu": {
"type": "external",
"source": "apcu"
},
"bcmath": {
"type": "builtin"
},
"bz2": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"bzip2"
]
},
"calendar": {
"type": "builtin"
},
"ctype": {
"type": "builtin"
},
"curl": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"curl"
]
},
"dba": {
"type": "builtin",
"arg-type-windows": "with"
},
"dom": {
"type": "builtin",
"arg-type": "custom",
"arg-type-windows": "with",
"lib-depends": [
"libxml2",
"zlib"
]
},
"event": {
"type": "external",
"source": "ext-event",
"arg-type": "custom",
"lib-depends": [
"libevent"
],
"ext-depends": [
"openssl"
],
"ext-suggests": [
"sockets"
]
},
"memcached": {
"type": "external",
"source": "memcached",
"arg-type": "custom",
"cpp-extension": true,
"lib-depends": [
"libmemcached"
],
"ext-depends": [
"session",
"zlib"
]
},
"exif": {
"type": "builtin"
},
"ffi": {
"arg-type": "custom",
"type": "builtin",
"lib-depends": [
"libffi"
]
},
"fileinfo": {
"type": "builtin"
},
"filter": {
"type": "builtin"
},
"ftp": {
"type": "builtin",
"lib-suggests": [
"openssl"
]
},
"gd": {
"type": "builtin",
"arg-type": "custom",
"arg-type-windows": "with",
"lib-depends": [
"zlib",
"libpng"
],
"ext-depends": [
"zlib"
],
"lib-suggests": [
"libavif",
"libwebp",
"libjpeg",
"freetype"
]
},
"gettext": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"gettext"
]
},
"gmp": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"gmp"
]
},
"iconv": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends-windows": [
"libiconv"
]
},
"imagick": {
"type": "external",
"source": "ext-imagick",
"arg-type": "custom",
"lib-depends": [
"imagemagick"
]
},
"glfw": {
"type": "external",
"arg-type": "custom",
"source": "ext-glfw",
"lib-depends": [
"glfw"
]
},
"imap": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"imap"
],
"lib-suggests": [
"kerberos"
]
},
"inotify": {
"type": "external",
"source": "inotify"
},
"intl": {
"type": "builtin",
"cpp-extension": true,
"lib-depends": [
"icu"
]
},
"ldap": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"ldap"
]
},
"mbregex": {
"type": "builtin",
"arg-type": "custom",
"ext-depends": [
"mbstring"
]
},
"mbstring": {
"type": "builtin",
"arg-type": "custom",
"lib-depends": [
"onig"
]
},
"memcache": {
"type": "external",
"source": "ext-memcache",
"arg-type": "custom",
"lib-depends": [
"zlib"
],
"ext-depends": [
"session"
]
},
"mongodb": {
"type": "external",
"source": "mongodb",
"arg-type": "custom",
"lib-suggests": [
"icu",
"openssl",
"zstd",
"zlib"
]
},
"mysqli": {
"type": "builtin",
"arg-type": "with",
"ext-depends": [
"mysqlnd"
]
},
"mysqlnd": {
"type": "builtin",
"arg-type-windows": "with",
"lib-depends": [
"zlib"
]
},
"opcache": {
"type": "builtin"
},
"openssl": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"openssl"
]
},
"pcntl": {
"type": "builtin",
"unix-only": true
},
"pdo": {
"type": "builtin"
},
"pdo_mysql": {
"type": "builtin",
"arg-type": "with",
"ext-depends": [
"pdo",
"mysqlnd"
]
},
"pdo_pgsql": {
"type": "builtin",
"arg-type": "with-prefix",
"ext-depends": [
"pdo",
"pgsql"
],
"lib-depends": [
"postgresql"
]
},
"pdo_sqlite": {
"type": "builtin",
"arg-type": "with",
"ext-depends": [
"pdo",
"sqlite3"
],
"lib-depends": [
"sqlite"
]
},
"pgsql": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"postgresql"
]
},
"phar": {
"type": "builtin",
"ext-depends": [
"zlib"
]
},
"posix": {
"type": "builtin",
"unix-only": true
},
"protobuf": {
"type": "external",
"source": "protobuf"
},
"pspell": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"aspell"
]
},
"readline": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"readline"
]
},
"redis": {
"type": "external",
"source": "redis",
"arg-type": "custom",
"ext-suggests": [
"session"
]
},
"session": {
"type": "builtin"
},
"shmop": {
"type": "builtin"
},
"simplexml": {
"type": "builtin",
"arg-type": "custom",
"arg-type-windows": "with",
"lib-depends": [
"libxml2"
]
},
"snmp": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"net-snmp"
]
},
"soap": {
"type": "builtin",
"arg-type": "custom",
"lib-depends": [
"libxml2"
]
},
"sockets": {
"type": "builtin"
},
"sodium": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"libsodium"
]
},
"sqlite3": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"sqlite"
]
},
"ssh2": {
"type": "external",
"source": "ext-ssh2",
"arg-type": "with-prefix",
"lib-depends": [
"libssh2"
]
},
"swoole": {
"type": "external",
"source": "swoole",
"arg-type": "custom",
"cpp-extension": true,
"lib-depends": [
"openssl"
],
"ext-depends": [
"openssl"
],
"ext-suggests": [
"curl"
],
"unix-only": true
},
"swow": {
"type": "external",
"source": "swow",
"arg-type": "custom",
"lib-suggests": [
"openssl",
"curl"
],
"ext-suggests": [
"openssl",
"curl"
]
},
"sysvmsg": {
"type": "builtin",
"unix-only": true
},
"sysvsem": {
"type": "builtin",
"unix-only": true
},
"sysvshm": {
"type": "builtin",
"unix-only": true
},
"tidy": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"tidy"
]
},
"tokenizer": {
"type": "builtin"
},
"xlswriter": {
"type": "external",
"source": "xlswriter",
"arg-type": "custom",
"ext-depends": [
"zlib",
"zip"
]
},
"xml": {
"type": "builtin",
"arg-type": "custom",
"arg-type-windows": "with",
"lib-depends": [
"libxml2"
]
},
"xmlreader": {
"type": "builtin",
"arg-type": "custom",
"lib-depends": [
"libxml2"
]
},
"xmlwriter": {
"type": "builtin",
"arg-type": "custom",
"lib-depends": [
"libxml2"
]
},
"xsl": {
"type": "builtin",
"arg-type": "with",
"lib-depends": [
"libxslt"
]
},
"yaml": {
"type": "external",
"source": "yaml",
"arg-type": "with-prefix",
"lib-depends": [
"libyaml"
]
},
"zip": {
"type": "builtin",
"arg-type": "with-prefix",
"arg-type-windows": "enable",
"lib-depends": [
"libzip"
]
},
"zlib": {
"type": "builtin",
"arg-type": "with",
"arg-type-windows": "enable",
"lib-depends": [
"zlib"
]
},
"zstd": {
"type": "external",
"source": "ext-zstd",
"arg-type": "custom",
"lib-depends": [
"zstd"
]
}
}

505
config/lib.json Normal file
View File

@@ -0,0 +1,505 @@
{
"brotli": {
"source": "brotli",
"static-libs-unix": [
"libbrotlidec-static.a",
"libbrotlienc-static.a",
"libbrotlicommon-static.a"
],
"static-libs-windows": [
"brotlicommon-static.lib",
"brotlienc-static.lib",
"brotlidec-static.lib"
],
"headers": [
"brotli"
]
},
"glfw": {
"source": "ext-glfw",
"static-libs-unix": [
"libglfw3.a"
],
"frameworks": [
"CoreVideo",
"OpenGL",
"Cocoa",
"IOKit"
]
},
"bzip2": {
"source": "bzip2",
"static-libs-unix": [
"libbz2.a"
],
"static-libs-windows": [
[
"libbz2.lib",
"libbz2_a.lib"
]
],
"headers": [
"bzlib.h"
]
},
"curl": {
"source": "curl",
"static-libs-unix": [
"libcurl.a"
],
"static-libs-windows": [
"libcurl.lib"
],
"headers": [
"curl"
],
"lib-depends-unix": [
"zlib"
],
"lib-suggests": [
"libssh2",
"brotli",
"nghttp2",
"zstd",
"openssl"
],
"lib-suggests-windows": [
"zlib",
"libssh2",
"brotli",
"nghttp2",
"zstd",
"openssl",
"idn2",
"psl"
],
"frameworks": [
"CoreFoundation",
"SystemConfiguration"
]
},
"freetype": {
"source": "freetype",
"static-libs-unix": [
"libfreetype.a"
],
"headers-unix": [
"freetype2/freetype/freetype.h",
"freetype2/ft2build.h"
],
"lib-depends": [
"zlib"
],
"lib-suggests": [
"libpng",
"bzip2",
"brotli"
]
},
"gmp": {
"source": "gmp",
"static-libs-unix": [
"libgmp.a"
],
"static-libs-windows": [
"libgmp.lib"
],
"headers": [
"gmp.h"
]
},
"icu": {
"source": "icu",
"static-libs-unix": [
"libicui18n.a",
"libicuio.a",
"libicuuc.a",
"libicudata.a"
]
},
"imagemagick": {
"source": "imagemagick",
"static-libs-unix": [
"libMagick++-7.Q16HDRI.a",
"libMagickCore-7.Q16HDRI.a",
"libMagickWand-7.Q16HDRI.a"
],
"lib-depends": [
"zlib",
"libpng",
"libjpeg",
"bzip2",
"libwebp",
"freetype"
],
"lib-suggests": [
"zstd",
"xz",
"libzip",
"libxml2"
]
},
"libavif": {
"source": "libavif",
"static-libs-unix": [
"libavif.a"
]
},
"libevent": {
"source": "libevent",
"static-libs-unix": [
"libevent.a",
"libevent_core.a",
"libevent_extra.a",
"libevent_openssl.a"
],
"lib-depends": [
"openssl"
]
},
"libffi": {
"source": "libffi",
"static-libs-unix": [
"libffi.a"
],
"static-libs-windows": [
"libffi.lib"
],
"headers-unix": [
"ffi.h",
"ffitarget.h"
],
"headers-windows": [
"ffi.h",
"fficonfig.h",
"ffitarget.h"
]
},
"libiconv": {
"source": "libiconv",
"static-libs-unix": [
"libiconv.a",
"libcharset.a"
],
"headers": [
"iconv.h",
"libcharset.h",
"localcharset.h"
]
},
"libjpeg": {
"source": "libjpeg",
"static-libs-unix": [
"libjpeg.a",
"libturbojpeg.a"
]
},
"libmcrypt": {
"source": "libmcrypt",
"static-libs-unix": [
"libmcrypt.a"
]
},
"libpng": {
"source": "libpng",
"static-libs-unix": [
"libpng.a"
],
"static-libs-windows": [
"libpng16_static.lib"
],
"headers-unix": [
"png.h",
"pngconf.h",
"pnglibconf.h"
],
"headers-windows": [
"png.h",
"pngconf.h"
],
"lib-depends": [
"zlib"
]
},
"libsodium": {
"source": "libsodium",
"static-libs-unix": [
"libsodium.a"
]
},
"libssh2": {
"source": "libssh2",
"static-libs-unix": [
"libssh2.a"
],
"static-libs-windows": [
"libssh2.lib"
],
"headers": [
"libssh2.h",
"libssh2_publickey.h",
"libssh2_sftp.h"
],
"lib-depends": [
"openssl"
],
"lib-suggests": [
"zlib"
]
},
"libwebp": {
"source": "libwebp",
"static-libs-unix": [
"libwebp.a",
"libwebpdecoder.a",
"libwebpdemux.a",
"libwebpmux.a",
"libsharpyuv.a"
]
},
"libxml2": {
"source": "libxml2",
"static-libs-unix": [
"libxml2.a"
],
"static-libs-windows": [
[
"libxml2s.lib",
"libxml2_a.lib"
]
],
"headers": [
"libxml2"
],
"lib-depends": [
"libiconv"
],
"lib-suggests": [
"xz",
"zlib",
"icu"
],
"lib-suggests-windows": [
"icu",
"xz",
"zlib",
"pthreads4w"
]
},
"libyaml": {
"source": "libyaml",
"static-libs-unix": [
"libyaml.a"
],
"static-libs-windows": [
"yaml.lib"
],
"headers": [
"yaml.h"
]
},
"libzip": {
"source": "libzip",
"static-libs-unix": [
"libzip.a"
],
"static-libs-windows": [
[
"zip.lib",
"libzip_a.lib"
]
],
"headers": [
"zip.h",
"zipconf.h"
],
"lib-depends": [
"zlib"
],
"lib-suggests": [
"bzip2",
"xz",
"zstd",
"openssl"
]
},
"mcrypt": {
"source": "mcrypt",
"static-libs-unix": [
"libmcrypt.a"
]
},
"ncurses": {
"source": "ncurses",
"static-libs-unix": [
"libncurses.a"
]
},
"nghttp2": {
"source": "nghttp2",
"static-libs-unix": [
"libnghttp2.a"
],
"static-libs-windows": [
"nghttp2.lib"
],
"headers": [
"nghttp2"
],
"lib-depends": [
"zlib",
"openssl"
],
"lib-suggests": [
"libxml2"
]
},
"onig": {
"source": "onig",
"static-libs-unix": [
"libonig.a"
],
"static-libs-windows": [
[
"onig.lib",
"onig_a.lib"
]
],
"headers": [
"oniggnu.h",
"oniguruma.h"
]
},
"openssl": {
"source": "openssl",
"static-libs-unix": [
"libssl.a",
"libcrypto.a"
],
"static-libs-windows": [
"libssl.lib",
"libcrypto.lib"
],
"headers": [
"openssl"
],
"lib-depends": [
"zlib"
]
},
"pkg-config": {
"source": "pkg-config"
},
"postgresql": {
"source": "postgresql",
"static-libs-unix": [
"libpq.a",
"libpgport.a",
"libpgcommon.a"
],
"lib-depends": [
"libiconv",
"libxml2",
"openssl",
"zlib",
"readline"
],
"lib-suggests": [
"icu"
]
},
"pthreads4w": {
"source": "pthreads4w",
"static-libs-windows": [
"libpthreadVC3.lib"
],
"headers-windows": [
"_ptw32.h",
"pthread.h",
"sched.h",
"semaphore.h"
]
},
"readline": {
"source": "readline",
"static-libs-unix": [
"libreadline.a"
],
"lib-depends": [
"ncurses"
]
},
"sqlite": {
"source": "sqlite",
"static-libs-unix": [
"libsqlite3.a"
],
"headers-unix": [
"sqlite3.h",
"sqlite3ext.h"
]
},
"xz": {
"source": "xz",
"static-libs-unix": [
"liblzma.a"
],
"static-libs-windows": [
[
"liblzma.lib",
"liblzma_a.lib"
]
],
"headers-unix": [
"lzma"
],
"headers-windows": [
"lzma",
"lzma.h"
],
"lib-depends": [
"libiconv"
]
},
"zlib": {
"source": "zlib",
"static-libs-unix": [
"libz.a"
],
"static-libs-windows": [
"zlib_a.lib"
],
"headers": [
"zlib.h",
"zconf.h"
]
},
"libmemcached": {
"source": "libmemcached",
"static-libs-unix": [
"libmemcached.a",
"libmemcachedutil.a"
]
},
"zstd": {
"source": "zstd",
"static-libs-unix": [
"libzstd.a"
],
"static-libs-windows": [
[
"zstd.lib",
"zstd_static.lib"
]
],
"headers-unix": [
"zdict.h",
"zstd.h",
"zstd_errors.h"
],
"headers-windows": [
"zstd.h",
"zstd_errors.h"
]
}
}

479
config/source.json Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,137 +0,0 @@
from alpine:latest
# define script basic information
# Version of this Dockerfile
ENV SCRIPT_VERSION=1.3.0
# Download address uses backup address
# (if downloading slowly, consider set it to yes)
ENV USE_BACKUP=no
# Version of some manually-installed package
ENV VER_PHP=7.4.19
ENV VER_SWOOLE=4.6.7
ENV VER_HASH=1.5
ENV VER_INOTIFY=3.0.0
ENV VER_REDIS=5.3.4
ENV VER_LIBXML2=2.9.12
ENV VER_CURL=7.77.0
ENV VER_LIBLZMA=master
# LINK_OF_ADDRESS_ORIGIN
ENV LINK_APK_REPO='mirrors.ustc.edu.cn'
ENV LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
RUN if [ "${USE_BACKUP}" = "yes" ]; then \
echo "Using backup address..." && sleep 3s; \
else \
echo "Using original address..." && sleep 3s; \
fi
RUN sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories
# build requirements
RUN apk add cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses
# php zlib dependencies
RUN apk add zlib-dev zlib-static
# php mbstring dependencies
RUN apk add oniguruma-dev
# php openssl dependencies
RUN apk add openssl-libs-static openssl-dev openssl
# php gd dependencies
RUN apk add libpng-dev libpng-static
# curl c-ares dependencies
RUN apk add c-ares-static c-ares-dev
RUN mkdir /app
WORKDIR /app
COPY download.sh /app/
COPY compile-php.sh /app/
RUN chmod +x /app/download.sh && \
chmod +x /app/compile-php.sh
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
RUN ./download.sh hash ${USE_BACKUP} ${VER_HASH}
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
RUN wget "http://mirrors.zhamao.xin/php/php-${VER_PHP}.tar.gz" -O php.tar.gz
RUN wget "http://mirrors.zhamao.xin/pecl/swoole-${VER_SWOOLE}.tgz" -O swoole.tar.gz
RUN wget "http://mirrors.zhamao.xin/pecl/hash-${VER_HASH}.tgz" -O hash.tar.gz
RUN wget "http://mirrors.zhamao.xin/pecl/inotify-${VER_INOTIFY}.tgz" -O inotify.tar.gz
RUN wget "http://mirrors.zhamao.xin/pecl/redis-${VER_REDIS}.tgz" -O redis.tar.gz
RUN wget "https://dl.zhamao.me/libxml2/libxml2-${VER_LIBXML2}.tar.gz" -O libxml2.tar.gz
RUN wget "https://dl.zhamao.me/liblzma/liblzma.tar.gz"
RUN wget "https://dl.zhamao.me/curl/curl-${VER_CURL}.tar.gz" -O curl.tar.gz
RUN tar -xf php.tar.gz && \
tar -xf swoole.tar.gz && \
tar -xf hash.tar.gz && \
tar -xf inotify.tar.gz && \
tar -xf redis.tar.gz && \
tar -xf libxml2.tar.gz && \
tar -xf liblzma.tar.gz && \
tar -xf curl.tar.gz
RUN cd liblzma && \
./configure && \
make -j4 && \
make install && \
echo "liblzma compiled!"
RUN cd "libxml2-${VER_LIBXML2}" && \
./configure --with-lzma --without-python && \
make -j4 && \
make install && \
echo "libxml2 compiled!"
RUN cd "curl-${VER_CURL}" && \
CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure \
--without-nghttp2 \
--with-ssl=/usr \
--with-pic=pic \
--enable-ipv6 \
--enable-shared=no \
--without-libidn2 \
--disable-ldap \
--without-libpsl \
--without-lber \
--enable-ares && \
make -j4 && \
make install && \
echo "curl compiled!"
COPY ac_override_1 /
COPY ac_override_2 /
COPY compile-php.sh /app/
RUN apk add bash
# copy
RUN mv "swoole-${VER_SWOOLE}" "php-${VER_PHP}/ext/swoole" && \
mv "redis-${VER_REDIS}" "php-${VER_PHP}/ext/redis" && \
mv "inotify-${VER_INOTIFY}" "php-${VER_PHP}/ext/inotify"
RUN cat /ac_override_1 /app/php-${VER_PHP}/ext/curl/config.m4 /ac_override_2 > /app/aa
RUN mv /app/aa /app/php-${VER_PHP}/ext/curl/config.m4
RUN cd "php-${VER_PHP}/ext/swoole/" && \
./clear.sh && \
cd ../../ && \
./buildconf --force
RUN ./compile-php.sh ${VER_PHP}
RUN cd "php-${VER_PHP}" && \
sed -ie 's/-export-dynamic//g' "Makefile" && \
sed -ie 's/-o \$(SAPI_CLI_PATH)/-all-static -o \$(SAPI_CLI_PATH)/g' "Makefile" && \
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "ext/swoole/include/swoole.h" && \
make LDFLAGS=-ldl -j4 && \
make install && \
strip

View File

@@ -1,3 +0,0 @@
AC_DEFUN([PHP_CHECK_LIBRARY], [
$3
])

View File

@@ -1,18 +0,0 @@
AC_DEFUN([PHP_CHECK_LIBRARY], [
save_old_LDFLAGS=$LDFLAGS
ac_stuff="$5"
save_ext_shared=$ext_shared
ext_shared=yes
PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
AC_CHECK_LIB([$1],[$2],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
$3
],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
unset ac_cv_lib_$1[]_$2
$4
])dnl
])

View File

@@ -1,87 +0,0 @@
#!/bin/sh
VER_PHP="$1"
function php_compile_args() {
_php_arg="--prefix=/app/php-dist"
_php_arg="$_php_arg --disable-all"
_php_arg="$_php_arg --enable-shared=no"
_php_arg="$_php_arg --enable-static=yes"
_php_arg="$_php_arg --enable-inline-optimization"
_php_arg="$_php_arg --with-layout=GNU"
_php_arg="$_php_arg --enable-calendar"
_php_arg="$_php_arg --enable-ctype"
_php_arg="$_php_arg --enable-filter"
_php_arg="$_php_arg --enable-openssl"
_php_arg="$_php_arg --enable-bcmath"
_php_arg="$_php_arg --enable-pcntl"
_php_arg="$_php_arg --enable-openssl"
_php_arg="$_php_arg --with-openssl"
_php_arg="$_php_arg --with-iconv"
_php_arg="$_php_arg --enable-mbstring"
_php_arg="$_php_arg --enable-phar"
_php_arg="$_php_arg --enable-pdo"
_php_arg="$_php_arg --with-pdo-mysql=mysqlnd"
_php_arg="$_php_arg --enable-sockets"
_php_arg="$_php_arg --enable-swoole"
_php_arg="$_php_arg --enable-inotify"
_php_arg="$_php_arg --enable-redis"
_php_arg="$_php_arg --disable-redis-session"
_php_arg="$_php_arg --enable-simplexml"
_php_arg="$_php_arg --enable-dom"
_php_arg="$_php_arg --enable-xml"
_php_arg="$_php_arg --enable-xmlwriter"
_php_arg="$_php_arg --enable-xmlreader"
_php_arg="$_php_arg --with-zlib"
_php_arg="$_php_arg --enable-posix"
_php_arg="$_php_arg --enable-mysqlnd"
_php_arg="$_php_arg --enable-tokenizer"
_php_arg="$_php_arg --with-curl"
_php_arg="$_php_arg --with-pear=no"
_php_arg="$_php_arg --disable-cgi"
_php_arg="$_php_arg --disable-phpdbg"
for loop in $(cat extension.txt)
do
case $loop in
swoole)
esac
done
case $1 in
7.3.*|7.2.*)
_php_arg="$_php_arg --with-gd"
_php_arg="$_php_arg --enable-libxml"
_php_arg="$_php_arg --enable-hash"
_php_arg="$_php_arg --enable-json"
;;
7.4.*)
_php_arg="$_php_arg --enable-gd"
_php_arg="$_php_arg --with-libxml"
_php_arg="$_php_arg --enable-json"
;;
8.*)
_php_arg="$_php_arg --enable-gd"
_php_arg="$_php_arg --with-libxml"
;;
esac
echo $_php_arg
}
function before_configure() {
for loop in $(cat extension.txt)
do
case $loop in
swoole)
esac
done
}
cd php-$VER_PHP && \
before_configure && \
./buildconf --force && \
./configure LDFLAGS=-static $(php_compile_args $VER_PHP) && \
after_configure && \
sed -ie 's/-export-dynamic//g' "Makefile" && \
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile" && \
if [ "$(cat extension.txt | grep swoole)" != "" ]; then sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "ext/swoole/include/swoole.h" && \

View File

@@ -1,3 +0,0 @@
swoole
redis
hello

View File

@@ -1,109 +0,0 @@
#!/bin/sh
_use_backup="$2"
function download_file() {
downloader="wget"
type wget >/dev/null 2>&1 || { downloader="curl"; }
if [ "$downloader" = "wget" ]; then
_down_prefix="O"
else
_down_prefix="o"
fi
_down_symbol=0
if [ ! -f "$2" ]; then
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
echo "$1 完成! $2" && _down_symbol=1
else
echo "$2 已存在!" && _down_symbol=1
fi
if [ $_down_symbol == 0 ]; then
echo "下载 $1 失败!请检查网络连接!"
rm -rf "$2"
return 1
fi
return 0
}
function lib_download_link() {
if [ "$_use_backup" = "yes" ]; then
case $1 in
"php") echo "https://www.php.net/distributions/php-$2.tar.gz" ;;
"swoole") echo "https://pecl.php.net/get/swoole-$2.tgz" ;;
"hash") echo "https://pecl.php.net/get/hash-$2.tgz" ;;
"inotify") echo "https://pecl.php.net/get/inotify-$2.tgz" ;;
"redis") echo "https://pecl.php.net/get/redis-$2.tgz" ;;
"libxml2") echo "http://xmlsoft.org/sources/libxml2-$2.tar.gz" ;;
"liblzma") echo "https://github.com/kobolabs/liblzma/archive/refs/heads/master.zip" ;;
"curl") echo "https://curl.haxx.se/download/curl-$2.tar.gz" ;;
*) echo "unknown" ;;
esac
else
case $1 in
"php") echo "http://mirrors.zhamao.xin/php/php-$2.tar.gz" ;;
"swoole") echo "http://mirrors.zhamao.xin/pecl/swoole-$2.tgz" ;;
"hash") echo "http://mirrors.zhamao.xin/pecl/hash-$2.tgz" ;;
"inotify") echo "http://mirrors.zhamao.xin/pecl/inotify-$2.tgz" ;;
"redis") echo "http://mirrors.zhamao.xin/pecl/redis-$2.tgz" ;;
"libxml2") echo "https://dl.zhamao.me/libxml2/libxml2-$2.tar.gz" ;;
"liblzma") echo "https://dl.zhamao.me/liblzma/liblzma.tar.gz" ;;
"curl") echo "https://dl.zhamao.me/curl/curl-$2.tar.gz" ;;
*) echo "unknown" ;;
esac
fi
}
function lib_x_cmd() {
case $1 in
"php"|"swoole"|"hash"|"inotify"|"redis"|"libxml2"|"curl")
_x_cmd="tar"
;;
"liblzma") if [ "$_use_backup" = "yes" ]; then _x_cmd="unzip"; else _x_cmd="tar"; fi ;;
*) _x_cmd="unknown" ;;
esac
case $2 in
"cmd")
echo $_x_cmd
;;
"file-prefix")
case $_x_cmd in
"tar") echo "-zxvf" ;;
"unzip") echo "" ;;
esac
;;
"out-prefix")
case $_x_cmd in
"tar") echo "-C" ;;
"unzip") echo "-d" ;;
esac
;;
esac
}
function lib_x() {
$(lib_x_cmd $1 cmd) $(lib_x_cmd $1 file-prefix) "$_source_dir/$(lib_x_dirname $1 file)" $(lib_x_cmd $1 out-prefix) "$_source_dir/"
}
# 获取解压后的源码根目录
function lib_x_dirname() {
case $1 in
"php"|"swoole"|"hash"|"inotify"|"redis"|"libxml2"|"curl")
if [ "$2" = "file" ]; then _name_prefix=".tar.gz"; else _name_prefix=""; fi
echo "$1-$(lib_ver $1)$_name_prefix"
;;
"liblzma")
if [ "$_use_backup" = "yes" ]; then
if [ "$2" = "file" ]; then _name_prefix=".zip"; else _name_prefix=""; fi
echo "$1-$(lib_ver $1)$_name_prefix"
else
if [ "$2" = "file" ]; then _name_prefix=".tar.gz"; else _name_prefix=""; fi
echo "$1""$_name_prefix"
fi
;;
*)
echo "unknown"
;;
esac
}
download_file $(lib_download_link $1 $3) $(lib_x_firname $1 file)

3
ext-support.md Normal file
View File

@@ -0,0 +1,3 @@
# Extension List
See: [Docs - Extensions](https://static-php-cli.zhamao.me/en/guide/extensions.html)

View File

@@ -1,23 +0,0 @@
#!/bin/sh
_main_dir="$(pwd)/"
_build_dir="$_main_dir/build"
mkdir "$_build_dir" > /dev/null 2>&1
for loop in "7.2.34" "7.3.28" "7.4.19" "8.0.6"
do
sed -i 's/phpver"|"php") echo ".*/phpver"|"php") echo "'$loop'" ;;/g' "$_main_dir""static-compile-php.sh" && \
rm -rf "$_main_dir""source/php.tar.gz" "$_main_dir""source/php-*" "$_main_dir""php-dist" && \
"$_main_dir""static-compile-php.sh" && \
cp "$_main_dir""php-dist/bin/php" "$_build_dir/" && \
cd "$_build_dir/" && \
tar -zcvf "php-$loop-static-bin-"$(uname -m)".tar.gz" "./php" && \
mv "./php" "./php-$loop" && \
cd "$_main_dir"
if [ $? -ne 0 ]; then
echo "Compile static php-$loop failed!"
exit 1
fi
done

12
phpstan.neon Normal file
View File

@@ -0,0 +1,12 @@
parameters:
reportUnmatchedIgnoredErrors: false
level: 4
paths:
- ./src/
ignoreErrors:
- '#Constant .* not found#'
- '#Unsafe usage of new static#'
- '#class Fiber#'
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
dynamicConstantNames:
- PHP_OS_FAMILY

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace SPC;
use SPC\store\FileSystem;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\HelpCommand;
use Symfony\Component\Console\Command\ListCommand;
/**
* spc 应用究级入口
*/
class ConsoleApplication extends Application
{
public const VERSION = '2.0-rc5';
/**
* @throws \ReflectionException
* @throws exception\FileSystemException
*/
public function __construct()
{
parent::__construct('static-php-cli', self::VERSION);
global $argv;
// 生产环境不显示详细的调试错误,只使用 symfony console 自带的错误显示
$this->setCatchExceptions(file_exists(ROOT_DIR . '/.prod') || !in_array('--debug', $argv));
// 通过扫描目录 src/static-php-cli/command/ 添加子命令
$commands = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/command', 'SPC\\command');
$phar = class_exists('\\Phar') && \Phar::running() || !class_exists('\\Phar');
$commands = array_filter($commands, function ($y) use ($phar) {
$archive_blacklist = [
'SPC\command\dev\SortConfigCommand',
'SPC\command\DeployCommand',
];
if ($phar && in_array($y, $archive_blacklist)) {
return false;
}
$reflection = new \ReflectionClass($y);
return !$reflection->isAbstract() && !$reflection->isInterface();
});
$this->addCommands(array_map(function ($x) { return new $x(); }, $commands));
}
/**
* 重载以去除一些不必要的默认命令
*/
protected function getDefaultCommands(): array
{
return [new HelpCommand(), new ListCommand()];
}
}

View File

@@ -0,0 +1,299 @@
<?php
declare(strict_types=1);
namespace SPC\builder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\FileSystem;
use SPC\store\SourceExtractor;
use SPC\util\CustomExt;
use SPC\util\DependencyUtil;
abstract class BuilderBase
{
/** @var bool 是否启用 ZTS 线程安全 */
public bool $zts = false;
/** @var string 编译目标架构 */
public string $arch;
/** @var string GNU 格式的编译目标架构 */
public string $gnu_arch;
/** @var int 编译进程数 */
public int $concurrency = 1;
/** @var array<string, LibraryBase> 要编译的 libs 列表 */
protected array $libs = [];
/** @var array<string, Extension> 要编译的扩展列表 */
protected array $exts = [];
/** @var array<int, string> 要编译的扩展列表(仅名字列表,用于最后生成编译的扩展列表给 micro */
protected array $plain_extensions = [];
/** @var bool 本次编译是否只编译 libs不编译 PHP */
protected bool $libs_only = false;
/** @var bool 是否 strip 最终的二进制 */
protected bool $strip = true;
/**
* 构建指定列表的 libs
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildLibs(array $libraries): void
{
// 通过扫描目录查找 lib
$support_lib_list = [];
$classes = FileSystem::getClassesPsr4(
ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library',
'SPC\\builder\\' . osfamily2dir() . '\\library'
);
foreach ($classes as $class) {
if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) {
$support_lib_list[$class::NAME] = $class;
}
}
// 如果传入了空则默认检查和安置所有支持的liblibraries为要build的support_lib_list为支持的列表
if ($libraries === [] && $this->isLibsOnly()) {
$libraries = array_keys($support_lib_list);
}
if (!in_array('pkg-config', $libraries)) {
array_unshift($libraries, 'pkg-config');
}
// 排序 libs根据依赖计算一个新的列表出来
$libraries = DependencyUtil::getLibsByDeps($libraries);
// 过滤不支持的库后添加
foreach ($libraries as $library) {
if (!isset($support_lib_list[$library])) {
throw new RuntimeException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
}
$lib = new ($support_lib_list[$library])($this);
$this->addLib($lib);
}
// 计算依赖,经过这里的遍历,如果没有抛出异常,说明依赖符合要求,可以继续下面的
foreach ($this->libs as $lib) {
$lib->calcDependency();
}
SourceExtractor::initSource(libs: $libraries);
// 构建库
foreach ($this->libs as $lib) {
match ($lib->tryBuild()) {
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
};
}
}
/**
* 添加要编译的 Lib 库
*
* @param LibraryBase $library Lib 库对象
*/
public function addLib(LibraryBase $library): void
{
$this->libs[$library::NAME] = $library;
}
/**
* 获取要编译的 Lib 库对象
*
* @param string $name 库名称
*/
public function getLib(string $name): ?LibraryBase
{
return $this->libs[$name] ?? null;
}
/**
* 添加要编译的扩展
*
* @param Extension $extension 扩展对象
*/
public function addExt(Extension $extension): void
{
$this->exts[$extension->getName()] = $extension;
}
/**
* 获取要编译的扩展对象
*
* @param string $name 扩展名称
*/
public function getExt(string $name): ?Extension
{
return $this->exts[$name] ?? null;
}
/**
* 获取所有要编译的扩展对象
*
* @return Extension[]
*/
public function getExts(): array
{
return $this->exts;
}
/**
* 检查 C++ 扩展是否存在
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function hasCppExtension(): bool
{
// judge cpp-extension
$exts = array_keys($this->getExts());
$cpp = false;
foreach ($exts as $ext) {
if (Config::getExt($ext, 'cpp-extension', false) === true) {
$cpp = true;
break;
}
}
return $cpp;
}
/**
* 设置本次 Builder 是否为仅编译库的模式
*/
public function setLibsOnly(bool $status = true): void
{
$this->libs_only = $status;
}
/**
* 检验 ext 扩展列表是否合理,并声明 Extension 对象,检查扩展的依赖
*
* @throws FileSystemException
* @throws RuntimeException
* @throws \ReflectionException
* @throws WrongUsageException
*/
public function proveExts(array $extensions): void
{
CustomExt::loadCustomExt();
SourceExtractor::initSource(sources: ['php-src']);
if ($this->getPHPVersionID() >= 80000) {
SourceExtractor::initSource(sources: ['micro']);
}
SourceExtractor::initSource(exts: $extensions);
foreach ($extensions as $extension) {
$class = CustomExt::getExtClass($extension);
$ext = new $class($extension, $this);
$this->addExt($ext);
}
foreach ($this->exts as $ext) {
// 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理
$ext->checkDependency();
}
$this->plain_extensions = $extensions;
}
/**
* 开始构建 PHP
*
* @param int $build_target 规则
* @param bool $bloat 保留
*/
abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false);
/**
* 生成依赖的扩展编译启用参数
* 例如 --enable-mbstring 等
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function makeExtensionArgs(): string
{
$ret = [];
foreach ($this->exts as $ext) {
$ret[] = trim($ext->getConfigureArg());
}
logger()->info('Using configure: ' . implode(' ', $ret));
return implode(' ', $ret);
}
/**
* 返回是否只编译 libs 的模式
*/
public function isLibsOnly(): bool
{
return $this->libs_only;
}
/**
* 获取当前即将编译的 PHP 的版本 ID五位数那个
*/
public function getPHPVersionID(): int
{
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
preg_match('/PHP_VERSION_ID (\d+)/', $file, $match);
return intval($match[1]);
}
public function getBuildTypeName(int $type): string
{
$ls = [];
if (($type & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
$ls[] = 'cli';
}
if (($type & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
$ls[] = 'micro';
}
if (($type & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) {
$ls[] = 'fpm';
}
return implode(', ', $ls);
}
public function setStrip(bool $strip): void
{
$this->strip = $strip;
}
/**
* 检查是否存在 lib 库对应的源码,如果不存在,则抛出异常
*
* @throws RuntimeException
*/
protected function checkLibsSource(): void
{
$not_downloaded = [];
foreach ($this->libs as $lib) {
if (!file_exists($lib->getSourceDir())) {
$not_downloaded[] = $lib::NAME;
}
}
if ($not_downloaded !== []) {
throw new RuntimeException(
'"' . implode(', ', $not_downloaded) .
'" totally ' . count($not_downloaded) .
' source' . (count($not_downloaded) === 1 ? '' : 's') .
' not downloaded, maybe you need to "fetch" ' . (count($not_downloaded) === 1 ? 'it' : 'them') . ' first?'
);
}
}
}

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace SPC\builder;
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder;
use SPC\builder\windows\WindowsBuilder;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use Symfony\Component\Console\Input\InputInterface;
/**
* 用于生成对应系统环境的 Builder 对象的类
*/
class BuilderProvider
{
/**
* @throws RuntimeException
*/
public static function makeBuilderByInput(InputInterface $input): BuilderBase
{
return match (PHP_OS_FAMILY) {
// 'Windows' => new WindowsBuilder(
// binary_sdk_dir: $input->getOption('with-sdk-binary-dir'),
// vs_ver: $input->getOption('vs-ver'),
// arch: $input->getOption('arch'),
// ),
'Darwin' => new MacOSBuilder(
cc: $input->getOption('cc'),
cxx: $input->getOption('cxx'),
arch: $input->getOption('arch'),
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->hasOption('enable-zts') ? $input->getOption('enable-zts') : false,
),
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
};
}
}

View File

@@ -0,0 +1,225 @@
<?php
declare(strict_types=1);
namespace SPC\builder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
class Extension
{
protected array $dependencies = [];
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function __construct(protected string $name, protected BuilderBase $builder)
{
$ext_type = Config::getExt($this->name, 'type');
$unix_only = Config::getExt($this->name, 'unix-only', false);
$windows_only = Config::getExt($this->name, 'windows-only', false);
if (PHP_OS_FAMILY !== 'Windows' && $windows_only) {
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Linux and macOS platform");
}
if (PHP_OS_FAMILY === 'Windows' && $unix_only) {
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Windows platform");
}
}
/**
* 获取开启该扩展的 PHP 编译添加的参数
*
* @throws FileSystemException|RuntimeException
* @throws WrongUsageException
*/
public function getConfigureArg(): string
{
$arg = $this->getEnableArg();
switch (PHP_OS_FAMILY) {
case 'Windows':
$arg = $this->getWindowsConfigureArg();
break;
case 'Darwin':
case 'Linux':
$arg .= $this->getUnixConfigureArg();
break;
}
return $arg;
}
/**
* 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function getEnableArg(): string
{
$_name = str_replace('_', '-', $this->name);
return match ($arg_type = Config::getExt($this->name, 'arg-type', 'enable')) {
'enable' => '--enable-' . $_name . ' ',
'with' => '--with-' . $_name . ' ',
'with-prefix' => '--with-' . $_name . '="' . BUILD_ROOT_PATH . '" ',
'none', 'custom' => '',
default => throw new WrongUsageException("argType does not accept {$arg_type}, use [enable/with/with-prefix] ."),
};
}
/**
* 导出当前扩展依赖的所有 lib 库生成的 .a 静态编译库文件,以字符串形式导出,用空格分割
*/
public function getLibFilesString(): string
{
$ret = array_map(
fn ($x) => $x->getStaticLibFiles(),
$this->getLibraryDependencies(recursive: true)
);
return implode(' ', $ret);
}
/**
* 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function checkDependency(): static
{
foreach (Config::getExt($this->name, 'lib-depends', []) as $name) {
$this->addLibraryDependency($name);
}
foreach (Config::getExt($this->name, 'lib-suggests', []) as $name) {
$this->addLibraryDependency($name, true);
}
foreach (Config::getExt($this->name, 'ext-depends', []) as $name) {
$this->addExtensionDependency($name);
}
foreach (Config::getExt($this->name, 'ext-suggests', []) as $name) {
$this->addExtensionDependency($name, true);
}
return $this;
}
public function getExtensionDependency(): array
{
return array_filter($this->dependencies, fn ($x) => $x instanceof Extension);
}
public function getName(): string
{
return $this->name;
}
/**
* returns extension dist name
*/
public function getDistName(): string
{
return $this->name;
}
public function getWindowsConfigureArg(): string
{
return '';
// Windows is not supported yet
}
public function getUnixConfigureArg(): string
{
return '';
}
/**
* Patch code before ./buildconf
* If you need to patch some code, overwrite this and return true
*/
public function patchBeforeBuildconf(): bool
{
return false;
}
/**
* Patch code before ./configure
* If you need to patch some code, overwrite this and return true
*/
public function patchBeforeConfigure(): bool
{
return false;
}
/**
* Patch code before make
* If you need to patch some code, overwrite this and return true
*/
public function patchBeforeMake(): bool
{
return false;
}
/**
* @throws RuntimeException
*/
protected function addLibraryDependency(string $name, bool $optional = false): void
{
$depLib = $this->builder->getLib($name);
if (!$depLib) {
if (!$optional) {
throw new RuntimeException("extension {$this->name} requires library {$name}");
}
logger()->info("enabling {$this->name} without library {$name}");
} else {
$this->dependencies[] = $depLib;
}
}
/**
* @throws RuntimeException
*/
protected function addExtensionDependency(string $name, bool $optional = false): void
{
$depExt = $this->builder->getExt($name);
if (!$depExt) {
if (!$optional) {
throw new RuntimeException("{$this->name} requires extension {$name}");
}
logger()->info("enabling {$this->name} without extension {$name}");
} else {
$this->dependencies[] = $depExt;
}
}
private function getLibraryDependencies(bool $recursive = false): array
{
$ret = array_filter($this->dependencies, fn ($x) => $x instanceof LibraryBase);
if (!$recursive) {
return $ret;
}
$deps = [];
$added = 1;
while ($added !== 0) {
$added = 0;
foreach ($ret as $depName => $dep) {
foreach ($dep->getDependencies(true) as $depdepName => $depdep) {
if (!in_array($depdepName, array_keys($deps), true)) {
$deps[$depdepName] = $depdep;
++$added;
}
}
if (!in_array($depName, array_keys($deps), true)) {
$deps[$depName] = $dep;
}
}
}
return $deps;
}
}

View File

@@ -0,0 +1,206 @@
<?php
declare(strict_types=1);
namespace SPC\builder;
use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\Config;
/**
* Lib 库的基类操作对象
*/
abstract class LibraryBase
{
/** @var string lib 依赖名称,必须重写 */
public const NAME = 'unknown';
/** @var string lib 依赖的根目录 */
protected string $source_dir;
/** @var array 依赖列表 */
protected array $dependencies = [];
/**
* @throws RuntimeException
*/
public function __construct(?string $source_dir = null)
{
if (static::NAME === 'unknown') {
throw new RuntimeException('no unknown!!!!!');
}
$this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . static::NAME);
}
/**
* 获取 lib 库的根目录
*/
public function getSourceDir(): string
{
return $this->source_dir;
}
/**
* 获取当前 lib 库的所有依赖列表
*
* @param bool $recursive 是否递归获取(默认为 False
* @return array<string, LibraryBase> 依赖的 Map
*/
public function getDependencies(bool $recursive = false): array
{
// 非递归情况下直接返回通过 addLibraryDependency 方法添加的依赖
if (!$recursive) {
return $this->dependencies;
}
// 下面为递归获取依赖列表,根据依赖顺序
$deps = [];
$added = 1;
while ($added !== 0) {
$added = 0;
foreach ($this->dependencies as $depName => $dep) {
foreach ($dep->getDependencies(true) as $depdepName => $depdep) {
if (!in_array($depdepName, array_keys($deps), true)) {
$deps[$depdepName] = $depdep;
++$added;
}
}
if (!in_array($depName, array_keys($deps), true)) {
$deps[$depName] = $dep;
}
}
}
return $deps;
}
/**
* 计算依赖列表,不符合依赖将抛出异常
*
* @throws RuntimeException
* @throws FileSystemException
*/
public function calcDependency(): void
{
// 先从配置文件添加依赖,这里根据不同的操作系统分别选择不同的元信息
/*
选择规则:
如果是 Windows 系统,则依次尝试有无 lib-depends-windows、lib-depends-win、lib-depends。
如果是 macOS 系统,则依次尝试 lib-depends-darwin、lib-depends-unix、lib-depends。
如果是 Linux 系统,则依次尝试 lib-depends-linux、lib-depends-unix、lib-depends。
*/
foreach (Config::getLib(static::NAME, 'lib-depends', []) as $dep_name) {
$this->addLibraryDependency($dep_name);
}
foreach (Config::getLib(static::NAME, 'lib-suggests', []) as $dep_name) {
$this->addLibraryDependency($dep_name, true);
}
}
/**
* 获取当前库编译出来获取到的静态库文件列表
*
* @return string[] 获取编译出来后的需要的静态库文件列表
* @throws FileSystemException
* @throws RuntimeException
*/
public function getStaticLibs(): array
{
return Config::getLib(static::NAME, 'static-libs', []);
}
/**
* 获取当前 lib 编译出来的 C Header 文件列表
*
* @return string[] 获取编译出来后需要的 C Header 文件列表
* @throws FileSystemException
* @throws RuntimeException
*/
public function getHeaders(): array
{
return Config::getLib(static::NAME, 'headers', []);
}
/**
* 证明该库是否已编译好且就绪,如果没有就绪,内部会调用 build 来进行构建该库
*
* @throws RuntimeException
* @throws FileSystemException
*/
public function tryBuild(bool $force_build = false): int
{
// 传入 true表明直接编译
if ($force_build) {
logger()->info('Building required library [' . static::NAME . ']');
$this->patchBeforeBuild();
$this->build();
return BUILD_STATUS_OK;
}
// 看看这些库是不是存在,如果不存在,则调用编译并返回结果状态
foreach ($this->getStaticLibs() as $name) {
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
}
// 头文件同理
foreach ($this->getHeaders() as $name) {
if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
}
// pkg-config 做特殊处理,如果是 pkg-config 就检查有没有 pkg-config 二进制
if ($this instanceof MacOSLibraryBase && static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
// 到这里说明所有的文件都存在,就跳过编译
return BUILD_STATUS_ALREADY;
}
/**
* Patch before build, overwrite this and return true to patch libs
*/
public function patchBeforeBuild(): bool
{
return false;
}
/**
* 获取构建当前 lib 的 Builder 对象
*/
abstract public function getBuilder(): BuilderBase;
/**
* 构建该库需要调用的命令和操作
*
* @throws RuntimeException
*/
abstract protected function build();
/**
* 添加 lib 库的依赖库
*
* @param string $name 依赖名称
* @param bool $optional 是否是可选依赖(默认为 False
* @throws RuntimeException
*/
protected function addLibraryDependency(string $name, bool $optional = false): void
{
// Log::i("add $name as dep of {$this->name}");
$dep_lib = $this->getBuilder()->getLib($name);
if (!$dep_lib) {
if (!$optional) {
throw new RuntimeException(static::NAME . " requires library {$name}");
}
logger()->debug('enabling ' . static::NAME . " without {$name}");
} else {
$this->dependencies[$name] = $dep_lib;
}
}
}

View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace SPC\builder;
interface LibraryInterface
{
public function getName(): string;
}

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('bz2')]
class bz2 extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, '/-lbz2/', $this->getLibFilesString() . $frameworks);
return true;
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('curl')]
class curl extends Extension
{
public function patchBeforeBuildconf(): bool
{
logger()->info('patching before-configure for curl checks');
$file1 = "AC_DEFUN([PHP_CHECK_LIBRARY], [\n $3\n])";
$files = FileSystem::readFile(SOURCE_PATH . '/php-src/ext/curl/config.m4');
$file2 = 'AC_DEFUN([PHP_CHECK_LIBRARY], [
save_old_LDFLAGS=$LDFLAGS
ac_stuff="$5"
save_ext_shared=$ext_shared
ext_shared=yes
PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
AC_CHECK_LIB([$1],[$2],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
$3
],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
unset ac_cv_lib_$1[]_$2
$4
])dnl
])';
file_put_contents(SOURCE_PATH . '/php-src/ext/curl/config.m4', $file1 . "\n" . $files . "\n" . $file2);
return true;
}
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, '/-lcurl/', $this->getLibFilesString() . $frameworks);
return true;
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('enchant')]
class enchant extends Extension
{
public function getUnixConfigureArg(): string
{
$glibs = [
'/Users/jerry/project/git-project/static-php-cli/buildroot/lib/libgio-2.0.a',
'/Users/jerry/project/git-project/static-php-cli/buildroot/lib/libglib-2.0.a',
'/Users/jerry/project/git-project/static-php-cli/buildroot/lib/libgmodule-2.0.a',
'/Users/jerry/project/git-project/static-php-cli/buildroot/lib/libgobject-2.0.a',
'/Users/jerry/project/git-project/static-php-cli/buildroot/lib/libgthread-2.0.a',
'/Users/jerry/project/git-project/static-php-cli/buildroot/lib/libintl.a',
];
$arg = '--with-enchant="' . BUILD_ROOT_PATH . '"';
$arg .= ' ENCHANT2_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '/enchant-2"';
$arg .= ' ENCHANT2_LIBS="' . $this->getLibFilesString() . '"';
$arg .= ' GLIB_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '"';
$arg .= ' GLIB_LIBS="' . implode(' ', $glibs) . '"';
return $arg;
}
}

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('event')]
class event extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = '--with-event-core --with-event-extra --with-event-libevent-dir=' . BUILD_ROOT_PATH;
if ($this->builder->getLib('openssl')) {
$arg .= ' --with-event-openssl=' . BUILD_ROOT_PATH;
}
if ($this->builder->getExt('sockets')) {
$arg .= ' --enable-event-sockets';
} else {
$arg .= ' --disable-event-sockets';
}
return $arg;
}
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/php-src/configure',
REPLACE_FILE_PREG,
'/-levent_openssl/',
$this->getLibFilesString()
);
return true;
}
}

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('ffi')]
class ffi extends Extension
{
public function getUnixConfigureArg(): string
{
return '--with-ffi --enable-zend-signals';
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('gd')]
class gd extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = '--enable-gd';
$arg .= $this->builder->getLib('freetype') ? ' --with-freetype' : '';
$arg .= $this->builder->getLib('libjpeg') ? ' --with-jpeg' : '';
$arg .= $this->builder->getLib('libwebp') ? ' --with-webp' : '';
$arg .= $this->builder->getLib('libavif') ? ' --with-avif' : '';
return $arg;
}
}

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('glfw')]
class glfw extends Extension
{
public function patchBeforeBuildconf(): bool
{
FileSystem::copyDir(SOURCE_PATH . '/ext-glfw', SOURCE_PATH . '/php-src/ext/glfw');
return true;
}
public function getUnixConfigureArg(): string
{
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
}
}

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('imagick')]
class imagick extends Extension
{
public function getUnixConfigureArg(): string
{
return '--with-imagick=' . BUILD_ROOT_PATH;
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('mbregex')]
class mbregex extends Extension
{
public function getDistName(): string
{
return 'mbstring';
}
public function getConfigureArg(): string
{
return '';
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('mbstring')]
class mbstring extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = '--enable-mbstring';
if ($this->builder->getExt('mbregex') === null) {
$arg .= ' --disable-mbregex';
}
return $arg;
}
}

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('memcache')]
class memcache extends Extension
{
public function getUnixConfigureArg(): string
{
return '--enable-memcache --with-zlib-dir=' . BUILD_ROOT_PATH;
}
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
REPLACE_FILE_STR,
'if test -d $abs_srcdir/src ; then',
'if test -d $abs_srcdir/main ; then'
);
FileSystem::replaceFile(
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
REPLACE_FILE_STR,
'export CPPFLAGS="$CPPFLAGS $INCLUDES"',
'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"'
);
// add for in-tree building
file_put_contents(
SOURCE_PATH . '/php-src/ext/memcache/php_memcache.h',
<<<'EOF'
#ifndef PHP_MEMCACHE_H
#define PHP_MEMCACHE_H
extern zend_module_entry memcache_module_entry;
#define phpext_memcache_ptr &memcache_module_entry
#endif
EOF
);
return true;
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('memcached')]
class memcached extends Extension
{
public function getUnixConfigureArg(): string
{
$rootdir = BUILD_ROOT_PATH;
return "--enable-memcached --with-zlib-dir={$rootdir} --with-libmemcached-dir={$rootdir} --disable-memcached-sasl --enable-memcached-json";
}
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('mongodb')]
class mongodb extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = ' --enable-mongodb ';
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';
$arg .= ' --with-mongodb-sasl=no ';
if ($this->builder->getLib('openssl')) {
$arg .= '--with-mongodb-ssl=openssl';
}
$arg .= $this->builder->getLib('icu') ? ' --with-mongodb-icu=yes ' : ' --with-mongodb-icu=no ';
$arg .= $this->builder->getLib('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no ';
// $arg .= $this->builder->getLib('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no ';
$arg .= $this->builder->getLib('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled ';
return $arg;
}
}

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('opcache')]
class opcache extends Extension
{
public function getDistName(): string
{
return 'Zend Opcache';
}
}

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
use SPC\util\Util;
#[CustomExt('openssl')]
class openssl extends Extension
{
public function patchBeforeMake(): bool
{
// patch openssl3 with php8.0 bug
if (file_exists(SOURCE_PATH . '/openssl/VERSION.dat') && Util::getPHPVersionID() < 80100) {
$openssl_c = file_get_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c');
$openssl_c = preg_replace('/REGISTER_LONG_CONSTANT\s*\(\s*"OPENSSL_SSLV23_PADDING"\s*.+;/', '', $openssl_c);
file_put_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c', $openssl_c);
return true;
}
return false;
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('pdo_sqlite')]
class pdo_sqlite extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/php-src/configure',
REPLACE_FILE_PREG,
'/sqlite3_column_table_name=yes/',
'sqlite3_column_table_name=no'
);
return true;
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('pgsql')]
class pgsql extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/php-src/configure',
REPLACE_FILE_PREG,
'/-lpq/',
$this->getLibFilesString()
);
return true;
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('readline')]
class readline extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/php-src/configure',
REPLACE_FILE_PREG,
'/-lncurses/',
$this->getLibFilesString()
);
return true;
}
}

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('redis')]
class redis extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = '--enable-redis';
if (!$this->builder->getExt('session')) {
$arg .= ' --disable-redis-session';
} else {
$arg .= ' --enable-redis-session';
}
if ($this->builder->getLib('zstd')) {
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
}
return $arg;
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('ssh2')]
class ssh2 extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/php-src/configure',
REPLACE_FILE_PREG,
'/-lssh2/',
$this->getLibFilesString()
);
return true;
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('swoole')]
class swoole extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = '--enable-swoole';
$arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl';
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
// curl hook is buggy for static php
$arg .= ' --disable-swoole-curl';
return $arg;
}
}

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
use SPC\util\Util;
#[CustomExt('swow')]
class swow extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = '--enable-swow';
$arg .= $this->builder->getLib('openssl') ? ' --enable-swow-ssl' : ' --disable-swow-ssl';
$arg .= $this->builder->getLib('curl') ? ' --enable-swow-curl' : ' --disable-swow-curl';
return $arg;
}
public function patchBeforeBuildconf(): bool
{
if (Util::getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) {
if (PHP_OS_FAMILY === 'Windows') {
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D swow swow-src\ext');
} else {
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && ln -s swow-src/ext swow');
}
return true;
}
return false;
}
}

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('xlswriter')]
class xlswriter extends Extension
{
public function getUnixConfigureArg(): string
{
return '--with-xlswriter --enable-reader';
}
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\util\CustomExt;
#[CustomExt('xml')]
#[CustomExt('soap')]
#[CustomExt('xmlreader')]
#[CustomExt('xmlwriter')]
#[CustomExt('dom')]
#[CustomExt('simplexml')]
class xml extends Extension
{
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(): string
{
$arg = match ($this->name) {
'xml' => '--enable-xml',
'soap' => '--enable-soap',
'xmlreader' => '--enable-xmlreader',
'xmlwriter' => '--enable-xmlwriter',
'dom' => '--enable-dom',
'simplexml' => '--enable-simplexml',
default => throw new RuntimeException('Not accept non-xml extension'),
};
$arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"';
return $arg;
}
}

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('zstd')]
class zstd extends Extension
{
public function getUnixConfigureArg(): string
{
return '--enable-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
}
}

View File

@@ -0,0 +1,312 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux;
use SPC\builder\BuilderBase;
use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\builder\traits\UnixBuilderTrait;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\SourcePatcher;
/**
* Linux 系统环境下的构建器
*/
class LinuxBuilder extends BuilderBase
{
/** 编译的 Unix 工具集 */
use UnixBuilderTrait;
/** @var string[] Linux 环境下编译依赖的命令 */
public const REQUIRED_COMMANDS = ['make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', /* 'xz', 好像不需要 */ 'gzip', 'bzip2', 'cmake'];
/** @var string 使用的 libc */
public string $libc;
/** @var array 特殊架构下的 cflags */
public array $tune_c_flags;
/** @var string pkg-config 环境变量 */
public string $pkgconf_env;
/** @var string 交叉编译变量 */
public string $cross_compile_prefix = '';
public string $note_section = "Je pense, donc je suis\0";
private bool $phar_patched = false;
/**
* @throws RuntimeException
* @throws WrongUsageException
*/
public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null, bool $zts = false)
{
// 初始化一些默认参数
$this->cc = $cc ?? match (SystemUtil::getOSRelease()['dist']) {
'alpine' => 'gcc',
default => 'musl-gcc'
};
$this->cxx = $cxx ?? 'g++';
$this->arch = $arch ?? php_uname('m');
$this->gnu_arch = arch2gnu($this->arch);
$this->zts = $zts;
$this->libc = 'musl'; // SystemUtil::selectLibc($this->cc);
// 根据 CPU 线程数设置编译进程数
$this->concurrency = SystemUtil::getCpuCount();
// 设置 cflags
$this->arch_c_flags = SystemUtil::getArchCFlags($this->cc, $this->arch);
$this->arch_cxx_flags = SystemUtil::getArchCFlags($this->cxx, $this->arch);
$this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->arch), $this->cc);
// 设置 cmake
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(
os: 'Linux',
target_arch: $this->arch,
cflags: $this->arch_c_flags,
cc: $this->cc,
cxx: $this->cxx
);
// 设置 pkgconfig
$this->pkgconf_env = 'PKG_CONFIG="' . BUILD_ROOT_PATH . '/bin/pkg-config" PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig"';
// 设置 configure 依赖的环境变量
$this->configure_env =
$this->pkgconf_env . ' ' .
"CC='{$this->cc}' " .
"CXX='{$this->cxx}' " .
(php_uname('m') === $this->arch ? '' : "CFLAGS='{$this->arch_c_flags}'");
// 交叉编译依赖的TODO
if (php_uname('m') !== $this->arch) {
$this->cross_compile_prefix = SystemUtil::getCrossCompilePrefix($this->cc, $this->arch);
logger()->info('using cross compile prefix: ' . $this->cross_compile_prefix);
$this->configure_env .= " CROSS_COMPILE='{$this->cross_compile_prefix}'";
}
$missing = [];
foreach (self::REQUIRED_COMMANDS as $cmd) {
if (SystemUtil::findCommand($cmd) === null) {
$missing[] = $cmd;
}
}
if (!empty($missing)) {
throw new WrongUsageException('missing system commands: ' . implode(', ', $missing));
}
// 创立 pkg-config 和放头文件的目录
f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true);
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
}
public function makeAutoconfArgs(string $name, array $libSpecs): string
{
$ret = '';
foreach ($libSpecs as $libName => $arr) {
$lib = $this->getLib($libName);
$arr = $arr ?? [];
$disableArgs = $arr[0] ?? null;
$prefix = $arr[1] ?? null;
if ($lib instanceof LinuxLibraryBase) {
logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support");
$ret .= $lib->makeAutoconfEnv($prefix) . ' ';
} else {
logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support");
$ret .= ($disableArgs ?? "--with-{$libName}=no") . ' ';
}
}
return rtrim($ret);
}
/**
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $with_clean = false, bool $bloat = false)
{
if (!$bloat) {
$extra_libs = implode(' ', $this->getAllStaticLibFiles());
} else {
logger()->info('bloat linking');
$extra_libs = implode(
' ',
array_map(
fn ($x) => "-Xcompiler {$x}",
array_filter($this->getAllStaticLibFiles())
)
);
}
if ($this->hasCppExtension()) {
$extra_libs .= ' -lstdc++';
}
if ($this->getExt('imagick')) {
$extra_libs .= ' /usr/lib/libMagick++-7.Q16HDRI.a /usr/lib/libMagickCore-7.Q16HDRI.a /usr/lib/libMagickWand-7.Q16HDRI.a';
}
$envs = $this->pkgconf_env . ' ' .
"CC='{$this->cc}' " .
"CXX='{$this->cxx}' ";
$cflags = $this->arch_c_flags;
$use_lld = '';
switch ($this->libc) {
case 'musl_wrapper':
case 'glibc':
$cflags .= ' -static-libgcc -I"' . BUILD_INCLUDE_PATH . '"';
break;
case 'musl':
if (str_ends_with($this->cc, 'clang') && SystemUtil::findCommand('lld')) {
$use_lld = '-Xcompiler -fuse-ld=lld';
}
break;
default:
throw new WrongUsageException('libc ' . $this->libc . ' is not implemented yet');
}
$envs = "{$envs} CFLAGS='{$cflags}' LIBS='-ldl -lpthread'";
SourcePatcher::patchBeforeBuildconf($this);
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
SourcePatcher::patchBeforeConfigure($this);
if ($this->getPHPVersionID() < 80000) {
$json_74 = '--enable-json ';
} else {
$json_74 = '';
}
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
'./configure ' .
'--prefix= ' .
'--with-valgrind=no ' .
'--enable-shared=no ' .
'--enable-static=yes ' .
'--disable-all ' .
'--disable-cgi ' .
'--disable-phpdbg ' .
'--enable-cli ' .
'--enable-fpm ' .
$json_74 .
'--enable-micro=all-static ' .
($this->zts ? '--enable-zts' : '') . ' ' .
$this->makeExtensionArgs() . ' ' .
$envs
);
SourcePatcher::patchBeforeMake($this);
file_put_contents('/tmp/comment', $this->note_section);
// 清理
$this->cleanMake();
if ($bloat) {
logger()->info('bloat linking');
$extra_libs = "-Wl,--whole-archive {$extra_libs} -Wl,--no-whole-archive";
}
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
logger()->info('building cli');
$this->buildCli($extra_libs, $use_lld);
}
if (($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) {
logger()->info('building fpm');
$this->buildFpm($extra_libs, $use_lld);
}
if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
logger()->info('building micro');
$this->buildMicro($extra_libs, $use_lld, $cflags);
}
if (php_uname('m') === $this->arch) {
$this->sanityCheck($build_target);
}
if ($this->phar_patched) {
SourcePatcher::patchMicro(['phar'], true);
}
}
/**
* @throws RuntimeException
*/
public function buildCli(string $extra_libs, string $use_lld): void
{
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec(
'make -j' . $this->concurrency .
' EXTRA_CFLAGS="-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . '" ' .
"EXTRA_LIBS=\"{$extra_libs}\" " .
"EXTRA_LDFLAGS_PROGRAM='{$use_lld} -all-static' " .
'cli'
);
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')
->exec("{$this->cross_compile_prefix}objcopy --only-keep-debug php php.debug")
->exec('elfedit --output-osabi linux php')
->exec("{$this->cross_compile_prefix}strip --strip-all php")
->exec("{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=php.debug --remove-section=.note php");
$this->deployBinary(BUILD_TARGET_CLI);
}
/**
* @throws RuntimeException
*/
public function buildMicro(string $extra_libs, string $use_lld, string $cflags): void
{
if ($this->getPHPVersionID() < 80000) {
throw new RuntimeException('phpmicro only support PHP >= 8.0!');
}
if ($this->getExt('phar')) {
$this->phar_patched = true;
SourcePatcher::patchMicro(['phar']);
}
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec(
"make -j{$this->concurrency} " .
'EXTRA_CFLAGS=' . quote('-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags))) . ' ' .
'EXTRA_LIBS=' . quote($extra_libs) . ' ' .
'EXTRA_LDFLAGS_PROGRAM=' . quote("{$cflags} {$use_lld}" . ' -all-static', "'") . ' ' .
'micro'
);
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec("{$this->cross_compile_prefix}strip --strip-all micro.sfx");
$this->deployBinary(BUILD_TARGET_MICRO);
}
/**
* 构建 fpm
*
* @throws FileSystemException|RuntimeException
*/
public function buildFpm(string $extra_libs, string $use_lld): void
{
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec(
'make -j' . $this->concurrency .
' EXTRA_CFLAGS="-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . '" ' .
"EXTRA_LIBS=\"{$extra_libs}\" " .
"EXTRA_LDFLAGS_PROGRAM='{$use_lld} -all-static' " .
'fpm'
);
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')
->exec("{$this->cross_compile_prefix}objcopy --only-keep-debug php-fpm php-fpm.debug")
->exec('elfedit --output-osabi linux php-fpm')
->exec("{$this->cross_compile_prefix}strip --strip-all php-fpm")
->exec("{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=php-fpm.debug --remove-section=.note php-fpm");
$this->deployBinary(BUILD_TARGET_FPM);
}
}

View File

@@ -0,0 +1,203 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux;
use JetBrains\PhpStorm\ArrayShape;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
class SystemUtil
{
use UnixSystemUtilTrait;
#[ArrayShape(['dist' => 'mixed|string', 'ver' => 'mixed|string'])]
public static function getOSRelease(): array
{
$ret = [
'dist' => 'unknown',
'ver' => 'unknown',
];
switch (true) {
case file_exists('/etc/os-release'):
$lines = file('/etc/os-release');
foreach ($lines as $line) {
if (preg_match('/^ID=(.*)$/', $line, $matches)) {
$ret['dist'] = $matches[1];
}
if (preg_match('/^VERSION_ID=(.*)$/', $line, $matches)) {
$ret['ver'] = $matches[1];
}
}
$ret['dist'] = trim($ret['dist'], '"\'');
$ret['ver'] = trim($ret['ver'], '"\'');
if (strcasecmp($ret['dist'], 'centos') === 0) {
$ret['dist'] = 'redhat';
}
break;
case file_exists('/etc/centos-release'):
$lines = file('/etc/centos-release');
goto rh;
case file_exists('/etc/redhat-release'):
$lines = file('/etc/redhat-release');
rh:
foreach ($lines as $line) {
if (preg_match('/release\s+(\d+(\.\d+)*)/', $line, $matches)) {
$ret['dist'] = 'redhat';
$ret['ver'] = $matches[1];
}
}
break;
}
return $ret;
}
public static function getCpuCount(): int
{
$ncpu = 1;
if (is_file('/proc/cpuinfo')) {
$cpuinfo = file_get_contents('/proc/cpuinfo');
preg_match_all('/^processor/m', $cpuinfo, $matches);
$ncpu = count($matches[0]);
}
return $ncpu;
}
/**
* @throws RuntimeException
*/
public static function getCCType(string $cc): string
{
return match (true) {
str_ends_with($cc, 'c++'), str_ends_with($cc, 'cc'), str_ends_with($cc, 'g++'), str_ends_with($cc, 'gcc') => 'gcc',
$cc === 'clang++', $cc === 'clang', str_starts_with($cc, 'musl-clang') => 'clang',
default => throw new RuntimeException("unknown cc type: {$cc}"),
};
}
/**
* @throws RuntimeException
*/
public static function getArchCFlags(string $cc, string $arch): string
{
if (php_uname('m') === $arch) {
return '';
}
return match (static::getCCType($cc)) {
'clang' => match ($arch) {
'x86_64' => '--target=x86_64-unknown-linux',
'arm64', 'aarch64' => '--target=arm64-unknown-linux',
default => throw new WrongUsageException('unsupported arch: ' . $arch),
},
'gcc' => '',
default => throw new WrongUsageException('cc compiler ' . $cc . ' is not supported'),
};
}
/**
* @throws RuntimeException
*/
public static function getTuneCFlags(string $arch): array
{
return match ($arch) {
'x86_64' => [
'-march=corei7',
'-mtune=core-avx2',
],
'arm64', 'aarch64' => [],
default => throw new RuntimeException('unsupported arch: ' . $arch),
};
}
public static function checkCCFlags(array $flags, string $cc): array
{
return array_filter($flags, fn ($flag) => static::checkCCFlag($flag, $cc));
}
public static function checkCCFlag(string $flag, string $cc): string
{
[$ret] = shell()->execWithResult("echo | {$cc} -E -x c - {$flag}");
if ($ret != 0) {
return '';
}
return $flag;
}
/**
* @throws RuntimeException
*/
public static function getCrossCompilePrefix(string $cc, string $arch): string
{
return match (static::getCCType($cc)) {
// guessing clang toolchains
'clang' => match ($arch) {
'x86_64' => 'x86_64-linux-gnu-',
'arm64', 'aarch64' => 'aarch64-linux-gnu-',
default => throw new RuntimeException('unsupported arch: ' . $arch),
},
// remove gcc postfix
'gcc' => str_replace('-cc', '', str_replace('-gcc', '', $cc)) . '-',
default => throw new RuntimeException('unsupported cc'),
};
}
public static function findStaticLib(string $name): ?array
{
$paths = getenv('LIBPATH');
if (!$paths) {
$paths = '/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64:';
}
foreach (explode(':', $paths) as $path) {
if (file_exists("{$path}/{$name}")) {
return ["{$path}", "{$name}"];
}
}
return null;
}
public static function findStaticLibs(array $names): ?array
{
$ret = [];
foreach ($names as $name) {
$path = static::findStaticLib($name);
if (!$path) {
logger()->warning("static library {$name} not found");
return null;
}
$ret[] = $path;
}
return $ret;
}
public static function findHeader(string $name): ?array
{
$paths = getenv('INCLUDEPATH');
if (!$paths) {
$paths = '/include:/usr/include:/usr/local/include';
}
foreach (explode(':', $paths) as $path) {
if (file_exists("{$path}/{$name}") || is_dir("{$path}/{$name}")) {
return ["{$path}", "{$name}"];
}
}
return null;
}
public static function findHeaders(array $names): ?array
{
$ret = [];
foreach ($names as $name) {
$path = static::findHeader($name);
if (!$path) {
logger()->warning("header {$name} not found");
return null;
}
$ret[] = $path;
}
return $ret;
}
}

View File

@@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\builder\BuilderBase;
use SPC\builder\LibraryBase;
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\traits\UnixLibraryTrait;
use SPC\exception\RuntimeException;
abstract class LinuxLibraryBase extends LibraryBase
{
use UnixLibraryTrait;
protected array $static_libs = [];
protected array $headers;
protected array $pkgconfs;
/**
* 依赖的名字及是否可选例如curl => true代表依赖 curl 但可选
*/
protected array $dep_names;
public function __construct(protected LinuxBuilder $builder)
{
parent::__construct();
}
public function getBuilder(): BuilderBase
{
return $this->builder;
}
/**
* @throws RuntimeException
*/
public function tryBuild(bool $force_build = false): int
{
// 传入 true表明直接编译
if ($force_build) {
logger()->info('Building required library [' . static::NAME . ']');
$this->patchBeforeBuild();
$this->build();
return BUILD_STATUS_OK;
}
// 看看这些库是不是存在,如果不存在,则调用编译并返回结果状态
foreach ($this->getStaticLibs() as $name) {
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
}
// 头文件同理
foreach ($this->getHeaders() as $name) {
if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
}
// pkg-config 做特殊处理,如果是 pkg-config 就检查有没有 pkg-config 二进制
if (static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
// 到这里说明所有的文件都存在,就跳过编译
return BUILD_STATUS_ALREADY;
}
protected function makeFakePkgconfs()
{
$workspace = BUILD_ROOT_PATH;
if ($workspace === '/') {
$workspace = '';
}
foreach ($this->pkgconfs as $name => $content) {
file_put_contents(BUILD_LIB_PATH . "/pkgconfig/{$name}", "prefix={$workspace}\n" . $content);
}
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class brotli extends LinuxLibraryBase
{
use \SPC\builder\unix\library\brotli;
public const NAME = 'brotli';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class bzip2 extends LinuxLibraryBase
{
use \SPC\builder\unix\library\bzip2;
public const NAME = 'bzip2';
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class curl extends LinuxLibraryBase
{
use \SPC\builder\unix\library\curl;
public const NAME = 'curl';
public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string
{
$libs = parent::getStaticLibFiles($style, $recursive);
if ($this->builder->getLib('openssl')) {
$libs .= ' -ldl -lpthread';
}
return $libs;
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class freetype extends LinuxLibraryBase
{
use \SPC\builder\unix\library\freetype;
public const NAME = 'freetype';
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
/**
* gmp is a template library class for unix
*/
class gmp extends LinuxLibraryBase
{
use \SPC\builder\unix\library\gmp;
public const NAME = 'gmp';
}

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

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
/**
* a template library class for unix
*/
class imagemagick extends LinuxLibraryBase
{
use \SPC\builder\unix\library\imagemagick;
public const NAME = 'imagemagick';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libavif extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libavif;
public const NAME = 'libavif';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libevent extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libevent;
public const NAME = 'libevent';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libiconv extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libiconv;
public const NAME = 'libiconv';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libjpeg extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libjpeg;
public const NAME = 'libjpeg';
}

View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\exception\RuntimeException;
/**
* gmp is a template library class for unix
*/
class libmemcached extends LinuxLibraryBase
{
public const NAME = 'libmemcached';
public function build()
{
throw new RuntimeException('libmemcached is currently not supported on Linux platform');
}
}

View File

@@ -0,0 +1,83 @@
<?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;
use SPC\store\FileSystem;
class libpng extends LinuxLibraryBase
{
public const NAME = 'libpng';
public function patchBeforeBuild(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/libpng/configure',
REPLACE_FILE_STR,
'-lz',
BUILD_LIB_PATH . '/libz.a'
);
if (SystemUtil::getOSRelease()['dist'] === 'alpine') {
FileSystem::replaceFile(
SOURCE_PATH . '/libpng/configure',
REPLACE_FILE_STR,
'-lm',
'/usr/lib/libm.a'
);
}
return true;
}
/**
* @throws RuntimeException
* @throws FileSystemException
*/
public function build()
{
$optimizations = match ($this->builder->arch) {
'x86_64' => '--enable-intel-sse ',
'arm64' => '--enable-arm-neon ',
default => '',
};
shell()->cd($this->source_dir)
->exec('chmod +x ./configure')
->exec('chmod +x ./install-sh')
->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');
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
$this->cleanLaFiles();
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libsodium extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libsodium;
public const NAME = 'libsodium';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libssh2 extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libssh2;
public const NAME = 'libssh2';
}

View File

@@ -0,0 +1,28 @@
<?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;
class libwebp extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libwebp;
public const NAME = 'libwebp';
}

View File

@@ -0,0 +1,53 @@
<?php
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';
/**
* @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;
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} " . ' cmake ' .
"{$this->builder->makeCmakeArgs()} " .
'-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 ' .
'..'
)
->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')) {
shell()->exec('rm -rf "' . BUILD_INCLUDE_PATH . '/libxml"');
}
$path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/libxml2/libxml');
$dst_path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/');
shell()->exec('mv "' . $path . '" "' . $dst_path . '"');
}
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libyaml extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libyaml;
public const NAME = 'libyaml';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libzip extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libzip;
public const NAME = 'libzip';
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
/**
* gmp is a template library class for unix
*/
class ncurses extends LinuxLibraryBase
{
use \SPC\builder\unix\library\ncurses;
public const NAME = 'ncurses';
}

View File

@@ -0,0 +1,63 @@
<?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;
class nghttp2 extends LinuxLibraryBase
{
public const NAME = 'nghttp2';
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}");
$this->patchPkgconfPrefix(['libnghttp2.pc']);
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class onig extends LinuxLibraryBase
{
use \SPC\builder\unix\library\onig;
public const NAME = 'onig';
}

View File

@@ -0,0 +1,78 @@
<?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';
/**
* @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 -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' : '';
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} {$env} ./Configure no-shared {$extra} " .
'--prefix=/ ' .
'--libdir=lib ' .
'-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}");
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
}
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
/**
* gmp is a template library class for unix
*/
class pkgconfig extends LinuxLibraryBase
{
use \SPC\builder\unix\library\pkgconfig;
public const NAME = 'pkg-config';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class postgresql extends LinuxLibraryBase
{
use \SPC\builder\unix\library\postgresql;
public const NAME = 'postgresql';
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
/**
* gmp is a template library class for unix
*/
class readline extends LinuxLibraryBase
{
use \SPC\builder\unix\library\readline;
public const NAME = 'readline';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class sqlite extends LinuxLibraryBase
{
use \SPC\builder\unix\library\sqlite;
public const NAME = 'sqlite';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class xz extends LinuxLibraryBase
{
use \SPC\builder\unix\library\xz;
public const NAME = 'xz';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class zlib extends LinuxLibraryBase
{
use \SPC\builder\unix\library\zlib;
public const NAME = 'zlib';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class zstd extends LinuxLibraryBase
{
use \SPC\builder\unix\library\zstd;
public const NAME = 'zstd';
}

View File

@@ -0,0 +1,257 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos;
use SPC\builder\BuilderBase;
use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\builder\traits\UnixBuilderTrait;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\SourcePatcher;
/**
* macOS 系统环境下的构建器
* 源于 Config但因为感觉叫 Config 不太合适,就换成了 Builder
*/
class MacOSBuilder extends BuilderBase
{
/** 编译的 Unix 工具集 */
use UnixBuilderTrait;
/** @var bool 标记是否 patch 了 phar */
private bool $phar_patched = false;
/**
* @param null|string $cc C编译器名称如果不传入则默认使用clang
* @param null|string $cxx C++编译器名称如果不传入则默认使用clang++
* @param null|string $arch 当前架构,如果不传入则默认使用当前系统架构
* @throws RuntimeException
* @throws WrongUsageException
*/
public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null, bool $zts = false)
{
// 如果是 Debug 模式,才使用 set -x 显示每条执行的命令
$this->set_x = defined('DEBUG_MODE') ? 'set -x' : 'true';
// 初始化一些默认参数
$this->cc = $cc ?? 'clang';
$this->cxx = $cxx ?? 'clang++';
$this->arch = $arch ?? php_uname('m');
$this->gnu_arch = arch2gnu($this->arch);
$this->zts = $zts;
// 根据 CPU 线程数设置编译进程数
$this->concurrency = SystemUtil::getCpuCount();
// 设置 cflags
$this->arch_c_flags = SystemUtil::getArchCFlags($this->arch);
$this->arch_cxx_flags = SystemUtil::getArchCFlags($this->arch);
// 设置 cmake
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->arch, $this->arch_c_flags);
// 设置 configure 依赖的环境变量
$this->configure_env =
'PKG_CONFIG="' . BUILD_ROOT_PATH . '/bin/pkg-config" ' .
'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig/" ' .
"CC='{$this->cc}' " .
"CXX='{$this->cxx}' " .
"CFLAGS='{$this->arch_c_flags} -Wimplicit-function-declaration -Os'";
// 创立 pkg-config 和放头文件的目录
f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true);
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
}
/**
* 生成库构建采用的 autoconf 参数列表
*
* @param string $name 要构建的 lib 库名,传入仅供输出日志
* @param array $lib_specs 依赖的 lib 库的 autoconf 文件
*/
public function makeAutoconfArgs(string $name, array $lib_specs): string
{
$ret = '';
foreach ($lib_specs as $libName => $arr) {
$lib = $this->getLib($libName);
$arr = $arr ?? [];
$disableArgs = $arr[0] ?? null;
$prefix = $arr[1] ?? null;
if ($lib instanceof MacOSLibraryBase) {
logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support");
$ret .= '--with-' . $libName . '=yes ';
} else {
logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support");
$ret .= ($disableArgs ?? "--with-{$libName}=no") . ' ';
}
}
return rtrim($ret);
}
/**
* 返回 macOS 系统依赖的框架列表
*
* @param bool $asString 是否以字符串形式返回(默认为 False
*/
public function getFrameworks(bool $asString = false): array|string
{
$libs = [];
// reorder libs
foreach ($this->libs as $lib) {
foreach ($lib->getDependencies() as $dep) {
$libs[] = $dep;
}
$libs[] = $lib;
}
$frameworks = [];
/** @var MacOSLibraryBase $lib */
foreach ($libs as $lib) {
array_push($frameworks, ...$lib->getFrameworks());
}
if ($asString) {
return implode(' ', array_map(fn ($x) => "-framework {$x}", $frameworks));
}
return $frameworks;
}
/**
* @param int $build_target build target
* @param bool $bloat just raw add all lib files
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void
{
$extra_libs = $this->getFrameworks(true) . ' ' . ($this->hasCppExtension() ? '-lc++ ' : '');
if (!$bloat) {
$extra_libs .= implode(' ', $this->getAllStaticLibFiles());
} else {
logger()->info('bloat linking');
$extra_libs .= implode(
' ',
array_map(
fn ($x) => "-Wl,-force_load,{$x}",
array_filter($this->getAllStaticLibFiles())
)
);
}
// patch before buildconf
SourcePatcher::patchBeforeBuildconf($this);
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
SourcePatcher::patchBeforeConfigure($this);
if ($this->getLib('libxml2') || $this->getExt('iconv')) {
$extra_libs .= ' -liconv';
}
if ($this->getPHPVersionID() < 80000) {
$json_74 = '--enable-json ';
} else {
$json_74 = '';
}
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
'./configure ' .
'--prefix= ' .
'--with-valgrind=no ' . // 不检测内存泄漏
'--enable-shared=no ' .
'--enable-static=yes ' .
"CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " .
'--disable-all ' .
'--disable-cgi ' .
'--disable-phpdbg ' .
'--enable-cli ' .
'--enable-fpm ' .
$json_74 .
'--enable-micro ' .
($this->zts ? '--enable-zts' : '') . ' ' .
$this->makeExtensionArgs() . ' ' .
$this->configure_env
);
SourcePatcher::patchBeforeMake($this);
$this->cleanMake();
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
logger()->info('building cli');
$this->buildCli($extra_libs);
}
if (($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) {
logger()->info('building fpm');
$this->buildFpm($extra_libs);
}
if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
logger()->info('building micro');
$this->buildMicro($extra_libs);
}
if (php_uname('m') === $this->arch) {
$this->sanityCheck($build_target);
}
if ($this->phar_patched) {
SourcePatcher::patchMicro(['phar'], true);
}
}
/**
* 构建 cli
*
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildCli(string $extra_libs): void
{
$shell = shell()->cd(SOURCE_PATH . '/php-src');
$shell->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" cli");
if ($this->strip) {
$shell->exec('dsymutil -f sapi/cli/php')->exec('strip sapi/cli/php');
}
$this->deployBinary(BUILD_TARGET_CLI);
}
/**
* 构建 phpmicro
*
* @throws FileSystemException|RuntimeException
*/
public function buildMicro(string $extra_libs): void
{
if ($this->getPHPVersionID() < 80000) {
throw new RuntimeException('phpmicro only support PHP >= 8.0!');
}
if ($this->getExt('phar')) {
$this->phar_patched = true;
SourcePatcher::patchMicro(['phar']);
}
shell()->cd(SOURCE_PATH . '/php-src')
->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" " . ($this->strip ? 'STRIP="dsymutil -f " ' : '') . 'micro');
$this->deployBinary(BUILD_TARGET_MICRO);
}
/**
* 构建 fpm
*
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildFpm(string $extra_libs): void
{
$shell = shell()->cd(SOURCE_PATH . '/php-src');
$shell->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" fpm");
if ($this->strip) {
$shell->exec('dsymutil -f sapi/fpm/php-fpm')->exec('strip sapi/fpm/php-fpm');
}
$this->deployBinary(BUILD_TARGET_FPM);
}
}

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
class SystemUtil
{
/** macOS 兼容 unix 的系统工具 */
use UnixSystemUtilTrait;
/**
* 获取系统 CPU 逻辑内核数
*
* @throws RuntimeException
*/
public static function getCpuCount(): int
{
[$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu');
if ($ret !== 0) {
throw new RuntimeException('Failed to get cpu count');
}
return (int) $output[0];
}
/**
* 获取不同架构对应的 cflags 参数
*
* @param string $arch 架构名称
* @throws WrongUsageException
*/
public static function getArchCFlags(string $arch): string
{
return match ($arch) {
'x86_64' => '--target=x86_64-apple-darwin',
'arm64','aarch64' => '--target=arm64-apple-darwin',
default => throw new WrongUsageException('unsupported arch: ' . $arch),
};
}
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
use SPC\builder\BuilderBase;
use SPC\builder\LibraryBase;
use SPC\builder\macos\MacOSBuilder;
use SPC\builder\traits\UnixLibraryTrait;
use SPC\store\Config;
abstract class MacOSLibraryBase extends LibraryBase
{
use UnixLibraryTrait;
protected array $headers;
public function __construct(protected MacOSBuilder $builder)
{
parent::__construct();
}
public function getBuilder(): BuilderBase
{
return $this->builder;
}
/**
* 获取当前 lib 库依赖的 macOS framework
*/
public function getFrameworks(): array
{
return Config::getLib(static::NAME, 'frameworks', []);
}
}

View File

@@ -0,0 +1,28 @@
<?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\macos\library;
class brotli extends MacOSLibraryBase
{
use \SPC\builder\unix\library\brotli;
public const NAME = 'brotli';
}

View File

@@ -0,0 +1,28 @@
<?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\macos\library;
class bzip2 extends MacOSLibraryBase
{
use \SPC\builder\unix\library\bzip2;
public const NAME = 'bzip2';
}

View File

@@ -0,0 +1,51 @@
<?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\macos\library;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
class curl extends MacOSLibraryBase
{
use \SPC\builder\unix\library\curl;
public const NAME = 'curl';
/**
* @throws FileSystemException
*/
public function patchBeforeBuild(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/curl/CMakeLists.txt',
REPLACE_FILE_PREG,
'/NOT COREFOUNDATION_FRAMEWORK/m',
'FALSE'
);
FileSystem::replaceFile(
SOURCE_PATH . '/curl/CMakeLists.txt',
REPLACE_FILE_PREG,
'/NOT SYSTEMCONFIGURATION_FRAMEWORK/m',
'FALSE'
);
return true;
}
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
/**
* is a template library class for unix
*/
class freetype extends MacOSLibraryBase
{
use \SPC\builder\unix\library\freetype;
public const NAME = 'freetype';
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class glfw extends MacOSLibraryBase
{
public const NAME = 'glfw';
protected function build()
{
// compile
shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw')
->exec("{$this->builder->configure_env} cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF")
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
// patch pkgconf
$this->patchPkgconfPrefix(['glfw3.pc']);
}
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
/**
* gmp is a template library class for unix
*/
class gmp extends MacOSLibraryBase
{
use \SPC\builder\unix\library\gmp;
public const NAME = 'gmp';
}

Some files were not shown because too many files have changed in this diff Show More