Compare commits

...

426 Commits
2.7.0 ... 2.7.7

Author SHA1 Message Date
Jerry Ma
90981e3877 Export php binary external debug symbol files (#953) 2025-11-17 11:53:30 +08:00
henderkes
d69826eb4a update php 8.5 to RC5 2025-11-16 11:30:53 +01:00
Marc
dc83282019 remove SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS, use eu-strip (#966) 2025-11-12 20:51:06 +01:00
henderkes
23c0d6f4aa simplify deployBinary a little bit 2025-11-12 10:11:29 +01:00
henderkes
8e4d4b7be5 suggestion 2025-11-11 16:51:30 +01:00
henderkes
ee906aaff9 Merge remote-tracking branch 'origin/feat/no-strip' into frankenphp/mbed 2025-11-11 15:56:10 +01:00
henderkes
e2b80e7f03 update building of frankenphp 2025-11-11 15:53:44 +01:00
henderkes
09073c5517 sort config and remove lonesome configure cflags 2025-11-11 15:51:28 +01:00
Marc
00050f4d0e Merge branch 'main' into feat/no-strip 2025-11-11 15:17:16 +01:00
crazywhalecc
cff6ec17ea Remove escape backslashes 2025-11-11 15:02:21 +01:00
henderkes
64079d9331 simplify regex 2025-11-11 15:02:20 +01:00
henderkes
541889d17b update to rc4 2025-11-11 15:02:20 +01:00
henderkes
c91128995d update freetype download to get latest version 2025-11-11 15:02:20 +01:00
henderkes
fd2b7af1dc make --with-frankenphp-app=dir work with docker scripts 2025-11-11 15:02:20 +01:00
henderkes
081e2d2846 fix debugflags being backwards 2025-11-11 15:02:19 +01:00
DubbleClick
9edb9417a1 add --with-frankenphp-app option to embed an app
# Conflicts:
#	config/lib.json
#	src/SPC/builder/unix/UnixBuilderBase.php
2025-11-11 15:02:17 +01:00
Marc
4ae4165ba2 add --with-frankenphp-app=/path/to/app option (#891) 2025-11-10 10:37:07 +01:00
crazywhalecc
e441a575ea Remove escape backslashes 2025-11-10 13:26:17 +08:00
henderkes
1575016885 simplify regex 2025-11-09 23:35:49 +01:00
crazywhalecc
987ad4b846 Use diff to detect and deploy-patch new shared extensions that built with php 2025-11-09 17:13:41 +08:00
crazywhalecc
f4b03ae835 Introduce standalone DirDiff util class 2025-11-09 17:12:22 +08:00
henderkes
d6de01d05c update to rc4 2025-11-09 10:01:19 +01:00
henderkes
09b7159119 update freetype download to get latest version 2025-11-08 09:41:12 +01:00
henderkes
4198ddd5d1 make --with-frankenphp-app=dir work with docker scripts 2025-11-07 11:06:50 +01:00
Marc
8332ed87e0 Merge branch 'main' into frankenphp/mbed 2025-11-07 10:51:55 +01:00
crazywhalecc
f6b091498f Fix missing debug link and debug option 2025-11-06 16:51:46 +08:00
crazywhalecc
a45f314447 Remove for pure test 2025-11-06 16:31:24 +08:00
crazywhalecc
8c8cb70174 phpstan fix 2025-11-06 16:27:11 +08:00
crazywhalecc
f09c18e78f Use separated deploy functions 2025-11-06 16:24:59 +08:00
crazywhalecc
f5d93d2f54 Merge branch 'main' into feat/no-strip 2025-11-06 14:55:54 +08:00
Marc
7402fbf7c1 Use cmake to build librdkafka, add helper function for SPCConfigUtil (#955) 2025-11-04 14:58:58 +01:00
crazywhalecc
2c590e5895 Define dependencies with kv array 2025-11-04 15:52:52 +08:00
crazywhalecc
463a98b1bf Support suggested libs not specified by with-suggested-libs 2025-11-04 13:51:11 +08:00
crazywhalecc
6d1c6d7f61 Add PHPDocs 2025-11-04 13:38:11 +08:00
crazywhalecc
08362fb6e5 Add helper function for SPCConfigUtil 2025-11-04 13:36:29 +08:00
crazywhalecc
4d5641f6ec Change librdkafka to cmake 2025-11-04 13:35:43 +08:00
crazywhalecc
f34ecf9468 Use pkg-configs for librdkafka 2025-11-04 13:35:31 +08:00
crazywhalecc
aa5c829fae Add missing file and line for Unhandled exception 2025-11-04 13:35:15 +08:00
Marc
fc118d709e Remove deduplication of pkg-config libraries
Removed deduplication of pkg-config libraries.
2025-11-03 21:58:46 +01:00
henderkes
589a4a9803 test rdkafka with all suggested libs 2025-11-03 21:13:47 +01:00
Marc
944e314bab Merge branch 'main' into feat/rdkafka-ssl 2025-11-03 20:48:19 +01:00
henderkes
0b17ce9e61 test rdkafka with all suggested libs 2025-11-03 20:47:42 +01:00
henderkes
ed4978bb89 add frankenphp version 2025-11-03 20:40:50 +01:00
henderkes
7a4f28e939 add frankenphp version 2025-11-03 20:39:26 +01:00
henderkes
5cb6a75e7d add extra features to librdkafka (curl, ssl, sasl 2025-11-03 20:29:15 +01:00
crazywhalecc
757af25d8f Suggestions 2025-11-01 00:49:50 +08:00
crazywhalecc
5e3e7eccbf Update version to 2.7.7 2025-10-31 16:48:55 +08:00
crazywhalecc
9738fcd6cd Update env.ini docs 2025-10-31 16:48:36 +08:00
crazywhalecc
5a6a33303c Export php binary debug symbols for mac, linux and windows 2025-10-31 16:48:21 +08:00
Marc
ae15d6c5f5 fix postgresql libraries when --with-suggested-libs is false (#952) 2025-10-31 09:46:21 +01:00
henderkes
ff15973a25 suggestions 2025-10-31 09:08:15 +01:00
henderkes
b88a68dab8 fix postgresql libraries when --with-suggested-libs is false 2025-10-29 18:55:26 +01:00
Jerry Ma
b05bdcd83d Add snmp and net-snmp support for macOS and Linux (#946)
Co-authored-by: Marc <m@pyc.ac>
2025-10-29 11:56:36 +08:00
Jerry Ma
6a4ad34324 Add trader extension support (#951) 2025-10-29 11:54:35 +08:00
henderkes
9a2d94cc33 fix debugflags being backwards 2025-10-28 18:50:16 +01:00
Jerry Ma
f1d1d4fe10 Beautify docs (#948) 2025-10-28 18:56:18 +08:00
crazywhalecc
fa6fa1c425 Add docs 2025-10-27 09:56:47 +08:00
Jerry Ma
f8c8300c9c Add Windows CGI SAPI build support (#927) 2025-10-25 16:04:00 +08:00
crazywhalecc
09198b431f Use unified configure args format 2025-10-25 15:41:48 +08:00
crazywhalecc
f426ced789 Use phpmicro patches instead 2025-10-25 13:42:04 +08:00
crazywhalecc
bab330b64e Unify CGI deploy functions 2025-10-25 03:03:40 +08:00
crazywhalecc
b59a06face Add backward patches for win32 2025-10-25 02:56:38 +08:00
crazywhalecc
bb44e88c3b Merge branch 'refs/heads/main' into sapi/cgi-win
# Conflicts:
#	src/globals/test-extensions.php
2025-10-25 00:11:45 +08:00
Marc
8649068159 Merge branch 'main' into frankenphp/mbed 2025-10-24 16:50:28 +02:00
Marc
5476385553 Update PHP 8.5 to RC3, enable swoole-stdext for upcoming 6.1.0 release. (#944) 2025-10-24 12:09:46 +02:00
henderkes
56bac35768 do both in one go 2025-10-24 12:09:24 +02:00
henderkes
4cdc6a07ae fix php 8.5 2025-10-24 11:49:11 +02:00
crazywhalecc
c30b34ae5c Fix gettext missing symbols on macOS 2025-10-24 17:02:15 +08:00
Marc
da5c6fd084 Merge branch 'main' into fix/php85 2025-10-24 10:47:29 +02:00
Jerry Ma
a4b6499530 Fix libevent build, use newer cmake options (#945) 2025-10-24 16:34:07 +08:00
henderkes
eb4445ea59 use release tarballs from Daniel rather than automatically generated ones from github 2025-10-24 10:06:29 +02:00
crazywhalecc
be51bcfdfc Fix libevent build, use newer cmake options 2025-10-24 13:55:33 +08:00
henderkes
7bc4131c02 use correct license for gettext as we only build libs now, update gmp to dynamically check version 2025-10-23 23:11:30 +02:00
henderkes
da8debdade test php 8.5 with gettext 2025-10-23 22:19:53 +02:00
henderkes
ef5e664981 don't build iconv program, or gettext programs 2025-10-23 22:14:57 +02:00
henderkes
8e50af3a7e update to rc3 2025-10-23 21:28:49 +02:00
henderkes
8e96c64918 add stdext to swoole 2025-10-23 21:28:48 +02:00
henderkes
8a9c8a279d why does this fix compilation? 2025-10-23 21:28:48 +02:00
Marc
72ca0cecd1 Update license path for attr package (#941) 2025-10-23 13:32:43 +02:00
Marc
3564f6d0a7 Fix zip archive strip function for cross-device move (#942) 2025-10-23 13:32:12 +02:00
henderkes
d3e2b4b5b2 don't even build tools in the first place 2025-10-23 13:11:20 +02:00
crazywhalecc
c6de6e7056 test zip unarchive 2025-10-23 16:29:46 +08:00
crazywhalecc
55322a282c Fix rename cross-device link bug (using copy-delete) 2025-10-23 15:19:45 +08:00
Marc
6789ea81ff Update license path for acl in source.json 2025-10-22 19:52:21 +02:00
Marc
ac8a9af89c Update license path for attr package 2025-10-22 19:43:54 +02:00
Marc
553b817b2a prevent libedit from building strlcat/strlcpy, no idea why their sour… (#937) 2025-10-21 21:14:39 +07:00
henderkes
96592bce3e fix 2025-10-21 14:26:44 +02:00
henderkes
4e393886aa no idea why our source has that uncommented 2025-10-21 14:23:55 +02:00
henderkes
2e13be2a7a prevent libedit from building strlcat/strlcpy, no idea why their soure code doesn't prevent this correctly itself 2025-10-21 13:54:34 +02:00
Jerry Ma
41fb29eba4 Feat/pie (#936) 2025-10-21 18:58:04 +08:00
Jerry Ma
b519291fa2 PIE download support & Downloader and ConfigValidator enhance (#934) 2025-10-21 16:20:13 +08:00
crazywhalecc
dd752cd5be Fix windows 7z unzip strip function, fix windows pkg extract files path 2025-10-21 15:50:12 +08:00
Marc
6a153f9aa0 also install-modules of course... (#933) 2025-10-21 10:06:56 +07:00
henderkes
bba390dbcc add runtime libs to unixshell (debian 11 is stupid and doesn't add them automatically) 2025-10-20 23:04:33 +02:00
henderkes
32efeb970c don't build ossfuzzer for zip 2025-10-20 23:00:23 +02:00
henderkes
310335813f use libedit for postgreqsql 2025-10-20 21:24:21 +02:00
crazywhalecc
487980c9a8 phpunit fix 2025-10-20 13:48:52 +08:00
crazywhalecc
f8801e224f phpstan fix 2025-10-20 13:43:05 +08:00
crazywhalecc
5e229a0b01 Update dependencies 2025-10-20 13:41:41 +08:00
crazywhalecc
49cfcbe92d Update docs 2025-10-20 13:41:33 +08:00
crazywhalecc
4e4ce282db Fix zip extract not strip dir bug 2025-10-20 13:41:25 +08:00
crazywhalecc
e2fd3e18d6 Refactor ConfigValidator, make it more strict 2025-10-20 13:41:02 +08:00
crazywhalecc
605c06f85c Add pie support for downloading sources 2025-10-20 13:39:13 +08:00
Marc
4cdefeab81 test with modules to build
linux should use install-modules now, macOS should not (zip is not built with php)
2025-10-19 11:03:39 +02:00
henderkes
8ab09898f0 conditional install-modules 2025-10-19 10:41:14 +02:00
henderkes
9c8b4d627c also install-modules of course... 2025-10-19 09:08:50 +02:00
Marc
8923077120 don't use full install target, don't install-binaries (#932) 2025-10-18 21:21:42 +07:00
henderkes
29c31d90e5 also only do that for macos (saves build time) 2025-10-18 11:35:41 +02:00
henderkes
e281d26a3a Merge remote-tracking branch 'origin' into fix/frankenphp-readline 2025-10-18 11:35:14 +02:00
henderkes
8ed68f481a don't pass unused envs 2025-10-18 11:31:20 +02:00
henderkes
b1abff61a5 don't use full install target, don't install-binaries 2025-10-18 11:08:55 +02:00
crazywhalecc
15638cea4c Add log dir expose, unify SPC_FIX_DEPLOY_ROOT parsing 2025-10-18 12:52:59 +08:00
Marc
9ed77c10e0 use the spx upstream version (#931) 2025-10-17 23:55:37 +07:00
crazywhalecc
ccf262d202 Update test workflow to trigger on pull request events only 2025-10-17 13:28:00 +08:00
crazywhalecc
4be894bc10 Remove ds and gd test 2025-10-17 10:15:05 +08:00
crazywhalecc
6440863ce4 Remove igbinary 2025-10-17 09:25:44 +08:00
henderkes
25d7c72b6e use the upstream version 2025-10-16 23:19:24 +07:00
crazywhalecc
dc4dd6ffa4 Full test 2025-10-16 20:52:20 +08:00
crazywhalecc
bf79134405 Fix tsrmls cache define patches 2025-10-16 20:42:26 +08:00
crazywhalecc
4f8b9d0f81 Fix patches 2025-10-16 02:18:24 +08:00
crazywhalecc
70bda268e5 Fix patches, add more debug comments 2025-10-16 01:51:22 +08:00
crazywhalecc
e559dce9d5 Reduce tests 2025-10-16 01:35:30 +08:00
crazywhalecc
6a98a6bf5e Use BUILD_BIN_PATH instead 2025-10-16 01:32:56 +08:00
crazywhalecc
9b53133ba4 test 2025-10-16 01:19:10 +08:00
crazywhalecc
5b319b0df1 test 2025-10-16 01:16:22 +08:00
crazywhalecc
572bf919aa test 2025-10-16 01:13:26 +08:00
crazywhalecc
1d960a9084 test 2025-10-16 01:05:06 +08:00
crazywhalecc
4b28d1c2df test 2025-10-16 01:04:42 +08:00
crazywhalecc
9c8fd4d45d cs fix 2025-10-16 00:59:33 +08:00
crazywhalecc
b62f029da7 cs fix 2025-10-16 00:56:28 +08:00
crazywhalecc
c711a3666e Add Windows CGI SAPI build support 2025-10-16 00:55:21 +08:00
Marc
487c6da4ac switch readline to libedit (#919) 2025-10-15 10:21:00 +02:00
Marc
e942b13d73 Merge branch 'main' into libedit 2025-10-13 21:28:15 +02:00
Jerry Ma
c5ae719b9c Update src/SPC/builder/unix/library/postgresql.php
Co-authored-by: Marc <m@pyc.ac>
2025-10-14 00:08:40 +08:00
crazywhalecc
7b6e707e24 Remove unnecessary macOS 15 bug CFLAGS from PostgreSQL build configuration 2025-10-14 00:08:40 +08:00
crazywhalecc
0114700dad Fix PostgreSQL build compatibility for aarch64 on glibc 2.17 and update test configurations 2025-10-14 00:08:40 +08:00
Marc
ec9364db69 use latest zip version for building shared (#917) 2025-10-13 11:28:16 +02:00
Marc
033e29985e Merge branch 'main' into feature/shared-exts 2025-10-13 11:20:54 +02:00
Marc
61cba2342d Drop macos-13 from actions runner (#922) 2025-10-13 11:20:37 +02:00
Marc
a3acad4ef3 Update config/source.json 2025-10-13 10:59:31 +02:00
Marc
1e13eb4abe Merge branch 'main' into ci/macos-15-intel 2025-10-13 10:38:48 +02:00
Jerry Ma
1bac06fe3c Remove more macOS 14 case from shared extensions switch
Yeah. Copied by tab.
2025-10-13 08:27:40 +08:00
Marc
762a768969 Merge branch 'main' into feature/shared-exts 2025-10-12 23:23:25 +02:00
Marc
d0a6e3a860 update pgsql version to 18.0, php 8.5 to RC2 (#916) 2025-10-12 22:59:09 +02:00
henderkes
995187d258 extra information for steps 2025-10-12 22:32:27 +02:00
henderkes
5333a04e1c clarification 2025-10-12 22:27:38 +02:00
henderkes
19be5263b5 add error 2025-10-12 22:26:06 +02:00
crazywhalecc
6e79401ab5 Add missing libs for suggested option defined 2025-10-13 00:21:13 +08:00
crazywhalecc
903036f1c0 Bump version 2025-10-13 00:00:31 +08:00
crazywhalecc
6bd3eea0fe Use SPCConfigUtil for postgresql build, refactor patches 2025-10-12 23:54:59 +08:00
crazywhalecc
f28a3cf5a3 Drop macos-13 from actions runner 2025-10-12 22:33:22 +08:00
Marc
c828c2c6e4 Merge branch 'main' into feature/shared-exts 2025-10-12 11:35:57 +02:00
Marc
26ccaa4449 Merge branch 'main' into libedit 2025-10-12 11:34:11 +02:00
Marc
ae1193ab16 Merge branch 'main' into pgsql-18 2025-10-12 11:28:49 +02:00
Marc
6d6a29368e fix building of shared extensions (grpc, simdjson, soap) (#905) 2025-10-12 11:24:32 +02:00
crazywhalecc
897cb00351 Use failsafe for SPC_EXTRA_PHP_VARS 2025-10-12 16:42:38 +08:00
henderkes
8a1689b79d don't fail build without ldap 2025-10-11 13:20:20 +02:00
henderkes
018dfae15e suggestions 2025-10-11 10:38:51 +02:00
Marc
c83e803c85 Merge branch 'main' into pgsql-18 2025-10-10 18:47:48 +02:00
henderkes
fa4d33671d update to RC2 2025-10-10 18:35:15 +02:00
henderkes
f8d77b9b50 remove pointless comments 2025-10-08 11:55:21 +02:00
henderkes
6594811536 remove pointless SPC_CMD_PREFIX_PHP_MAKE 2025-10-08 11:48:40 +02:00
henderkes
cc7eb7cd84 Merge remote-tracking branch 'origin/main' into libedit 2025-10-08 11:37:54 +02:00
Marc
e6408b4693 Fix static linux cli -a not working issue (#893) 2025-10-08 11:37:27 +02:00
henderkes
330c3486af extra readline check to make sure -a works 2025-10-08 10:45:23 +02:00
henderkes
b9dfb5afe3 maybe better this way 2025-10-08 10:17:14 +02:00
henderkes
565ac87b65 only apply readline fix for CLI compilation on linux 2025-10-08 10:05:02 +02:00
henderkes
f0c39c1770 fix #19871 2025-10-08 09:46:20 +02:00
henderkes
896cf889e4 test readline 2025-10-08 09:27:04 +02:00
henderkes
6b91570054 fix clang musl compilation 2025-10-08 09:26:20 +02:00
henderkes
31906b36e5 reorder stuff for readline 2025-10-08 08:48:30 +02:00
henderkes
4e2d4f3f05 fix ncurses build error (?: [] in case of false) 2025-10-08 08:47:48 +02:00
henderkes
ffdc2dc85a fix #918 (use COPYING.LIB instead of COPYING for libiconv) 2025-10-08 08:18:43 +02:00
DubbleClick
911bc74bf4 add libedit 2025-10-08 08:16:54 +02:00
henderkes
3467c9d291 patch correct file 2025-10-06 22:53:41 +02:00
henderkes
15cd8543f1 arm64 fix 2025-10-06 22:50:37 +02:00
henderkes
864db0ebc5 fix macos finally I hope 2025-10-06 22:49:28 +02:00
henderkes
9ee623112d attempt to fix macOS? 2025-10-06 22:43:03 +02:00
henderkes
d789b1a472 fix musl toolchain (needs LD_LIBRARY_PATH) 2025-10-06 22:31:23 +02:00
henderkes
17a25b44e2 attempt fix for aarch64 #2 2025-10-06 22:26:00 +02:00
henderkes
781260f3fc attempt fix for aarch64 2025-10-06 22:11:17 +02:00
henderkes
6c43fa55b1 don't use -static, shared libraries cannot link against static musl libc and linking isn't done for static libraries yet 2025-10-06 21:37:36 +02:00
henderkes
c4440668bb make sure -DFRONTEND is used 2025-10-06 21:28:57 +02:00
henderkes
e437bf2ffe don't test macos 13 2025-10-06 21:05:05 +02:00
henderkes
0f2d2d5734 test pgsql without macos 13 2025-10-06 21:03:57 +02:00
henderkes
a49ae05599 use latest zip version for building shared 2025-10-06 21:00:45 +02:00
henderkes
8ae2755dbe update php 8.5 to rc1 2025-10-06 20:14:52 +02:00
henderkes
3966bd5f0a update pgsql version to 18.0 2025-10-06 20:06:37 +02:00
Marc
384ba54c79 update extension count (#914) 2025-10-04 08:56:30 +02:00
Marc
26dbc922eb update extension count
we now sit at 101 🎉
2025-10-04 08:39:45 +02:00
henderkes
31a4498056 bring back simdjson tests, extension headers do not properly guard for avx512 symbols 2025-09-30 15:07:22 +02:00
henderkes
044275d909 typo 2025-09-30 14:22:38 +02:00
henderkes
c5316f9231 -v3 doesn't have avx512 yet 2025-09-30 14:21:31 +02:00
henderkes
2d1a61d184 explicitly disable avx512 if zig and march not high enough 2025-09-30 14:00:13 +02:00
henderkes
f7744188f4 fix configutil 2025-09-30 00:34:30 +02:00
henderkes
5b6c923eef snappy is a c++ lib 2025-09-30 00:31:20 +02:00
henderkes
b0b031afb2 add docstring 2025-09-30 00:18:32 +02:00
henderkes
fe09d8c03e add docstring 2025-09-30 00:17:53 +02:00
henderkes
c2813d5736 move hasCpp to SPCConfigUtil 2025-09-30 00:12:59 +02:00
Marc
8b2b658ced Merge branch 'main' into fix/grpc-shared 2025-09-29 23:27:58 +02:00
henderkes
e862bacc8a php 8.5 has beta 3 2025-09-29 21:15:56 +02:00
henderkes
cac57dbf79 php 8.5 has beta 3 2025-09-29 21:15:18 +02:00
crazywhalecc
345fe783cc Add version table in docs 2025-09-24 15:46:54 +08:00
crazywhalecc
55efe6d65b Add gnu-bulk 2025-09-24 15:46:54 +08:00
crazywhalecc
dccbc30972 update README 2025-09-24 15:46:54 +08:00
crazywhalecc
f914a82379 Add PHP version, remove duplicate desc 2025-09-24 15:46:54 +08:00
crazywhalecc
18979d8fb6 Simplify README 2025-09-24 15:46:54 +08:00
henderkes
21149f6807 simdjson needs patch 2025-09-23 12:42:29 +02:00
henderkes
93e6dcab1d cflags and cxxflags separately 2025-09-23 12:01:09 +02:00
henderkes
59dedbea2c simdjson requires +evex512 (for zig-cc) 2025-09-23 12:00:15 +02:00
henderkes
8bda4fd31e simdjson requires +evex512 2025-09-23 11:59:30 +02:00
henderkes
8039ea49f9 soap requires libxml and session 2025-09-23 11:56:12 +02:00
henderkes
fc90b4ae23 allow appending pkg_config_path #910 2025-09-22 13:10:48 +02:00
henderkes
e02be69e40 update grpc from 1.68.x to 1.75.x 2025-09-21 21:01:07 +02:00
henderkes
35a90f2769 skip -mcpu or -march=armv8-... flags because zig doesn't support them (stupid grpc build thirdparty hardcode) 2025-09-21 20:32:47 +02:00
henderkes
fa87149631 shallow submodules as well (grpc download goes from 2.9 gb to 900mb) 2025-09-21 19:59:24 +02:00
Marc
8dfe722e14 Merge branch 'main' into fix/grpc-shared 2025-09-19 15:31:25 +02:00
henderkes
dcbfe1e0ab e-dant/watcher is a c++ library too 2025-09-19 15:29:49 +02:00
Marc
e11946fd10 also install g++ with doctor (not preinstalled on ubuntu, not include… (#904) 2025-09-19 15:22:17 +02:00
henderkes
44399cd185 remove -Wl,--as-needed for imagemagick build 2025-09-19 09:21:17 +02:00
henderkes
927d7f55ba make sure -ldl is not taken as needed, problem on EL8 2025-09-18 22:47:01 +02:00
henderkes
e323d7b155 revert to private 2025-09-18 21:41:35 +02:00
henderkes
d0b253c346 not required 2025-09-18 21:36:38 +02:00
henderkes
81430e6853 also use libstdc++.a for grpc? 2025-09-18 21:29:46 +02:00
henderkes
83696e92b7 remove whitespace 2025-09-18 20:12:41 +02:00
henderkes
b0538c09bf deduplicate those to make it more readable 2025-09-18 20:09:17 +02:00
henderkes
40f89d1dca is shared_libadd enough? 2025-09-18 19:44:48 +02:00
henderkes
fa2e041cc9 test shared grpc, imagick 2025-09-18 19:01:10 +02:00
Marc
3c614663a3 Merge branch 'main' into fix/grpc-shared 2025-09-18 18:22:42 +02:00
henderkes
b5c7185374 add comment for new method 2025-09-18 18:20:26 +02:00
henderkes
d0a9a3a594 fix return of array 2025-09-18 18:17:48 +02:00
henderkes
2e6329bb86 add cpp-library for imagemagick too 2025-09-18 18:16:42 +02:00
henderkes
d3ba04fc5b fix grpc shared build (ignores CXXFLAGS, needs CPPFLAGS) 2025-09-18 18:16:41 +02:00
Marc
7a78ea0185 Merge branch 'main' into fix/g++ 2025-09-18 17:35:44 +02:00
henderkes
36b04f9eba also install g++ with doctor (not preinstalled on ubuntu, not included in gcc package) 2025-09-18 17:24:08 +02:00
Marc
79ab6490fd fix CustomPackage handling (#897) 2025-09-18 13:37:26 +02:00
henderkes
191d345250 update paths to only install once 2025-09-18 12:41:36 +02:00
henderkes
311ee40ae4 update LinuxToolCheckList.php to install perl-Time-Piece to make openssl work 2025-09-18 11:58:58 +02:00
henderkes
808d224b08 build frankenphp before shared extensions again 2025-09-18 09:07:18 +02:00
Marc
4247883664 Merge branch 'main' into fix-zig 2025-09-18 08:06:23 +02:00
Marc
3198cc40c1 Remove icu backend from libxml2 (#903) 2025-09-17 10:46:05 +02:00
Marc Henderkes
8680e83af3 fix dba building shared 2025-09-16 14:43:49 +02:00
Marc
0156f33a20 Merge branch 'main' into remove-icu-backend 2025-09-16 13:35:46 +02:00
Marc Henderkes
df8b2dbf16 better patching for libstdc++ when extensions forget they need it 2025-09-16 13:10:10 +02:00
Marc Henderkes
30e174ac95 use any available english locale instead of requiring en_US.utf-8 2025-09-16 13:10:09 +02:00
Marc Henderkes
b9f8f02d98 don't use libicu backend for libxml2
(it's discouraged from being used, the first path always goes through iconv, icu is only the fallback)
2025-09-16 13:10:09 +02:00
henderkes
0b0ae270da we lost a v somehow 2025-09-10 23:35:17 +07:00
henderkes
893ce31b17 only install pkgs for crafting when necessary 2025-09-10 23:28:20 +07:00
crazywhalecc
e35d6c2651 Oh, we also support windows here 2025-09-09 19:43:08 +08:00
crazywhalecc
8dd0512335 Fix macOS lib-depends 2025-09-09 19:43:08 +08:00
henderkes
5c1194ea92 fix custompackage handling 2025-09-09 12:10:06 +07:00
Marc
953ed83df5 Merge pull request #896 from crazywhalecc/fix-zig
Fix zig -isystem overriding
2025-09-08 11:00:03 +02:00
henderkes
c330d02e78 update pkg paths to not double the $arch-$os 2025-09-08 14:18:03 +07:00
henderkes
af6a23011c fix zig relative directory 2025-09-08 13:33:44 +07:00
Abi أب
882ae07deb libxml2 arg typo 2025-09-07 22:56:41 +08:00
crazywhalecc
be7c002869 Patch only when building cli 2025-09-07 16:10:50 +08:00
crazywhalecc
e621e4a5a1 test 2025-09-07 15:38:38 +08:00
crazywhalecc
bd815d4ea2 Fix static linux cli -a not working issue 2025-09-07 14:10:28 +08:00
crazywhalecc
4bc30b0b6f Add php-src/config.log for SPCException 2025-09-07 11:50:51 +08:00
DubbleClick
4d3501118e add --with-frankenphp-app option to embed an app 2025-09-05 21:47:41 +07:00
Marc
8d303348d9 Merge pull request #883 from crazywhalecc/sapi/cgi
Add cgi support for macOS and Linux
2025-09-05 11:52:26 +02:00
Marc
2a2f4120b9 Merge pull request #889 from crazywhalecc/franken
use our toolchain for go mod
2025-09-05 11:47:15 +02:00
Marc
15f8887f14 Update config/lib.json 2025-09-05 16:25:15 +07:00
crazywhalecc
fe945ab3ea Merge branch 'main' into sapi/cgi
# Conflicts:
#	composer.lock
2025-09-05 17:15:28 +08:00
crazywhalecc
e2b6f4cedd Merge branch 'main' into sapi/cgi 2025-09-05 17:14:27 +08:00
Jerry Ma
d82c86cf62 Fix docker doctor fix pkgroot volume overwrite bug (#882)
* Fix docker doctor fix pkgroot volume overwrite bug

* cs fix

* Remove pkgroot-private

* Use arch-specified pkgroot

* Update setup-runtime php version

* Add docker-entrypoint.sh

* Update dependencies

* cs fix

* test
2025-09-05 17:13:40 +08:00
henderkes
9df2867175 just always require libxml2 until we rework sapis to require their own stuff 2025-09-05 15:52:07 +07:00
henderkes
5c803d1553 fix cs 2025-09-05 15:31:30 +07:00
henderkes
d45b1853f8 fix cs 2025-09-05 15:28:51 +07:00
henderkes
1ac621fb9c use our toolchain for go mod 2025-09-05 15:20:24 +07:00
crazywhalecc
4e74ac1937 test 2025-09-05 15:02:45 +08:00
crazywhalecc
959734ac31 cs fix 2025-09-05 11:17:45 +08:00
crazywhalecc
166f3de52f Merge branch 'main' into feat/cgi 2025-09-05 11:17:34 +08:00
crazywhalecc
e3adfff16f Update dependencies 2025-09-05 11:14:56 +08:00
crazywhalecc
7cbc374278 Add docker-entrypoint.sh 2025-09-05 11:04:42 +08:00
crazywhalecc
129041402d Update setup-runtime php version 2025-09-05 11:00:57 +08:00
crazywhalecc
9ac578dfd6 Use arch-specified pkgroot 2025-09-05 11:00:46 +08:00
crazywhalecc
ef709a169b Remove pkgroot-private 2025-09-05 11:00:25 +08:00
Marc
2eeba33f94 Merge pull request #885 from crazywhalecc/dumb_github
switch getting frankenphp version to go mod (bypass rate limits)
2025-09-04 18:15:40 +02:00
henderkes
f4b2b9ae7d fix cs 2025-09-04 17:45:13 +07:00
henderkes
e44efb2a54 use go mod to bypass github rate limiting 2025-09-04 17:42:17 +07:00
henderkes
598f6d55c5 keep retrying more 2025-09-04 16:28:17 +07:00
crazywhalecc
a2c5c7e6e6 Add cgi SAPI 2025-09-04 14:05:00 +08:00
crazywhalecc
4f6e646812 cs fix 2025-09-04 12:13:57 +08:00
crazywhalecc
a79564f685 Fix docker doctor fix pkgroot volume overwrite bug 2025-09-04 12:03:13 +08:00
crazywhalecc
a77e49cbc9 Stubborn phpstan 2025-09-02 00:17:44 +08:00
crazywhalecc
cefb737fd2 Update version to 2.7.3 2025-09-02 00:17:44 +08:00
crazywhalecc
8c8aba2dd5 Fix unixodbc driver config searching path 2025-09-02 00:17:44 +08:00
Marc
97b18e9121 Merge pull request #877 from crazywhalecc/franken-retries
retry fetching frankenphp release info
2025-09-01 15:29:21 +02:00
gemini
ddc9cc2237 Fix cli generator: prefer-pre-built belongs to download-options rather than build-options 2025-09-01 20:44:37 +08:00
DubbleClick
aff803f334 retry fetching frankenphp release info 2025-09-01 19:07:29 +07:00
Marc
38ec03fe30 Merge pull request #871 from crazywhalecc/fix/frankenphp-dynamic-exports
build frankenphp and embed after shared extensions
2025-08-31 15:06:11 +02:00
Marc
55836771c9 Merge pull request #869 from crazywhalecc/pkg-config-pkg
turn pkg-config into a package
2025-08-31 15:04:41 +02:00
crazywhalecc
08a68796bf Call export in dynamic symbol getter 2025-08-31 18:05:09 +08:00
crazywhalecc
3b9efcb2d4 Put it into toolchain manager to skip in unit test 2025-08-31 15:24:29 +08:00
crazywhalecc
022ba3dce4 Merge branch 'main' into pkg-config-pkg
# Conflicts:
#	src/globals/test-extensions.php
2025-08-31 15:20:50 +08:00
crazywhalecc
86973e622d sort config 2025-08-31 15:06:59 +08:00
crazywhalecc
0fa38bad6d Use existing pkg-config builds and pre-built contents for packages 2025-08-31 15:04:34 +08:00
crazywhalecc
465bd3ce85 Use separated functions for exporting symbols 2025-08-31 14:24:28 +08:00
Jerry Ma
0c9130ab6c Update node version in vitepress-deploy.yml 2025-08-31 13:44:37 +08:00
crazywhalecc
6c75ecf0c4 Add docs search 2025-08-31 11:47:41 +08:00
DubbleClick
d533a0591b skip line before preg_replacing 2025-08-30 19:31:22 +07:00
DubbleClick
3f74d58503 fix macos, for real this time 2025-08-30 14:12:13 +07:00
DubbleClick
1ba92ccc99 fix patch version stripping (.\d -> .\d+) 2025-08-30 12:02:15 +07:00
DubbleClick
75db184077 fix macos command to print defined symbols? 2025-08-29 17:50:47 +07:00
DubbleClick
66902d74c4 cs fix 2025-08-29 16:38:48 +07:00
DubbleClick
f6cc6af39c macos? 3 2025-08-29 16:36:43 +07:00
DubbleClick
0da8dcf04a macos? 2 2025-08-29 15:14:54 +07:00
DubbleClick
190be6c7b9 macos? 2025-08-29 14:12:00 +07:00
DubbleClick
2972ab31d7 don't add empty dynamic list x) 2025-08-29 12:15:56 +07:00
DubbleClick
4b4ae9b014 write to a --dynamic-list file
see https://sourceware.org/binutils/docs-2.36/ld/Options.html
2025-08-29 10:53:38 +07:00
DubbleClick
20db00afcc no need to test all static targets, nothing changes for them 2025-08-29 10:26:46 +07:00
DubbleClick
56c90ca4a3 use all symbols from libphp.a, so we don't need to build shared extensions 2025-08-29 10:24:51 +07:00
DubbleClick
fad2314539 found ENABLE_SHARED option in liburing! 2025-08-29 09:25:32 +07:00
DubbleClick
460eb02086 build frankenphp and embed after shared extensions, make sure the linker doesn't drop libphp.a symbols that extensions need 2025-08-29 08:52:55 +07:00
Marc
5a30d509e7 Merge pull request #864 from crazywhalecc/swoolehooks
swoole hooks can be compiled if pgsql/sqlite are not compiled in statically
2025-08-29 03:46:30 +02:00
crazywhalecc
0f0050115c Update cli generator, add frankenphp SAPI, add copy-to-clipboard func 2025-08-28 22:35:51 +08:00
crazywhalecc
bf55db959e Add swoole-hook-odbc notes 2025-08-28 22:35:23 +08:00
DubbleClick
39a9840d49 why is phpstan so stupid about this constant? 2025-08-28 12:14:26 +07:00
DubbleClick
866ca264d9 only disable it for x86_64 2025-08-28 11:35:46 +07:00
DubbleClick
f18725083a disable opcache jit automatically on alpine target (only required for php < 8.5) 2025-08-28 11:32:33 +07:00
crazywhalecc
20fbbb1dbe test 2025-08-28 11:01:58 +08:00
crazywhalecc
1a7bf2d070 test 2025-08-28 10:49:02 +08:00
crazywhalecc
fc7e8ebc53 extension test 2025-08-28 10:29:22 +08:00
crazywhalecc
532360886e Merge branch 'main' into swoolehooks 2025-08-28 10:29:07 +08:00
crazywhalecc
117a54d077 extension test 2025-08-28 10:14:47 +08:00
DubbleClick
f2c131a2cc wno-int-conversion 2025-08-27 17:01:07 +07:00
DubbleClick
6f0310e8f7 cs fix 2025-08-27 16:46:58 +07:00
DubbleClick
c7141003db oops 2025-08-27 16:46:09 +07:00
DubbleClick
d32bdb2825 all env vars 2025-08-27 16:45:47 +07:00
DubbleClick
a66abfa583 test all OS 2025-08-27 16:35:24 +07:00
DubbleClick
2551772de4 use system cc 2025-08-27 16:34:29 +07:00
DubbleClick
25fe794acc trim all items 2025-08-27 14:36:05 +07:00
DubbleClick
694fd2f1e0 turn pkg-config into a package instead of a library 2025-08-27 14:33:39 +07:00
DubbleClick
5a4b920ae2 pkg-config patch 2025-08-27 13:04:08 +07:00
DubbleClick
95f1b65bca fix perl installation by checking for FindBin 2025-08-27 13:03:57 +07:00
DubbleClick
25401e5959 cs fix 2025-08-27 12:43:48 +07:00
DubbleClick
3da58d5c24 filter micro patches to not be '' 2025-08-27 11:48:59 +07:00
DubbleClick
08ab3c17d6 fix perl-IPC-Cmd check so it doesn't try installing it every time 2025-08-27 11:40:06 +07:00
DubbleClick
ecdb94b429 suggestions 2025-08-27 08:31:48 +07:00
DubbleClick
00892c20fa fix odbc libs when iconv is built too 2025-08-26 20:44:30 +07:00
DubbleClick
c433aed521 fix macos? 2025-08-26 19:35:10 +07:00
DubbleClick
1243fb9678 don't test macos as it just fails either way, add odbc test 2025-08-26 18:55:22 +07:00
DubbleClick
d9c2247f99 fix alpine realpath -s issue 2025-08-26 18:16:44 +07:00
DubbleClick
0d4d4283d1 only install library for liburing 2025-08-26 18:04:43 +07:00
DubbleClick
effefd4844 string 2025-08-26 14:51:07 +07:00
DubbleClick
2d409db2f9 we don't need a min glibc version, just don't use --use-libc! 2025-08-26 14:42:34 +07:00
DubbleClick
00f262571c cs fix 2025-08-26 14:08:09 +07:00
DubbleClick
4eac953c71 ensure liburing is only pulled in by suggested libs when glibc >= 2.30 (or musl) 2025-08-26 14:07:49 +07:00
DubbleClick
43352ab986 don't print repeated --ri swoole check 2025-08-26 01:01:45 +07:00
DubbleClick
9803bf6c3f prevent warning message from addons 2025-08-26 00:59:54 +07:00
DubbleClick
ba326973e5 prevent infinite recursion if ext suggests addons that depend on the extension 2025-08-26 00:56:57 +07:00
DubbleClick
a1f2126c00 update comments 2025-08-26 00:38:35 +07:00
DubbleClick
b1da64d46b add swoole-hook-odbc to work the same way as the other hooks 2025-08-26 00:24:40 +07:00
DubbleClick
2694dd9e21 add liburing for swoole 2025-08-25 22:57:04 +07:00
Marc
37e0f1d3f3 Update src/SPC/command/BuildPHPCommand.php 2025-08-25 19:50:41 +07:00
DubbleClick
f80aee5133 get rid of $rt 2025-08-25 19:31:15 +07:00
DubbleClick
65ee7479ac suggestion and clean up frankenphp build 2025-08-25 19:29:10 +07:00
DubbleClick
868f6d408b only feed -lgcov to the go driver 2025-08-25 18:44:03 +07:00
DubbleClick
efdfbf437a use format string 2025-08-25 18:23:04 +07:00
DubbleClick
2b57bca55c remove useless import 2025-08-25 15:30:04 +07:00
DubbleClick
99ccbf8a40 @crazywhalecc please look what's wrong with macos 2025-08-25 15:28:53 +07:00
DubbleClick
9fe322375f use 8.4 for tests only 2025-08-25 14:55:30 +07:00
DubbleClick
d13e369994 test swoole 2025-08-25 13:11:40 +07:00
DubbleClick
a46ad7b81e cs fix 2025-08-25 12:58:12 +07:00
DubbleClick
324ba0d3dc use type=addon and arg-type=none 2025-08-25 12:57:49 +07:00
DubbleClick
1c7fa0132d remove space 2025-08-25 12:44:34 +07:00
DubbleClick
93223a9d44 too much pgo, too little pdo 2025-08-25 12:43:21 +07:00
DubbleClick
b6d4af218b zts -> --enable-swoole-thread 2025-08-25 12:42:36 +07:00
DubbleClick
448941f741 don't request configurearg if it's not used (ease debugging) 2025-08-25 12:36:10 +07:00
DubbleClick
7e0e9091be explicitly enable swoole-mysql too 2025-08-25 12:11:56 +07:00
DubbleClick
8104ff7236 update checks for shared swoole-hook extensions 2025-08-25 12:08:53 +07:00
DubbleClick
75f734daa8 cs fix 2025-08-25 11:22:35 +07:00
DubbleClick
779a724875 go's gcc driver is the dumbest shit to ever exist 2025-08-25 11:21:08 +07:00
DubbleClick
e975e151f9 swoole hooks can be compiled if pgsql/sqlite are not compiled in statically 2025-08-25 11:09:02 +07:00
Marc
a5351e1546 Merge pull request #863 from crazywhalecc/brotli-watcher
fix gcc version detection
2025-08-25 05:32:46 +02:00
DubbleClick
af90b840ee format string 2025-08-25 09:59:27 +07:00
DubbleClick
2558c02470 oopsie 2025-08-25 09:59:06 +07:00
DubbleClick
df60ccff0e also make sure clang version uses dots 2025-08-25 09:52:03 +07:00
DubbleClick
2ed8bbf391 add cflags and ldflags to frankenphp build 2025-08-25 09:29:19 +07:00
DubbleClick
ef3025798d fix gcc compiler version 2025-08-25 09:29:06 +07:00
Marc
bea3bd8392 Merge pull request #861 from crazywhalecc/fix/macos-ar
Add macOS AR and LD
2025-08-22 07:23:49 +02:00
crazywhalecc
99e8900aba Add macOS AR and LD 2025-08-22 13:19:42 +08:00
Marc
1c4a6ca02e Merge pull request #860 from crazywhalecc/brotli-watcher
add brotli and watcher to lib-suggests
2025-08-21 15:31:35 +02:00
DubbleClick
b5fa7be53f add brotli and watcher to lib-suggests 2025-08-20 13:40:54 +07:00
Marc
3804e842bb Merge pull request #858 from crazywhalecc/fix/imagick
imagick needs static libstdc++ on gcc-toolset (successor of devtoolse) too
2025-08-20 07:56:08 +02:00
DubbleClick
e6832ecf61 add msgpack suggestion 2025-08-19 20:15:41 +07:00
DubbleClick
ed3e29bade devtoolset any version 2025-08-19 20:03:16 +07:00
DubbleClick
811aeb58ea imagick needs static libstdc++ on gcc-toolset (successor of devtoolset) too 2025-08-19 20:01:10 +07:00
Marc
6b5aaa38ae Merge pull request #857 from crazywhalecc/fix/lstdcpp
move -lstdc++ to the end of the libraries
2025-08-19 10:51:28 +02:00
DubbleClick
4e9545262d finish the redis thingy from the year long open PR 2025-08-19 10:42:30 +07:00
DubbleClick
d48c84d81b move -lstdc++ to the end of the libraries 2025-08-19 10:27:52 +07:00
Jerry Ma
cbddb2652d Merge pull request #856 from crazywhalecc/fix/windows-cmd
Fix WindowsCmd execution, use popen instead of proc_open
2025-08-18 12:07:09 +08:00
Jerry Ma
5f629253ac Merge pull request #853 from crazywhalecc/fix/exception-reflection
Enhance exception handling by binding builder and extra info to exception handler
2025-08-16 19:33:13 +08:00
crazywhalecc
8d84a95c01 Fix WindowsCmd execution, use popen instead of proc_open 2025-08-16 17:54:24 +08:00
crazywhalecc
2cabaf6402 8.5 extension test 2025-08-15 13:19:14 +08:00
crazywhalecc
ad25ac49b8 Update to beta1, extension test 2025-08-15 12:28:26 +08:00
crazywhalecc
d0412a88df Use PatchException instead of ExecutionException for patchFile 2025-08-15 12:04:06 +08:00
crazywhalecc
a3ae1eb2f0 Remove redundant builer options 2025-08-15 11:54:34 +08:00
crazywhalecc
2e616af836 PHPStan fix 2025-08-11 13:32:59 +08:00
Jerry Ma
4fd8afcee4 Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:30:10 +08:00
Jerry Ma
e96b4f5541 Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:30:04 +08:00
Jerry Ma
9978a56b1e Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:59 +08:00
Jerry Ma
d3a5be13ea Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:54 +08:00
Jerry Ma
5ba0de12eb Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:48 +08:00
Jerry Ma
a73c097c94 Update src/SPC/command/BuildPHPCommand.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:42 +08:00
Jerry Ma
d3840b19fa Update src/SPC/builder/BuilderProvider.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:36 +08:00
crazywhalecc
b34b6594de Suggestions 2025-08-11 12:05:41 +08:00
crazywhalecc
2fba61e9bd Enhance exception handling by binding builder and extra info to ExceptionHandler 2025-08-11 10:48:48 +08:00
crazywhalecc
1e9434221b Remove spc.env.log due to potential secret leaks 2025-08-07 16:25:01 +08:00
crazywhalecc
afd6791075 Fix phpunit 2025-08-07 13:09:18 +08:00
crazywhalecc
b3b53b6b4d Use latest version of logger 2025-08-07 13:09:18 +08:00
crazywhalecc
b8b8cf6ea9 Update version to 2.7.2 2025-08-07 13:09:18 +08:00
crazywhalecc
9a340e1ad8 Update docs, GitHub issue templates, workflows 2025-08-07 13:09:18 +08:00
crazywhalecc
29dc5e4ea7 Chore 2025-08-07 13:09:18 +08:00
crazywhalecc
08fa49b791 Remove craft.log 2025-08-07 13:09:18 +08:00
crazywhalecc
333b776e77 Refactor all command class exception handling 2025-08-07 13:09:18 +08:00
crazywhalecc
f68f060be2 Refactor all (except command) modules using new exceptions 2025-08-07 13:09:18 +08:00
crazywhalecc
722bb31815 Introduce AttributeMapper for managing extensions and doctor attributes 2025-08-07 13:09:18 +08:00
crazywhalecc
e28580de00 Refactor shell utilities: reorganize namespaces and introduce Shell base class 2025-08-07 13:09:18 +08:00
crazywhalecc
cc447a089a Refactor all exception classes, remove unclear RuntimeException, InvalidArgumentException 2025-08-07 13:09:18 +08:00
crazywhalecc
0c9a30256e Remove all @throws PHPDoc, it's almost useless for SPC anymore 2025-08-07 13:09:18 +08:00
Jerry Ma
fa10142f13 Merge pull request #847 from crazywhalecc/fix/spc-exe
Fix spc build actions version, add spc validation
2025-08-06 01:03:38 +08:00
Jerry Ma
c342741670 Update version to 2.7.1 2025-08-05 23:13:19 +08:00
Jerry Ma
64d49003e0 Update release-build.yml 2025-08-05 21:26:35 +08:00
crazywhalecc
b0c93c7418 Fix spc build actions version, add spc validation 2025-08-05 18:59:30 +08:00
262 changed files with 8175 additions and 5540 deletions

View File

@@ -10,6 +10,7 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
indent_size = 2
[*.{yml,yaml, vue}]
[*.{yml,yaml,vue,ts}]
indent_size = 2

View File

@@ -3,6 +3,15 @@ name: Bug report
about: Build PHP or library failed, download failed, doesn't seem to work...
title: ''
labels: bug
assignees: crazywhalecc
body:
- type: textarea
id: what-happened
attributes:
label: What happened?
description: |
Please tell us what you do, what you get and what you expected.
Provide with some step-by-step instructions to reproduce the issue.
If possible, attach a screenshot or log files in ./log directory.
validations:
required: true
---

View File

@@ -3,6 +3,6 @@ name: Feature request
about: Suggest an idea for this project
title: ''
labels: new feature
assignees: ''
assignees: crazywhalecc
---

View File

@@ -136,12 +136,12 @@ jobs:
macos-x86_64)
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
BUILD_CMD="./bin/spc build"
RUNS_ON="macos-13"
RUNS_ON="macos-15-intel"
;;
macos-aarch64)
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
BUILD_CMD="./bin/spc build"
RUNS_ON="macos-14"
RUNS_ON="macos-15"
;;
esac
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"

View File

@@ -65,7 +65,7 @@ jobs:
- sqlsrv
- ssh2
- swoole
- swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite
- swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite,swoole-hook-odbc
- swow
- sysvmsg,sysvsem,sysvshm
- tidy
@@ -82,12 +82,12 @@ jobs:
- zlib
- zstd
php-version:
- "git"
- "8.4"
operating-system:
- "ubuntu-latest"
#- "macos-13"
#- "macos-15-intel"
#- "debian-arm64-self-hosted"
- "macos-14"
- "macos-15"
steps:
- name: "Checkout"
@@ -99,11 +99,11 @@ jobs:
OS=""
if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then
OS="linux-x86_64"
elif [ "${{ matrix.operating-system }}" = "macos-13" ]; then
elif [ "${{ matrix.operating-system }}" = "macos-15-intel" ]; then
OS="macos-x86_64"
elif [ "${{ matrix.operating-system }}" = "debian-arm64-self-hosted" ]; then
OS="linux-aarch64"
elif [ "${{ matrix.operating-system }}" = "macos-14" ]; then
elif [ "${{ matrix.operating-system }}" = "macos-15" ]; then
OS="macos-aarch64"
fi
echo "OS=$OS" >> $GITHUB_ENV

View File

@@ -3,6 +3,10 @@ name: Build SPC Binary
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/release-build.yml'
release:
types:
- published
@@ -10,7 +14,7 @@ on:
env:
PHP_VERSION: 8.4
MICRO_VERSION: 8.4.10
MICRO_VERSION: 8.4.11
jobs:
build-release-artifacts:
@@ -23,7 +27,7 @@ jobs:
os: "ubuntu-latest"
filename: "spc-linux-x86_64.tar.gz"
- name: "macos-x86_64"
os: "macos-13"
os: "macos-15-intel"
filename: "spc-macos-x86_64.tar.gz"
- name: "linux-aarch64"
os: "ubuntu-latest"
@@ -117,7 +121,8 @@ jobs:
files: dist/${{ matrix.operating-system.filename }}
- name: "Deploy to self-hosted OSS"
if: github.repository == 'crazywhalecc/static-php-cli'
# only run this step if the repository is static-php-cli and the branch is main
if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main'
uses: static-php/upload-s3-action@v1.0.0
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
@@ -132,3 +137,39 @@ jobs:
with:
path: spc${{ env.SUFFIX }}
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
test-spc:
name: "Test SPC Binary for ${{ matrix.operating-system.name }}"
runs-on: ${{ matrix.operating-system.os }}
needs: [build-release-artifacts]
strategy:
matrix:
operating-system:
- name: "linux-x86_64"
os: "ubuntu-latest"
- name: "macos-x86_64"
os: "macos-15-intel"
- name: "linux-aarch64"
os: "ubuntu-24.04-arm"
- name: "macos-aarch64"
os: "macos-15"
- name: "windows-x64"
os: "windows-latest"
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Download Artifact"
uses: actions/download-artifact@v4
env:
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
with:
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
- name: "Chmod"
if: matrix.operating-system.name != 'windows-x64'
run: chmod +x spc
- name: "Run SPC Tests"
env:
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
run: ./spc${{ env.SUFFIX }} dev:extensions

View File

@@ -1,13 +1,9 @@
name: Tests
on:
push:
branches:
- main
paths:
- 'src/globals/test-extensions.php'
pull_request:
branches: [ "main" ]
types: [ opened, synchronize, reopened ]
paths:
- 'src/**'
- 'config/**'
@@ -179,7 +175,7 @@ jobs:
key: php-dependencies-${{ matrix.os }}
- name: "Install Dependencies"
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
run: composer update -vvv --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-plugins
- name: "Run Build Tests (doctor)"
run: php src/globals/test-extensions.php doctor_cmd ${{ matrix.os }} ${{ matrix.php }}
@@ -206,6 +202,13 @@ jobs:
if: ${{ !startsWith(matrix.os, 'windows-') }}
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: "Upload logs"
if: ${{ always() && hashFiles('log/**') != '' }}
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ matrix.os }}-${{ matrix.php }}
path: log
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3

View File

@@ -21,7 +21,6 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- run: yarn install --frozen-lockfile

14
.gitignore vendored
View File

@@ -22,6 +22,9 @@ docker/source/
# default package root directory
/pkgroot/**
# Windows PHP SDK binary tools
/php-sdk-binary-tools/**
# default pack:lib and release directory
/dist/**
packlib_files.txt
@@ -34,6 +37,7 @@ packlib_files.txt
/bin/*
!/bin/spc*
!/bin/setup-runtime*
!/bin/docker-entrypoint.sh
# exclude windows build tools
/php-sdk-binary-tools/
@@ -48,6 +52,12 @@ packlib_files.txt
package-lock.json
pnpm-lock.yaml
# craft.log
craft.log
# craft
craft.yml
# SPC logs
log/
# spc.phar
spc.phar
spc.exe

View File

@@ -5,309 +5,168 @@
[![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases)
[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
[![Extensions](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)](https://static-php.dev/zh/guide/extensions.html)
**static-php-cli**是一个用于静态编译、构建 PHP 解释器的工具,支持众多流行扩展。
目前 static-php-cli 支持 `cli``fpm``embed``micro``frankenphp` SAPI。
**static-php-cli**也支持将 PHP 代码和 PHP 运行时打包为一个文件并运行。
**static-php-cli** 是一个用于构建静态、独立 PHP 运行时的强大工具,支持众多流行扩展。
## 特性
static-php-cli简称 `spc`)有许多特性:
- :elephant: **支持多 PHP 版本** - 支持 PHP 8.1, 8.2, 8.3, 8.4, 8.5
- :handbag: **单文件 PHP 可执行文件** - 构建零依赖的独立 PHP
- :hamburger: **phpmicro 集成** - 构建 **[phpmicro](https://github.com/dixyes/phpmicro)** 自解压可执行文件(将 PHP 二进制文件和源代码合并为一个文件)
- :pill: **智能环境检查器** - 自动构建环境检查器,具备自动修复功能
- :zap: **跨平台支持** - 支持 Linux、macOS、FreeBSD 和 Windows
- :wrench: **可配置补丁** - 可自定义的源代码补丁系统
- :books: **智能依赖管理** - 自动处理构建依赖
- 📦 **自包含工具** - 提供使用 [box](https://github.com/box-project/box) 构建的 `spc` 可执行文件
- :fire: **广泛的扩展支持** - 支持 75+ 流行 [扩展](https://static-php.dev/zh/guide/extensions.html)
- :floppy_disk: **UPX 压缩** - 减小二进制文件大小 30-50%(仅 Linux/Windows
- :handbag: 构建独立的单文件 PHP 解释器,无需任何依赖
- :hamburger: 构建 **[phpmicro](https://github.com/dixyes/phpmicro)** 自执行二进制(将 PHP 代码和 PHP 解释器打包为一个文件)
- :pill: 提供一键检查和修复编译环境的 Doctor 模块
- :zap: 支持多个系统:`Linux``macOS``FreeBSD``Windows`
- :wrench: 高度自定义的代码 patch 功能
- :books: 自带编译依赖管理
- 📦 提供由自身编译的独立 `spc` 二进制(使用 spc 和 [box](https://github.com/box-project/box) 构建)
- :fire: 支持大量 [扩展](https://static-php.dev/zh/guide/extensions.html)
- :floppy_disk: 整合 UPX 工具(减小二进制文件体积)
**静态 php-cli:**
**单文件独立 php-cli**
<img width="700" alt="out1" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/01a2e60f-13b0-4242-a645-f7afa4936396">
**使用 phpmicro 打包 PHP 代码:**
**使用 phpmicro PHP 代码与 PHP 解释器结合:**
<img width="700" alt="out2" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/46b7128d-fb72-4169-957e-48564c3ff3e2">
## 文档
## 快速开始
目前 README 编写了基本用法。有关 static-php-cli 所有的功能,请点击这里查看文档:<https://static-php.dev>。
## 直接下载
如果你不想自行编译 PHP可以从本项目现有的示例 Action 下载 Artifact也可以从自托管的服务器下载。
| 组合名称 | 组合扩展数 | 系统 | 备注 |
|---------------------------------------------------------------------|----------------------------------------------------------------------------|-------------|--------------|
| [common](https://dl.static-php.dev/static-php-cli/common/) | [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) | Linux/macOS | 体积为 7.5MB 左右 |
| [bulk](https://dl.static-php.dev/static-php-cli/bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux/macOS | 体积为 25MB 左右 |
| [minimal](https://dl.static-php.dev/static-php-cli/minimal/) | [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) | Linux/macOS | 体积为 3MB 左右 |
| [spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min) | [5](https://dl.static-php.dev/static-php-cli/windows/spc-min/README.txt) | Windows | 体积为 3MB 左右 |
| [spc-max](https://dl.static-php.dev/static-php-cli/windows/spc-max) | [40+](https://dl.static-php.dev/static-php-cli/windows/spc-max/README.txt) | Windows | 体积为 8.5MB 左右 |
> Linux 和 Windows 默认启用了 UPX 压缩,可减小 30~50% 的 PHP 二进制体积。
> macOS 当前不支持 UPX所以上述预编译的 macOS 版本体积可能较大。
## 使用 static-php-cli 构建 PHP
### 编译环境需求
- PHP >= 8.4(这是 spc 自身需要的版本,不是支持的构建版本)
- 扩展:`mbstring,tokenizer,phar`
- 系统安装了 `curl``git`
是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。
但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含上面提到的扩展和 PHP 版本大于等于 8.1 即可。
下面是架构支持情况,:octocat: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。
| | x86_64 | aarch64 |
|---------|----------------------|----------------------|
| macOS | :octocat: :computer: | :octocat: :computer: |
| Linux | :octocat: :computer: | :octocat: :computer: |
| Windows | :octocat: :computer: | |
| FreeBSD | :computer: | :computer: |
当前支持编译的 PHP 版本:
> :warning: 部分支持,对于新的测试版和旧版本可能存在问题。
>
> :heavy_check_mark: 支持
>
> :x: 不支持
| PHP Version | Status | Comment |
|-------------|--------------------|---------------------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 7.4 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 8.0 | :warning: | PHP 官方已停止 8.0 的维护,我们不再处理 8.0 相关的 backport 支持 |
| 8.1 | :heavy_check_mark: | PHP 官方仅对 8.1 提供安全更新,在 8.5 发布后我们不再处理 8.1 相关的 backport 支持 |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
| 8.5 (alpha) | :warning: | PHP 8.5 目前处于 alpha 阶段 |
> 这个表格的支持状态是 static-php-cli 对构建对应版本的支持情况,不是 PHP 官方对该版本的支持情况。
### 支持的扩展
请先根据下方扩展列表选择你要编译的扩展。
- [扩展支持列表](https://static-php.dev/zh/guide/extensions.html)
- [编译命令生成器](https://static-php.dev/zh/guide/cli-generator.html)
> 如果这里没有你需要的扩展,可以提交 Issue。
### 在线构建(使用 GitHub Actions
使用 GitHub Action 可以方便地构建一个静态编译的 PHP同时可以自行定义要编译的扩展。
1. Fork 本项目。
2. 进入项目的 Actions选择 CI。
3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`
4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`
如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。
### 本地构建(使用 spc 二进制,推荐)
该项目提供了 static-php-cli 的二进制文件:`spc`
您可以使用 `spc` 二进制文件,无需安装任何运行时(用起来就像 golang 程序)。
目前,`spc` 二进制文件提供的平台有 Linux 和 macOS。
使用以下命令从自托管服务器下载:
### 1. 下载 spc 二进制文件
```bash
# Download from self-hosted nightly builds (sync with main branch)
# For Linux x86_64
# Linux x86_64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
# For Linux aarch64
# Linux aarch64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64
# macOS x86_64 (Intel)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
# macOS aarch64 (Apple)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
# Windows (x86_64, win10 build 17063 or later)
# Windows (x86_64, win10 build 17063 或更高版本,请先安装 VS2022)
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
```
# Add execute perm (Linux and macOS only)
对于 macOS 和 Linux请先添加执行权限
```bash
chmod +x ./spc
# Run (Linux and macOS)
./spc --version
# Run (Windows powershell)
.\spc.exe --version
```
自托管 `spc` 由 GitHub Actions 构建,你也可以从 Actions 直接下载:[此处](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。
### 2. 构建静态 PHP
### 本地构建(使用 git 源码)
首先,创建一个 `craft.yml` 文件,并从 [扩展列表](https://static-php.dev/zh/guide/extensions.html) 或 [命令生成器](https://static-php.dev/zh/guide/cli-generator.html) 中指定要包含的扩展:
如果你需要修改 static-php-cli 源码,或者使用 spc 二进制构建有问题,你可以使用 git 源码下载 static-php-cli。
```yml
# PHP 版本支持8.1, 8.2, 8.3, 8.4, 8.5
php-version: 8.4
# 在此处放置您的扩展列表
extensions: "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib"
sapi:
- cli
- micro
- fpm
download-options:
prefer-pre-built: true
```
运行命令:
```bash
# clone 仓库即可
git clone https://github.com/crazywhalecc/static-php-cli.git
./spc craft
# 输出完整控制台日志
./spc craft --debug
```
如果您的系统上尚未安装 php我们建议你使用内置的 setup-runtime 自动安装 PHP 和 Composer。
### 3. 静态 PHP 使用
```bash
cd static-php-cli
chmod +x bin/setup-runtime
# it will download static php (from self-hosted server) and composer (from getcomposer)
bin/setup-runtime
# initialize composer deps
bin/composer install
# chmod
chmod +x bin/spc
bin/spc --version
现在您可以将 static-php-cli 构建的二进制文件复制到另一台机器上,无需依赖即可运行:
```
# php-cli
buildroot/bin/php -v
# phpmicro
echo '<?php echo "Hello world!\n";' > a.php
./spc micro:combine a.php -O my-app
./my-app
# php-fpm
buildroot/bin/php-fpm -v
```
### 开始构建 PHP
## 文档
下面是使用 static-php-cli 的基础用法:
当前 README 包含基本用法。有关 static-php-cli 的所有功能,
请访问 <https://static-php.dev>。
> 如果你使用的是打包好的 `spc` 二进制,你需要将下列命令的 `./bin/spc` 替换为 `./spc`。
## 直接下载
```bash
# 检查环境依赖,并根据尝试自动安装缺失的编译工具
./bin/spc doctor --auto-fix
如果您不想构建或想先测试,可以从 [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-bulk.yml) 下载示例预编译工件,或从自托管服务器下载。
# 输出目标项目依赖的扩展列表
./bin/spc dump-extensions /path/to/your/project --format=text
以下是几个具有不同扩展组合的预编译静态 PHP 二进制文件,
您可以根据需要直接下载。
# 拉取所有依赖库
./bin/spc download --all
# 只拉取编译指定扩展需要的所有依赖(推荐)
./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite"
# 下载依赖时,优先下载有预编译的库(节省编译依赖的时间)
./bin/spc download --for-extensions="openssl,curl,mbstring,mbregex" --prefer-pre-built
# 下载编译不同版本的 PHP (--with-php=x.y 或 --with-php=x.y.z推荐 8.1 ~ 8.3)
./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1
| 组合名称 | 扩展数量 | 系统 | 备注 |
|----------------------------------------------------------------------|----------------------------------------------------------------------------|--------------|--------------------|
| [common](https://dl.static-php.dev/static-php-cli/common/) | [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) | Linux, macOS | 二进制文件大小约为 7.5MB |
| [bulk](https://dl.static-php.dev/static-php-cli/bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux, macOS | 二进制文件大小约为 25MB |
| [gnu-bulk](https://dl.static-php.dev/static-php-cli/gnu-bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux, macOS | 使用 glibc 的 bulk 组合 |
| [minimal](https://dl.static-php.dev/static-php-cli/minimal/) | [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) | Linux, macOS | 二进制文件大小约为 3MB |
| [spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/) | [5](https://dl.static-php.dev/static-php-cli/windows/spc-min/README.txt) | Windows | 二进制文件大小约为 3MB |
| [spc-max](https://dl.static-php.dev/static-php-cli/windows/spc-max/) | [40+](https://dl.static-php.dev/static-php-cli/windows/spc-max/README.txt) | Windows | 二进制文件大小约为 8.5MB |
# 构建包含 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
# 编译线程安全版本 (--enable-zts)
./bin/spc build "curl,phar" --enable-zts --build-cli
# 编译后使用 UPX 减小可执行文件体积 (仅 Linux、Windows 可用) (至少压缩至原来的 30~50%)
./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack
```
> Linux 和 Windows 支持对二进制文件进行 UPX 压缩,可以将二进制文件大小减少 30% 到 50%。
> macOS 不支持 UPX 压缩,因此 mac 的预构建二进制文件大小较大。
其中,目前支持构建 climicrofpm 和 embed使用以下参数的一个或多个来指定编译的 SAPI
### 在线构建(使用 GitHub Actions
- `--build-cli`:构建 cli 二进制
- `--build-micro`:构建 phpmicro 自执行二进制
- `--build-fpm`:构建 fpm
- `--build-embed`:构建 embedlibphp
- `--build-all`:构建所有
上方直接下载的二进制不能满足需求时,可使用 GitHub Action 可以轻松构建静态编译的 PHP
同时自行定义要编译的扩展。
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
1. Fork 本项目。
2. 进入项目的 Actions 并选择 `CI`
3. 选择 `Run workflow`,填入您要编译的 PHP 版本、目标类型和扩展列表。(扩展用逗号分隔,例如 `bcmath,curl,mbstring`
4. 等待一段时间后,进入相应的任务并获取 `Artifacts`
```bash
./bin/spc build "openssl,pcntl,mbstring" --debug --build-all
./bin/spc download --all --debug
```
## 不同 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/php/frankenphp/blob/main/docs/static.md)。
如果您启用 `debug`,构建时将输出所有日志,包括编译日志,以便故障排除。
## 贡献
如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉也欢迎为本项目发起 Pull Request
如果需要的扩展缺失,可以创建 issue
如果您熟悉本项目,也欢迎发起 pull request。
另外,添加新扩展的贡献方式,可以参考下方 `进阶`
如果您想贡献文档,请直接编辑 `docs/` 目录
如果你想贡献文档内容,请直接修改 `docs/` 目录
现在有一个 [static-php](https://github.com/static-php) 组织,用于存储与项目相关的仓库
## 赞助本项目
可以 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。捐赠的一部分将会被用于维护 **static-php.dev** 服务器。
可以 [GitHub Sponsor](https://github.com/crazywhalecc) 赞助我或我的项目。捐赠的一部分将用于维护 **static-php.dev** 服务器。
**特别赞助商**:
**特别感谢以下赞助商**
<a href="https://beyondco.de/"><img src="/docs/public/images/beyondcode-seeklogo.png" width="300" alt="Beyond Code Logo" /></a>
<a href="https://nativephp.com/"><img src="/docs/public/images/nativephp-logo.svg" width="300" alt="NativePHP Logo" /></a>
## 开源协议
## 开源许可证
本项目采用 MIT License 许可开源,下面是类似的项目:
本项目本身基于 MIT 许可证,
一些新添加的扩展和依赖可能来自其他项目,
这些代码文件的头部也会给出额外的许可证和作者说明。
这些是类似的项目:
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)
项目使用了 [dixyes/lwmbs](https://github.com/dixyes/lwmbs) 的一些代码,例如 Windows 静态构建目标和 libiconv 支持。
lwmbs 使用 [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2) 许可进行分发。对应文件有关于作者和许可的特殊说明,除此之外,均使用 MIT 授权许可
项目使用了 [dixyes/lwmbs](https://github.com/dixyes/lwmbs) 的一些代码,例如 Windows 静态构建目标和 libiconv 支持。
lwmbs 基于 [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2) 许可
本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。
请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。
由于本项目的特殊性,
项目编译过程中会使用许多其他开源项目,如 curl 和 protobuf
它们都有自己的开源许可证。
请在编译后使用 `bin/spc dump-license` 命令导出项目中使用的开源许可证,
并遵守相应项目的 LICENSE。

328
README.md
View File

@@ -5,29 +5,22 @@
[![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases)
[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
[![Extensions](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)](https://static-php.dev/en/guide/extensions.html)
**static-php-cli** is a powerful tool designed for building static, standalone PHP runtime
with popular extensions.
Static PHP built by **static-php-cli** supports `cli`, `fpm`, `embed`, `micro` and `frankenphp` SAPI.
**static-php-cli** also has the ability to package PHP projects
along with the PHP interpreter into one single executable file.
## Features
static-php-cli (you can call it `spc`) has a lot of features:
- :handbag: Build single-file php executable, without any dependencies
- :hamburger: Build **[phpmicro](https://github.com/dixyes/phpmicro)** self-extracted executable (glue php binary and php source code into one file)
- :pill: Automatic build environment checker (Doctor module)
- :elephant: Support multiple PHP versions - PHP 8.1, 8.2, 8.3, 8.4, 8.5
- :handbag: Build single-file PHP executable with zero dependencies
- :hamburger:Build **[phpmicro](https://github.com/dixyes/phpmicro)** self-extracting executables (combines PHP binary and source code into one file)
- :pill: Automatic build environment checker with auto-fix capabilities
- :zap: `Linux`, `macOS`, `FreeBSD`, `Windows` support
- :wrench: Configurable source code patches
- :books: Build dependency management
- 📦 Provide `spc` own standalone executable (built by spc and [box](https://github.com/box-project/box))
- :fire: Support many popular [extensions](https://static-php.dev/en/guide/extensions.html)
- :floppy_disk: UPX integration (significantly reduces binary size)
- :wrench: Configurable source code patching
- :books: Intelligent dependency management
- 📦 Self-contained `spc` executable (built with [box](https://github.com/box-project/box))
- :fire: Support 100+ popular [extensions](https://static-php.dev/en/guide/extensions.html)
- :floppy_disk: UPX compression support (reduces binary size by 30-50%)
**Single-file standalone php-cli:**
@@ -37,6 +30,72 @@ static-php-cli (you can call it `spc`) has a lot of features:
<img width="700" alt="out2" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/46b7128d-fb72-4169-957e-48564c3ff3e2">
## Quickstart
### 1. Download spc binary
```bash
# For Linux x86_64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
# For Linux aarch64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64
# macOS x86_64 (Intel)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
# macOS aarch64 (Apple)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
# Windows (x86_64, win10 build 17063 or later, please install VS2022 first)
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
```
For macOS and Linux, add execute permission first:
```bash
chmod +x ./spc
```
### 2. Build Static PHP
First, create a `craft.yml` file and specify which extensions you want to include from [extension list](https://static-php.dev/en/guide/extensions.html) or [command generator](https://static-php.dev/en/guide/cli-generator.html):
```yml
# PHP version support: 8.1, 8.2, 8.3, 8.4, 8.5
php-version: 8.4
# Put your extension list here
extensions: "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib"
sapi:
- cli
- micro
- fpm
download-options:
prefer-pre-built: true
```
Run command:
```bash
./spc craft
# Output full console log
./spc craft --debug
```
### 3. Static PHP usage
Now you can copy binaries built by static-php-cli to another machine and run with no dependencies:
```
# php-cli
buildroot/bin/php -v
# phpmicro
echo '<?php echo "Hello world!\n";' > a.php
./spc micro:combine a.php -O my-app
./my-app
# php-fpm
buildroot/bin/php-fpm -v
```
## Documentation
The current README contains basic usage. For all the features of static-php-cli,
@@ -53,6 +112,7 @@ which can be downloaded directly according to your needs.
|----------------------------------------------------------------------|----------------------------------------------------------------------------|--------------|--------------------------------|
| [common](https://dl.static-php.dev/static-php-cli/common/) | [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) | Linux, macOS | The binary size is about 7.5MB |
| [bulk](https://dl.static-php.dev/static-php-cli/bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux, macOS | The binary size is about 25MB |
| [gnu-bulk](https://dl.static-php.dev/static-php-cli/gnu-bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux, macOS | Using shared glibc |
| [minimal](https://dl.static-php.dev/static-php-cli/minimal/) | [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) | Linux, macOS | The binary size is about 3MB |
| [spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/) | [5](https://dl.static-php.dev/static-php-cli/windows/spc-min/README.txt) | Windows | The binary size is about 3MB |
| [spc-max](https://dl.static-php.dev/static-php-cli/windows/spc-max/) | [40+](https://dl.static-php.dev/static-php-cli/windows/spc-max/README.txt) | Windows | The binary size is about 8.5MB |
@@ -60,64 +120,10 @@ which can be downloaded directly according to your needs.
> Linux and Windows supports UPX compression for binaries, which can reduce the size of the binary by 30% to 50%.
> macOS does not support UPX compression, so the size of the pre-built binaries for mac is larger.
## Build
### Compilation Requirements
You can say I made a PHP builder written in PHP, pretty funny.
But static-php-cli runtime only requires an environment above PHP 8.1 and extensions mentioned below.
- PHP >= 8.4 (This is the version required by spc itself, not the build version)
- Extension: `mbstring,tokenizer,phar`
- Supported OS with `curl` and `git` installed
Here is the supported OS and arch, 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: | :octocat: :computer: |
| Linux | :octocat: :computer: | :octocat: :computer: |
| Windows | :octocat: :computer: | |
| FreeBSD | :computer: | :computer: |
Currently supported PHP versions for compilation:
> :warning: Partial support, there may be issues with newer test versions or older versions.
>
> :heavy_check_mark: supported
>
> :x: not supported
| PHP Version | Status | Comment |
|-------------|--------------------|----------------------------------------------------------------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :x: | phpmicro and some extensions not supported on 7.x |
| 7.4 | :x: | phpmicro and some extensions not supported on 7.x |
| 8.0 | :warning: | PHP official has stopped maintenance of 8.0, we no longer provide backport support for version 8.0 |
| 8.1 | :heavy_check_mark: | PHP official has security fixes only, we no longer provide backport support when 8.5 released |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
| 8.5 (alpha) | :warning: | PHP 8.5 is in alpha |
> This table shows the support status for static-php-cli in building the corresponding version,
> not the official PHP support status for that version.
### 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) .
### Build Online (using GitHub Actions)
Use GitHub Action to easily build a statically compiled PHP,
When the above direct download binaries cannot meet your needs,
you can 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.
@@ -127,184 +133,6 @@ and at the same time define the extensions to be compiled by yourself.
If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting.
### Build Locally (using SPC binary, recommended)
This project provides a binary file of static-php-cli: `spc`.
You can use `spc` binary instead of installing any runtime like golang app.
Currently, the platforms supported by `spc` binary are Linux and macOS.
Download from self-hosted nightly builds using commands below:
```bash
# Download from self-hosted nightly builds (sync with main branch)
# For Linux x86_64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
# For Linux aarch64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64
# macOS x86_64 (Intel)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
# macOS aarch64 (Apple)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
# Windows (x86_64, win10 build 17063 or later)
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
# Add execute perm (Linux and macOS only)
chmod +x ./spc
# Run (Linux and macOS)
./spc --version
# Run (Windows powershell)
.\spc.exe --version
```
Self-hosted `spc` is built by GitHub Actions, you can also download from Actions artifacts [here](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml).
### Build Locally (using git source)
If you need to modify the static-php-cli source code, or have problems using the spc binary build,
you can download static-php-cli using the git source code.
```bash
# just clone me!
git clone https://github.com/crazywhalecc/static-php-cli.git
```
If you have not installed php on your system, we recommend that you use the built-in setup-runtime to install PHP and Composer automatically.
```bash
cd static-php-cli
chmod +x bin/setup-runtime
# it will download static php (from self-hosted server) and composer (from getcomposer)
bin/setup-runtime
# initialize composer deps
bin/composer install
# chmod
chmod +x bin/spc
bin/spc --version
```
### Start Building PHP
Basic usage for building php with some extensions:
> If you are using the packaged standalone `spc` binary, you need to replace `bin/spc` with `./spc` or `.\spc.exe` in the following commands.
```bash
# Check system tool dependencies, auto-fix them if possible
./bin/spc doctor --auto-fix
# fetch all libraries
./bin/spc download --all
# dump a list of extensions required by your project
./bin/spc dump-extensions /path/to/your/project --format=text
# only fetch necessary sources by needed extensions (recommended)
./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite"
# download pre-built libraries first (save time for compiling dependencies)
./bin/spc download --for-extensions="openssl,curl,mbstring,mbregex" --prefer-pre-built
# download different PHP version (--with-php=x.y or --with-php=x.y.z, recommend 8.3 ~ 8.4)
./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1
# 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
# build thread-safe (ZTS) version (--enable-zts)
./bin/spc build "curl,phar" --enable-zts --build-cli
# build, pack executable with UPX (linux and windows only) (reduce binary size for 30~50%)
./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack
```
Now we support `cli`, `micro`, `fpm` and `embed` SAPI. 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 download --all --debug
```
## 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
```
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
# 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
```
> In some cases, PHAR files may not run in a micro environment. Overall, micro is not production ready.
### Use fpm
When using the parameter `--build-all` or `--build-fpm`,
the final compilation result will output a file named `./php-fpm`,
This file will be located in the path `buildroot/bin/`, simply copy it out for use.
In 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.
Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`.
### Use embed
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.
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.
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/php/frankenphp/blob/main/docs/static.md).
## Contribution
If the extension you need is missing, you can create an issue.

11
bin/docker-entrypoint.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e
TARGET_DIR="/app/pkgroot/$(uname -m)-linux"
BACKUP_DIR="/app/pkgroot-private"
# copy private pkgroot to pkgroot if pkgroot is empty
if [ ! -d "$TARGET_DIR" ] || [ -z "$(ls -A "$TARGET_DIR")" ]; then
echo "* Copying private pkgroot to pkgroot ..."
rm -rf "$TARGET_DIR"
cp -r "$BACKUP_DIR" "$TARGET_DIR"
fi
exec "$@"

View File

@@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd)
__PROJECT__=$(cd "${__DIR__}"/../ && pwd)
# set download dir
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
# use china mirror
@@ -45,7 +45,7 @@ done
case "$mirror" in
china)
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://mirrors.tencent.com/composer/composer.phar"
;;

View File

@@ -3,7 +3,7 @@
set -e
# This file is using docker to run commands
SPC_DOCKER_VERSION=v5
SPC_DOCKER_VERSION=v6
# Detect docker can run
if ! which docker >/dev/null; then
@@ -122,6 +122,14 @@ ADD ./src /app/src
COPY ./composer.* /app/
ADD ./bin /app/bin
RUN composer install --no-dev
ADD ./config /app/config
RUN bin/spc doctor --auto-fix
RUN bin/spc install-pkg upx
RUN mv /app/pkgroot/\$(uname -m)-linux /app/pkgroot-private
ADD bin/docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod +x /bin/docker-entrypoint.sh
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
EOF
fi
@@ -142,6 +150,7 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/log:/app/log"
if [ -f "$(pwd)/craft.yml" ]; then
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
fi
@@ -153,6 +162,47 @@ if [ ! -z "$GITHUB_TOKEN" ]; then
ENV_LIST="$ENV_LIST -e GITHUB_TOKEN=$GITHUB_TOKEN"
fi
# Intercept and rewrite --with-frankenphp-app option, and mount host path to /app/app
FRANKENPHP_APP_PATH=""
NEW_ARGS=()
while [ $# -gt 0 ]; do
case "$1" in
--with-frankenphp-app=*)
FRANKENPHP_APP_PATH="${1#*=}"
NEW_ARGS+=("--with-frankenphp-app=/app/app")
shift
;;
--with-frankenphp-app)
if [ -n "${2:-}" ]; then
FRANKENPHP_APP_PATH="$2"
NEW_ARGS+=("--with-frankenphp-app=/app/app")
shift 2
else
NEW_ARGS+=("$1")
shift
fi
;;
*)
NEW_ARGS+=("$1")
shift
;;
esac
done
# Normalize the path and add mount if provided
if [ -n "$FRANKENPHP_APP_PATH" ]; then
# expand ~ to $HOME
if [ "${FRANKENPHP_APP_PATH#~}" != "$FRANKENPHP_APP_PATH" ]; then
FRANKENPHP_APP_PATH="$HOME${FRANKENPHP_APP_PATH#~}"
fi
# make absolute if relative
case "$FRANKENPHP_APP_PATH" in
/*) ABS_APP_PATH="$FRANKENPHP_APP_PATH" ;;
*) ABS_APP_PATH="$(pwd)/$FRANKENPHP_APP_PATH" ;;
esac
MOUNT_LIST="$MOUNT_LIST -v $ABS_APP_PATH:/app/app"
fi
# Run docker
# shellcheck disable=SC2068
# shellcheck disable=SC2086
@@ -174,5 +224,5 @@ if [ "$SPC_DOCKER_DEBUG" = "yes" ]; then
set -ex
$DOCKER_EXECUTABLE run $PLATFORM_ARG --rm $INTERACT $ENV_LIST $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION /bin/bash
else
$DOCKER_EXECUTABLE run $PLATFORM_ARG --rm $INTERACT $ENV_LIST $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION bin/spc $@
$DOCKER_EXECUTABLE run $PLATFORM_ARG --rm $INTERACT $ENV_LIST $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION bin/spc "${NEW_ARGS[@]}"
fi

View File

@@ -3,7 +3,7 @@
set -e
# This file is using docker to run commands
SPC_DOCKER_VERSION=v5
SPC_DOCKER_VERSION=v6
# Detect docker can run
if ! which docker >/dev/null; then
@@ -113,6 +113,7 @@ ENV PATH="/app/bin:/cmake/bin:/opt/rh/devtoolset-10/root/usr/bin:\$PATH"
ADD ./config /app/config
RUN CC=gcc bin/spc doctor --auto-fix --debug
RUN bin/spc install-pkg upx
RUN if [ -f /app/buildroot/bin/re2c ]; then \
cp /app/buildroot/bin/re2c /usr/local/bin/re2c ;\
fi
@@ -132,6 +133,11 @@ RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.ta
make && \
make install && \
ln -sf /usr/local/bin/automake /usr/bin/automake
RUN mv /app/pkgroot/\$(uname -m)-linux /app/pkgroot-private
ADD bin/docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod +x /bin/docker-entrypoint.sh
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
EOF
fi
@@ -152,6 +158,7 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/log:/app/log"
if [ -f "$(pwd)/craft.yml" ]; then
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
fi
@@ -167,6 +174,47 @@ if [ ! -z "$GITHUB_TOKEN" ]; then
ENV_LIST="$ENV_LIST -e GITHUB_TOKEN=$GITHUB_TOKEN"
fi
# Intercept and rewrite --with-frankenphp-app option, and mount host path to /app/app
FRANKENPHP_APP_PATH=""
NEW_ARGS=()
while [ $# -gt 0 ]; do
case "$1" in
--with-frankenphp-app=*)
FRANKENPHP_APP_PATH="${1#*=}"
NEW_ARGS+=("--with-frankenphp-app=/app/app")
shift
;;
--with-frankenphp-app)
if [ -n "${2:-}" ]; then
FRANKENPHP_APP_PATH="$2"
NEW_ARGS+=("--with-frankenphp-app=/app/app")
shift 2
else
NEW_ARGS+=("$1")
shift
fi
;;
*)
NEW_ARGS+=("$1")
shift
;;
esac
done
# Normalize the path and add mount if provided
if [ -n "$FRANKENPHP_APP_PATH" ]; then
# expand ~ to $HOME
if [ "${FRANKENPHP_APP_PATH#~}" != "$FRANKENPHP_APP_PATH" ]; then
FRANKENPHP_APP_PATH="$HOME${FRANKENPHP_APP_PATH#~}"
fi
# make absolute if relative
case "$FRANKENPHP_APP_PATH" in
/*) ABS_APP_PATH="$FRANKENPHP_APP_PATH" ;;
*) ABS_APP_PATH="$(pwd)/$FRANKENPHP_APP_PATH" ;;
esac
MOUNT_LIST="$MOUNT_LIST -v $ABS_APP_PATH:/app/app"
fi
# Run docker
# shellcheck disable=SC2068
# shellcheck disable=SC2086
@@ -189,5 +237,5 @@ if [ "$SPC_DOCKER_DEBUG" = "yes" ]; then
set -ex
$DOCKER_EXECUTABLE run $PLATFORM_ARG --privileged --rm -it $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION /bin/bash
else
$DOCKER_EXECUTABLE run $PLATFORM_ARG --rm $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION bin/spc $@
$DOCKER_EXECUTABLE run $PLATFORM_ARG --rm $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION bin/spc "${NEW_ARGS[@]}"
fi

View File

@@ -16,7 +16,7 @@
"symfony/console": "^5.4 || ^6 || ^7",
"symfony/process": "^7.2",
"symfony/yaml": "^7.2",
"zhamao/logger": "^1.0"
"zhamao/logger": "^1.1.3"
},
"require-dev": {
"captainhook/captainhook-phar": "^5.23",

607
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,39 +1,41 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; static-php-cli (spc) env configuration
;
; This file is used to set default env vars for static-php-cli build.
; As dynamic build process, some of these vars can be overwritten by CLI options.
; And you can also overwrite these vars by setting them in your shell environment.
; The value should be changed only if you know what you are doing. Otherwise, please leave them as default.
;
; We need to use some pre-defined internal env vars, like `BUILD_ROOT_PATH`, `DOWNLOAD_PATH`, etc.
; Please note that these vars cannot be defined in this file, they are only be defined before static-php-cli running.
; Please note that these vars cannot be defined in this file, they should only be defined before static-php-cli running.
;
; Here's a list of env vars, these value cannot be changed anywhere:
; Here's a list of env vars, these variables will be defined if not defined:
;
; SPC_VERSION: the version of static-php-cli.
; WORKING_DIR: the working directory of the build process. (default: `$(pwd)`)
; ROOT_DIR: the root directory of static-php-cli. (default: `/path/to/static-php-cli`, when running in phar or micro mode: `phar://path/to/spc.phar`)
; BUILD_ROOT_PATH: the root path of the build process. (default: `$(pwd)/buildroot`)
; BUILD_INCLUDE_PATH: the path of the include files. (default: `$BUILD_ROOT_PATH/include`)
; BUILD_LIB_PATH: the path of the lib files. (default: `$BUILD_ROOT_PATH/lib`)
; BUILD_BIN_PATH: the path of the bin files. (default: `$BUILD_ROOT_PATH/bin`)
; PKG_ROOT_PATH: the root path of the package files. (default: `$(pwd)/pkgroot`)
; BUILD_MODULES_PATH: the path of the php modules (shared extensions) files. (default: `$BUILD_ROOT_PATH/modules`)
; PKG_ROOT_PATH: the root path of the package files. (default: `$(pwd)/pkgroot/$GNU_ARCH-{darwin|linux|windows}`)
; SOURCE_PATH: the path of the source files. (default: `$(pwd)/source`)
; DOWNLOAD_PATH: the path of the download files. (default: `$(pwd)/downloads`)
; CPU_COUNT: the count of the CPU cores. (default: `$(nproc)`)
; SPC_ARCH: the arch of the current system, for some libraries needed `--host=XXX` args. (default: `$(uname -m)`, e.g. `x86_64`, `aarch64`, `arm64`)
; GNU_ARCH: the GNU arch of the current system. (default: `$(uname -m)`, e.g. `x86_64`, `aarch64`)
; MAC_ARCH: the MAC arch of the current system. (default: `$(uname -m)`, e.g. `x86_64`, `arm64`)
; PATH: (*nix only) static-php-cli will add `$BUILD_BIN_PATH` to PATH.
; PKG_CONFIG_PATH: (*nix only) static-php-cli will set `$BUILD_LIB_PATH/pkgconfig` to PKG_CONFIG_PATH.
;
; * These vars are only be defined in Unix (macOS, Linux, FreeBSD)Builder and cannot be changed anywhere:
; PATH: static-php-cli will add `$BUILD_BIN_PATH` to PATH.
; PKG_CONFIG: static-php-cli will set `$BUILD_BIN_PATH/pkg-config` to PKG_CONFIG.
; PKG_CONFIG_PATH: static-php-cli will set `$BUILD_LIB_PATH/pkgconfig` to PKG_CONFIG_PATH.
; Here's a list of env vars, these variables is defined in SPC and cannot be changed anywhere:
;
; * These vars are only be defined in LinuxBuilder and cannot be changed anywhere:
; SPC_LINUX_DEFAULT_CC: the default compiler for linux. (For alpine linux: `gcc`, default: `$GNU_ARCH-linux-musl-gcc`)
; SPC_LINUX_DEFAULT_CXX: the default c++ compiler for linux. (For alpine linux: `g++`, default: `$GNU_ARCH-linux-musl-g++`)
; SPC_LINUX_DEFAULT_AR: the default archiver for linux. (For alpine linux: `ar`, default: `$GNU_ARCH-linux-musl-ar`)
; SPC_VERSION: the version of static-php-cli.
; WORKING_DIR: the working directory of the build process. (default: `$(pwd)`)
; ROOT_DIR: the root directory of static-php-cli. (default: `/path/to/static-php-cli`, when running in phar or micro mode: `phar://path/to/spc.phar`)
; CPU_COUNT: the count of the CPU cores. (default: `$(nproc)`)
; SPC_ARCH: the arch of the current system, for some libraries needed `--host=XXX` args. (default: `$(uname -m)`, e.g. `x86_64`, `aarch64`, `arm64`)
; GNU_ARCH: the GNU arch of the current system. (default: `$(uname -m)`, e.g. `x86_64`, `aarch64`)
; MAC_ARCH: the MAC arch of the current system. (default: `$(uname -m)`, e.g. `x86_64`, `arm64`)
; PKG_CONFIG: (*nix only) static-php-cli will set `$BUILD_BIN_PATH/pkg-config` to PKG_CONFIG.
; SPC_LINUX_DEFAULT_CC: (linux only) the default compiler for linux. (For alpine linux: `gcc`, default: `$GNU_ARCH-linux-musl-gcc`)
; SPC_LINUX_DEFAULT_CXX: (linux only) the default c++ compiler for linux. (For alpine linux: `g++`, default: `$GNU_ARCH-linux-musl-g++`)
; SPC_LINUX_DEFAULT_AR: (linux only) the default archiver for linux. (For alpine linux: `ar`, default: `$GNU_ARCH-linux-musl-ar`)
; SPC_EXTRA_PHP_VARS: (linux only) the extra vars for building php, used in `configure` and `make` command.
[global]
; Build concurrency for make -jN, default is CPU_COUNT, this value are used in every libs.
@@ -43,7 +45,7 @@ SPC_SKIP_PHP_VERSION_CHECK="no"
; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed")
SPC_SKIP_DOCTOR_CHECK_ITEMS=""
; extra modules that xcaddy will include in the FrankenPHP build
SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/frankenphp/caddy --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli"
SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli"
; The display message for php version output (PHP >= 8.4 available)
PHP_BUILD_PROVIDER="static-php-cli ${SPC_VERSION}"
@@ -64,7 +66,7 @@ PHP_SDK_PATH="${WORKING_DIR}\php-sdk-binary-tools"
; upx executable path
UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe"
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static
SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static,win32_api
[linux]
; Linux can use different build toolchains.
@@ -103,16 +105,12 @@ SPC_MICRO_PATCHES=cli_checks,disable_huge_page
; buildconf command
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
; configure command
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable-shared --enable-static --disable-all --disable-cgi --disable-phpdbg --with-pic"
; make command
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable-shared --enable-static --disable-all --disable-phpdbg --with-pic"
; *** default build vars for building php ***
; embed type for php, static (libphp.a) or shared (libphp.so)
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; CFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fPIE"
; EXTRA_CFLAGS for `make` php
; EXTRA_CFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
@@ -124,6 +122,8 @@ SPC_TARGET=native-macos
; compiler environments
CC=clang
CXX=clang++
AR=ar
LD=ld
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
@@ -135,17 +135,13 @@ SPC_MICRO_PATCHES=cli_checks,macos_iconv
; buildconf command
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
; configure command
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
; make command
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-phpdbg"
; *** default build vars for building php ***
; embed type for php, static (libphp.a) or shared (libphp.dylib)
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; CFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -Werror=unknown-warning-option"
; EXTRA_CFLAGS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_CFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_C_FLAGS}"
[freebsd]
; compiler environments

View File

@@ -341,6 +341,7 @@
"ext-depends": [
"xml"
],
"build-with-php": true,
"target": [
"static"
]
@@ -414,9 +415,17 @@
"libmemcached",
"fastlz"
],
"lib-suggests": [
"zstd"
],
"ext-depends": [
"session",
"zlib"
],
"ext-suggests": [
"igbinary",
"msgpack",
"session"
]
},
"mongodb": {
@@ -445,7 +454,7 @@
"type": "external",
"source": "msgpack",
"arg-type-unix": "with",
"arg-type-win": "enable",
"arg-type-windows": "enable",
"ext-depends": [
"session"
]
@@ -453,6 +462,7 @@
"mysqli": {
"type": "builtin",
"arg-type": "with",
"build-with-php": true,
"ext-depends": [
"mysqlnd"
]
@@ -460,6 +470,7 @@
"mysqlnd": {
"type": "builtin",
"arg-type-windows": "with",
"build-with-php": true,
"lib-depends": [
"zlib"
]
@@ -679,7 +690,7 @@
"type": "builtin",
"arg-type": "with-path",
"lib-depends": [
"readline"
"libedit"
],
"target": [
"static"
@@ -694,7 +705,8 @@
"arg-type": "custom",
"ext-suggests": [
"session",
"igbinary"
"igbinary",
"msgpack"
],
"lib-suggests-unix": [
"zstd",
@@ -744,17 +756,27 @@
"apcu"
]
},
"snmp": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"type": "builtin",
"arg-type-unix": "with",
"arg-type-windows": "with",
"lib-depends": [
"net-snmp"
]
},
"soap": {
"support": {
"BSD": "wip"
},
"type": "builtin",
"arg-type": "custom",
"lib-depends": [
"libxml2"
],
"ext-depends-windows": [
"xml"
"ext-depends": [
"libxml",
"session"
]
},
"sockets": {
@@ -790,6 +812,7 @@
"type": "builtin",
"arg-type": "with-path",
"arg-type-windows": "with",
"build-with-php": true,
"lib-depends": [
"sqlite"
]
@@ -841,14 +864,23 @@
"nghttp2",
"zlib"
],
"lib-suggests": [
"zstd"
],
"lib-suggests-linux": [
"zstd",
"liburing"
],
"ext-depends": [
"openssl",
"curl"
],
"ext-suggests": [
"sockets",
"swoole-hook-pgsql",
"swoole-hook-mysql",
"swoole-hook-sqlite"
"swoole-hook-sqlite",
"swoole-hook-odbc"
]
},
"swoole-hook-mysql": {
@@ -858,16 +890,33 @@
},
"notes": true,
"type": "addon",
"arg-type": "custom",
"arg-type": "none",
"ext-depends": [
"mysqlnd",
"pdo",
"pdo_mysql"
"pdo_mysql",
"swoole"
],
"ext-suggests": [
"mysqli"
]
},
"swoole-hook-odbc": {
"support": {
"Windows": "no",
"BSD": "wip"
},
"notes": true,
"type": "addon",
"arg-type": "none",
"ext-depends": [
"pdo",
"swoole"
],
"lib-depends": [
"unixodbc"
]
},
"swoole-hook-pgsql": {
"support": {
"Windows": "no",
@@ -876,10 +925,11 @@
},
"notes": true,
"type": "addon",
"arg-type": "custom",
"arg-type": "none",
"ext-depends": [
"pgsql",
"pdo"
"pdo",
"swoole"
]
},
"swoole-hook-sqlite": {
@@ -889,10 +939,11 @@
},
"notes": true,
"type": "addon",
"arg-type": "custom",
"arg-type": "none",
"ext-depends": [
"sqlite3",
"pdo"
"pdo",
"swoole"
]
},
"swow": {
@@ -949,6 +1000,14 @@
"type": "builtin",
"build-with-php": true
},
"trader": {
"support": {
"BSD": "wip",
"Windows": "wip"
},
"type": "external",
"source": "ext-trader"
},
"uuid": {
"support": {
"Windows": "wip",
@@ -1117,8 +1176,9 @@
"support": {
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-path",
"type": "external",
"source": "ext-zip",
"arg-type": "custom",
"arg-type-windows": "enable",
"lib-depends-unix": [
"libzip"
@@ -1141,6 +1201,7 @@
"lib-depends": [
"zlib"
],
"build-with-php": true,
"target": [
"static"
]

View File

@@ -1,21 +1,35 @@
{
"lib-base": {
"type": "root",
"lib-depends-unix": [
"pkg-config"
]
"type": "root"
},
"php": {
"type": "root",
"source": "php-src",
"lib-depends": [
"lib-base",
"micro"
"micro",
"frankenphp"
],
"lib-depends-macos": [
"lib-base",
"micro",
"libxml2",
"frankenphp"
],
"lib-suggests-linux": [
"libacl"
"libacl",
"brotli",
"watcher"
],
"lib-suggests-macos": [
"brotli",
"watcher"
]
},
"frankenphp": {
"source": "frankenphp",
"type": "target"
},
"micro": {
"type": "target",
"source": "micro"
@@ -194,7 +208,7 @@
"openssl",
"libcares"
],
"provide-pre-built": true,
"cpp-library": true,
"frameworks": [
"CoreFoundation"
]
@@ -222,6 +236,7 @@
},
"imagemagick": {
"source": "imagemagick",
"cpp-library": true,
"pkg-configs": [
"Magick++-7.Q16HDRI",
"MagickCore-7.Q16HDRI",
@@ -335,6 +350,15 @@
],
"cpp-library": true
},
"libedit": {
"source": "libedit",
"static-libs-unix": [
"libedit.a"
],
"lib-depends": [
"ncurses"
]
},
"libevent": {
"source": "libevent",
"static-libs-unix": [
@@ -444,6 +468,7 @@
},
"libmemcached": {
"source": "libmemcached",
"cpp-library": true,
"static-libs-unix": [
"libmemcached.a",
"libmemcachedprotocol.a",
@@ -487,13 +512,16 @@
},
"librdkafka": {
"source": "librdkafka",
"static-libs-unix": [
"librdkafka.a",
"librdkafka++.a",
"librdkafka-static.a"
"pkg-configs": [
"rdkafka++-static",
"rdkafka-static"
],
"cpp-library": true,
"lib-suggests": [
"curl",
"liblz4",
"openssl",
"zlib",
"zstd"
]
},
@@ -540,6 +568,21 @@
"zstd"
]
},
"liburing": {
"source": "liburing",
"pkg-configs": [
"liburing",
"liburing-ffi"
],
"static-libs-linux": [
"liburing.a",
"liburing-ffi.a"
],
"headers-linux": [
"liburing/",
"liburing.h"
]
},
"libuuid": {
"source": "libuuid",
"static-libs-unix": [
@@ -573,8 +616,8 @@
},
"libxml2": {
"source": "libxml2",
"static-libs-unix": [
"libxml2.a"
"pkg-configs": [
"libxml-2.0"
],
"static-libs-windows": [
"libxml2s.lib",
@@ -588,7 +631,6 @@
],
"lib-suggests-unix": [
"xz",
"icu",
"zlib"
],
"lib-depends-windows": [
@@ -664,6 +706,17 @@
"libncurses.a"
]
},
"net-snmp": {
"source": "net-snmp",
"pkg-configs": [
"netsnmp",
"netsnmp-agent"
],
"lib-depends": [
"openssl",
"zlib"
]
},
"nghttp2": {
"source": "nghttp2",
"static-libs-unix": [
@@ -762,7 +815,7 @@
"libxml2",
"openssl",
"zlib",
"readline"
"libedit"
],
"lib-suggests": [
"icu",
@@ -814,6 +867,7 @@
},
"snappy": {
"source": "snappy",
"cpp-library": true,
"static-libs-unix": [
"libsnappy.a"
],
@@ -859,6 +913,7 @@
},
"watcher": {
"source": "watcher",
"cpp-library": true,
"static-libs-unix": [
"libwatcher-c.a"
],
@@ -919,5 +974,24 @@
"zstd.h",
"zstd_errors.h"
]
},
"liburing": {
"source": "liburing",
"pkg-configs": [
"liburing",
"liburing-ffi"
],
"static-libs-linux": [
"liburing.a",
"liburing-ffi.a"
],
"headers-linux": [
"liburing/",
"liburing.h"
]
},
"frankenphp": {
"source": "frankenphp",
"type": "target"
}
}

View File

@@ -1,4 +1,16 @@
{
"go-xcaddy-aarch64-linux": {
"type": "custom"
},
"go-xcaddy-aarch64-macos": {
"type": "custom"
},
"go-xcaddy-x86_64-linux": {
"type": "custom"
},
"go-xcaddy-x86_64-macos": {
"type": "custom"
},
"musl-toolchain-aarch64-linux": {
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/aarch64-musl-toolchain.tgz"
@@ -11,8 +23,40 @@
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/nasm/nasm-2.16.01-win64.zip",
"extract-files": {
"nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe",
"nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe"
"nasm.exe": "{php_sdk_path}/bin/nasm.exe",
"ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe"
}
},
"pkg-config-aarch64-linux": {
"type": "ghrel",
"repo": "static-php/static-php-cli-hosted",
"match": "pkg-config-aarch64-linux-musl-1.2.5.txz",
"extract-files": {
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
}
},
"pkg-config-aarch64-macos": {
"type": "ghrel",
"repo": "static-php/static-php-cli-hosted",
"match": "pkg-config-aarch64-darwin.txz",
"extract-files": {
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
}
},
"pkg-config-x86_64-linux": {
"type": "ghrel",
"repo": "static-php/static-php-cli-hosted",
"match": "pkg-config-x86_64-linux-musl-1.2.5.txz",
"extract-files": {
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
}
},
"pkg-config-x86_64-macos": {
"type": "ghrel",
"repo": "static-php/static-php-cli-hosted",
"match": "pkg-config-x86_64-darwin.txz",
"extract-files": {
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
}
},
"strawberry-perl-x86_64-win": {
@@ -40,33 +84,21 @@
"repo": "upx/upx",
"match": "upx.+-win64\\.zip",
"extract-files": {
"upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe"
"upx.exe": "{pkg_root_path}/bin/upx.exe"
}
},
"go-xcaddy-x86_64-linux": {
"zig-aarch64-linux": {
"type": "custom"
},
"go-xcaddy-aarch64-linux": {
"type": "custom"
},
"go-xcaddy-x86_64-macos": {
"type": "custom"
},
"go-xcaddy-aarch64-macos": {
"zig-aarch64-macos": {
"type": "custom"
},
"zig-x86_64-linux": {
"type": "custom"
},
"zig-aarch64-linux": {
"type": "custom"
},
"zig-x86_64-macos": {
"type": "custom"
},
"zig-aarch64-macos": {
"type": "custom"
},
"zig-x86_64-win": {
"type": "custom"
}

View File

@@ -47,7 +47,7 @@
"provide-pre-built": true,
"license": {
"type": "file",
"path": "doc/COPYING"
"path": "doc/COPYING.LGPL"
}
},
"brotli": {
@@ -233,6 +233,16 @@
"path": "LICENSE"
}
},
"ext-trader": {
"type": "url",
"url": "https://pecl.php.net/get/trader",
"path": "php-src/ext/trader",
"filename": "trader.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-uuid": {
"type": "url",
"url": "https://pecl.php.net/get/uuid",
@@ -263,6 +273,15 @@
"path": "LICENSE"
}
},
"ext-zip": {
"type": "url",
"url": "https://pecl.php.net/get/zip",
"filename": "ext-zip.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-zstd": {
"type": "git",
"path": "php-src/ext/zstd",
@@ -282,10 +301,20 @@
"path": "LICENSE.MIT"
}
},
"frankenphp": {
"type": "ghtar",
"repo": "php/frankenphp",
"prefer-stable": true,
"provide-pre-built": false,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"freetype": {
"type": "git",
"rev": "VER-2-13-2",
"url": "https://github.com/freetype/freetype",
"type": "ghtagtar",
"repo": "freetype/freetype",
"match": "VER-2-\\d+-\\d+",
"license": {
"type": "file",
"path": "LICENSE.TXT"
@@ -297,16 +326,17 @@
"regex": "/href=\"(?<file>gettext-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"license": {
"type": "file",
"path": "COPYING"
"path": "gettext-runtime/intl/COPYING.LIB"
}
},
"gmp": {
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/gmp/gmp-6.3.0.tar.xz",
"type": "filelist",
"url": "https://gmplib.org/download/gmp/",
"regex": "/href=\"(?<file>gmp-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"provide-pre-built": true,
"alt": {
"type": "ghtagtar",
"repo": "alisw/GMP"
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/gmp/gmp-6.3.0.tar.xz"
},
"license": {
"type": "text",
@@ -324,7 +354,7 @@
},
"grpc": {
"type": "git",
"rev": "v1.68.x",
"rev": "v1.75.x",
"url": "https://github.com/grpc/grpc.git",
"provide-pre-built": true,
"license": {
@@ -343,6 +373,16 @@
"path": "LICENSE"
}
},
"frankenphp": {
"type": "ghtar",
"repo": "php/frankenphp",
"prefer-stable": true,
"provide-pre-build": false,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"icu-static-win": {
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/icu-static-windows-x64/icu-static-windows-x64.zip",
@@ -430,7 +470,7 @@
"provide-pre-built": true,
"license": {
"type": "file",
"path": "doc/COPYING"
"path": "doc/COPYING.LGPL"
}
},
"libaom": {
@@ -489,6 +529,16 @@
"path": "COPYING"
}
},
"libedit": {
"type": "filelist",
"url": "https://thrysoee.dk/editline/",
"regex": "/href=\"(?<file>libedit-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"libevent": {
"type": "ghrel",
"repo": "libevent/libevent",
@@ -537,7 +587,7 @@
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
"path": "COPYING.LIB"
}
},
"libiconv-win": {
@@ -650,6 +700,15 @@
"path": "LICENSE.md"
}
},
"liburing": {
"type": "ghtar",
"repo": "axboe/liburing",
"prefer-stable": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"libuuid": {
"type": "git",
"url": "https://github.com/static-php/libuuid.git",
@@ -733,7 +792,7 @@
"micro": {
"type": "git",
"path": "php-src/sapi/micro",
"rev": "php-85-win",
"rev": "master",
"url": "https://github.com/static-php/phpmicro",
"license": {
"type": "file",
@@ -781,6 +840,14 @@
"path": "COPYING"
}
},
"net-snmp": {
"type": "ghtagtar",
"repo": "net-snmp/net-snmp",
"license": {
"type": "file",
"path": "COPYING"
}
},
"nghttp2": {
"type": "ghrel",
"repo": "nghttp2/nghttp2",
@@ -880,7 +947,7 @@
"postgresql": {
"type": "ghtagtar",
"repo": "postgres/postgres",
"match": "REL_16_\\d+",
"match": "REL_18_\\d+",
"license": {
"type": "file",
"path": "COPYRIGHT"
@@ -971,7 +1038,6 @@
},
"snappy": {
"type": "git",
"repo": "google/snappy",
"rev": "main",
"url": "https://github.com/google/snappy",
"license": {
@@ -980,9 +1046,8 @@
}
},
"spx": {
"type": "git",
"rev": "master",
"url": "https://github.com/static-php/php-spx.git",
"type": "pie",
"repo": "noisebynorthwest/php-spx",
"path": "php-src/ext/spx",
"license": {
"type": "file",

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,219 @@
<template>
<div class="contributors-container">
<div class="contributors-header">
<h2>Contributors</h2>
<p class="contributors-description">
Thanks to all the amazing people who have contributed to this project!
</p>
</div>
<div v-if="loading" class="loading-state">
<div class="spinner"></div>
<p>Loading contributors...</p>
</div>
<div v-else-if="error" class="error-state">
<p>{{ error }}</p>
</div>
<div v-else class="contributors-grid">
<a
v-for="contributor in contributors"
:key="contributor.id"
:href="contributor.html_url"
target="_blank"
rel="noopener noreferrer"
class="contributor-card"
:title="contributor.login"
>
<img
:src="contributor.avatar_url"
:alt="contributor.login"
class="contributor-avatar"
loading="lazy"
/>
<div class="contributor-name">{{ contributor.login }}</div>
</a>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
interface Contributor {
id: number;
login: string;
avatar_url: string;
html_url: string;
contributions: number;
}
const contributors = ref<Contributor[]>([]);
const loading = ref(true);
const error = ref('');
const fetchContributors = async () => {
try {
loading.value = true;
error.value = '';
const response = await fetch(
'https://api.github.com/repos/crazywhalecc/static-php-cli/contributors?per_page=24'
);
if (!response.ok) {
throw new Error('Failed to fetch contributors');
}
const data = await response.json();
contributors.value = data;
} catch (err) {
error.value = 'Failed to load contributors. Please try again later.';
console.error('Error fetching contributors:', err);
} finally {
loading.value = false;
}
};
onMounted(() => {
fetchContributors();
});
</script>
<style scoped>
.contributors-container {
margin: 48px auto;
padding: 32px 24px;
max-width: 1152px;
background: linear-gradient(135deg, var(--vp-c-bg-soft) 0%, var(--vp-c-bg) 100%);
border-radius: 16px;
border: 1px solid var(--vp-c-divider);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}
.contributors-header {
text-align: center;
margin-bottom: 24px;
}
.contributors-header h2 {
font-size: 1.5rem;
font-weight: 700;
margin: 0 0 8px 0;
background: linear-gradient(120deg, var(--vp-c-brand-1), var(--vp-c-brand-2));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.contributors-description {
font-size: 0.95rem;
color: var(--vp-c-text-2);
margin: 0;
line-height: 1.5;
}
.loading-state,
.error-state {
text-align: center;
padding: 40px 20px;
color: var(--vp-c-text-2);
}
.spinner {
width: 40px;
height: 40px;
margin: 0 auto 16px;
border: 4px solid var(--vp-c-divider);
border-top-color: var(--vp-c-brand-1);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.contributors-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
gap: 16px;
}
.contributor-card {
display: flex;
flex-direction: column;
align-items: center;
padding: 12px;
background: var(--vp-c-bg);
border-radius: 12px;
border: 1px solid var(--vp-c-divider);
transition: all 0.3s ease;
text-decoration: none;
color: var(--vp-c-text-1);
}
.contributor-card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
border-color: var(--vp-c-brand-1);
}
.contributor-avatar {
width: 60px;
height: 60px;
border-radius: 50%;
border: 2px solid var(--vp-c-divider);
transition: all 0.3s ease;
margin-bottom: 8px;
}
.contributor-card:hover .contributor-avatar {
border-color: var(--vp-c-brand-1);
transform: scale(1.05);
}
.contributor-name {
font-size: 12px;
font-weight: 500;
text-align: center;
word-break: break-word;
max-width: 100%;
}
@media (max-width: 768px) {
.contributors-container {
margin: 32px 16px;
padding: 24px 16px;
}
.contributors-header h2 {
font-size: 1.25rem;
}
.contributors-description {
font-size: 0.9rem;
}
.contributors-grid {
grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
gap: 12px;
}
.contributor-card {
padding: 8px;
}
.contributor-avatar {
width: 48px;
height: 48px;
}
.contributor-name {
font-size: 11px;
}
}
</style>

View File

@@ -4,7 +4,7 @@ import sidebarZh from "./sidebar.zh";
// https://vitepress.dev/reference/site-config
export default {
title: "static-php-cli",
title: "Static PHP",
description: "Build single static PHP binary, with PHP project together, with popular extensions included.",
locales: {
en: {
@@ -44,6 +44,7 @@ export default {
},
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo: '/images/static-php_nobg.png',
nav: [],
socialLinks: [
{icon: 'github', link: 'https://github.com/crazywhalecc/static-php-cli'}
@@ -51,6 +52,14 @@ export default {
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2023-present crazywhalecc'
}
},
search: {
provider: 'algolia',
options: {
appId: 'IHJHUB1SF1',
apiKey: '8266d31cc2ffbd0e059f1c6e5bdaf8fc',
indexName: 'static-php docs',
},
},
}
}

View File

@@ -4,3 +4,21 @@
max-width: 1000px !important;
}
.vp-doc .contributors-header h2 {
padding-top: 0;
border-top: none;
}
.vp-doc .sponsors-header h2 {
padding-top: 0;
border-top: none;
}
.dark .VPImage.logo {
filter: contrast(0.7);
}
.dark .VPImage.image-src {
filter: contrast(0.7);
}

View File

@@ -36,6 +36,7 @@ The following is the source download configuration corresponding to the `libeven
The most important field here is `type`. Currently, the types it supports are:
- `url`: Directly use URL to download, for example: `https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz`.
- `pie`: Download PHP extensions from Packagist using the PIE (PHP Installer for Extensions) standard.
- `ghrel`: Use the GitHub Release API to download, download the artifacts uploaded from the latest version released by maintainers.
- `ghtar`: Use the GitHub Release API to download.
Different from `ghrel`, `ghtar` is downloaded from the `source code (tar.gz)` in the latest Release of the project.
@@ -89,6 +90,37 @@ Example (download the imagick extension and extract it to the extension storage
}
```
## Download type - pie
PIE (PHP Installer for Extensions) type sources refer to downloading PHP extensions from Packagist that follow the PIE standard.
This method automatically fetches extension information from the Packagist repository and downloads the appropriate distribution file.
The parameters included are:
- `repo`: The Packagist vendor/package name, such as `vendor/package-name`
Example (download a PHP extension from Packagist using PIE):
```json
{
"ext-example": {
"type": "pie",
"repo": "vendor/example-extension",
"path": "php-src/ext/example",
"license": {
"type": "file",
"path": "LICENSE"
}
}
}
```
::: tip
The PIE download type will automatically detect the extension information from Packagist metadata,
including the download URL, version, and distribution type.
The extension must be marked as `type: php-ext` or contain `php-ext` metadata in its Packagist package definition.
:::
## Download type - ghrel
ghrel will download files from Assets uploaded in GitHub Release.

View File

@@ -44,6 +44,11 @@ So on macOS, you can **directly** use SPC to build statically compiled PHP binar
2. You will get `buildroot/modules/xdebug.so` and `buildroot/bin/php`.
3. The `xdebug.so` file could be used for php that version and thread-safe are the same.
For the Windows platform, since officially built extensions (such as `php_yaml.dll`) force the use of the `php8.dll` dynamic library as a link, and statically built PHP does not include any dynamic libraries other than system libraries,
php.exe built by static-php cannot load officially built dynamic extensions. Since static-php-cli does not yet support building dynamic extensions, there is currently no way to load dynamic extensions with static-php.
However, Windows can normally use the `FFI` extension to load other dll files and call them.
## Can it support Oracle database extension?
Some extensions that rely on closed source libraries, such as `oci8`, `sourceguardian`, etc.,

View File

@@ -46,6 +46,14 @@ If you use `swoole,swoole-hook-sqlite`, you will enable the coroutine mode of Sw
swoole-hook-sqlite conflicts with the `pdo_sqlite` extension. If you want to use Swoole and `pdo_sqlite`, please delete the pdo_sqlite extension and enable `swoole` and `swoole-hook-sqlite`.
This extension contains an implementation of the coroutine environment for `pdo_sqlite`.
## swoole-hook-odbc
swoole-hook-odbc is not an extension, it's a Hook feature of Swoole.
If you use `swoole,swoole-hook-odbc`, you will enable the coroutine mode of Swoole's `odbc` extension.
swoole-hook-odbc conflicts with the `pdo_odbc` extension. If you want to use Swoole and `pdo_odbc`, please delete the `pdo_odbc` extension and enable `swoole` and `swoole-hook-odbc`.
This extension contains an implementation of the coroutine environment for `pdo_odbc`.
## swow
1. Only PHP 8.0+ is supported.

View File

@@ -21,19 +21,30 @@ The following is the architecture support situation, where :gear: represents sup
| Windows | :gear: :computer: | |
| FreeBSD | :computer: | :computer: |
Among them, Linux is currently only tested on Ubuntu, Debian, and Alpine distributions,
and other distributions have not been tested, which cannot guarantee successful compilation.
For untested distributions, local compilation can be done using methods such as Docker to avoid environmental issues.
Current supported PHP versions for compilation:
There are two architectures for macOS: `x86_64` and `Arm`, but binaries compiled on one architecture cannot be directly used on the other architecture.
Rosetta 2 cannot guarantee that programs compiled with `Arm` architecture can fully run on `x86_64` environment.
> :warning: Partial support, there may be issues with new beta versions and old versions.
>
> :heavy_check_mark: Supported
>
> :x: Not supported
Windows currently only supports the x86_64 architecture, and does not support 32-bit x86 or arm64 architecture.
| PHP Version | Status | Comment |
|-------------|--------------------|-------------------------------------------------------------------------------------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :x: | phpmicro and many extensions do not support 7.3, 7.4 versions |
| 7.4 | :x: | phpmicro and many extensions do not support 7.3, 7.4 versions |
| 8.0 | :warning: | PHP official has stopped maintaining 8.0, we no longer handle 8.0 related backport support |
| 8.1 | :warning: | PHP official only provides security updates for 8.1, we no longer handle 8.1 related backport support after 8.5 release |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
| 8.5 (beta) | :warning: | PHP 8.5 is currently in beta stage |
## Supported PHP Version
> This table shows the support status of static-php-cli for building corresponding versions, not the PHP official support status for that version.
Currently, static php cli supports PHP versions 8.1 to 8.5, and theoretically supports PHP 8.0 and earlier versions.
Simply select the earlier version when downloading.
However, due to some extensions and special components that have stopped supporting earlier versions of PHP,
static-php-cli will not explicitly support earlier versions.
## PHP Support Versions
Currently, static-php-cli supports PHP versions 8.2 ~ 8.5, and theoretically supports PHP 8.1 and earlier versions, just select the earlier version when downloading.
However, due to some extensions and special components that have stopped supporting earlier versions of PHP, static-php-cli will not explicitly support earlier versions.
We recommend that you compile the latest PHP version possible for a better experience.

View File

@@ -172,7 +172,7 @@ If the build is successful, you will see the `buildroot/bin` directory in the cu
If the build fails, you can use the `--debug` parameter to view detailed error information,
or use the `--with-clean` to clear the old compilation results and recompile.
If the build still fails to use the above method, please submit an issue and attach your `craft.yml` and `craft.log`.
If the build still fails to use the above method, please submit an issue and attach your `craft.yml` and `./log` archive.
## Step-by-step build command
@@ -289,6 +289,7 @@ You need to specify a compilation target, choose from the following parameters:
- `--build-cli`: Build a cli sapi (command line interface, which can execute PHP code on the command line)
- `--build-fpm`: Build a fpm sapi (php-fpm, used in conjunction with other traditional fpm architecture software such as nginx)
- `--build-cgi`: Build a cgi sapi (cgi, rarely used)
- `--build-micro`: Build a micro sapi (used to build a standalone executable binary containing PHP code)
- `--build-embed`: Build an embed sapi (used to embed into other C language programs)
- `--build-frankenphp`: Build a [FrankenPHP](https://github.com/php/frankenphp) executable

View File

@@ -3,11 +3,14 @@
layout: home
hero:
name: "static-php-cli"
name: "Static PHP"
tagline: "Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included."
image:
src: /images/static-php_nobg.png
alt: Static PHP CLI Logo
actions:
- theme: brand
text: Guide
text: Get Started
link: ./guide/
features:
@@ -19,3 +22,121 @@ features:
details: static-php-cli comes with dependency management and supports installation of different types of PHP extensions.
---
<script setup>
import {VPSponsors} from "vitepress/theme";
import Contributors from '../.vitepress/components/Contributors.vue';
const sponsors = [
{ name: 'Beyond Code', img: '/images/beyondcode-seeklogo.png', url: 'https://beyondco.de/' },
{ name: 'NativePHP', img: '/images/nativephp-logo.svg', url: 'https://nativephp.com/' },
];
</script>
<div class="sponsors-section">
<div class="sponsors-header">
<h2>Special Sponsors</h2>
<p class="sponsors-description">
Thank you to our amazing sponsors for supporting this project!
</p>
</div>
<VPSponsors :data="sponsors"/>
</div>
<style scoped>
.sponsors-section {
margin: 48px auto;
padding: 32px 24px;
max-width: 1152px;
background: linear-gradient(135deg, var(--vp-c-bg-soft) 0%, var(--vp-c-bg) 100%);
border-radius: 16px;
border: 1px solid var(--vp-c-divider);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
}
.sponsors-section:hover {
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
transform: translateY(-2px);
}
.sponsors-header {
text-align: center;
margin-bottom: 24px;
}
.sponsors-header h2 {
font-size: 1.5rem;
font-weight: 700;
margin: 0 0 8px 0;
background: linear-gradient(120deg, var(--vp-c-brand-1), var(--vp-c-brand-2));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.sponsors-description {
font-size: 0.95rem;
color: var(--vp-c-text-2);
margin: 0;
line-height: 1.5;
}
@media (max-width: 768px) {
.sponsors-section {
margin: 32px 16px;
padding: 24px 16px;
}
.sponsors-header h2 {
font-size: 1.25rem;
}
.sponsors-description {
font-size: 0.9rem;
}
}
/* Hero logo styling */
:deep(.VPImage.image-src) {
border-radius: 20px;
background: linear-gradient(135deg, var(--vp-c-bg-soft) 0%, var(--vp-c-default-soft) 100%);
padding: 40px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
:deep(.VPImage.image-src:hover) {
transform: translateY(-4px);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
/* Dark mode adjustments for logo */
.dark :deep(.VPImage.image-src) {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
opacity: 0.9;
}
.dark :deep(.VPImage.image-src:hover) {
opacity: 1;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}
/* Additional styling for the logo image itself */
:deep(.VPImage.image-src img) {
max-height: 280px;
width: auto;
}
@media (max-width: 768px) {
:deep(.VPImage.image-src) {
padding: 24px;
}
:deep(.VPImage.image-src img) {
max-height: 200px;
}
}
</style>
<Contributors />

View File

@@ -3,8 +3,11 @@
layout: home
hero:
name: "static-php-cli"
name: "Static PHP"
tagline: "Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included."
image:
src: /images/static-php_nobg.png
alt: Static PHP CLI Logo
actions:
- theme: brand
text: Get Started
@@ -24,13 +27,121 @@ features:
<script setup>
import {VPSponsors} from "vitepress/theme";
import Contributors from './.vitepress/components/Contributors.vue';
const sponsors = [
{ name: 'Beyond Code', img: '/images/beyondcode-seeklogo.png', url: 'https://beyondco.de/' },
{ name: 'NativePHP', img: '/images/nativephp-logo.svg', url: 'https://nativephp.com/' },
];
</script>
## Special Sponsors
<div class="sponsors-section">
<div class="sponsors-header">
<h2>Special Sponsors</h2>
<p class="sponsors-description">
Thank you to our amazing sponsors for supporting this project!
</p>
</div>
<VPSponsors :data="sponsors"/>
</div>
<VPSponsors :data="sponsors"/>
<style scoped>
.sponsors-section {
margin: 48px auto;
padding: 32px 24px;
max-width: 1152px;
background: linear-gradient(135deg, var(--vp-c-bg-soft) 0%, var(--vp-c-bg) 100%);
border-radius: 16px;
border: 1px solid var(--vp-c-divider);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
}
.sponsors-section:hover {
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
transform: translateY(-2px);
}
.sponsors-header {
text-align: center;
margin-bottom: 24px;
}
.sponsors-header h2 {
font-size: 1.5rem;
font-weight: 700;
margin: 0 0 8px 0;
background: linear-gradient(120deg, var(--vp-c-brand-1), var(--vp-c-brand-2));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.sponsors-description {
font-size: 0.95rem;
color: var(--vp-c-text-2);
margin: 0;
line-height: 1.5;
}
@media (max-width: 768px) {
.sponsors-section {
margin: 32px 16px;
padding: 24px 16px;
}
.sponsors-header h2 {
font-size: 1.25rem;
}
.sponsors-description {
font-size: 0.9rem;
}
}
/* Hero logo styling */
:deep(.VPImage.image-src) {
border-radius: 20px;
background: linear-gradient(135deg, var(--vp-c-bg-soft) 0%, var(--vp-c-default-soft) 100%);
padding: 40px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
:deep(.VPImage.image-src:hover) {
transform: translateY(-4px);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
/* Dark mode adjustments for logo */
.dark :deep(.VPImage.image-src) {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
opacity: 0.9;
}
.dark :deep(.VPImage.image-src:hover) {
opacity: 1;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}
/* Additional styling for the logo image itself */
:deep(.VPImage.image-src img) {
max-height: 280px;
width: auto;
}
@media (max-width: 768px) {
:deep(.VPImage.image-src) {
padding: 24px;
}
:deep(.VPImage.image-src img) {
max-height: 200px;
}
}
</style>
<Contributors />

Binary file not shown.

After

Width:  |  Height:  |  Size: 965 KiB

View File

@@ -30,6 +30,7 @@ static-php-cli 的下载资源模块是一个主要的功能,它包含了所
这里最主要的字段是 `type`,目前它支持的类型有:
- `url`: 直接使用 URL 下载,例如:`https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz`
- `pie`: 使用 PIEPHP Installer for Extensions标准从 Packagist 下载 PHP 扩展。
- `ghrel`: 使用 GitHub Release API 下载,即从 GitHub 项目发布的最新版本中上传的附件下载。
- `ghtar`: 使用 GitHub Release API 下载,与 `ghrel` 不同的是,`ghtar` 是从项目的最新 Release 中找 `source code (tar.gz)` 下载的。
- `ghtagtar`: 使用 GitHub Release API 下载,与 `ghtar` 相比,`ghtagtar` 可以从 `tags` 列表找最新的,并下载 `tar.gz` 格式的源码(因为有些项目只使用了 `tag` 发布版本)。
@@ -77,6 +78,36 @@ url 类型的资源指的是从 URL 直接下载文件。
}
```
## 下载类型 - pie
PIEPHP Installer for Extensions类型的资源是从 Packagist 下载遵循 PIE 标准的 PHP 扩展。
该方法会自动从 Packagist 仓库获取扩展信息,并下载相应的分发文件。
包含的参数有:
- `repo`: Packagist 的 vendor/package 名称,如 `vendor/package-name`
例子(使用 PIE 从 Packagist 下载 PHP 扩展):
```json
{
"ext-example": {
"type": "pie",
"repo": "vendor/example-extension",
"path": "php-src/ext/example",
"license": {
"type": "file",
"path": "LICENSE"
}
}
}
```
::: tip
PIE 下载类型会自动从 Packagist 元数据中检测扩展信息,包括下载 URL、版本和分发类型。
扩展必须在其 Packagist 包定义中标记为 `type: php-ext` 或包含 `php-ext` 元数据。
:::
## 下载类型 - ghrel
ghrel 会从 GitHub Release 中上传的 Assets 下载文件。首先使用 GitHub Release API 获取最新版本,然后根据正则匹配方式下载相应的文件。

View File

@@ -41,6 +41,11 @@ buildroot/bin/php -d "zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so" -
2. 你将获得 `buildroot/modules/xdebug.so``buildroot/bin/php`
3. `xdebug.so` 文件可用于版本和线程安全相同的 php。
对于 Windows 平台,由于官方构建的扩展(如 `php_yaml.dll`)强制使用了 `php8.dll` 动态库作为链接,静态构建的 PHP 不包含任何系统库以外的动态库,
所以 Windows 下无法加载官方构建的动态扩展。 由于 static-php-cli 还暂未支持构建动态扩展,所以目前还没有让 static-php 加载动态扩展的方法。
不过Windows 可以正常使用 `FFI` 扩展加载其他的 dll 文件并调用。
## 可以支持 Oracle 数据库扩展吗?
部分依赖库闭源的扩展,如 `oci8``sourceguardian` 等,它们没有提供纯静态编译的依赖库文件(`.a`),仅提供了动态依赖库文件(`.so`

View File

@@ -43,6 +43,14 @@ swoole-hook-sqlite 不是一个扩展,而是 Swoole 的 Hook 特性。
swoole-hook-sqlite 与 `pdo_sqlite` 扩展冲突。如需使用 Swoole 和 `pdo_sqlite`,请删除 pdo_sqlite 扩展,启用 `swoole``swoole-hook-sqlite` 即可。
该扩展包含了 `pdo_sqlite` 的协程环境的实现。
## swoole-hook-odbc
swoole-hook-odbc 不是一个扩展,而是 Swoole 的 Hook 特性。
如果你在编译时添加了 `swoole,swoole-hook-odbc`,你将启用 Swoole 的 `odbc` 扩展的协程模式。
swoole-hook-odbc 与 `pdo_odbc` 扩展冲突。如需使用 Swoole 和 `pdo_odbc`,请删除 `pdo_odbc` 扩展,启用 `swoole``swoole-hook-odbc` 即可。
该扩展包含了 `pdo_odbc` 的协程环境的实现。
## swow
1. swow 仅支持 PHP 8.0+ 版本。

View File

@@ -19,16 +19,30 @@ static-php-cli 是一个用于构建静态编译的 PHP 二进制的工具,目
| Windows | :gear: :computer: | |
| FreeBSD | :computer: | :computer: |
其中Linux 目前仅在 Ubuntu、Debian、Alpine 发行版测试通过,其他发行版未进行测试,不能保证编译成功。
对于未经过测试的发行版,可以使用 Docker 等方式本地编译,避免环境导致的问题。
当前支持编译的 PHP 版本:
macOS 下支持 x86_64 和 Arm 两种架构,但在其中一个架构上编译的二进制无法直接在另一个架构上使用
Rosetta 2 不能保证 Arm 架构编译的程序可以完全运行在 x86_64 环境下。
> :warning: 部分支持,对于新的测试版和旧版本可能存在问题
>
> :heavy_check_mark: 支持
>
> :x: 不支持
Windows 目前只支持 x86_64 架构,不支持 32 位 x86、不支持 arm64 架构。
| PHP Version | Status | Comment |
|-------------|--------------------|---------------------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 7.4 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 8.0 | :warning: | PHP 官方已停止 8.0 的维护,我们不再处理 8.0 相关的 backport 支持 |
| 8.1 | :warning: | PHP 官方仅对 8.1 提供安全更新,在 8.5 发布后我们不再处理 8.1 相关的 backport 支持 |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
| 8.5 (beta) | :warning: | PHP 8.5 目前处于 beta 阶段 |
> 这个表格的支持状态是 static-php-cli 对构建对应版本的支持情况,不是 PHP 官方对该版本的支持情况。
## PHP 支持版本
目前static-php-cli 对 PHP 8.1 ~ 8.5 版本是支持的,对于 PHP 8.0 及更早版本理论上支持,只需下载时选择早期版本即可。
目前static-php-cli 对 PHP 8.2 ~ 8.5 版本是支持的,对于 PHP 8.1 及更早版本理论上支持,只需下载时选择早期版本即可。
但由于部分扩展和特殊组件已对早期版本的 PHP 停止了支持,所以 static-php-cli 不会明确支持早期版本。
我们推荐你编译尽可能新的 PHP 版本,以获得更好的体验。

View File

@@ -149,7 +149,7 @@ bin/spc craft --debug
如果中途构建出错,你可以使用 `--debug` 参数查看详细的错误信息,或者使用 `--with-clean` 参数清除旧的编译结果,重新编译。
如使用以上方式仍构建失败,请提交一个 issue附上你的 `craft.yml``craft.log`
如使用以上方式仍构建失败,请提交一个 issue附上你的 `craft.yml` 文件`log/` 目录的压缩包
## 分步构建命令
@@ -249,6 +249,7 @@ bin/spc doctor --auto-fix
- `--build-cli`: 构建一个 cli sapi命令行界面可在命令行执行 PHP 代码)
- `--build-fpm`: 构建一个 fpm sapiphp-fpm用于和其他传统的 fpm 架构的软件如 nginx 配合使用)
- `--build-cgi`: 构建一个 cgi sapicgi可用于传统的 cgi 架构的软件如 apache 配合使用)
- `--build-micro`: 构建一个 micro sapi用于构建一个包含 PHP 代码的独立可执行二进制)
- `--build-embed`: 构建一个 embed sapi用于嵌入到其他 C 语言程序中)
- `--build-frankenphp`: 构建一个 [frankenphp](https://github.com/php/frankenphp) 二进制

View File

@@ -3,18 +3,140 @@
layout: home
hero:
name: "static-php-cli"
name: "Static PHP"
tagline: "在 Linux、macOS、FreeBSD、Windows 上与 PHP 项目一起构建独立的 PHP 二进制文件,并包含流行的扩展。"
image:
src: /images/static-php_nobg.png
alt: Static PHP CLI Logo
actions:
- theme: brand
text: 指南
text: 开始使用
link: ./guide/
features:
- title: 静态二进制
details: 您可以轻松地编译一个独立的 PHP 二进制文件以供嵌入程序使用包括 cli、fpm、micro
- title: phpmicro 自执行二进制
details: 您可以使用 micro SAPI 编译一个自解压的可执行文件,并将 PHP 代码与二进制文件打包为一个文件
- title: 依赖管理
details: static-php-cli 附带依赖项管理,支持安装不同类型的 PHP 扩展和不同的依赖库
- title: 静态 CLI 二进制
details: 您可以轻松地编译一个独立的 PHP 二进制文件以供通用使用包括 CLI、FPM SAPI
- title: Micro 自解压可执行文件
details: 您可以编译一个自解压的可执行文件,并将 PHP 代码与二进制文件打包在一起
- title: 依赖管理
details: static-php-cli 附带依赖项管理,支持安装不同类型的 PHP 扩展。
---
<script setup>
import {VPSponsors} from "vitepress/theme";
import Contributors from '../.vitepress/components/Contributors.vue';
const sponsors = [
{ name: 'Beyond Code', img: '/images/beyondcode-seeklogo.png', url: 'https://beyondco.de/' },
{ name: 'NativePHP', img: '/images/nativephp-logo.svg', url: 'https://nativephp.com/' },
];
</script>
<div class="sponsors-section">
<div class="sponsors-header">
<h2>特别赞助商</h2>
<p class="sponsors-description">
感谢我们出色的赞助商对本项目的支持!
</p>
</div>
<VPSponsors :data="sponsors"/>
</div>
<style scoped>
.sponsors-section {
margin: 48px auto;
padding: 32px 24px;
max-width: 1152px;
background: linear-gradient(135deg, var(--vp-c-bg-soft) 0%, var(--vp-c-bg) 100%);
border-radius: 16px;
border: 1px solid var(--vp-c-divider);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
}
.sponsors-section:hover {
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
transform: translateY(-2px);
}
.sponsors-header {
text-align: center;
margin-bottom: 24px;
}
.sponsors-header h2 {
font-size: 1.5rem;
font-weight: 700;
margin: 0 0 8px 0;
background: linear-gradient(120deg, var(--vp-c-brand-1), var(--vp-c-brand-2));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.sponsors-description {
font-size: 0.95rem;
color: var(--vp-c-text-2);
margin: 0;
line-height: 1.5;
}
@media (max-width: 768px) {
.sponsors-section {
margin: 32px 16px;
padding: 24px 16px;
}
.sponsors-header h2 {
font-size: 1.25rem;
}
.sponsors-description {
font-size: 0.9rem;
}
}
/* Hero logo styling */
:deep(.VPImage.image-src) {
border-radius: 20px;
background: linear-gradient(135deg, var(--vp-c-bg-soft) 0%, var(--vp-c-default-soft) 100%);
padding: 40px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
:deep(.VPImage.image-src:hover) {
transform: translateY(-4px);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
/* Dark mode adjustments for logo */
.dark :deep(.VPImage.image-src) {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
opacity: 0.9;
}
.dark :deep(.VPImage.image-src:hover) {
opacity: 1;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}
/* Additional styling for the logo image itself */
:deep(.VPImage.image-src img) {
max-height: 280px;
width: auto;
}
@media (max-width: 768px) {
:deep(.VPImage.image-src) {
padding: 24px;
}
:deep(.VPImage.image-src img) {
max-height: 200px;
}
}
</style>
<Contributors />

View File

@@ -8,6 +8,8 @@ parameters:
- '#class Fiber#'
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
- '#Function Swoole\\Coroutine\\run not found.#'
- '#Static call to instance method ZM\\Logger\\ConsoleColor#'
- '#Constant GNU_ARCH not found#'
dynamicConstantNames:
- PHP_OS_FAMILY
excludePaths:

View File

@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
*/
final class ConsoleApplication extends Application
{
public const VERSION = '2.7.0';
public const string VERSION = '2.7.7';
public function __construct()
{

View File

@@ -4,18 +4,16 @@ declare(strict_types=1);
namespace SPC\builder;
use PharIo\FileSystem\File;
use SPC\exception\ExceptionHandler;
use SPC\exception\FileSystemException;
use SPC\exception\BuildFailureException;
use SPC\exception\InterruptException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\FileSystem;
use SPC\store\LockFile;
use SPC\store\pkg\GoXcaddy;
use SPC\store\SourceManager;
use SPC\store\SourcePatcher;
use SPC\util\CustomExt;
use SPC\util\AttributeMapper;
abstract class BuilderBase
{
@@ -46,20 +44,14 @@ abstract class BuilderBase
/**
* Convert libraries to class
*
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
*
* @internal
*/
abstract public function proveLibs(array $sorted_libraries);
/**
* Set-Up libraries
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function setupLibs(): void
{
@@ -70,12 +62,11 @@ abstract class BuilderBase
match ($status) {
LIB_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] setup success, took ' . round(microtime(true) - $starttime, 2) . ' s'),
LIB_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
LIB_STATUS_BUILD_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
LIB_STATUS_INSTALL_FAILED => logger()->error('lib [' . $lib::NAME . '] install failed'),
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
};
if (in_array($status, [LIB_STATUS_BUILD_FAILED, LIB_STATUS_INSTALL_FAILED])) {
throw new RuntimeException('Library [' . $lib::NAME . '] setup failed.');
throw new BuildFailureException('Library [' . $lib::NAME . '] setup failed.');
}
}
}
@@ -137,30 +128,6 @@ abstract class BuilderBase
return array_filter($this->exts, fn ($ext) => $ext->isBuildStatic());
}
/**
* 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(false));
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.
*
@@ -174,15 +141,10 @@ abstract class BuilderBase
/**
* 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 \Throwable|WrongUsageException
* @internal
*/
public function proveExts(array $static_extensions, array $shared_extensions = [], bool $skip_check_deps = false, bool $skip_extract = false): void
{
CustomExt::loadCustomExt();
// judge ext
foreach ($static_extensions as $ext) {
// if extension does not support static build, throw exception
@@ -213,7 +175,7 @@ abstract class BuilderBase
}
foreach ([...$static_extensions, ...$shared_extensions] as $extension) {
$class = CustomExt::getExtClass($extension);
$class = AttributeMapper::getExtensionClassByName($extension) ?? Extension::class;
/** @var Extension $ext */
$ext = new $class($extension, $this);
if (in_array($extension, $static_extensions)) {
@@ -248,9 +210,7 @@ abstract class BuilderBase
abstract public function testPHP(int $build_target = BUILD_TARGET_NONE);
/**
* @throws WrongUsageException
* @throws RuntimeException
* @throws FileSystemException
* Build shared extensions.
*/
public function buildSharedExts(): void
{
@@ -273,9 +233,8 @@ abstract class BuilderBase
}
$ext->buildShared();
}
} catch (RuntimeException $e) {
} finally {
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line);
throw $e;
}
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line);
FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', '# test "[$]$1" = "no" && $1=yes', 'test "[$]$1" = "no" && $1=yes');
@@ -284,19 +243,16 @@ abstract class BuilderBase
/**
* Generate extension enable arguments for configure.
* e.g. --enable-mbstring
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function makeStaticExtensionArgs(): string
{
$ret = [];
foreach ($this->getExts() as $ext) {
$arg = $ext->getConfigureArg();
$arg = null;
if ($ext->isBuildShared() && !$ext->isBuildStatic()) {
if (
(Config::getExt($ext->getName(), 'type') === 'builtin' &&
!file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) ||
!file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) ||
Config::getExt($ext->getName(), 'build-with-php') === true
) {
$arg = $ext->getConfigureArg(true);
@@ -304,6 +260,7 @@ abstract class BuilderBase
continue;
}
}
$arg ??= $ext->getConfigureArg();
logger()->info($ext->getName() . ' is using ' . $arg);
$ret[] = trim($arg);
}
@@ -321,9 +278,6 @@ abstract class BuilderBase
/**
* Get PHP Version ID from php-src/main/php_version.h
*
* @throws RuntimeException
* @throws WrongUsageException
*/
public function getPHPVersionID(): int
{
@@ -336,7 +290,7 @@ abstract class BuilderBase
return intval($match[1]);
}
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
throw new WrongUsageException('PHP version file format is malformed, please remove "./source/php-src" dir and download/extract again');
}
public function getPHPVersion(bool $exception_on_failure = true): string
@@ -354,7 +308,7 @@ abstract class BuilderBase
if (!$exception_on_failure) {
return 'unknown';
}
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
throw new WrongUsageException('PHP version file format is malformed, please remove it and download again');
}
/**
@@ -418,6 +372,9 @@ abstract class BuilderBase
if (($type & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) {
$ls[] = 'frankenphp';
}
if (($type & BUILD_TARGET_CGI) === BUILD_TARGET_CGI) {
$ls[] = 'cgi';
}
return implode(', ', $ls);
}
@@ -501,7 +458,7 @@ abstract class BuilderBase
foreach ($patches as $patch) {
try {
if (!file_exists($patch)) {
throw new RuntimeException("Additional patch script file {$patch} not found!");
throw new WrongUsageException("Additional patch script file {$patch} not found!");
}
logger()->debug('Running additional patch script: ' . $patch);
require $patch;
@@ -514,11 +471,6 @@ abstract class BuilderBase
exit($e->getCode());
} catch (\Throwable $e) {
logger()->critical('Patch script ' . $patch . ' failed to run.');
if ($this->getOption('debug')) {
ExceptionHandler::getInstance()->handle($e);
} else {
logger()->critical('Please check with --debug option to see more details.');
}
throw $e;
}
}
@@ -535,8 +487,7 @@ abstract class BuilderBase
throw new WrongUsageException('FrankenPHP SAPI is only available on Linux and macOS!');
}
// frankenphp needs package go-xcaddy installed
$pkg_dir = PKG_ROOT_PATH . '/go-xcaddy-' . arch2gnu(php_uname('m')) . '-' . osfamily2shortname();
if (!file_exists("{$pkg_dir}/bin/go") || !file_exists("{$pkg_dir}/bin/xcaddy")) {
if (!GoXcaddy::isInstalled()) {
global $argv;
throw new WrongUsageException("FrankenPHP SAPI requires the go-xcaddy package, please install it first: {$argv[0]} install-pkg go-xcaddy");
}

View File

@@ -8,8 +8,7 @@ use SPC\builder\freebsd\BSDBuilder;
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder;
use SPC\builder\windows\WindowsBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\ExceptionHandler;
use SPC\exception\WrongUsageException;
use Symfony\Component\Console\Input\InputInterface;
@@ -20,11 +19,6 @@ class BuilderProvider
{
private static ?BuilderBase $builder = null;
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public static function makeBuilderByInput(InputInterface $input): BuilderBase
{
ini_set('memory_limit', '4G');
@@ -36,12 +30,13 @@ class BuilderProvider
'BSD' => new BSDBuilder($input->getOptions()),
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
};
// bind the builder to ExceptionHandler
ExceptionHandler::bindBuilder(self::$builder);
return self::$builder;
}
/**
* @throws WrongUsageException
*/
public static function getBuilder(): BuilderBase
{
if (self::$builder === null) {

View File

@@ -4,13 +4,13 @@ declare(strict_types=1);
namespace SPC\builder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\EnvironmentException;
use SPC\exception\SPCException;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\FileSystem;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
@@ -24,21 +24,16 @@ class Extension
protected string $source_dir;
/**
* @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");
throw new EnvironmentException("{$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");
throw new EnvironmentException("{$ext_type} extension {$name} is not supported on Windows platform");
}
// set source_dir for builtin
if ($ext_type === 'builtin') {
@@ -46,7 +41,7 @@ class Extension
} elseif ($ext_type === 'external') {
$source = Config::getExt($this->name, 'source');
if ($source === null) {
throw new RuntimeException("{$ext_type} extension {$name} source not found");
throw new ValidationException("{$ext_type} extension {$name} source not found", validation_module: "Extension [{$name}] loader");
}
$source_path = Config::getSource($source)['path'] ?? null;
$source_path = $source_path === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $source_path;
@@ -63,9 +58,6 @@ class Extension
/**
* 获取开启该扩展的 PHP 编译添加的参数
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getConfigureArg(bool $shared = false): string
{
@@ -80,9 +72,6 @@ class Extension
/**
* 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getEnableArg(bool $shared = false): string
{
@@ -112,10 +101,6 @@ class Extension
/**
* 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function checkDependency(): static
{
@@ -236,13 +221,25 @@ class Extension
*/
public function patchBeforeSharedMake(): bool
{
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()], array_map(fn ($l) => $l->getName(), $this->builder->getLibs()));
[$staticLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
'/^(.*_SHARED_LIBADD\s*=.*)$/m',
'$1 ' . trim($staticLibs)
);
$config = (new SPCConfigUtil($this->builder))->getExtensionConfig($this);
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
$lstdcpp = str_contains($sharedLibs, '-l:libstdc++.a') ? '-l:libstdc++.a' : null;
$lstdcpp ??= str_contains($sharedLibs, '-lstdc++') ? '-lstdc++' : '';
$makefileContent = file_get_contents($this->source_dir . '/Makefile');
if (preg_match('/^(.*_SHARED_LIBADD\s*=\s*)(.*)$/m', $makefileContent, $matches)) {
$prefix = $matches[1];
$currentLibs = trim($matches[2]);
$newLibs = trim("{$currentLibs} {$staticLibs} {$lstdcpp}");
$deduplicatedLibs = deduplicate_flags($newLibs);
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
'/^(.*_SHARED_LIBADD\s*=.*)$/m',
$prefix . $deduplicatedLibs
);
}
if ($objs = getenv('SPC_EXTRA_RUNTIME_OBJECTS')) {
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
@@ -259,8 +256,6 @@ class Extension
* i.e.; pdo_pgsql would return:
*
* `-d "extension=pgsql" -d "extension=pdo_pgsql"`
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getSharedExtensionLoadString(): string
{
@@ -268,12 +263,15 @@ class Extension
$order = [];
$resolve = function ($extension) use (&$resolve, &$loaded, &$order) {
if (!$extension instanceof Extension) {
return;
}
if (isset($loaded[$extension->getName()])) {
return;
}
$loaded[$extension->getName()] = true;
foreach ($this->dependencies as $dependency) {
foreach ($extension->dependencies as $dependency) {
$resolve($dependency);
}
@@ -285,6 +283,9 @@ class Extension
$ret = '';
foreach ($order as $ext) {
if ($ext instanceof self && $ext->isBuildShared()) {
if (Config::getExt($ext->getName(), 'type', false) === 'addon') {
continue;
}
if (Config::getExt($ext->getName(), 'zend-extension', false) === true) {
$ret .= " -d \"zend_extension={$ext->getName()}\"";
} else {
@@ -300,20 +301,16 @@ class Extension
return $ret;
}
/**
* @throws RuntimeException
*/
public function runCliCheckUnix(): void
{
// Run compile check if build target is cli
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
// If check failed, throw RuntimeException
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
[$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
if ($ret !== 0) {
throw new RuntimeException(
'extension ' . $this->getName() . ' failed runtime check: php-cli returned ' . $ret . "\n" .
join("\n", $out)
throw new ValidationException(
"extension {$this->getName()} failed compile check: php-cli returned {$ret}",
validation_module: 'Extension ' . $this->getName() . ' sanity check'
);
}
@@ -327,23 +324,21 @@ class Extension
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"');
if ($ret !== 0) {
var_dump($out);
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
throw new ValidationException(
"extension {$this->getName()} failed sanity check. Code: {$ret}, output: " . implode("\n", $out),
validation_module: 'Extension ' . $this->getName() . ' function check'
);
}
}
}
/**
* @throws RuntimeException
*/
public function runCliCheckWindows(): void
{
// Run compile check if build target is cli
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
// If check failed, throw RuntimeException
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n --ri "' . $this->getDistName() . '"', false);
[$ret] = cmd()->execWithResult(BUILD_BIN_PATH . '/php.exe -n --ri "' . $this->getDistName() . '"', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
}
if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))) {
@@ -356,7 +351,10 @@ class Extension
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n -r "' . trim($test) . '"');
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
throw new ValidationException(
"extension {$this->getName()} failed function check",
validation_module: "Extension {$this->getName()} function check"
);
}
}
}
@@ -368,73 +366,54 @@ class Extension
/**
* Build shared extension
*
* @throws WrongUsageException
* @throws RuntimeException
*/
public function buildShared(): void
public function buildShared(array $visited = []): void
{
if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) {
try {
if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) {
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)');
return;
}
if (Config::getExt($this->getName(), 'build-with-php') === true) {
logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)');
logger()->warning('Try deleting your build and source folders and running `spc build`` again.');
return;
}
}
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)');
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
return;
}
if (Config::getExt($this->getName(), 'build-with-php') === true) {
logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)');
logger()->warning('Try deleting your build and source folders and running `spc build`` again.');
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
foreach ($this->dependencies as $dependency) {
if (!$dependency instanceof Extension) {
continue;
}
if (!$dependency->isBuildStatic() && !in_array($dependency->getName(), $visited)) {
logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName());
$dependency->buildShared([...$visited, $this->getName()]);
}
}
if (Config::getExt($this->getName(), 'type') === 'addon') {
return;
}
match (PHP_OS_FAMILY) {
'Darwin', 'Linux' => $this->buildUnixShared(),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
};
} catch (SPCException $e) {
$e->bindExtensionInfo(['extension_name' => $this->getName()]);
throw $e;
}
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
}
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
foreach ($this->dependencies as $dependency) {
if (!$dependency instanceof Extension) {
continue;
}
if (!$dependency->isBuildStatic()) {
logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName());
$dependency->buildShared();
}
}
match (PHP_OS_FAMILY) {
'Darwin', 'Linux' => $this->buildUnixShared(),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
};
}
/**
* Build shared extension for Unix
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @throws \ReflectionException
* @throws \Throwable
*/
public function buildUnixShared(): void
{
$config = (new SPCConfigUtil($this->builder))->config(
[$this->getName()],
array_map(fn ($l) => $l->getName(), $this->getLibraryDependencies(recursive: true)),
$this->builder->getOption('with-suggested-exts'),
$this->builder->getOption('with-suggested-libs'),
);
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
$postStatic = PHP_OS_FAMILY === 'Darwin' ? '' : ' -Wl,--end-group ';
$env = [
'CFLAGS' => $config['cflags'],
'CXXFLAGS' => $config['cflags'],
'LDFLAGS' => $config['ldflags'],
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
];
if (ToolchainManager::getToolchainClass() === ZigToolchain::class && SPCTarget::getTargetOS() === 'Linux') {
$env['SPC_COMPILER_EXTRA'] = '-lstdc++';
}
$env = $this->getSharedExtensionEnv();
if ($this->patchBeforeSharedPhpize()) {
logger()->info("Extension [{$this->getName()}] patched before shared phpize");
}
@@ -449,13 +428,15 @@ class Extension
logger()->info("Extension [{$this->getName()}] patched before shared configure");
}
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
shell()->cd($this->source_dir)
->setEnv($env)
->appendEnv($this->getExtraEnv())
->exec(
'./configure ' . $this->getUnixConfigureArg(true) .
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
'--enable-shared --disable-static'
"--enable-shared --disable-static {$phpvars}"
);
if ($this->patchBeforeSharedMake()) {
@@ -468,6 +449,15 @@ class Extension
->exec('make clean')
->exec('make -j' . $this->builder->concurrency)
->exec('make install');
// process *.so file
$soFile = BUILD_MODULES_PATH . '/' . $this->getName() . '.so';
if (!file_exists($soFile)) {
throw new ValidationException("extension {$this->getName()} build failed: {$soFile} not found", validation_module: "Extension {$this->getName()} build");
}
/** @var UnixBuilderBase $builder */
$builder = $this->builder;
$builder->deployBinary($soFile, $soFile, false);
}
/**
@@ -507,34 +497,80 @@ class Extension
}
/**
* @throws RuntimeException
* Get the library dependencies that current extension depends on.
*
* @param bool $recursive Whether it includes dependencies recursively
*/
public 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 (!array_key_exists($depdepName, $deps)) {
$deps[$depdepName] = $depdep;
++$added;
}
}
if (!array_key_exists($depName, $deps)) {
$deps[$depName] = $dep;
}
}
}
return $deps;
}
/**
* Returns the environment variables a shared extension needs to be built.
* CFLAGS, CXXFLAGS, LDFLAGS and so on.
*/
protected function getSharedExtensionEnv(): array
{
$config = (new SPCConfigUtil($this->builder))->getExtensionConfig($this);
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
$postStatic = PHP_OS_FAMILY === 'Darwin' ? '' : ' -Wl,--end-group ';
return [
'CFLAGS' => $config['cflags'],
'CXXFLAGS' => $config['cflags'],
'LDFLAGS' => $config['ldflags'],
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
];
}
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}");
throw new WrongUsageException("extension {$this->name} requires library {$name}");
}
logger()->info("enabling {$this->name} without library {$name}");
} else {
$this->dependencies[] = $depLib;
$this->dependencies[$name] = $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}");
throw new WrongUsageException("{$this->name} requires extension {$name} which is not included");
}
logger()->info("enabling {$this->name} without extension {$name}");
} else {
$this->dependencies[] = $depExt;
$this->dependencies[$name] = $depExt;
}
}
@@ -569,37 +605,4 @@ class Extension
}
return [trim($staticLibString), trim($sharedLibString)];
}
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;
}
}
}
if (array_key_exists(0, $deps)) {
$zero = [0 => $deps[0]];
unset($deps[0]);
return $zero + $deps;
}
return $deps;
}
}

View File

@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace SPC\builder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\SPCException;
use SPC\exception\SPCInternalException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\Downloader;
@@ -27,23 +27,17 @@ abstract class LibraryBase
protected bool $patched = false;
/**
* @throws RuntimeException
*/
public function __construct(?string $source_dir = null)
{
if (static::NAME === 'unknown') {
throw new RuntimeException('no unknown!!!!!');
throw new SPCInternalException('Please set the NAME constant in ' . static::class);
}
$this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . Config::getLib(static::NAME, 'source'));
$this->source_dir = $source_dir ?? (SOURCE_PATH . DIRECTORY_SEPARATOR . Config::getLib(static::NAME, 'source'));
}
/**
* Try to install or build this library.
* @param bool $force If true, force install or build
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @param bool $force If true, force install or build
*/
public function setup(bool $force = false): int
{
@@ -107,10 +101,6 @@ abstract class LibraryBase
/**
* Calculate dependencies for current library.
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function calcDependency(): void
{
@@ -131,9 +121,6 @@ abstract class LibraryBase
/**
* Get config static libs.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getStaticLibs(): array
{
@@ -142,9 +129,6 @@ abstract class LibraryBase
/**
* Get config headers.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getHeaders(): array
{
@@ -153,19 +137,12 @@ abstract class LibraryBase
/**
* Get binary files.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getBinaryFiles(): array
{
return Config::getLib(static::NAME, 'bin', []);
}
/**
* @throws WrongUsageException
* @throws FileSystemException
*/
public function tryInstall(array $lock, bool $force_install = false): int
{
$install_file = $lock['filename'];
@@ -177,7 +154,7 @@ abstract class LibraryBase
FileSystem::extractPackage($install_file, $lock['source_type'], DOWNLOAD_PATH . '/' . $install_file, BUILD_ROOT_PATH);
$this->install();
return LIB_STATUS_OK;
} catch (FileSystemException|RuntimeException $e) {
} catch (SPCException $e) {
logger()->error('Failed to extract pre-built library [' . static::NAME . ']: ' . $e->getMessage());
return LIB_STATUS_INSTALL_FAILED;
}
@@ -194,10 +171,6 @@ abstract class LibraryBase
* 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
{
@@ -319,8 +292,6 @@ abstract class LibraryBase
/**
* Build this library.
*
* @throws RuntimeException
*/
abstract protected function build();
@@ -333,7 +304,7 @@ abstract class LibraryBase
}
$replace_items = json_decode(file_get_contents($replace_item_file), true);
if (!is_array($replace_items)) {
throw new RuntimeException('Invalid placeholder file: ' . $replace_item_file);
throw new SPCInternalException("Invalid placeholder file: {$replace_item_file}");
}
$placeholders = get_pack_replace();
// replace placeholders in BUILD_ROOT_PATH
@@ -351,8 +322,6 @@ abstract class LibraryBase
/**
* Add lib dependency
*
* @throws RuntimeException
*/
protected function addLibraryDependency(string $name, bool $optional = false): void
{
@@ -362,7 +331,7 @@ abstract class LibraryBase
return;
}
if (!$optional) {
throw new RuntimeException(static::NAME . " requires library {$name}");
throw new WrongUsageException(static::NAME . " requires library {$name} but it is not included");
}
logger()->debug('enabling ' . static::NAME . " without {$name}");
}

View File

@@ -6,18 +6,12 @@ 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) . ' ' : '';

View File

@@ -8,17 +8,13 @@ use SPC\builder\Extension;
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder;
use SPC\builder\windows\WindowsBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\exception\PatchException;
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');
@@ -46,10 +42,6 @@ class curl extends Extension
return true;
}
/**
* @throws FileSystemException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool
{
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
@@ -105,7 +97,7 @@ class curl extends Extension
);
if ($patched === null) {
throw new \RuntimeException('Failed to patch config.m4 due to a regex error');
throw new PatchException('shared extension curl patcher', 'Failed to patch config.m4 due to a regex error');
}
FileSystem::writeFile($file, $patched);

View File

@@ -12,7 +12,7 @@ class dba extends Extension
{
public function getUnixConfigureArg(bool $shared = false): string
{
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH) : '';
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : '';
return '--enable-dba' . ($shared ? '=shared' : '') . $qdbm;
}

View File

@@ -5,16 +5,12 @@ 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('dom')]
class dom extends Extension
{
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-dom' . ($shared ? '=shared' : '');

View File

@@ -5,16 +5,12 @@ 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('ev')]
class ev extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
/*

View File

@@ -6,7 +6,6 @@ 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;
@@ -27,18 +26,12 @@ class event extends Extension
return $arg;
}
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString());
return true;
}
/**
* @throws FileSystemException
*/
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();

View File

@@ -6,29 +6,24 @@ 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('gettext')]
class gettext extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
if ($this->builder instanceof MacOSBuilder) {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gettext/config.m4', 'AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB(intl');
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/gettext/config.m4',
['AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB([$GETTEXT_CHECK_IN_LIB'],
['AC_CHECK_LIB(intl', 'AC_CHECK_LIB([intl'] // new php versions use a bracket
);
}
return true;
}
/**
* @throws WrongUsageException
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
if ($this->builder instanceof MacOSBuilder) {

View File

@@ -5,16 +5,12 @@ 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')) {

View File

@@ -6,6 +6,7 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\windows\WindowsBuilder;
use SPC\exception\ValidationException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager;
@@ -18,7 +19,7 @@ class grpc extends Extension
public function patchBeforeBuildconf(): bool
{
if ($this->builder instanceof WindowsBuilder) {
throw new \RuntimeException('grpc extension does not support windows yet');
throw new ValidationException('grpc extension does not support windows yet');
}
if (file_exists(SOURCE_PATH . '/php-src/ext/grpc')) {
return false;
@@ -27,7 +28,7 @@ class grpc extends Extension
if (is_dir($this->source_dir . '/src/php/ext/grpc')) {
shell()->exec('ln -s ' . $this->source_dir . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
} else {
throw new \RuntimeException('Cannot find grpc source code');
throw new ValidationException('Cannot find grpc source code in ' . $this->source_dir . '/src/php/ext/grpc');
}
if (SPCTarget::getTargetOS() === 'Darwin') {
FileSystem::replaceFileRegex(
@@ -42,7 +43,7 @@ class grpc extends Extension
public function patchBeforeConfigure(): bool
{
$util = new SPCConfigUtil($this->builder, ['libs_only_deps' => true]);
$config = $util->config(['grpc']);
$config = $util->getExtensionConfig($this);
$libs = $config['libs'];
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lgrpc', $libs);
return true;
@@ -55,4 +56,11 @@ class grpc extends Extension
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
return true;
}
protected function getSharedExtensionEnv(): array
{
$env = parent::getSharedExtensionEnv();
$env['CPPFLAGS'] = $env['CXXFLAGS'] . ' -Wno-attributes';
return $env;
}
}

View File

@@ -19,7 +19,7 @@ class imagick extends Extension
protected function splitLibsIntoStaticAndShared(string $allLibs): array
{
[$static, $shared] = parent::splitLibsIntoStaticAndShared($allLibs);
if (str_contains(getenv('PATH'), 'rh/devtoolset-10')) {
if (str_contains(getenv('PATH'), 'rh/devtoolset') || str_contains(getenv('PATH'), 'rh/gcc-toolset')) {
$static .= ' -l:libstdc++.a';
$shared = str_replace('-lstdc++', '', $shared);
}

View File

@@ -24,9 +24,6 @@ class imap extends Extension
return false;
}
/**
* @throws WrongUsageException
*/
public function validate(): void
{
if ($this->builder->getOption('enable-zts')) {

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('mbregex')]
@@ -16,11 +16,6 @@ class mbregex extends Extension
return 'mbstring';
}
public function getConfigureArg(bool $shared = false): string
{
return '';
}
/**
* mbregex is not an extension, we need to overwrite the default check.
*/
@@ -29,7 +24,7 @@ class mbregex extends Extension
$sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? '-d "extension_dir=' . BUILD_MODULES_PATH . '" -d "extension=mbstring"' : '';
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --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 !');
throw new ValidationException("Extension {$this->getName()} failed compile check: compiled php-cli mbstring extension does not contain regex !");
}
}
@@ -37,11 +32,11 @@ class mbregex extends Extension
{
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring"', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
throw new ValidationException("extension {$this->getName()} failed compile check: compiled php-cli does not contain mbstring !");
}
$out = implode("\n", $out);
if (!str_contains($out, 'regex')) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
throw new ValidationException("extension {$this->getName()} failed compile check: compiled php-cli mbstring extension does not contain regex !");
}
}
}

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
@@ -17,9 +16,6 @@ class memcache extends Extension
return '--enable-memcache' . ($shared ? '=shared' : '') . ' --with-zlib-dir=' . BUILD_ROOT_PATH;
}
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(

View File

@@ -17,6 +17,10 @@ class memcached extends Extension
'--with-libmemcached-dir=' . BUILD_ROOT_PATH . ' ' .
'--disable-memcached-sasl ' .
'--enable-memcached-json ' .
($this->builder->getLib('zstd') ? '--with-zstd ' : '') .
($this->builder->getExt('igbinary') ? '--enable-memcached-igbinary ' : '') .
($this->builder->getExt('session') ? '--enable-memcached-session ' : '') .
($this->builder->getExt('msgpack') ? '--enable-memcached-msgpack ' : '') .
'--with-system-fastlz';
}
}

