Compare commits

...

606 Commits

Author SHA1 Message Date
Jerry Ma
d72ee53cb4 Update README.md 2023-12-17 02:02:00 +08:00
crazywhalecc
a5fa46b82d update README 2023-12-17 01:35:28 +08:00
Jerry Ma
bc15de0dfb Update README.md 2023-12-17 01:03:32 +08:00
crazywhalecc
1f7bdb94fb update README 2023-12-17 01:02:02 +08:00
crazywhalecc
ea64e50ce5 fix SourcePatcher::patchFile not working with spc binary 2023-12-16 18:49:38 +08:00
crazywhalecc
ed8b606761 add libtool for macos doctor 2023-12-16 15:07:04 +08:00
Jerry Ma
b722b3edd4 Merge pull request #279 from jingjingxyk/feature_upgrade_libpq
upgrade libpq to v16.1
2023-12-16 12:34:36 +08:00
crazywhalecc
9266a4c504 remove ldap test 2023-12-15 23:36:12 +08:00
crazywhalecc
d8ce5f69f4 fix mongodb support for Linux (mac still broken) 2023-12-15 01:31:01 +08:00
crazywhalecc
0cfac49560 adjust package order 2023-12-15 00:34:22 +08:00
crazywhalecc
3e9ddc8e01 update to rc9 2023-12-10 20:43:52 +08:00
crazywhalecc
83dd1bd5c3 Merge branch 'main' into feature_upgrade_libpq 2023-12-10 19:10:39 +08:00
crazywhalecc
42f448cf17 reformat build log 2023-12-10 19:07:28 +08:00
crazywhalecc
f0319de93e opcache limit php version 2023-12-10 19:07:28 +08:00
crazywhalecc
c7e9294908 fix libtool missing bug for freetype 2023-12-10 19:07:28 +08:00
Jerry Ma
c1758bd754 Update README.md 2023-12-07 16:01:12 +08:00
jingjingxyk
bba2d0dbf7 test remove imap ldap extension 2023-11-30 21:29:57 +08:00
jingjingxyk
00689b951b update ldap depends 2023-11-30 14:19:20 +08:00
jingjingxyk
98b7164de3 test libpq build 2023-11-30 13:09:02 +08:00
jingjingxyk
d3e4470e1f test libpq build 2023-11-30 13:06:36 +08:00
jingjingxyk
433c91b68d test libpq build 2023-11-30 13:01:15 +08:00
jingjingxyk
3185d98b1a test libpq build 2023-11-30 13:00:04 +08:00
jingjingxyk
e603e441e7 test libpq build 2023-11-30 12:56:47 +08:00
jingjingxyk
b1bf8bb848 test libpq build 2023-11-30 12:53:19 +08:00
jingjingxyk
b1958ea0c4 test libpq build 2023-11-30 12:37:20 +08:00
jingjingxyk
930849758c swoole.php and LinuxBuilder.php revert 2023-11-29 22:28:20 +08:00
jingjingxyk
7ee431725c test swoole enable pgsql 2023-11-29 22:22:36 +08:00
jingjingxyk
7c866cb0e3 swoole enable pgsql 2023-11-29 22:19:20 +08:00
jingjingxyk
266108b25f test libpq build config 2023-11-29 22:06:30 +08:00
crazywhalecc
82e3a86f17 bypass error: swoole curl hook is buggy for php 8.0 2023-11-29 20:31:53 +08:00
crazywhalecc
ba18819b41 Merge branch 'main' into feature_upgrade_libpq
# Conflicts:
#	src/globals/test-extensions.php
2023-11-29 19:16:40 +08:00
jingjingxyk
6b23c90bba test build libpq 2023-11-29 16:52:53 +08:00
crazywhalecc
edfd371973 bypass error: unknown warning option '-Wno-logical-op' for macOS 2023-11-29 16:03:30 +08:00
crazywhalecc
8ed95602e2 add tests 2023-11-29 16:03:30 +08:00
crazywhalecc
cee1346bec fix imagemagick linking issue 2023-11-29 16:03:30 +08:00
jingjingxyk
400007c206 test change test-extensions 2023-11-29 15:56:52 +08:00
jingjingxyk
443e615066 Merge remote-tracking branch 'origin/feature_upgrade_libpq' into feature_upgrade_libpq 2023-11-29 15:46:26 +08:00
jingjingxyk
ed22945ae2 test 2023-11-29 15:44:04 +08:00
Jerry Ma
5db084ba0e reduce test extensions 2023-11-29 15:17:21 +08:00
jingjingxyk
c7b3275a72 update libpq build config 2023-11-29 15:06:17 +08:00
Jerry Ma
41cd319d4e Update test-extensions.php 2023-11-29 14:28:39 +08:00
jingjingxyk
1c307d0d59 upgrade libpq to v16.1 2023-11-29 13:30:12 +08:00
Jerry Ma
9dcda873f3 Fix debian libtool bug (#276)
* add libtool installation for debian

* update composer lock

* re-fix libtool check

* re-fix libtool check
2023-11-27 22:35:40 +08:00
crazywhalecc
4400c6271e update composer lock 2023-11-27 21:59:59 +08:00
crazywhalecc
0589690eaa add libtool installation for debian 2023-11-27 21:59:59 +08:00
Jerry Ma
5449e05898 Update README.md 2023-11-24 10:28:35 +08:00
crazywhalecc
93e64e1d5a use php 8.2 to setup php runtime 2023-11-24 01:33:12 +08:00
crazywhalecc
7a2e237069 add php 8.3 support 2023-11-24 01:33:12 +08:00
crazywhalecc
c95da8c150 add tests 2023-11-24 01:23:15 +08:00
crazywhalecc
89afd44344 add tidy support for linux 2023-11-24 01:23:15 +08:00
crazywhalecc
04f100da8b add tidy support 2023-11-24 01:23:15 +08:00
Jerry Ma
2e24976b71 Update README.md 2023-11-22 11:05:57 +08:00
Jerry Ma
36a30cc23b Update README.md 2023-11-21 23:35:34 +08:00
crazywhalecc
869130572f change test 2023-11-21 23:09:20 +08:00
crazywhalecc
2bb08af89b add rar test 2023-11-21 23:09:20 +08:00
crazywhalecc
b3d41ef969 add extension rar 2023-11-21 23:09:20 +08:00
crazywhalecc
9c904409cd use string 2023-11-19 13:47:48 +08:00
crazywhalecc
859182abff remove fail fast 2023-11-19 13:44:12 +08:00
crazywhalecc
c0e88bf4bd prevent setup php from using 8.0 2023-11-19 13:42:40 +08:00
crazywhalecc
79bcd35c0e Add test build things 2023-11-19 13:41:09 +08:00
crazywhalecc
2e637524fc Add test build things 2023-11-19 13:38:55 +08:00
Jerry Ma
a2c687599f Create pull_request_template.md 2023-11-19 13:38:09 +08:00
Kévin Dunglas
d09a3074ad include git metadata 2023-11-16 19:21:54 +08:00
Kévin Dunglas
5736964b2e fix 2023-11-16 19:21:54 +08:00
Kévin Dunglas
edaa82b8c5 autogen 2023-11-16 19:21:54 +08:00
Kévin Dunglas
2a6441a500 switch to git 2023-11-16 19:21:54 +08:00
crazywhalecc
3bd5a05725 remove pthreads4w 2023-11-16 00:12:56 +08:00
Kévin Dunglas
a6fbcc954e fix pthreads4w URL 2023-11-16 00:12:56 +08:00
crazywhalecc
66cebb5fe4 disable brotli if not enabled 2023-11-15 18:29:59 +08:00
crazywhalecc
e3671387fc temporarily use fixed url for freetype 2023-11-15 18:00:06 +08:00
Jerry Ma
f7c73c00af Fix iconv not depends on libiconv in linux 2023-11-14 20:54:03 +08:00
Jerry Ma
74536bd2e1 Change CI download all to --for-extensions (#262)
* Change download all to --for-extensions

* Update build-linux-x86_64.yml

* Update build-linux-arm.yml

* Update build-linux-x86_64.yml

* Update build-macos-x86_64.yml
2023-11-13 17:59:03 +08:00
crazywhalecc
a8f2b0096b cs fix 2023-11-13 16:09:11 +08:00
crazywhalecc
2d192fc390 replace libpng to github 2023-11-13 16:09:11 +08:00
crazywhalecc
031da802f3 apply new patches 2023-11-13 16:09:11 +08:00
crazywhalecc
5fdeb33031 separate linux and macos patches 2023-11-13 16:09:11 +08:00
crazywhalecc
347da67b71 use static-php/imap 2023-11-13 16:09:11 +08:00
crazywhalecc
65ef9ab20c use WrongUsageException for not supported libs 2023-11-13 16:09:11 +08:00
crazywhalecc
3d64c6349e remove kerberos temporarily
--for-extensions is not working with it
2023-11-13 16:09:11 +08:00
DubbleClick
31cf9bb5b7 fix redhat os detection 2023-11-13 16:09:11 +08:00
DubbleClick
7c4a991c0e add imap support 2023-11-13 16:09:11 +08:00
crazywhalecc
07f943af7e add dev:extensions command custom column display 2023-11-06 22:29:52 +08:00
crazywhalecc
ff74f0cdaf overwrite mbregex cli check 2023-11-05 17:49:30 +08:00
crazywhalecc
dccfde9f39 Adjust mbstring and mbregex dependencies 2023-11-05 17:49:30 +08:00
crazywhalecc
5db23e1db7 let sanity check can be overwritten 2023-11-05 17:49:30 +08:00
crazywhalecc
b1ae48a209 let sanity check can be overwritten 2023-11-05 17:49:30 +08:00
crazywhalecc
ac7a236763 Transfer crazywhalecc/phpmicro ownership 2023-11-01 21:07:20 +08:00
crazywhalecc
1bf39c1f06 Update static-php-cli-hosted ownership 2023-11-01 20:51:31 +08:00
Jerry Ma
678283cd98 Update README.md 2023-11-01 20:48:23 +08:00
crazywhalecc
97a76aba8a update README 2023-11-01 20:35:45 +08:00
Jerry Ma
af464e7b3d Update source.json 2023-11-01 20:06:49 +08:00
Jerry Ma
5ee7dd9200 Update README-zh.md 2023-11-01 13:51:12 +08:00
Jerry Ma
9e1c2c6dd5 Update README-zh.md 2023-11-01 13:49:37 +08:00
Jerry Ma
d29ba16cbc Update README.md 2023-11-01 13:49:18 +08:00
Jerry Ma
7bef45eb32 Update README.md 2023-11-01 11:01:44 +08:00
crazywhalecc
772ab77d2e fix glfw linking issue 2023-11-01 10:03:36 +08:00
crazywhalecc
58897c6941 add swoole curl hook support, disable pgsql hook support 2023-11-01 10:03:36 +08:00
Jerry Ma
8230e1bcec Update README.md 2023-11-01 00:02:59 +08:00
crazywhalecc
279a1dab4b fix prompts dependency and box pack path 2023-10-31 18:03:14 +08:00
Jerry Ma
9fb5173e3e Merge pull request #231 from DubbleClick/cplus
Linux c++ support using musl-cross-make toolchains
2023-10-31 13:44:25 +08:00
crazywhalecc
0b37080cdd a good coding font is very important 2023-10-31 12:17:53 +08:00
DubbleClick
8747266df6 make it rc8 2023-10-30 22:22:01 +01:00
DubbleClick
12cc422d5b merge main 2023-10-30 22:20:16 +01:00
DubbleClick
bfc56cff72 refactor build var generation 2023-10-30 22:14:47 +01:00
crazywhalecc
d5405ce436 update to the release version 2023-10-31 01:51:53 +08:00
crazywhalecc
e158cc5886 update composer lock 2023-10-31 01:51:14 +08:00
crazywhalecc
aee040d6a4 use prompts to show table 2023-10-31 01:48:57 +08:00
crazywhalecc
e637cce6f2 use prompts to ask 2023-10-31 01:48:49 +08:00
crazywhalecc
98b906db40 Merge remote-tracking branch 'origin/main' into cplus 2023-10-31 01:02:02 +08:00
crazywhalecc
7625f585d2 fix macos imagemagick libwebp linking issue 2023-10-31 00:59:35 +08:00
crazywhalecc
ed8837fe9f let postgresql use -lc++ in bsd and macos 2023-10-31 00:59:22 +08:00
Jerry Ma
a5754125a8 Update README.md 2023-10-30 20:32:59 +08:00
DubbleClick
6b848da4dd disable musl-gcc wrapper 2023-10-29 18:02:02 +01:00
crazywhalecc
2768dc0c40 adjust doctor for os and linux musl check 2023-10-30 00:35:58 +08:00
crazywhalecc
90b2e5568c update sqlite version 2023-10-29 23:34:17 +08:00
DubbleClick
b4f9235cb6 Merge branch 'main' into cplus 2023-10-29 12:14:58 +01:00
DubbleClick
86ce7e9d25 rename --by-extensions to --for-extensions
--without-suggests to --without-suggestions
2023-10-29 12:00:16 +08:00
DubbleClick
2e47e8af6b specify --with-openssl-dir in php ./configure
I'm not sure if this is correct, please revert if it doesn't fix the issue
2023-10-27 18:42:53 +02:00
DubbleClick
d40f2cafec simplify libpng compilation 2023-10-27 17:37:31 +02:00
DubbleClick
e84a246dd2 add back required -lgomp for imagick extension 2023-10-27 17:33:43 +02:00
crazywhalecc
98f32ae0f0 Use emoji 2023-10-26 20:49:42 +08:00
crazywhalecc
5499109278 Adjust new README 2023-10-26 20:40:32 +08:00
crazywhalecc
9a5b02692d Adjust new README 2023-10-26 20:37:35 +08:00
crazywhalecc
970a74896a Adjust new README 2023-10-26 20:34:58 +08:00
crazywhalecc
29179ecb84 Adjust new README 2023-10-26 20:28:35 +08:00
crazywhalecc
5e0cccfe3d Add --by-extensions for README 2023-10-26 20:20:17 +08:00
crazywhalecc
ed52ec9ee1 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	README-en.md
2023-10-26 20:17:27 +08:00
crazywhalecc
f25d2d5db4 Decided to change README default language to English 2023-10-26 20:17:17 +08:00
crazywhalecc
e00908d8cb Merge remote-tracking branch 'DubbleClick/cplus' into cplus
# Conflicts:
#	src/SPC/builder/unix/library/bzip2.php
2023-10-26 19:45:37 +08:00
DubbleClick
c24dc8f518 create helper method to pass environment variables to 'make' 2023-10-24 12:21:36 +02:00
Jerry Ma
d381e48605 Update README-en.md 2023-10-23 22:44:42 +08:00
crazywhalecc
8dcec73929 let bzip2 use correct CC and AR 2023-10-23 22:27:19 +08:00
crazywhalecc
9b9644fe63 simplify download error message 2023-10-23 20:12:47 +08:00
crazywhalecc
8a70da6291 change instanceof check 2023-10-23 00:41:43 +08:00
crazywhalecc
c84eb723ec [mixed] refactor with putenv, fix imagemagick and c++ build 2023-10-23 00:37:28 +08:00
crazywhalecc
5934e5e881 fix doctor phpunit test 2023-10-22 22:16:20 +08:00
crazywhalecc
99150e2cef add putenv wrapper 2023-10-22 22:14:11 +08:00
crazywhalecc
8191444fe9 refactor musl tool doctor 2023-10-22 21:33:09 +08:00
crazywhalecc
5cfba6e83b Merge branch 'main' into cplus 2023-10-22 17:43:18 +08:00
crazywhalecc
4e9b8980d0 add --by-extensions and --without-suggests options for download command 2023-10-22 17:42:35 +08:00
crazywhalecc
c800a53f77 separate --from-zip in download command 2023-10-22 17:42:35 +08:00
crazywhalecc
6cc7e6cff6 add comment for hard-coded musl version 2023-10-22 17:24:01 +08:00
crazywhalecc
d56c060863 remove --enable-wrapper=gcc for fix-musl 2023-10-22 17:15:12 +08:00
crazywhalecc
b6409bded4 optimize install musl wrapper and cross make function 2023-10-22 16:55:02 +08:00
DubbleClick
ca1189b6ca use ld.gold (revert this if you think this doesn't add benefit) 2023-10-19 18:28:36 +02:00
DubbleClick
75b9d66698 use ar and ld from musl-tools (uses gold-ld and can handle wrong lib order) 2023-10-19 18:24:05 +02:00
DubbleClick
6dfd35348f fix order of imagick libs 2023-10-19 18:24:05 +02:00
DubbleClick
0007043f4a fix imagemagick and postgresql builds with different libs 2023-10-19 18:24:04 +02:00
DubbleClick
da1cbeb79c introduce library_path and ld_library_path options to linuxbuilder (some libs require it to load -lstdc++) 2023-10-19 18:24:03 +02:00
DubbleClick
a83a457905 fix pgsql build on non-alpine 2023-10-19 18:24:03 +02:00
DubbleClick
a4dc177621 install libxml2 and snappy into /lib instead of /lib64 2023-10-19 18:24:02 +02:00
DubbleClick
a7265bf624 add -static linker flag to libicu compilation 2023-10-19 18:24:01 +02:00
DubbleClick
64dfb57366 don't add -liconv on linux (cannot find library when specified that way in extra_libs) 2023-10-19 18:24:01 +02:00
DubbleClick
658e8e74bd use arch-linux-musl toolchains 2023-10-19 18:24:00 +02:00
DubbleClick
46b0ecf3fa allow patching of extra_libs before make on linux too 2023-10-19 18:23:59 +02:00
DubbleClick
830f379bf6 add --disable-opcache-jit option for alpine 2023-10-19 18:23:59 +02:00
crazywhalecc
c9b544f8c4 fix zlib detection in debian linux 2023-10-19 23:19:51 +08:00
DubbleClick
11af370fe1 remove useless softlink libpng.a (pointing to libpng16.a), causes imagick build failure if freetype or png is enabled 2023-10-19 23:19:51 +08:00
DubbleClick
1e11559c4b fix libpng license and libname 2023-10-19 23:19:51 +08:00
crazywhalecc
8b188bd1b9 change icu to ghrel 2023-10-19 00:05:36 +08:00
crazywhalecc
e0e3bc6d97 add detection for ghrel prerelease 2023-10-19 00:05:36 +08:00
crazywhalecc
dbb566ac7c fix curl 7.4.0 CoreServices framework build bug for mac 2023-10-17 18:43:49 +08:00
crazywhalecc
37b9704fbb move option rebuild add position 2023-10-17 18:37:40 +08:00
DubbleClick
c225aeffed introduce --rebuild option to BuildCliCommand.php (who even uses build:libs?) 2023-10-17 18:37:40 +08:00
DubbleClick
2e3544f296 catch exception when license path key is not set, fix libxslt license 2023-10-17 10:08:07 +08:00
Jerry Ma
ce60a9c804 Update README.md 2023-10-16 10:28:10 +08:00
crazywhalecc
b6c0b998b3 add bz2,curl support 2023-10-16 10:28:10 +08:00
crazywhalecc
6277539a79 change README micro repo description 2023-10-16 10:28:10 +08:00
crazywhalecc
9520d68cda add onig and openssl support for BSD 2023-10-16 10:28:10 +08:00
crazywhalecc
812c71f31f update README 2023-10-16 10:28:10 +08:00
crazywhalecc
b3cc360eeb fix extension configure arg for BSD 2023-10-16 10:28:10 +08:00
crazywhalecc
39fe6fa081 fix copyDir for FreeBSD and add debug message 2023-10-16 10:28:10 +08:00
crazywhalecc
243ee63283 fix strip order for micro 2023-10-16 10:28:10 +08:00
crazywhalecc
24c946d687 fix phpunit 2023-10-16 10:28:10 +08:00
crazywhalecc
84d1c789bd add basic FreeBSD support for utils 2023-10-16 10:28:10 +08:00
crazywhalecc
a983667b90 fix docker alpine install package redundant link 2023-10-15 09:42:55 +08:00
crazywhalecc
8d9cace469 fix mongodb release file match 2023-10-14 15:10:15 +08:00
crazywhalecc
e9d3e48f90 simplify hasCppExtension() method 2023-10-14 14:07:48 +08:00
crazywhalecc
ed53394389 add mark library patch function 2023-10-14 14:07:48 +08:00
crazywhalecc
8893d08ba9 adjust linux distro detection 2023-10-14 13:56:40 +08:00
crazywhalecc
5a13daee39 remove redundant LinuxLibraryBase tryBuild 2023-10-14 13:56:13 +08:00
crazywhalecc
c1e9cd2ea3 fix --with-clean to make it work 2023-10-14 11:37:56 +08:00
crazywhalecc
30213da70a change default download php to 8.2 2023-10-14 11:30:43 +08:00
crazywhalecc
5d363bdb0b adjust store classes 2023-10-14 11:23:25 +08:00
crazywhalecc
630c0d3a5d add SourcePatcher::patchFile 2023-10-14 11:18:36 +08:00
Jerry Ma
56caef78e3 Update README.md 2023-10-07 15:37:49 +08:00
Jerry Ma
29be3a2e39 set version to 2.0-rc7 2023-10-05 22:07:44 +08:00
crazywhalecc
fbe149bcac reuse static-php-cli-hosted workflows 2023-10-05 21:58:42 +08:00
crazywhalecc
92cafb36f6 fix bugs when building micro and embed at the same time 2023-10-01 10:01:45 +08:00
Joseph Bielawski
8636f2e7c9 Throw proper exception when PHP source is not available 2023-10-01 01:24:02 +08:00
crazywhalecc
8f43a09533 separate alternative libs 2023-10-01 01:19:35 +08:00
DubbleClick
654c5cba0c fix musl install on rhel 2023-10-01 01:19:35 +08:00
crazywhalecc
f9685b82a1 adjust tool check level 2023-10-01 01:19:35 +08:00
crazywhalecc
f2371d3702 bugfix: complete ldap support for macOS and Linux 2023-10-01 01:19:35 +08:00
crazywhalecc
fe39aecd72 adjust config order 2023-10-01 01:19:35 +08:00
crazywhalecc
68d176ad26 prevent c compiler not found error 2023-10-01 01:19:35 +08:00
crazywhalecc
d7627dd81a correct libc name for linux 2023-10-01 01:19:35 +08:00
crazywhalecc
a4e173f16d add configure flags for unix builder 2023-10-01 01:19:35 +08:00
DubbleClick
1437be3a9d gmp and libsodium for ldap if enabled
only enable openssl when zlib ext is also enabled (missing 'deflate' otherwise)
move back from source/php-src/ext/ldap to source/ldap (fix "LICENSE not found")
2023-10-01 01:19:35 +08:00
DubbleClick
059c32e59c add ext-ldap (openldap) support 2023-10-01 01:19:35 +08:00
DubbleClick
e3a4cd6e1d fix spelling mistake in README-en.md 2023-10-01 01:19:35 +08:00
DubbleClick
dd9a5d8316 add rhel and almalinux support 2023-10-01 01:19:35 +08:00
Joseph Bielawski
3b83c1fa7b Remove dead code from ConsoleApplication class 2023-09-30 13:52:29 +08:00
Rif'at Ahdi R
ff128df76b Update libwebp dependency (fix #208) 2023-09-29 16:07:59 +08:00
crazywhalecc
cd04a9ea4f change all related url to static-php.dev 2023-09-26 22:27:44 +08:00
Jerry Ma
3b793005fe Change domain 2023-09-26 18:32:18 +08:00
Jerry Ma
87e073a0b9 Change domain 2023-09-26 18:29:45 +08:00
crazywhalecc
db8aa15677 adjust micro's phar patch execution location 2023-09-25 10:35:31 +08:00
crazywhalecc
6ed9749732 cs fix and composer update 2023-09-23 17:03:20 +08:00
crazywhalecc
4e99211bc3 add hardcoded-ini option for embed SAPI 2023-09-17 12:21:06 +08:00
crazywhalecc
824748c2a7 remove download cache and minimize download sources 2023-09-16 15:15:46 +08:00
crazywhalecc
fe6a98b30d remove debug option 2023-09-16 15:15:46 +08:00
crazywhalecc
49149cebf1 Add new GH action to build binary SPC 2023-09-16 15:15:46 +08:00
Joseph Bielawski
7b6a1b4212 Simplify adding composer in bin/spc-alpine-docker
Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
2023-09-15 09:39:27 +08:00
Joseph Bielawski
965e7a25e2 Add composer.lock into repository 2023-09-15 09:39:27 +08:00
Kévin Dunglas
0c3885c33d fix(docker): php82-sodium is required 2023-09-14 10:02:54 +08:00
Joseph Bielawski
be32190829 Sanity check extensions by inline their test code 2023-09-13 23:42:10 +08:00
crazywhalecc
f1d5916090 remove unused old deploy command 2023-09-13 21:45:19 +08:00
Joseph Bielawski
b2ea479fac Remove the phar workflow temporary 2023-09-13 21:45:19 +08:00
Joseph Bielawski
16cc5df66d Temporary disable phar build in GH actions 2023-09-13 21:45:19 +08:00
Joseph Bielawski
a63e3f4575 Add version into phar 2023-09-13 21:45:19 +08:00
Joseph Bielawski
6b061e6332 Adjust box configuration for smaller phar size 2023-09-13 21:45:19 +08:00
Joseph Bielawski
4a17491aaa Initial code to get Box for phar building 2023-09-13 21:45:19 +08:00
Jerry Ma
06f29712e2 Update README.md 2023-09-13 10:03:31 +08:00
Kévin Dunglas
4b1d59c5a9 Link to FrankenPHP docs about embed SAPI in README-en.md 2023-09-13 10:03:31 +08:00
crazywhalecc
1a81fe6a0d change help message for dev:extensions 2023-09-12 23:30:23 +08:00
crazywhalecc
c63136d484 change dev:extensions argument to comma separated 2023-09-12 23:30:23 +08:00
crazywhalecc
4b500f2dd8 remove redundant libssh2 cmake build target option 2023-09-12 23:09:58 +08:00
crazywhalecc
9da20497cc fix ln src and dst for brotli 2023-09-12 22:53:47 +08:00
crazywhalecc
5efc15b404 fix libwebp pkgconfig patch, add custom patch argument 2023-09-12 22:52:20 +08:00
Joseph Bielawski
fa0740f216 Explicitly define application commands 2023-09-12 22:51:50 +08:00
Joseph Bielawski
52430cbdde Rework doctor command 2023-09-12 22:46:44 +08:00
crazywhalecc
01c4538ce0 update README for embed SAPI 2023-09-12 22:44:19 +08:00
Kévin Dunglas
3183ecceaf --disable-opcache-jit 2023-09-12 22:30:13 +08:00
Kévin Dunglas
dd2e7cc129 static opcache patch 2023-09-12 22:30:13 +08:00
Kévin Dunglas
adfa620ef4 Revert "always enable micro"
This reverts commit eb8cefd9ca.
2023-09-12 22:30:13 +08:00
Kévin Dunglas
1a32ddc70a Revert "temporary workaround for PECL certificate expiration"
This reverts commit 7c78003c9f.
2023-09-12 22:30:13 +08:00
Kévin Dunglas
4bfca6fe93 always enable micro 2023-09-12 22:30:13 +08:00
Kévin Dunglas
dbec043894 temporary workaround for PECL certificate expiration 2023-09-12 22:30:13 +08:00
Kévin Dunglas
727d78a689 Revert "fix: replace down URL"
This reverts commit 6eadbca21bf9a3b57058160a2f7ea8f4cc5f21dd.
2023-09-12 22:30:13 +08:00
Kévin Dunglas
9b1e784604 fix: replace down URL 2023-09-12 22:30:13 +08:00
Kévin Dunglas
50d44d8310 explicitly disable unneeded SAPIs 2023-09-12 22:30:13 +08:00
Kévin Dunglas
3b300698f3 use lixml GH mirror because gitlab.gnome.org is down 2023-09-12 22:30:13 +08:00
Kévin Dunglas
899eb94b8b remove useless ls 2023-09-12 22:30:13 +08:00
Kévin Dunglas
451a0c0e34 workaround for macOS 2023-09-12 22:30:13 +08:00
Kévin Dunglas
085c1a159c feat: add support for libphp and the embed SAPI 2023-09-12 22:30:13 +08:00
Joseph Bielawski
ca3f8a350d Prevent fatal error when php source files are missing 2023-09-12 18:19:32 +08:00
crazywhalecc
5025850f71 fix Alpine docker install packages 2023-09-12 12:45:51 +08:00
crazywhalecc
fe2f658e08 dev:sort-config add \n at the end of json 2023-09-12 00:24:01 +08:00
crazywhalecc
00a49c662b add build:libs option --rebuild 2023-09-11 23:47:02 +08:00
Jerry Ma
be8eb90b86 cs fix (#166) 2023-09-08 22:12:59 +08:00
Jerry Ma
54e98666e7 Update ConsoleApplication.php 2023-09-08 22:03:40 +08:00
Joseph Bielawski
e8b277ad0d Prevent unknown extension call 2023-09-07 19:05:00 +08:00
Joseph Bielawski
3bd037f48f Rework style of dev command showing extensions details 2023-09-07 19:05:00 +08:00
Joseph Bielawski
4d0e825b43 Adjust dependencies in composer.json file
Removed unsupported Symfony versions
Bump minimal version of dev dependencies to the latest supported
2023-09-06 21:29:04 +08:00
Jerry Ma
b14179a8de Update README-en.md 2023-09-06 16:26:51 +08:00
Jerry Ma
01111c51ee Update README.md 2023-09-06 16:26:22 +08:00
Jerry Ma
e7230d9f50 Update README-en.md 2023-09-06 16:13:43 +08:00
Jerry Ma
c22c5617ad Update README.md 2023-09-06 16:05:38 +08:00
Joseph Bielawski
cae7bb1dda Add GH Action for tests 2023-09-06 15:47:10 +08:00
Joseph Bielawski
c0830a9e1f Allow setting suffix for licence name 2023-09-06 09:53:45 +08:00
Joseph Bielawski
33798ff108 Add simple unit test 2023-09-06 01:00:24 +08:00
Joseph Bielawski
8d348b9e14 Allow setting multiple license in extensions, libraries & sources 2023-09-06 01:00:24 +08:00
Joseph Bielawski
3d2f6e4c3a Sort lib definition 2023-09-04 23:12:13 +08:00
Joseph Bielawski
88e9639482 Fix operator precedence 2023-09-04 23:12:13 +08:00
Joseph Bielawski
0381a1c412 Adjust extension definition after review 2023-09-04 23:12:13 +08:00
Joseph Bielawski
fdc3a7a04b Add snappy extension 2023-09-04 23:12:13 +08:00
crazywhalecc
6de5c1dab0 Remove unused source libressl 2023-08-31 20:27:46 +08:00
Kévin Dunglas
dc28ce0899 fix: curl dependency on openssl 2023-08-31 20:05:37 +08:00
Kévin Dunglas
9286153742 fix: linxml build on macOS 2023-08-29 14:28:12 +08:00
crazywhalecc
f90892c92f fix curl in musl-gcc bug, fix #88 2023-08-27 03:24:32 +08:00
crazywhalecc
5359f3a79a fix webp compile to cmake, fix #95 2023-08-27 03:08:12 +08:00
crazywhalecc
42fbf18bba update license 2023-08-27 00:25:51 +08:00
crazywhalecc
ed227ce00e fix linux libxml2 #75 issue 2023-08-27 00:25:51 +08:00
crazywhalecc
6c49d35aec add libxslt compile command 2023-08-27 00:25:51 +08:00
crazywhalecc
238fd7fc74 add libxslt source 2023-08-27 00:25:51 +08:00
Kévin Dunglas
1ebc58664e ci: remove useless step and dump Compose autoloader 2023-08-26 17:58:34 +08:00
Kévin Dunglas
bcf64cbeef fix: throw if the PHP version doesn't exist 2023-08-26 13:58:09 +08:00
Kévin Dunglas
dc12d4d982 fix: ExceptionHandler:: must not be accessed before initialization 2023-08-26 13:57:43 +08:00
Kévin Dunglas
42e5877a7f fix: check of xz 2023-08-26 13:57:18 +08:00
Kévin Dunglas
a8924ac4fe fix: setup-runtime portability 2023-08-26 13:53:52 +08:00
Jerry Ma
7fb27c0c29 fix reference error 2023-08-23 10:42:53 +08:00
Kévin Dunglas
3d9a3194b2 hide warning 2023-08-22 23:37:34 +08:00
Kévin Dunglas
e7e0ac006f more optims 2023-08-22 23:37:34 +08:00
Kévin Dunglas
cf35a270bb minor: read Dockerfile from stdin 2023-08-22 23:37:34 +08:00
crazywhalecc
3e7ef49bde update README 2023-08-22 18:33:34 +08:00
crazywhalecc
100d31791a fix linux builder cpp link option 2023-08-22 18:19:04 +08:00
Kévin Dunglas
15905c063a fix: use apt-get instead of apt 2023-08-22 09:59:47 +08:00
Kévin Dunglas
4c46f6a762 fix: error when source doesn't exist 2023-08-22 09:56:47 +08:00
Kévin Dunglas
f4327c8c81 fix 2023-08-22 01:50:13 +08:00
Kévin Dunglas
4a4b0e209c detect PHP 8.1+ 2023-08-22 01:50:13 +08:00
Kévin Dunglas
60e06737d7 fix: disable Zend Signals and enable Zend Max Execution Timers for ZTS builds 2023-08-22 01:50:13 +08:00
Kévin Dunglas
d326154241 fix: musl detection on non-x86_64 2023-08-22 00:56:59 +08:00
crazywhalecc
4766ae146f change swoole-pgsql as alternative 2023-08-21 18:31:51 +08:00
kocoten1992
21a4ba7478 add swoole pgsql (--enable-swoole-pgsql) 2023-08-21 18:31:51 +08:00
crazywhalecc
dfdeab70f1 add buildroot bin PATH 2023-08-21 18:10:09 +08:00
crazywhalecc
c8fa767576 Do some code quality check and fix #126 2023-08-21 18:10:09 +08:00
Jerry Ma
9c57ed6439 Update README-en.md 2023-08-20 20:32:28 +08:00
Jerry Ma
585826b438 Update README.md 2023-08-20 20:32:07 +08:00
Kévin Dunglas
cf22949f3b minor: prevent warning when installing cmake with Homebrew 2023-08-20 20:30:07 +08:00
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
263 changed files with 20092 additions and 1463 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']

12
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,12 @@
## What does this PR do?
## Checklist before merging
> If your PR involves the changes mentioned below and completed the action, please tick the corresponding option.
> If a modification is not involved, please skip it directly.
- [ ] If it's a extension or dependency update, make sure adding related extensions in `src/global/test-extensions.php`.
- [ ] If you changed the behavior of static-php-cli, add docs in [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs) .
- [ ] If you updated `config/xxxx.json` content, run `bin/spc dev:sort-config xxx`.

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

@@ -0,0 +1,107 @@
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.3'
- '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-${{ inputs.extensions }}
# 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 }} --for-extensions=${{ inputs.extensions }} ${{ 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

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

@@ -0,0 +1,113 @@
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.3'
- '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
# 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 --classmap-authoritative
# Cache downloaded source
- id: cache-download
uses: actions/cache@v3
with:
path: downloads
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
# 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 }} --for-extensions=${{ inputs.extensions }} ${{ 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

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

@@ -0,0 +1,118 @@
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.3'
- '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 --classmap-authoritative
# Cache downloaded source
- id: cache-download
uses: actions/cache@v3
with:
path: downloads
key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }}
# 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 }} --for-extensions=${{ inputs.extensions }} ${{ 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

View File

@@ -1,67 +0,0 @@
name: Build PHP
on:
push:
branches: [ master ]
paths:
- ".github/workflows/**.yml"
- "docker/**"
jobs:
integration:
name: Build PHP ${{ matrix.php-versions }} for ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ "7.4.30", "8.0.23", "8.1.10", "8.2.0" ]
arch: [ "x86_64", "aarch64", "armv7l" ]
steps:
- uses: actions/checkout@v2
- name: Check Dockerfile to ${{ matrix.arch }}
run: |
cd docker/
if [[ "${{ matrix.arch }}" != "x86_64" ]]; then
if [[ "${{ matrix.arch }}" = "armv7l" ]]; then
sed -ie 's/alpine:latest/multiarch\/alpine:armv7-latest-stable/g' Dockerfile
else
sed -ie 's/alpine:latest/multiarch\/alpine:${{ matrix.arch }}-v3.16/g' Dockerfile
fi
docker run --rm --privileged multiarch/qemu-user-static:register --reset
fi
- name: Build micro and PHP distribution ${{ matrix.php-versions }} for ${{ matrix.arch }}
id: buildphp
run: |
cd docker/ && docker build . --tag static-php --build-arg USE_BACKUP_ADDRESS=yes && \
mkdir ../dist && \
docker run --rm -v $(pwd)/../dist:/dist/ static-php build-php original ${{ matrix.php-versions }} all /dist/
- name: Fail if anything failed
if: steps.buildphp == 'failure'
run: |
false
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: static-php-cli_${{ matrix.php-versions }}_${{ matrix.arch }}
path: |
dist
- name: Pack PHP ${{ matrix.php-versions }} to archive
run: |
cd dist
tar -zcvf "php-${{ matrix.php-versions }}-static-bin-${{ matrix.arch }}.tar.gz" ./php && rm ./php
if [ -f "./micro.sfx" ]; then
tar -zcvf "micro-${{ matrix.php-versions }}-${{ matrix.arch }}.tar.gz" ./micro.sfx && rm ./micro.sfx
fi
- name: Deploy to Zhamao Server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }}
ARGS: "-rltgoDzvO"
SOURCE: "dist/"
REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }}
REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }}
REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }}
TARGET: ${{ secrets.DEPLOY_SERVER_TARGET }}
- name: Remove dist directory
run: |
rm -rf dist/
docker images | grep -v REPOSITORY | awk '{print $3}' | xargs docker rmi --force

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", "8.3" ]
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/