View File

@@ -12,9 +12,9 @@ class mongodb extends Extension
{
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = ' --enable-mongodb ';
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';
$arg .= ' --with-mongodb-sasl=no ';
$arg .= ' --with-mongodb-sasl=no ';
if ($this->builder->getLib('openssl')) {
$arg .= '--with-mongodb-ssl=openssl';
}
@@ -22,6 +22,6 @@ class mongodb extends Extension
$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;
return clean_spaces($arg);
}
}

View File

@@ -5,18 +5,14 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\SourcePatcher;
use SPC\util\CustomExt;
use SPC\util\SPCTarget;
#[CustomExt('opcache')]
class opcache extends Extension
{
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
@@ -51,7 +47,18 @@ class opcache extends Extension
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-opcache';
$phpVersionID = $this->builder->getPHPVersionID();
$opcache_jit = ' --enable-opcache-jit';
if ((SPCTarget::getTargetOS() === 'Linux' &&
SPCTarget::getLibc() === 'musl' &&
$this->builder->getOption('enable-zts') &&
arch2gnu(php_uname('m')) === 'x86_64' &&
$phpVersionID < 80500) ||
$this->builder->getOption('disable-opcache-jit')
) {
$opcache_jit = ' --disable-opcache-jit';
}
return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit;
}
public function getDistName(): string

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager;
@@ -15,7 +16,7 @@ class opentelemetry extends Extension
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The opentelemetry extension requires PHP 8.0 or later');
throw new ValidationException('The opentelemetry extension requires PHP 8.0 or later');
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('password-argon2')]
@@ -20,7 +20,7 @@ class password_argon2 extends Extension
{
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
throw new ValidationException('extension ' . $this->getName() . ' failed sanity check', validation_module: 'password_argon2 function check');
}
}