47
.github/workflows/release-build.yml vendored Normal file
View File

@@ -0,0 +1,47 @@
name: Upload SPC Binary (Release)
on:
release:
types:
- published
workflow_dispatch:
jobs:
build-release-artifacts:
name: "Upload SPC Binary (Release)"
runs-on: ubuntu-latest
strategy:
matrix:
operating-system:
- "linux-x86_64"
- "macos-x86_64"
- "linux-aarch64"
- "macos-aarch64"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: Reuse static-php-cli-hosted artifacts
uses: dawidd6/action-download-artifact@v2
with:
repo: static-php/static-php-cli-hosted
branch: master
workflow: build-spc-release.yml
name: "spc-${{ matrix.operating-system }}"
- name: "Archive Executable"
run: |
tar -czf spc-${{ matrix.operating-system }}.tar.gz spc
echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV
- name: upload binaries to release
uses: softprops/action-gh-release@v1
if: ${{startsWith(github.ref, 'refs/tags/') }}
with:
files: ${{ env.filename }}
- name: "Upload Artifact"
uses: actions/upload-artifact@v3
with:
path: spc
name: spc-${{ matrix.operating-system }}

146
.github/workflows/tests.yml vendored Normal file
View File

@@ -0,0 +1,146 @@
name: Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
tools: pecl, composer, php-cs-fixer
- name: Run PHP-CS-Fixer fix
run: php-cs-fixer fix --dry-run --diff --ansi
phpstan:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
tools: composer
- name: "Cache Composer packages"
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-phpstan-
- name: "Install Dependencies"
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: "Run phpstan"
run: vendor/bin/phpstan analyse
phpunit:
name: "PHPUnit (PHP ${{ matrix.php }})"
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
include:
- php: '8.1'
- php: '8.2'
- php: '8.3'
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: pecl, composer
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
- name: "Cache Composer packages"
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: "Install Dependencies"
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: "Run PHPUnit Tests"
run: |
vendor/bin/phpunit tests/ --no-coverage
build:
name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})"
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
matrix:
php:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
os:
- ubuntu-latest
- macos-latest
fail-fast: false
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: pecl, composer
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
- name: "Cache Composer packages"
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: "Install Dependencies"
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: "Run Build Tests (doctor)"
run: bin/spc doctor --auto-fix
- name: "Run Build Tests (download)"
run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php)" --with-php=${{ matrix.php }} --debug
- name: "Run Build Tests (build)"
run: bin/spc build "$(php src/globals/test-extensions.php)" --build-cli --build-micro --build-fpm --debug