View File

@@ -5,16 +5,12 @@ 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(

View File

@@ -5,20 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('pgsql')]
class pgsql extends Extension
{
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(
@@ -29,10 +21,6 @@ class pgsql extends Extension
return true;
}
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
if ($this->builder->getPHPVersionID() >= 80400) {
@@ -46,10 +34,6 @@ class pgsql extends Extension
return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
}
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getWindowsConfigureArg(bool $shared = false): string
{
if ($this->builder->getPHPVersionID() >= 80400) {

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('protobuf')]
@@ -13,12 +14,12 @@ class protobuf extends Extension
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The latest protobuf extension requires PHP 8.0 or later');
throw new ValidationException('The latest protobuf extension requires PHP 8.0 or later');
}
$grpc = $this->builder->getExt('grpc');
// protobuf conflicts with grpc
if ($grpc?->isBuildStatic()) {
throw new \RuntimeException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
throw new ValidationException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
}
}
}

View File

@@ -6,16 +6,12 @@ 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('rar')]
class rar extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
// workaround for newer Xcode clang (>= 15.0)

View File

@@ -7,6 +7,7 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\SPCConfigUtil;
#[CustomExt('rdkafka')]
class rdkafka extends Extension
@@ -15,6 +16,7 @@ class rdkafka extends Extension
{
FileSystem::replaceFileStr("{$this->source_dir}/config.m4", "-L\$RDKAFKA_DIR/\$PHP_LIBDIR -lm\n", "-L\$RDKAFKA_DIR/\$PHP_LIBDIR -lm \$RDKAFKA_LIBS\n");
FileSystem::replaceFileStr("{$this->source_dir}/config.m4", "-L\$RDKAFKA_DIR/\$PHP_LIBDIR -lm\"\n", '-L$RDKAFKA_DIR/$PHP_LIBDIR -lm $RDKAFKA_LIBS"');
FileSystem::replaceFileStr("{$this->source_dir}/config.m4", 'PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,', 'AC_CHECK_LIB([$LIBNAME], [$LIBSYMBOL],');
return true;
}
@@ -37,8 +39,7 @@ class rdkafka extends Extension
public function getUnixConfigureArg(bool $shared = false): string
{
$pkgconf_libs = shell()->execWithResult('pkg-config --libs --static rdkafka')[1];
$pkgconf_libs = trim(implode('', $pkgconf_libs));
return '--with-rdkafka=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . ' RDKAFKA_LIBS="' . $pkgconf_libs . '"';
$pkgconf_libs = (new SPCConfigUtil($this->builder, ['no_php' => true, 'libs_only_deps' => true]))->getExtensionConfig($this);
return '--with-rdkafka=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . " RDKAFKA_LIBS=\"{$pkgconf_libs['libs']}\"";
}
}

View File

@@ -5,16 +5,13 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\exception\ValidationException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('readline')]
class readline extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(
@@ -27,12 +24,7 @@ class readline extends Extension
public function getUnixConfigureArg(bool $shared = false): string
{
$enable = '--without-libedit --with-readline=' . BUILD_ROOT_PATH;
if ($this->builder->getPHPVersionID() < 84000) {
// the check uses `char rl_pending_input()` instead of `extern int rl_pending_input`, which makes LTO fail
$enable .= ' ac_cv_lib_readline_rl_pending_input=yes';
}
return $enable;
return '--with-libedit --without-readline';
}
public function buildUnixShared(): void
@@ -43,4 +35,13 @@ class readline extends Extension
}
parent::buildUnixShared();
}
public function runCliCheckUnix(): void
{
parent::runCliCheckUnix();
[$ret, $out] = shell()->execWithResult('printf "exit\n" | ' . BUILD_BIN_PATH . '/php -a');
if ($ret !== 0 || !str_contains(implode("\n", $out), 'Interactive shell')) {
throw new ValidationException("readline extension failed sanity check. Code: {$ret}, output: " . implode("\n", $out));
}
}
}

View File

@@ -16,9 +16,11 @@ class redis extends Extension
if ($this->isBuildStatic()) {
$arg .= $this->builder->getExt('session')?->isBuildStatic() ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= $this->builder->getExt('igbinary')?->isBuildStatic() ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
$arg .= $this->builder->getExt('msgpack')?->isBuildStatic() ? ' --enable-redis-msgpack' : ' --disable-redis-msgpack';
} else {
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
$arg .= $this->builder->getExt('msgpack') ? ' --enable-redis-msgpack' : ' --disable-redis-msgpack';
}
if ($this->builder->getLib('zstd')) {
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';

View File

@@ -6,6 +6,8 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\CustomExt;
#[CustomExt('simdjson')]
@@ -17,7 +19,7 @@ class simdjson extends Extension
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/ext/simdjson/config.m4',
'/php_version=(`.*`)$/m',
'php_version=' . strval($php_ver)
'php_version=' . $php_ver
);
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/simdjson/config.m4',
@@ -31,4 +33,18 @@ class simdjson extends Extension
);
return true;
}
public function getSharedExtensionEnv(): array
{
$env = parent::getSharedExtensionEnv();
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
$extra = getenv('SPC_COMPILER_EXTRA');
if (!str_contains((string) $extra, '-lstdc++')) {
f_putenv('SPC_COMPILER_EXTRA=' . clean_spaces($extra . ' -lstdc++'));
}
$env['CFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
$env['CXXFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
}
return $env;
}
}