25
.gitignore vendored
View File

@@ -3,3 +3,28 @@ runtime/
docker/libraries/
docker/extensions/
docker/source/
# Vendor files
/vendor/
# default source extract directory
/source/
# default source download directory
/downloads/
# default source build root directory
/buildroot/
# tools cache files
.php-cs-fixer.cache
.phpunit.result.cache
# exclude self-runtime
/bin/*
!/bin/spc
!/bin/setup-runtime
!/bin/spc-alpine-docker
# default test directory
/tests/var/

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', __DIR__ . '/tests/SPC'])
);

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022 Jerry Ma
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

View File

@@ -1,180 +1,3 @@
# static-php-cli
Compile A Statically Linked PHP With Swoole and other Popular Extensions.
Compile A Single Binary With PHP Code.
**If you are intrested in this project, don't miss this discussion: <https://github.com/crazywhalecc/static-php-cli/discussions/29>**
[![version](https://img.shields.io/badge/version-1.5.2-green.svg)]()
![Build Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build-php.yml/badge.svg)
## Compilation Requirements
- Supporting architecture: `x86_64`, `arm64(aarch64)`, `armv7(armv7l)`
- Docker required (or alpine linux 3.13+)
- PHP version from 7.2 to 8.1
- Micro Package requires PHP >= 8.0
## Runtime Requirements
Linux
## Usage
1. Directly download static binary from this link or [Actions uploaded artifacts](https://github.com/crazywhalecc/static-php-cli/actions).
<https://dl.zhamao.xin/php-bin/file/>
2. Use fast install script `install-runtime.sh` to download static php and composer distribution into `runtime/` directory
But this script has some Chinese comments and prompts, if you cannot understand or have to use it in English, I will make an pure international version! :)
```bash
bash -c "`curl -fsSL https://raw.githubusercontent.com/crazywhalecc/static-php-cli/master/install-runtime.sh`"
```
## Packing PHP Code into a Static Binary
From v1.5.0, we support packing PHP code into a static binary. You can pack your PHP code into a static binary by micro.
You can directly download `micro-` prefix file, untar it and you will get file `micro.sfx`.
Here's a simple example to use it:
```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 phar into a static binary, just change code.php to your phar path.
```
> Note: It means that your PHP code won't be compiled and you can't protect your source code by using micro!
>
> If you are looking for compiling PHP code or encrypting code, here's not your solution.
>
> Special thanks: <https://github.com/dixyes/phpmicro>
## Compiling
Here's help command to compile it yourself:
```bash
git clone https://github.com/crazywhalecc/static-php-cli.git
cd static-php-cli/docker
docker build -t static-php . --build-arg USE_BACKUP_ADDRESS=yes
# Making a directory to put binary files
mkdir dist
# It will ask you for PHP version, extensions, and compile static binaries
docker run --rm -v $(pwd)/dist:/dist/ -it static-php build-php
```
After compilation you can use command to get static php binary file.
```bash
cd dist
file ./php
```
If you don't want to use docker, a single script for compiling in **Alpine Linux**:
```bash
cd docker
# Change PHP Version
export VER_PHP="8.1.7"
# Use Original download link (Default is China mainland mirror link, for others please use 'yes' for original link)
export USE_BACKUP="yes"
./fast-compiler.sh
```
To customize PHP extensions, edit `docker/extensions.txt` file, and rules below:
- Use `^` as deselect, to mark not install. Use `#` as comments.
- extensions name uses lower case, and default file contains all supported extensions, if u need other extensions, consider write an Issue
## Supported PHP extensions
| Support | PHP Ext Name | Version | Comments |
| ------- | ------------ | ------- | ---------------------------------------- |
| yes | bcmath | * | |
| yes | calendar | * | |
| yes | ctype | * | |
| yes | curl | * | |
| yes | dom | * | |
| yes | event | >=3.0.8 | author's bitbucket version, not pecl |
| yes | exif | * | |
| yes | filter | * | |
| yes | fileinfo | * | |
| yes | gd | * | |
| yes | hash | * | |
| yes | iconv | * | |
| yes | inotify | 3.0.0 | |
| yes | json | * | |
| yes | libxml | * | |
| yes | mbstring | * | |
| yes | mongodb | >=1.9.1 | not tested |
| | mysqli | | |
| yes | mysqlnd | * | |
| yes | openssl | * | |
| yes | pcntl | * | |
| yes | pdo | * | |
| yes | pdo_mysql | * | |
| yes | pdo_sqlite | * | |
| | pdo_pgsql | * | |
| yes | phar | * | |
| yes | posix | * | |
| yes, not compiled | protobuf | * | Not compiled and enabled as default |
| yes | readline | * | Not support `./php -a` |
| yes | redis | * | |
| yes | shmop | * | |
| yes | simplexml | * | |
| yes | soap | * | |
| yes | sockets | * | |
| yes | sqlite3 | * | |
| yes | swoole | >=4.6.6 | support mysqlnd, sockets, openssl, redis |
| yes | tokenizer | * | |
| yes | xml | * | |
| yes | xmlreader | * | |
| yes | xmlwriter | * | |
| yes | zip | * | not support `bzip2`, `lzma` compression |
| yes | zlib | * | |
## Customization
- If you are going to run without prompt, Just add it to the end of `docker run xxx` cmd according to the parameters given below.
> 1st parameter `original` represents that you are using global original download address to fetch dependencies, if you are in mainland China, use `mirror`.
>
> 2nd parameter `8.1.7` is your PHP version you are compiling.
>
> 3rd parameter `all` represents that you will compile all supported extensions.
>
> 4th parameter `/dist/` is your binary output directory.
>
> For example, `docker run --rm -v $(pwd)/dist:/dist/ -it static-php build-php original 8.1.7 all /dist/`
- `docker/extensions.txt` edit extensions.
- `docker/compile-php.sh` file `php_compile_args` function to adjust PHP configure arguments.
- `docker/check-extensions.sh` file `check_in_configure` function to adjust extensions' configure arguments.
- `docker/config.json` edit extensions and dependencies version and download links.
## Current Issue
- [X] Not support event(libevent), because of its `config.m4` and code.
- [ ] Swoole not support `--enable-swoole-curl`.
- [X] Not support readline, maybe caused by ncurses library.
- [X] Not support curl (solved)
- [X] Customize extensions to compile
- [X] php.ini integration
- [X] i18n (including README and scripts)
## Running preview
### Using static binary
<img width="881" alt="未命名" src="https://user-images.githubusercontent.com/20330940/168441751-e62cb8d4-a3c8-42d9-b34e-d804b39756a1.png">
### Using swoole application packed with micro
<img width="937" alt="all" src="https://user-images.githubusercontent.com/20330940/168557743-b8f92263-712f-490e-9fe0-831597741595.png">
## 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/>
English README has been moved to [README.md](README.md).

254
README-zh.md Executable file
View File

@@ -0,0 +1,254 @@
# static-php-cli
Build single static PHP binary, with PHP project together, with popular extensions included.
🌐 **[中文](README-zh.md)** | **[English](README.md)**
编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携cli SAPI
<img width="600" alt="截屏2023-05-02 15 53 13" src="https://user-images.githubusercontent.com/20330940/235610282-23e58d68-bd35-4092-8465-171cff2d5ba8.png">
同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发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">
> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/static-php/phpmicro)。
[![Version](https://img.shields.io/badge/Version-2.0--rc8-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/static-php/static-php-cli-hosted/build-php-common.yml?branch=refactor&label=Build%20Common%20Extensions&style=flat-square)](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.yml)
[![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]()
[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]()
> 项目名称是 static-php-cli但其实支持 cli、fpm、micro 和 embed SAPI 😎
## 文档
目前 README 编写了基本用法。有关 static-php-cli 所有的功能,请点击这里查看文档:<https://static-php.dev>。
## 自托管直接下载
如果你不想自行编译 PHP可以从本项目现有的示例 Action 下载 Artifact也可以从自托管的服务器下载。
- [扩展组合 - common](https://dl.static-php.dev/static-php-cli/common/)common 组合包含了约 [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) 个常用扩展,体积为 22MB 左右。
- [扩展组合 - bulk](https://dl.static-php.dev/static-php-cli/bulk/)bulk 组合包含了 [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) 个扩展,体积为 70MB 左右。
- [扩展组合 - minimal](https://dl.static-php.dev/static-php-cli/minimal/)minimal 组合包含了 [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) 个扩展,体积为 6MB 左右。
## 使用 static-php-cli 构建 PHP
### 编译环境需求
是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。
但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。
下面是架构支持情况,:octocat: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。
| | x86_64 | aarch64 |
|---------|----------------------|----------------------|
| macOS | :octocat: :computer: | :computer: |
| Linux | :octocat: :computer: | :octocat: :computer: |
| Windows | | |
| FreeBSD | :computer: | :computer: |
> macOS-arm64 因 GitHub 暂未提供 arm runner如果要构建 arm 二进制,可以使用手动构建。
目前支持编译的 PHP 版本为:`7.3``7.4``8.0``8.1``8.2``8.3`
### 支持的扩展情况
请先根据下方扩展列表选择你要编译的扩展。
- [扩展支持列表](https://static-php.dev/zh/guide/extensions.html)
- [编译命令生成器](https://static-php.dev/zh/guide/cli-generator.html)
> 如果这里没有你需要的扩展,可以提交 Issue。
### 使用 Actions 构建
使用 GitHub Action 可以方便地构建一个静态编译的 PHP同时可以自行定义要编译的扩展。
1. Fork 本项目。
2. 进入项目的 Actions选择 CI。
3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`
4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`
如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。
### 手动构建(使用 SPC 二进制)
本项目提供了一个 static-php-cli 的二进制文件,你可以直接下载对应平台的二进制文件,然后使用它来构建静态的 PHP。目前 `spc` 二进制支持的平台有 Linux 和 macOS。
下面是从 GitHub Action 下载的方法:
1. 进入 [GitHub Action](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。
2. 选择一个最新的构建任务,进入后选择 `Artifacts`,下载对应平台的二进制文件。
3. 解压 `.zip` 文件。解压后,为其添加执行权限:`chmod +x ./spc`
你也可以从自托管的服务器下载二进制文件:[进入](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/)。
### 手动构建(使用源码)
先克隆本项目:
```bash
git clone https://github.com/crazywhalecc/static-php-cli.git
```
如果你本机没有安装 PHP你需要先使用包管理例如 brew、apt、yum、apk 等)安装 php。
你也可以通过 `bin/setup-runtime` 命令下载静态编译好的 php-cli 和 Composer。下载的 php 和 Composer 将保存为 `bin/php``bin/composer`
```bash
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
# 初始化本项目
cd static-php-cli
composer update
chmod +x bin/spc
```
### 使用 static-php-cli 命令行程序
下面是使用 static-php-cli 编译静态 php 和 micro 的基础用法:
> 如果你使用的是打包好的 `spc` 二进制,你需要将下列命令的 `bin/spc` 替换为 `./spc`。
```bash
# 检查环境依赖,并根据提示的命令安装缺失的编译工具
./bin/spc doctor
# 拉取所有依赖库
./bin/spc fetch --all
# 只拉取编译指定扩展需要的所有依赖
./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite
# 构建包含 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
```
你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.3
```bash
# 优先考虑使用 >= 8.0 的 PHP 版本,因为 phpmicro 不支持在 PHP7 中构建
./bin/spc download --with-php=8.2 --all
```
其中,目前支持构建 climicrofpm 三种静态二进制,使用以下参数的一个或多个来指定编译的 SAPI
- `--build-cli`:构建 cli 二进制
- `--build-micro`:构建 phpmicro 自执行二进制
- `--build-fpm`:构建 fpm
- `--build-embed`:构建 embedlibphp
- `--build-all`:构建所有
如果出现了任何错误,可以使用 `--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 等工具调试,但这样会让静态二进制体积变大。
## 不同 SAPI 的使用
### 使用 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
> 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 文件路径即可。
你可以使用 [box-project/box](https://github.com/box-project/box) 将你的 CLI 项目打包为 Phar
然后将它与 phpmicro 结合,生成独立可执行的二进制文件。
```bash
# 使用 static-php-cli 生成的 micro.sfx 结合,也可以直接使用 cat 命令结合它们
bin/spc micro:combine my-app.phar
cat buildroot/bin/micro.sfx my-app.phar > my-app && chmod +x my-app
# 使用 micro:combine 结合可以将 INI 选项注入到二进制中
bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2
```
> 有些情况下的 phar 文件或 PHP 项目可能无法在 micro 环境下运行。
### 使用 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`
### 使用 embed
采用项目参数 `--build-embed``--build-all` 时,最后编译结果会输出一个 `libphp.a``php-config` 以及一系列头文件,存放在 `buildroot/`,你可以在你的其他代码中引入它们。
如果你知道 [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed),你应该知道如何使用它。对于有可能编译用到引入其他库的问题,你可以使用 `buildroot/bin/php-config` 来获取编译时的配置。
另外,有关如何使用此功能的高级示例,请查看[如何使用它构建 FrankenPHP 的静态版本](https://github.com/dunglas/frankenphp/blob/main/docs/static.md)。
## 贡献
如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉也欢迎为本项目发起 Pull Request。
另外,添加新扩展的贡献方式,可以参考下方 `进阶`
如果你想贡献文档内容,请到项目仓库 [static-php/static-php-cli-docs](https://github.com/static-php/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.dev) 贡献代码或文档。

402
README.md
View File

@@ -1,217 +1,291 @@
# static-php-cli
Compile A Statically Linked PHP With Swoole and other Extensions. [English README](README-en.md)
**如果你对本项目有兴趣,请看讨论进行投票:<https://github.com/crazywhalecc/static-php-cli/discussions/29>**
Build single static PHP binary, with PHP project together, with popular extensions included.
编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!
🌐 **[中文](README-zh.md)** | **[English](README.md)**
同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!
The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎
注:只能编译 CLI 模式,暂不支持 CGI 和 FPM 模式
Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI)
[![版本](https://img.shields.io/badge/script--version-1.5.2-green.svg)]()
[![License](https://img.shields.io/badge/License-MIT-blue.svg)]()
![Build Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build-php.yml/badge.svg)
<img width="600" alt="2023-05-02 15 53 13" src="https://user-images.githubusercontent.com/20330940/235610282-23e58d68-bd35-4092-8465-171cff2d5ba8.png">
## 编译环境需求
You can also use the micro binary file to combine php binary and php source code into one for distribution! (micro SAPI)
- 目前支持 arm64、x86_64、armv7l 架构
- 需要 Docker也可以直接在 Alpine Linux 上使用)
- 脚本支持编译的 PHP 版本7.2 ~ 8.1
<img width="600" alt="2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
## 运行环境需求
> This SAPI feature is from the [Fork](https://github.com/static-php/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro).
Linux
[![Version](https://img.shields.io/badge/Version-2.0--rc8-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-65+-yellow.svg?style=flat-square)]()
[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]()
1. 可以直接下面的托管服务器或到 `Actions` 找到最新的构建项目下载 Actions 构建的文件。
## Documentation
<https://dl.zhamao.xin/php-bin/file/>
The current README contains basic usage. For all the features of static-php-cli,
see <https://static-php.dev> .
2. 可以直接使用快速脚本 `install-runtime.sh`,将静态 PHP 二进制及 Composer 下载到当前目录的 `runtime/` 子目录下:
## Direct Download
If you don't want to compile yourself, you can download example pre-compiled artifact from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.yml), or from self-hosted server.
Below are several precompiled static-php binaries with different extension combinations,
which can be downloaded directly according to your needs.
- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` combination contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB.
- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` combination contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size.
- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` combination contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size.
## Use static-php-cli to build PHP
### 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 :octocat: represents support for GitHub Action builds,
:computer: represents support for local manual builds, and blank represents not currently supported.
| | x86_64 | aarch64 |
|---------|----------------------|----------------------|
| macOS | :octocat: :computer: | :computer: |
| Linux | :octocat: :computer: | :octocat: :computer: |
| Windows | | |
| FreeBSD | :computer: | :computer: |
> 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.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`.
### Supported Extensions
Please first select the extension you want to compile based on the extension list below.
- [Supported Extension List](https://static-php.dev/en/guide/extensions.html)
- [Command Generator](https://static-php.dev/en/guide/cli-generator.html)
> If an extension you need is missing, you can submit an issue.
Here is the current planned roadmap for extension support: [#152](https://github.com/crazywhalecc/static-php-cli/issues/152) .
### GitHub Actions Build
Use GitHub Action to easily build a statically compiled PHP,
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 (using SPC binary)
This project provides a binary file of static-php-cli.
You can directly download the binary file of the corresponding platform and then use it to build static PHP.
Currently, the platforms supported by `spc` binary are Linux and macOS.
Here's how to download from GitHub Actions:
1. Enter [GitHub Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml) or [self-hosted nightly builds](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/).
2. If you download from GHA, select the latest build task, select `Artifacts`, and download the binary file of the corresponding platform.
3. If you download from GHA, unzip the `.zip` file. After decompressing, add execution permissions to it: `chmod +x ./spc`.
4. If you download from self-hosted server, download `spc-$os-$arch` file and just use it (don't forget `chmod +x`).
> SPC single-file binary is built by phpmicro and box, and it doesn't need to install PHP. Just treat `spc` as a standalone executable.
### Manual build (using source code)
Clone repo first:
```bash
# 可以使用 export ZM_DOWN_PHP_VERION=8.0 来切换 PHP 版本
bash <(curl -fsSL https://dl.zhamao.xin/php-bin/install-runtime.sh)
git clone https://github.com/crazywhalecc/static-php-cli.git
```
## PHP 代码打包使用
If you have not installed php on your system, you can use package management to install PHP (such as brew, apt, yum, apk etc.).
v1.5.0 脚本开始,脚本新增了对 PHP 代码打包的支持,可以将 PHP 代码打包为一个文件分发,方便在 Linux 系统使用。(仅支持 PHP >= 8.0
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`.
1. 可以直接在上面的下载链接中下载 `micro-` 开头的文件并解压,获得 `micro.sfx` 文件后,使用以下命令和 PHP 源码或 PHAR 结合:
```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
# Use this php runtime to run static-php-cli compiler
./bin/php bin/spc
# Use composer
./bin/php bin/composer
# Initialize this project
cd static-php-cli
composer update
chmod +x bin/spc
```
### Use static-php-cli
Basic usage for building php and micro with some extensions:
> If you are using the packaged `spc` binary, you need to replace `bin/spc` with `./spc` in the following commands.
```bash
# Check system tool dependencies, fix them if possible
./bin/spc doctor
# fetch all libraries
./bin/spc download --all
# only fetch necessary sources by needed extensions
./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite
# 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.3:
```bash
# Using PHP >= 8.0 is recommended, because PHP7 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-embed`: build embed (libphp)
- `--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 (non-thread-safe) 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.
## Different SAPI Usage
### Use cli
> 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)
```
### Use micro
> phpmicro is a SelF-extracted eXecutable SAPI module,
> provided by [phpmicro](https://github.com/dixyes/phpmicro) project.
> But this project is using a [fork](https://github.com/static-php/phpmicro) of phpmicro, because we need to add some features to it.
> 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
# 如果打包 PHAR 文件,仅需把 code.php 更换为 phar 文件路径即可
```
2. 如果打包项目,可以先将项目打包为 phar + entry然后结合打包 micro 与 phar 文件即可。
> 关于如何将项目打包为 phar见项目 [php-cli-helper](https://github.com/crazywhalecc/php-cli-helper)。
> 感谢 <https://github.com/dixyes/phpmicro> 项目提供的支持
## 自行编译
可以自己使用 Dockerfile 进行编译构建:
If you package a PHAR file, just replace `code.php` with the phar file path.
You can use [box-project/box](https://github.com/box-project/box) to package your CLI project as Phar,
It is then combined with phpmicro to produce a standalone executable binary.
```bash
# Use the micro.sfx generated by static-php-cli to combine,
bin/spc micro:combine my-app.phar
# or you can directly use the cat command to combine them.
cat buildroot/bin/micro.sfx my-app.phar > my-app && chmod +x my-app
git clone https://github.com/crazywhalecc/static-php-cli.git
cd static-php-cli/docker
export DOCKER_BUILDKIT=1
docker build -t static-php . --build-arg USE_BACKUP_ADDRESS=no
# 新建一个用于放置构建好的二进制的文件夹
mkdir dist
# 终端会引导你进行编译安装,可选择 PHP 版本、要编译的扩展
docker run --rm -v $(pwd)/dist:/dist/ -it static-php build-php
# Use micro:combine combination to inject INI options into the binary.
bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2
```
编译之后可以使用下方命令将二进制 PHP 提取出来,用以下方式:
> In some cases, PHAR files may not run in a micro environment. Overall, micro is not production ready.
```bash
cd dist
file ./php
# 如果是 PHP 8.0 以上,同时会输出 micro 构建版本
file ./micro.sfx
```
### Use fpm
如果你不想使用 Docker想从Alpine环境直接编译可以使用预置相同编译配置的脚本 `fast-compiler.sh`
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.
```bash
cd docker
# 用于切换编译的PHP版本
export VER_PHP="8.1.7"
./fast-compiler.sh
```
In common 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.
如果要选择安装的扩展,可以修改 `docker/extensions.txt` 文件,具体规则如下:
- 文件内使用 `^` 可以表示默认不安装该扩展,`#` 开头可以编写注释
- 扩展名一律使用小写,目前默认状态下文件内所列的扩展为支持的扩展,其他扩展暂不支持,如有需求请提 Issue 添加
Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`.
## 支持的扩展表
| 是否支持 | PHP 扩展名称 | 支持版本 | 备注 |
| -------- | ------------ | -------- | ------------------------------------------------------- |
| yes, enabled | bcmath | * | |
| yes, enabled | calendar | * | |
| yes, enabled | ctype | * | |
| yes, enabled | curl | * | 自带下载编译 curl 库 |
| yes, enabled | dom | * | |
| yes, enabled | event | >=3.0.8 | 从 BitBucket 作者仓库下载,非 pecl 版本 |
| yes, enabled | exif | * | |
| yes, enabled | filter | * | |
| yes, enabled | fileinfo | * | |
| yes, enabled | gd | * | |
| yes, enabled | hash | * | |
| yes, enabled | iconv | * | |
| yes, enabled | inotify | 3.0.0 | 从 pecl 或镜像站下载的源码 |
| yes, enabled | json | * | |
| yes, enabled | libxml | * | 自带下载编译 libxml2 库 |
| yes, enabled | mbstring | * | |
| yes, enabled | mongodb | >=1.9.1 | 未测试,从 pecl 或镜像站下载的源码 |
| | mysqli | | |
| yes, enabled | mysqlnd | * | |
| yes, enabled | openssl | * | |
| yes, enabled | pcntl | * | |
| yes, enabled | pdo | * | |
| yes, enabled | pdo_mysql | * | |
| yes, enabled | pdo_sqlite | * | |
| | pdo_pgsql | * | |
| yes, enabled | phar | * | |
| yes, enabled | posix | * | |
| yes, not enabled | protobuf | * | 默认不编译 |
| yes, enabled | readline | * | 不支持 `./php -a` |
| yes, enabled | redis | * | 从 pecl 或镜像站下载的源码 |
| yes, enabled | shmop | * | |
| yes, enabled | simplexml | * | |
| yes, enabled | soap | * | |
| yes, enabled | sockets | * | |
| yes, enabled | sqlite3 | * | |
| yes, enabled | swoole | >=4.6.6 | 使用参数 `--enable-openssl --with-openssl --with-openssl-dir=/usr`,从 pecl 或镜像站下载的源码 |
| yes, enabled | tokenizer | * | |
| yes, enabled | xml | * | |
| yes, enabled | xmlreader | * | |
| yes, enabled | xmlwriter | * | |
| yes, enabled | zip | * | 因链接库原因已关闭 `libzip` 库的 `bzip2``lzma` 支持 |
| yes, enabled | zlib | * | |
### Use embed
## 自定义
- 从 Docker 运行编译会依次询问下载地址、PHP 版本、要编译的扩展、编译输出文件夹。
- 如果不想弹出终端交互框,只需按照下方给出的参数加到字符串的后面。
When using the project parameters `--build-embed` or `--build-all`,
the final compilation result will output a `libphp.a`, `php-config` and a series of header files,
stored in `buildroot/`. You can introduce them in your other projects.
> `参数1`: `original` 代表使用原始地址,如果你位于中国大陆,可使用 `mirror` 加快下载。
>
> `参数2`: `8.1.7` 是你要编译的 PHP 版本。
>
> `参数3`: `all` 代表你要编译所有非反选的扩展,不询问。
>
> `参数4`: `/dist/` 是你编译后输出二进制 PHP 和 micro 的文件夹
>
> 基本例子: `docker run --rm -v $(pwd)/dist:/dist/ -it static-php build-php original 8.1.7 all /dist/`
If you know [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed), you should know how to use it.
You may require the introduction of other libraries during compilation,
you can use `buildroot/bin/php-config` to obtain the compile-time configuration.
- `docker/extensions.txt` 指定要编译安装的扩展。
- `docker/extensions.txt` 中,`^` 开头的扩展名为反选,反选的扩展将出现在编译的扩展列表中,但默认不选中。
- `docker/compile-php.sh` 中的 `php_compile_args` 函数来调整 PHP 编译参数。
- `docker/check-extensions.sh` 中的 `check_in_configure` 函数可调整 PHP 扩展编译的参数。
- `docker/config.json` 可调整要下载的扩展和依赖库版本和链接。
- `docker/fast-compiler.sh` 可以在 Alpine Linux 系统下直接运行。
For an advanced example of how to use this feature, take a look at [how to use it to build a static version of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/static.md).
## 目前的问题(对勾为已解决)
- [X] 不支持 event(libevent) 扩展event 扩展的 sockets 支持不能在静态编译中使用,因为静态内嵌编译暂时没办法调整扩展编译顺序,同时其本身也不支持静态编译。
- [ ] Swoole 扩展不支持 `--enable-swoole-curl`,也是因为编译顺序和加载顺序的问题。
- [X] 不支持 readline 扩展readline 扩展安装后无法正常使用 `php -a`,原因还没有弄清楚,可能是静态编译造成的 ncurses 库出现了问题。
- [X] curl/libcurl 扩展静态编译
- [X] 可自行选择不需要编译进入的扩展
- [X] php.ini 内嵌或分发
- [X] i18n国际化脚本本身和 README
## Contribution
如果你对以上问题有解决方案,请提出 Issue 或 PR
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.
如果你对此脚本比较感兴趣,未来会在此编写脚本中涉及内容的解析和说明。
If you want to contribute documentation, please go to [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs).
## 运行示例
Now there is a [static-php](https://github.com/static-php) organization, which is used to store the repo related to the project.
### 静态 PHP 运行脚本
## Sponsor this project
<img width="881" alt="未命名" src="https://user-images.githubusercontent.com/20330940/168441751-e62cb8d4-a3c8-42d9-b34e-d804b39756a1.png">
You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md).
### micro 打包运行 Swoole
## Open-Source License
<img width="937" alt="all" src="https://user-images.githubusercontent.com/20330940/168557743-b8f92263-712f-490e-9fe0-831597741595.png">
This project itself is based on MIT License,
some newly added extensions and dependencies may originate from the the other projects,
and the headers of these code files will also be given additional instructions LICENSE and AUTHOR.
## 原理
These are similar projects:
静态编译是一项比较多见于 Golang 的编译方式,在传统的 Linux 系统下正常的程序和库基本是动态编译链接Dynamically linked也就是说不同程序引用同样的库可以共用减少资源重复。
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)
但是由于不少系统软件环境配置复杂,或者依赖的库版本冲突,一般使用 Docker 等容器技术可以解决这一问题。但 Docker 等容器也需要拉取镜像,体积较大,对于程序有便携需求的人(比如网络安全员做渗透测试等)需要很多程序可以像 Windows 上的绿色程序一样随处打包运行。
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.
PHP 是最好的编程语言,它编写容易,易于部署和开发,倘若将 PHP 编译为静态的文件,并且将 Swoole 或 libevent 等库同样内嵌,那 PHP 不仅将可以编写便携的 Web 服务器,还能做很多想不到的事!
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.
编译静态 PHP 大致分为以下几个步骤:
1. 下载 PHP 源码
2. 下载需要静态编译的额外扩展源码(如 inotify、mongodb、redis 等)
3. 将额外扩展源码放入 PHP 源码中
4. 生成 `configure` 并使用 `-static` 的 FLAG 进行生成 makefile
5. 修改 Makefile 中的编译参数,增加 `-all-static` 和去掉 dynamic 相关的参数
6. 使用 `make` 构建静态 PHP
7. 使用 `make install` 安装到指定目录,再使用 `strip` 去除符号表缩小体积
对于第二步,如果额外扩展中有依赖 Linux 的其他库(比如 curl 依赖 libcurl则需要在第二步之前编译安装对应库的静态版本比如 libxml2.a
而此处出问题最多的部分就是安装额外扩展的依赖上,很多库不支持静态编译,而互联网很难找到对对应库进行静态编译的资料。
脚本和 Dockerfile 统一采用 Alpine 的目的就是apk 包管理下有很多库提供了 `*-static` 静态版本,直接使用包管理安装就可以使用,而即使没有,也可以使用 musl-libc 进行静态编译,避免 glibc 下的 `libnss` 等无法静态编译的问题。
第二种要面对比较棘手的问题就是 PHP 扩展可能本身不支持静态编译(如 curl 扩展),有些通过绕过手段可以静态编译,但有些只能通过对扩展源码进行修改才能使其支持。
所以这个项目中涉及的脚本,最大的问题就在于对其他依赖的处理,而不是 PHP 编译本身。PHP 如果不启用任何扩展(即使用 `--disable-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/>

75
bin/setup-runtime Executable file
View File

@@ -0,0 +1,75 @@
#!/usr/bin/env sh
# 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.static-php.dev/static-php-cli/common/php-8.2.12-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.static-php.dev/static-php-cli/common/php-8.2.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar"
;;
esac
if ! command -v curl > /dev/null && command -v apk > /dev/null; then
apk add --no-cache curl
fi
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 ""

18
bin/spc Executable file
View File

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

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

@@ -0,0 +1,113 @@
#!/usr/bin/env sh
# This file is using docker to run commands
# 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"
# shellcheck disable=SC2046
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"
# shellcheck disable=SC2039
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
# shellcheck disable=SC2039
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 ..."
$DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH -f- . <<EOF
FROM $ALPINE_FROM
$SPC_USE_MIRROR
RUN apk update; \
apk add --no-cache \
autoconf \
automake \
gettext \
bash \
binutils \
bison \
build-base \
cmake \
curl \
file \
flex \
g++ \
gcc \
git \
jq \
libgcc \
libtool \
libstdc++ \
linux-headers \
m4 \
make \
php82 \
php82-common \
php82-pcntl \
php82-phar \
php82-posix \
php82-sodium \
php82-tokenizer \
php82-dom \
php82-xml \
php82-xmlwriter \
composer \
pkgconfig \
wget \
xz
WORKDIR /app
ADD ./src /app/src
COPY ./composer.* /app/
ADD ./bin /app/bin
RUN composer install --no-dev --classmap-authoritative
EOF
fi
# Check if in ci (local terminal can execute with -it)
if [ -t 0 ]; then
INTERACT=-it
else
INTERACT=''
fi
# Run docker
# shellcheck disable=SC2068
$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 $@

19
box.json Normal file
View File

@@ -0,0 +1,19 @@
{
"alias": "spc-php.phar",
"banner": false,
"blacklist": [
".github"
],
"directories": [
"config",
"src",
"vendor/psr",
"vendor/laravel/prompts",
"vendor/illuminate",
"vendor/symfony",
"vendor/zhamao"
],
"git-commit-short": "git_commit_short",
"metadata": "ConsoleApplication::VERSION",
"output": "spc.phar"
}

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"
]
]
}
]
}
]
}
}

59
composer.json Normal file
View File

@@ -0,0 +1,59 @@
{
"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.12",
"symfony/console": "^5.4 || ^6 || ^7",
"zhamao/logger": "^1.0"
},
"require-dev": {
"captainhook/captainhook": "^5.10",
"captainhook/plugin-composer": "^5.3",
"friendsofphp/php-cs-fixer": "^3.25",
"humbug/box": "^4.3",
"nunomaduro/collision": "^7.8",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.3"
},
"autoload": {
"psr-4": {
"SPC\\": "src/SPC"
},
"files": [
"src/globals/defines.php",
"src/globals/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"SPC\\Tests\\": "tests/SPC"
}
},
"bin": [
"bin/spc"
],
"scripts": {
"analyse": "phpstan analyse --memory-limit 300M",
"cs-fix": "php-cs-fixer fix",
"test": "vendor/bin/phpunit tests/ --no-coverage",
"build:phar": "vendor/bin/box compile"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true,
"captainhook/plugin-composer": true
},
"optimize-autoloader": true,
"sort-packages": true
}
}

6030
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

521
config/ext.json Normal file
View File

@@ -0,0 +1,521 @@
{
"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"
]
},
"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"
]
},
"glfw": {
"type": "external",
"arg-type": "custom",
"source": "ext-glfw",
"lib-depends": [
"glfw"
]
},
"gmp": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"gmp"
]
},
"iconv": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"libiconv"
]
},
"imagick": {
"type": "external",
"source": "ext-imagick",
"arg-type": "custom",
"lib-depends": [
"imagemagick"
]
},
"imap": {
"type": "builtin",
"arg-type": "custom",
"lib-depends": [
"imap"
],
"lib-suggests": [
"openssl"
]
},
"inotify": {
"type": "external",
"source": "inotify"
},
"intl": {
"type": "builtin",
"lib-depends": [
"icu"
]
},
"ldap": {
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"ldap"
],
"lib-suggests": [
"gmp",
"libsodium"
],
"ext-suggests": [
"openssl"
]
},
"mbregex": {
"type": "builtin",
"arg-type": "custom",
"ext-depends": [
"mbstring"
],
"lib-depends": [
"onig"
]
},
"mbstring": {
"type": "builtin",
"arg-type": "custom"
},
"memcache": {
"type": "external",
"source": "ext-memcache",
"arg-type": "custom",
"lib-depends": [
"zlib"
],
"ext-depends": [
"session"
]
},
"memcached": {
"type": "external",
"source": "memcached",
"arg-type": "custom",
"cpp-extension": true,
"lib-depends": [
"libmemcached"
],
"ext-depends": [
"session",
"zlib"
]
},
"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",
"arg-type": "custom"
},
"openssl": {
"type": "builtin",
"arg-type": "custom",
"lib-depends": [
"openssl",
"zlib"
],
"ext-depends": [
"zlib"
]
},
"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"
]
},
"rar": {
"type": "external",
"source": "rar",
"cpp-extension": true
},
"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"
]
},
"snappy": {
"type": "external",
"source": "ext-snappy",
"cpp-extension": true,
"arg-type": "custom",
"lib-depends": [
"snappy"
],
"ext-suggest": [
"apcu"
]
},
"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",
"pgsql"
],
"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-prefix",
"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-prefix",
"lib-depends": [
"libxslt"
],
"ext-depends": [
"xml",
"dom"
]
},
"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": "custom",
"arg-type-windows": "enable",
"lib-depends": [
"zlib"
]
},
"zstd": {
"type": "external",
"source": "ext-zstd",
"arg-type": "custom",
"lib-depends": [
"zstd"
]
}
}

549
config/lib.json Normal file
View File

@@ -0,0 +1,549 @@
{
"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"
]
},
"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": [
"openssl",
"zlib"
],
"lib-suggests": [
"libssh2",
"brotli",
"nghttp2",
"zstd"
],
"lib-suggests-windows": [
"zlib",
"libssh2",
"brotli",
"nghttp2",
"zstd",
"openssl",
"idn2",
"psl"
],
"frameworks": [
"CoreFoundation",
"CoreServices",
"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"
]
},
"glfw": {
"source": "ext-glfw",
"static-libs-unix": [
"libglfw3.a"
],
"frameworks": [
"CoreVideo",
"OpenGL",
"Cocoa",
"IOKit"
]
},
"gmp": {
"source": "gmp",
"static-libs-unix": [
"libgmp.a"
],
"static-libs-windows": [
"libgmp.lib"
],
"headers": [
"gmp.h"
]
},
"icu": {
"source": "icu",
"cpp-library": true,
"static-libs-unix": [
"libicui18n.a",
"libicuio.a",
"libicuuc.a",
"libicudata.a"
]
},
"imagemagick": {
"source": "imagemagick",
"static-libs-unix": [
"libMagick++-7.Q16HDRI.a",
"libMagickWand-7.Q16HDRI.a",
"libMagickCore-7.Q16HDRI.a"
],
"lib-depends": [
"zlib",
"libpng",
"libjpeg",
"libwebp",
"freetype"
],
"lib-suggests": [
"zstd",
"xz",
"bzip2",
"libzip",
"libxml2"
]
},
"imap": {
"source": "imap",
"static-libs-unix": [
"libc-client.a"
],
"lib-suggests": [
"openssl"
]
},
"ldap": {
"source": "ldap",
"static-libs-unix": [
"liblber.a",
"libldap.a"
],
"lib-depends": [
"openssl",
"zlib",
"gmp",
"libsodium"
]
},
"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"
]
},
"libmemcached": {
"source": "libmemcached",
"static-libs-unix": [
"libmemcached.a",
"libmemcachedutil.a"
]
},
"libpng": {
"source": "libpng",
"static-libs-unix": [
"libpng16.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",
"zlib"
],
"lib-suggests": [
"xz",
"icu"
],
"lib-suggests-windows": [
"icu",
"xz"
]
},
"libxslt": {
"source": "libxslt",
"static-libs-unix": [
"libxslt.a",
"libexslt.a"
],
"lib-depends": [
"libxml2"
]
},
"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",
"libxslt",
"ldap",
"zstd"
]
},
"readline": {
"source": "readline",
"static-libs-unix": [
"libreadline.a"
],
"lib-depends": [
"ncurses"
]
},
"snappy": {
"source": "snappy",
"static-libs-unix": [
"libsnappy.a"
],
"headers-unix": [
"snappy.h",
"snappy-c.h",
"snappy-sinksource.h",
"snappy-stubs-public.h"
],
"lib-depends": [
"zlib"
]
},
"sqlite": {
"source": "sqlite",
"static-libs-unix": [
"libsqlite3.a"
],
"headers-unix": [
"sqlite3.h",
"sqlite3ext.h"
]
},
"tidy": {
"source": "tidy",
"static-libs-unix": [
"libtidy.a"
]
},
"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"
]
},
"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"
]
}
}

528
config/source.json Normal file
View File

@@ -0,0 +1,528 @@
{
"php-src": {
"type": "custom",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"apcu": {
"type": "url",
"url": "https://pecl.php.net/get/APCu",
"path": "php-src/ext/apcu",
"filename": "apcu.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"brotli": {
"type": "ghtar",
"repo": "google/brotli",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"bzip2": {
"type": "filelist",
"url": "https://sourceware.org/pub/bzip2/",
"regex": "/href=\"(?<file>bzip2-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"license": {
"type": "text",
"text": "This program, \"bzip2\", the associated library \"libbzip2\", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@bzip.org bzip2/libbzip2 version 1.0.6 of 6 September 2010\n\nPATENTS: To the best of my knowledge, bzip2 and libbzip2 do not use any patented algorithms. However, I do not have the resources to carry out a patent search. Therefore I cannot give any guarantee of the above statement."
}
},
"curl": {
"type": "ghrel",
"repo": "curl/curl",
"match": "curl.+\\.tar\\.xz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"ext-event": {
"type": "url",
"url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz",
"path": "php-src/ext/event",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-glfw": {
"type": "git",
"url": "https://github.com/mario-deluna/php-glfw",
"rev": "master",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-imagick": {
"type": "url",
"url": "https://pecl.php.net/get/imagick",
"path": "php-src/ext/imagick",
"filename": "imagick.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-memcache": {
"type": "url",
"url": "https://pecl.php.net/get/memcache",
"path": "php-src/ext/memcache",
"filename": "memcache.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-snappy": {
"type": "git",
"path": "php-src/ext/snappy",
"rev": "master",
"url": "https://github.com/kjdev/php-ext-snappy",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-ssh2": {
"type": "url",
"url": "https://pecl.php.net/get/ssh2",
"path": "php-src/ext/ssh2",
"filename": "ssh2.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-zstd": {
"type": "git",
"path": "php-src/ext/zstd",
"rev": "master",
"url": "https://github.com/kjdev/php-ext-zstd",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"freetype": {
"type": "git",
"rev": "VER-2-13-2",
"url": "https://github.com/freetype/freetype",
"license": {
"type": "file",
"path": "LICENSE.TXT"
}
},
"gmp": {
"type": "ghtagtar",
"repo": "alisw/GMP",
"license": {
"type": "text",
"text": "Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 and GNU GPL v2. These licenses make the library free to use, share, and improve, and allow you to pass on the result. The GNU licenses give freedoms, but also set firm restrictions on the use with non-free programs."
}
},
"icu": {
"type": "ghrel",
"repo": "unicode-org/icu",
"match": "icu4c.+-src\\.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"imagemagick": {
"type": "ghtar",
"repo": "ImageMagick/ImageMagick",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"imap": {
"type": "git",
"url": "https://github.com/static-php/imap.git",
"rev": "master",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"inotify": {
"type": "url",
"url": "https://pecl.php.net/get/inotify",
"path": "php-src/ext/inotify",
"filename": "inotify.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ldap": {
"type": "filelist",
"url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/",
"regex": "/href=\"(?<file>openldap-(?<version>[^\"]+)\\.tgz)\"/",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libavif": {
"type": "ghtar",
"repo": "AOMediaCodec/libavif",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libevent": {
"type": "ghrel",
"repo": "libevent/libevent",
"match": "libevent.+\\.tar\\.gz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libffi": {
"type": "ghrel",
"repo": "libffi/libffi",
"match": "libffi.+\\.tar\\.gz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libiconv": {
"type": "filelist",
"url": "https://ftp.gnu.org/gnu/libiconv/",
"regex": "/href=\"(?<file>libiconv-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"license": {
"type": "file",
"path": "COPYING"
}
},
"libjpeg": {
"type": "ghtar",
"repo": "libjpeg-turbo/libjpeg-turbo",
"license": {
"type": "file",
"path": "LICENSE.md"
}
},
"libmcrypt": {
"type": "url",
"url": "https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"libmemcached": {
"type": "git",
"url": "https://github.com/static-php/libmemcached-macos.git",
"rev": "master",
"license": {
"type": "file",
"path": "COPYING"
}
},
"libpng": {
"type": "git",
"url": "https://github.com/glennrp/libpng.git",
"rev": "libpng16",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libsodium": {
"type": "url",
"url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libssh2": {
"type": "ghrel",
"repo": "libssh2/libssh2",
"match": "libssh2.+\\.tar\\.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"libwebp": {
"type": "url",
"url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"libxml2": {
"type": "url",
"url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.9.14.tar.gz",
"license": {
"type": "file",
"path": "Copyright"
}
},
"libxslt": {
"type": "filelist",
"url": "https://download.gnome.org/sources/libxslt/1.1/",
"regex": "/href=\"(?<file>libxslt-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"license": {
"type": "file",
"path": "COPYING"
}
},
"libyaml": {
"type": "ghrel",
"repo": "yaml/libyaml",
"match": "yaml-.+\\.tar\\.gz",
"license": {
"type": "file",
"path": "License"
}
},
"libzip": {
"type": "ghrel",
"repo": "nih-at/libzip",
"match": "libzip.+\\.tar\\.xz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"mcrypt": {
"type": "url",
"url": "https://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"memcached": {
"type": "url",
"url": "https://pecl.php.net/get/memcached",
"path": "php-src/ext/memcached",
"filename": "memcached.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"micro": {
"type": "git",
"path": "php-src/sapi/micro",
"rev": "master",
"url": "https://github.com/static-php/phpmicro",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"mongodb": {
"type": "ghrel",
"repo": "mongodb/mongo-php-driver",
"path": "php-src/ext/mongodb",
"match": "mongodb.+\\.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ncurses": {
"type": "filelist",
"url": "https://ftp.gnu.org/pub/gnu/ncurses/",
"regex": "/href=\"(?<file>ncurses-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"license": {
"type": "file",
"path": "COPYING"
}
},
"nghttp2": {
"type": "ghrel",
"repo": "nghttp2/nghttp2",
"match": "nghttp2.+\\.tar\\.xz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"onig": {
"type": "ghrel",
"repo": "kkos/oniguruma",
"match": "onig-.+\\.tar\\.gz",
"license": {
"type": "file",
"path": "COPYING"
}
},
"openssl": {
"type": "filelist",
"url": "https://www.openssl.org/source/",
"regex": "/href=\"(?<file>openssl-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"license": {
"type": "file",
"path": "LICENSE.txt"
}
},
"pkg-config": {
"type": "filelist",
"url": "https://pkgconfig.freedesktop.org/releases/",
"regex": "/href=\"(?<file>pkg-config-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"license": {
"type": "file",
"path": "COPYING"
}
},
"postgresql": {
"type": "url",
"url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz",
"license": {
"type": "file",
"path": "COPYRIGHT"
}
},
"protobuf": {
"type": "url",
"url": "https://pecl.php.net/get/protobuf",
"path": "php-src/ext/protobuf",
"filename": "protobuf.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"rar": {
"type": "git",
"url": "https://github.com/static-php/php-rar.git",
"path": "php-src/ext/rar",
"rev": "issue-php82",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"readline": {
"type": "filelist",
"url": "https://ftp.gnu.org/pub/gnu/readline/",
"regex": "/href=\"(?<file>readline-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"license": {
"type": "file",
"path": "COPYING"
}
},
"redis": {
"type": "git",
"path": "php-src/ext/redis",
"rev": "5.3.7",
"url": "https://github.com/phpredis/phpredis",
"license": {
"type": "file",
"path": "COPYING"
}
},
"snappy": {
"type": "git",
"repo": "google/snappy",
"rev": "main",
"url": "https://github.com/google/snappy",
"license": {
"type": "file",
"path": "COPYING"
}
},
"sqlite": {
"type": "url",
"url": "https://www.sqlite.org/2023/sqlite-autoconf-3430200.tar.gz",
"license": {
"type": "text",
"text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give."
}
},
"swoole": {
"type": "ghtar",
"path": "php-src/ext/swoole",
"repo": "swoole/swoole-src",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"swow": {
"type": "git",
"path": "php-src/ext/swow-src",
"rev": "ci",
"url": "https://github.com/swow/swow",
"patch": "patchSwow",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"tidy": {
"type": "url",
"url": "https://github.com/htacg/tidy-html5/archive/refs/tags/5.8.0.tar.gz",
"filename": "tidy-html5.tgz",
"license": {
"type": "file",
"path": "README/LICENSE.md"
}
},
"xlswriter": {
"type": "url",
"url": "https://pecl.php.net/get/xlswriter",
"path": "php-src/ext/xlswriter",
"filename": "xlswriter.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"xz": {
"type": "filelist",
"url": "https://tukaani.org/xz/",
"regex": "/href=\"(?<file>xz-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"license": {
"type": "file",
"path": "COPYING"
}
},
"yaml": {
"type": "git",
"path": "php-src/ext/yaml",
"rev": "php7",
"url": "https://github.com/php/pecl-file_formats-yaml",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"zlib": {
"type": "ghrel",
"repo": "madler/zlib",
"match": "zlib.+\\.tar\\.gz",
"license": {
"type": "text",
"text": "(C) 1995-2022 Jean-loup Gailly and Mark Adler\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\n claim that you wrote the original software. If you use this software\n in a product, an acknowledgment in the product documentation would be\n appreciated but is not required.\n2. Altered source versions must be plainly marked as such, and must not be\n misrepresented as being the original software.\n3. This notice may not be removed or altered from any source distribution.\n\nJean-loup Gailly Mark Adler\njloup@gzip.org madler@alumni.caltech.edu"
}
},
"zstd": {
"type": "ghrel",
"repo": "facebook/zstd",
"match": "zstd.+\\.tar\\.gz",
"license": {
"type": "file",
"path": "LICENSE"
}
}
}

View File

@@ -1,89 +0,0 @@
FROM alpine:3.16
# define script basic information
# Version of this Dockerfile
ENV SCRIPT_VERSION=1.5.1
# Download address uses backup address
ARG USE_BACKUP_ADDRESS
# (if downloading slowly, consider set it to yes)
ENV USE_BACKUP="${USE_BACKUP_ADDRESS}"
# APK repositories mirror address, if u r not in China, consider set USE_BACKUP=yes to boost
ENV LINK_APK_REPO='mirrors.ustc.edu.cn'
ENV LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
RUN if [ "${USE_BACKUP}" = "" ]; then \
export USE_BACKUP="no" ; \
fi
RUN sed -i.backup 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories ;
RUN if [ "${USE_BACKUP}" = "no" ]; then cp -f /etc/apk/repositories.backup /etc/apk/repositories; fi
RUN cat /etc/apk/repositories
# build requirements
RUN apk add bash file wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses dialog > /dev/null
# php zlib dependencies
RUN apk add zlib-dev zlib-static > /dev/null
# php mbstring dependencies
RUN apk add oniguruma-dev > /dev/null
# php openssl dependencies
RUN apk add openssl-libs-static openssl-dev openssl > /dev/null
# php gd dependencies
RUN apk add libpng-dev libpng-static > /dev/null
# curl c-ares dependencies
RUN apk add c-ares-static c-ares-dev > /dev/null
# php event dependencies
RUN apk add libevent libevent-dev libevent-static > /dev/null
# php sqlite3 dependencies
RUN apk add sqlite sqlite-dev sqlite-libs sqlite-static > /dev/null
# php libzip dependencies
RUN apk add bzip2-dev bzip2-static bzip2 > /dev/null
# php micro ffi dependencies
RUN apk add libffi libffi-dev > /dev/null
# php gd event parent dependencies
RUN apk add zstd-static > /dev/null
# php readline dependencies
RUN apk add readline-static ncurses-static readline-dev > /dev/null
RUN apk add aria2
RUN mkdir /app
WORKDIR /app
ADD ./ /app/
# RUN chmod +x /app/*.sh
# use proxy
# ENV http_proxy=http://192.168.3.26:8015
# ENV https_proxy=http://192.168.3.26:8015
# 提前下载好,就可以跳过两步
# (容器外提前执行 下面两个命令)
RUN sh ./download-library-batch-aria2.sh
RUN sh ./download-extension-batch-aria2.sh
#ENV http_proxy=''
#ENV https_proxy=''
RUN ls -lh source/libraries
RUN ls -lh source/extensions
# quick test complie
# RUN bash ./compile-deps.sh
RUN sh ./download.sh swoole ${USE_BACKUP} && \
sh ./download.sh inotify ${USE_BACKUP} && \
sh ./download.sh mongodb ${USE_BACKUP} && \
sh ./download.sh event ${USE_BACKUP} && \
sh ./download.sh redis ${USE_BACKUP} && \
sh ./download.sh libxml2 ${USE_BACKUP} && \
sh ./download.sh xz ${USE_BACKUP} && \
sh ./download.sh curl ${USE_BACKUP} && \
sh ./download.sh libzip ${USE_BACKUP} && \
sh ./download.sh libiconv ${USE_BACKUP} && \
sh ./download-git.sh dixyes/phpmicro phpmicro ${USE_BACKUP}
RUN bash ./compile-deps.sh
RUN echo -e "#!/usr/bin/env bash\n/app/compile-php.sh \$@" > /bin/build-php && chmod +x /bin/build-php

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,200 +0,0 @@
#!/bin/sh
# Here are 3 steps in configuration of extensions
# before_configure
# in_configure
# after_configure
self_dir=$(cd "$(dirname "$0")";pwd)
php_dir=$(find $self_dir/source -name "php-*" -type d | tail -n1)
test -f "$self_dir/extensions_install.txt" && EXT_LIST_FILE="$self_dir/extensions_install.txt" || EXT_LIST_FILE="$self_dir/extensions.txt"
function do_copy_extension() {
ext_dir=$(find $self_dir/source -name "*$1-*" -type d | tail -n1)
mv $ext_dir $php_dir/ext/$1
if [ $? != 0 ]; then
echo "Compile error! ext: $1, ext_dir=$ext_dir"
exit 1
fi
}
function check_before_configure() {
list=$(cat "$EXT_LIST_FILE" | grep -v "^#" | grep -v "^$" | grep -v "^\^")
xml_sign="no"
for loop in $list
do
case $loop in
bcmath) ;;
calendar) ;;
ctype) ;;
exif) ;;
filter) ;;
fileinfo) ;;
gd) ;;
hash) ;;
iconv) ;;
json) ;;
mbstring) ;;
mysqlnd) ;;
openssl) ;;
pcntl) ;;
pdo) ;;
pdo_mysql) ;;
pdo_sqlite) ;;
phar) ;;
posix) ;;
protobuf)
do_copy_extension protobuf
echo '#ifndef PHP_PROTOBUF_H' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '# define PHP_PROTOBUF_H' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '#ifdef HAVE_CONFIG_H' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '# include "config.h"' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '#endif' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo 'extern zend_module_entry protobuf_module_entry;' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '# define phpext_protobuf_ptr &protobuf_module_entry' >> $php_dir/ext/protobuf/php_protobuf.h && \
echo '#endif' >> $php_dir/ext/protobuf/php_protobuf.h
;;
readline)
if [ ! -d "/nom" ]; then
mkdir /nom
fi
mv /usr/lib/libreadline.so* /nom/ && \
mv /usr/lib/libncurses*.so* /nom
;;
shmop) ;;
sockets) ;;
sqlite3) ;;
tokenizer) ;;
zlib) ;;
zip) ;;
curl) cat "$self_dir/ac_override_1" "$php_dir/ext/curl/config.m4" "$self_dir/ac_override_2" > /tmp/aa && mv /tmp/aa "$php_dir/ext/curl/config.m4" ;;
dom|xml|libxml|xmlreader|xmlwriter|simplexml|soap) ;;
inotify) do_copy_extension inotify ;;
redis) do_copy_extension redis ;;
swoole) do_copy_extension swoole ;;
mongodb) do_copy_extension mongodb ;;
event) do_copy_extension event ;;
esac
done
case $1 in
8.*)
mv $self_dir/source/phpmicro $php_dir/sapi/micro && \
sed -ie 's/#include "php.h"/#include "php.h"\n#define PHP_MICRO_FAKE_CLI 1/g' $php_dir/sapi/micro/php_micro.c
;;
esac
}
function check_in_configure() {
php_configure=""
list=$(cat "$EXT_LIST_FILE" | sed 's/#.*//g' | sed 's/\^.*//g' | sed -e 's/[ ]*$//g' | grep -v "^\s*$")
for loop in $list
do
case $loop in
bcmath) php_configure="$php_configure --enable-bcmath" ;;
calendar) php_configure="$php_configure --enable-calendar" ;;
ctype) php_configure="$php_configure --enable-ctype" ;;
curl) php_configure="$php_configure --with-curl" ;;
dom) php_configure="$php_configure --enable-dom" ;;
exif) php_configure="$php_configure --enable-exif" ;;
event) php_configure="$php_configure --with-event-libevent-dir=/usr --with-event-core --with-event-extra --with-event-openssl" ;;
filter) php_configure="$php_configure --enable-filter" ;;
fileinfo) php_configure="$php_configure --enable-fileinfo" ;;
gd)
case $1 in
7.3.*|7.2.*) php_configure="$php_configure --with-gd" ;;
7.4.*|8.*) php_configure="$php_configure --enable-gd" ;;
esac
;;
hash)
case $1 in
7.3.*|7.2.*) php_configure="$php_configure --enable-hash" ;;
esac
;;
iconv) php_configure="$php_configure --with-iconv=/usr" ;;
inotify) php_configure="$php_configure --enable-inotify" ;;
json)
case $1 in
7.*) php_configure="$php_configure --enable-json" ;;
esac
;;
libxml)
case $1 in
7.3.*|7.2.*) php_configure="$php_configure --enable-libxml" ;;
7.4.*|8.*) php_configure="$php_configure --with-libxml" ;;
esac
;;
mbstring) php_configure="$php_configure --enable-mbstring" ;;
mongodb) php_configure="$php_configure --enable-mongodb" ;;
mysqlnd) php_configure="$php_configure --enable-mysqlnd" ;;
openssl) php_configure="$php_configure --with-openssl --with-openssl-dir=/usr" ;;
pcntl) php_configure="$php_configure --enable-pcntl" ;;
pdo) php_configure="$php_configure --enable-pdo" ;;
pdo_mysql) php_configure="$php_configure --with-pdo-mysql=mysqlnd" ;;
phar) php_configure="$php_configure --enable-phar" ;;
posix) php_configure="$php_configure --enable-posix" ;;
protobuf) php_configure="$php_configure --enable-protobuf" ;;
readline) php_configure="$php_configure --with-readline" ;;
redis) php_configure="$php_configure --enable-redis --disable-redis-session" ;;
shmop) php_configure="$php_configure --enable-shmop" ;;
simplexml) php_configure="$php_configure --enable-simplexml" ;;
sockets) php_configure="$php_configure --enable-sockets" ;;
soap) php_configure="$php_configure --enable-soap" ;;
sqlite3) php_configure="$php_configure --with-sqlite3" ;;
pdo_sqlite) php_configure="$php_configure --with-pdo-sqlite" ;;
swoole)
php_configure="$php_configure --enable-swoole"
have_openssl=$(echo $list | grep openssl)
if [ "$have_openssl" != "" ]; then
php_configure="$php_configure --enable-openssl --with-openssl --with-openssl-dir=/usr"
fi
have_hash=$(echo $list | grep hash)
if [ "$have_hash" = "" ]; then
case $1 in
7.3.*|7.2.*) php_configure="$php_configure --enable-hash" ;;
esac
fi
;;
tokenizer) php_configure="$php_configure --enable-tokenizer" ;;
xml) php_configure="$php_configure --enable-xml" ;;
xmlreader) php_configure="$php_configure --enable-xmlreader" ;;
xmlwriter) php_configure="$php_configure --enable-xmlwriter" ;;
zlib) php_configure="$php_configure --with-zlib" ;;
zip) php_configure="$php_configure --with-zip" ;;
*)
echo "Unsupported extension '$loop' !" >&2
exit 1
;;
esac
done
case $1 in
8.*) php_configure="$php_configure --with-ffi --enable-micro=all-static" ;;
esac
echo $php_configure
}
function check_after_configure() {
list=$(cat "$EXT_LIST_FILE" | grep -v "^#" | grep -v "^$")
for loop in $list
do
case $loop in
swoole)
sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "$php_dir/ext/swoole/include/swoole.h"
sed -ie 's/strcmp("cli", sapi_module.name) == 0/strcmp("cli", sapi_module.name) == 0 || strcmp("micro", sapi_module.name) == 0/g' "$php_dir/ext/swoole/ext-src/php_swoole.cc"
;;
esac
done
case $1 in
8.*) sed -ie 's/$(EXTRA_LIBS:-lresolv=-Wl,-Bstatic,-lresolv,-Bdynamic)/$(EXTRA_LIBS)/g' "$php_dir/Makefile" ;;
esac
}
function finish_compile() {
if [ -d "/nom" ]; then
mv /nom/* /usr/lib/ || echo "Empty directory"
rm -rf /nom/
fi
}
$1 $2

View File

@@ -1,64 +0,0 @@
#!/usr/bin/env bash
self_dir=$(cd "$(dirname "$0")";pwd)
function do_xml_compiler() {
cd $self_dir/source/xz-* && \
./configure --enable-static=yes && \
make -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "xz compiled!" && \
cd ../libxml2-* && \
./configure --prefix=/usr --with-lzma --without-python && \
make -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "libxml2 compiled!"
}
function do_libzip_compiler() {
cd $self_dir/source/libzip-* && \
mkdir build && \
cd build && \
cmake -DBUILD_SHARED_LIBS=no .. -Wno-dev -DENABLE_BZIP2=no -DENABLE_LZMA=no && \
make LDFLAGS="-llzma -lbz2" -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "libzip compiled!"
}
function do_curl_compiler() {
cd $self_dir/source/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 -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "curl compiled!"
}
function do_iconv_compiler() {
cd $self_dir/source/libiconv-* && \
./configure --enable-static=yes --prefix=/usr && \
make -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install && \
echo "libiconv compiled!"
}
if [ ! -f "$self_dir/source/.deps-compiled" ]; then
source ${self_dir}/deps-modules/libmcrypt.sh
source ${self_dir}/deps-modules/gmp.sh
do_xml_compiler && \
do_curl_compiler && \
do_libzip_compiler && \
do_iconv_compiler && \
touch "$self_dir/source/.deps-compiled"
else
echo "Skip compilation for dependencies"
fi

View File

@@ -1,125 +0,0 @@
#!/usr/bin/env bash
self_dir=$(cd "$(dirname "$0")";pwd)
# 通过 extensions.txt 生成一个 dialog 命令
function generate_ext_dialog_cmd() {
list=$(cat "$self_dir/extensions.txt" | grep -v "^#" | grep -v "^$")
echo -n "dialog --backtitle \"static-php-cli Compile Options\" --checklist \"Please select the extension you don't want to compile.\n\nNOTE: Use <space> to select or deselect items\n\n** Default is compiling all **\" 24 60 20 " > $self_dir/.ask_cmd.sh
for loop in $list
do
case $loop in
^*)
loop=$(echo ${loop:1} | xargs)
echo -n "$loop '$loop Extension' off " >> $self_dir/.ask_cmd.sh
;;
*) echo -n "$loop '$loop Extension' on " >> $self_dir/.ask_cmd.sh ;;
esac
done
echo "2>$self_dir/extensions_install.txt" >> $self_dir/.ask_cmd.sh
}
# PHP 编译参数生成
function php_compile_args() {
_php_arg="--prefix=$self_dir/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 --with-pear=no"
_php_arg="$_php_arg --disable-cgi"
_php_arg="$_php_arg --disable-phpdbg"
_php_arg="$_php_arg --with-config-file-path=/etc"
_php_arg="$_php_arg $($self_dir/check-extensions.sh check_in_configure $1)"
echo $_php_arg
}
# 第一个参数用于使用镜像地址还是原地址mirror为镜像地址original为原地址
if [ "$1" = "" ]; then
dialog --backtitle "static-php-cli Compile Options" --yesno "<Yes>: Use mirror download address, mainland China users recommended.\n\n<No>: Use original address, global users recommended." 10 50
test $? == 0 && USE_BACKUP="no" || USE_BACKUP="yes"
else
test "$1" != "mirror" && USE_BACKUP="yes" || USE_BACKUP="no"
fi
# 第二个参数用于规定编译的 PHP 版本
if [ "$2" = "" ]; then
dialog --backtitle "static-php-cli Compile Options" --inputbox "Please input your PHP version to compile" 10 50 "8.1.7" 2>$self_dir/.phpver
if [ $? != 0 ]; then
clear
echo "canceled Compiling PHP." && rm -f $self_dir/.phpver
exit 1
else
VER_PHP=$(cat $self_dir/.phpver)
rm -f $self_dir/.phpver
fi
else
VER_PHP=$2
fi
# 第三个参数用于是否直接安装,如果留空则询问编译的扩展,如果填入 all则直接编译所有的扩展
if [ "$3" != "all" ]; then
generate_ext_dialog_cmd && cat $self_dir/.ask_cmd.sh && chmod +x $self_dir/.ask_cmd.sh && $self_dir/.ask_cmd.sh
if [ $? != 0 ]; then
clear
echo "canceled Compiling PHP while selecting extensions." && rm -rf $self_dir/.ask_cmd.sh
exit 1
fi
rm -f $self_dir/.ask_cmd.sh
else
cp $self_dir/extensions.txt $self_dir/extensions_install.txt
fi
# 第四个参数用于输出 PHP 和 micro 二进制文件的位置
if [ "$4" = "" ]; then
dialog --backtitle "static-php-cli Compile Options" --inputbox "Please input compiled output directory" 10 50 "/dist/" 2>$self_dir/.outdir
if [ $? != 0 ]; then
clear
echo "canceled setting output dir, compiling PHP stopped." && rm -f $self_dir/.outdir
exit 1
else
OUT_DIR=$(cat $self_dir/.outdir)
rm -f $self_dir/.outdir
fi
else
OUT_DIR=$4
fi
if [ ! -d "$OUT_DIR" ]; then
mkdir -p "$OUT_DIR"
fi
# 下载 PHP
echo "All done. Downloading PHP ..."
if [ -d "$self_dir/source/php-$VER_PHP" ]; then
rm -rf "$self_dir/source/php-$VER_PHP"
fi
$self_dir/download.sh php ${USE_BACKUP} ${VER_PHP} || { echo "Download PHP failed!" && exit 1 ; }
# 选择性编译依赖的库、移动需要安装的扩展到 PHP 目录
$self_dir/check-extensions.sh check_before_configure ${VER_PHP} || { echo "Install required library failed!" && exit 1 ; }
# 编译 PHP
echo "Compiling PHP ..."
php_dir=$(find $self_dir/source -name "php-$VER_PHP" -type d | tail -n1)
cd $php_dir && \
./buildconf --force && \
./configure LDFLAGS=-static $(php_compile_args $VER_PHP) && \
$self_dir/check-extensions.sh check_after_configure ${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/$(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_MICRO_OBJS)/$(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_BINARY_OBJS:.lo=.o) $(PHP_MICRO_OBJS:.lo=.o)/g' "Makefile" && \
make LDFLAGS="-ldl" -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
make install-cli && \
$self_dir/check-extensions.sh finish_compile && \
strip $self_dir/php-dist/bin/php
if [ $? != 0 ]; then
exit 1
fi
# 将 PHP 和 micro 输出到指定目录
echo "Copying php binary to $OUT_DIR ..." && \
cp $self_dir/php-dist/bin/php $OUT_DIR/ && \
test -f $php_dir/sapi/micro/micro.sfx && \
echo "Copying micro.sfx binary to $OUT_DIR ..." && \
cp $php_dir/sapi/micro/micro.sfx $OUT_DIR/ || { exit 0 ; }

View File

@@ -1,61 +0,0 @@
{
"php": {
"link": "http://mirrors.zhamao.xin/php/php-{version}.tar.gz",
"link_2": "https://www.php.net/distributions/php-{version}.tar.gz"
},
"protobuf": {
"version": "3.21.2",
"link": "http://mirrors.zhamao.xin/pecl/protobuf-{version}.tgz",
"link_2": "https://pecl.php.net/get/protobuf-{version}.tgz"
},
"swoole": {
"version": "4.8.10",
"link": "http://mirrors.zhamao.xin/pecl/swoole-{version}.tgz",
"link_2": "https://pecl.php.net/get/swoole-{version}.tgz"
},
"mongodb": {
"version": "1.13.0",
"link": "http://mirrors.zhamao.xin/pecl/mongodb-{version}.tgz",
"link_2": "https://pecl.php.net/get/mongodb-{version}.tgz"
},
"inotify": {
"version": "3.0.0",
"link": "http://mirrors.zhamao.xin/pecl/inotify-{version}.tgz",
"link_2": "https://pecl.php.net/get/inotify-{version}.tgz"
},
"event": {
"version": "3.0.8",
"link": "https://mirrors.zhamao.xin/library/php-event/event-{version}.tar.gz",
"link_2": "https://bitbucket.org/osmanov/pecl-event/get/{version}.tar.gz"
},
"redis": {
"version": "5.3.7",
"link": "http://mirrors.zhamao.xin/pecl/redis-{version}.tgz",
"link_2": "https://pecl.php.net/get/redis-{version}.tgz"
},
"libxml2": {
"version": "2.9.12",
"link": "http://mirrors.zhamao.xin/library/libxml2/libxml2-{version}.tar.gz",
"link_2": "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
},
"curl": {
"version": "7.83.1",
"link": "https://mirrors.zhamao.xin/library/curl/curl-{version}.tar.gz",
"link_2": "https://curl.haxx.se/download/curl-{version}.tar.gz"
},
"xz": {
"version": "5.2.5",
"link": "https://mirrors.zhamao.xin/library/xz/xz-{version}.tar.gz",
"link_2": "https://tukaani.org/xz/xz-{version}.tar.gz"
},
"libzip": {
"version": "1.9.2",
"link": "https://mirrors.zhamao.xin/library/libzip/libzip-{version}.tar.gz",
"link_2": "https://libzip.org/download/libzip-{version}.tar.gz"
},
"libiconv": {
"version": "1.17",
"link": "https://mirrors.zhamao.xin/library/libiconv/libiconv-{version}.tar.gz",
"link_2": "https://ftp.gnu.org/gnu/libiconv/libiconv-{version}.tar.gz"
}
}

View File

@@ -1,32 +0,0 @@
#!/bin/bash
if [ -n "$__MODULE_SH__" ]; then
return
fi
__MODULE_SH__='gmp.sh'
set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
# cpu 核数 前面为linux 后面为macos
cpu_nums=`nproc 2> /dev/null || sysctl -n hw.ncpu`
# cpu_nums=`grep "processor" /proc/cpuinfo | sort -u | wc -l`
function do_gmp_compiler() {
pwd
mkdir -p /app/source/builder_dir/gmp
tar --strip-components=1 -C ${__DIR__}/source/builder_dir/gmp -xf ${__DIR__}/source/libraries/gmp-6.2.1.tar.lz
cd ${__DIR__}/source/builder_dir/gmp
./configure --prefix=/usr/gmp --enable-static --disable-shared
make -j $cpu_nums
echo "gmp compiled!" && \
make install && \
echo "gmp compiled!"
return $?
}
do_gmp_compiler

View File

@@ -1,35 +0,0 @@
#!/bin/bash
if [ -n "$__MODULE_SH__" ]; then
return
fi
__MODULE_SH__='libmcrypt.sh'
set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
# cpu 核数 前面为linux 后面为macos
cpu_nums=`nproc 2> /dev/null || sysctl -n hw.ncpu`
# cpu_nums=`grep "processor" /proc/cpuinfo | sort -u | wc -l`
function do_libmcrypt_compiler() {
pwd
mkdir -p /app/source/builder_dir/libmcrypt
tar --strip-components=1 -C ${__DIR__}/source/builder_dir/libmcrypt -xf ${__DIR__}/source/libraries/libmcrypt-2.5.8-3.4.tar.gz
cd ${__DIR__}/source/builder_dir/libmcrypt
chmod a+x ./install-sh
sh ./configure --prefix=/usr/libmcrypt \
--enable-static=yes \
--enable-shared=no
make -j $cpu_nums
echo "libmcrypt compiled!" && \
make install && \
echo "libmcrypt compiled!"
return $?
}
do_libmcrypt_compiler

View File

@@ -1,34 +0,0 @@
#!/bin/bash
set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
# https://aria2.github.io/manual/en/html/aria2c.html#http-ftp-segmented-downloads
# https://aria2.github.io/manual/en/html/aria2c.html
# -with-config-file-path=/usr/local/php/etc
# -U, --user-agent
# aria2c -h
# aria2c --conf-path=/etc/aria2/aria2.conf
:<<EOF
-c, --continue [true|false]
-s, --split=<N>
-x, --max-connection-per-server=<NUM>
-k, --min-split-size=<SIZE>
-j, --max-concurrent-downloads=<N>
-i, --input-file=<FILE>
EOF
user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'
test -f download_extension_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 --user-agent=$user_agent \
-d extensions --input-file=download_extension_urls.txt
mkdir -p source/extensions
awk 'BEGIN { cmd="cp -ri extensions/* source/extensions/" ; print "n" |cmd; }'

View File

@@ -1,20 +0,0 @@
#!/usr/bin/env bash
self_dir=$(cd "$(dirname "$0")";pwd)
test -d "$self_dir/source/cache/" || mkdir -p "$self_dir/source/cache"
test "$3" != "yes" && GITHUB_ADDR="https://gh.api.99988866.xyz/" || GITHUB_ADDR=""
if [ -d "$self_dir/source/cache/$2" ]; then
echo "Using cache for $2"
cp -r "$self_dir/source/cache/$2" "$self_dir/source/"
else
wget -O $self_dir/source/master.zip "$GITHUB_ADDR""https://github.com/$1/archive/master.zip" && \
cd $self_dir/source/ && \
unzip master.zip && \
mv $2-master/ cache/$2 && \
cp -r cache/$2 ./
fi
# git clone https://$GITHUB_ADDR/$1.git --depth=1 $self_dir/source/$2

View File

@@ -1,34 +0,0 @@
#!/bin/bash
set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
# https://aria2.github.io/manual/en/html/aria2c.html#http-ftp-segmented-downloads
# https://aria2.github.io/manual/en/html/aria2c.html
# -with-config-file-path=/usr/local/php/etc
# -U, --user-agent
# aria2c -h
# aria2c --conf-path=/etc/aria2/aria2.conf
:<<EOF
-c, --continue [true|false]
-s, --split=<N>
-x, --max-connection-per-server=<NUM>
-k, --min-split-size=<SIZE>
-j, --max-concurrent-downloads=<N>
-i, --input-file=<FILE>
EOF
user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'
test -f download_library_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 --user-agent=$user_agent \
-d libraries --input-file=download_library_urls.txt
mkdir -p source/libraries
awk 'BEGIN { cmd="cp -ri libraries/* source/libraries/" ; print "n" |cmd; }'

View File

@@ -1,60 +0,0 @@
#!/bin/sh
_use_backup="$2"
SELF_DIR=$(cd "$(dirname "$0")";pwd)
if [ ! -d "source" ]; then
mkdir source
fi
if [ ! -d "source/cache" ]; then
mkdir source/cache
fi
function readconf() {
cat $SELF_DIR/config.json | jq $@ | sed 's/\"//g'
}
cd source
if [ "$_use_backup" = "yes" ]; then
_use_backup="_2"
else
_use_backup=""
fi
archive_find_tar=$(find cache/ -name "$1.*" | grep -E ".tgz" | tail -n1)
archive_find_zip=$(find cache/ -name "$1.*" | grep -E ".zip" | tail -n1)
if [ "$archive_find_tar" != "" ]; then
echo "Using cache for $1 ($archive_find_tar)"
tar -zxf "$archive_find_tar"
elif [ "$archive_find_zip" != "" ]; then
echo "Using cache for $1 ($archive_find_zip)"
unzip $archive_find_zip -d "$SELF_DIR/source" > /dev/null
else
if [ "$3" != "" ]; then
wget -q "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$3'/g')"
else
echo "Downloading $1"
wget -q "$(readconf ".$1.link$_use_backup" | sed 's/{version}/'$(readconf ".$1.version")'/g')"
fi
if [ $? == 0 ]; then
archive_file_tar=$(find . -name "*.*" -maxdepth 1 | grep -E ".tar|.gz|.tgz" | tail -n1)
archive_file_zip=$(find . -name "*.zip" -maxdepth 1 | tail -n1)
if [ "$archive_file_tar" != "" ]; then
tar -zxf $archive_file_tar && mv $archive_file_tar $SELF_DIR/source/cache/$1.tgz
elif [ "$archive_file_zip" != "" ]; then
unzip $archive_file_zip && mv $archive_file_zip $SELF_DIR/source/cache/$1.zip > /dev/null
else
find . -name "*$1*.*"
echo "Unable to find downloaded file, only support '.tar.gz', '.tgz', '.zip' file!"
exit 1
fi
else
echo "Download $1 failed! (at $?)"
exit 1
fi
fi

View File

@@ -1,22 +0,0 @@
https://pecl.php.net/get/redis-5.3.7.tgz
out=redis-5.3.7.tgz
https://pecl.php.net/get/yaml-2.2.2.tgz
out=yaml-2.2.2.tgz
https://pecl.php.net/get/imagick-3.6.0.tgz
out=imagick-3.6.0.tgz
https://pecl.php.net/get/mongodb-1.14.2.tgz
out=mongodb-1.14.2.tgz
https://pecl.php.net/get/apcu-5.1.22.tgz
out=apcu-5.1.22.tgz
https://pecl.php.net/get/ds-1.4.0.tgz
out=ds-1.4.0.tgz
https://pecl.php.net/get/inotify-3.0.0.tgz
out=inotify-3.0.0.tgz
https://pecl.php.net/get/xlswriter-1.5.2.tgz
out=xlswriter-1.5.2.tgz
https://pecl.php.net/get/zstd-0.12.1.tgz
out=zstd-0.12.1.tgz
https://pecl.php.net/get/event-3.0.8.tgz
out=event-3.0.8.tgz
https://pecl.php.net/get/mcrypt-1.0.5.tgz
out=mcrypt-1.0.5.tgz

View File

@@ -1,4 +0,0 @@
https://pecl.php.net/get/mcrypt-1.0.5.tgz
out=mcrypt-1.0.5.tgz
https://pecl.php.net/get/apcu-5.1.22.tgz
out=apcu-5.1.22.tgz

View File

@@ -1,72 +0,0 @@
https://www.openssl.org/source/openssl-1.1.1p.tar.gz
out=openssl-1.1.1p.tar.gz
https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
out=libiconv-1.16.tar.gz
https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.9.10/libxml2-v2.9.10.tar.gz
out=libxml2-v2.9.10.tar.gz
https://gitlab.gnome.org/GNOME/libxslt/-/archive/v1.1.34/libxslt-v1.1.34.tar.gz
out=libxslt-v1.1.34.tar.gz
https://github.com/google/brotli/archive/refs/tags/v1.0.9.tar.gz
out=brotli-1.0.9.tar.gz
https://c-ares.org/download/c-ares-1.19.0.tar.gz
out=c-ares-1.19.0.tar.gz
https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz
out=gmp-6.2.1.tar.lz
https://mirrors.tuna.tsinghua.edu.cn/gnu/ncurses/ncurses-6.3.tar.gz https://mirrors.ustc.edu.cn/gnu/ncurses/ncurses-6.3.tar.gz https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.3.tar.gz
out=ncurses-6.3.tar.gz
https://mirrors.tuna.tsinghua.edu.cn/gnu/readline/readline-8.2.tar.gz https://mirrors.ustc.edu.cn/gnu/readline/readline-8.2.tar.gz https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz
out=readline-8.2.tar.gz
https://pyyaml.org/download/libyaml/yaml-0.2.5.tar.gz
out=yaml-0.2.5.tar.gz
https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz
out=libsodium-1.0.18.tar.gz
https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
out=bzip2-1.0.8.tar.gz
https://udomain.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
out=zlib-1.2.11.tar.gz
https://github.com/lz4/lz4/archive/refs/tags/v1.9.4.tar.gz
out=lz4-v1.9.4.tar.gz
https://github.com/tukaani-project/xz/releases/download/v5.4.1/xz-5.4.1.tar.gz
out=xz-5.4.1.tar.gz
https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz
out=zstd-1.5.2.tar.gz
https://libzip.org/download/libzip-1.9.2.tar.gz
out=libzip-1.9.2.tar.gz
https://www.sqlite.org/2021/sqlite-autoconf-3370000.tar.gz
out=sqlite-autoconf-3370000.tar.gz
https://github.com/unicode-org/icu/releases/download/release-60-3/icu4c-60_3-src.tgz
out=icu4c-60_3-src.tgz
https://codeload.github.com/kkos/oniguruma/tar.gz/refs/tags/v6.9.7
out=oniguruma-6.9.7.tar.gz
https://github.com/microsoft/mimalloc/archive/refs/tags/v2.0.7.tar.gz
out=mimalloc-2.0.7.tar.gz
https://codeload.github.com/libjpeg-turbo/libjpeg-turbo/tar.gz/refs/tags/2.1.2
out=libjpeg-turbo-2.1.2.tar.gz
https://nchc.dl.sourceforge.net/project/giflib/giflib-5.2.1.tar.gz
out=giflib-5.2.1.tar.gz
https://nchc.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz
out=libpng-1.6.37.tar.gz
https://codeload.github.com/webmproject/libwebp/tar.gz/refs/tags/v1.2.1
out=libwebp-1.2.1.tar.gz
https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.gz
out=freetype-2.10.4.tar.gz
https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.0-62.tar.gz
out=ImageMagick-v7.1.0-62.tar.gz
https://ftp.gnu.org/gnu/libidn/libidn2-2.3.4.tar.gz
out=libidn2-2.3.4.tar.gz
https://curl.se/download/curl-7.88.0.tar.gz
out=curl-7.88.0.tar.gz
https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.gz
out=postgresql-15.1.tar.gz
https://github.com/libffi/libffi/releases/download/v3.4.4/libffi-3.4.4.tar.gz
out=libffi-3.4.4.tar.gz
https://github.com/winlibs/libmcrypt/archive/refs/tags/libmcrypt-2.5.8-3.4.tar.gz
out=libmcrypt-2.5.8-3.4.tar.gz
https://github.com/jmcnamara/libxlsxwriter/archive/refs/tags/RELEASE_1.1.5.tar.gz
out=libxlsxwriter-1.1.5.tar.gz
https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
out=libevent-2.1.12-stable.tar.gz
https://github.com/libuv/libuv/archive/refs/tags/v1.44.2.tar.gz
out=libuv-v1.44.2.tar.gz
https://github.com/php/php-src/archive/refs/tags/php-8.1.12.tar.gz
out=php-8.1.12.tar.gz

View File

@@ -1,4 +0,0 @@
https://github.com/winlibs/libmcrypt/archive/refs/tags/libmcrypt-2.5.8-3.4.tar.gz
out=libmcrypt-2.5.8-3.4.tar.gz
https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz
out=gmp-6.2.1.tar.lz

View File

@@ -1,44 +0,0 @@
# Start with '#' is comments
# Start with '^' is deselecting extensions, which is not installed as default
# Each line just leave the extension name or ^ character
bcmath
calendar
ctype
curl
dom
event
exif
fileinfo
filter
gd
hash
iconv
inotify
json
libxml
mbstring
mongodb
mysqlnd
openssl
pcntl
pdo
pdo_mysql
pdo_sqlite
phar
posix
^protobuf
^readline
redis
shmop
simplexml
soap
sockets
sqlite3
swoole
tokenizer
xml
xmlreader
xmlwriter
zlib
zip

View File

@@ -1,63 +0,0 @@
#!/bin/sh
# This script needs alpine linux system.
self_dir=$(cd "$(dirname "$0")";pwd)
test "$VER_PHP" = "" && VER_PHP="8.1.7"
test "$USE_BACKUP" = "" && USE_BACKUP="no"
test "$ALL_EXTENSIONS" = "" && ALL_EXTENSIONS="all"
LINK_APK_REPO='mirrors.ustc.edu.cn'
LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
if [ "${USE_BACKUP}" = "yes" ]; then \
echo "Using backup address..." && sleep 1s
LINK_APK_REPO=${LINK_APK_REPO_BAK}
else
echo "Using original address..." && sleep 1s
fi
sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories
# build requirements
apk add bash file wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses dialog
# php zlib dependencies
apk add zlib-dev zlib-static
# php mbstring dependencies
apk add oniguruma-dev
# php openssl dependencies
apk add openssl-libs-static openssl-dev openssl
# php gd dependencies
apk add libpng-dev libpng-static
# curl c-ares dependencies
apk add c-ares-static c-ares-dev
# php event dependencies
apk add libevent libevent-dev libevent-static
# php sqlite3 dependencies
apk add sqlite sqlite-dev sqlite-libs sqlite-static
# php libzip dependencies
apk add bzip2-dev bzip2-static bzip2
# php micro ffi dependencies
apk add libffi libffi-dev
# php gd event parent dependencies
apk add zstd-static
# php readline dependencies
apk add readline-static ncurses-static readline-dev
test "$USE_BACKUP" = "no" && PROMPT_1="mirror" || PROMPT_1="original"
$self_dir/download.sh swoole ${USE_BACKUP} && \
$self_dir/download.sh inotify ${USE_BACKUP} && \
$self_dir/download.sh mongodb ${USE_BACKUP} && \
$self_dir/download.sh event ${USE_BACKUP} && \
$self_dir/download.sh redis ${USE_BACKUP} && \
$self_dir/download.sh libxml2 ${USE_BACKUP} && \
$self_dir/download.sh xz ${USE_BACKUP} && \
$self_dir/download.sh protobuf ${USE_BACKUP} && \
$self_dir/download.sh curl ${USE_BACKUP} && \
$self_dir/download.sh libzip ${USE_BACKUP} && \
$self_dir/download.sh libiconv ${USE_BACKUP} && \
$self_dir/download-git.sh dixyes/phpmicro phpmicro ${USE_BACKUP} && \
$self_dir/compile-deps.sh && \
$self_dir/compile-php.sh $PROMPT_1 $VER_PHP $ALL_EXTENSIONS /dist/

3
ext-support.md Normal file
View File

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

View File

@@ -1,69 +0,0 @@
#!/usr/bin/env bash
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
echo $1
$downloader "$1" -$_down_prefix "$2" >/dev/null 2>&1 && \
echo "完成!" && _down_symbol=1
else
echo "已存在!" && _down_symbol=1
fi
if [ $_down_symbol == 0 ]; then
echo "失败!请检查网络连接!"
rm -rf "$2"
return 1
fi
return 0
}
function test_composer_and_php() {
succ=$("$(pwd)/runtime/composer" -n about | grep Manage)
if [ "$succ" = "" ]; then
echo "Download PHP binary and composer failed!"
return 1
fi
return 0
}
if [ "$(uname -s)" != "Linux" ]; then
echo "Only support Linux!!!"
exit 1
fi
ZM_PHP_VERSION="7.4"
if [ "$ZM_DOWN_PHP_VERSION" != "" ]; then
ZM_PHP_VERSION="$ZM_DOWN_PHP_VERSION"
echo "Using custom PHP version: $ZM_PHP_VERSION"
fi
mkdir "$(pwd)/runtime" >/dev/null 2>&1
if [ ! -f "$(pwd)/runtime/php" ]; then
download_file "https://dl.zhamao.xin/php-bin/down.php?php_ver=$ZM_PHP_VERSION&arch=$(uname -m)" "$(pwd)/runtime/php.tar.gz"
if [ $? -ne 0 ]; then
exit 1
fi
tar -xf "$(pwd)/runtime/php.tar.gz" -C "$(pwd)/runtime/"
fi
if [ ! -f "$(pwd)/runtime/composer" ]; then
download_file "https://mirrors.aliyun.com/composer/composer.phar" "$(pwd)/runtime/composer.phar"
if [ $? -ne 0 ]; then
exit 1
fi
echo '$(dirname $0)/php $(dirname $0)/composer.phar $@' > $(pwd)/runtime/composer
chmod +x $(pwd)/runtime/composer
test_composer_and_php
fi
if [ $? -ne 0 ]; then
exit 1
fi
echo "成功下载!" && \
echo -e "PHP使用\truntime/php -v" && \
echo -e "Composer使用\truntime/composer"

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,54 @@
<?php
declare(strict_types=1);
namespace SPC;
use SPC\command\BuildCliCommand;
use SPC\command\BuildLibsCommand;
use SPC\command\dev\AllExtCommand;
use SPC\command\dev\PhpVerCommand;
use SPC\command\dev\SortConfigCommand;
use SPC\command\DoctorCommand;
use SPC\command\DownloadCommand;
use SPC\command\DumpLicenseCommand;
use SPC\command\ExtractCommand;
use SPC\command\MicroCombineCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\HelpCommand;
use Symfony\Component\Console\Command\ListCommand;
/**
* static-php-cli console app entry
*/
final class ConsoleApplication extends Application
{
public const VERSION = '2.0.0-rc9';
public function __construct()
{
parent::__construct('static-php-cli', self::VERSION);
$this->addCommands(
[
new BuildCliCommand(),
new BuildLibsCommand(),
new DoctorCommand(),
new DownloadCommand(),
new DumpLicenseCommand(),
new ExtractCommand(),
new MicroCombineCommand(),
// Dev commands
new AllExtCommand(),
new PhpVerCommand(),
new SortConfigCommand(),
]
);
}
protected function getDefaultCommands(): array
{
return [new HelpCommand(), new ListCommand()];
}
}

View File

@@ -0,0 +1,370 @@
<?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 int Concurrency */
public int $concurrency = 1;
/** @var array<string, LibraryBase> libraries */
protected array $libs = [];
/** @var array<string, Extension> extensions */
protected array $exts = [];
/** @var bool compile libs only (just mark it) */
protected bool $libs_only = false;
/** @var array<string, mixed> compile options */
protected array $options = [];
/**
* Build libraries
*
* @param array<string> $libraries Libraries to build
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildLibs(array $libraries): void
{
// search all supported libs
$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;
}
}
// if no libs specified, compile all supported libs
if ($libraries === [] && $this->isLibsOnly()) {
$libraries = array_keys($support_lib_list);
}
// pkg-config must be compiled first, whether it is specified or not
if (!in_array('pkg-config', $libraries)) {
array_unshift($libraries, 'pkg-config');
}
// append dependencies
$libraries = DependencyUtil::getLibsByDeps($libraries);
// add lib object for builder
foreach ($libraries as $library) {
// if some libs are not supported (but in config "lib.json", throw exception)
if (!isset($support_lib_list[$library])) {
throw new WrongUsageException('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);
}
// calculate and check dependencies
foreach ($this->libs as $lib) {
$lib->calcDependency();
}
// extract sources
SourceExtractor::initSource(libs: $libraries);
// build all libs
foreach ($this->libs as $lib) {
match ($lib->tryBuild($this->getOption('rebuild', false))) {
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'),
};
}
}
/**
* Add library to build.
*
* @param LibraryBase $library Library object
*/
public function addLib(LibraryBase $library): void
{
$this->libs[$library::NAME] = $library;
}
/**
* Get library object by name.
*/
public function getLib(string $name): ?LibraryBase
{
return $this->libs[$name] ?? null;
}
/**
* Get all library objects.
*
* @return LibraryBase[]
*/
public function getLibs(): array
{
return $this->libs;
}
/**
* Add extension to build.
*/
public function addExt(Extension $extension): void
{
$this->exts[$extension->getName()] = $extension;
}
/**
* Get extension object by name.
*/
public function getExt(string $name): ?Extension
{
return $this->exts[$name] ?? null;
}
/**
* Get all extension objects.
*
* @return Extension[]
*/
public function getExts(): array
{
return $this->exts;
}
/**
* Check if there is a cpp extensions or libraries.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function hasCpp(): bool
{
// judge cpp-extension
$exts = array_keys($this->getExts());
foreach ($exts as $ext) {
if (Config::getExt($ext, 'cpp-extension', false) === true) {
return true;
}
}
$libs = array_keys($this->getLibs());
foreach ($libs as $lib) {
if (Config::getLib($lib, 'cpp-library', false) === true) {
return true;
}
}
return false;
}
/**
* Set libs only mode.
*/
public function setLibsOnly(bool $status = true): void
{
$this->libs_only = $status;
}
/**
* Verify the list of "ext" extensions for validity and declare an Extension object to check the dependencies of the extensions.
*
* @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) {
$ext->checkDependency();
}
}
/**
* Start to build PHP
*
* @param int $build_target Build target, see BUILD_TARGET_*
*/
abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE);
/**
* Generate extension enable arguments for configure.
* e.g. --enable-mbstring
*
* @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);
}
/**
* Get libs only mode.
*/
public function isLibsOnly(): bool
{
return $this->libs_only;
}
/**
* Get PHP Version ID from php-src/main/php_version.h
*
* @throws RuntimeException
* @throws WrongUsageException
*/
public function getPHPVersionID(): int
{
if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
throw new WrongUsageException('PHP source files are not available, you need to download them first');
}
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0) {
return intval($match[1]);
}
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
}
public function getPHPVersion(): string
{
if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
throw new WrongUsageException('PHP source files are not available, you need to download them first');
}
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
if (preg_match('/PHP_VERSION "(.*)"/', $file, $match) !== 0) {
return $match[1];
}
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
}
/**
* Get build type name string to display.
*
* @param int $type Build target type
*/
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';
}
if (($type & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
$ls[] = 'embed';
}
return implode(', ', $ls);
}
/**
* Get builder options (maybe changed by user)
*
* @param string $key Option key
* @param mixed $default If not exists, return this value
*/
public function getOption(string $key, mixed $default = null): mixed
{
return $this->options[$key] ?? $default;
}
/**
* Get all builder options
*/
public function getOptions(): array
{
return $this->options;
}
/**
* Set builder options if not exists.
*/
public function setOptionIfNotExist(string $key, mixed $value): void
{
if (!isset($this->options[$key])) {
$this->options[$key] = $value;
}
}
/**
* Set builder options.
*/
public function setOption(string $key, mixed $value): void
{
$this->options[$key] = $value;
}
public function getEnvString(array $vars = ['cc', 'cxx', 'ar', 'ld']): string
{
$env = [];
foreach ($vars as $var) {
$var = strtoupper($var);
if (getenv($var) !== false) {
$env[] = "{$var}=" . getenv($var);
}
}
return implode(' ', $env);
}
/**
* Check if all libs are downloaded.
* If not, throw exception.
*
* @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,39 @@
<?php
declare(strict_types=1);
namespace SPC\builder;
use SPC\builder\freebsd\BSDBuilder;
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use Symfony\Component\Console\Input\InputInterface;
/**
* 用于生成对应系统环境的 Builder 对象的类
*/
class BuilderProvider
{
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
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($input->getOptions()),
'Linux' => new LinuxBuilder($input->getOptions()),
'BSD' => new BSDBuilder($input->getOptions()),
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
};
}
}