View File

@@ -6,16 +6,12 @@ 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(

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\PkgConfigUtil;
#[CustomExt('snmp')]
class snmp extends Extension
{
public function patchBeforeBuildconf(): bool
{
// Overwrite m4 config using newer PHP version
if ($this->builder->getPHPVersionID() < 80400) {
FileSystem::copy(ROOT_DIR . '/src/globals/extra/snmp-ext-config-old.m4', "{$this->source_dir}/config.m4");
}
$libs = implode(' ', PkgConfigUtil::getLibsArray('netsnmp'));
FileSystem::replaceFileStr(
"{$this->source_dir}/config.m4",
'PHP_EVAL_LIBLINE([$SNMP_LIBS], [SNMP_SHARED_LIBADD])',
"SNMP_LIBS=\"{$libs}\"\nPHP_EVAL_LIBLINE([\$SNMP_LIBS], [SNMP_SHARED_LIBADD])"
);
return true;
}
}

View File

@@ -13,7 +13,7 @@ class spx extends Extension
{
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-spx' . ($shared ? '=shared' : '');
$arg = '--enable-SPX' . ($shared ? '=shared' : '');
if ($this->builder->getLib('zlib') !== null) {
$arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH;
}
@@ -29,4 +29,20 @@ class spx extends Extension
);
return true;
}
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(
$this->source_dir . '/config.m4',
'CFLAGS="$CFLAGS -Werror -Wall -O3 -pthread -std=gnu90"',
'CFLAGS="$CFLAGS -pthread"'
);
FileSystem::replaceFileStr(
$this->source_dir . '/src/php_spx.h',
"extern zend_module_entry spx_module_entry;\n",
"extern zend_module_entry spx_module_entry;;\n#define phpext_spx_ptr &spx_module_entry\n"
);
FileSystem::copy($this->source_dir . '/src/php_spx.h', $this->source_dir . '/php_spx.h');
return true;
}
}