View File

@@ -0,0 +1,254 @@
<?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
* @throws WrongUsageException
*/
public function getConfigureArg(): string
{
$arg = $this->getEnableArg();
switch (PHP_OS_FAMILY) {
case 'Windows':
$arg = $this->getWindowsConfigureArg();
break;
case 'Darwin':
case 'Linux':
case 'BSD':
$arg .= $this->getUnixConfigureArg();
break;
}
return $arg;
}
/**
* 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx
*
* @throws FileSystemException
* @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;
}
/**
* Run compile check if build target is cli
* If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php
* If check failed, throw RuntimeException
*
* @throws RuntimeException
*/
public function runCliCheck(): void
{
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $this->getDistName() . '"', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
}
if (file_exists(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')) {
// Trim additional content & escape special characters to allow inline usage
$test = str_replace(
['<?php', 'declare(strict_types=1);', "\n", '"', '$'],
['', '', '', '\"', '\$'],
file_get_contents(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')
);
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
}
}
}
/**
* @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,207 @@
<?php
declare(strict_types=1);
namespace SPC\builder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
abstract class LibraryBase
{
/** @var string */
public const NAME = 'unknown';
protected string $source_dir;
protected array $dependencies = [];
protected bool $patched = false;
/**
* @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);
}
/**
* Get current lib source root dir.
*/
public function getSourceDir(): string
{
return $this->source_dir;
}
/**
* Get current lib dependencies.
*
* @return array<string, LibraryBase>
*/
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;
}
/**
* Calculate dependencies for current library.
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function calcDependency(): void
{
// Add dependencies from the configuration file. Here, choose different metadata based on the operating system.
/*
Rules:
If it is a Windows system, try the following dependencies in order: lib-depends-windows, lib-depends-win, lib-depends.
If it is a macOS system, try the following dependencies in order: lib-depends-darwin, lib-depends-unix, lib-depends.
If it is a Linux system, try the following dependencies in order: 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);
}
}
/**
* Get config static libs.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getStaticLibs(): array
{
return Config::getLib(static::NAME, 'static-libs', []);
}
/**
* Get config headers.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getHeaders(): array
{
return Config::getLib(static::NAME, 'headers', []);
}
/**
* Try to build this library, before build, we check first.
*
* BUILD_STATUS_OK if build success
* BUILD_STATUS_ALREADY if already built
* BUILD_STATUS_FAILED if build failed
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function tryBuild(bool $force_build = false): int
{
if (file_exists($this->source_dir . '/.spc.patched')) {
$this->patched = true;
}
// force means just build
if ($force_build) {
logger()->info('Building required library [' . static::NAME . ']');
if (!$this->patched && $this->patchBeforeBuild()) {
file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!');
}
$this->build();
return BUILD_STATUS_OK;
}
// check if these libraries exist, if not, invoke compilation and return the result status
foreach ($this->getStaticLibs() as $name) {
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
}
// header files the same
foreach ($this->getHeaders() as $name) {
if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
}
// pkg-config is treated specially. If it is pkg-config, check if the pkg-config binary exists
if (static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) {
$this->tryBuild(true);
return BUILD_STATUS_OK;
}
// if all the files exist at this point, skip the compilation process
return BUILD_STATUS_ALREADY;
}
/**
* Patch before build, overwrite this and return true to patch libs.
*/
public function patchBeforeBuild(): bool
{
return false;
}
/**
* Get current builder object.
*/
abstract public function getBuilder(): BuilderBase;
/**
* Build this library.
*
* @throws RuntimeException
*/
abstract protected function build();
/**
* Add lib dependency
*
* @throws RuntimeException
*/
protected function addLibraryDependency(string $name, bool $optional = false): void
{
$dep_lib = $this->getBuilder()->getLib($name);
if ($dep_lib) {
$this->dependencies[$name] = $dep_lib;
return;
}
if (!$optional) {
throw new RuntimeException(static::NAME . " requires library {$name}");
}
logger()->debug('enabling ' . static::NAME . " without {$name}");
}
}

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