View File

@@ -5,16 +5,12 @@ 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(

View File

@@ -8,6 +8,8 @@ use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
#[CustomExt('swoole')]
class swoole extends Extension
@@ -43,32 +45,43 @@ class swoole extends Extension
public function getUnixConfigureArg(bool $shared = false): string
{
// enable swoole
$arg = '--enable-swoole';
$arg = '--enable-swoole' . ($shared ? '=shared' : '');
// commonly-used feature: coroutine-time, disable-thread-context
$arg .= ' --enable-swoole-coro-time --disable-thread-context';
// commonly used feature: coroutine-time
$arg .= ' --enable-swoole-coro-time --with-pic';
// required feature: curl, openssl (but curl hook is buggy for php 8.0)
$arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context';
// required features: curl, openssl (but curl hook is buggy for php 8.0)
$arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl';
$arg .= ' --enable-openssl';
// additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature)
// additional features that only require libraries
$arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : '';
if (!$shared) {
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
}
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
$arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : '';
$arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : '';
$arg .= $this->builder->getLib('liburing') ? ' --enable-iouring' : '';
$arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : '';
// additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc.
// so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support)
$arg .= $this->builder->getExt('swoole-hook-pgsql') ? '' : ' --disable-swoole-pgsql';
// enable additional features that require the pdo extension, but conflict with pdo_* extensions
// to make sure everything works as it should, this is done in fake addon extensions
$arg .= $this->builder->getExt('swoole-hook-pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql';
$arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-mysqlnd' : ' --disable-mysqlnd';
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite';
if ($this->builder->getExt('swoole-hook-odbc')) {
$config = (new SPCConfigUtil($this->builder))->getLibraryConfig($this->builder->getLib('unixodbc'));
$arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"';
}
// enable this feature , need remove pdo_sqlite
// more info : https://wenda.swoole.com/detail/109023
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? '' : ' --disable-swoole-sqlite';
if ($this->getExtVersion() >= '6.1.0') {
$arg .= ' --enable-swoole-stdext';
}
if (SPCTarget::getTargetOS() === 'Darwin') {
$arg .= ' ac_cv_lib_pthread_pthread_barrier_init=no';
}
// enable this feature , need stop pdo_*
// $arg .= $this->builder->getLib('unixodbc') ? ' --with-swoole-odbc=unixODBC,' : ' ';
return $arg;
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('swoole-hook-mysql')]
@@ -16,26 +16,15 @@ class swoole_hook_mysql extends Extension
return 'swoole';
}
public function getUnixConfigureArg(bool $shared = false): string
{
// pdo_mysql doesn't need to be disabled
// enable swoole-hook-mysql will enable mysqli, pdo, pdo_mysql, we don't need to add any additional options
return '';
}
public function runCliCheckUnix(): void
{
// skip if not enable swoole
if ($this->builder->getExt('swoole') === null) {
return;
}
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false);
$out = implode('', $out);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: 'extension swoole_hook_mysql sanity check');
}
if (!str_contains($out, 'mysqlnd')) {
throw new RuntimeException('swoole mysql hook is not enabled correctly.');
throw new ValidationException('swoole mysql hook is not enabled correctly.', validation_module: 'Extension swoole mysql hook availability check');
}
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
#[CustomExt('swoole-hook-odbc')]
class swoole_hook_odbc extends Extension
{
public function getDistName(): string
{
return 'swoole';
}
public function validate(): void
{
// pdo_pgsql need to be disabled
if ($this->builder->getExt('pdo_odbc')?->isBuildStatic()) {
throw new WrongUsageException('swoole-hook-odbc provides pdo_odbc, if you enable odbc hook for swoole, you must remove pdo_odbc extension.');
}
}
public function runCliCheckUnix(): void
{
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
$out = implode('', $out);
if ($ret !== 0) {
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
}
if (!str_contains($out, 'coroutine_odbc')) {
throw new ValidationException('swoole odbc hook is not enabled correctly.', validation_module: 'Extension swoole odbc hook availability check');
}
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
@@ -20,31 +20,27 @@ class swoole_hook_pgsql extends Extension
public function validate(): void
{
// pdo_pgsql need to be disabled
if ($this->builder->getExt('pdo_pgsql') !== null) {
if ($this->builder->getExt('pdo_pgsql')?->isBuildStatic()) {
throw new WrongUsageException('swoole-hook-pgsql provides pdo_pgsql, if you enable pgsql hook for swoole, you must remove pdo_pgsql extension.');
}
}
public function getUnixConfigureArg(bool $shared = false): string
{
// enable swoole pgsql hook
return '--enable-swoole-pgsql';
}
public function runCliCheckUnix(): void
{
// skip if not enable swoole
if ($this->builder->getExt('swoole') === null) {
return;
}
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
$out = implode('', $out);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
throw new ValidationException(
"extension {$this->getName()} failed sanity check: php-cli returned {$ret}",
validation_module: 'Extension swoole-hook-pgsql sanity check'
);
}
if (!str_contains($out, 'coroutine_pgsql')) {
throw new RuntimeException('swoole pgsql hook is not enabled correctly.');
throw new ValidationException(
'swoole pgsql hook is not enabled correctly.',
validation_module: 'Extension swoole pgsql hook availability check'
);
}
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
@@ -20,31 +20,21 @@ class swoole_hook_sqlite extends Extension
public function validate(): void
{
// pdo_pgsql need to be disabled
if ($this->builder->getExt('pdo_sqlite') !== null) {
if ($this->builder->getExt('pdo_sqlite')?->isBuildStatic()) {
throw new WrongUsageException('swoole-hook-sqlite provides pdo_sqlite, if you enable sqlite hook for swoole, you must remove pdo_sqlite extension.');
}
}
public function getUnixConfigureArg(bool $shared = false): string
{
// enable swoole pgsql hook
return '--enable-swoole-sqlite';
}
public function runCliCheckUnix(): void
{
// skip if not enable swoole
if ($this->builder->getExt('swoole') === null) {
return;
}
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
$out = implode('', $out);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
}
if (!str_contains($out, 'coroutine_sqlite')) {
throw new RuntimeException('swoole sqlite hook is not enabled correctly.');
throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check');
}
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('swow')]
@@ -14,7 +14,7 @@ class swow extends Extension
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new RuntimeException('The latest swow extension requires PHP 8.0 or later');
throw new ValidationException('The latest swow extension requires PHP 8.0 or later');
}
}
@@ -26,9 +26,6 @@ class swow extends Extension
return $arg;
}
/**
* @throws RuntimeException
*/
public function patchBeforeBuildconf(): bool
{
if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) {

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
@@ -14,7 +15,7 @@ class uv extends Extension
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later');
throw new ValidationException('The latest uv extension requires PHP 8.0 or later');
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\SPCInternalException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
@@ -16,9 +16,6 @@ use SPC\util\CustomExt;
#[CustomExt('simplexml')]
class xml extends Extension
{
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = match ($this->name) {
@@ -27,7 +24,7 @@ class xml extends Extension
'xmlreader' => '--enable-xmlreader',
'xmlwriter' => '--enable-xmlwriter',
'simplexml' => '--enable-simplexml',
default => throw new RuntimeException('Not accept non-xml extension'),
default => throw new SPCInternalException('Not accept non-xml extension'),
};
$arg .= ($shared ? '=shared' : '') . ' --with-libxml="' . BUILD_ROOT_PATH . '"';
return $arg;
@@ -47,7 +44,7 @@ class xml extends Extension
'xmlreader' => '--enable-xmlreader',
'xmlwriter' => '--enable-xmlwriter',
'simplexml' => '--with-simplexml',
default => throw new RuntimeException('Not accept non-xml extension'),
default => throw new SPCInternalException('Not accept non-xml extension'),
};
$arg .= ' --with-libxml';
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('zip')]
class zip extends Extension
{
public function getUnixConfigureArg(bool $shared = false): string
{
return !$shared ? '--with-zip=' . BUILD_ROOT_PATH : '--enable-zip=shared';
}
}

View File

@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\freebsd;
use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\store\SourcePatcher;
@@ -16,11 +14,6 @@ class BSDBuilder extends UnixBuilderBase
/** @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;
@@ -32,10 +25,6 @@ class BSDBuilder extends UnixBuilderBase
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'));
@@ -56,10 +45,7 @@ class BSDBuilder extends UnixBuilderBase
/**
* Just start to build statically linked php binary
*
* @param int $build_target build target
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @param int $build_target build target
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{
@@ -132,6 +118,11 @@ class BSDBuilder extends UnixBuilderBase
}
$this->buildEmbed();
}
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
if (!empty($shared_extensions)) {
logger()->info('Building shared extensions ...');
$this->buildSharedExts();
}
if ($enableFrankenphp) {
logger()->info('building frankenphp');
$this->buildFrankenphp();
@@ -148,9 +139,6 @@ class BSDBuilder extends UnixBuilderBase
/**
* Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
protected function buildCli(): void
{
@@ -165,15 +153,11 @@ class BSDBuilder extends UnixBuilderBase
if (!$this->getOption('no-strip', false)) {
$shell->exec('strip sapi/cli/php');
}
$this->deployBinary(BUILD_TARGET_CLI);
$this->deploySAPIBinary(BUILD_TARGET_CLI);
}
/**
* Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function buildMicro(): void
{
@@ -200,7 +184,7 @@ class BSDBuilder extends UnixBuilderBase
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-unneeded micro.sfx');
}
$this->deployBinary(BUILD_TARGET_MICRO);
$this->deploySAPIBinary(BUILD_TARGET_MICRO);
if ($this->phar_patched) {
SourcePatcher::unpatchMicroPhar();
@@ -209,9 +193,6 @@ class BSDBuilder extends UnixBuilderBase
/**
* Build fpm sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
protected function buildFpm(): void
{
@@ -225,13 +206,11 @@ class BSDBuilder extends UnixBuilderBase
if (!$this->getOption('no-strip', false)) {
$shell->exec('strip sapi/fpm/php-fpm');
}
$this->deployBinary(BUILD_TARGET_FPM);
$this->deploySAPIBinary(BUILD_TARGET_FPM);
}
/**
* Build embed sapi
*
* @throws RuntimeException
*/
protected function buildEmbed(): void
{

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\freebsd;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
use SPC\exception\EnvironmentException;
use SPC\exception\WrongUsageException;
class SystemUtil
@@ -15,14 +15,15 @@ class SystemUtil
/**
* 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');
throw new EnvironmentException(
'Failed to get cpu count from FreeBSD sysctl',
'Please ensure you are running this command on a FreeBSD system and have the sysctl command available.'
);
}
return (int) $output[0];
@@ -31,9 +32,8 @@ class SystemUtil
/**
* Get Target Arch CFlags
*
* @param string $arch Arch Name
* @return string return Arch CFlags string
* @throws WrongUsageException
* @param string $arch Arch Name
* @return string return Arch CFlags string
*/
public static function getArchCFlags(string $arch): string
{

View File

@@ -22,19 +22,11 @@ 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;

View File

@@ -5,9 +5,10 @@ declare(strict_types=1);
namespace SPC\builder\linux;
use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\PatchException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\DirDiff;
use SPC\store\FileSystem;
use SPC\store\SourcePatcher;
use SPC\util\GlobalEnvManager;
@@ -19,10 +20,6 @@ class LinuxBuilder extends UnixBuilderBase
/** @var bool Micro patch phar flag */
private bool $phar_patched = false;
/**
* @throws FileSystemException
* @throws WrongUsageException
*/
public function __construct(array $options = [])
{
$this->options = $options;
@@ -45,10 +42,7 @@ class LinuxBuilder extends UnixBuilderBase
/**
* Build PHP from source.
*
* @param int $build_target Build target, use `BUILD_TARGET_*` constants
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
* @param int $build_target Build target, use `BUILD_TARGET_*` constants
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{
@@ -72,10 +66,7 @@ class LinuxBuilder extends UnixBuilderBase
// if opcache_jit is enabled for 8.5 or opcache enabled,
// we need to disable undefined behavior sanitizer.
f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
} elseif ($opcache_jit) {
$opcache_jit = false;
}
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit ' : '--disable-opcache-jit ';
if ($this->getOption('enable-zts', false)) {
$maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : '';
@@ -95,16 +86,19 @@ class LinuxBuilder extends UnixBuilderBase
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
$enableCgi = ($build_target & BUILD_TARGET_CGI) === BUILD_TARGET_CGI;
// prepare build php envs
// $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
$php_configure_env = SystemUtil::makeEnvVarString([
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'),
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag,
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
]);
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
if ($embed_type !== 'static' && SPCTarget::isStatic()) {
throw new WrongUsageException(
@@ -113,22 +107,22 @@ class LinuxBuilder extends UnixBuilderBase
);
}
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
$php_configure_env . ' ' .
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') .
($enableFpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
$config_file_path .
$config_file_scan_dir .
$opcache_jit_arg .
$json_74 .
$zts .
$maxExecutionTimers .
$this->makeStaticExtensionArgs() . ' '
);
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
$php_configure_env . ' ' .
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') .
($enableFpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
($enableCgi ? '--enable-cgi ' : '--disable-cgi ') .
$config_file_path .
$config_file_scan_dir .
$json_74 .
$zts .
$maxExecutionTimers .
$phpvars . ' ' .
$this->makeStaticExtensionArgs() . ' '
));
$this->emitPatchPoint('before-php-make');
SourcePatcher::patchBeforeMake($this);
@@ -143,6 +137,10 @@ class LinuxBuilder extends UnixBuilderBase
logger()->info('building fpm');
$this->buildFpm();
}
if ($enableCgi) {
logger()->info('building cgi');
$this->buildCgi();
}
if ($enableMicro) {
logger()->info('building micro');
$this->buildMicro();
@@ -158,6 +156,18 @@ class LinuxBuilder extends UnixBuilderBase
logger()->info('building frankenphp');
$this->buildFrankenphp();
}
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
if (!empty($shared_extensions)) {
if (SPCTarget::isStatic()) {
throw new WrongUsageException(
"You're building against musl libc statically (the default on Linux), but you're trying to build shared extensions.\n" .
'Static musl libc does not implement `dlopen`, so your php binary is not able to load shared extensions.' . "\n" .
'Either use SPC_LIBC=glibc to link against glibc on a glibc OS, or use SPC_TARGET="native-native-musl -dynamic" to link against musl libc dynamically using `zig cc`.'
);
}
logger()->info('Building shared extensions...');
$this->buildSharedExts();
}
}
public function testPHP(int $build_target = BUILD_TARGET_NONE)
@@ -168,109 +178,157 @@ class LinuxBuilder extends UnixBuilderBase
/**
* Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
protected function buildCli(): void
{
if ($this->getExt('readline') && SPCTarget::isStatic()) {
SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src');
}
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli");
->exec("make {$concurrency} {$vars} cli");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-unneeded php');
}
if ($this->getOption('with-upx-pack')) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')
->exec(getenv('UPX_EXEC') . ' --best php');
if ($this->getExt('readline') && SPCTarget::isStatic()) {
SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src', true);
}
$this->deployBinary(BUILD_TARGET_CLI);
$this->deploySAPIBinary(BUILD_TARGET_CLI);
}
protected function buildCgi(): void
{
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make {$concurrency} {$vars} cgi");
$this->deploySAPIBinary(BUILD_TARGET_CGI);
}
/**
* Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected 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::patchMicroPhar($this->getPHPVersionID());
}
try {
if ($this->getExt('phar')) {
$this->phar_patched = true;
SourcePatcher::patchMicroPhar($this->getPHPVersionID());
}
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
$vars = $this->getMakeExtraVars();
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
$vars = $this->getMakeExtraVars();
// patch fake cli for micro
$vars['EXTRA_CFLAGS'] .= $enable_fake_cli;
$vars = SystemUtil::makeEnvVarString($vars);
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
// patch fake cli for micro
$vars['EXTRA_CFLAGS'] .= $enable_fake_cli;
$vars = SystemUtil::makeEnvVarString($vars);
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} micro");
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make {$concurrency} {$vars} micro");
$this->processMicroUPX();
// deploy micro.sfx
$dst = $this->deploySAPIBinary(BUILD_TARGET_MICRO);
$this->deployBinary(BUILD_TARGET_MICRO);
if ($this->phar_patched) {
SourcePatcher::unpatchMicroPhar();
// patch after UPX-ed micro.sfx
$this->processUpxedMicroSfx($dst);
} finally {
if ($this->phar_patched) {
SourcePatcher::unpatchMicroPhar();
}
}
}
/**
* Build fpm sapi
*
* @throws FileSystemException
* @throws RuntimeException
*/
protected function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} fpm");
->exec("make {$concurrency} {$vars} fpm");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-unneeded php-fpm');
}
if ($this->getOption('with-upx-pack')) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')
->exec(getenv('UPX_EXEC') . ' --best php-fpm');
}
$this->deployBinary(BUILD_TARGET_FPM);
$this->deploySAPIBinary(BUILD_TARGET_FPM);
}
/**
* Build embed sapi
*
* @throws RuntimeException
*/
protected function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared());
$sharedExts = array_filter($sharedExts, static function ($ext) {
return Config::getExt($ext->getName(), 'build-with-php') === true;
});
$install_modules = $sharedExts ? 'install-modules' : '';
// detect changes in module path
$diff = new DirDiff(BUILD_MODULES_PATH, true);
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec('sed -i "s|^EXTENSION_DIR = .*|EXTENSION_DIR = /' . basename(BUILD_MODULES_PATH) . '|" Makefile')
->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install");
->exec("make {$concurrency} INSTALL_ROOT=" . BUILD_ROOT_PATH . " {$vars} install-sapi {$install_modules} install-build install-headers install-programs");
// process libphp.so for shared embed
$libphpSo = BUILD_LIB_PATH . '/libphp.so';
if (file_exists($libphpSo)) {
// post actions: rename libphp.so to libphp-<release>.so if -release is set in LDFLAGS
$this->processLibphpSoFile($libphpSo);
// deploy libphp.so
$this->deployBinary($libphpSo, $libphpSo, false);
}
// process shared extensions build-with-php
$increment_files = $diff->getChangedFiles();
foreach ($increment_files as $increment_file) {
$this->deployBinary($increment_file, $increment_file, false);
}
// process libphp.a for static embed
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
$AR = getenv('AR') ?: 'ar';
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
// export dynamic symbols
SystemUtil::exportDynamicSymbols(BUILD_LIB_PATH . '/libphp.a');
}
// patch embed php scripts
$this->patchPhpScripts();
}
/**
* Return extra variables for php make command.
*/
private function getMakeExtraVars(): array
{
$config = (new SPCConfigUtil($this, ['libs_only_deps' => true, 'absolute_libs' => true]))->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs'));
$static = SPCTarget::isStatic() ? '-all-static' : '';
$lib = BUILD_LIB_PATH;
return array_filter([
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'EXTRA_LIBS' => $config['libs'],
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
'EXTRA_LDFLAGS_PROGRAM' => "-L{$lib} {$static} -pie",
]);
}
private function processLibphpSoFile(string $libphpSo): void
{
$ldflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: '';
$libDir = BUILD_LIB_PATH;
$modulesDir = BUILD_MODULES_PATH;
$libphpSo = "{$libDir}/libphp.so";
$realLibName = 'libphp.so';
$cwd = getcwd();
@@ -320,7 +378,7 @@ class LinuxBuilder extends UnixBuilderBase
$target = "{$libDir}/{$realLibName}";
if (file_exists($target)) {
[, $output] = shell()->execWithResult('readelf -d ' . escapeshellarg($target));
$output = join("\n", $output);
$output = implode("\n", $output);
if (preg_match('/SONAME.*\[(.+)]/', $output, $sonameMatch)) {
$currentSoname = $sonameMatch[1];
if ($currentSoname !== basename($target)) {
@@ -332,66 +390,29 @@ class LinuxBuilder extends UnixBuilderBase
}
}
}
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
$AR = getenv('AR') ?: 'ar';
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
}
if (!$this->getOption('no-strip', false) && file_exists(BUILD_LIB_PATH . '/' . $realLibName)) {
shell()->cd(BUILD_LIB_PATH)->exec("strip --strip-unneeded {$realLibName}");
}
$this->patchPhpScripts();
}
/**
* Return extra variables for php make command.
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @throws \ReflectionException
* @throws \Throwable
* Patch micro.sfx after UPX compression.
* micro needs special section handling in LinuxBuilder.
* The micro.sfx does not support UPX directly, but we can remove UPX
* info segment to adapt.
* This will also make micro.sfx with upx-packed more like a malware fore antivirus
*/
private function getMakeExtraVars(): array
private function processUpxedMicroSfx(string $dst): void
{
$config = (new SPCConfigUtil($this, ['libs_only_deps' => true, 'absolute_libs' => true]))->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs'));
$static = SPCTarget::isStatic() ? '-all-static' : '';
$lib = BUILD_LIB_PATH;
return [
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'EXTRA_LIBS' => $config['libs'],
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
'EXTRA_LDFLAGS_PROGRAM' => "-L{$lib} {$static} -pie",
];
}
/**
* Strip micro.sfx for Linux.
* The micro.sfx does not support UPX directly, but we can remove UPX-info segment to adapt.
* This will also make micro.sfx with upx-packed more like a malware fore antivirus :(
*
* @throws RuntimeException
*/
private function processMicroUPX(): void
{
if (version_compare($this->getMicroVersion(), '0.2.0') >= 0 && !$this->getOption('no-strip', false)) {
shell()->exec('strip --strip-unneeded ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx');
if ($this->getOption('with-upx-pack')) {
// strip first
shell()->exec(getenv('UPX_EXEC') . ' --best ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx');
// cut binary with readelf
[$ret, $out] = shell()->execWithResult('readelf -l ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx | awk \'/LOAD|GNU_STACK/ {getline; print $1, $2, $3, $4, $6, $7}\'');
$out[1] = explode(' ', $out[1]);
$offset = $out[1][0];
if ($ret !== 0 || !str_starts_with($offset, '0x')) {
throw new RuntimeException('Cannot find offset in readelf output');
}
$offset = hexdec($offset);
// remove upx extra wastes
file_put_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx', substr(file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx'), 0, $offset));
if ($this->getOption('with-upx-pack') && version_compare($this->getMicroVersion(), '0.2.0') >= 0) {
// strip first
// cut binary with readelf
[$ret, $out] = shell()->execWithResult("readelf -l {$dst} | awk '/LOAD|GNU_STACK/ {getline; print \$1, \$2, \$3, \$4, \$6, \$7}'");
$out[1] = explode(' ', $out[1]);
$offset = $out[1][0];
if ($ret !== 0 || !str_starts_with($offset, '0x')) {
throw new PatchException('phpmicro UPX patcher', 'Cannot find offset in readelf output');
}
$offset = hexdec($offset);
// remove upx extra wastes
file_put_contents($dst, substr(file_get_contents($dst), 0, $offset));
}
}
}