View File

@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('curl')]
class curl extends Extension
{
/**
* @throws FileSystemException
*/
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
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool
{
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-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,37 @@
<?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::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-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,37 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('glfw')]
class glfw extends Extension
{
/**
* @throws RuntimeException
*/
public function patchBeforeBuildconf(): bool
{
if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) {
return false;
}
FileSystem::copyDir(SOURCE_PATH . '/ext-glfw', SOURCE_PATH . '/php-src/ext/glfw');
return true;
}
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lglfw ', '-lglfw3 ');
return true;
}
public function getUnixConfigureArg(): string
{
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
}
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\util\CustomExt;
#[CustomExt('iconv')]
class iconv extends Extension
{
public function patchBeforeConfigure(): bool
{
// macOS need to link iconv dynamically, we add it to extra-libs
if (!$this->builder instanceof MacOSBuilder) {
return false;
}
$extra_libs = $this->builder->getOption('extra-libs', '');
if (!str_contains($extra_libs, '-liconv')) {
$extra_libs .= ' -liconv';
}
$this->builder->setOption('extra-libs', $extra_libs);
return true;
}
}

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\linux\LinuxBuilder;
use SPC\util\CustomExt;
#[CustomExt('imagick')]
class imagick extends Extension
{
public function patchBeforeMake(): bool
{
// imagick may call omp_pause_all which requires -lgomp
$extra_libs = $this->builder->getOption('extra-libs', '');
if ($this->builder instanceof LinuxBuilder) {
$extra_libs .= ' -lgomp ';
}
$this->builder->setOption('extra-libs', $extra_libs);
return true;
}
public function getUnixConfigureArg(): string
{
return '--with-imagick=' . BUILD_ROOT_PATH;
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
#[CustomExt('imap')]
class imap extends Extension
{
/**
* @throws WrongUsageException
*/
public function getUnixConfigureArg(): string
{
if ($this->builder->getOption('enable-zts')) {
throw new WrongUsageException('ext-imap is not thread safe, do not build it with ZTS builds');
}
$arg = '--with-imap=' . BUILD_ROOT_PATH;
if ($this->builder->getLib('openssl') !== null) {
$arg .= ' --with-imap-ssl=' . BUILD_ROOT_PATH;
}
return $arg;
}
}

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\util\CustomExt;
#[CustomExt('mbregex')]
class mbregex extends Extension
{
public function getConfigureArg(): string
{
return '';
}
/**
* mbregex is not an extension, we need to overwrite the default check.
*/
public function runCliCheck(): void
{
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring" | grep regex', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
}
}
}

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,50 @@
<?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('memcache')]
class memcache extends Extension
{
public function getUnixConfigureArg(): string
{
return '--enable-memcache --with-zlib-dir=' . BUILD_ROOT_PATH;
}
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
'if test -d $abs_srcdir/src ; then',
'if test -d $abs_srcdir/main ; then'
);
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
'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,36 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('mongodb')]
class mongodb extends Extension
{
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'if test -z "$PHP_CONFIG"; then', 'if false; then');
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'PHP_MONGODB_PHP_VERSION=`${PHP_CONFIG} --version`', 'PHP_MONGODB_PHP_VERSION=' . $this->builder->getPHPVersion());
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'PHP_MONGODB_PHP_VERSION_ID=`${PHP_CONFIG} --vernum`', 'PHP_MONGODB_PHP_VERSION_ID=' . $this->builder->getPHPVersionID());
return true;
}
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,31 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
#[CustomExt('opcache')]
class opcache extends Extension
{
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getUnixConfigureArg(): string
{
if ($this->builder->getPHPVersionID() < 80000) {
throw new WrongUsageException('Statically compiled PHP with Zend Opcache only available for PHP >= 8.0 !');
}
return '--enable-opcache';
}
public function getDistName(): string
{
return 'Zend Opcache';
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('openssl')]
class openssl extends Extension
{
public function patchBeforeMake(): bool
{
// patch openssl3 with php8.0 bug
if (file_exists(SOURCE_PATH . '/openssl/VERSION.dat') && $this->builder->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;
}
public function getUnixConfigureArg(): string
{
return '--with-openssl=' . BUILD_ROOT_PATH . ' --with-openssl-dir=' . BUILD_ROOT_PATH;
}
}

View File

@@ -0,0 +1,27 @@
<?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::replaceFileRegex(
SOURCE_PATH . '/php-src/configure',
'/sqlite3_column_table_name=yes/',
'sqlite3_column_table_name=no'
);
return true;
}
}