View File

@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
use SPC\util\SPCTarget;
@@ -13,9 +11,6 @@ class imap extends LinuxLibraryBase
{
public const NAME = 'imap';
/**
* @throws FileSystemException
*/
public function patchBeforeBuild(): bool
{
$cc = getenv('CC') ?: 'gcc';
@@ -44,9 +39,6 @@ class imap extends LinuxLibraryBase
return false;
}
/**
* @throws RuntimeException
*/
protected function build(): void
{
if ($this->builder->getLib('openssl')) {

View File

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

View File

@@ -4,18 +4,12 @@ declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixAutoconfExecutor;
class libffi extends LinuxLibraryBase
{
public const NAME = 'libffi';
/**
* @throws RuntimeException
* @throws FileSystemException
*/
public function build(): void
{
UnixAutoconfExecutor::create($this)

View File

@@ -21,20 +21,12 @@ declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixAutoconfExecutor;
class libpng extends LinuxLibraryBase
{
public const NAME = 'libpng';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function build(): void
{
UnixAutoconfExecutor::create($this)

View File

@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\builder\linux\SystemUtil;
use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCTarget;
class liburing extends LinuxLibraryBase
{
public const NAME = 'liburing';
public function patchBeforeBuild(): bool
{
if (!SystemUtil::isMuslDist()) {
return false;
}
FileSystem::replaceFileStr($this->source_dir . '/configure', 'realpath -s', 'realpath');
return true;
}
protected function build(): void
{
$use_libc = SPCTarget::getLibc() !== 'glibc' || version_compare(SPCTarget::getLibcVersion(), '2.30', '>=');
$make = UnixAutoconfExecutor::create($this);
if (!$use_libc) {
$make->appendEnv([
'CC' => 'gcc', // libc-less version fails to compile with clang or zig
'CXX' => 'g++',
'AR' => 'ar',
'LD' => 'ld',
]);
} else {
$make->appendEnv([
'CFLAGS' => '-D_GNU_SOURCE',
]);
}
$make
->removeConfigureArgs(
'--disable-shared',
'--enable-static',
'--with-pic',
'--enable-pic',
)
->addConfigureArgs(
$use_libc ? '--use-libc' : '',
)
->configure()
->make('library', 'install ENABLE_SHARED=0', with_clean: false);
$this->patchPkgconfPrefix();
}
}

View File

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

View File

@@ -21,9 +21,6 @@ declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
class openssl extends LinuxLibraryBase
@@ -32,11 +29,6 @@ class openssl extends LinuxLibraryBase
public const NAME = 'openssl';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function build(): void
{
$extra = '';
@@ -86,7 +78,7 @@ class openssl extends LinuxLibraryBase
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
}
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', '/Libs.private:.*/m', 'Libs.private: ${libdir}/libz.a');
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', '/Libs.private:.*/m', 'Requires.private: zlib');
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/cmake/OpenSSL/OpenSSLConfig.cmake', '/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m', 'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}/libz.a")');
}
}

View File

@@ -4,9 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\linux\library;
/**
* gmp is a template library class for unix
*/
class readline extends LinuxLibraryBase
{
use \SPC\builder\unix\library\readline;

View File

@@ -6,9 +6,9 @@ namespace SPC\builder\macos;
use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\DirDiff;
use SPC\store\FileSystem;
use SPC\store\SourcePatcher;
use SPC\util\GlobalEnvManager;
@@ -19,11 +19,6 @@ class MacOSBuilder extends UnixBuilderBase
/** @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;
@@ -48,9 +43,7 @@ class MacOSBuilder extends UnixBuilderBase
/**
* Get dynamically linked macOS frameworks
*
* @param bool $asString If true, return as string
* @throws FileSystemException
* @throws WrongUsageException
* @param bool $asString If true, return as string
*/
public function getFrameworks(bool $asString = false): array|string
{
@@ -83,10 +76,7 @@ class MacOSBuilder extends UnixBuilderBase
/**
* Just start to build statically linked php binary
*
* @param int $build_target build target
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @param int $build_target build target
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{
@@ -102,13 +92,6 @@ class MacOSBuilder extends UnixBuilderBase
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
$zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : '';
$opcache_jit = !$this->getOption('disable-opcache-jit', false);
// disable opcache jit for PHP < 8.5.0 when opcache is not enabled
if ($opcache_jit && $phpVersionID < 80500 && !$this->getExt('opcache')) {
$opcache_jit = false;
}
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit ' : '--disable-opcache-jit ';
$config_file_path = $this->getOption('with-config-file-path', false) ?
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
$config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ?
@@ -119,10 +102,11 @@ class MacOSBuilder extends UnixBuilderBase
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
$enableCgi = ($build_target & BUILD_TARGET_CGI) === BUILD_TARGET_CGI;
// prepare build php envs
$envs_build_php = SystemUtil::makeEnvVarString([
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'),
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH,
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
]);
@@ -136,21 +120,20 @@ class MacOSBuilder extends UnixBuilderBase
}
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') .
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
$opcache_jit_arg .
($enableCgi ? '--enable-cgi ' : '--disable-cgi ') .
$config_file_path .
$config_file_scan_dir .
$json_74 .
$zts .
$this->makeStaticExtensionArgs() . ' ' .
$envs_build_php
);
));
$this->emitPatchPoint('before-php-make');
SourcePatcher::patchBeforeMake($this);
@@ -165,6 +148,10 @@ class MacOSBuilder extends UnixBuilderBase
logger()->info('building fpm');
$this->buildFpm();
}
if ($enableCgi) {
logger()->info('building cgi');
$this->buildCgi();
}
if ($enableMicro) {
logger()->info('building micro');
$this->buildMicro();
@@ -180,6 +167,11 @@ class MacOSBuilder extends UnixBuilderBase
logger()->info('building frankenphp');
$this->buildFrankenphp();
}
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
if (!empty($shared_extensions)) {
logger()->info('Building shared extensions ...');
$this->buildSharedExts();
}
}
public function testPHP(int $build_target = BUILD_TARGET_NONE)
@@ -190,95 +182,111 @@ class MacOSBuilder extends UnixBuilderBase
/**
* Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
protected function buildCli(): void
{
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$shell = shell()->cd(SOURCE_PATH . '/php-src');
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
$shell->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli");
if (!$this->getOption('no-strip', false)) {
$shell->exec('dsymutil -f sapi/cli/php')->exec('strip -S sapi/cli/php');
}
$this->deployBinary(BUILD_TARGET_CLI);
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
$shell->exec("make {$concurrency} {$vars} cli");
$this->deploySAPIBinary(BUILD_TARGET_CLI);
}
protected function buildCgi(): void
{
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$shell = shell()->cd(SOURCE_PATH . '/php-src');
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
$shell->exec("make {$concurrency} {$vars} cgi");
$this->deploySAPIBinary(BUILD_TARGET_CGI);
}
/**
* Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected 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::patchMicroPhar($this->getPHPVersionID());
}
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
$vars = $this->getMakeExtraVars();
try {
if ($this->getExt('phar')) {
$this->phar_patched = true;
SourcePatcher::patchMicroPhar($this->getPHPVersionID());
}
// patch fake cli for micro
$vars['EXTRA_CFLAGS'] .= $enable_fake_cli;
$vars = SystemUtil::makeEnvVarString($vars);
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
$vars = $this->getMakeExtraVars();
$shell = shell()->cd(SOURCE_PATH . '/php-src');
// build
$shell->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . " {$vars} micro");
// strip
if (!$this->getOption('no-strip', false)) {
$shell->exec('dsymutil -f sapi/micro/micro.sfx')->exec('strip -S sapi/micro/micro.sfx');
}
// patch fake cli for micro
$vars['EXTRA_CFLAGS'] .= $enable_fake_cli;
$vars = SystemUtil::makeEnvVarString($vars);
$this->deployBinary(BUILD_TARGET_MICRO);
$shell = shell()->cd(SOURCE_PATH . '/php-src');
// build
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
$shell->exec("make {$concurrency} {$vars} micro");
if ($this->phar_patched) {
SourcePatcher::unpatchMicroPhar();
$this->deploySAPIBinary(BUILD_TARGET_MICRO);
} finally {
if ($this->phar_patched) {
SourcePatcher::unpatchMicroPhar();
}
}
}
/**
* Build fpm sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
protected function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$shell = shell()->cd(SOURCE_PATH . '/php-src');
$shell->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . " {$vars} fpm");
if (!$this->getOption('no-strip', false)) {
$shell->exec('dsymutil -f sapi/fpm/php-fpm')->exec('strip -S sapi/fpm/php-fpm');
}
$this->deployBinary(BUILD_TARGET_FPM);
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
$shell->exec("make {$concurrency} {$vars} fpm");
$this->deploySAPIBinary(BUILD_TARGET_FPM);
}
/**
* Build embed sapi
*
* @throws RuntimeException
*/
protected function buildEmbed(): void
{
$sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared());
$sharedExts = array_filter($sharedExts, static function ($ext) {
return Config::getExt($ext->getName(), 'build-with-php') === true;
});
$install_modules = $sharedExts ? 'install-modules' : '';
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
$diff = new DirDiff(BUILD_MODULES_PATH, true);
shell()->cd(SOURCE_PATH . '/php-src')
->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install");
->exec('sed -i "" "s|^EXTENSION_DIR = .*|EXTENSION_DIR = /' . basename(BUILD_MODULES_PATH) . '|" Makefile')
->exec("make {$concurrency} INSTALL_ROOT=" . BUILD_ROOT_PATH . " {$vars} install-sapi {$install_modules} install-build install-headers install-programs");
$libphp = BUILD_LIB_PATH . '/libphp.dylib';
if (file_exists($libphp)) {
$this->deployBinary($libphp, $libphp, false);
// macOS currently have no -release option for dylib, so we just rename it here
}
// process shared extensions build-with-php
$increment_files = $diff->getChangedFiles();
foreach ($increment_files as $increment_file) {
$this->deployBinary($increment_file, $increment_file, false);
}
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
$AR = getenv('AR') ?: 'ar';
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
// export dynamic symbols
SystemUtil::exportDynamicSymbols(BUILD_LIB_PATH . '/libphp.a');
}
$this->patchPhpScripts();
}
@@ -286,10 +294,10 @@ class MacOSBuilder extends UnixBuilderBase
private function getMakeExtraVars(): array
{
$config = (new SPCConfigUtil($this, ['libs_only_deps' => true]))->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs'));
return [
return array_filter([
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'EXTRA_LDFLAGS_PROGRAM' => '-L' . BUILD_LIB_PATH,
'EXTRA_LIBS' => $config['libs'],
];
]);
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\macos;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
use SPC\exception\EnvironmentException;
use SPC\exception\WrongUsageException;
class SystemUtil
@@ -15,25 +15,25 @@ class SystemUtil
/**
* Get Logic CPU Count for macOS
*
* @throws RuntimeException
*/
public static function getCpuCount(): int
{
[$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu', false);
$cpu = exec('sysctl -n hw.ncpu', $output, $ret);
if ($ret !== 0) {
throw new RuntimeException('Failed to get cpu count');
throw new EnvironmentException(
'Failed to get cpu count from macOS sysctl',
'Please ensure you are running this command on a macOS system and have the sysctl command available.'
);
}
return (int) $output[0];
return (int) $cpu;
}
/**
* Get Target Arch CFlags
*
* @param string $arch Arch Name
* @return string return Arch CFlags string
* @throws WrongUsageException
* @param string $arch Arch Name
* @return string return Arch CFlags string
*/
public static function getArchCFlags(string $arch): string
{

View File

@@ -8,8 +8,6 @@ use SPC\builder\BuilderBase;
use SPC\builder\LibraryBase;
use SPC\builder\macos\MacOSBuilder;
use SPC\builder\traits\UnixLibraryTrait;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
abstract class MacOSLibraryBase extends LibraryBase
@@ -28,10 +26,6 @@ abstract class MacOSLibraryBase extends LibraryBase
return $this->builder;
}
/**
* @throws WrongUsageException
* @throws FileSystemException
*/
public function getFrameworks(): array
{
return Config::getLib(static::NAME, 'frameworks', []);

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