View File

@@ -0,0 +1,27 @@
<?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::replaceFileRegex(
SOURCE_PATH . '/php-src/configure',
'/-lpq/',
$this->getLibFilesString()
);
return true;
}
}

View File

@@ -0,0 +1,27 @@
<?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::replaceFileRegex(
SOURCE_PATH . '/php-src/configure',
'/-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,33 @@
<?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('snappy')]
class snappy extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/configure',
'/-lsnappy/',
$this->getLibFilesString() . ($this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++')
);
return true;
}
public function getUnixConfigureArg(): string
{
return '--enable-snappy --with-snappy-includedir="' . BUILD_ROOT_PATH . '"';
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('sodium')]
class sodium extends Extension
{
public function patchBeforeBuildconf(): bool
{
// bypass error: unknown warning option '-Wno-logical-op' for macOS
return $this->removeLineContainingString();
}
private function removeLineContainingString(): bool
{
$path = SOURCE_PATH . '/php-src/ext/sodium/config.m4';
$search = '-Wno-logical-op';
if (!file_exists($path)) {
return false;
}
$content = file_get_contents($path);
$lines = preg_split('/\r\n|\n/', $content);
$filteredLines = array_filter($lines, function ($line) use ($search) {
return strpos($line, $search) === false;
});
$newContent = implode("\n", $filteredLines);
file_put_contents($path, $newContent);
return true;
}
}

View File

@@ -0,0 +1,27 @@
<?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::replaceFileRegex(
SOURCE_PATH . '/php-src/configure',
'/-lssh2/',
$this->getLibFilesString()
);
return true;
}
}

View File

@@ -0,0 +1,24 @@
<?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';
// pgsql hook is buggy for static php
$arg .= ' --disable-swoole-pgsql';
$arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl';
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli';
// swoole curl hook is buggy for php 8.0
$arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl';
return $arg;
}
}

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\util\CustomExt;
#[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;
}
/**
* @throws RuntimeException
*/
public function patchBeforeBuildconf(): bool
{
if ($this->builder->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('zlib')]
class zlib extends Extension
{
public function getUnixConfigureArg(): string
{
return '--with-zlib --with-zlib-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('zstd')]
class zstd extends Extension
{
public function getUnixConfigureArg(): string
{
return '--enable-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
}
}

View File

@@ -0,0 +1,253 @@
<?php
declare(strict_types=1);
namespace SPC\builder\freebsd;
use SPC\builder\BuilderBase;
use SPC\builder\traits\UnixBuilderTrait;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\store\SourcePatcher;
class BSDBuilder extends BuilderBase
{
/** Unix compatible builder methods */
use UnixBuilderTrait;
/** @var bool Micro patch phar flag */
private bool $phar_patched = false;
/**
* @throws RuntimeException
* @throws WrongUsageException
* @throws FileSystemException
*/
public function __construct(array $options = [])
{
$this->options = $options;
// ---------- set necessary options ----------
// set C Compiler (default: clang)
f_putenv('CC=' . $this->getOption('cc', 'clang'));
// set C++ Composer (default: clang++)
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
// set PATH
f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
// set PKG_CONFIG
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
// set PKG_CONFIG_PATH
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/');
// set arch (default: current)
$this->setOptionIfNotExist('arch', php_uname('m'));
$this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch')));
// ---------- set necessary compile environments ----------
// concurrency
$this->concurrency = SystemUtil::getCpuCount();
// cflags
$this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('arch'));
$this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch'));
// cmake toolchain
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('BSD', $this->getOption('arch'), $this->arch_c_flags);
// create pkgconfig and include dir (some libs cannot create them automatically)
f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true);
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
}
/**
* Just start to build statically linked php binary
*
* @param int $build_target build target
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{
// ---------- Update extra-libs ----------
$extra_libs = $this->getOption('extra-libs', '');
// add libc++, some extensions or libraries need it (C++ cannot be linked statically)
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : '');
if (!$this->getOption('bloat', false)) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
} else {
logger()->info('bloat linking');
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Wl,-force_load,{$x}", array_filter($this->getAllStaticLibFiles())));
}
$this->setOption('extra-libs', $extra_libs);
SourcePatcher::patchBeforeBuildconf($this);
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
SourcePatcher::patchBeforeConfigure($this);
$json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : '';
$zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : '';
$enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
$enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
'./configure ' .
'--prefix= ' .
'--with-valgrind=no ' . // Not detect memory leak
'--enable-shared=no ' .
'--enable-static=yes ' .
"CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " .
'--disable-all ' .
'--disable-cgi ' .
'--disable-phpdbg ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') .
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') .
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
$json_74 .
$zts .
$this->makeExtensionArgs()
);
SourcePatcher::patchBeforeMake($this);
$this->cleanMake();
if ($enableCli) {
logger()->info('building cli');
$this->buildCli();
}
if ($enableFpm) {
logger()->info('building fpm');
$this->buildFpm();
}
if ($enableMicro) {
logger()->info('building micro');
$this->buildMicro();
}
if ($enableEmbed) {
logger()->info('building embed');
if ($enableMicro) {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la');
}
$this->buildEmbed();
}
if (php_uname('m') === $this->getOption('arch')) {
$this->sanityCheck($build_target);
}
}
/**
* Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildCli(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a",
]);
$shell = shell()->cd(SOURCE_PATH . '/php-src');
$shell->exec('sed -ie "s|//lib|/lib|g" Makefile');
$shell->exec("make -j{$this->concurrency} {$vars} cli");
if (!$this->getOption('no-strip', false)) {
$shell->exec('strip sapi/cli/php');
}
$this->deployBinary(BUILD_TARGET_CLI);
}
/**
* Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildMicro(): void
{
if ($this->getPHPVersionID() < 80000) {
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
}
if ($this->getExt('phar')) {
$this->phar_patched = true;
SourcePatcher::patchMicro(['phar']);
}
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
$vars = [
// with debug information, optimize for size, remove identifiers, patch fake cli for micro
'EXTRA_CFLAGS' => '-g -Os' . $enable_fake_cli,
// link resolv library (macOS needs it)
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a",
];
$vars = SystemUtil::makeEnvVarString($vars);
shell()->cd(SOURCE_PATH . '/php-src')
->exec("make -j{$this->concurrency} {$vars} micro");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx');
}
$this->deployBinary(BUILD_TARGET_MICRO);
if ($this->phar_patched) {
SourcePatcher::patchMicro(['phar'], true);
}
}
/**
* Build fpm sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a", // link resolv library (macOS needs it)
]);
$shell = shell()->cd(SOURCE_PATH . '/php-src');
$shell->exec("make -j{$this->concurrency} {$vars} fpm");
if (!$this->getOption('no-strip', false)) {
$shell->exec('strip sapi/fpm/php-fpm');
}
$this->deployBinary(BUILD_TARGET_FPM);
}
/**
* Build embed sapi
*
* @throws RuntimeException
*/
public function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a", // link resolv library (macOS needs it)
]);
shell()
->cd(SOURCE_PATH . '/php-src')
->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install")
// Workaround for https://github.com/php/php-src/issues/12082
->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o')
->exec('mkdir ' . BUILD_ROOT_PATH . '/lib/php-o')
->cd(BUILD_ROOT_PATH . '/lib/php-o')
->exec('ar x ' . BUILD_ROOT_PATH . '/lib/libphp.a')
->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a')
->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o')
->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o');
}
}

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace SPC\builder\freebsd;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
class SystemUtil
{
/** Unix System Util Compatible */
use UnixSystemUtilTrait;
/**
* Get Logic CPU Count for macOS
*
* @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];
}
/**
* Get Target Arch CFlags
*
* @param string $arch Arch Name
* @return string return Arch CFlags string
* @throws WrongUsageException
*/
public static function getArchCFlags(string $arch): string
{
return match ($arch) {
'amd64', 'x86_64' => '--target=x86_64-unknown-freebsd',
'arm64','aarch64' => '--target=aarch-unknown-freebsd',
default => throw new WrongUsageException('unsupported arch: ' . $arch),
};
}
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace SPC\builder\freebsd\library;
use SPC\builder\BuilderBase;
use SPC\builder\freebsd\BSDBuilder;
use SPC\builder\LibraryBase;
use SPC\builder\traits\UnixLibraryTrait;
abstract class BSDLibraryBase extends LibraryBase
{
use UnixLibraryTrait;
protected array $headers;
public function __construct(protected BSDBuilder $builder)
{
parent::__construct();
}
public function getBuilder(): BuilderBase
{
return $this->builder;
}
}

View File

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

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace SPC\builder\freebsd\library;
class curl extends BSDLibraryBase
{
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')) {
$this->builder->setOption('extra-libs', $this->builder->getOption('extra-libs') . ' /usr/lib/libpthread.a /usr/lib/libdl.a');
}
return $libs;
}
}

View File

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

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\freebsd\library;
use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
class openssl extends BSDLibraryBase
{
public const NAME = 'openssl';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void
{
[$lib,,$destdir] = SEPARATED_PATH;
// lib:zlib
$extra = '';
$ex_lib = '';
$zlib = $this->builder->getLib('zlib');
if ($zlib instanceof MacOSLibraryBase) {
$extra = 'zlib';
$ex_lib = trim($zlib->getStaticLibFiles() . ' ' . $ex_lib);
}
shell()->cd($this->source_dir)
->exec(
"./Configure no-shared {$extra} " .
'--prefix=/ ' . // use prefix=/
"--libdir={$lib} " .
'--openssldir=/etc/ssl ' .
'BSD-' . arch2gnu($this->builder->getOption('arch'))
)
->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\freebsd\library;
/**
* gmp is a template library class for unix
*/
class pkgconfig extends BSDLibraryBase
{
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\freebsd\library;
class zlib extends BSDLibraryBase
{
use \SPC\builder\unix\library\zlib;
public const NAME = 'zlib';
}

View File

@@ -0,0 +1,331 @@
<?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\FileSystem;
use SPC\store\SourcePatcher;
class LinuxBuilder extends BuilderBase
{
/** Unix compatible builder methods */
use UnixBuilderTrait;
/** @var array Tune cflags */
public array $tune_c_flags;
/** @var bool Micro patch phar flag */
private bool $phar_patched = false;
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function __construct(array $options = [])
{
$this->options = $options;
// ---------- set necessary options ----------
// set C/C++ compilers (default: alpine: gcc, others: musl-cross-make)
if (SystemUtil::isMuslDist()) {
f_putenv("CC={$this->getOption('cc', 'gcc')}");
f_putenv("CXX={$this->getOption('cxx', 'g++')}");
f_putenv("AR={$this->getOption('ar', 'ar')}");
f_putenv("LD={$this->getOption('ld', 'ld.gold')}");
} else {
$arch = arch2gnu(php_uname('m'));
f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}");
f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}");
f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}");
f_putenv("LD={$this->getOption('ld', 'ld.gold')}");
f_putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
// check musl-cross make installed if we use musl-cross-make
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) {
throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)');
}
}
// set PKG_CONFIG
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
// set PKG_CONFIG_PATH
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig');
// set arch (default: current)
$this->setOptionIfNotExist('arch', php_uname('m'));
$this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch')));
// concurrency
$this->concurrency = SystemUtil::getCpuCount();
// cflags
$this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch'));
$this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch'));
$this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC'));
// cmake toolchain
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(
'Linux',
$this->getOption('arch'),
$this->arch_c_flags,
getenv('CC'),
getenv('CXX'),
);
// cross-compiling is not supported yet
/*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}'";
}*/
// create pkgconfig and include dir (some libs cannot create them automatically)
f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true);
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
}
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
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
* @throws WrongUsageException
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{
// ---------- Update extra-libs ----------
$extra_libs = $this->getOption('extra-libs', '');
// non-bloat linking
if (!$this->getOption('bloat', false)) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
} else {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles())));
}
// add libstdc++, some extensions or libraries need it
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
$this->setOption('extra-libs', $extra_libs);
$cflags = $this->arch_c_flags;
// prepare build php envs
$envs_build_php = SystemUtil::makeEnvVarString([
'CFLAGS' => $cflags,
'LIBS' => '-ldl -lpthread',
]);
SourcePatcher::patchBeforeBuildconf($this);
shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force');
SourcePatcher::patchBeforeConfigure($this);
$phpVersionID = $this->getPHPVersionID();
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
if ($this->getOption('enable-zts', false)) {
$maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : '';
$zts = '--enable-zts --disable-zend-signals ';
} else {
$maxExecutionTimers = '';
$zts = '';
}
$disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : '';
$enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
$enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
"{$this->getOption('ld_library_path')} " .
'./configure ' .
'--prefix= ' .
'--with-valgrind=no ' .
'--enable-shared=no ' .
'--enable-static=yes ' .
'--disable-all ' .
'--disable-cgi ' .
'--disable-phpdbg ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') .
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') .
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
$disable_jit .
$json_74 .
$zts .
$maxExecutionTimers .
$this->makeExtensionArgs() . ' ' .
$envs_build_php
);
SourcePatcher::patchBeforeMake($this);
$this->cleanMake();
if ($enableCli) {
logger()->info('building cli');
$this->buildCli();
}
if ($enableFpm) {
logger()->info('building fpm');
$this->buildFpm();
}
if ($enableMicro) {
logger()->info('building micro');
$this->buildMicro();
}
if ($enableEmbed) {
logger()->info('building embed');
if ($enableMicro) {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la');
}
$this->buildEmbed();
}
if (php_uname('m') === $this->getOption('arch')) {
$this->sanityCheck($build_target);
}
}
/**
* Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildCli(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make -j{$this->concurrency} {$vars} cli");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php');
}
$this->deployBinary(BUILD_TARGET_CLI);
}
/**
* Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildMicro(): void
{
if ($this->getPHPVersionID() < 80000) {
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
}
if ($this->getExt('phar')) {
$this->phar_patched = true;
SourcePatcher::patchMicro(['phar']);
}
$vars = SystemUtil::makeEnvVarString($this->getBuildVars([
'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '',
]));
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make -j{$this->concurrency} {$vars} micro");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx');
}
$this->deployBinary(BUILD_TARGET_MICRO);
if ($this->phar_patched) {
SourcePatcher::patchMicro(['phar'], true);
}
}
/**
* Build fpm sapi
*
* @throws FileSystemException
* @throws RuntimeException
*/
public function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make -j{$this->concurrency} {$vars} fpm");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm');
}
$this->deployBinary(BUILD_TARGET_FPM);
}
/**
* Build embed sapi
*
* @throws RuntimeException
*/
public function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
shell()
->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install");
}
private function getBuildVars($input = []): array
{
$use_lld = '';
if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) {
$use_lld = '-Xcompiler -fuse-ld=lld';
}
$optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -Os';
$cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : '';
$libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : '';
$ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : '';
return [
'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags,
'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs,
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags,
];
}
}

View File

@@ -0,0 +1,212 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
class SystemUtil
{
use UnixSystemUtilTrait;
/** @noinspection PhpMissingBreakStatementInspection */
public static function getOSRelease(): array
{
$ret = [
'dist' => 'unknown',
'ver' => 'unknown',
];
switch (true) {
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;
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;
}
return $ret;
}
public static function isMuslDist(): bool
{
return static::getOSRelease()['dist'] === 'alpine';
}
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
* @throws WrongUsageException
* @throws WrongUsageException
*/
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} 2>/dev/null");
if ($ret != 0) {
return '';
}
return $flag;
}
/**
* @throws RuntimeException
* @noinspection PhpUnused
*/
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;
}
/** @noinspection PhpUnused */
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;
}
/** @noinspection PhpUnused */
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,36 @@
<?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;
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;
}
}

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';
}

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