Compare commits

...

584 Commits
2.3.6 ... 2.6.0

Author SHA1 Message Date
Jerry Ma
d9cd4d7e36 Update version to 2.6.0 2025-06-12 13:16:45 +08:00
Marc
56080f40ef Merge pull request #763 from crazywhalecc/docs
update documentation for glibc
2025-06-12 12:12:26 +07:00
Marc
bb0a3589c1 Merge pull request #760 from lyrixx/better-exception
Better exception
2025-06-12 12:10:20 +07:00
DubbleClick
db109e3586 update documentation for glibc 2025-06-12 12:07:48 +07:00
Marc
289f4b300a Merge pull request #726 from crazywhalecc/fix/icurel
Fix PIC errors when building libphp.so | extensive extension building rework
2025-06-12 11:48:33 +07:00
DubbleClick
0ee9a0cfa4 oops, don't pass -fpic to CPPflags, I misread it as CXXflags 2025-06-12 11:45:47 +07:00
DubbleClick
d9f7aa760e update default env (shouldn't we pass -fpic to default c flags on macos?) 2025-06-12 11:40:32 +07:00
DubbleClick
01ab0d3530 update default flags 2025-06-12 11:01:05 +07:00
Jerry Ma
8bd7794a2e Add -v compatibility for command 2025-06-12 11:57:42 +08:00
DubbleClick
fcfbb59637 fix phpstan 2025-06-12 10:48:15 +07:00
DubbleClick
089b94d753 add fastlz, libmemcached for linux 2025-06-12 10:46:35 +07:00
crazywhalecc
bfba598ef4 Fix glfw source path 2025-06-12 10:58:58 +08:00
DubbleClick
e2efaab2b2 fix attempted ar deletions when building shared libphp 2025-06-12 08:18:32 +07:00
crazywhalecc
28e5e584b4 Revert ext-matrix-tests and test-extensions 2025-06-12 01:20:02 +08:00
crazywhalecc
e0734fe848 Add frameworks for extension 2025-06-12 01:16:57 +08:00
crazywhalecc
2ea8a7e662 Fix macOS embed re-archive bug 2025-06-12 01:16:30 +08:00
crazywhalecc
c0ea47ce75 I really got redundant test error 2025-06-12 00:41:33 +08:00
DubbleClick
84fb354bc0 this is not needed anymore 2025-06-11 22:46:22 +07:00
DubbleClick
9f35c954ac cs fix 2025-06-11 22:45:08 +07:00
DubbleClick
78b3778442 err 2025-06-11 22:43:51 +07:00
DubbleClick
0e092284eb err 2025-06-11 22:43:41 +07:00
DubbleClick
4be1e75128 dirty as fuck, I don't understand why AMQP_SHARED_LIBADD is not available in ./configure 2025-06-11 22:41:55 +07:00
DubbleClick
62a581393d compatibility with RHEL 10? 2025-06-11 21:55:08 +07:00
crazywhalecc
cec5274ea3 Re-test 2025-06-11 22:42:26 +08:00
crazywhalecc
80f2912026 Fix rdkafka with zstd build failed bug, reset test-extensions 2025-06-11 22:40:43 +08:00
crazywhalecc
70b91867cb Lets' fuzz it 2025-06-11 21:37:00 +08:00
crazywhalecc
a1ccddb53c Test macOS 15 for all php version 2025-06-11 20:57:43 +08:00
Grégoire Pineau
5a7db86471 Better exception 2025-06-11 14:20:24 +02:00
DubbleClick
518ed3a7fd don't add -lomp on macos (not required) 2025-06-11 15:38:43 +07:00
DubbleClick
d322be1666 err, add it back in 2025-06-11 15:02:07 +07:00
DubbleClick
a503aaa8a0 -lomp on macos 2025-06-11 15:01:16 +07:00
DubbleClick
a7771e95f2 enable musl too 2025-06-11 13:49:38 +07:00
DubbleClick
311de9381c fix gomp error 2025-06-11 13:47:32 +07:00
DubbleClick
c3aa7356ec update tests to all static 2025-06-11 11:43:00 +07:00
DubbleClick
63656cf383 cs fixer, of course 2025-06-10 19:58:25 +07:00
DubbleClick
6d3e2d9316 revert extension tests 2025-06-10 19:57:31 +07:00
DubbleClick
dcdd167db3 Merge remote-tracking branch 'origin/fix/icurel' into fix/icurel
# Conflicts:
#	src/SPC/builder/unix/library/gettext.php
#	src/SPC/builder/unix/library/libiconv.php
#	src/SPC/builder/unix/library/libxslt.php
2025-06-10 19:48:22 +07:00
DubbleClick
9ed62b02b6 make patchLaDependencyPrefix argument optional, remove cleanLaFiles 2025-06-10 19:46:55 +07:00
crazywhalecc
145fe7ce13 Remove curl libbrotli patches 2025-06-10 17:17:46 +08:00
crazywhalecc
b320eb853a Rename ignoreConfigureArgs to removeConfigureArgs 2025-06-10 17:17:46 +08:00
crazywhalecc
474fe63ad3 Add optional lib log 2025-06-10 17:17:46 +08:00
crazywhalecc
da45aa7f15 Fix ngtcp2 and libheif build missing lib bug 2025-06-10 17:17:46 +08:00
crazywhalecc
11f21304f9 Fix libxslt lib compile bug 2025-06-10 17:17:46 +08:00
crazywhalecc
6cb2cdd5a2 Add ignoreConfigureArgs for UnixAutoconfExecutor 2025-06-10 17:17:46 +08:00
crazywhalecc
9e8119e69c Fix ldap build 2025-06-10 17:17:46 +08:00
crazywhalecc
25c2bafa88 Fix brotlienc pkgconfig patching 2025-06-10 17:17:46 +08:00
crazywhalecc
ae56bed032 Fix ncurses build 2025-06-10 17:17:46 +08:00
crazywhalecc
4c8f9e154d Remove attr and libacl tests 2025-06-10 17:17:46 +08:00
crazywhalecc
0ed6f2924e Add tests for autoconf libs 2025-06-10 17:17:46 +08:00
crazywhalecc
8896d477aa Add tests for autoconf libs 2025-06-10 17:17:46 +08:00
crazywhalecc
1b08a250f6 Add --enable-pic for default autoconf args 2025-06-10 17:17:46 +08:00
crazywhalecc
8b09e1a446 Fix zlib autoconf builder 2025-06-10 17:17:46 +08:00
crazywhalecc
720251458f Add autoconf executor 2025-06-10 17:17:46 +08:00
crazywhalecc
a48680c26f Use tar gzip for windows 2025-06-09 19:33:10 +08:00
DubbleClick
684b5d4534 remove alpine tests for now https://github.com/php/php-src/pull/18779 2025-06-09 16:16:54 +07:00
DubbleClick
aedcc86fc5 fix cmake minimum version for libtidy 2025-06-09 15:52:17 +07:00
DubbleClick
978975d396 import class 2025-06-09 14:54:58 +07:00
DubbleClick
c9e9119bff remove gd from static extension test 2025-06-09 14:48:42 +07:00
DubbleClick
20f222d19e post merge fixes 2025-06-09 14:48:05 +07:00
DubbleClick
187d51e501 -DPOSITION_INDEPENDENT_CODE=ON for cmake 2025-06-09 14:41:14 +07:00
DubbleClick
fa744bb802 merge cmake changes from master into icurel 2025-06-09 14:38:45 +07:00
Jerry Ma
bed5b9d4ef Merge pull request #751 from crazywhalecc/shell-improvement
Extract default build env to unix shell
2025-06-09 13:37:12 +08:00
crazywhalecc
13540c8008 Remove shared tidy 2025-06-09 13:08:28 +08:00
crazywhalecc
48df491c31 Fix brotli build on macOS 2025-06-09 13:00:43 +08:00
crazywhalecc
3fbf8fcfb8 Merge branch 'main' into shell-improvement 2025-06-09 12:51:00 +08:00
Jerry Ma
104038bc7e Merge pull request #752 from crazywhalecc/cmake-test
Trigger tests
2025-06-09 12:50:32 +08:00
crazywhalecc
bb37c0058e Fix CMake related options 2025-06-09 12:49:33 +08:00
crazywhalecc
f4e1d7d4c1 Trigger tests 2025-06-09 12:37:50 +08:00
crazywhalecc
e6c9a82cd3 Fix gitignore 2025-06-09 12:14:25 +08:00
crazywhalecc
0ca71b62db Fix gitignore 2025-06-09 12:13:14 +08:00
crazywhalecc
936c4d8696 Change env string inject order 2025-06-09 12:12:22 +08:00
crazywhalecc
1c1f7b19dd Add XXX_CXXFLAGS for common build 2025-06-09 11:13:54 +08:00
crazywhalecc
0558d67240 Rename initBuildEnv to initializeEnv 2025-06-09 11:12:34 +08:00
Jerry Ma
3bb9a7b1f8 Feat: UnixCMakeExecutor (#750)
* Add cmake executor and default library path var wrapper

* Add cmake tool functions

* Use cmake executor instead of raw command

* Fix UnixCMakeExecutor.php missing return

* Fix UnixCMakeExecutor.php

* Refactor remaining cmake libs

* Add reset function

* Remove unused cmake things

* Remove unused cmake things

* Whoops

* Update src/SPC/builder/unix/library/libzip.php

Co-authored-by: Marc <m@pyc.ac>

* Update src/SPC/builder/unix/library/libzip.php

Co-authored-by: Marc <m@pyc.ac>

* For tomorrow windows executor, move it

* Rename setCMakeBuildDir to setBuildDir

---------

Co-authored-by: Marc <m@pyc.ac>
2025-06-09 11:09:41 +08:00
crazywhalecc
123cc92756 Extract default build env to unix shell 2025-06-09 10:24:06 +08:00
crazywhalecc
9babe7f1d2 Rename setCMakeBuildDir to setBuildDir 2025-06-09 09:26:39 +08:00
crazywhalecc
f46b714990 For tomorrow windows executor, move it 2025-06-09 09:24:31 +08:00
Jerry Ma
3497b2a760 Update src/SPC/builder/unix/library/libzip.php
Co-authored-by: Marc <m@pyc.ac>
2025-06-09 09:17:11 +08:00
Jerry Ma
acd10bd978 Update src/SPC/builder/unix/library/libzip.php
Co-authored-by: Marc <m@pyc.ac>
2025-06-09 09:17:04 +08:00
crazywhalecc
802950d941 Whoops 2025-06-09 01:52:23 +08:00
crazywhalecc
f158fba48d Remove unused cmake things 2025-06-09 01:48:48 +08:00
crazywhalecc
059d134990 Remove unused cmake things 2025-06-09 01:34:32 +08:00
crazywhalecc
f7871c0036 Add reset function 2025-06-09 01:33:21 +08:00
crazywhalecc
42943b315c Refactor remaining cmake libs 2025-06-09 01:33:06 +08:00
crazywhalecc
37b9ccfaa8 Fix UnixCMakeExecutor.php 2025-06-09 01:15:48 +08:00
crazywhalecc
1cf2a3dd3f Fix UnixCMakeExecutor.php missing return 2025-06-09 01:08:24 +08:00
crazywhalecc
1718806042 Use cmake executor instead of raw command 2025-06-09 01:07:30 +08:00
crazywhalecc
7d26aa533a Add cmake tool functions 2025-06-09 00:34:25 +08:00
crazywhalecc
521af84797 Add cmake executor and default library path var wrapper 2025-06-09 00:16:18 +08:00
DubbleClick
53eb6dcc80 cs fix hook isn't working on windows 2025-06-08 14:49:06 +07:00
DubbleClick
6ed440d861 refactor out method to get static and shared libraries 2025-06-08 14:45:09 +07:00
DubbleClick
a99c4a3fee remove getLibFilesString from Extension buildUnixShared 2025-06-08 08:13:03 +07:00
DubbleClick
0ebd44bc4f bring back zstd cmake flags 2025-06-07 23:19:32 +07:00
DubbleClick
2f53915064 fix ldap for postgresql 2025-06-07 23:00:26 +07:00
DubbleClick
08d3849c43 cs fix 2025-06-07 22:00:01 +07:00
DubbleClick
bb1f086674 pq forgets to link against -llber, only links against -lldap 2025-06-07 21:57:04 +07:00
DubbleClick
f4771b4f21 test macos too 2025-06-07 21:33:02 +07:00
DubbleClick
2093b4ec85 cs fix 2025-06-07 21:19:17 +07:00
DubbleClick
e5f483de1d libtidy uses strange cmake options 2025-06-07 21:16:53 +07:00
DubbleClick
23be5484e3 thread safety for pgsql (in version 17, remove this entirely) 2025-06-07 21:16:15 +07:00
DubbleClick
0b8543e6dd thread safety for pgsql? 2025-06-07 20:50:54 +07:00
DubbleClick
a3025479e7 fix libyaml install dir 2025-06-07 20:50:46 +07:00
DubbleClick
a6ea49981d ngtcp2 patch la files 2025-06-07 20:29:19 +07:00
DubbleClick
2a39fb0bd5 Merge remote-tracking branch 'origin/main' into fix/icurel 2025-06-07 20:10:04 +07:00
DubbleClick
2dde53760a makeCmakeArgs 2025-06-07 20:09:50 +07:00
Marc
a7e48a8d3b Merge pull request #748 from crazywhalecc/feat/h3
simplify makeAutoConfArgs, fix macOS differences
2025-06-07 10:51:03 +07:00
DubbleClick
4fae158a3c cs fix 2025-06-07 10:33:41 +07:00
DubbleClick
7d87856f4a remove static libraries from libngtcp_crypto_ossl.a 2025-06-07 10:23:10 +07:00
DubbleClick
cfa525351a cs fix 2025-06-07 10:11:57 +07:00
DubbleClick
f9de43c7d4 =yes 2025-06-07 10:11:23 +07:00
DubbleClick
e00227f0c6 remove separate method from macosbuilder, move method from LinuxBuilder into UnixBuilderBase 2025-06-07 09:45:19 +07:00
DubbleClick
e31942bf1e uncommented buildphp, haha 2025-06-07 08:21:56 +07:00
DubbleClick
111de20a57 fix cs 2025-06-07 00:00:17 +07:00
DubbleClick
635fbae3c9 Merge remote-tracking branch 'origin/main' into fix/icurel 2025-06-07 00:00:00 +07:00
DubbleClick
f29ee95176 remove buildUnixShared method from xhprof 2025-06-06 23:58:33 +07:00
DubbleClick
0d91ad7d94 remove buildUnixShared method from sqlsrv 2025-06-06 23:57:48 +07:00
DubbleClick
715650c4db add "which" to spc doctor 2025-06-06 23:51:58 +07:00
DubbleClick
a68212672b apply suggestions 2025-06-06 23:49:58 +07:00
Marc
fce115d39c Merge pull request #747 from crazywhalecc/feat/h3
fix ngtcp2 with openssl on glibc <= 2.17, macos still pending
2025-06-06 17:08:14 +07:00
DubbleClick
301f2d8a97 nghttp2 has brotlienc and brotlidec too 2025-06-06 17:02:35 +07:00
DubbleClick
500c19d900 phpstan 2025-06-06 16:59:36 +07:00
DubbleClick
617b0de31f add -lpthread and -ldl in openssl::getStaticLibFiles 2025-06-06 16:56:08 +07:00
DubbleClick
92ad792eff oops 2025-06-06 16:24:52 +07:00
DubbleClick
560f684f7f remove more unused options 2025-06-06 16:20:34 +07:00
DubbleClick
a0c0555089 add -lpthread -dl 2025-06-06 16:00:24 +07:00
DubbleClick
9fa1fb7b44 fix cs 2025-06-06 14:58:18 +07:00
DubbleClick
f5fa49338d macos is stupid now? 2025-06-06 14:49:09 +07:00
DubbleClick
df7cfa0d6a different extension combination fails? 2025-06-06 14:33:39 +07:00
DubbleClick
a0579efbc2 test 2025-06-06 14:32:28 +07:00
DubbleClick
b6a1182876 patch la files 2025-06-06 14:26:06 +07:00
DubbleClick
4582e1f508 cs fix 2025-06-06 13:57:45 +07:00
DubbleClick
621e396373 Merge branch 'fix/icurel' of https://github.com/crazywhalecc/static-php-cli into fix/icurel 2025-06-06 13:55:11 +07:00
DubbleClick
300723419b Merge remote-tracking branch 'origin/main' into fix/icurel 2025-06-06 13:55:00 +07:00
Marc
f75ab9f428 Merge pull request #743 from crazywhalecc/feat/h3
Feature: add http/3 support to curl.
2025-06-06 13:53:25 +07:00
Marc
dbc7ff5de7 Merge pull request #746 from crazywhalecc/fix/embed-soname
-release (soname) compilation support for linux shared embed
2025-06-06 13:44:34 +07:00
Marc
856db3df08 Merge pull request #745 from crazywhalecc/feat/lz4
add lz4 extension
2025-06-06 13:28:54 +07:00
DubbleClick
1479bef00d brotli was matching /dev/null, which should not be used 2025-06-06 13:21:20 +07:00
DubbleClick
3761a9c8ba brotli was matching /dev/null, which should not be used 2025-06-06 13:18:49 +07:00
DubbleClick
7c4c8c6275 cache libc version 2025-06-06 13:10:28 +07:00
DubbleClick
3b9670c202 fpic for liblzma 2025-06-06 09:57:20 +07:00
DubbleClick
861010af0e trim envs 2025-06-06 09:35:05 +07:00
DubbleClick
57b527c886 gzencode, of course 2025-06-05 21:29:20 +07:00
DubbleClick
31652e8b04 I HATE WINDOWS 2025-06-05 20:26:41 +07:00
DubbleClick
8b94a7174f cs fix 2025-06-05 20:14:02 +07:00
DubbleClick
01a79fcc6e unify tests for all compression extensions 2025-06-05 20:07:55 +07:00
DubbleClick
17b4c18830 accidental space 2025-06-05 19:59:45 +07:00
DubbleClick
86541b1aa8 only apply ffi patch at version >= 8.3.16 2025-06-05 19:58:38 +07:00
DubbleClick
e022a45048 only apply ffi patch at version >= 8.3.16 2025-06-05 19:57:59 +07:00
DubbleClick
94e31f1953 doms 2025-06-05 17:32:54 +07:00
DubbleClick
ad8581db97 Merge remote-tracking branch 'origin/main' into fix/icurel 2025-06-05 16:48:47 +07:00
DubbleClick
e2191113b0 tests for brotli and xz 2025-06-05 16:42:52 +07:00
DubbleClick
161a553948 -release (soname) compilation support for linux shared embed 2025-06-05 13:54:17 +07:00
DubbleClick
80f63e66c3 check static compilation 2025-06-05 11:48:28 +07:00
DubbleClick
2f25409475 add lz4 test 2025-06-05 11:48:07 +07:00
DubbleClick
67320d3eb3 add to tests 2025-06-05 11:37:36 +07:00
DubbleClick
92aeb2d816 enable shared 2025-06-05 11:35:50 +07:00
DubbleClick
3420f6ca42 add lz4 extension 2025-06-05 11:33:51 +07:00
DubbleClick
8e5efb923f update docs 2025-06-05 10:27:18 +07:00
Marc
ab4e0bc406 Merge pull request #741 from crazywhalecc/fix/freetype-cmake
force minimum version 3.5 for cmake policies in freetype
2025-06-05 10:22:51 +07:00
DubbleClick
8993b3f4f0 add pkgconf prefix patch for ngtcp2 crypto library 2025-06-05 10:06:20 +07:00
DubbleClick
499c281931 cs fix 2025-06-05 09:50:14 +07:00
DubbleClick
bb7e0f6f89 add nghttp3 and ngtcp2 2025-06-05 09:44:03 +07:00
DubbleClick
8919a2fcca goddamn windows 2025-06-04 21:50:28 +07:00
DubbleClick
ba0796c9ea nghttp3 2025-06-04 21:42:44 +07:00
DubbleClick
1b7404f194 php cs fix 2025-06-04 21:22:05 +07:00
DubbleClick
5add534848 don't use two extra variables 2025-06-04 21:20:00 +07:00
DubbleClick
ef7ebdfd1f force minimum version 3.12 for cmake policies in freetype, only when cmake >= 4 2025-06-04 21:18:44 +07:00
Marc
42f356d322 Merge pull request #739 from crazywhalecc/fix/curlca
force curl to respect SSL_CERT_FILE
2025-06-04 19:09:57 +07:00
DubbleClick
dabf52511f force minimum version 3.5 for cmake policies in freetype 2025-06-04 17:18:09 +07:00
DubbleClick
df85f97646 force curl to respect SSL_CERT_FILE 2025-06-04 13:44:18 +07:00
DubbleClick
a9d37bb2a2 add source patch for ffi on centos 7 2025-06-04 08:58:46 +07:00
DubbleClick
6b689f1584 explicitly pass env to process handler, fails in docker otherwise (??????) 2025-06-02 15:12:44 +07:00
DubbleClick
4b0fa94b3c stan 2025-06-02 12:32:53 +07:00
DubbleClick
c53b06c3d2 shared-extensions instead of build-shared 2025-06-02 12:27:58 +07:00
DubbleClick
ed87a7cd67 don't force invalidate php-src if the download option is explicitly passed 2025-06-02 12:00:20 +07:00
DubbleClick
108bf34cca craft needs to download shared extensions too 2025-06-02 11:55:55 +07:00
DubbleClick
8b98792ccf zts of course 2025-06-01 13:59:18 +07:00
DubbleClick
7c009b6dce add rdkafka 2025-06-01 13:53:56 +07:00
DubbleClick
5ae5a3d75d cs fix 2025-06-01 13:53:33 +07:00
DubbleClick
396ddd3e6f cs fix 2025-06-01 13:52:17 +07:00
DubbleClick
da7a125faf librdkafka needs "which" to be installed 2025-06-01 13:51:05 +07:00
DubbleClick
febf9b1815 full test suite for shared extensions 2025-06-01 13:27:36 +07:00
DubbleClick
55b4ba5832 fix file_exists check in printing shared extension folder 2025-06-01 13:23:44 +07:00
Marc
3bc5ac28be space 2025-05-31 22:33:30 +07:00
Marc
93eb6378ba Merge branch 'main' into fix/icurel 2025-05-31 22:32:08 +07:00
Marc
61837f0d68 more os tests 2025-05-31 22:26:56 +07:00
henderkes
c44b8b1029 test xz and brotli as well 2025-05-31 22:20:03 +07:00
henderkes
8312ce4d4c add ext-xz and ext-brotli 2025-05-31 22:17:06 +07:00
DubbleClick
3052b1cca5 change extension_dir, the env variable only has an effect during compilation 2025-05-31 21:01:22 +07:00
DubbleClick
ad3860981a -DPOSITION_INDEPENDENT_CODE=ON 2025-05-31 14:41:35 +07:00
DubbleClick
2dbcbc6963 --with-pic and --enable-pic for other libraries that support them 2025-05-31 14:35:59 +07:00
DubbleClick
8767181a80 --with-pic for ldap 2025-05-31 14:21:55 +07:00
DubbleClick
4c64707138 -ldl and --with-pic for imagemagick 2025-05-31 14:19:04 +07:00
DubbleClick
764fdd4d08 --enable-pic for gettext 2025-05-31 14:09:35 +07:00
DubbleClick
4c124770ed --with-pic for libffi 2025-05-31 14:06:00 +07:00
DubbleClick
78b2a89b0a --with-pic for libpng 2025-05-31 14:03:17 +07:00
DubbleClick
6147721314 dont disable openmp macro 2025-05-30 22:26:43 +07:00
DubbleClick
2a5915f4b6 patched this in ext-spx before, do it here instead 2025-05-30 21:21:50 +07:00
DubbleClick
5382362168 only disable openmp for rh devtoolset-10 2025-05-30 20:41:17 +07:00
DubbleClick
3867b9933d update doc for spx extension 2025-05-30 16:18:34 +07:00
crazywhalecc
4299abf68b Update vitepress version, fix selecting all options 2025-05-30 15:38:06 +08:00
DubbleClick
b68701f51b updated the static-php spx 2025-05-27 12:18:31 +07:00
David Grüner
c551efb75c Fix CraftCommand ignoring build-options during build (closes #732) (#733)
Unified option to parameter conversion
2025-05-26 20:14:23 +08:00
DubbleClick
92acb95a58 linter 2025-05-25 18:39:11 +07:00
DubbleClick
e2ea10d2eb set extension dir before 2025-05-25 18:29:34 +07:00
DubbleClick
d833d8946c fixes on arch64 2025-05-25 18:03:07 +07:00
DubbleClick
3662e079ac fix spc doctor command, gettext is installed by default, but doesn't provide all required autopoint stuff - check for gettextize instead, which is only installed with the gettext-devel package 2025-05-25 17:26:48 +07:00
DubbleClick
c972a94876 another way where static extensions would be excluded if also compiled shared 2025-05-25 15:52:11 +07:00
DubbleClick
234df8d11f update spx, works static and shared 2025-05-25 11:48:52 +07:00
DubbleClick
14ca782672 rename method 2025-05-25 11:07:44 +07:00
DubbleClick
9665473669 revert env 2025-05-25 11:02:54 +07:00
DubbleClick
a8987d48ed the what now? 2025-05-25 11:00:38 +07:00
DubbleClick
f83715c370 add function description 2025-05-25 10:52:46 +07:00
DubbleClick
a9d5dcf4a2 fixer 2025-05-25 10:47:32 +07:00
DubbleClick
e568041143 \$SPC_CMD_PREFIX_PHP_MAKE -> $SPC_CMD_PREFIX_PHP_MAKE 2025-05-25 10:44:38 +07:00
DubbleClick
4ce7374ac9 move zend extension check into config 2025-05-25 09:37:15 +07:00
DubbleClick
ed35b65390 build all static exts no matter if we're also building shared versions 2025-05-23 12:09:57 +07:00
DubbleClick
15dc672bcf remove shared-ext-depends 2025-05-23 10:01:24 +07:00
DubbleClick
51891478e4 shared ssh2 wants openssl if mysqli or mysqlnd aren't built in 2025-05-22 16:51:03 +07:00
DubbleClick
c2d5afc4e9 mysqli and mysqlnd can also be built shared 2025-05-22 16:48:22 +07:00
DubbleClick
835fc1e360 oops 2025-05-22 16:08:09 +07:00
DubbleClick
2a70b998e3 change to count of Static Extensions 2025-05-22 16:07:52 +07:00
DubbleClick
5eecd14ce0 linter 2025-05-22 16:04:29 +07:00
DubbleClick
0afe0e5f46 last problems (?) 2025-05-22 15:46:42 +07:00
DubbleClick
396d4b341f broli, hahahaha 2025-05-22 13:01:36 +07:00
DubbleClick
bc002d500e linter again 2025-05-22 12:45:06 +07:00
DubbleClick
6a86b28977 fix case of nonexistent pc 2025-05-22 12:44:48 +07:00
DubbleClick
b91c83b6cd linter 2025-05-22 12:29:19 +07:00
DubbleClick
4b8412dfdb shared for imagick 2025-05-22 12:28:00 +07:00
DubbleClick
3713ae8c93 extra dependencies for extensions 2025-05-22 12:27:41 +07:00
DubbleClick
310be957b6 new build-with-php key for extensions 2025-05-22 12:27:27 +07:00
DubbleClick
c29ca9722f add -lbrotlienc to curl 2025-05-22 12:26:25 +07:00
DubbleClick
64b6f98ce7 the flag doesn't fix it, the problem is something else 2025-05-21 20:43:10 +07:00
DubbleClick
4a44282556 shoehorn the lot in, I don't know how to fix this otherwise 2025-05-21 20:12:12 +07:00
DubbleClick
e3d7969b96 select all quick button 2025-05-21 20:03:21 +07:00
DubbleClick
b68d71b7b7 testPHP in windowsbuilder 2025-05-21 19:22:15 +07:00
DubbleClick
b376d1682f remove runSharedExtensionCheckUnix 2025-05-21 18:35:48 +07:00
DubbleClick
af51469b62 session, not sockets... 2025-05-21 18:04:38 +07:00
DubbleClick
fc7df585bd msgpack requires session 2025-05-21 18:01:41 +07:00
DubbleClick
3ff31d20cf fix undefined references to brotlicommon functions in gd.so 2025-05-21 17:59:46 +07:00
DubbleClick
11c116480f fix spx 2025-05-21 17:57:53 +07:00
Marc
fd5bc54cd0 Merge pull request #721 from crazywhalecc/feat/spx
update ext-spx (support zts builds)
2025-05-21 14:55:44 +07:00
Marc
95380168ef Merge branch 'fix/icurel' into feat/spx 2025-05-21 14:55:17 +07:00
DubbleClick
d349627fa1 linter 2025-05-21 14:29:49 +07:00
DubbleClick
3f8d297fb1 linter 2025-05-21 14:15:58 +07:00
Jerry Ma
aae6c2c98b Fix GHA token missing bug (#731)
* Update test-extensions.php

* Enable UPX test

* Add debug messages

* Test

* Revert

* Update tests.yml

* Update tests.yml

* Explict define GITHUB_TOKEN

* What's this???

* Check GITHUB_TOKEN in workflow

* Test token variable in step

* Test token variable inside php

* Test token in command

* Get env in commands

* Revert workflow env, add passthrough GITHUB_TOKEN into docker

* See build commands

* See build commands

* Typo fix

* Remove debug symbol for normal mode
2025-05-21 15:11:42 +08:00
DubbleClick
7698ceb108 fixes for more configure args 2025-05-21 14:10:56 +07:00
DubbleClick
495e868a71 rework configure args 2025-05-21 13:19:51 +07:00
DubbleClick
95a2f4600b rework building of shared extensions so that builtin extensions are built at php-src/configure -> make time 2025-05-21 12:01:00 +07:00
DubbleClick
c43423a7d0 replace root cause of the automatic enable 2025-05-21 11:19:28 +07:00
DubbleClick
fa285ecc82 more patching, xml still not working though 2025-05-20 23:16:36 +07:00
DubbleClick
f47daac3cc cs fix, xml building fails now, unsure why, doesn't seem to import expat_compat.h for some reason 2025-05-20 23:04:58 +07:00
DubbleClick
03ca3f4f59 why do we have prefix= calls instead of prefix=BUILD_ROOT_DIR? 2025-05-20 22:19:09 +07:00
DubbleClick
a9f81dd38e remove -fpic and -fpie (-fPIC and -fPIE are still there) 2025-05-20 20:03:02 +07:00
DubbleClick
93c6928624 fix readline 2025-05-20 20:00:37 +07:00
Marc
1e50dac5a6 Update BuildPHPCommand.php
fix printed path
2025-05-20 10:50:41 +07:00
henderkes
545a653c0d better phar handling 2025-05-20 09:20:20 +07:00
henderkes
20b6870f90 rewrite extension_dir 2025-05-20 09:14:13 +07:00
Jerry Ma
ca6f19f77d Add build from config support (craft command) (#713)
* Add build from config support (craft command)

* fix 60s timeout

* Fix missing optional warning

* Fix Windows missing SIGINT bug

---------

Co-authored-by: DubbleClick <m@pyc.ac>
2025-05-20 10:07:19 +08:00
henderkes
14a0e1a6cc fix macos 2025-05-20 08:24:39 +07:00
henderkes
38dfcdabd0 fix rdkafka 2025-05-20 08:06:49 +07:00
henderkes
683371adaa fix phar 2025-05-20 07:48:49 +07:00
henderkes
7ba1948101 fix pdo_sqlsrv 2025-05-20 07:48:49 +07:00
henderkes
5bd53ed714 skip php rebuild if we're only building shared libphp.so 2025-05-20 07:48:49 +07:00
henderkes
bff99fa537 fix imagick shared build 2025-05-20 07:48:48 +07:00
Marc
54ff71798c patch intl standard to c++17 2025-05-18 21:48:43 +07:00
Marc
81474336c1 Update dom.php 2025-05-18 18:29:43 +07:00
henderkes
6b50700d8c remove dom extra cake 2025-05-18 18:24:09 +07:00
henderkes
f708907d99 zstd pic 2025-05-18 17:59:12 +07:00
Marc
117923791a Update test-extensions.php 2025-05-18 17:46:55 +07:00
henderkes
ea7c145c62 libxml2 pic... 2025-05-18 15:52:15 +07:00
henderkes
bdd764218b install headers and modules from shared extensions 2025-05-18 12:53:49 +07:00
henderkes
1fbd2c1adc -fPIC for postgresql CFLAGS, but it's still erroring out 2025-05-18 12:46:55 +07:00
henderkes
2ff300970a -fPIC for unixodbc 2025-05-18 12:19:26 +07:00
henderkes
f88c10d4aa restore buildphp command 2025-05-18 08:57:07 +07:00
henderkes
eab8c27e4a shared dom ext requires xml 2025-05-17 22:43:34 +07:00
henderkes
c1e91e1ccb sockets doesn't install header?! 2025-05-17 22:40:30 +07:00
henderkes
05e9129a66 refactor dom out to its own extension, fails shared build 2025-05-17 19:01:32 +07:00
henderkes
76a9be2167 fix shared bz2 build 2025-05-17 19:00:57 +07:00
Marc
872673655e oopsie in opcache 2025-05-16 00:26:23 +07:00
Marc
1ae27c7b5a oopsie 2025-05-16 00:24:18 +07:00
henderkes
b402b735d6 fix copy command with BUILD_MODULES_CONSTANT 2025-05-15 23:30:07 +07:00
henderkes
22001792cd remove static target for swoole 2025-05-15 21:51:18 +07:00
henderkes
9557c9ef21 remove static target for zip 2025-05-15 21:50:35 +07:00
henderkes
6fe8b591ce ld library path for shared extension building 2025-05-15 19:52:30 +07:00
henderkes
23ae3f60f3 remove unused option 2025-05-15 15:35:13 +07:00
henderkes
03b634b961 fix libsodium with -fPIC too 2025-05-15 15:29:12 +07:00
henderkes
2897fdda04 fix icu for relocatable objects (required by libphp.so building) 2025-05-15 14:47:54 +07:00
henderkes
f5fffafd43 format setEnv§ 2025-05-15 14:46:44 +07:00
Marc
e884f97621 Merge pull request #723 from crazywhalecc/fix/xslt
fix libxslt build when trying to create a PIE executable using it
2025-05-07 10:50:04 +07:00
DubbleClick
e4028da886 typo 2025-05-06 16:56:06 +07:00
DubbleClick
a65bc95091 test arm64 too 2025-05-06 16:54:20 +07:00
DubbleClick
14563417a7 don't test on windows x) 2025-05-06 16:53:52 +07:00
DubbleClick
a3ee3e5a24 add to tests 2025-05-06 16:41:35 +07:00
DubbleClick
16a36b8315 damn comma 2025-05-06 16:39:02 +07:00
DubbleClick
861c49c9bc make sure -fpic -fpie from CFLAGS bleeds through to libxslt compilation 2025-05-06 16:35:41 +07:00
DubbleClick
b3dacf9c5a lowercase 2025-05-06 16:22:37 +07:00
DubbleClick
2c13eb257b static compilation is not quite working yet 2025-04-30 21:46:27 +07:00
crazywhalecc
348decf72f Fix Windows missing SIGINT bug 2025-04-29 14:52:24 +08:00
crazywhalecc
92483cf188 Fix missing optional warning 2025-04-29 14:51:49 +08:00
DubbleClick
8143b1d768 fix 60s timeout 2025-04-29 13:11:26 +07:00
Jerry Ma
e7d6f37e98 Fix windows xlswriter duplicate md5 symbol bug (#719)
* Add missing SOURCE_PATH before making cmake toolchain

* Fix windows xlswriter duplicate md5 symbol bug

* Add detection for patchFile to prevent duplicate patches

* Add tests
2025-04-28 14:35:08 +08:00
DubbleClick
d275a44895 Merge remote-tracking branch 'origin/main' into feat/craft 2025-04-28 10:58:11 +07:00
Marc
f755d66342 fix attr and acl build without autogen.sh (if we don't download from git) (#718) 2025-04-28 11:14:46 +08:00
Jerry Ma
22a438ed5e Add xlswriter extension windows support (#712)
* Add xlswriter extension windows support

* cs fix
2025-04-24 14:21:37 +08:00
Jerry Ma
a014294d58 Fix ghrel download link, use API directly (#711)
* Fix ghrel download link, use API directly

* Add missing GH token for downloading API
2025-04-24 14:21:22 +08:00
Jerry Ma
39953b5223 Fix pack lib command with wrong compression (#710)
* Fix pack lib command with wrong compression

* Update src/SPC/command/dev/PackLibCommand.php

Co-authored-by: Marc <m@pyc.ac>

---------

Co-authored-by: Marc <m@pyc.ac>
2025-04-24 14:21:07 +08:00
crazywhalecc
bd341db54a Add build from config support (craft command) 2025-04-24 14:18:39 +08:00
Jerry Ma
455ed7d503 Add alt download for Downloader (#706)
* Add alt download for Downloader

* Test broken url

* Break another source

* Good!

* Rename alt_sources variable

* Use SPC_DOWNLOAD_RETRIES instead of SPC_RETRY_TIME

* Apply new curlExec args
2025-04-22 20:25:44 +08:00
Marc
637ae89583 Merge pull request #707 from crazywhalecc/retries
rename SPC_RETRY_TIME to SPC_DOWNLOAD_RETRIES to clear up what it's doing sleep 5 seconds between retries
2025-04-22 15:45:02 +07:00
DubbleClick
7fd858b472 Revert "unwrap cast to unify curlDown with curlExec"
This reverts commit 74d8377400.
2025-04-22 14:44:57 +07:00
DubbleClick
74d8377400 unwrap cast to unify curlDown with curlExec 2025-04-22 14:36:58 +07:00
DubbleClick
a29992b907 rename retry to retries 2025-04-22 14:34:43 +07:00
Jerry Ma
57097d1275 Fix postgresql macOS 15.4 build bug (#705) 2025-04-22 15:09:31 +08:00
tricker
b21c62c11d Allow CI build to be called by other worklows (#698)
* add workflow_call

* change type choice string

* remove options for type string

* when vendor-mode run composer install

* move vendor-mode composer install

* debug

* move out vendor-mode inputs
2025-04-22 15:09:17 +08:00
DubbleClick
0b3421e3cd rename SPC_RETRY_TIME to SPC_DOWNLOAD_RETRIES to clear up what it's doing
sleep 5 seconds between retries
2025-04-22 12:24:08 +07:00
Jerry Ma
a7adec1341 Add extension ev support (#703)
* Add extension ev support

* Sort config

* Correct ev build arg for windows

* Use static-php mirror of nasm

* Fix windows ev patch

* Oops
2025-04-19 20:39:48 +08:00
crazywhalecc
a236ee3ac3 Prepare for 2.5.2 2025-04-19 16:22:26 +08:00
DubbleClick
d7b9e5a7d4 better matching pattern just in case we forget x) 2025-04-19 16:17:12 +08:00
DubbleClick
3d1738b14b add mirror sources to savannah downloads 2025-04-19 16:14:09 +08:00
Jerry Ma
f0e634a4fa Merge pull request #673 from crazywhalecc/feat/xdebug-dynamic
add xdebug dynamic extension
2025-04-19 16:01:07 +08:00
crazywhalecc
0f5f60e477 Fix gnu static extension build test 2025-04-19 15:18:48 +08:00
crazywhalecc
9fe09f57f6 Add Chinese docs and additional option docs 2025-04-19 15:04:29 +08:00
crazywhalecc
cf24b88bc8 Add final full test 2025-04-19 14:43:51 +08:00
DubbleClick
d34fa0ba4e check for SPC_LIBC 2025-04-18 16:03:49 +07:00
DubbleClick
f40170ee6f update extension tests to support shared extensions 2025-04-18 15:43:54 +07:00
crazywhalecc
2da750d5f9 Fix phpunit, add skip extraction arg for SPCConfigUtil new builder 2025-04-18 14:50:58 +08:00
crazywhalecc
720e700701 Merge branch 'main' into feat/xdebug-dynamic 2025-04-18 14:43:34 +08:00
crazywhalecc
b452f7f32a Add default shared target 2025-04-18 14:38:42 +08:00
crazywhalecc
7bfb8d6f53 Use SPCConfigUtil to generate shared extension env 2025-04-18 14:38:22 +08:00
crazywhalecc
b06db1f920 Add more PHPUnit tests 2025-04-18 14:03:54 +08:00
crazywhalecc
61eafa48ff Add static extension filter 2025-04-18 12:18:20 +08:00
crazywhalecc
8b07b15f6c Merge branch 'main' into feat/xdebug-dynamic 2025-04-18 09:45:19 +08:00
Marc
5e67133495 Merge pull request #693 from crazywhalecc/fix/libheif-with-heic
explicitly state libheif -> --with-heic
2025-04-14 16:25:46 +07:00
Marc
30b740b7f0 Merge pull request #696 from crazywhalecc/remove-extension_dir
don't set EXTENSION_DIR by default
2025-04-14 14:35:09 +07:00
DubbleClick
7501ae4b4d don't set EXTENSION_DIR by default 2025-04-14 11:01:39 +07:00
DubbleClick
4391c30299 explicitly state libheif -> --with-heic 2025-04-12 09:49:00 +07:00
Marc
536641eadd Merge pull request #692
mimalloc v2.2.3 is bugged on musl
2025-04-12 09:32:02 +07:00
DubbleClick
21594cd4c0 mimalloc v2.2.3 is bugged on musl 2025-04-12 09:30:37 +07:00
Jerry Ma
d4b263bc9f Merge pull request #689 from crazywhalecc/fix/extract-source-only
Add extract source only mode for SourceManager
2025-03-31 21:56:51 +08:00
crazywhalecc
4e4eaed123 Add extract source only mode for SourceManager 2025-03-31 16:37:24 +08:00
Jerry Ma
610843398e Merge pull request #681 from crazywhalecc/fix/remove-libgomp
Remove openmp support for imagemagick
2025-03-31 16:17:05 +08:00
Jerry Ma
615e680b9b Update extension-notes.md 2025-03-31 16:15:12 +08:00
DubbleClick
4e67c63808 add note to sharedExtensionCheck 2025-03-31 00:10:27 +07:00
DubbleClick
f556f375ee add zlib... 2025-03-31 00:04:55 +07:00
DubbleClick
f21f833aed add phar?! 2025-03-30 23:58:33 +07:00
DubbleClick
0c6dd7a577 warning for building an extension as both static and shared 2025-03-30 23:50:49 +07:00
Marc
fc4872c5d6 Merge branch 'main' into feat/xdebug-dynamic 2025-03-30 23:39:30 +07:00
DubbleClick
3fe50e9ca3 let tests succeed 2025-03-30 23:37:22 +07:00
DubbleClick
a5e4d6a5ec xdebug and ffi compilable shared, updated notes 2025-03-30 23:36:23 +07:00
Marc
0524129b64 add notes to imagick 2025-03-30 23:34:52 +07:00
Marc
7ce13751a0 Merge pull request #677 from crazywhalecc/dynamic-ext-refactor
Dynamic extension build support for macOS and glibc Linux
2025-03-30 23:23:43 +07:00
Marc
e149ee0d70 Merge branch 'main' into fix/remove-libgomp 2025-03-30 23:05:17 +07:00
Jerry Ma
2f3c71e55a Downloader enhancement (#685)
* Quiet console output for non --debug mode

* Adjust console output and PHPDoc

* Allow locking different arch pre-built content

* Add install-pkg and pre-built test

* Fix typo

* Add debug console output for Downloader

* Add libc version for pre-built content name

* Separate musl-dist and non-musl-dist

* Add additional log output for pre-built finder

* Return default version for musl and musl-wrapper

* Test arm runner

* Re-enable musl version detect

* Add upx cmd for tests

* Remove comment

* Add SPC_DOCKER_DEBUG for gnu docker, remove classmap for alpine docker

* Add glibc build for CI

* Fix PHP warning in test-extensions.php

* Remove redundant suffix, add libc version suffix

* Fix redundant pre-built name calling

* Fix redundant pre-built name calling

* Fix CI wrong runner name

* Fix end of line space

* Full spell for SPC_DOWNLOAD
2025-03-31 00:01:11 +08:00
crazywhalecc
5c04638cb4 Full spell for SPC_DOWNLOAD 2025-03-30 23:27:43 +08:00
crazywhalecc
6dd6d807b6 Fix end of line space 2025-03-30 23:27:23 +08:00
crazywhalecc
237d39f09c Fix CI wrong runner name 2025-03-30 23:27:05 +08:00
DubbleClick
7a2f77193f add imagick extension note 2025-03-30 22:22:22 +07:00
DubbleClick
d21980170e bring back openmp for musl, add TODO to add it back in on glibc 2025-03-30 22:07:56 +07:00
crazywhalecc
7dec34bdfe Fix redundant pre-built name calling 2025-03-30 22:05:50 +08:00
crazywhalecc
62d619b6cd Fix redundant pre-built name calling 2025-03-30 22:05:20 +08:00
crazywhalecc
67afffeb96 Remove redundant suffix, add libc version suffix 2025-03-30 21:59:58 +08:00
crazywhalecc
c58ea0c3bd Fix PHP warning in test-extensions.php 2025-03-30 21:24:46 +08:00
crazywhalecc
acb8cea437 Add glibc build for CI 2025-03-30 21:14:27 +08:00
crazywhalecc
11f0957963 Add SPC_DOCKER_DEBUG for gnu docker, remove classmap for alpine docker 2025-03-30 21:03:40 +08:00
crazywhalecc
2d7c052fd9 Remove comment 2025-03-30 21:03:19 +08:00
crazywhalecc
23bd216cc7 Add upx cmd for tests 2025-03-30 21:03:11 +08:00
crazywhalecc
50cfc5899b Re-enable musl version detect 2025-03-30 20:54:32 +08:00
crazywhalecc
01d3cb4b11 Test arm runner 2025-03-30 20:53:41 +08:00
crazywhalecc
a940200164 Return default version for musl and musl-wrapper 2025-03-30 20:34:57 +08:00
crazywhalecc
4e5c0f0a48 Add additional log output for pre-built finder 2025-03-30 20:21:56 +08:00
crazywhalecc
8e5657eff0 Separate musl-dist and non-musl-dist 2025-03-30 20:20:04 +08:00
crazywhalecc
631a1b5864 Add libc version for pre-built content name 2025-03-30 20:16:41 +08:00
crazywhalecc
67d2ad5511 Add debug console output for Downloader 2025-03-30 19:21:29 +08:00
crazywhalecc
ab4d7fae7d Fix typo 2025-03-30 19:16:01 +08:00
crazywhalecc
0e4a3f5e2b Add install-pkg and pre-built test 2025-03-30 19:09:32 +08:00
crazywhalecc
87c0535624 Allow locking different arch pre-built content 2025-03-30 16:53:14 +08:00
crazywhalecc
5648681ecc Adjust console output and PHPDoc 2025-03-30 15:17:09 +08:00
crazywhalecc
2c0bb1f7ba Quiet console output for non --debug mode 2025-03-30 14:31:29 +08:00
crazywhalecc
16d82212dd Add full tests for imagick extension 2025-03-30 14:03:06 +08:00
crazywhalecc
6ea1d06460 Add bzip2 support for imagick 2025-03-30 14:02:44 +08:00
crazywhalecc
936413a6d9 Define HAVE_OMP_PAUSE_RESOURCE_ALL to 0, add additional file system func 2025-03-30 14:01:31 +08:00
crazywhalecc
88ce2eafab Fix path bug 2025-03-29 23:29:45 +08:00
crazywhalecc
3915c8410b Destroy imagick config for disabling openmp 2025-03-29 23:15:55 +08:00
crazywhalecc
4115e42dc6 Remove openmp support for imagemagick 2025-03-29 22:51:12 +08:00
DubbleClick
48f257f85a unixconfigurearg needs to know if currently building shared or static 2025-03-27 11:12:19 +07:00
DubbleClick
acdec64144 build static and shared at the same time 2025-03-27 09:36:46 +07:00
crazywhalecc
0beb97648a Fix phpstan 2025-03-26 12:41:13 +08:00
crazywhalecc
5564559192 Change --with-shared to --build-shared 2025-03-26 12:39:55 +08:00
crazywhalecc
8cb93bc1fe Add more exception and log 2025-03-26 12:39:15 +08:00
crazywhalecc
ae23b721b3 Fix shared extension does not build bug 2025-03-26 12:38:59 +08:00
crazywhalecc
df06a4bb2c Fix shared extension does not build bug 2025-03-26 12:38:53 +08:00
crazywhalecc
f37110605e Remove dev build target 2025-03-25 16:13:41 +08:00
crazywhalecc
8459754692 Change to --enable-shared --disable-static 2025-03-25 13:29:55 +08:00
crazywhalecc
fc08e5cf23 Remove brotli support for shared build 2025-03-25 00:17:15 +08:00
crazywhalecc
6dec44bdc3 sort-config 2025-03-25 00:17:01 +08:00
crazywhalecc
8cd69b2b70 Support zero extension build result 2025-03-25 00:05:46 +08:00
crazywhalecc
625a03e799 phpstan fix 2025-03-24 23:51:24 +08:00
crazywhalecc
aa4d4db11f Refactor, supports shared extension build now ! 2025-03-24 23:50:12 +08:00
crazywhalecc
76c353e790 Add SPC_DOCKER_DEBUG=yes option for docker build 2025-03-24 22:39:45 +08:00
crazywhalecc
8909b62dc4 Some prerequisites for refactor 2025-03-24 19:25:38 +08:00
crazywhalecc
371a588396 Merge branch 'main' into feat/xdebug-dynamic 2025-03-24 19:11:09 +08:00
tricker
ee54b6d347 Add pgsql extension for Windows <#664> (#665)
* Add pgsql extension for Windows <#664>

* Add pgsql to windows test

* Added pdo_pgsql for windows, added missing header files

* Adjust some configure args and deps

---------

Co-authored-by: crazywhalecc <jesse2061@outlook.com>
2025-03-24 12:47:00 +08:00
tricker
3ba215c35c enable PDO_ODBC and ODBC extension statically (#661)
* enable PDO_ODBC and ODBC extension statically

* fix sorting of ext.json

* add odbc and pdo_odbc extension to tests

* Add full tests, remove pdo_odbc from bulk

* Remove windows support for docs

* Add ODBC and PDO_ODBC extension

* Revert curl static lib

* Add full tests

* Add iconv for macOS

* Add tests

* Fix linux pdo_odbc patch

* Sort config

---------

Co-authored-by: crazywhalecc <jesse2061@outlook.com>
2025-03-23 23:26:36 +08:00
Jerry Ma
161a3924d2 Fix windows micro logo changer bug (illegal realpath) (#675) 2025-03-23 22:55:25 +08:00
Jerry Ma
7b6fae6d92 Fix windows ssl bug for curl (#674) 2025-03-23 22:33:26 +08:00
Marc
71b52e58b2 Merge branch 'main' into feat/xdebug-dynamic 2025-03-23 10:13:56 +01:00
Marc
d0a66ab16b Merge pull request #663 from crazywhalecc/feat/mimalloc
Add mimalloc support for macOS and Linux
2025-03-23 10:12:08 +01:00
DubbleClick
9d75265e25 fix crash on windoof 2025-03-23 16:11:03 +07:00
DubbleClick
744e066d5f Merge remote-tracking branch 'origin/main' into feat/mimalloc 2025-03-23 15:38:31 +07:00
DubbleClick
1791b443bc add xdebug dynamic extension 2025-03-23 15:35:25 +07:00
Marc
e850df505c Merge pull request #671 from crazywhalecc/fix/phpize
fix phpize using wrong paths
2025-03-23 07:14:23 +01:00
DubbleClick
918223e7da fix phpize using wrong paths 2025-03-23 12:40:50 +07:00
Marc Henderkes
1552d992df fix typo in gettext 2025-03-21 07:41:19 +01:00
Marc
f0a895691b Merge pull request #670 from crazywhalecc/fix/gettext-typo
fix typo in gettext
2025-03-21 07:38:48 +01:00
Marc Henderkes
1f7c805da4 fix typo in gettext 2025-03-21 07:38:14 +01:00
crazywhalecc
1ad33556e9 Add full tests 2025-03-20 16:11:45 +08:00
crazywhalecc
6b5e83b98e Sync Chinese docs 2025-03-20 16:06:33 +08:00
Marc Henderkes
6fb9c2df3b test macos 2025-03-20 08:46:54 +01:00
Marc Henderkes
1b29803ed2 docs 2025-03-20 08:00:35 +01:00
Marc Henderkes
3477857584 mimalloc on mac (untested) 2025-03-20 07:41:13 +01:00
Marc Henderkes
0ce2c894e9 juggle mimalloc.o to the beginning 2025-03-20 07:27:38 +01:00
Marc Henderkes
92470a35da replace allocator with mimalloc (works for cli/fpm, embed needs to be tested) 2025-03-20 06:22:11 +01:00
Marc Henderkes
6447fec028 mimalloc WIP 2025-03-20 04:36:46 +01:00
Jerry Ma
0bc143cac3 Fix windows curl build >= 8.3 (#660)
* Test windows curl

* Test windows curl

* Fix windows curl build for PHP 8.3 and 8.4
2025-03-20 09:22:10 +08:00
Marc
8a4ba7a876 fix libffi compiling without -fPIC because of missing env (#657)
Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>
2025-03-19 14:49:25 +08:00
Jerry Ma
146a4d334b Build freetype using CMake instead (#658) 2025-03-19 14:49:12 +08:00
Marc
d86b7c4cec fix freetype lib build (#654)
Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>
2025-03-19 09:21:23 +08:00
Jerry Ma
b1931059a5 Add missing ext source when downloading pre-built grpc (#652)
* Add missing ext source when downloading pre-built grpc

* Add tests
2025-03-15 01:30:00 +08:00
Jerry Ma
a2476690c2 Add sodium extension support for Windows (#651)
* Add sodium extension support for Windows

* cs-fix
2025-03-15 01:29:44 +08:00
Jerry Ma
99be7b078b Add conflict message when building protobuf and grpc (#653) 2025-03-14 23:39:31 +08:00
Jerry Ma
8925e97e62 Fix windows setup-runtime php download link (#650) 2025-03-14 23:37:15 +08:00
Jerry Ma
4558204962 Fix libavif build on VS2019 syntax error (#649)
* Test old source of libavif

* Test old source of libavif

* Fix libavif 1.2.0 bug
2025-03-14 23:37:01 +08:00
Jerry Ma
b4f3657323 Remove SPC_NO_MUSL_PATH, remove --libc, use SPC_LIBC instead (#642)
* Remove SPC_NO_MUSL_PATH, remove --libc, use SPC_LIBC instead

* Fix tests

* Internally use GNU_ARCH for unified

* Update EXTENSION_DIR comments for env.ini

* Remove redundant -fPIC cflags in curl
2025-03-14 18:22:50 +08:00
Marc
91a3a01c39 fix libxslt license file path (#646)
Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>
2025-03-14 15:49:38 +08:00
Jerry Ma
4cc985a39b Fix gettext on locale bug (#634)
* Fix gettext locale sanity check failure bug

* Fix phpstan

* Add tests

* Add additional attr build configure args

* Remove windows test

* Fix attr configure arg

* Fix attr configure bug on gnu docker and alpine docker

* Add gettext-devel for doctor

* weird change for gnu docker container (#643)

Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>

---------

Co-authored-by: Marc <m@pyc.ac>
Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>
2025-03-14 15:25:51 +08:00
Jerry Ma
39a66daf04 Fix imagick patch newer than 30800 (#641) 2025-03-14 10:57:33 +08:00
Marc
2681a88488 don't require libacl and attr - use --with-libs='libacl' if you build… (#635)
* don't require libacl and attr - use --with-libs='libacl' if you build fpm with acl support

* don't filter out libacl and libattr

* suggest attr instead of requiring it

* disable nls if libiconv is not built

* suggest libiconv when using attr/libacl

* wrong directive...

* gettext (libintl) for acl/attr

* remove suggestions and build acl and attr without nls

---------

Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>
2025-03-13 18:23:36 +08:00
Jerry Ma
e1162606f5 Update automake on gnu docker to fix attr build bug (#636) 2025-03-13 14:57:37 +08:00
Jerry Ma
c6d4934dd6 Fix gmssl and openssl duplicate symbol (#632)
* Fix gmssl and openssl duplicate symbol

* Add tests
2025-03-13 14:18:27 +08:00
Marc
21265cd561 fix embed sapi being unusable to build extensions (#628)
Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>
2025-03-13 13:44:02 +08:00
Jerry Ma
a6b843f4dd Update docs for FFI and dynamic loading extensions (#629) 2025-03-13 11:56:40 +08:00
Jerry Ma
d643051759 Update musl-wrapper version to 1.2.5 and apply CVE patch (#627) 2025-03-13 11:11:58 +08:00
Jerry Ma
58eafe5100 Merge pull request #622 from DubbleClick/libacl
bring back pr for libacl
2025-03-12 23:02:04 +08:00
Marc
74edcb7d6f Update LibraryBase.php
newline
2025-03-12 20:07:04 +07:00
Marc
e7bac8f78d Update LibraryBase.php
rectify typo
2025-03-12 20:05:05 +07:00
Marc Henderkes
5caf5b7694 check for libacl in fewer places 2025-03-12 09:19:01 +01:00
Marc Henderkes
76ac57edf4 download attr and libacl on linux 2025-03-12 09:07:26 +01:00
Marc Henderkes
d15b387bea don't require libacl and attr for non fpm compilation 2025-03-12 08:59:47 +01:00
Marc Henderkes
b534cdce11 remove line 2025-03-11 08:53:31 +01:00
Marc Henderkes
f246125677 requested changes 2025-03-11 07:44:31 +01:00
Marc Henderkes
2c644d5c18 cs fix 2025-03-11 07:15:07 +01:00
crazywhalecc
ec3c0dc934 Add SPC_CMD_VAR_PHP_EMBED_TYPE for embed building in glibc mode 2025-03-11 07:08:44 +01:00
crazywhalecc
09c0e43501 Add gnu based static binary support 2025-03-11 07:08:00 +01:00
Marc Henderkes
878e17ddb4 remove attr and libacl from macos 2025-03-11 06:59:43 +01:00
Marc Henderkes
c52ab62fa6 arch c flags 2025-03-11 06:59:42 +01:00
Marc Henderkes
40ea306008 try something with static 2025-03-11 06:59:42 +01:00
Marc Henderkes
be3d68cebe patch the makefile before make (remove -lacl from FPM_EXTRA_LIBS) 2025-03-11 06:59:41 +01:00
Marc Henderkes
4e32ff47df patch libacl WIP 2025-03-11 06:59:41 +01:00
Marc Henderkes
c6552f6800 add patch for attr on alpine 2025-03-11 06:59:40 +01:00
Marc Henderkes
511fd0e301 add required packages for autopoint to spc doctor 2025-03-11 06:59:39 +01:00
Marc Henderkes
77bbc7fcaa add libacl and attr to macos, not sure if they build 2025-03-11 06:59:39 +01:00
Marc Henderkes
53f82d286c split requirements into unix and windows 2025-03-11 06:59:38 +01:00
Marc Henderkes
bed40c3d05 add libacl to php requirements 2025-03-11 06:59:38 +01:00
Marc Henderkes
29a0f2facb revert to SystemUtils::makeEnvVarString 2025-03-11 06:59:37 +01:00
Marc Henderkes
4bc4c2ff05 revert EXTRA_LDFLAGS_PROGRAM patch, TODO: patchBeforeMake and remove -lacl from the libtool command 2025-03-11 06:59:36 +01:00
Marc Henderkes
460699c48c add (lib)attr and libacl as optional libraries
when libacl is built and --enable-fpm is used, also enable --with-fpm-acl
2025-03-11 06:59:33 +01:00
crazywhalecc
89e8c152dc Emegency fix env.ini 2025-03-11 13:33:03 +08:00
Jerry Ma
5caaa4d1d4 Merge pull request #592 from crazywhalecc/feat/gnu-static
[feat] Add gnu based static binary support
2025-03-11 11:49:55 +08:00
crazywhalecc
939fd88789 Merge branch 'main' into feat/gnu-static 2025-03-11 11:33:45 +08:00
Marc
067b02f6d7 update php default to 8.4 (#621)
* update php defaul to 8.4

* update config

* Update README.md

---------

Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>
2025-03-10 16:20:22 +08:00
crazywhalecc
2afd39fbf1 Fix test-extensions 2025-03-10 16:19:24 +08:00
crazywhalecc
1ce1c326b2 Add SPC_CMD_VAR_PHP_EMBED_TYPE for embed building in glibc mode 2025-03-10 16:15:47 +08:00
crazywhalecc
b6324fd71e Fix syntax on Dockerfile 2025-03-10 15:54:43 +08:00
crazywhalecc
7e462d6625 Update spc-gnu-docker with gcc10, add build-static-frankenphp 2025-03-10 00:39:59 +08:00
crazywhalecc
2a9cd436b6 Support -fPIC and -fPIE for most libs and PHP 2025-03-10 00:39:20 +08:00
crazywhalecc
4eeb48cdc2 Update gnu-docker and fix icu build on glibc 2025-03-09 20:30:22 +08:00
crazywhalecc
23bfad6f87 Merge branch 'main' into feat/gnu-static
# Conflicts:
#	src/SPC/builder/linux/LinuxBuilder.php
2025-03-09 17:44:13 +08:00
Jerry Ma
36dc18012a Update something-want-to-know.md 2025-03-08 17:12:29 +08:00
Jerry Ma
d30d1fc447 Add php and lib-base as special libraries to add dependencies to the root node (#618)
* Remove E_STRICT

* Add lib-base and php as special libs

* Remove debug code

* Fix phpunit with new config structure

* Fix phpunit test and fix license dumper bug for new type of lib

* Add missing lib type filter for windows builder
2025-03-08 14:29:44 +08:00
Jerry Ma
15c7e41501 Update pull_request_template.md 2025-03-08 10:23:10 +08:00
crazywhalecc
b6243d8478 Fix vitepress-deploy.yml in minimal PHP version 2025-03-08 10:04:59 +08:00
Jerry Ma
cf30418be9 Remove deprecated args for PHP 8.4 (#616)
* Remove deprecated args for PHP 8.4

* Add tests

* Use nts for testing

* Test

* memcache still uses `--with-zlib-dir`
2025-03-07 18:25:19 +08:00
Marc
a95d034e98 fix SPC_NO_MUSL_PATH not working in .env.ini (#612)
* fix SPC_NO_MUSL_PATH not working in .env.ini

* use filter var instead of assuming var was defined in .env.ini

* CS fix and composer update

* update composer.lock

* fix LIBRARY_PATH and LD_LIBRARY_PATH

* Revert composer lock and cs-fixer options

* filter validate boolean

---------

Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de>
Co-authored-by: crazywhalecc <jesse2061@outlook.com>
2025-03-07 18:15:11 +08:00
Jerry Ma
29ea46bd17 Switch static-php-cli to support PHP 8.3 and 8.4 only (#615)
* Update spc self to PHP 8.4 only

* Update workflows

* Fix test-extensions, adjust docs order

* Fix cs-fix and phpunit

* Add PHP_CS_FIXER_IGNORE_ENV

* Add compatibility for PHP 8.3

* Change version description in README, adjust composer.json PHP version limit

* Switch PHP to 8.4 in spc-alpine-docker

* Add deprecation notice
2025-03-07 18:06:32 +08:00
Jerry Ma
8a17e2384e Update feature_request.md 2025-03-07 13:10:06 +08:00
Jerry Ma
60dbb18504 Update bug_report.md 2025-03-07 13:09:53 +08:00
Jerry Ma
5f53b34fae Update issue templates 2025-03-07 13:08:42 +08:00
Alexander Over
6b227d88ac Add command to dump required PHP extensions based on vendor/composer/… (#599)
* Add command to dump required PHP extensions based on vendor/composer/installed.json, composer.lock, composer.json (in this order)

* remove unused use

* missing translation

* Adjust dump-extensions

* Add docs for dump-extension command

---------

Co-authored-by: crazywhalecc <jesse2061@outlook.com>
2025-03-07 10:46:07 +08:00
Jerry Ma
34934368a2 Ignore any ini files when sanity check (#609) 2025-02-16 01:30:08 +08:00
Klaas Skelte van der Werf
15af034b34 Report why the sanity check for the cli target failed (#605) 2025-02-11 10:34:43 +08:00
Jerry Ma
1f281cd376 Fix gettext multithread segment fault bug (#603)
* Fix gettext included with multithreaded bug

* Change --enable-zts to BuildCommand
2025-02-10 20:28:00 +08:00
Jerry Ma
95d741496e Fix windows curl build (using cmake) (#600) 2025-02-06 22:59:02 +08:00
Alexander Over
21de1a2291 add opentelemetry extension support (#593)
* add opentelemetry extension support

* config sort

* cleanup build args

* Update docs

* Adjust custom extension overrides for opentelemetry

* Add tests

* Update README.md and remove windows limitation

* Fix windows static build for opentelemetry

---------

Co-authored-by: crazywhalecc <jesse2061@outlook.com>
2025-02-06 12:27:43 +08:00
crazywhalecc
d047176fc9 Update docs 2025-02-06 11:25:22 +08:00
crazywhalecc
7b1e2fb89e Update docs 2025-02-04 17:34:53 +08:00
crazywhalecc
cb73222e21 Fix embed sanity check on glibc mode 2025-02-04 17:34:47 +08:00
crazywhalecc
9c878ce613 Remove env.custom.ini 2025-02-04 17:24:28 +08:00
crazywhalecc
4beea4ad39 Add issue content 2025-02-04 17:23:47 +08:00
crazywhalecc
0aab10ba31 Add docs for gnu static build 2025-02-04 17:20:27 +08:00
crazywhalecc
daa6196afc cs-fix 2025-01-28 19:41:06 +08:00
crazywhalecc
75ee69b07d Add gnu based static binary support 2025-01-28 19:37:50 +08:00
Jerry Ma
f19e90afd7 Add extension dio support (#590)
* Add extension dio support

* cs-fix
2025-01-25 17:43:12 +08:00
Jerry Ma
36b4ef306e Fix libtiff dependencies, avoid using system libraries (#588)
* Remove tmate debugger

* Bump version to 2.4.4

* Fix libtiff dependencies may wrongly added

* Add matrix tests

* Add tmate debug

* Disable libdeflate for libtiff

* Remove ssh debugger
2025-01-25 16:15:53 +08:00
crazywhalecc
4bd3a2ae25 Add ssh debug 2025-01-25 12:20:54 +08:00
crazywhalecc
dd647c53ec Add doctor for build-unix CI 2025-01-25 11:35:47 +08:00
crazywhalecc
0c0d16bbb3 Try new build CI 2025-01-25 11:30:59 +08:00
crazywhalecc
c665a18b79 Try new build CI 2025-01-25 11:29:18 +08:00
crazywhalecc
16d448b97c Try new build CI 2025-01-25 11:09:13 +08:00
crazywhalecc
27ccc1189f Try new build CI 2025-01-25 10:59:44 +08:00
Jerry Ma
eecebbcd4d Fix x86_64 macOS CI invalid options 2025-01-25 09:48:15 +08:00
Jerry Ma
2ca5ad075b Add legacy CentOS distro support (#585) 2025-01-13 20:42:09 +08:00
Jean-François Lépine
20dad4cdb3 Merge pull request #583 from Halleck45/support_ast_extension
Support AST extension
2025-01-13 11:11:32 +08:00
crazywhalecc
a3e0ad6b9f Add PHP 8.4 support for cli-generator 2025-01-13 09:33:25 +08:00
Jerry Ma
4b16631d45 Fix openssl missing cert bug for Linux & macOS (#581)
* Fix openssl missing cert bug for linux

* Fix openssl missing cert bug for macOS
2024-12-24 22:06:31 +08:00
Jerry Ma
944f4af914 Update FUNDING.yml 2024-12-23 11:05:21 +08:00
Jerry Ma
4865c1c124 Update README.md 2024-12-23 11:04:46 +08:00
Jerry Ma
78aea56de4 Add aom patch for alpine linux (#579) 2024-12-20 12:18:34 +08:00
Jerry Ma
adbe2e80f3 Update ConsoleApplication.php 2024-12-19 12:28:49 +08:00
Jerry Ma
192c8cde87 Add libaom, libde265, libheif support, for imagick AVIF format support (#575)
* Add libaom, libde265, libheif support, for imagick AVIF format support

* Fix aom optimization

* Fix aom build command

* Fix libheif build command

* Fix libheif build

* cs fix
2024-12-19 12:23:39 +08:00
Adam
d4ec366c5f Update SQLite to 3.45 (#574)
* Force SQLite 3.45 build from source.

* Update SQLite to 3.45.

* Sort config.

* Minimize changes.
2024-12-15 20:03:48 +08:00
Jerry Ma
bad28fa263 Merge pull request #256 from crazywhalecc/ext/rdkafka
Add extension rdkafka support
2024-12-13 16:23:21 +08:00
crazywhalecc
985cd6781e Add macOS x86_64 test 2024-12-13 15:36:51 +08:00
crazywhalecc
44dcc830f4 Add rdkafka tests 2024-12-13 15:23:55 +08:00
crazywhalecc
10ef4c0d3b Adjust config 2024-12-13 15:22:54 +08:00
crazywhalecc
d0fbc5ab2d Merge branch 'main' into ext/rdkafka
# Conflicts:
#	src/globals/test-extensions.php
2024-12-13 15:12:05 +08:00
crazywhalecc
1bc7bc3421 Addd embed docs 2024-12-13 15:05:44 +08:00
crazywhalecc
8b9b70704a Fix test 2024-12-13 15:05:44 +08:00
crazywhalecc
804020210d Fix test 2024-12-13 15:05:44 +08:00
crazywhalecc
5c51305978 Add embed build tests 2024-12-13 15:05:44 +08:00
crazywhalecc
43cc9d0ba3 Add command, bump version 2024-12-13 15:05:44 +08:00
crazywhalecc
52869218e0 Fix grpc redundant static lib 2024-12-13 15:05:44 +08:00
crazywhalecc
82e11e52dd Fix gettext build 2024-12-13 15:05:44 +08:00
crazywhalecc
955c367a47 Fix pgsql embed builds 2024-12-13 15:05:44 +08:00
crazywhalecc
a613e9a84f Add spc-config command 2024-12-13 15:05:44 +08:00
crazywhalecc
c4b9660cd7 Add embed sanity check 2024-12-13 15:05:44 +08:00
crazywhalecc
f433866671 Add embed spc-config output instead of php-config 2024-12-13 15:05:44 +08:00
crazywhalecc
fdc4a907c7 Fix pgsql missing symbol 2024-12-09 21:57:35 +08:00
Jerry Ma
cf37e16e38 Update build-macos-x86_64.yml 2024-12-06 13:13:50 +08:00
Jerry Ma
2aa42123f6 Update build-macos-x86_64.yml 2024-12-06 13:07:52 +08:00
crazywhalecc
bc7dba6125 Fix parallel config.m4 2024-12-05 18:51:57 +08:00
crazywhalecc
3ce24da15c Fix patch point tests 2024-12-05 18:51:57 +08:00
crazywhalecc
3659e20b0d Fix patch point tests 2024-12-05 18:51:57 +08:00
crazywhalecc
a90a57ffab Add extension configure tests 2024-12-05 18:51:57 +08:00
crazywhalecc
45bdb6a66b Add extension configure tests 2024-12-05 18:51:57 +08:00
crazywhalecc
64258e3513 Fix pgsql linux builds with PHP 8.4 2024-12-05 18:30:19 +08:00
crazywhalecc
fe72b800c6 Add pgsql tests 2024-12-05 13:48:27 +08:00
crazywhalecc
39bc44322e cs-fix 2024-12-05 13:48:27 +08:00
crazywhalecc
1a0e6ee717 cs-fix, add tests 2024-12-05 13:48:27 +08:00
crazywhalecc
cc088b6382 Let grpc use openssl 2024-12-05 13:48:27 +08:00
crazywhalecc
b9f709c23d Change ext.json for pgsql 2024-12-05 13:48:27 +08:00
crazywhalecc
05b602d38c Fix pgsql with PHP 8.4 embed missing libs bug 2024-12-05 13:48:27 +08:00
Simon Hamp
a8a071de1a Add missing step 2024-12-01 16:11:05 +08:00
crazywhalecc
391555b1f5 Update docs 2024-11-23 11:55:29 +08:00
crazywhalecc
62b0bf8eca Remove PHP 8.1 libxml2 patch 2024-11-23 11:55:29 +08:00
crazywhalecc
1ab464431f Update workflows, add php 8.4 2024-11-23 11:55:29 +08:00
crazywhalecc
f04b54bc2a Update docs 2024-11-23 11:55:29 +08:00
crazywhalecc
e1652a4b36 Sort config 2024-11-23 11:55:29 +08:00
crazywhalecc
8c586fe7d9 Remove RC version for PHP 8.4 2024-11-23 11:55:29 +08:00
crazywhalecc
d2c929cb72 Update to RC4 2024-11-23 11:55:29 +08:00
crazywhalecc
b9584e48ac Fix FileSystem remove soft link directory 2024-11-23 11:55:29 +08:00
crazywhalecc
e269d1ba00 Fix gettext sanity check 2024-11-23 11:55:29 +08:00
crazywhalecc
87750c462f Do not cache PHP 2024-11-23 11:55:29 +08:00
crazywhalecc
219edb6b59 Add extension matrix tests 2024-11-23 11:55:29 +08:00
crazywhalecc
4f87e01bff Use similar optimize flags for compiling PHP (bump major ver) 2024-11-23 11:55:29 +08:00
crazywhalecc
5f69e957ac Add 8.1-8.3 test 2024-11-23 11:55:29 +08:00
crazywhalecc
756bdbf92f Fix imagick build for PHP 8.4 2024-11-23 11:55:29 +08:00
crazywhalecc
610fb66b0c Remove --with-zlib-dir that has been removed in 8.4 2024-11-23 11:55:29 +08:00
crazywhalecc
1186bac49c Update README 2024-11-23 11:55:29 +08:00
crazywhalecc
f6fe902c76 Fix sodium build, remove build patches 2024-11-23 11:55:29 +08:00
crazywhalecc
f984516a67 Change swoole source to git master instead of pecl (6.0 has not been released) 2024-11-23 11:55:29 +08:00
crazywhalecc
0d2f6456fb Change default download php version to 8.3 2024-11-23 11:55:29 +08:00
crazywhalecc
2fc61d8e5c Remove 8.1-8.3 tests 2024-11-23 11:55:29 +08:00
crazywhalecc
12b119e235 Fix display PHP version when using archive 2024-11-23 11:55:29 +08:00
crazywhalecc
6fa5f75963 Fix imap library build in macOS Sequoia 2024-11-23 11:55:29 +08:00
crazywhalecc
1fa5514c57 8.4 download imap separately, compatible with 8.1-8.3 2024-11-23 11:55:29 +08:00
crazywhalecc
73e3480bdf Add 8.4 support for switch-php-version command 2024-11-23 11:55:29 +08:00
crazywhalecc
ddafdf8987 Add PHP 8.4 support (testing) 2024-11-23 11:55:29 +08:00
crazywhalecc
2bfc5e1d74 Add grpc support for macOS and Linux 2024-11-10 10:42:04 +08:00
yinheli
3c4d47d072 feat: improve downloader retry (#558)
- Refactored to remove duplicate retry expressions by utilizing the getRetryTime() method.
- Fixed a typo in the log message.
2024-11-09 10:50:08 +08:00
crazywhalecc
c840165fa8 Add tests for rdkafka 2024-09-23 16:52:01 +08:00
crazywhalecc
4e95d969e3 Merge branch 'refs/heads/main' into ext/rdkafka
# Conflicts:
#	config/source.json
2024-09-23 16:25:59 +08:00
daddeffe
330dd2bfc6 Added optional zlib and disabled two extension (#545)
asd
2024-09-23 16:19:40 +08:00
crazywhalecc
c0b52fc2d1 Add extension rdkafka support 2023-11-05 17:09:48 +08:00
301 changed files with 10528 additions and 4295 deletions

15
.editorconfig Normal file
View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml, vue}]
indent_size = 2

4
.github/FUNDING.yml vendored
View File

@@ -1,9 +1,9 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: [crazywhalecc]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: crazywhalecc # Replace with a single Ko-fi username
# ko_fi: crazywhalecc # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username

8
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,8 @@
---
name: Bug report
about: Build PHP or library failed, download failed, doesn't seem to work...
title: ''
labels: bug
assignees: crazywhalecc
---

View File

@@ -0,0 +1,8 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: new feature
assignees: ''
---

View File

@@ -0,0 +1,10 @@
---
name: Something want to know
about: Describe your question about static-php, we will reply ASAP
title: ''
labels: question
assignees: ''
---

View File

@@ -7,6 +7,7 @@
> If your PR involves the changes mentioned below and completed the action, please tick the corresponding option.
> If a modification is not involved, please skip it directly.
- [ ] If you modified `*.php`, run `composer cs-fix` at local machine.
- [ ] If it's an extension or dependency update, make sure adding related extensions in `src/global/test-extensions.php`.
- [ ] If you changed the behavior of static-php-cli, update docs in `./docs/`.
- [ ] If you updated `config/xxx.json` content, run `bin/spc dev:sort-config xxx`.

View File

@@ -1,130 +0,0 @@
name: CI on arm linux
on:
workflow_dispatch:
inputs:
operating-system:
required: true
description: Compile target arch (Linux only)
type: choice
options:
- aarch64
version:
required: true
description: php version to compile
default: '8.2'
type: choice
options:
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
prefer-pre-built:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: enable debug logs
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on ${{ inputs.operating-system }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
- name: Generate hashed key for download cache
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- if: inputs.prefer-pre-built == true
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
# Run build command
- run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.version }}-linux-${{ inputs.operating-system }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -1,125 +0,0 @@
name: CI on x86_64 linux
on:
workflow_dispatch:
inputs:
version:
required: true
description: php version to compile
default: '8.2'
type: choice
options:
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
prefer-pre-built:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: enable debug logs
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on Linux x86_64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
- name: Generate hashed key for download cache
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- if: inputs.prefer-pre-built == true
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
# Run build command
- run: ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -1,139 +0,0 @@
name: CI on arm64 macOS
on:
workflow_dispatch:
inputs:
version:
required: true
description: php version to compile
default: '8.2'
type: choice
options:
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
prefer-pre-built:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: enable debug logs
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on macOS arm64
runs-on: macos-14
steps:
- uses: actions/checkout@v4
# Install macOS missing packages and mark os suffix
- run: |
brew install automake gzip
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: pecl, composer
extensions: curl, openssl, mbstring, tokenizer
ini-values: memory_limit=-1
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
- name: Generate hashed key for download cache
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- if: inputs.prefer-pre-built == true
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
# Run build command
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -1,138 +0,0 @@
name: CI on x86_64 macOS
on:
workflow_dispatch:
inputs:
version:
required: true
description: php version to compile
default: '8.2'
type: choice
options:
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true
type: boolean
build-micro:
description: build phpmicro binary
type: boolean
build-fpm:
description: build fpm binary
type: boolean
extensions:
description: extensions to compile (comma separated)
required: true
type: string
prefer-pre-built:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: enable debug logs
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: build ${{ inputs.version }} on macOS x86_64
runs-on: macos-13
steps:
- uses: actions/checkout@v4
# Install macOS missing packages and mark os suffix
- run: |
brew install automake gzip
echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: pecl, composer
extensions: curl, openssl, mbstring, tokenizer
ini-values: memory_limit=-1
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
- name: Generate hashed key for download cache
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- if: inputs.prefer-pre-built == true
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
# With target select: cli, micro or both
- if: ${{ inputs.build-cli == true }}
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV
- if: ${{ inputs.build-micro == true }}
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV
- if: ${{ inputs.build-fpm == true }}
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
# Run build command
- run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }}
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

241
.github/workflows/build-unix.yml vendored Normal file
View File

@@ -0,0 +1,241 @@
name: "CI on Unix"
on:
workflow_dispatch:
inputs:
os:
required: true
description: Build target OS
default: 'linux-x86_64'
type: choice
options:
- 'linux-x86_64'
- 'linux-aarch64'
- 'linux-x86_64-glibc'
- 'linux-aarch64-glibc'
- 'macos-x86_64'
- 'macos-aarch64'
php-version:
required: true
description: PHP version to compile
default: '8.4'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
extensions:
description: Extensions to build (comma separated)
required: true
type: string
extra-libs:
description: Extra libraries to build (optional, comma separated)
type: string
build-cli:
description: Build cli binary
default: true
type: boolean
build-micro:
description: Build phpmicro binary
type: boolean
build-fpm:
description: Build fpm binary
type: boolean
prefer-pre-built:
description: Prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: Show full build logs
type: boolean
no-strip:
description: Keep debug symbols for debugging
type: boolean
default: false
workflow_call:
inputs:
os:
required: true
description: Build target OS
default: 'linux-x86_64'
type: string
php-version:
required: true
description: PHP version to compile
default: '8.4'
type: string
extensions:
description: Extensions to build (comma separated)
required: true
type: string
extra-libs:
description: Extra libraries to build (optional, comma separated)
type: string
build-cli:
description: Build cli binary
default: true
type: boolean
build-micro:
description: Build phpmicro binary
type: boolean
build-fpm:
description: Build fpm binary
type: boolean
prefer-pre-built:
description: Prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: Show full build logs
type: boolean
no-strip:
description: Keep debug symbols for debugging
type: boolean
default: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
define-build:
name: "Define Build Scripts"
runs-on: ubuntu-latest
outputs:
run: ${{ steps.gendef.outputs.run }}
download: ${{ steps.gendef.outputs.download }}
build: ${{ steps.gendef.outputs.build }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Define"
id: gendef
run: |
case "${{ inputs.os }}" in
linux-x86_64)
DOWN_CMD="./bin/spc-alpine-docker download"
BUILD_CMD="./bin/spc-alpine-docker build"
RUNS_ON="ubuntu-latest"
;;
linux-aarch64)
DOWN_CMD="./bin/spc-alpine-docker download"
BUILD_CMD="./bin/spc-alpine-docker build"
RUNS_ON="ubuntu-24.04-arm"
;;
linux-x86_64-glibc)
DOWN_CMD="./bin/spc-gnu-docker download"
BUILD_CMD="./bin/spc-gnu-docker build"
RUNS_ON="ubuntu-22.04"
;;
linux-aarch64-glibc)
DOWN_CMD="./bin/spc-gnu-docker download"
BUILD_CMD="./bin/spc-gnu-docker build"
RUNS_ON="ubuntu-22.04-arm"
;;
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"
;;
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"
;;
esac
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"
BUILD_CMD="$BUILD_CMD ${{ inputs.extensions }}"
if [ -n "${{ inputs.extra-libs }}" ]; then
DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
fi
if [ ${{ inputs.debug }} == true ]; then
DOWN_CMD="$DOWN_CMD --debug"
BUILD_CMD="$BUILD_CMD --debug"
fi
if [ ${{ inputs.prefer-pre-built }} == true ]; then
DOWN_CMD="$DOWN_CMD --prefer-pre-built"
fi
if [ ${{ inputs.build-cli }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-cli"
fi
if [ ${{ inputs.build-micro }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-micro"
fi
if [ ${{ inputs.build-fpm }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-fpm"
fi
echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
build:
name: "Build ${{ inputs.version }} on ${{ inputs.os }}"
runs-on: ${{ needs.define-build.outputs.run }}
needs: define-build
timeout-minutes: 240
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
tools: pecl, composer
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
env:
phpts: nts
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-dependencies-${{ inputs.os }}
- name: "Download sources"
run: ${{ needs.define-build.outputs.download }}
- name: "Build PHP"
run: ${{ needs.define-build.outputs.build }}
#- name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
name: "Upload PHP cli SAPI"
uses: actions/upload-artifact@v4
with:
name: php-cli-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
name: "Upload PHP micro SAPI"
uses: actions/upload-artifact@v4
with:
name: php-micro-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
name: "Upload PHP fpm SAPI"
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
name: "Upload License Files"
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
name: "Upload Build Metadata"
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -6,14 +6,14 @@ on:
version:
required: true
description: php version to compile
default: '8.2'
default: '8.4'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
build-cli:
description: build cli binary
default: true

148
.github/workflows/ext-matrix-tests.yml vendored Normal file
View File

@@ -0,0 +1,148 @@
name: "Extension matrix tests"
on:
workflow_dispatch:
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/ext-matrix-tests.yml'
jobs:
test:
name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})"
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
extension:
- amqp
- apcu
- bcmath
- bz2
- calendar
- ctype
- curl
- dba
- dom
- ds
- event
- exif
- filter
- fileinfo
- ftp
- gd
- gettext
- gmp
- iconv
- igbinary
- imagick
- imap
- intl
- ldap
- mbstring,mbregex
- memcache
- mysqli,mysqlnd,pdo_mysql
- opcache
- openssl
- pcntl
- password-argon2
- pcntl
- pdo
- pgsql,pdo_pgsql
- phar
- posix
- rar
- protobuf
- readline
- redis
- session
- shmop
- simdjson
- simplexml,xml
- snappy
- soap
- sockets
- sodium
- sqlite3,pdo_sqlite
- sqlsrv
- ssh2
- swoole
- swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite
- swow
- sysvmsg,sysvsem,sysvshm
- tidy
- tokenizer
- uuid
- uv
- xhprof
- xlswriter
- xmlwriter,xmlreader
- xsl
- yac
- yaml
- zip
- zlib
- zstd
php-version:
- "8.4"
operating-system:
- "ubuntu-latest"
#- "macos-13"
#- "debian-arm64-self-hosted"
- "macos-14"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: OS type
id: os-type
run: |
OS=""
if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then
OS="linux-x86_64"
elif [ "${{ matrix.operating-system }}" = "macos-13" ]; then
OS="macos-x86_64"
elif [ "${{ matrix.operating-system }}" = "debian-arm64-self-hosted" ]; then
OS="linux-aarch64"
elif [ "${{ matrix.operating-system }}" = "macos-14" ]; then
OS="macos-aarch64"
fi
echo "OS=$OS" >> $GITHUB_ENV
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
tools: pecl, composer
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
env:
phpts: nts
- name: "Install Dependencies"
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ matrix.php-version }}-dependencies-for-tests
# If there's no dependencies cache, fetch sources
- name: "Download sources"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./bin/spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} --debug --ignore-cache-sources=php-src
- name: "Build library: ${{ matrix.library }}"
run: |
SPC_USE_SUDO=yes ./bin/spc doctor --auto-fix
if [ "${{ env.OS }}" = "linux-x86_64" ]; then
./bin/spc install-pkg upx
UPX=--with-upx-pack
elif [ "${{ env.OS }}" = "linux-aarch64" ]; then
./bin/spc install-pkg upx
UPX=--with-upx-pack
fi
./bin/spc build --build-cli --build-micro --build-fpm ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts

View File

@@ -9,8 +9,8 @@ on:
workflow_dispatch:
env:
PHP_VERSION: 8.2
MICRO_VERSION: 8.2.18
PHP_VERSION: 8.4
MICRO_VERSION: 8.4.4
jobs:
build-release-artifacts:

View File

@@ -17,8 +17,7 @@ on:
- 'box.json'
- '.php-cs-fixer.php'
permissions:
contents: read
permissions: read-all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -34,13 +33,13 @@ jobs:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.4'
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
tools: pecl, composer, php-cs-fixer
- name: Run PHP-CS-Fixer fix
run: php-cs-fixer fix --dry-run --diff --ansi
run: PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --dry-run --diff --ansi
phpstan:
runs-on: ubuntu-latest
@@ -52,7 +51,7 @@ jobs:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.4'
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
tools: composer
@@ -79,9 +78,7 @@ jobs:
strategy:
matrix:
include:
- php: '8.1'
- php: '8.2'
- php: '8.3'
- php: '8.4'
steps:
- name: "Checkout"
@@ -102,14 +99,13 @@ jobs:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
${{ runner.os }}-php
- name: "Install Dependencies"
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: "Run PHPUnit Tests"
run: |
SPC_NO_MUSL_PATH=yes vendor/bin/phpunit tests/ --no-coverage
run: SPC_LIBC=glibc vendor/bin/phpunit tests/ --no-coverage
define-matrix:
name: "Define Matrix"
@@ -124,7 +120,7 @@ jobs:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.4
- name: Define
id: gendef
@@ -152,7 +148,7 @@ jobs:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.4
tools: pecl, composer
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
@@ -179,22 +175,26 @@ jobs:
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: "Run Build Tests (doctor)"
run: bin/spc doctor --auto-fix --debug
run: php src/globals/test-extensions.php doctor_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: "Prepare UPX for Windows"
if: matrix.os == 'windows-latest'
if: ${{ startsWith(matrix.os, 'windows-') }}
run: |
bin/spc install-pkg upx
php src/globals/test-extensions.php install_upx_cmd ${{ matrix.os }} ${{ matrix.php }}
echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $env:GITHUB_ENV
- name: "Prepare UPX for Linux"
if: matrix.os == 'ubunut-latest'
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
run: |
bin/spc install-pkg upx
php src/globals/test-extensions.php install_upx_cmd ${{ matrix.os }} ${{ matrix.php }}
echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV
- name: "Run Build Tests (download)"
run: php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}
run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: "Run Build Tests (build)"
run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: "Run Build Tests (build - embed for non-windows)"
if: ${{ !startsWith(matrix.os, 'windows-') }}
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}

View File

@@ -36,7 +36,7 @@ jobs:
with:
coverage: none
tools: composer:v2
php-version: 8.2
php-version: 8.4
ini-values: memory_limit=-1
- name: "Get Composer Cache Directory"

21
.gitignore vendored
View File

@@ -5,22 +5,25 @@ docker/extensions/
docker/source/
# Vendor files
/vendor/
/vendor/**
# default source extract directory
/source/
/source/**
# built by shared embed tests
/locale/
# default source download directory
/downloads/
/downloads/**
# default source build root directory
/buildroot/
/buildroot/**
# default package root directory
/pkgroot/
/pkgroot/**
# default pack:lib and release directory
/dist/
/dist/**
packlib_files.txt
# tools cache files
@@ -32,6 +35,8 @@ packlib_files.txt
!/bin/spc*
!/bin/setup-runtime*
!/bin/spc-alpine-docker
!/bin/php-cs-fixer-wrapper
!/bin/build-static-frankenphp
# exclude windows build tools
/php-sdk-binary-tools/
@@ -45,3 +50,7 @@ packlib_files.txt
/docs/.vitepress/cache/
package-lock.json
pnpm-lock.yaml
# craft.log
craft.log
craft.yml

View File

@@ -64,6 +64,8 @@ return (new PhpCsFixer\Config())
'php_unit_test_class_requires_covers' => false,
'phpdoc_var_without_name' => false,
'fully_qualified_strict_types' => false,
'operator_linebreak' => false,
'php_unit_data_provider_method_order' => false,
])
->setFinder(
PhpCsFixer\Finder::create()->in([__DIR__ . '/src', __DIR__ . '/tests/SPC'])

View File

@@ -58,7 +58,7 @@ static-php-cli简称 `spc`)有许多特性:
### 编译环境需求
- PHP >= 8.1(这是 spc 自身需要的版本,不是支持的构建版本)
- PHP >= 8.4(这是 spc 自身需要的版本,不是支持的构建版本)
- 扩展:`mbstring,tokenizer,phar`
- 系统安装了 `curl``git`
@@ -82,16 +82,18 @@ static-php-cli简称 `spc`)有许多特性:
>
> :x: 不支持
| PHP Version | Status | Comment |
|-------------|--------------------|------------------------------|
| 7.2 | :x: | |
| 7.3 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 7.4 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 8.0 | :heavy_check_mark: | PHP 官方已停止 8.0 的维护 |
| 8.1 | :heavy_check_mark: | PHP 官方仅对 8.1 提供安全更新 |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :x: | WIP |
| 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.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
> 这个表格的支持状态是 static-php-cli 对构建对应版本的支持情况,不是 PHP 官方对该版本的支持情况。
### 支持的扩展
@@ -178,6 +180,9 @@ bin/spc --version
# 检查环境依赖,并根据尝试自动安装缺失的编译工具
./bin/spc doctor --auto-fix
# 输出目标项目依赖的扩展列表
./bin/spc dump-extensions /path/to/your/project --format=text
# 拉取所有依赖库
./bin/spc download --all
# 只拉取编译指定扩展需要的所有依赖(推荐)

View File

@@ -67,7 +67,7 @@ which can be downloaded directly according to your needs.
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.1 (This is the version required by spc itself, not the build version)
- 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
@@ -89,16 +89,19 @@ Currently supported PHP versions for compilation:
>
> :x: not supported
| PHP Version | Status | Comment |
|-------------|--------------------|---------------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :warning: | phpmicro and some extensions not supported on 7.x |
| 7.4 | :warning: | phpmicro and some extensions not supported on 7.x |
| 8.0 | :heavy_check_mark: | PHP official has stopped maintenance of 8.0 |
| 8.1 | :heavy_check_mark: | PHP official has security fixes only |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :x: | WIP |
| 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 |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
> 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
@@ -191,11 +194,13 @@ Basic usage for building php with some extensions:
# 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.1 ~ 8.3)
# 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
@@ -310,7 +315,7 @@ Now there is a [static-php](https://github.com/static-php) organization, which i
## Sponsor this project
You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). A portion of your donation will be used to maintain the **static-php.dev** server.
You can sponsor me or my project from [GitHub Sponsor](https://github.com/crazywhalecc). A portion of your donation will be used to maintain the **static-php.dev** server.
## Open-Source License

158
bin/build-static-frankenphp Executable file
View File

@@ -0,0 +1,158 @@
#!/usr/bin/env bash
# This file is using docker to run commands
set -e
# Detect docker can run
if ! which docker >/dev/null; then
echo "Docker is not installed, please install docker first !"
exit 1
fi
DOCKER_EXECUTABLE="docker"
# shellcheck disable=SC2046
if [ $(id -u) -ne 0 ]; then
if ! docker info > /dev/null 2>&1; then
if [ "$SPC_USE_SUDO" != "yes" ]; then
echo "Docker command requires sudo"
# shellcheck disable=SC2039
echo -n 'To use sudo to run docker, run "export SPC_USE_SUDO=yes" and run command again'
exit 1
fi
DOCKER_EXECUTABLE="sudo docker"
fi
fi
# to check if qemu-docker run
if [ "$SPC_USE_ARCH" = "" ]; then
SPC_USE_ARCH=current
fi
case $SPC_USE_ARCH in
current)
BASE_ARCH=$(uname -m)
if [ "$BASE_ARCH" = "arm64" ]; then
BASE_ARCH=aarch64
GO_ARCH=arm64
else
GO_ARCH=amd64
fi
;;
aarch64)
BASE_ARCH=aarch64
GO_ARCH=arm64
# shellcheck disable=SC2039
echo -e "\e[033m* Using different arch needs to setup qemu-static for docker !\e[0m"
$DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null
;;
*)
echo "Current arch is not supported to run in docker: $SPC_USE_ARCH"
exit 1
;;
esac
# Detect docker env is setup
if ! $DOCKER_EXECUTABLE images | grep -q cwcc-frankenphp-gnu-$SPC_USE_ARCH; then
echo "Docker container does not exist. Building docker image ..."
$DOCKER_EXECUTABLE build -t cwcc-frankenphp-gnu-$SPC_USE_ARCH -f- . <<EOF
FROM centos:7
RUN sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
RUN yum clean all && \
yum makecache && \
yum update -y && \
localedef -c -i en_US -f UTF-8 en_US.UTF-8
RUN yum install -y centos-release-scl
RUN if [ "$BASE_ARCH" = "aarch64" ]; then \
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo ; \
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl.repo ; \
else \
sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo ; \
fi
RUN sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
RUN yum update -y && \
yum install -y devtoolset-10-gcc-*
RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc
RUN source /etc/bashrc
RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \
mkdir /cmake && \
tar -xzf cmake.tgz -C /cmake --strip-components 1
WORKDIR /app
ADD ./src /app/src
COPY ./composer.* /app/
ADD ./bin/setup-runtime /app/bin/setup-runtime
ADD ./bin/spc /app/bin/spc
RUN /app/bin/setup-runtime
RUN /app/bin/php /app/bin/composer install --no-dev --classmap-authoritative
ENV PATH="/app/bin:/cmake/bin:/usr/local/go/bin:$PATH"
ENV SPC_LIBC=glibc
ADD ./config/env.ini /app/config/env.ini
RUN bin/spc doctor --auto-fix --debug
RUN curl -o make.tgz -fsSL https://ftp.gnu.org/gnu/make/make-4.4.tar.gz && \
tar -zxvf make.tgz && \
cd make-4.4 && \
./configure && \
make && \
make install && \
ln -sf /usr/local/bin/make /usr/bin/make
RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.tar.xz && \
tar -xvf automake.tgz && \
cd automake-1.17 && \
./configure && \
make && \
make install && \
ln -sf /usr/local/bin/automake /usr/bin/automake
RUN git clone https://github.com/static-php/gnu-frankenphp --depth=1 /frankenphp
WORKDIR /frankenphp
RUN curl -o go.tgz -fsSL https://go.dev/dl/go1.24.1.linux-$GO_ARCH.tar.gz && \
rm -rf /usr/local/go && tar -C /usr/local -xzf go.tgz
EOF
fi
# Check if in ci (local terminal can execute with -it)
if [ -t 0 ]; then
INTERACT=-it
else
INTERACT=''
fi
# Mounting volumes
MOUNT_LIST=""
# shellcheck disable=SC2089
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/config:/app/config"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/src:/app/src"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/buildroot:/app/buildroot"
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)""/frankenphp-dist:/frankenphp/dist"
# Apply env in temp env file
echo 'CC=/opt/rh/devtoolset-10/root/usr/bin/gcc' > /tmp/spc-gnu-docker.env
echo 'CXX=/opt/rh/devtoolset-10/root/usr/bin/g++' >> /tmp/spc-gnu-docker.env
echo 'AR=/opt/rh/devtoolset-10/root/usr/bin/ar' >> /tmp/spc-gnu-docker.env
echo 'LD=/opt/rh/devtoolset-10/root/usr/bin/ld' >> /tmp/spc-gnu-docker.env
echo 'SPC_DEFAULT_C_FLAGS=-fPIE -fPIC' >> /tmp/spc-gnu-docker.env
echo 'SPC_LIBC=glibc' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"' >> /tmp/spc-gnu-docker.env
# Run docker
# shellcheck disable=SC2068
# shellcheck disable=SC2086
# shellcheck disable=SC2090
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-frankenphp-gnu-$SPC_USE_ARCH ./build-static.sh

4
bin/php-cs-fixer-wrapper Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env bash
# get parent dir, and run the php-cs-fixer
PHP_CS_FIXER_IGNORE_ENV=1 "$(dirname "$0")/../vendor/bin/php-cs-fixer" "$@"

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.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-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.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://mirrors.tencent.com/composer/composer.phar"
;;
@@ -61,7 +61,7 @@ test -f "${__PROJECT__}"/downloads/runtime.tar.gz || { echo "Downloading $__PHP_
test -f "${__DIR__}"/php || { tar -xf "${__PROJECT__}"/downloads/runtime.tar.gz -C "${__DIR__}"/ ; }
chmod +x "${__DIR__}"/php
# download composer
test -f "${__DIR__}"/composer || curl -#fSL -o "${__DIR__}"/composer "$__COMPOSER_URL__"
test -f "${__DIR__}"/composer || { echo "Downloading Composer from $__COMPOSER_URL__" && curl -#fSL -o "${__DIR__}"/composer "$__COMPOSER_URL__" ; }
chmod +x "${__DIR__}"/composer
# sanity check for php and composer
"${__DIR__}"/php -v >/dev/null || { echo "Failed to run php" && exit 1; }

View File

@@ -51,10 +51,11 @@ if ($action -eq 'add-path') {
}
# get php 8.1 specific version
$API = (Invoke-WebRequest -Uri "https://www.php.net/releases/index.php?json&version=8.3") | ConvertFrom-Json
# php windows download
$PHPRuntimeUrl = "https://windows.php.net/downloads/releases/php-" + $API.version + "-nts-Win32-vs16-x64.zip"
$PHPRuntimeUrl = "https://windows.php.net/downloads/releases/archives/php-8.4.4-nts-Win32-vs17-x64.zip"
Write-Host "Downloading PHP from: " -NoNewline
Write-Host $PHPRuntimeUrl -ForegroundColor Cyan
$ComposerUrl = "https://getcomposer.org/download/latest-stable/composer.phar"
# create dir

10
bin/spc
View File

@@ -4,6 +4,11 @@
use SPC\ConsoleApplication;
use SPC\exception\ExceptionHandler;
// Load custom php if exists
if (PHP_OS_FAMILY !== 'Windows' && PHP_BINARY !== (__DIR__ . '/php') && file_exists(__DIR__ . '/php') && is_executable(__DIR__ . '/php')) {
pcntl_exec(__DIR__ . '/php', $argv);
}
if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
// Current: ./bin (git/project mode)
require_once dirname(__DIR__) . '/vendor/autoload.php';
@@ -17,6 +22,11 @@ if (PHP_OS_FAMILY === 'Windows' && Phar::running()) {
exec('CHCP 65001');
}
// Print deprecation notice on PHP < 8.4, use red and highlight background
if (PHP_VERSION_ID < 80400) {
echo "\e[43mDeprecation Notice: PHP < 8.4 is deprecated, please upgrade your PHP version.\e[0m\n";
}
try {
(new ConsoleApplication())->run();
} catch (Exception $e) {

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env sh
# This file is using docker to run commands
SPC_DOCKER_VERSION=v3
# Detect docker can run
if ! which docker >/dev/null; then
@@ -50,9 +51,9 @@ else
fi
# Detect docker env is setup
if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-$SPC_USE_ARCH; then
if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION; then
echo "Docker container does not exist. Building docker image ..."
$DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH -f- . <<EOF
$DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION -f- . <<EOF
FROM $ALPINE_FROM
$SPC_USE_MIRROR
RUN apk update; \
@@ -79,26 +80,23 @@ RUN apk update; \
linux-headers \
m4 \
make \
php82 \
php82-common \
php82-pcntl \
php82-phar \
php82-posix \
php82-sodium \
php82-tokenizer \
php82-dom \
php82-xml \
php82-xmlwriter \
composer \
pkgconfig \
wget \
xz
xz \
gettext-dev \
binutils-gold
RUN curl -#fSL https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-linux-\$(uname -m).tar.gz | tar -xz -C /usr/local/bin && \
chmod +x /usr/local/bin/php
RUN curl -#fSL https://getcomposer.org/download/latest-stable/composer.phar -o /usr/local/bin/composer && \
chmod +x /usr/local/bin/composer
WORKDIR /app
ADD ./src /app/src
COPY ./composer.* /app/
ADD ./bin /app/bin
RUN composer install --no-dev --classmap-authoritative
RUN composer install --no-dev
EOF
fi
@@ -119,9 +117,37 @@ 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"
if [ -f "$(pwd)/craft.yml" ]; then
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
fi
# Environment variable passthrough
ENV_LIST=""
ENV_LIST="$ENV_LIST -e SPC_FIX_DEPLOY_ROOT="$(pwd)""
if [ ! -z "$GITHUB_TOKEN" ]; then
ENV_LIST="$ENV_LIST -e GITHUB_TOKEN=$GITHUB_TOKEN"
fi
# Run docker
# shellcheck disable=SC2068
# shellcheck disable=SC2086
# shellcheck disable=SC2090
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH bin/spc $@
if [ "$SPC_DOCKER_DEBUG" = "yes" ]; then
echo "* Debug mode enabled, run docker in interactive mode."
echo "* You can use 'exit' to exit the docker container."
echo "* You can use 'bin/spc' like normal builds."
echo "*"
echo "* Mounted directories:"
echo "* ./config: $(pwd)/config"
echo "* ./src: $(pwd)/src"
echo "* ./buildroot: $(pwd)/buildroot"
echo "* ./source: $(pwd)/source"
echo "* ./dist: $(pwd)/dist"
echo "* ./downloads: $(pwd)/downloads"
echo "* ./pkgroot: $(pwd)/pkgroot"
echo "*"
set -ex
$DOCKER_EXECUTABLE run --rm $INTERACT $ENV_LIST $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION
else
$DOCKER_EXECUTABLE run --rm $INTERACT $ENV_LIST $MOUNT_LIST cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION bin/spc $@
fi

174
bin/spc-gnu-docker Executable file
View File

@@ -0,0 +1,174 @@
#!/usr/bin/env bash
# Detect docker can run
if ! which docker >/dev/null; then
echo "Docker is not installed, please install docker first !"
exit 1
fi
DOCKER_EXECUTABLE="docker"
# shellcheck disable=SC2046
if [ $(id -u) -ne 0 ]; then
if ! docker info > /dev/null 2>&1; then
if [ "$SPC_USE_SUDO" != "yes" ] && [ "$SPC_DOCKER_DEBUG" != "yes" ]; then
echo "Docker command requires sudo"
# shellcheck disable=SC2039
echo -n 'To use sudo to run docker, run "export SPC_USE_SUDO=yes" and run command again'
exit 1
fi
DOCKER_EXECUTABLE="sudo docker"
fi
fi
# to check if qemu-docker run
if [ "$SPC_USE_ARCH" = "" ]; then
SPC_USE_ARCH=current
fi
case $SPC_USE_ARCH in
current)
BASE_ARCH=$(uname -m)
if [ "$BASE_ARCH" = "arm64" ]; then
BASE_ARCH=aarch64
fi
;;
aarch64)
BASE_ARCH=aarch64
# shellcheck disable=SC2039
echo -e "\e[033m* Using different arch needs to setup qemu-static for docker !\e[0m"
$DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null
;;
*)
echo "Current arch is not supported to run in docker: $SPC_USE_ARCH"
exit 1
;;
esac
# Detect docker env is setup
if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-gnu-$SPC_USE_ARCH; then
echo "Docker container does not exist. Building docker image ..."
$DOCKER_EXECUTABLE build -t cwcc-spc-gnu-$SPC_USE_ARCH -f- . <<EOF
FROM centos:7
RUN sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
RUN yum clean all && \
yum makecache && \
yum update -y && \
localedef -c -i en_US -f UTF-8 en_US.UTF-8
RUN yum install -y centos-release-scl
RUN if [ "$BASE_ARCH" = "aarch64" ]; then \
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo ; \
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl.repo ; \
else \
sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo ; \
fi
RUN sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
RUN yum update -y && \
yum install -y devtoolset-10-gcc-*
RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc
RUN source /etc/bashrc
RUN yum install -y which
RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \
mkdir /cmake && \
tar -xzf cmake.tgz -C /cmake --strip-components 1
WORKDIR /app
ADD ./src /app/src
COPY ./composer.* /app/
ADD ./bin/setup-runtime /app/bin/setup-runtime
ADD ./bin/spc /app/bin/spc
RUN /app/bin/setup-runtime
RUN /app/bin/php /app/bin/composer install --no-dev
ENV PATH="/app/bin:/cmake/bin:$PATH"
ENV SPC_LIBC=glibc
ADD ./config/env.ini /app/config/env.ini
RUN bin/spc doctor --auto-fix --debug
RUN curl -o make.tgz -fsSL https://ftp.gnu.org/gnu/make/make-4.4.tar.gz && \
tar -zxvf make.tgz && \
cd make-4.4 && \
./configure && \
make && \
make install && \
ln -sf /usr/local/bin/make /usr/bin/make
RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.tar.xz && \
tar -xvf automake.tgz && \
cd automake-1.17 && \
./configure && \
make && \
make install && \
ln -sf /usr/local/bin/automake /usr/bin/automake
EOF
fi
# Check if in ci (local terminal can execute with -it)
if [ -t 0 ]; then
INTERACT=-it
else
INTERACT=''
fi
# Mounting volumes
MOUNT_LIST=""
# shellcheck disable=SC2089
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/config:/app/config"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/src:/app/src"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/buildroot:/app/buildroot"
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"
if [ -f "$(pwd)/craft.yml" ]; then
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/craft.yml:/app/craft.yml"
fi
# Apply env in temp env file
echo 'CC=/opt/rh/devtoolset-10/root/usr/bin/gcc' > /tmp/spc-gnu-docker.env
echo 'CXX=/opt/rh/devtoolset-10/root/usr/bin/g++' >> /tmp/spc-gnu-docker.env
echo 'AR=/opt/rh/devtoolset-10/root/usr/bin/ar' >> /tmp/spc-gnu-docker.env
echo 'LD=/opt/rh/devtoolset-10/root/usr/bin/ld' >> /tmp/spc-gnu-docker.env
echo 'SPC_DEFAULT_C_FLAGS=-fPIE -fPIC' >> /tmp/spc-gnu-docker.env
echo 'SPC_LIBC=glibc' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"' >> /tmp/spc-gnu-docker.env
# Environment variable passthrough
ENV_LIST=""
ENV_LIST="$ENV_LIST -e SPC_FIX_DEPLOY_ROOT="$(pwd)""
if [ ! -z "$GITHUB_TOKEN" ]; then
ENV_LIST="$ENV_LIST -e GITHUB_TOKEN=$GITHUB_TOKEN"
fi
# Run docker
# shellcheck disable=SC2068
# shellcheck disable=SC2086
# shellcheck disable=SC2090
if [ "$SPC_DOCKER_DEBUG" = "yes" ]; then
echo "* Debug mode enabled, run docker in interactive mode."
echo "* You can use 'exit' to exit the docker container."
echo "* You can use 'bin/spc' like normal builds."
echo "*"
echo "* Mounted directories:"
echo "* ./config: $(pwd)/config"
echo "* ./src: $(pwd)/src"
echo "* ./buildroot: $(pwd)/buildroot"
echo "* ./source: $(pwd)/source"
echo "* ./dist: $(pwd)/dist"
echo "* ./downloads: $(pwd)/downloads"
echo "* ./pkgroot: $(pwd)/pkgroot"
echo "*"
set -ex
$DOCKER_EXECUTABLE run --rm -it --privileged $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH
else
$DOCKER_EXECUTABLE run --rm $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH bin/spc $@
fi

View File

@@ -9,17 +9,19 @@
}
],
"require": {
"php": ">= 8.1",
"php": ">= 8.3",
"ext-mbstring": "*",
"ext-zlib": "*",
"laravel/prompts": "^0.1.12",
"symfony/console": "^5.4 || ^6 || ^7",
"symfony/process": "^7.2",
"symfony/yaml": "^7.2",
"zhamao/logger": "^1.0"
},
"require-dev": {
"captainhook/captainhook-phar": "^5.23",
"captainhook/hook-installer": "^1.0",
"friendsofphp/php-cs-fixer": "^3.25",
"friendsofphp/php-cs-fixer": "^3.60",
"humbug/box": "^4.5.0 || ^4.6.0",
"nunomaduro/collision": "^7.8",
"phpstan/phpstan": "^1.10",

2840
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,8 +7,11 @@
;
; 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.
; Here's a list of these pre-defined internal env vars, these vars are only be defined in the static-php-cli build process if not set in the shell environment:
;
; Here's a list of env vars, these value cannot be changed anywhere:
;
; 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`)
@@ -17,25 +20,19 @@
; 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`)
;
; Here's a list of env vars, these value cannot be changed anywhere:
;
; 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`)
;
; * These vars are only be defined in Unix (macOS, Linux, FreeBSD)Builder *
; * 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.
; SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS: the default optimization CFLAGS for compiling php. (if --no-strip option is set: `-g -O0`, else: `-g -Os`)
;
; * These vars are only be defined in LinuxBuilder *
; * 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_PHP_DEFAULT_LD_LIBRARY_PATH_CMD: the default LD_LIBRARY_PATH for php. (linux: `LD_LIBRARY_PATH=/usr/local/musl/$GNU_ARCH-linux-musl/lib`, default: empty)
[global]
@@ -45,6 +42,14 @@ SPC_CONCURRENCY=${CPU_COUNT}
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=""
; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them
; only useful for builds targeting not pure-static linking
; default paths
; Ubuntu/Debian: /usr/lib/php/{PHP_VERSION}/
; RHEL: /usr/lib64/php/modules
; Alpine: /usr/lib/php{PHP_VERSION}/modules
; where {PHP_VERSION} is 84 for php 8.4
; EXTENSION_DIR=
[windows]
; php-sdk-binary-tools path
@@ -56,15 +61,15 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
[linux]
; include PATH for musl libc.
SPC_NO_MUSL_PATH=no
SPC_LIBC=musl
; compiler environments
CC=${SPC_LINUX_DEFAULT_CC}
CXX=${SPC_LINUX_DEFAULT_CXX}
AR=${SPC_LINUX_DEFAULT_AR}
LD=ld.gold
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
SPC_DEFAULT_C_FLAGS=
SPC_DEFAULT_CXX_FLAGS=
SPC_DEFAULT_C_FLAGS="-fpic -Os"
SPC_DEFAULT_CXX_FLAGS="-fpic -Os"
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
SPC_EXTRA_LIBS=
; upx executable path
@@ -76,13 +81,15 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
; buildconf command
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
; configure command
SPC_CMD_PREFIX_PHP_CONFIGURE="${SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
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${CPU_COUNT}"
; embed type for php, static (libphp.a) or shared (libphp.so)
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; *** default build vars for building php ***
; CFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS}"
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fpie"
; CPPFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
; LDFLAGS for configuring php
@@ -90,19 +97,21 @@ SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
; LIBS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm"
; EXTRA_CFLAGS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS} -fno-ident -fPIE"
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fpie ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_LIBS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS=""
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm"
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
; EXTRA_LDFLAGS_PROGRAM for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static"
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static -Wl,-O1 -pie"
[macos]
; compiler environments
CC=clang
CXX=clang++
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin"
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin"
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
SPC_EXTRA_LIBS=
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
@@ -124,9 +133,11 @@ SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
; LDFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
; EXTRA_CFLAGS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS}"
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_LIBS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv"
; embed type for php, static (libphp.a) or shared (libphp.dylib)
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
[freebsd]
; compiler environments

View File

@@ -17,9 +17,21 @@
"type": "external",
"source": "apcu"
},
"ast": {
"type": "external",
"source": "ast"
},
"bcmath": {
"type": "builtin"
},
"brotli": {
"type": "external",
"source": "ext-brotli",
"arg-type": "enable",
"lib-depends": [
"brotli"
]
},
"bz2": {
"type": "builtin",
"arg-type-unix": "with-prefix",
@@ -53,6 +65,13 @@
"qdbm"
]
},
"dio": {
"support": {
"BSD": "wip"
},
"type": "external",
"source": "dio"
},
"dom": {
"support": {
"BSD": "wip"
@@ -81,6 +100,14 @@
},
"type": "wip"
},
"ev": {
"type": "external",
"source": "ev",
"arg-type-windows": "with",
"ext-depends": [
"sockets"
]
},
"event": {
"support": {
"Windows": "wip",
@@ -105,7 +132,7 @@
},
"ffi": {
"support": {
"Linux": "no",
"Linux": "partial",
"BSD": "wip"
},
"notes": true,
@@ -199,6 +226,19 @@
"gmssl"
]
},
"grpc": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"type": "external",
"source": "grpc",
"arg-type-unix": "custom",
"cpp-extension": true,
"lib-depends": [
"grpc"
]
},
"iconv": {
"support": {
"BSD": "wip"
@@ -229,6 +269,7 @@
"Windows": "wip",
"BSD": "wip"
},
"notes": true,
"type": "external",
"source": "ext-imagick",
"arg-type": "custom",
@@ -242,7 +283,8 @@
"BSD": "wip"
},
"notes": true,
"type": "builtin",
"type": "external",
"source": "ext-imap",
"arg-type": "custom",
"lib-depends": [
"imap"
@@ -294,13 +336,28 @@
},
"type": "builtin",
"arg-type": "none",
"ext-depends": [
"xml"
"target": [
"static"
]
},
"lz4": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"type": "external",
"source": "ext-lz4",
"arg-type": "custom",
"lib-depends": [
"liblz4"
]
},
"mbregex": {
"type": "builtin",
"arg-type": "custom",
"target": [
"static"
],
"ext-depends": [
"mbstring"
],
@@ -330,18 +387,16 @@
"type": "external",
"source": "ext-memcache",
"arg-type": "custom",
"lib-depends": [
"zlib"
],
"ext-depends": [
"zlib",
"session"
]
],
"build-with-php": true
},
"memcached": {
"support": {
"Windows": "wip",
"BSD": "wip",
"Linux": "no"
"BSD": "wip"
},
"type": "external",
"source": "memcached",
@@ -350,6 +405,10 @@
"lib-depends": [
"libmemcached"
],
"lib-depends-unix": [
"libmemcached",
"fastlz"
],
"ext-depends": [
"session",
"zlib"
@@ -368,6 +427,10 @@
"openssl",
"zstd",
"zlib"
],
"frameworks": [
"CoreFoundation",
"Security"
]
},
"msgpack": {
@@ -377,7 +440,10 @@
"type": "external",
"source": "msgpack",
"arg-type-unix": "with",
"arg-type-win": "enable"
"arg-type-win": "enable",
"ext-depends": [
"session"
]
},
"mysqli": {
"type": "builtin",
@@ -403,9 +469,21 @@
},
"notes": true
},
"odbc": {
"support": {
"BSD": "wip",
"Windows": "wip"
},
"type": "builtin",
"arg-type-unix": "custom",
"lib-depends-unix": [
"unixodbc"
]
},
"opcache": {
"type": "builtin",
"arg-type-unix": "custom"
"arg-type-unix": "custom",
"zend-extension": true
},
"openssl": {
"notes": true,
@@ -420,6 +498,13 @@
"zlib"
]
},
"opentelemetry": {
"support": {
"BSD": "wip"
},
"type": "external",
"source": "opentelemetry"
},
"parallel": {
"support": {
"BSD": "wip"
@@ -462,19 +547,36 @@
"mysqlnd"
]
},
"pdo_odbc": {
"support": {
"BSD": "wip"
},
"type": "builtin",
"arg-type": "custom",
"lib-depends-unix": [
"unixodbc"
],
"ext-depends": [
"pdo",
"odbc"
]
},
"pdo_pgsql": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type-windows": "custom",
"ext-depends": [
"pdo",
"pgsql"
],
"lib-depends": [
"lib-depends-unix": [
"postgresql"
],
"lib-depends-windows": [
"postgresql-win"
]
},
"pdo_sqlite": {
@@ -505,14 +607,16 @@
},
"pgsql": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"notes": true,
"type": "builtin",
"arg-type": "with-prefix",
"lib-depends": [
"arg-type": "custom",
"lib-depends-unix": [
"postgresql"
],
"lib-depends-windows": [
"postgresql-win"
]
},
"phar": {
@@ -546,6 +650,19 @@
"source": "rar",
"cpp-extension": true
},
"rdkafka": {
"support": {
"BSD": "wip",
"Windows": "wip"
},
"type": "external",
"source": "ext-rdkafka",
"arg-type": "custom",
"cpp-extension": true,
"lib-depends": [
"librdkafka"
]
},
"readline": {
"support": {
"Windows": "wip",
@@ -555,6 +672,9 @@
"arg-type": "with-prefix",
"lib-depends": [
"readline"
],
"target": [
"static"
]
},
"redis": {
@@ -574,10 +694,12 @@
]
},
"session": {
"type": "builtin"
"type": "builtin",
"build-with-php": true
},
"shmop": {
"type": "builtin"
"type": "builtin",
"build-with-php": true
},
"simdjson": {
"type": "external",
@@ -595,7 +717,8 @@
],
"ext-depends-windows": [
"xml"
]
],
"build-with-php": true
},
"snappy": {
"support": {
@@ -631,7 +754,6 @@
},
"sodium": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"type": "builtin",
@@ -689,7 +811,7 @@
"lib-depends": [
"libssh2"
],
"ext-depends-windows": [
"ext-depends": [
"openssl",
"zlib"
]
@@ -816,7 +938,8 @@
]
},
"tokenizer": {
"type": "builtin"
"type": "builtin",
"build-with-php": true
},
"uuid": {
"support": {
@@ -846,14 +969,19 @@
]
},
"xdebug": {
"type": "builtin",
"type": "external",
"source": "xdebug",
"target": [
"shared"
],
"support": {
"Windows": "wip",
"BSD": "no",
"Darwin": "no",
"Linux": "no"
"Darwin": "partial",
"Linux": "partial"
},
"notes": true
"notes": true,
"zend-extension": true
},
"xhprof": {
"support": {
@@ -865,11 +993,11 @@
"source": "xhprof",
"ext-depends": [
"ctype"
]
],
"build-with-php": true
},
"xlswriter": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"type": "external",
@@ -896,7 +1024,8 @@
],
"ext-depends-windows": [
"iconv"
]
],
"build-with-php": true
},
"xmlreader": {
"support": {
@@ -910,7 +1039,8 @@
"ext-depends-windows": [
"xml",
"dom"
]
],
"build-with-php": true
},
"xmlwriter": {
"support": {
@@ -923,7 +1053,8 @@
],
"ext-depends-windows": [
"xml"
]
],
"build-with-php": true
},
"xsl": {
"support": {
@@ -940,6 +1071,14 @@
"dom"
]
},
"xz": {
"type": "external",
"source": "ext-xz",
"arg-type": "with",
"lib-depends": [
"xz"
]
},
"yac": {
"support": {
"BSD": "wip"
@@ -947,6 +1086,9 @@
"type": "external",
"source": "yac",
"arg-type-unix": "custom",
"lib-depends-unix": [
"fastlz"
],
"ext-depends-unix": [
"igbinary"
]
@@ -990,6 +1132,9 @@
"arg-type-windows": "enable",
"lib-depends": [
"zlib"
],
"target": [
"static"
]
},
"zstd": {

View File

@@ -1,4 +1,38 @@
{
"lib-base": {
"type": "root",
"lib-depends-unix": [
"pkg-config"
]
},
"php": {
"type": "root",
"source": "php-src",
"lib-depends": [
"lib-base",
"micro"
],
"lib-suggests-linux": [
"libacl"
]
},
"micro": {
"type": "target",
"source": "micro"
},
"pkg-config": {
"type": "package",
"source": "pkg-config",
"bin-unix": [
"pkg-config"
]
},
"attr": {
"source": "attr",
"static-libs-unix": [
"libattr.a"
]
},
"brotli": {
"source": "brotli",
"static-libs-unix": [
@@ -44,7 +78,6 @@
"zlib"
],
"lib-depends-windows": [
"openssl",
"zlib",
"libssh2",
"nghttp2"
@@ -53,6 +86,8 @@
"libssh2",
"brotli",
"nghttp2",
"nghttp3",
"ngtcp2",
"zstd",
"libcares"
],
@@ -66,6 +101,15 @@
"SystemConfiguration"
]
},
"fastlz": {
"source": "fastlz",
"static-libs-unix": [
"libfastlz.a"
],
"headers": [
"fastlz/fastlz.h"
]
},
"freetype": {
"source": "freetype",
"static-libs-unix": [
@@ -139,6 +183,20 @@
"Security"
]
},
"grpc": {
"source": "grpc",
"static-libs-unix": [
"libgrpc.a",
"libcares.a"
],
"lib-depends": [
"zlib",
"openssl"
],
"frameworks": [
"CoreFoundation"
]
},
"icu": {
"source": "icu",
"cpp-library": true,
@@ -162,12 +220,13 @@
"libjpeg",
"libwebp",
"freetype",
"libtiff"
"libtiff",
"libheif",
"bzip2"
],
"lib-suggests": [
"zstd",
"xz",
"bzip2",
"libzip",
"libxml2"
]
@@ -184,8 +243,8 @@
"ldap": {
"source": "ldap",
"static-libs-unix": [
"liblber.a",
"libldap.a"
"libldap.a",
"liblber.a"
],
"lib-depends": [
"openssl",
@@ -194,6 +253,22 @@
"libsodium"
]
},
"libacl": {
"source": "libacl",
"static-libs-unix": [
"libacl.a"
],
"lib-depends": [
"attr"
]
},
"libaom": {
"source": "libaom",
"static-libs-unix": [
"libaom.a"
],
"cpp-library": true
},
"libargon2": {
"source": "libargon2",
"static-libs-unix": [
@@ -217,10 +292,16 @@
"headers-unix": [
"ares.h",
"ares_dns.h",
"ares_nameser.h",
"ares_rules.h"
"ares_nameser.h"
]
},
"libde265": {
"source": "libde265",
"static-libs-unix": [
"libde265.a"
],
"cpp-library": true
},
"libevent": {
"source": "libevent",
"static-libs-unix": [
@@ -262,6 +343,19 @@
"fficonfig.h"
]
},
"libheif": {
"source": "libheif",
"static-libs-unix": [
"libheif.a"
],
"lib-depends": [
"libde265",
"libwebp",
"libaom",
"zlib",
"brotli"
]
},
"libiconv": {
"source": "libiconv",
"static-libs-unix": [
@@ -304,7 +398,9 @@
"source": "libmemcached",
"static-libs-unix": [
"libmemcached.a",
"libmemcachedutil.a"
"libmemcachedprotocol.a",
"libmemcachedutil.a",
"libhashkit.a"
]
},
"libpng": {
@@ -341,10 +437,25 @@
"openssl"
]
},
"librdkafka": {
"source": "librdkafka",
"static-libs-unix": [
"librdkafka.a",
"librdkafka++.a",
"librdkafka-static.a"
],
"cpp-library": true,
"lib-suggests": [
"zstd"
]
},
"libsodium": {
"source": "libsodium",
"static-libs-unix": [
"libsodium.a"
],
"static-libs-windows": [
"libsodium.lib"
]
},
"libssh2": {
@@ -371,6 +482,10 @@
"source": "libtiff",
"static-libs-unix": [
"libtiff.a"
],
"lib-depends": [
"zlib",
"libjpeg"
]
},
"libuuid": {
@@ -485,6 +600,12 @@
"openssl"
]
},
"mimalloc": {
"source": "mimalloc",
"static-libs-unix": [
"mimalloc.o"
]
},
"ncurses": {
"source": "ncurses",
"static-libs-unix": [
@@ -507,7 +628,45 @@
"openssl"
],
"lib-suggests": [
"libxml2"
"libxml2",
"nghttp3",
"ngtcp2"
]
},
"nghttp3": {
"source": "nghttp3",
"static-libs-unix": [
"libnghttp3.a"
],
"static-libs-windows": [
"nghttp3.lib"
],
"headers": [
"nghttp3"
],
"lib-depends": [
"openssl"
]
},
"ngtcp2": {
"source": "ngtcp2",
"static-libs-unix": [
"libngtcp2.a",
"libngtcp2_crypto_ossl.a"
],
"static-libs-windows": [
"ngtcp2.lib",
"ngtcp2_crypto_ossl.lib"
],
"headers": [
"ngtcp2"
],
"lib-depends": [
"openssl"
],
"lib-suggests": [
"nghttp3",
"brotli"
]
},
"onig": {
@@ -541,9 +700,6 @@
"zlib"
]
},
"pkg-config": {
"source": "pkg-config"
},
"postgresql": {
"source": "postgresql",
"static-libs-unix": [
@@ -565,6 +721,14 @@
"zstd"
]
},
"postgresql-win": {
"source": "postgresql-win",
"static-libs": [
"libpq.lib",
"libpgport.lib",
"libpgcommon.lib"
]
},
"pthreads4w": {
"source": "pthreads4w",
"static-libs-windows": [

View File

@@ -9,7 +9,7 @@
},
"nasm-x86_64-win": {
"type": "url",
"url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip",
"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"

View File

@@ -1,6 +1,7 @@
{
"repo": "static-php/static-php-cli-hosted",
"prefer-stable": true,
"match-pattern": "{name}-{arch}-{os}.txz",
"suffix": "txz"
}
"match-pattern-linux": "{name}-{arch}-{os}-{libc}-{libcver}.txz",
"match-pattern-macos": "{name}-{arch}-{os}.txz",
"match-pattern-windows": "{name}-{arch}-{os}.tgz"
}

View File

@@ -26,9 +26,33 @@
"path": "LICENSE"
}
},
"ast": {
"type": "url",
"url": "https://pecl.php.net/get/ast",
"path": "php-src/ext/ast",
"filename": "ast.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"attr": {
"alt": {
"type": "url",
"url": "https://mirror.souseiseki.middlendian.com/nongnu/attr/attr-2.5.2.tar.gz"
},
"type": "url",
"url": "https://download.savannah.nongnu.org/releases/attr/attr-2.5.2.tar.gz",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "doc/COPYING"
}
},
"brotli": {
"type": "ghtar",
"type": "ghtagtar",
"repo": "google/brotli",
"match": "v1\\.\\d.*",
"provide-pre-built": true,
"license": {
"type": "file",
@@ -36,9 +60,13 @@
}
},
"bzip2": {
"type": "filelist",
"url": "https://sourceware.org/pub/bzip2/",
"regex": "/href=\"(?<file>bzip2-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"alt": {
"type": "filelist",
"url": "https://sourceware.org/pub/bzip2/",
"regex": "/href=\"(?<file>bzip2-(?<version>[^\"]+)\\.tar\\.gz)\"/"
},
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/bzip2/bzip2-1.0.8.tar.gz",
"provide-pre-built": true,
"license": {
"type": "text",
@@ -55,6 +83,36 @@
"path": "COPYING"
}
},
"dio": {
"type": "url",
"url": "https://pecl.php.net/get/dio",
"path": "php-src/ext/dio",
"filename": "dio.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ev": {
"type": "url",
"url": "https://pecl.php.net/get/ev",
"path": "php-src/ext/ev",
"filename": "ev.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-brotli": {
"type": "git",
"path": "php-src/ext/brotli",
"rev": "master",
"url": "https://github.com/kjdev/php-ext-brotli",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-ds": {
"type": "url",
"url": "https://pecl.php.net/get/ds",
@@ -102,6 +160,29 @@
"path": "LICENSE"
}
},
"ext-imap": {
"type": "url",
"url": "https://pecl.php.net/get/imap",
"path": "php-src/ext/imap",
"filename": "imap.tgz",
"license": {
"type": "file",
"path": [
"LICENSE"
]
}
},
"ext-lz4": {
"type": "ghtagtar",
"repo": "kjdev/php-ext-lz4",
"path": "php-src/ext/lz4",
"license": {
"type": "file",
"path": [
"LICENSE"
]
}
},
"ext-memcache": {
"type": "url",
"url": "https://pecl.php.net/get/memcache",
@@ -112,6 +193,15 @@
"path": "LICENSE"
}
},
"ext-rdkafka": {
"type": "ghtar",
"repo": "arnaud-lb/php-rdkafka",
"path": "php-src/ext/rdkafka",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-simdjson": {
"type": "url",
"url": "https://pecl.php.net/get/simdjson",
@@ -162,6 +252,16 @@
"path": "LICENSE"
}
},
"ext-xz": {
"type": "git",
"path": "php-src/ext/xz",
"rev": "main",
"url": "https://github.com/codemasher/php-ext-xz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-zstd": {
"type": "git",
"path": "php-src/ext/zstd",
@@ -172,6 +272,15 @@
"path": "LICENSE"
}
},
"fastlz": {
"type": "git",
"url": "https://github.com/ariya/FastLZ.git",
"rev": "master",
"license": {
"type": "file",
"path": "LICENSE.MIT"
}
},
"freetype": {
"type": "git",
"rev": "VER-2-13-2",
@@ -206,6 +315,17 @@
"gmssl": {
"type": "ghtar",
"repo": "guanzhi/GmSSL",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"grpc": {
"type": "git",
"rev": "v1.68.x",
"url": "https://github.com/grpc/grpc.git",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "LICENSE"
@@ -268,6 +388,29 @@
"path": "LICENSE"
}
},
"libacl": {
"alt": {
"type": "url",
"url": "https://mirror.souseiseki.middlendian.com/nongnu/acl/acl-2.3.2.tar.gz"
},
"type": "url",
"url": "https://download.savannah.nongnu.org/releases/acl/acl-2.3.2.tar.gz",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "doc/COPYING"
}
},
"libaom": {
"type": "git",
"rev": "main",
"url": "https://aomedia.googlesource.com/aom",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libargon2": {
"type": "git",
"rev": "master",
@@ -303,6 +446,17 @@
"path": "LICENSE.md"
}
},
"libde265": {
"type": "ghrel",
"repo": "strukturag/libde265",
"match": "libde265-.+\\.tar\\.gz",
"prefer-stable": true,
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"libevent": {
"type": "ghrel",
"repo": "libevent/libevent",
@@ -333,6 +487,17 @@
"path": "LICENSE"
}
},
"libheif": {
"type": "ghrel",
"repo": "strukturag/libheif",
"match": "libheif-.+\\.tar\\.gz",
"prefer-stable": true,
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"libiconv": {
"type": "filelist",
"url": "https://ftp.gnu.org/gnu/libiconv/",
@@ -372,12 +537,12 @@
}
},
"libmemcached": {
"type": "git",
"url": "https://github.com/static-php/libmemcached-macos.git",
"rev": "master",
"type": "ghtagtar",
"repo": "awesomized/libmemcached",
"match": "1.\\d.\\d",
"license": {
"type": "file",
"path": "COPYING"
"path": "LICENSE"
}
},
"libpng": {
@@ -399,6 +564,14 @@
"path": "LICENSE"
}
},
"librdkafka": {
"type": "ghtar",
"repo": "confluentinc/librdkafka",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libsodium": {
"type": "ghrel",
"repo": "jedisct1/libsodium",
@@ -476,7 +649,7 @@
"regex": "/href=\"(?<file>libxslt-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"license": {
"type": "file",
"path": "COPYING"
"path": "Copyright"
}
},
"libyaml": {
@@ -513,13 +686,23 @@
"micro": {
"type": "git",
"path": "php-src/sapi/micro",
"rev": "master",
"rev": "84beta",
"url": "https://github.com/static-php/phpmicro",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"mimalloc": {
"type": "ghtagtar",
"repo": "microsoft/mimalloc",
"match": "v2\\.\\d\\.[^3].*",
"provide-pre-built": false,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"mongodb": {
"type": "ghrel",
"repo": "mongodb/mongo-php-driver",
@@ -561,6 +744,26 @@
"path": "COPYING"
}
},
"nghttp3": {
"type": "ghrel",
"repo": "ngtcp2/nghttp3",
"match": "nghttp3.+\\.tar\\.xz",
"prefer-stable": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"ngtcp2": {
"type": "ghrel",
"repo": "ngtcp2/ngtcp2",
"match": "ngtcp2.+\\.tar\\.xz",
"prefer-stable": true,
"license": {
"type": "file",
"path": "COPYING"
}
},
"onig": {
"type": "ghrel",
"repo": "kkos/oniguruma",
@@ -588,6 +791,16 @@
"path": "LICENSE.txt"
}
},
"opentelemetry": {
"type": "url",
"url": "https://pecl.php.net/get/opentelemetry",
"path": "php-src/ext/opentelemetry",
"filename": "opentelemetry.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"parallel": {
"type": "url",
"url": "https://pecl.php.net/get/parallel",
@@ -618,13 +831,22 @@
}
},
"postgresql": {
"type": "url",
"url": "https://ftp.postgresql.org/pub/source/v16.2/postgresql-16.2.tar.bz2",
"type": "ghtagtar",
"repo": "postgres/postgres",
"match": "REL_16_\\d+",
"license": {
"type": "file",
"path": "COPYRIGHT"
}
},
"postgresql-win": {
"type": "url",
"url": "https://get.enterprisedb.com/postgresql/postgresql-16.8-1-windows-x64-binaries.zip",
"license": {
"type": "text",
"text": "PostgreSQL Database Management System\n(also known as Postgres, formerly as Postgres95)\n\nPortions Copyright (c) 1996-2025, The PostgreSQL Global Development Group\n\nPortions Copyright (c) 1994, The Regents of the University of California\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose, without fee, and without a written\nagreement is hereby granted, provided that the above copyright notice\nand this paragraph and the following two paragraphs appear in all\ncopies.\n\nIN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY\nFOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,\nINCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS\nDOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF\nTHE POSSIBILITY OF SUCH DAMAGE.\n\nTHE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS\nON AN \"AS IS\" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS\nTO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
}
},
"protobuf": {
"type": "url",
"url": "https://pecl.php.net/get/protobuf",
@@ -708,7 +930,7 @@
},
"sqlite": {
"type": "url",
"url": "https://www.sqlite.org/2023/sqlite-autoconf-3430200.tar.gz",
"url": "https://www.sqlite.org/2024/sqlite-autoconf-3450200.tar.gz",
"provide-pre-built": true,
"license": {
"type": "text",
@@ -726,13 +948,18 @@
}
},
"swoole": {
"type": "ghtar",
"path": "php-src/ext/swoole",
"repo": "swoole/swoole-src",
"prefer-stable": true,
"type": "git",
"rev": "master",
"url": "https://github.com/swoole/swoole-src.git",
"license": {
"type": "file",
"path": "LICENSE"
},
"alt": {
"type": "ghtar",
"repo": "swoole/swoole-src",
"prefer-stable": true
}
},
"swow": {
@@ -740,7 +967,6 @@
"path": "php-src/ext/swow-src",
"rev": "ci",
"url": "https://github.com/swow/swow",
"patch": "patchSwow",
"license": {
"type": "file",
"path": "LICENSE"
@@ -764,6 +990,15 @@
"path": "COPYING"
}
},
"xdebug": {
"type": "url",
"url": "https://pecl.php.net/get/xdebug",
"filename": "xdebug.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"xhprof": {
"type": "url",
"url": "https://pecl.php.net/get/xhprof",

View File

@@ -30,6 +30,7 @@
</div>
</div>
<div class="my-btn" v-if="selectedSystem !== 'windows'" @click="selectCommon">{{ I18N[lang].selectCommon }}</div>
<div class="my-btn" v-if="selectedSystem !== 'windows'" @click="selectAll">{{ I18N[lang].selectAll }}</div>
<div class="my-btn" @click="checkedExts = []">{{ I18N[lang].selectNone }}</div>
<details class="details custom-block" open>
@@ -44,6 +45,7 @@
<div class="tip custom-block">
<p class="custom-block-title">TIP</p>
<p>{{ I18N[lang].depTips }}</p>
<p>{{ I18N[lang].depTips2 }}</p>
</div>
<h2>{{ I18N[lang].buildTarget }}</h2>
<div class="box">
@@ -175,6 +177,12 @@
{{ buildCommandString }}
</div>
</div>
<div class="command-container">
<b>craft.yml</b>
<div id="craft-cmd" class="command-preview pre">
{{ craftCommandString }}
</div>
</div>
</div>
</template>
@@ -225,11 +233,11 @@ const isSupported = (extName, os) => {
};
const availablePhpVersions = [
'7.4',
'8.0',
'8.1',
'8.2',
'8.3',
'8.4',
];
const I18N = {
@@ -246,6 +254,7 @@ const I18N = {
no: '否',
resultShow: '结果展示',
selectCommon: '选择常用扩展',
selectAll: '选择全部',
selectNone: '全部取消选择',
useZTS: '是否编译线程安全版',
hardcodedINI: '硬编码 INI 选项',
@@ -261,6 +270,7 @@ const I18N = {
selectedSystem: '选择操作系统',
buildLibs: '要构建的库',
depTips: '选择扩展后,不可选中的项目为必需的依赖,编译的依赖库列表中可选的为现有扩展和依赖库的可选依赖。选择可选依赖后,将生成 --with-libs 参数。',
depTips2: '无法同时构建所有扩展,因为有些扩展之间相互冲突。请根据需要选择扩展。',
microUnavailable: 'micro 不支持 PHP 7.4 及更早版本!',
windowsSAPIUnavailable: 'Windows 目前不支持 fpm、embed 构建!',
useUPX: '是否开启 UPX 压缩(减小二进制体积)',
@@ -280,6 +290,7 @@ const I18N = {
no: 'No',
resultShow: 'Result',
selectCommon: 'Select common extensions',
selectAll: 'Select all',
selectNone: 'Unselect all',
useZTS: 'Enable ZTS',
hardcodedINI: 'Hardcoded INI options',
@@ -295,6 +306,7 @@ const I18N = {
selectedSystem: 'Select Build OS',
buildLibs: 'Select Dependencies',
depTips: 'After selecting the extensions, the unselectable items are essential dependencies. In the compiled dependencies list, optional dependencies consist of existing extensions and optional dependencies of libraries. Optional dependencies will be added in --with-libs parameter.',
depTips2: 'It is not possible to build all extensions at the same time, as some extensions conflict with each other. Please select the extensions you need.',
microUnavailable: 'Micro does not support PHP 7.4 and earlier versions!',
windowsSAPIUnavailable: 'Windows does not support fpm and embed build!',
useUPX: 'Enable UPX compression (reduce binary size)',
@@ -331,6 +343,10 @@ const selectCommon = () => {
];
};
const selectAll = () => {
checkedExts.value = extFilter.value;
};
const extList = computed(() => {
return checkedExts.value.join(',');
});
@@ -358,7 +374,7 @@ const checkedTargets = ref(['cli']);
const selectedEnv = ref('spc');
// chosen php version
const selectedPhpVersion = ref('8.2');
const selectedPhpVersion = ref('8.4');
// chosen debug
const debug = ref(0);
@@ -499,6 +515,38 @@ const buildCommandString = computed(() => {
return `${spcCommand.value} build ${buildCommand.value} "${extList.value}"${additionalLibs.value}${debug.value ? ' --debug' : ''}${zts.value ? ' --enable-zts' : ''}${enableUPX.value ? ' --with-upx-pack' : ''}${displayINI.value}`;
});
const craftCommandString = computed(() => {
let str = `php-version: ${selectedPhpVersion.value}\n`;
str += `extensions: "${extList.value}"\n`;
if (checkedTargets.value.join(',') === 'all') {
str += 'sapi: ' + ['cli', 'fpm', 'micro', 'embed'].join(',') + '\n';
} else {
str += `sapi: ${checkedTargets.value.join(',')}\n`;
}
if (additionalLibs.value) {
str += `libs: ${additionalLibs.value.replace('--with-libs="', '').replace('"', '').trim()}\n`;
}
if (debug.value) {
str += 'debug: true\n';
}
str += '{{position_hold}}';
if (enableUPX.value) {
str += ' with-upx-pack: true\n';
}
if (zts.value) {
str += ' enable-zts: true\n';
}
if (preBuilt.value) {
str += ' prefer-pre-built: true\n';
}
if (!str.endsWith('{{position_hold}}')) {
str = str.replace('{{position_hold}}', 'build-options:\n');
} else {
str = str.replace('{{position_hold}}', '');
}
return str;
});
const calculateExtLibDepends = (input) => {
const result = new Set();
@@ -617,6 +665,12 @@ h2 {
overflow-wrap: break-word;
}
.pre {
white-space: pre-wrap;
word-break: break-word;
overflow-wrap: break-word;
}
.option-line {
padding: 4px 8px;
}

View File

@@ -1,54 +1,57 @@
export default {
'/en/guide/': [
{
text: 'Guide',
items: [
{text: 'Guide', link: '/en/guide/'},
{text: 'Actions Build', link: '/en/guide/action-build'},
{text: 'Manual Build', link: '/en/guide/manual-build'},
{text: 'Extension List', link: '/en/guide/extensions'},
{text: 'Extension Notes', link: '/en/guide/extension-notes'},
{text: 'Command Generator', link: '/en/guide/cli-generator'},
{text: 'Environment Variables', link: '/en/guide/env-vars', collapsed: true,},
{text: 'Dependency Table', link: '/en/guide/deps-map'},
]
},
{
items: [
{text: 'Troubleshooting', link: '/en/guide/troubleshooting'},
{text: 'Build on Windows', link: '/en/guide/build-on-windows'},
],
}
],
'/en/develop/': [
{
text: 'Development',
items: [
{text: 'Get Started', link: '/en/develop/'},
{text: 'Project Structure', link: '/en/develop/structure'},
{text: 'PHP Source Modification', link: '/en/develop/php-src-changes'},
],
},
{
text: 'Module',
items: [
{text: 'Doctor ', link: '/en/develop/doctor-module'},
{text: 'Source', link: '/en/develop/source-module'},
]
},
{
text: 'Extra',
items: [
{text: 'Compilation Tools', link: '/en/develop/system-build-tools'},
]
}
],
'/en/contributing/': [
{
text: 'Contributing',
items: [
{text: 'Contributing', link: '/en/contributing/'},
],
}
],
'/en/guide/': [
{
text: 'Basic Build Guides',
items: [
{text: 'Guide', link: '/en/guide/'},
{text: 'Build (Local)', link: '/en/guide/manual-build'},
{text: 'Build (CI)', link: '/en/guide/action-build'},
{text: 'Supported Extensions', link: '/en/guide/extensions'},
{text: 'Extension Notes', link: '/en/guide/extension-notes'},
{text: 'Build Command Generator', link: '/en/guide/cli-generator'},
{text: 'Environment Variables', link: '/en/guide/env-vars', collapsed: true,},
{text: 'Dependency Table', link: '/en/guide/deps-map'},
]
},
{
text: 'Extended Build Guides',
items: [
{text: 'Troubleshooting', link: '/en/guide/troubleshooting'},
{text: 'Build on Windows', link: '/en/guide/build-on-windows'},
{text: 'Build with GNU libc', link: '/en/guide/build-with-glibc'},
],
}
],
'/en/develop/': [
{
text: 'Development',
items: [
{text: 'Get Started', link: '/en/develop/'},
{text: 'Project Structure', link: '/en/develop/structure'},
{text: 'PHP Source Modification', link: '/en/develop/php-src-changes'},
],
},
{
text: 'Module',
items: [
{text: 'Doctor ', link: '/en/develop/doctor-module'},
{text: 'Source', link: '/en/develop/source-module'},
]
},
{
text: 'Extra',
items: [
{text: 'Compilation Tools', link: '/en/develop/system-build-tools'},
{text: 'craft.yml Configuration', link: '/zh/develop/craft-yml'},
]
}
],
'/en/contributing/': [
{
text: 'Contributing',
items: [
{text: 'Contributing', link: '/en/contributing/'},
],
}
],
};

View File

@@ -1,54 +1,57 @@
export default {
'/zh/guide/': [
{
text: '构建指南',
items: [
{text: '指南', link: '/zh/guide/'},
{text: 'Actions 构建', link: '/zh/guide/action-build'},
{text: '本地构建', link: '/zh/guide/manual-build'},
{text: '扩展列表', link: '/zh/guide/extensions'},
{text: '扩展注意事项', link: '/zh/guide/extension-notes'},
{text: '编译命令生成器', link: '/zh/guide/cli-generator'},
{text: '环境变量列表', link: '/zh/guide/env-vars'},
{text: '依赖关系图表', link: '/zh/guide/deps-map'},
]
},
{
items: [
{text: '故障排除', link: '/zh/guide/troubleshooting'},
{text: '在 Windows 上构建', link: '/zh/guide/build-on-windows'},
],
}
],
'/zh/develop/': [
{
text: '开发指南',
items: [
{ text: '开发简介', link: '/zh/develop/' },
{ text: '项目结构简介', link: '/zh/develop/structure' },
{text: '对 PHP 源码的修改', link: '/zh/develop/php-src-changes'},
],
},
{
text: '模块',
items: [
{ text: 'Doctor 环境检查工具', link: '/zh/develop/doctor-module' },
{ text: '资源模块', link: '/zh/develop/source-module' },
]
},
{
text: '其他',
items: [
{text: '系统编译工具', link: '/zh/develop/system-build-tools'},
]
}
],
'/zh/contributing/': [
{
text: '贡献指南',
items: [
{text: '贡献指南', link: '/zh/contributing/'},
],
}
],
'/zh/guide/': [
{
text: '构建指南',
items: [
{text: '指南', link: '/zh/guide/'},
{text: '本地构建', link: '/zh/guide/manual-build'},
{text: 'Actions 构建', link: '/zh/guide/action-build'},
{text: '扩展列表', link: '/zh/guide/extensions'},
{text: '扩展注意事项', link: '/zh/guide/extension-notes'},
{text: '编译命令生成器', link: '/zh/guide/cli-generator'},
{text: '环境变量列表', link: '/zh/guide/env-vars'},
{text: '依赖关系图表', link: '/zh/guide/deps-map'},
]
},
{
text: '扩展构建指南',
items: [
{text: '故障排除', link: '/zh/guide/troubleshooting'},
{text: '在 Windows 上构建', link: '/zh/guide/build-on-windows'},
{text: '构建 GNU libc 兼容的二进制', link: '/zh/guide/build-with-glibc'},
],
}
],
'/zh/develop/': [
{
text: '开发指南',
items: [
{text: '开发简介', link: '/zh/develop/'},
{text: '项目结构简介', link: '/zh/develop/structure'},
{text: '对 PHP 源码的修改', link: '/zh/develop/php-src-changes'},
],
},
{
text: '模块',
items: [
{text: 'Doctor 环境检查工具', link: '/zh/develop/doctor-module'},
{text: '资源模块', link: '/zh/develop/source-module'},
]
},
{
text: '其他',
items: [
{text: '系统编译工具', link: '/zh/develop/system-build-tools'},
{text: 'craft.yml 配置详解', link: '/zh/develop/craft-yml'},
]
}
],
'/zh/contributing/': [
{
text: '贡献指南',
items: [
{text: '贡献指南', link: '/zh/contributing/'},
],
}
],
};

67
docs/deps-craft-yml.md Normal file
View File

@@ -0,0 +1,67 @@
```yaml
# PHP version to build (default: 8.4)
php-version: 8.4
# [REQUIRED] Static PHP extensions to build (list or comma-separated are both accepted)
extensions: bcmath,fileinfo,phar,zlib,sodium,posix,pcntl
# Extra libraries to build (list or comma-separated are both accepted)
libs: [ ]
# [REQUIRED] Build SAPIs (list or comma-separated are both accepted)
sapi: cli,micro,fpm
# Show full console output (default: false)
debug: false
# Build options (same as `build` command options, all options are optional)
build-options:
# Before build, remove all old build files and sources (default: false)
with-clean: false
# Build with all suggested libraries (default: false)
with-suggested-libs: false
# Build with all suggested extensions (default: false)
with-suggested-exts: false
# Build extra shared extensions (list or comma-separated are both accepted)
build-shared: [ ]
# Build without stripping the binary (default: false)
no-strip: false
# Disable Opcache JIT (default: false)
disable-opcache-jit: false
# PHP configuration options (same as --with-config-file-path)
with-config-file-path: ""
# PHP configuration options (same as --with-config-file-scan-dir)
with-config-file-scan-dir: ""
# Hardcoded INI options for cli and micro SAPI (e.g. "memory_limit=4G", list accepted)
with-hardcoded-ini: [ ]
# Pretend micro SAPI as cli SAPI to avoid some frameworks to limit the usage of micro SAPI
with-micro-fake-cli: false
# Additional patch point injection files (e.g. "path/to/patch.php", list accepted)
with-added-patch: [ ]
# Ignore micro extension tests (if you are using micro SAPI, default: false)
without-micro-ext-test: false
# UPX pack the binary (default: false)
with-upx-pack: false
# Set the micro.exe program icon (only for Windows, default: "")
with-micro-logo: ""
# Set micro SAPI as win32 mode, without this, micro SAPI will be compiled as a console application (only for Windows, default: false)
enable-micro-win32: false
# Download options
download-options:
# Use custom url for specified sources, format: "{source-name}:{url}" (e.g. "php-src:https://example.com/php-8.4.0.tar.gz")
custom-url: [ ]
# Use custom git repo for specified sources, format: "{source-name}:{branch}:{url}" (e.g. "php-src:master:https://github.com/php/php-src.git")
custom-git: [ ]
# Retries count for downloading sources (default: 5)
retry: 5
# Use pre-built libraries if available (default: false)
prefer-pre-built: true
# Do not download from alternative sources (default: false)
no-alt: false
craft-options:
doctor: true
download: true
build: true
# Extra environment variables
extra-env:
# e.g. Use github token to avoid rate limit
GITHUB_TOKEN: your-github-token
```

View File

@@ -0,0 +1,7 @@
---
aside: false
---
# craft.yml Configuration
<!--@include: ../../deps-craft-yml.md-->

View File

@@ -16,13 +16,29 @@ The directory can be changed using the manual build option `--with-config-file-s
## Can statically-compiled PHP install extensions?
Because the principle of installing extensions in PHP under the traditional architecture is to install new extensions using `.so` type dynamic link libraries,
and statically linked PHP compiled using this project cannot **directly** install new extensions using dynamic link libraries.
Because the principle of installing PHP extensions under the normal mode is to use `.so` type dynamic link library to install new extensions,
and we use the static link PHP compiled by this project. However, static linking has different definitions in different operating systems.
For the macOS platform, almost all binary files under macOS cannot be linked purely statically,
and almost all binary files will link macOS system libraries: `/usr/lib/libresolv.9.dylib` and `/usr/lib/libSystem.B.dylib`.
So under macOS system, statically compiled php binary files can be used under certain compilation conditions,
and dynamic link extensions can be used at the same time:
First of all, for Linux systems, statically linked binaries will not link the system's dynamic link library.
Purely statically linked binaries (`build with -all-static`) cannot load dynamic libraries, so new extensions cannot be added.
At the same time, in pure static mode, you cannot use extensions such as `ffi` to load external `.so` modules.
You can use the command `ldd buildroot/bin/php` to check whether the binary you built under Linux is purely statically linked.
If you [build GNU libc based PHP](../guide/build-with-glibc), you can use the `ffi` extension to load external `.so` modules and load `.so` extensions with the same ABI.
For example, you can use the following command to build a static PHP binary dynamically linked with glibc,
supporting FFI extensions and loading the `xdebug.so` extension of the same PHP version and the same TS type:
```bash
bin/spc-gnu-docker download --for-extensions=ffi,xml --with-php=8.4
bin/spc-gnu-docker build ffi,xml --build-cli --debug
buildroot/bin/php -d "zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so" --ri xdebug
```
For macOS platform, almost all binaries under macOS cannot be truly purely statically linked, and almost all binaries will link macOS system libraries: `/usr/lib/libresolv.9.dylib` and `/usr/lib/libSystem.B.dylib`.
So on macOS, you can use statically compiled PHP binaries under certain compilation conditions, and dynamically linked extensions:
1. Using the `--no-strip` parameter will not strip information such as debugging symbols from the binary file for use with external Zend extensions such as `Xdebug`.
2. If you want to compile some Zend extensions, use Homebrew, MacPorts, source code compilation, and install a normal version of PHP on your operating system.
@@ -34,15 +50,12 @@ and dynamic link extensions can be used at the same time:
bin/spc build ffi --build-cli --no-strip
```
For the Linux platform, the current compilation result is a purely statically linked binary file,
and new extensions cannot be installed using a dynamic link library.
## Can it support Oracle database extension?
Some extensions that rely on closed source libraries, such as `oci8`, `sourceguardian`, etc.,
they do not provide purely statically compiled dependent library files (`.a`), only dynamic dependent library files (`.so`).
These extensions cannot be compiled into static-php-cli from source, so this project may never support them.
However, in theory, you can access and use such extensions under macOS according to the above questions.
These extensions cannot be compiled into static-php-cli using source code, so this project may never support these extensions.
However, in theory you can access and use such extensions under macOS and Linux according to the above questions.
If you have a need for such extensions, or most people have needs for these closed-source extensions,
see the discussion on [standalone-php-cli](https://github.com/crazywhalecc/static-php-cli/discussions/58). Welcome to leave a message.
@@ -75,6 +88,8 @@ such as Swoole Compiler, Source Guardian, etc.
## Unable to use ssl
**Update: This issue has been fixed in the latest version of static-php-cli, which now reads the system's certificate file by default. If you still have problems, try the solution below.**
When using curl, pgsql, etc. to request an HTTPS website or establish an SSL connection, there may be an `error:80000002:system library::No such file or directory` error.
This error is caused by statically compiled PHP without specifying `openssl.cafile` via `php.ini`.
@@ -84,3 +99,11 @@ For Linux systems, you can download the [cacert.pem](https://curl.se/docs/caextr
For the certificate locations of different distros, please refer to [Golang docs](https://go.dev/src/crypto/x509/root_linux.go).
> INI configuration `openssl.cafile` cannot be set dynamically using the `ini_set()` function, because `openssl.cafile` is a `PHP_INI_SYSTEM` type configuration and can only be set in the `php.ini` file.
## Why don't we support older versions of PHP?
Because older versions of PHP have many problems, such as security issues, performance issues, and functional issues.
In addition, many older versions of PHP are not compatible with the latest dependency libraries,
which is one of the reasons why older versions of PHP are not supported.
You can use older versions compiled earlier by static-php-cli, such as PHP 8.0, but earlier versions will not be explicitly supported.

View File

@@ -74,6 +74,12 @@ bin/setup-runtime -action add-path
bin/setup-runtime -action remove-path
```
Finally, now that you have PHP and Composer installed, you need to install static-php-cli's Composer dependencies:
```shell
composer install
```
### Install other Tools (automatic)
For `php-sdk-binary-tools`, `strawberry-perl`, and `nasm`,

View File

@@ -0,0 +1,64 @@
# Build glibc Compatible Linux Binary
## Why Build glibc Compatible Binary
Currently, the binaries built by static-php-cli on Linux by default are based on musl-libc (statically linked).
musl-libc is a lightweight libc implementation
that aims to be compatible with glibc and provides good support for pure static linking.
This means that the compiled static PHP executable can be used on almost any Linux distribution without worrying about the versions of libc, libstdc++, etc.
However, there are some issues with pure static linking of musl-libc binaries on Linux:
- The `dl()` function in PHP cannot be used to load dynamic libraries and external PHP extensions.
- The FFI extension in PHP cannot be used.
- In some extreme cases, performance issues may occur. See [musl-libc performance issues](https://github.com/php/php-src/issues/13648).
Different Linux distributions use different default libc.
For example, Alpine Linux uses musl libc, while most Linux distributions use glibc.
However, even so, we cannot directly use any distribution using glibc to build portable static binaries because glibc has some issues:
- Binaries built with gcc and other tools on newer versions of distributions cannot run on older versions of distributions.
- glibc is not recommended to be statically linked because some of its features require the support of dynamic libraries.
However, we can use Docker to solve this problem.
The final output is a binary **dynamically linked with glibc** and some necessary libraries,
but **statically linked with all other dependencies**.
1. Use an older version of a Linux distribution (such as CentOS 7.x), which has an older version of glibc but can run on most modern Linux distributions.
2. Build the static binary of PHP in this container so that it can run on most modern Linux distributions.
> Using glibc static binaries can run on most modern Linux distributions but cannot run on musl libc distributions, such as CentOS 6, Alpine Linux, etc.
## Build glibc Compatible Linux Binary
The latest version of static-php-cli includes the `bin/spc-gnu-docker` script,
which can create a CentOS 7.x (glibc-2.17) Docker container with one click and build a glibc compatible PHP static binary in the container.
Then, run the following command once.
The first run will take a long time because it needs to download the CentOS 7.x image and some build tools.
```bash
bin/spc-gnu-docker
```
After the image is built, you will see the same command help menu as `bin/spc`, which means the container is ready.
After the container is ready, you can refer to the [local build](./manual-build) section to build your PHP static binary.
Just replace `bin/spc` or `./spc` with `bin/spc-gnu-docker`.
```bash
bin/spc-gnu-docker build bcmath,ctype,openssl,pdo,phar,posix,session,tokenizer,xml,zip --build-cli --debug
```
## Notes
In rare cases, glibc-based static PHP may encounter segment faults and other errors, but there are currently few examples.
If you encounter any issues, please submit an issue.
glibc build is an extended feature and is not part of the default static-php support.
If you have related issues or requirements, please indicate that you are building based on glibc when submitting an issue.
If you need to build glibc-based binaries without using Docker,
please refer to the `bin/spc-gnu-docker` script to manually create a similar environment.
Please keep in mind that we only support glibc build with `bin/spc-gnu-docker`. Compilation on RHEL 9 & 10 has been tested and is stable, but if you run into issues, we may choose not to fix them.

View File

@@ -39,6 +39,21 @@ Or, if you need to modify an environment variable for a long time, you can modif
For example, if you need to modify the `./configure` command for compiling PHP, you can find the `SPC_CMD_PREFIX_PHP_CONFIGURE` environment variable in the `config/env.ini` file, and then modify its value.
If your build conditions are more complex and require multiple `env.ini` files to switch,
we recommend that you use the `config/env.custom.ini` file.
In this way, you can specify your environment variables by writing additional override items
without modifying the default `config/env.ini` file.
```ini
; This is an example of `config/env.custom.ini` file,
; we modify the `SPC_CONCURRENCY` and linux default CFLAGS passing to libs and PHP
[global]
SPC_CONCURRENCY=4
[linux]
SPC_DEFAULT_C_FLAGS="-O3"
```
## Library environment variables (Unix only)
Starting from 2.2.0, static-php-cli supports custom environment variables for all compilation dependent library commands of macOS, Linux, FreeBSD and other Unix systems.

View File

@@ -6,6 +6,8 @@ which will be listed one by one here.
## curl
HTTP3 support is not enabled by default, compile with `--with-libs="nghttp2,nghttp3,ngtcp2"` to enable HTTP3 support for PHP >= 8.4.
When using curl to request HTTPS, there may be an `error:80000002:system library::No such file or directory` error.
For details on the solution, see [FAQ - Unable to use ssl](../faq/#unable-to-use-ssl).
@@ -46,7 +48,11 @@ This extension contains an implementation of the coroutine environment for `pdo_
## swow
1. Only PHP version >= 8.0 is supported.
1. Only PHP 8.0 ~ 8.4 is supported.
## imagick
1. The imagick extension currently only has openmp support on musl libc. This means that multithreading is disabled on glibc or other operating systems. The extension is still fully functional.
## imap
@@ -76,11 +82,9 @@ and this extension cannot be compiled into php by static linking, so it cannot b
## xdebug
1. Xdebug is a Zend extension. The functions of Xdebug depend on PHP's Zend engine and underlying code.
If you want to statically compile it into PHP, you may need a huge amount of patch code, which is not feasible.
2. The macOS platform can compile an xdebug extension under PHP compiled on the same platform,
extract the `xdebug.so` file, and then use the `--no-strip` parameter in static-php-cli to retain the debug symbol table and add the `ffi` extension.
The compiled `./php` binary can be configured and run by specifying the INI, eg `./php -d 'zend_extension=/path/to/xdebug.so' your-code.php`.
1. Xdebug is only buildable as a shared extension. On Linux, you need to use static-php-cli with SPC_LIBC=glibc.
2. When using Linux/glibc or macOS, you can compile Xdebug as a shared extension using --build-shared="xdebug".
The compiled `./php` binary can be configured and run by specifying the INI, eg `./php -d 'zend_extension=/path/to/xdebug.so' your-code.php`.
## xml
@@ -123,8 +127,8 @@ For details on the solution, see [FAQ - Unable to use ssl](../faq/#unable-to-use
## ffi
1. Linux not supported yet: Due to limitations of the Linux system, although the ffi extension can be compiled successfully, it cannot be used to load other `so` extensions.
The prerequisite for Linux to support loading `so` extensions is dynamic compilation, but dynamic compilation conflicts with the purpose of this project.
1. Due to the limitation of musl libc's static linkage, you cannot use ffi because dynamic libraries cannot be loaded.
If you need to use the ffi extension, see [Compile PHP with GNU libc](./build-with-glibc).
2. macOS supports the ffi extension, but errors will occur when some kernels do not contain debugging symbols.
3. Windows x64 supports the ffi extension.
@@ -147,5 +151,10 @@ Parallel is only supported on PHP 8.0 ZTS and above.
## spx
1. The [SPX extension](https://github.com/NoiseByNorthwest/php-spx) only supports NTS mode.
2. SPX does not support Windows, and the official repository does not support static compilation. static-php-cli uses a [modified version](https://github.com/static-php/php-spx).
1. SPX does not support Windows, and the official repository does not support static compilation. static-php-cli uses a [modified version](https://github.com/static-php/php-spx).
## mimalloc
1. This is not technically an extension, but a library.
2. Building with `--with-libs="mimalloc"` on Linux or macOS will override the default allocator.
3. This is experimental for now, but is recommended in threaded environments.

View File

@@ -5,14 +5,10 @@ currently supporting Linux and macOS systems.
In the guide section, you will learn how to use static php cli to build standalone PHP programs.
- [GitHub Action Build](./action-build)
- [Manual Build](./manual-build)
- [Build (local)](./manual-build)
- [Build (GitHub Actions)](./action-build)
- [Supported Extensions](./extensions)
::: tip
If you are a native English speaker, some corrections to the documentation are welcome.
:::
## Compilation Environment
The following is the architecture support situation, where :gear: represents support for GitHub Action build,
@@ -36,7 +32,7 @@ Windows currently only supports the x86_64 architecture, and does not support 32
## Supported PHP Version
Currently, static php cli supports PHP versions 8.0 to 8.3, and theoretically supports PHP 7.4 and earlier versions.
Currently, static php cli supports PHP versions 8.1 to 8.4, 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.

View File

@@ -1,3 +1,7 @@
---
outline: 'deep'
---
# Build (Linux, macOS, FreeBSD)
This section covers the build process for Linux, macOS, and FreeBSD. If you want to build on Windows,
@@ -57,56 +61,6 @@ cd static-php-cli
composer update
```
### Use System PHP
Below are some example commands for installing PHP and Composer in the system.
It is recommended to search for the specific installation method yourself or ask the AI search engine to obtain the answer,
which will not be elaborated here.
```bash
# [macOS], need install Homebrew first. See https://brew.sh/
# Remember change your composer executable path. For M1/M2 Chip mac, "/opt/homebrew/bin/", for Intel mac, "/usr/local/bin/". Or add it to your own path.
brew install php wget
wget https://getcomposer.org/download/latest-stable/composer.phar -O /path/to/your/bin/composer && chmod +x /path/to/your/bin/composer
# [Debian], you need to make sure your php version >= 8.1 and composer >= 2.0
sudo apt install php-cli composer php-tokenizer
# [Alpine]
apk add bash file wget xz php81 php81-common php81-pcntl php81-tokenizer php81-phar php81-posix php81-xml composer
```
::: tip
Currently, some versions of Ubuntu install older PHP versions,
so no installation commands are provided. If necessary, it is recommended to add software sources such as ppa first,
and then install the latest version of PHP and tokenizer, XML, and phar extensions.
Older versions of Debian may have an older (<= 7.4) version of PHP installed by default, it is recommended to upgrade Debian first.
:::
### Use Docker
If you don't want to install PHP and Composer runtime environment on your system, you can use the built-in Docker environment build script.
```bash
# To use directly, replace `bin/spc` with `bin/spc-alpine-docker` in all used commands
bin/spc-alpine-docker
```
The first time the command is executed, `docker build` will be used to build a Docker image.
The default built Docker image is the `x86_64` architecture, and the image name is `cwcc-spc-x86_64`.
If you want to build `aarch64` static-php-cli in `x86_64` environment,
you can use qemu to emulate the arm image to run Docker, but the speed will be very slow.
Use command: `SPC_USE_ARCH=aarch64 bin/spc-alpine-docker`.
If it prompts that sudo is required to run after running,
execute the following command once to grant static-php-cli permission to execute sudo:
```bash
export SPC_USE_SUDO=yes
```
### Use Precompiled Static PHP Binaries
If you don't want to use Docker and install PHP in the system,
@@ -133,18 +87,108 @@ This script will download two files in total: `bin/php` and `bin/composer`. Afte
it is equivalent to installing PHP in the system, you can directly Use commands such as `composer`, `php -v`, or directly use `bin/spc`.
2. Direct call, such as executing static-php-cli command: `bin/php bin/spc --help`, executing Composer: `bin/php bin/composer update`.
## Command - download
### Use Docker
If you don't want to install PHP and Composer runtime environment on your system, you can use the built-in Docker environment build script.
```bash
# To use directly, replace `bin/spc` with `bin/spc-alpine-docker` in all used commands
bin/spc-alpine-docker
```
The first time the command is executed, `docker build` will be used to build a Docker image.
The default built Docker image is the `x86_64` architecture, and the image name is `cwcc-spc-x86_64`.
If you want to build `aarch64` static-php-cli in `x86_64` environment,
you can use qemu to emulate the arm image to run Docker, but the speed will be very slow.
Use command: `SPC_USE_ARCH=aarch64 bin/spc-alpine-docker`.
If it prompts that sudo is required to run after running,
execute the following command once to grant static-php-cli permission to execute sudo:
```bash
export SPC_USE_SUDO=yes
```
### Use System PHP
Below are some example commands for installing PHP and Composer in the system.
It is recommended to search for the specific installation method yourself or ask the AI search engine to obtain the answer,
which will not be elaborated here.
```bash
# [macOS], need install Homebrew first. See https://brew.sh/
# Remember change your composer executable path. For M1/M2 Chip mac, "/opt/homebrew/bin/", for Intel mac, "/usr/local/bin/". Or add it to your own path.
brew install php wget
wget https://getcomposer.org/download/latest-stable/composer.phar -O /path/to/your/bin/composer && chmod +x /path/to/your/bin/composer
# [Debian], you need to make sure your php version >= 8.1 and composer >= 2.0
sudo apt install php-cli composer php-tokenizer
# [Alpine]
apk add bash file wget xz php81 php81-common php81-pcntl php81-tokenizer php81-phar php81-posix php81-xml composer
```
::: tip
Currently, some versions of Ubuntu install older PHP versions,
so no installation commands are provided. If necessary, it is recommended to add software sources such as ppa first,
and then install the latest version of PHP and tokenizer, XML, and phar extensions.
Older versions of Debian may have an older (<= 7.4) version of PHP installed by default, it is recommended to upgrade Debian first.
:::
## Build with craft (recommended)
Using `bin/spc craft`, you can use a configuration file and a command to automatically check the environment, download source code, build dependency libraries, build PHP and extensions, etc.
You need to write a `craft.yml` file and save it in the current working directory. `craft.yml` can be generated by [command generator](./cli-generator) or written manually.
For manual writing, please refer to the comments in [craft.yml configuration](../develop/craft-yml.md) to write it.
Let's assume that you compile an extension combination and choose PHP 8.4, outputting `cli` and `fpm`:
```yaml
# path/to/craft.yml
php-version: 8.4
extensions: bcmath,posix,phar,zlib,openssl,curl,fileinfo,tokenizer
sapi:
- cli
- fpm
```
Then use the `bin/spc craft` command to compile:
```bash
bin/spc craft --debug
```
If the build is successful, you will see the `buildroot/bin` directory in the current directory, which contains the compiled PHP binary file, or the corresponding SAPI.
- cli: The build result is `buildroot/bin/php.exe` on Windows and `buildroot/bin/php` on other platforms.
- fpm: The build result is `buildroot/bin/php-fpm`.
- micro: The build result is `buildroot/bin/micro.sfx`. If you need to further package it with PHP code, please refer to [Packaging micro binary](./manual-build#command-micro-combine).
- embed: See [Using embed](./manual-build#embed-usage).
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`.
## Step-by-step build command
If you have customized requirements, or the need to download and compile PHP and dependent libraries separately, you can use the `bin/spc` command to execute step by step.
### Command download - Download dependency packages
Use the command `bin/spc download` to download the source code required for compilation,
including php-src and the source code of various dependent libraries.
```bash
# Download all dependencies
# Download all dependencies, defaults to php 8.4
bin/spc download --all
# Download all dependent packages, and specify the main version of PHP to download, optional: 7.3, 7.4, 8.0, 8.1, 8.2, 8.3
# Download all dependent packages, and specify the main version of PHP to download, optional: 8.1, 8.2, 8.3, 8.4
# Also supports specific version of php release: 8.3.10, 8.2.22, etc.
bin/spc download --all --with-php=8.2
bin/spc download --all --with-php=8.3
# Show download progress bar while downloading (curl)
bin/spc download --all --debug
@@ -217,7 +261,7 @@ bin/spc download --for-extensions=redis -G "php-src:master:https://github.com/ph
bin/spc download --for-extensions=swoole -G "swoole:master:https://github.com/swoole/swoole-src.git"
```
## Command - doctor
### Command - doctor
If you can run `bin/spc` normally but cannot compile static PHP or dependent libraries normally,
you can run `bin/spc doctor` first to check whether the system itself lacks dependencies.
@@ -230,13 +274,13 @@ bin/spc doctor
bin/spc doctor --auto-fix
```
## Command - build
### Command - build
Use the build command to start building the static php binary.
Before executing the `bin/spc build` command, be sure to use the `download` command to download sources.
It is recommended to use `doctor` to check the environment.
### Basic build
#### Basic build
You need to go to [Extension List](./extensions) or [Command Generator](./cli-generator) to select the extension you want to add,
and then use the command `bin/spc build` to compile.
@@ -272,27 +316,18 @@ If you want to build multiple versions of PHP and don't want to build other depe
you can use `switch-php-version` to quickly switch to another version and compile after compiling one version:
```shell
# switch to 8.3
bin/spc switch-php-version 8.3
# switch to 8.4
bin/spc switch-php-version 8.4
# build
bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli
# switch to 8.0
bin/spc switch-php-version 8.0
# switch to 8.1
bin/spc switch-php-version 8.1
# build
bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli
```
:::
### Debug
If you encounter problems during the compilation process, or want to view each executing shell command,
you can use `--debug` to enable debug mode and view all terminal logs:
```bash
bin/spc build mysqlnd,pdo_mysql --build-all --debug
```
### Build Options
#### Build Options
During the compilation process, in some special cases,
the compiler and the content of the compilation directory need to be intervened.
@@ -314,6 +349,7 @@ You can try to use the following commands:
- `--with-suggested-exts`: Add `ext-suggests` as dependencies when compiling
- `--with-suggested-libs`: Add `lib-suggests` as dependencies when compiling
- `--with-upx-pack`: Use UPX to reduce the size of the binary file after compilation (you need to use `bin/spc install-pkg upx` to install upx first)
- `--build-shared=XXX,YYY`: compile the specified extension into a shared library (the default is to compile into a static library)
For hardcoding INI options, it works for cli, micro, embed sapi. Here is a simple example where we preset a larger `memory_limit` and disable the `system` function:
@@ -321,6 +357,15 @@ For hardcoding INI options, it works for cli, micro, embed sapi. Here is a simpl
bin/spc build bcmath,pcntl,posix --build-all -I "memory_limit=4G" -I "disable_functions=system"
```
## Debug
If you encounter problems during the compilation process, or want to view each executing shell command,
you can use `--debug` to enable debug mode and view all terminal logs:
```bash
bin/spc build mysqlnd,pdo_mysql --build-all --debug
```
## Command - micro:combine
Use the `micro:combine` command to build the compiled `micro.sfx` and your code (`.php` or `.phar` file) into an executable binary.
@@ -397,6 +442,31 @@ manually unpack and copy the package to a specified location, and we can use com
bin/spc extract php-src,libxml2
```
## Command - dump-extensions
Use the command `bin/spc dump-extensions` to export required extensions of the current project.
```bash
# Print the extension list of the project, pass in the root directory of the project containing composer.json
bin/spc dump-extensions /path/to/your/project/
# Print the extension list of the project, excluding development dependencies
bin/spc dump-extensions /path-to/tour/project/ --no-dev
# Output in the extension list format acceptable to the spc command (comma separated)
bin/spc dump-extensions /path-to/tour/project/ --format=text
# Output as a JSON list
bin/spc dump-extensions /path-to/tour/project/ --format=json
# When the project does not have any extensions, output the specified extension combination instead of returning failure
bin/spc dump-extensions /path-to/your/project/ --no-ext-output=mbstring,posix,pcntl,phar
# Do not exclude extensions not supported by spc when outputting
bin/spc dump-extensions /path/to/your/project/ --no-spc-filter
```
It should be noted that the project directory must contain the `vendor/installed.json` and `composer.lock` files, otherwise they cannot be found normally.
## Dev Command - dev
Debug commands refer to a collection of commands that can assist in outputting some information
@@ -553,3 +623,76 @@ If you need to build multiple times locally, the following method can save you t
- If you want to rebuild once, but do not re-download the source code, you can first `rm -rf buildroot source` to delete the compilation directory and source code directory, and then rebuild.
- If you want to update a version of a dependency, you can use `bin/spc del-download <source-name>` to delete the specified source code, and then use `download <source-name>` to download it again.
- If you want to update all dependent versions, you can use `bin/spc download --clean` to delete all downloaded sources, and then download them again.
## embed usage
If you want to embed static-php into other C language programs, you can use `--build-embed` to build an embed version of PHP.
```bash
bin/spc build {your extensions} --build-embed --debug
```
Under normal circumstances, PHP embed will generate `php-config` after compilation.
For static-php, we provide `spc-config` to obtain the parameters during compilation.
In addition, when using embed SAPI (libphp.a), you need to use the same compiler as libphp, otherwise there will be a link error.
Here is the basic usage of spc-config:
```bash
# output all flags and options
bin/spc spc-config curl,zlib,phar,openssl
# output libs
bin/spc spc-config curl,zlib,phar,openssl --libs
# output includes
bin/spc spc-config curl,zlib,phar,openssl --includes
```
By default, static-php uses the following compilers on different systems:
- macOS: `clang`
- Linux (Alpine Linux): `gcc`
- Linux (glibc based distros, x86_64): `/usr/local/musl/bin/x86_64-linux-musl-gcc`
- Linux (glibc based distros, aarch64): `/usr/local/musl/bin/aarch64-linux-musl-gcc`
- FreeBSD: `clang`
Here is an example of using embed SAPI:
```c
// embed.c
#include <sapi/embed/php_embed.h>
int main(int argc,char **argv){
PHP_EMBED_START_BLOCK(argc,argv)
zend_file_handle file_handle;
zend_stream_init_filename(&file_handle,"embed.php");
if(php_execute_script(&file_handle) == FAILURE){
php_printf("Failed to execute PHP script.\n");
}
PHP_EMBED_END_BLOCK()
return 0;
}
```
```php
<?php
// embed.php
echo "Hello world!\n";
```
```bash
# compile in debian/ubuntu x86_64
/usr/local/musl/bin/x86_64-linux-musl-gcc embed.c $(bin/spc spc-config bcmath,zlib) -static -o embed
# compile in macOS/FreeBSD
clang embed.c $(bin/spc spc-config bcmath,zlib) -o embed
./embed
# out: Hello world!
```

View File

@@ -8,8 +8,15 @@ here will describe how to check the errors by yourself and report Issue.
Problems with downloading resources are one of the most common problems with spc.
The main reason is that the addresses used for SPC download resources are generally the official website of the corresponding project or GitHub, etc.,
and these websites may occasionally go down and block IP addresses.
Currently, version 2.0.0 has not added an automatic retry mechanism, so after encountering a download failure,
you can try to call the download command multiple times. If you confirm that the address is indeed inaccessible,
After encountering a download failure,
you can try to call the download command multiple times.
When downloading extensions, you may eventually see errors like `curl: (56) The requested URL returned error: 403` which are often caused by github rate limiting.
You can verify this by adding `--debug` to the command and will see something like `[DEBU] Running command (no output) : curl -sfSL "https://api.github.com/repos/openssl/openssl/releases"`.
To fix this, [create](https://github.com/settings/tokens) a personal access token on GitHub and set it as an environment variable `GITHUB_TOKEN=<XXX>`.
If you confirm that the address is indeed inaccessible,
you can submit an Issue or PR to update the url or download type.
## Doctor Can't Fix Something
@@ -31,3 +38,5 @@ and then determine the command that reported the error.
The error terminal output is very important for fixing compilation errors.
When submitting an issue, please upload the last error fragment of the terminal log (or the entire terminal log output),
and include the `spc` command and parameters used.
If you are rebuilding, please refer to the [Local Build - Multiple Builds](./manual-build#multiple-builds) section.

View File

@@ -0,0 +1,7 @@
---
aside: false
---
# craft.yml 配置
<!--@include: ../../deps-craft-yml.md-->

View File

@@ -16,10 +16,26 @@ PHP 默认也会从 [其他标准位置](https://www.php.net/manual/zh/configura
## 静态编译的 PHP 可以安装扩展吗
因为传统架构下的 PHP 安装扩展的原理是使用 `.so` 类型的动态链接的库方式安装新扩展,而使用本项目编译的静态链接的 PHP 无法**直接**使用动态链接库安装新扩展
因为传统架构下的 PHP 安装扩展的原理是使用 `.so` 类型的动态链接的库方式安装新扩展,而使用本项目编译的静态链接的 PHP。但是静态链接在不同操作系统有不同的定义
首先对于 Linux 系统来说,静态链接的二进制文件是不会链接系统的动态链接库的,纯静态链接的二进制无法加载动态库,所以无法添加新的扩展。
同时,在纯静态模式下你也不能使用 `ffi` 等扩展加载外部的 `.so` 模块。
你可以通过命令 `ldd buildroot/bin/php` 来查看你在 Linux 下构建的二进制是否为纯静态链接的。
如果你 [构建 GNU libc 兼容的 PHP](../guide/build-with-glibc),你可以使用 `ffi` 扩展加载外部的 `.so` 模块,并且加载具有相同 ABI 的 `.so` 扩展。
例如,你可以使用以下命令构建一个 glibc 动态链接的静态 PHP 二进制,同时支持 FFI 扩展和加载相同 PHP 版本和相同 TS 类型的 `xdebug.so` 扩展:
```bash
bin/spc-gnu-docker download --for-extensions=ffi,xml --with-php=8.4
bin/spc-gnu-docker build ffi,xml --build-cli --debug
buildroot/bin/php -d "zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so" --ri xdebug
```
对于 macOS 平台来说macOS 下的几乎所有二进制文件都无法真正纯静态链接,几乎所有二进制文件都会链接 macOS 的系统库:`/usr/lib/libresolv.9.dylib``/usr/lib/libSystem.B.dylib`
所以在 macOS 系统下,在特定的编译条件下可以使用静态编译的 php 二进制文件,同时使用动态链接的扩展:
所以在 macOS 系统下,在特定的编译条件下可以使用静态编译的 php 二进制文件,使用动态链接的扩展:
1. 使用 `--no-strip` 参数,将不会对二进制文件去除调试符号等信息,以供使用 `Xdebug` 等外部 Zend 扩展。
2. 如果要编译某些 Zend 扩展,使用 Homebrew、MacPorts、源码编译的形式在所在的操作系统安装一个普通版本的 PHP。
@@ -31,12 +47,10 @@ PHP 默认也会从 [其他标准位置](https://www.php.net/manual/zh/configura
bin/spc build ffi --build-cli --no-strip
```
对于 Linux 平台来说,目前的编译结果为纯静态链接的二进制文件,无法使用动态链接库安装新扩展。
## 可以支持 Oracle 数据库扩展吗
部分依赖库闭源的扩展,如 `oci8``sourceguardian` 等,它们没有提供纯静态编译的依赖库文件(`.a`),仅提供了动态依赖库文件(`.so`
这些扩展无法使用源码的形式编译到 static-php-cli 中,所以本项目可能永远也不会支持这些扩展。不过,理论上你可以根据上面的问题在 macOS 下接入和使用这类扩展。
这些扩展无法使用源码的形式编译到 static-php-cli 中,所以本项目可能永远也不会支持这些扩展。不过,理论上你可以根据上面的问题在 macOS 和 Linux 下接入和使用这类扩展。
如果你对此类扩展有需求,或者大部分人都对这些闭源扩展使用有需求,
可以看看有关 [standalone-php-cli](https://github.com/crazywhalecc/static-php-cli/discussions/58) 的讨论。欢迎留言。
@@ -62,6 +76,8 @@ PHP 代码的编译器是完全不同的项目,因此不会考虑额外的情
## 无法使用 ssl
**更新:该问题已在最新版本的 static-php-cli 中修复,现在默认读取系统的证书文件。如果你仍然遇到问题,再尝试下方的解决方案。**
使用 curl、pgsql 等 请求 HTTPS 网站或建立 SSL 连接时,可能存在 `error:80000002:system library::No such file or directory` 错误,
这个错误是由于静态编译的 PHP 未通过 `php.ini` 指定 `openssl.cafile` 导致的。
@@ -70,4 +86,10 @@ PHP 代码的编译器是完全不同的项目,因此不会考虑额外的情
对于 Linux 系统,你可以从 curl 官方网站下载 [cacert.pem](https://curl.se/docs/caextract.html) 文件,也可以使用系统自带的证书文件。
有关不同发行版的证书位置,可参考 [Go 标准库](https://go.dev/src/crypto/x509/root_linux.go)。
> INI 配置 `openssl.cafile` 不可以使用 `ini_set()` 函数动态设置,因为 `openssl.cafile` 是一个 `PHP_INI_SYSTEM` 类型的配置,只能在 `php.ini` 文件中设置。
> INI 配置 `openssl.cafile` 不可以使用 `ini_set()` 函数动态设置,因为 `openssl.cafile` 是一个 `PHP_INI_SYSTEM` 类型的配置,只能在 `php.ini` 文件中设置。
## 为什么不支持旧版本 PHP
因为旧版本的 PHP 有很多问题,比如安全问题、性能问题、功能问题等。此外,旧版本的 PHP 很多都无法与最新的依赖库兼容,这也是不支持旧版本 PHP 的原因之一。
你可以使用 static-php-cli 早期编译好的旧版本,如 PHP 8.0,但是不会明确支持早期版本。

View File

@@ -0,0 +1,54 @@
# 构建 glibc 兼容的 Linux 二进制
## 为什么要构建 glibc 兼容的二进制
目前static-php-cli 在默认条件下在 Linux 系统构建的二进制都是基于 musl-libc静态链接的。
musl-libc 是一个轻量级的 libc 实现,它的目标是与 glibc 兼容,并且提供良好的纯静态链接支持。
这意味着,编译出来的静态 PHP 可执行文件在几乎任何 Linux 发行版都可以使用,而不需要考虑 libc、libstdc++ 等库的版本问题。
但是Linux 系统的纯静态链接 musl-libc 二进制文件存在以下问题:
- 无法使用 PHP 的 `dl()` 函数加载动态链接库和外部 PHP 扩展。
- 无法使用 PHP 的 FFI 扩展。
- 部分极端情况下,可能会出现性能问题,参见 [musl-libc 的性能问题](https://github.com/php/php-src/issues/13648)。
对于不同的 Linux 发行版,它们使用的默认 libc 可能不同,比如 Alpine Linux 使用 musl libc而大多数 Linux 发行版使用 glibc。
但即便如此,我们也不能直接使用任意的发行版和 glibc 构建便携的静态二进制文件,因为 glibc 有一些问题:
- 基于新版本的发行版在使用 gcc 等工具构建的二进制,无法在旧版本的发行版上运行。
- glibc 不推荐被静态链接,因为它的一些特性需要动态链接库的支持。
但是,我们可以使用 Docker 容器来解决这个问题,最终输出的结果是一个动态链接 glibc 和一些必要库的二进制,但它静态链接所有其他依赖。
1. 使用一个旧版本的 Linux 发行版(如 CentOS 7.x它的 glibc 版本比较旧,但是可以在大多数现代 Linux 发行版上运行。
2. 在这个容器中构建 PHP 的静态二进制文件,这样就可以在大多数现代 Linux 发行版上运行了。
> 使用 glibc 的静态二进制文件,可以在大多数现代 Linux 发行版上运行,但是不能在 musl libc 的发行版上运行,如 CentOS 6、Alpine Linux 等。
## 构建 glibc 兼容的 Linux 二进制
最新版的 static-php-cli 内置了 `bin/spc-gnu-docker` 脚本,可以一键创建一个 CentOS 7.x (glibc-2.17) 的 Docker 容器,并在容器中构建 glibc 兼容的 PHP 静态二进制文件。
然后,先运行一次以下命令。首次运行时时间较长,因为需要下载 CentOS 7.x 的镜像和一些编译工具。
```bash
bin/spc-gnu-docker
```
构建镜像完成后,你将看到和 `bin/spc` 一样的命令帮助菜单,这时说明容器已经准备好了。
在容器准备好后,你可以参考 [本地构建](./manual-build) 章节的内容,构建你的 PHP 静态二进制文件。仅需要把 `bin/spc``./spc` 替换为 `bin/spc-gnu-docker` 即可。
```bash
bin/spc-gnu-docker build bcmath,ctype,openssl,pdo,phar,posix,session,tokenizer,xml,zip --build-cli --debug
```
## 注意事项
极少数情况下,基于 glibc 的静态 PHP 可能会出现 segment fault 等错误,但目前例子较少,如果遇到问题请提交 issue。
glibc 构建为扩展的特性,不属于默认 static-php 的支持范围。如果有相关问题或需求,请在提交 Issue 时注明你是基于 glibc 构建的。
如果你需要不使用 Docker 构建基于 glibc 的二进制,请参考 `bin/spc-gnu-docker` 脚本,手动构建一个类似的环境。
请注意,我们仅支持使用 bin/spc-gnu-docker 构建的 glibc 版本。已在 RHEL 9 和 10 上进行了编译测试并验证其稳定性,但如果您遇到问题,我们可能不会进行修复。

View File

@@ -36,6 +36,19 @@ SPC_CONCURRENCY=4 bin/spc build mbstring,pcntl --build-cli
例如,你需要修改编译 PHP 的 `./configure` 命令,你可以在 `config/env.ini` 文件中找到 `SPC_CMD_PREFIX_PHP_CONFIGURE` 环境变量,然后修改其值即可。
但如果你的构建条件比较复杂,需要多种 env.ini 进行切换,我们推荐你使用 `config/env.custom.ini` 文件,这样你可以在不修改默认的 `config/env.ini` 文件的情况下,
通过写入额外的重载项目指定你的环境变量。
```ini
; This is an example of `config/env.custom.ini` file,
; we modify the `SPC_CONCURRENCY` and linux default CFLAGS passing to libs and PHP
[global]
SPC_CONCURRENCY=4
[linux]
SPC_DEFAULT_C_FLAGS="-O3"
```
## 编译依赖库的环境变量(仅限 Unix 系统)
从 2.2.0 开始static-php-cli 对所有 macOS、Linux、FreeBSD 等 Unix 系统的编译依赖库的命令均支持自定义环境变量。

View File

@@ -4,6 +4,8 @@
## curl
HTTP3 支持默认未启用,需在编译时添加 `--with-libs="nghttp2,nghttp3,ngtcp2"` 以启用 PHP 8.4 及以上版本的 HTTP3 支持。
使用 curl 请求 HTTPS 时,可能存在 `error:80000002:system library::No such file or directory` 错误,
解决办法详见 [FAQ - 无法使用 ssl](../faq/#无法使用-ssl)。
@@ -43,7 +45,11 @@ swoole-hook-sqlite 与 `pdo_sqlite` 扩展冲突。如需使用 Swoole 和 `pdo_
## swow
1. swow 仅支持 PHP >= 8.0 版本。
1. swow 仅支持 PHP 8.0 ~ 8.4 版本。
## imagick
imagick 扩展目前仅在 musl libc 上支持 OpenMPlibgomp。使用 glibc 方式构建的 imagick 扩展无法支持多线程特性。
## imap
@@ -70,9 +76,9 @@ bin/spc build gd --with-libs=freetype,libjpeg,libavif,libwebp --build-cli
## xdebug
1. Xdebug 是一个 Zend 扩展Xdebug 的功能依赖于 PHP 的 Zend 引擎和底层代码,如果要将其静态编译到 PHP 中,可能需要巨量的 patch 代码,这是不可行的
2. macOS 平台可以通过在相同平台编译的 PHP 下编译一个 xdebug 扩展,并提取其中的 `xdebug.so` 文件,再在 static-php-cli 中使用 `--no-strip` 参数保留调试符号表,同时加入 `ffi` 扩展。
编译的 `./php` 二进制可以通过指定 INI 配置运行,例如`./php -d 'zend_extension=xdebug.so' your-code.php`
1. Xdebug 只能作为共享扩展进行构建。在 Linux 上,您需要使用 static-php-cli 并设置 SPC_LIBC=glibc
2. 使用 Linux/glibc 或 macOS 时,您可以使用 `--build-shared=xdebug` 将 Xdebug 编译为共享扩展。
编译`./php` 二进制文件可以通过指定 INI 文件进行配置运行,例如 `./php -d 'zend_extension=/path/to/xdebug.so' your-code.php`
## xml
@@ -113,9 +119,10 @@ pgsql 16.2 修复了这个 Bug现在正常工作了。
## ffi
1. 因为 Linux 系统的限制,虽然可以成功编译 ffi 扩展,但无法使用它加载其他 `so` 扩展。Linux 支持加载 so 扩展的前提是非静态编译,但动态编译和本项目的目的冲突
2. macOS 支持 ffi 扩展,但是部分内核下不包含调试符号时会出现错误
3. Windows 支持 ffi 扩展。
1. 由于 musl libc 静态链接的限制,无法加载动态库,因此无法使用 ffi
如果您需要使用 ffi 扩展,请参阅 [使用 GNU libc 编译 PHP](./build-with-glibc)
2. macOS 支持 ffi 扩展,但某些内核不包含调试符号时会出现错误
3. Windows x64 支持 ffi 扩展。
## xhprof
@@ -134,5 +141,10 @@ parallel 扩展只支持 PHP 8.0 及以上版本,并只支持 ZTS 构建(`--
## spx
1. [SPX 扩展](https://github.com/NoiseByNorthwest/php-spx) 只支持非线程模式
2. SPX 目前不支持 Windows且官方仓库也不支持静态编译static-php-cli 使用了 [修改版本](https://github.com/static-php/php-spx)。
1. SPX 目前不支持 Windows且官方仓库也不支持静态编译static-php-cli 使用了 [修改版本](https://github.com/static-php/php-spx)。
## mimalloc
1. 从技术上讲,这不是扩展,而是一个库。
2. 在 Linux 或 macOS 上使用 `--with-libs="mimalloc"` 进行构建将覆盖默认分配器。
3. 目前,这还处于实验阶段,但建议在线程环境中使用。

View File

@@ -29,6 +29,6 @@ Windows 目前只支持 x86_64 架构,不支持 32 位 x86、不支持 arm64
## PHP 支持版本
目前static-php-cli 对 PHP 7.4 ~ 8.3 版本是支持的,对于 PHP 7.4 及更早版本理论上支持,只需下载时选择早期版本即可。
目前static-php-cli 对 PHP 8.1 ~ 8.4 版本是支持的,对于 PHP 8.0 及更早版本理论上支持,只需下载时选择早期版本即可。
但由于部分扩展和特殊组件已对早期版本的 PHP 停止了支持,所以 static-php-cli 不会明确支持早期版本。
我们推荐你编译尽可能新的 PHP 版本,以获得更好的体验。

View File

@@ -1,3 +1,7 @@
---
outline: 'deep'
---
# 本地构建Linux、macOS、FreeBSD
本章节为 Linux、macOS、FreeBSD 的构建过程,如果你要在 Windows 上构建,请到 [在 Windows 上构建](./build-on-windows)。
@@ -50,29 +54,29 @@ cd static-php-cli
composer update
```
### 使用系统 PHP 环境
### 使用预编译静态 PHP 二进制运行 static-php-cli
下面是系统安装 PHP、Composer 的一些示例命令。具体安装方式建议自行搜索或询问 AI 搜索引擎获取答案,这里不多赘述。
如果你不想使用 Docker、在系统安装 PHP,可以直接下载本项目自身编译好的 php 二进制 cli 程序。使用流程如下:
```bash
# [macOS], 需要先安装 Homebrew. See https://brew.sh/
# Remember change your composer executable path. For M1/M2 Chip mac, "/opt/homebrew/bin/", for Intel mac, "/usr/local/bin/". Or add it to your own path.
brew install php wget
wget https://getcomposer.org/download/latest-stable/composer.phar -O /path/to/your/bin/composer && chmod +x /path/to/your/bin/composer
# [Debian], you need to make sure your php version >= 8.1 and composer >= 2.0
sudo apt install php-cli composer php-tokenizer
# [Alpine]
apk add bash file wget xz php81 php81-common php81-pcntl php81-tokenizer php81-phar php81-posix php81-xml composer
```
使用命令部署环境,此脚本会从 [自托管的服务器](https://dl.static-php.dev/static-php-cli/) 下载一个当前操作系统的 php-cli 包,
并从 [getcomposer](https://getcomposer.org/download/latest-stable/composer.phar) 或 [Aliyun镜像](https://mirrors.aliyun.com/composer/composer.phar) 下载 Composer。
::: tip
目前 Ubuntu 部分版本的 apt 安装的 php 版本较旧,故不提供安装命令。如有需要,建议先添加 ppa 等软件源后,安装最新版的 PHP 以及 tokenizer、xml、phar 扩展
较老版本的 Debian 默认安装的可能为旧版本(<= 7.4)版本的 PHP建议先升级 Debian。
使用预编译静态 PHP 二进制目前仅支持 Linux 和 macOS。FreeBSD 环境因为缺少自动化构建环境,所以暂不支持
:::
```bash
bin/setup-runtime
# 对于中国大陆地区等网络环境特殊的用户,可使用镜像站加快下载速度
bin/setup-runtime --mirror china
```
此脚本总共会下载两个文件:`bin/php``bin/composer`,下载完成后,有两种使用方式:
1.`bin/` 目录添加到 PATH 路径中:`export PATH="/path/to/your/static-php-cli/bin:$PATH"`,添加路径后,相当于系统安装了 PHP可直接使用 `composer``php -v` 等命令,也可以直接使用 `bin/spc`
2. 直接调用,比如执行 static-php-cli 命令:`bin/php bin/spc --help`,执行 Composer`bin/php bin/composer update`
### 使用 Docker 环境
如果你不愿意在系统安装 PHP 和 Composer 运行环境,可以使用内置的 Docker 环境构建脚本。
@@ -92,30 +96,65 @@ bin/spc-alpine-docker
export SPC_USE_SUDO=yes
```
### 使用预编译静态 PHP 二进制
### 使用系统 PHP 环境
如果你不想使用 Docker、在系统安装 PHP,可以直接下载本项目自身编译好的 php 二进制 cli 程序。使用流程如下:
使用命令部署环境,此脚本会从 [自托管的服务器](https://dl.static-php.dev/static-php-cli/) 下载一个当前操作系统的 php-cli 包,
并从 [getcomposer](https://getcomposer.org/download/latest-stable/composer.phar) 或 [Aliyun镜像](https://mirrors.aliyun.com/composer/composer.phar) 下载 Composer。
::: tip
使用预编译静态 PHP 二进制目前仅支持 Linux 和 macOS。FreeBSD 环境因为缺少自动化构建环境,所以暂不支持。
:::
下面是系统安装 PHP、Composer 的一些示例命令。具体安装方式建议自行搜索或询问 AI 搜索引擎获取答案,这里不多赘述。
```bash
bin/setup-runtime
# [macOS], 需要先安装 Homebrew. See https://brew.sh/
# Remember change your composer executable path. For M1/M2 Chip mac, "/opt/homebrew/bin/", for Intel mac, "/usr/local/bin/". Or add it to your own path.
brew install php wget
wget https://getcomposer.org/download/latest-stable/composer.phar -O /path/to/your/bin/composer && chmod +x /path/to/your/bin/composer
# 对于中国大陆地区等网络环境特殊的用户,可使用镜像站加快下载速度
bin/setup-runtime --mirror china
# [Debian], you need to make sure your php version >= 8.4 and composer >= 2.0
sudo apt install php-cli composer php-tokenizer
```
此脚本总共会下载两个文件:`bin/php``bin/composer`,下载完成后,有两种使用方式:
::: tip
目前 Ubuntu 部分版本的 apt 安装的 php 版本较旧,故不提供安装命令。如有需要,建议先添加 ppa 等软件源后,安装最新版的 PHP 以及 tokenizer、xml、phar 扩展。
1.`bin/` 目录添加到 PATH 路径中:`export PATH="/path/to/your/static-php-cli/bin:$PATH"`,添加路径后,相当于系统安装了 PHP可直接使用 `composer``php -v` 等命令,也可以直接使用 `bin/spc`
2. 直接调用,比如执行 static-php-cli 命令:`bin/php bin/spc --help`,执行 Composer`bin/php bin/composer update`
较老版本的 Debian 默认安装的可能为旧版本(<= 8.3)版本的 PHP建议先升级 Debian 或使用 Docker 或自带的静态二进制环境
:::
## 命令 download - 下载依赖包
## 使用 craft 构建(推荐)
使用 `bin/spc craft` 可以使用一个配置文件,一个命令实现自动检查环境、下载源代码、构建依赖库、构建 PHP 及扩展等。
你需要编写一个 `craft.yml` 文件,存放在当前工作目录下。`craft.yml` 可以由 [命令生成器](./cli-generator) 生成,或者手动编写。
手动编写可参考 [craft.yml 配置](../develop/craft-yml.md) 中的注释来编写。我们下面假设你编译一个扩展组合,并选用 PHP 8.4,输出 `cli``fpm`
```yaml
# path/to/craft.yml
php-version: 8.4
extensions: bcmath,posix,phar,zlib,openssl,curl,fileinfo,tokenizer
sapi:
- cli
- fpm
```
然后使用 `bin/spc craft` 命令来编译:
```bash
bin/spc craft --debug
```
如果构建成功,你会在当前目录下看到 `buildroot/bin` 目录,里面包含了编译好的 PHP 二进制文件,或相应的 SAPI。
- cli: Windows 下构建结果为 `buildroot/bin/php.exe`,其他平台为 `buildroot/bin/php`
- fpm: 构建结果为 `buildroot/bin/php-fpm`
- micro: 构建结果为 `buildroot/bin/micro.sfx`,如需进一步与 PHP 代码打包,请查看 [打包 micro 二进制](./manual-build#命令-micro-combine-打包-micro-二进制)。
- embed: 参见 [embed 使用](./manual-build#embed-使用)。
如果中途构建出错,你可以使用 `--debug` 参数查看详细的错误信息,或者使用 `--with-clean` 参数清除旧的编译结果,重新编译。
如使用以上方式仍构建失败,请提交一个 issue附上你的 `craft.yml``craft.log`
## 分步构建命令
如果你有定制化需求,或分开下载、编译 PHP 和依赖库的需求,可以使用 `bin/spc` 命令分步执行。
### 命令 download - 下载依赖包
使用命令 `bin/spc download` 可以下载编译需要的源代码,包括 php-src 以及依赖的各种库的源码。
@@ -141,8 +180,8 @@ bin/spc download --for-extensions="curl,pcntl,xml,mbstring" --prefer-pre-built
# 下载所有依赖包
bin/spc download --all
# 下载所有依赖包,并指定下载的 PHP 主版本,可选:7.37.48.08.18.28.3,也可以使用特定的版本,如 8.3.10。
bin/spc download --all --with-php=8.2
# 下载所有依赖包,并指定下载的 PHP 主版本可选8.18.28.38.4也可以使用特定的版本,如 8.3.10。
bin/spc download --all --with-php=8.3
# 下载时显示下载进度条curl
bin/spc download --all --debug
@@ -187,7 +226,7 @@ bin/spc download --for-extensions=redis,phar -G "php-src:master:https://github.c
bin/spc download --for-extensions=swoole -G "swoole:master:https://github.com/swoole/swoole-src.git"
```
## 命令 doctor - 环境检查
### 命令 doctor - 环境检查
如果你可以正常运行 `bin/spc` 但无法正常编译静态的 PHP 或依赖库,可以先运行 `bin/spc doctor` 检查系统自身是否缺少依赖。
@@ -199,11 +238,11 @@ bin/spc doctor
bin/spc doctor --auto-fix
```
## 命令 build - 编译 PHP
### 命令 build - 编译 PHP
使用 build 命令可以开始构建静态 php 二进制,在执行 `bin/spc build` 命令前,务必先使用 `download` 命令下载资源,建议使用 `doctor` 检查环境。
### 基本用法
#### 基本用法
你需要先到 [扩展列表](./extensions) 或 [命令生成器](./cli-generator) 选择你要加入的扩展,然后使用命令 `bin/spc build` 进行编译。你需要指定一个编译目标,从如下参数中选择:
@@ -236,26 +275,18 @@ bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli
如果你想构建多个版本的 PHP且不想每次都重复构建其他依赖库可以使用 `switch-php-version` 在编译好一个版本后快速切换至另一个版本并编译:
```shell
# switch to 8.3
bin/spc switch-php-version 8.3
# switch to 8.4
bin/spc switch-php-version 8.4
# build
bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli
# switch to 8.0
bin/spc switch-php-version 8.0
# switch to 8.1
bin/spc switch-php-version 8.1
# build
bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli
```
:::
### 调试
如果你在编译过程中遇到了问题,或者想查看每个执行的 shell 命令,可以使用 `--debug` 开启 debug 模式,查看所有终端日志:
```bash
bin/spc build mysqlnd,pdo_mysql --build-all --debug
```
### 编译运行选项
#### 编译运行选项
在编译过程中,有些特殊情况需要对编译器、编译目录的内容进行干预,可以尝试使用以下命令:
@@ -275,6 +306,7 @@ bin/spc build mysqlnd,pdo_mysql --build-all --debug
- `--with-suggested-exts`: 编译时将 `ext-suggests` 也作为编译依赖加入
- `--with-suggested-libs`: 编译时将 `lib-suggests` 也作为编译依赖加入
- `--with-upx-pack`: 编译后使用 UPX 减小二进制文件体积(需先使用 `bin/spc install-pkg upx` 安装 upx
- `--build-shared=XXX,YYY`: 编译时将指定的扩展编译为共享库(默认编译为静态库)
硬编码 INI 选项适用于 cli、micro、embed。有关硬编码 INI 选项,下面是一个简单的例子,我们预设一个更大的 `memory_limit`,并且禁用 `system` 函数:
@@ -342,6 +374,14 @@ memory_limit=1G
如果要打包 phar只需要将 `a.php` 替换为打包好的 phar 文件即可。但要注意phar 下的 micro.sfx 需要额外注意路径问题,见 [Developing - Phar 路径问题](../develop/structure#phar-应用目录问题)
## 调试
如果你在编译过程中遇到了问题,或者想查看每个执行的 shell 命令,可以使用 `--debug` 开启 debug 模式,查看所有终端日志:
```bash
bin/spc build mysqlnd,pdo_mysql --build-all --debug
```
## 命令 extract - 手动解压某个库
使用命令 `bin/spc extract` 可以解包和拷贝编译需要的源代码,包括 php-src 以及依赖的各种库的源码(需要自己指定要解包的库名)。
@@ -353,6 +393,32 @@ memory_limit=1G
bin/spc extract php-src,libxml2
```
## 命令 dump-extensions - 导出项目扩展依赖
使用命令 `bin/spc dump-extensions` 可以导出当前项目的扩展依赖。
```bash
# 打印项目的扩展列表传入项目包含composer.json的根目录
bin/spc dump-extensions /path/to/your/project/
# 打印项目的扩展列表,不包含开发依赖
bin/spc dump-extensions /path-to/tour/project/ --no-dev
# 输出为 spc 命令可接受的扩展列表格式(逗号分割)
bin/spc dump-extensions /path-to/tour/project/ --format=text
# 输出为 JSON 列表
bin/spc dump-extensions /path-to/tour/project/ --format=json
# 当项目没有任何扩展时,输出指定扩展组合,而不是返回失败
bin/spc dump-extensions /path-to/your/project/ --no-ext-output=mbstring,posix,pcntl,phar
# 输出时不排除 spc 不支持的扩展
bin/spc dump-extensions /path/to/your/project/ --no-spc-filter
```
需要注意的是,项目的目录下必须包含 `vendor/installed.json``composer.lock` 文件,否则无法正常获取。
## 调试命令 dev - 调试命令集合
调试命令指的是你在使用 static-php-cli 构建 PHP 或改造、增强 static-php-cli 项目本身的时候,可以辅助输出一些信息的命令集合。
@@ -493,3 +559,75 @@ static-php-cli 开放的方法非常多,文档中无法一一列举,但只
- 如果你想重新构建一次,但不重新下载源码,可以先 `rm -rf buildroot source` 删除编译目录和源码目录,然后重新构建。
- 如果你想更新某个依赖的版本,可以使用 `bin/spc del-download <source-name>` 删除指定的源码,然后使用 `download <source-name>` 重新下载。
- 如果你想更新所有依赖的版本,可以使用 `bin/spc download --clean` 删除所有下载的源码,然后重新下载。
## embed 使用
如果你想将 static-php 嵌入到其他 C 语言程序中,可以使用 `--build-embed` 构建一个 embed 版本的 PHP。
```bash
bin/spc build {your extensions} --build-embed --debug
```
在通常的情况下PHP embed 编译后会生成 `php-config`。对于 static-php我们提供了 `spc-config`,用于获取编译时的参数。
另外,在使用 embed SAPIlibphp.a你需要使用和编译 libphp 相同的编译器,否则会出现链接错误。
下面是 spc-config 的基本用法:
```bash
# output all flags and options
bin/spc spc-config curl,zlib,phar,openssl
# output libs
bin/spc spc-config curl,zlib,phar,openssl --libs
# output includes
bin/spc spc-config curl,zlib,phar,openssl --includes
```
默认情况下static-php 在不同系统使用的编译器分别是:
- macOS: `clang`
- Linux (Alpine Linux): `gcc`
- Linux (glibc based distros, x86_64): `/usr/local/musl/bin/x86_64-linux-musl-gcc`
- Linux (glibc based distros, aarch64): `/usr/local/musl/bin/aarch64-linux-musl-gcc`
- FreeBSD: `clang`
下面是一个使用 embed SAPI 的例子:
```c
// embed.c
#include <sapi/embed/php_embed.h>
int main(int argc,char **argv){
PHP_EMBED_START_BLOCK(argc,argv)
zend_file_handle file_handle;
zend_stream_init_filename(&file_handle,"embed.php");
if(php_execute_script(&file_handle) == FAILURE){
php_printf("Failed to execute PHP script.\n");
}
PHP_EMBED_END_BLOCK()
return 0;
}
```
```php
<?php
// embed.php
echo "Hello world!\n";
```
```bash
# compile in debian/ubuntu x86_64
/usr/local/musl/bin/x86_64-linux-musl-gcc embed.c $(bin/spc spc-config bcmath,zlib) -static -o embed
# compile in macOS/FreeBSD
clang embed.c $(bin/spc spc-config bcmath,zlib) -o embed
./embed
# out: Hello world!
```

View File

@@ -5,7 +5,14 @@
## 下载失败问题
下载资源问题是 spc 最常见的问题之一。主要是由于 spc 下载资源使用的地址一般均为对应项目的官方网站或 GitHub 等,而这些网站可能偶尔会宕机、屏蔽 IP 地址。
目前 2.0.0 版本还没有加入自动重试机制,所以在遇到下载失败后,可以多次尝试调用下载命令。如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址
在遇到下载失败后,可以多次尝试调用下载命令
当下载资源时,你可能最终会看到类似 `curl: (56) The requested URL returned error: 403` 的错误,这通常是由于 GitHub 限制导致的。
你可以通过在命令中添加 `--debug` 来验证,会看到类似 `[DEBU] Running command (no output) : curl -sfSL "https://api.github.com/repos/openssl/openssl/releases"` 的输出。
要解决这个问题,可以在 GitHub 上 [创建](https://github.com/settings/token) 一个个人访问令牌,并将其设置为环境变量 `GITHUB_TOKEN=<XXX>`
如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址。
## doctor 无法修复
@@ -18,3 +25,5 @@
遇到编译错误时,如果没有开启 `--debug` 日志,请先开启调试日志,然后确定报错的命令。
报错的终端输出对于修复编译错误非常重要,请在提交 Issue 时一并将终端日志的最后报错片段(或整个终端日志输出)上传,并且包含使用的 `spc` 命令和参数。
如果你是重复构建,请参考 [本地构建 - 多次构建](./manual-build#多次构建) 章节,清理构建缓存后再次构建。

View File

@@ -5,7 +5,7 @@
"docs:preview": "vitepress preview docs"
},
"devDependencies": {
"vitepress": "^1.0.0-rc.35",
"vitepress": "^2.0.0-alpha.5",
"vue": "^3.2.47"
}
}

View File

@@ -4,8 +4,9 @@ declare(strict_types=1);
namespace SPC;
use SPC\command\BuildCliCommand;
use SPC\command\BuildLibsCommand;
use SPC\command\BuildPHPCommand;
use SPC\command\CraftCommand;
use SPC\command\DeleteDownloadCommand;
use SPC\command\dev\AllExtCommand;
use SPC\command\dev\ExtVerCommand;
@@ -18,10 +19,12 @@ use SPC\command\dev\PhpVerCommand;
use SPC\command\dev\SortConfigCommand;
use SPC\command\DoctorCommand;
use SPC\command\DownloadCommand;
use SPC\command\DumpExtensionsCommand;
use SPC\command\DumpLicenseCommand;
use SPC\command\ExtractCommand;
use SPC\command\InstallPkgCommand;
use SPC\command\MicroCombineCommand;
use SPC\command\SPCConfigCommand;
use SPC\command\SwitchPhpVersionCommand;
use Symfony\Component\Console\Application;
@@ -30,7 +33,7 @@ use Symfony\Component\Console\Application;
*/
final class ConsoleApplication extends Application
{
public const VERSION = '2.3.6';
public const VERSION = '2.6.0';
public function __construct()
{
@@ -41,8 +44,10 @@ final class ConsoleApplication extends Application
$this->addCommands(
[
// Craft command
new CraftCommand(),
// Common commands
new BuildCliCommand(),
new BuildPHPCommand(),
new BuildLibsCommand(),
new DoctorCommand(),
new DownloadCommand(),
@@ -52,6 +57,8 @@ final class ConsoleApplication extends Application
new ExtractCommand(),
new MicroCombineCommand(),
new SwitchPhpVersionCommand(),
new SPCConfigCommand(),
new DumpExtensionsCommand(),
// Dev commands
new AllExtCommand(),

View File

@@ -4,8 +4,10 @@ declare(strict_types=1);
namespace SPC\builder;
use PharIo\FileSystem\File;
use SPC\exception\ExceptionHandler;
use SPC\exception\FileSystemException;
use SPC\exception\InterruptException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
@@ -24,6 +26,12 @@ abstract class BuilderBase
/** @var array<string, Extension> extensions */
protected array $exts = [];
/** @var array<int, string> extension names */
protected array $ext_list = [];
/** @var array<int, string> library names */
protected array $lib_list = [];
/** @var bool compile libs only (just mark it) */
protected bool $libs_only = false;
@@ -115,9 +123,12 @@ abstract class BuilderBase
*
* @return Extension[]
*/
public function getExts(): array
public function getExts(bool $including_shared = true): array
{
return $this->exts;
if ($including_shared) {
return $this->exts;
}
return array_filter($this->exts, fn ($ext) => $ext->isBuildStatic());
}
/**
@@ -129,7 +140,7 @@ abstract class BuilderBase
public function hasCpp(): bool
{
// judge cpp-extension
$exts = array_keys($this->getExts());
$exts = array_keys($this->getExts(false));
foreach ($exts as $ext) {
if (Config::getExt($ext, 'cpp-extension', false) === true) {
return true;
@@ -160,26 +171,49 @@ abstract class BuilderBase
* @throws FileSystemException
* @throws RuntimeException
* @throws \ReflectionException
* @throws WrongUsageException
* @throws \Throwable|WrongUsageException
* @internal
*/
public function proveExts(array $extensions, bool $skip_check_deps = false): void
public function proveExts(array $static_extensions, array $shared_extensions = [], bool $skip_check_deps = false, bool $skip_extract = false): void
{
CustomExt::loadCustomExt();
$this->emitPatchPoint('before-php-extract');
SourceManager::initSource(sources: ['php-src']);
$this->emitPatchPoint('after-php-extract');
if ($this->getPHPVersionID() >= 80000) {
$this->emitPatchPoint('before-micro-extract');
SourceManager::initSource(sources: ['micro']);
$this->emitPatchPoint('after-micro-extract');
// judge ext
foreach ($static_extensions as $ext) {
// if extension does not support static build, throw exception
if (!in_array('static', Config::getExtTarget($ext))) {
throw new WrongUsageException('Extension [' . $ext . '] does not support static build!');
}
}
$this->emitPatchPoint('before-exts-extract');
SourceManager::initSource(exts: $extensions);
$this->emitPatchPoint('after-exts-extract');
foreach ($extensions as $extension) {
foreach ($shared_extensions as $ext) {
// if extension does not support shared build, throw exception
if (!in_array('shared', Config::getExtTarget($ext)) && !in_array($ext, $shared_extensions)) {
throw new WrongUsageException('Extension [' . $ext . '] does not support shared build!');
}
}
if (!$skip_extract) {
$this->emitPatchPoint('before-php-extract');
SourceManager::initSource(sources: ['php-src'], source_only: true);
$this->emitPatchPoint('after-php-extract');
if ($this->getPHPVersionID() >= 80000) {
$this->emitPatchPoint('before-micro-extract');
SourceManager::initSource(sources: ['micro'], source_only: true);
$this->emitPatchPoint('after-micro-extract');
}
$this->emitPatchPoint('before-exts-extract');
SourceManager::initSource(exts: [...$static_extensions, ...$shared_extensions]);
$this->emitPatchPoint('after-exts-extract');
}
foreach ([...$static_extensions, ...$shared_extensions] as $extension) {
$class = CustomExt::getExtClass($extension);
/** @var Extension $ext */
$ext = new $class($extension, $this);
if (in_array($extension, $static_extensions)) {
$ext->setBuildStatic();
}
if (in_array($extension, $shared_extensions)) {
$ext->setBuildShared();
}
$this->addExt($ext);
}
@@ -187,9 +221,10 @@ abstract class BuilderBase
return;
}
foreach ($this->exts as $ext) {
foreach ($this->getExts() as $ext) {
$ext->checkDependency();
}
$this->ext_list = [...$static_extensions, ...$shared_extensions];
}
/**
@@ -199,6 +234,54 @@ abstract class BuilderBase
*/
abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE);
/**
* Test PHP
*/
abstract public function testPHP(int $build_target = BUILD_TARGET_NONE);
/**
* @throws WrongUsageException
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildSharedExts(): void
{
$lines = file(BUILD_BIN_PATH . '/php-config');
$extension_dir_line = null;
foreach ($lines as $key => $value) {
if (str_starts_with($value, 'extension_dir=')) {
$lines[$key] = 'extension_dir="' . BUILD_MODULES_PATH . '"' . PHP_EOL;
$extension_dir_line = $value;
break;
}
}
file_put_contents(BUILD_BIN_PATH . '/php-config', implode('', $lines));
FileSystem::createDir(BUILD_MODULES_PATH);
try {
foreach ($this->getExts() as $ext) {
if (!$ext->isBuildShared()) {
continue;
}
if (Config::getExt($ext->getName(), 'type') === 'builtin' || Config::getExt($ext->getName(), 'build-with-php') === true) {
if (file_exists(BUILD_MODULES_PATH . '/' . $ext->getName() . '.so')) {
logger()->info('Shared extension [' . $ext->getName() . '] was already built by php-src/configure (' . $ext->getName() . '.so)');
continue;
}
if (Config::getExt($ext->getName(), 'build-with-php') === true) {
logger()->warning('Shared extension [' . $ext->getName() . '] did not build with php-src/configure (' . $ext->getName() . '.so)');
logger()->warning('Try deleting your build and source folders and running `spc build`` again.');
continue;
}
}
$ext->buildShared();
}
} catch (RuntimeException $e) {
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);
}
/**
* Generate extension enable arguments for configure.
* e.g. --enable-mbstring
@@ -206,12 +289,24 @@ abstract class BuilderBase
* @throws FileSystemException
* @throws WrongUsageException
*/
public function makeExtensionArgs(): string
public function makeStaticExtensionArgs(): string
{
$ret = [];
foreach ($this->exts as $ext) {
logger()->info($ext->getName() . ' is using ' . $ext->getConfigureArg());
$ret[] = trim($ext->getConfigureArg());
foreach ($this->getExts() as $ext) {
$arg = $ext->getConfigureArg();
if ($ext->isBuildShared() && !$ext->isBuildStatic()) {
if (
(Config::getExt($ext->getName(), 'type') === 'builtin' &&
!file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) ||
Config::getExt($ext->getName(), 'build-with-php') === true
) {
$arg = $ext->getConfigureArg(true);
} else {
continue;
}
}
logger()->info($ext->getName() . ' is using ' . $arg);
$ret[] = trim($arg);
}
logger()->debug('Using configure: ' . implode(' ', $ret));
return implode(' ', $ret);
@@ -276,7 +371,7 @@ abstract class BuilderBase
return false;
}
}
if (preg_match('/php-(\d+\.\d+\.\d+)/', $file, $match)) {
if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) {
return $match[1];
}
return false;
@@ -388,7 +483,7 @@ abstract class BuilderBase
foreach ($this->libs as $lib) {
$lib->validate();
}
foreach ($this->exts as $ext) {
foreach ($this->getExts() as $ext) {
$ext->validate();
}
}
@@ -407,6 +502,13 @@ abstract class BuilderBase
}
logger()->debug('Running additional patch script: ' . $patch);
require $patch;
} catch (InterruptException $e) {
if ($e->getCode() === 0) {
logger()->notice('Patch script ' . $patch . ' interrupted' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.'));
} else {
logger()->error('Patch script ' . $patch . ' interrupted with error code [' . $e->getCode() . ']' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.'));
}
exit($e->getCode());
} catch (\Throwable $e) {
logger()->critical('Patch script ' . $patch . ' failed to run.');
if ($this->getOption('debug')) {
@@ -414,6 +516,7 @@ abstract class BuilderBase
} else {
logger()->critical('Please check with --debug option to see more details.');
}
throw $e;
}
}
}
@@ -425,7 +528,7 @@ abstract class BuilderBase
{
$php = "<?php\n\necho '[micro-test-start]' . PHP_EOL;\n";
foreach ($this->getExts() as $ext) {
foreach ($this->getExts(false) as $ext) {
$ext_name = $ext->getDistName();
if (!empty($ext_name)) {
$php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n";

View File

@@ -9,11 +9,18 @@ use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\FileSystem;
use SPC\util\SPCConfigUtil;
class Extension
{
protected array $dependencies = [];
protected bool $build_shared = false;
protected bool $build_static = false;
protected string $source_dir;
/**
* @throws FileSystemException
* @throws RuntimeException
@@ -30,6 +37,25 @@ class Extension
if (PHP_OS_FAMILY === 'Windows' && $unix_only) {
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Windows platform");
}
// set source_dir for builtin
if ($ext_type === 'builtin') {
$this->source_dir = SOURCE_PATH . '/php-src/ext/' . $this->name;
} elseif ($ext_type === 'external') {
$source = Config::getExt($this->name, 'source');
if ($source === null) {
throw new RuntimeException("{$ext_type} extension {$name} source not found");
}
$source_path = Config::getSource($source)['path'] ?? null;
$source_path = $source_path === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $source_path;
$this->source_dir = $source_path;
} else {
$this->source_dir = SOURCE_PATH . '/php-src';
}
}
public function getFrameworks(): array
{
return Config::getExt($this->getName(), 'frameworks', []);
}
/**
@@ -38,20 +64,15 @@ class Extension
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getConfigureArg(): string
public function getConfigureArg(bool $shared = false): string
{
$arg = $this->getEnableArg();
switch (PHP_OS_FAMILY) {
case 'Windows':
$arg .= $this->getWindowsConfigureArg();
break;
case 'Darwin':
case 'Linux':
case 'BSD':
$arg .= $this->getUnixConfigureArg();
break;
}
return $arg;
return match (PHP_OS_FAMILY) {
'Windows' => $this->getWindowsConfigureArg($shared),
'Darwin',
'Linux',
'BSD' => $this->getUnixConfigureArg($shared),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build is not supported yet'),
};
}
/**
@@ -60,13 +81,13 @@ class Extension
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getEnableArg(): string
public function getEnableArg(bool $shared = false): string
{
$_name = str_replace('_', '-', $this->name);
return match ($arg_type = Config::getExt($this->name, 'arg-type', 'enable')) {
'enable' => '--enable-' . $_name . ' ',
'with' => '--with-' . $_name . ' ',
'with-prefix' => '--with-' . $_name . '="' . BUILD_ROOT_PATH . '" ',
'enable' => '--enable-' . $_name . ($shared ? '=shared' : '') . ' ',
'with' => '--with-' . $_name . ($shared ? '=shared' : '') . ' ',
'with-prefix' => '--with-' . $_name . '=' . ($shared ? 'shared,' : '') . '"' . BUILD_ROOT_PATH . '" ',
'none', 'custom' => '',
default => throw new WrongUsageException("argType does not accept {$arg_type}, use [enable/with/with-prefix] ."),
};
@@ -126,20 +147,21 @@ class Extension
return $this->name;
}
public function getWindowsConfigureArg(): string
public function getWindowsConfigureArg(bool $shared = false): string
{
return '';
return $this->getEnableArg();
// Windows is not supported yet
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '';
return $this->getEnableArg($shared);
}
/**
* Patch code before ./buildconf
* If you need to patch some code, overwrite this and return true
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeBuildconf(): bool
{
@@ -148,7 +170,8 @@ class Extension
/**
* Patch code before ./configure
* If you need to patch some code, overwrite this and return true
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeConfigure(): bool
{
@@ -157,13 +180,81 @@ class Extension
/**
* Patch code before make
* If you need to patch some code, overwrite this and return true
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeMake(): bool
{
return false;
}
/**
* Patch code before shared extension phpize
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeSharedBuild(): bool
{
return false;
}
/**
* Patch code before shared extension ./configure
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeSharedConfigure(): bool
{
return false;
}
/**
* @return string
* returns a command line string with all required shared extensions to load
* i.e.; pdo_pgsql would return:
*
* `-d "extension=pgsql" -d "extension=pdo_pgsql"`
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getSharedExtensionLoadString(): string
{
$loaded = [];
$order = [];
$resolve = function ($extension) use (&$resolve, &$loaded, &$order) {
if (isset($loaded[$extension->getName()])) {
return;
}
$loaded[$extension->getName()] = true;
foreach ($this->dependencies as $dependency) {
$resolve($dependency);
}
$order[] = $extension;
};
$resolve($this);
$ret = '';
foreach ($order as $ext) {
if ($ext instanceof Extension && $ext->isBuildShared()) {
if (Config::getExt($ext->getName(), 'zend-extension', false) === true) {
$ret .= " -d \"zend_extension={$ext->getName()}\"";
} else {
$ret .= " -d \"extension={$ext->getName()}\"";
}
}
}
if ($ret !== '') {
$ret = ' -d "extension_dir=' . BUILD_MODULES_PATH . '"' . $ret;
}
return $ret;
}
/**
* @throws RuntimeException
*/
@@ -172,7 +263,8 @@ class Extension
// 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] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $this->getDistName() . '"', false);
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
}
@@ -185,7 +277,7 @@ class Extension
file_get_contents(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php')
);
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"');
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"');
if ($ret !== 0) {
if ($this->builder->getOption('debug')) {
var_dump($out);
@@ -203,7 +295,7 @@ class Extension
// 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 --ri "' . $this->getDistName() . '"', false);
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n --ri "' . $this->getDistName() . '"', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
}
@@ -216,7 +308,7 @@ class Extension
file_get_contents(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))
);
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -r "' . trim($test) . '"');
[$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');
}
@@ -228,6 +320,85 @@ class Extension
// do nothing, just throw wrong usage exception if not valid
}
/**
* Build shared extension
*
* @throws WrongUsageException
* @throws RuntimeException
*/
public function buildShared(): void
{
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('extension ' . $this->getName() . ' already built, skipping');
return;
}
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()], with_dependencies: true);
[$staticLibString, $sharedLibString] = $this->getStaticAndSharedLibs();
$env = [
'CFLAGS' => $config['cflags'],
'CXXFLAGS' => $config['cflags'],
'LDFLAGS' => $config['ldflags'],
'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibString . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString,
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
];
// prepare configure args
shell()->cd($this->source_dir)
->setEnv($env)
->exec(BUILD_BIN_PATH . '/phpize');
if ($this->patchBeforeSharedConfigure()) {
logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure');
}
shell()->cd($this->source_dir)
->setEnv($env)
->exec(
'./configure ' . $this->getUnixConfigureArg(true) .
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
'--enable-shared --disable-static'
);
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
'/^(.*_SHARED_LIBADD\s*=.*)$/m',
'$1 ' . $staticLibString
);
shell()->cd($this->source_dir)
->setEnv($env)
->exec('make clean')
->exec('make -j' . $this->builder->concurrency)
->exec('make install');
}
/**
* Get current extension version
*
@@ -238,6 +409,32 @@ class Extension
return null;
}
public function setBuildStatic(): void
{
if (!in_array('static', Config::getExtTarget($this->name))) {
throw new WrongUsageException("Extension [{$this->name}] does not support static build!");
}
$this->build_static = true;
}
public function setBuildShared(): void
{
if (!in_array('shared', Config::getExtTarget($this->name))) {
throw new WrongUsageException("Extension [{$this->name}] does not support shared build!");
}
$this->build_shared = true;
}
public function isBuildShared(): bool
{
return $this->build_shared;
}
public function isBuildStatic(): bool
{
return $this->build_static;
}
/**
* @throws RuntimeException
*/
@@ -270,6 +467,37 @@ class Extension
}
}
/**
* Get required static and shared libraries as a pair of strings in format -l{libname} -l{libname2}
*
* @return array [staticLibString, sharedLibString]
*/
private function getStaticAndSharedLibs(): array
{
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true);
$sharedLibString = '';
$staticLibString = '';
$staticLibs = $this->getLibFilesString();
$staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs);
$staticLibs = str_replace('.a', '', $staticLibs);
$staticLibs = explode('-l', $staticLibs . ' ' . $config['libs']);
foreach ($staticLibs as $lib) {
$lib = trim($lib);
if ($lib === '') {
continue;
}
$static_lib = 'lib' . $lib . '.a';
if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) {
if (!str_contains($staticLibString, '-l' . $lib . ' ')) {
$staticLibString .= '-l' . $lib . ' ';
}
} elseif (!str_contains($sharedLibString, '-l' . $lib . ' ')) {
$sharedLibString .= '-l' . $lib . ' ';
}
}
return [trim($staticLibString), trim($sharedLibString)];
}
private function getLibraryDependencies(bool $recursive = false): array
{
$ret = array_filter($this->dependencies, fn ($x) => $x instanceof LibraryBase);
@@ -295,6 +523,11 @@ class Extension
}
}
if (array_key_exists(0, $deps)) {
$zero = [0 => $deps[0]];
unset($deps[0]);
return $zero + $deps;
}
return $deps;
}
}

View File

@@ -8,11 +8,15 @@ use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\Downloader;
use SPC\store\FileSystem;
use SPC\store\SourceManager;
use SPC\util\GlobalValueTrait;
abstract class LibraryBase
{
use GlobalValueTrait;
/** @var string */
public const NAME = 'unknown';
@@ -30,7 +34,7 @@ abstract class LibraryBase
if (static::NAME === 'unknown') {
throw new RuntimeException('no unknown!!!!!');
}
$this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . static::NAME);
$this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . Config::getLib(static::NAME, 'source'));
}
/**
@@ -45,8 +49,9 @@ abstract class LibraryBase
$lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? [];
$source = Config::getLib(static::NAME, 'source');
// if source is locked as pre-built, we just tryInstall it
if (isset($lock[$source]) && ($lock[$source]['lock_as'] ?? SPC_LOCK_SOURCE) === SPC_LOCK_PRE_BUILT) {
return $this->tryInstall($lock[$source]['filename'], $force);
$pre_built_name = Downloader::getPreBuiltLockName($source);
if (isset($lock[$pre_built_name]) && ($lock[$pre_built_name]['lock_as'] ?? SPC_DOWNLOAD_SOURCE) === SPC_DOWNLOAD_PRE_BUILT) {
return $this->tryInstall($lock[$pre_built_name]['filename'], $force);
}
return $this->tryBuild($force);
}
@@ -113,7 +118,7 @@ abstract class LibraryBase
/*
Rules:
If it is a Windows system, try the following dependencies in order: lib-depends-windows, lib-depends-win, lib-depends.
If it is a macOS system, try the following dependencies in order: lib-depends-darwin, lib-depends-unix, lib-depends.
If it is a macOS system, try the following dependencies in order: lib-depends-macos, lib-depends-unix, lib-depends.
If it is a Linux system, try the following dependencies in order: lib-depends-linux, lib-depends-unix, lib-depends.
*/
foreach (Config::getLib(static::NAME, 'lib-depends', []) as $dep_name) {
@@ -146,6 +151,17 @@ abstract class LibraryBase
return Config::getLib(static::NAME, 'headers', []);
}
/**
* Get binary files.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getBinaryFiles(): array
{
return Config::getLib(static::NAME, 'bin', []);
}
/**
* @throws WrongUsageException
* @throws FileSystemException
@@ -203,12 +219,13 @@ abstract class LibraryBase
}
// force means just build
if ($force_build) {
logger()->info('Building required library [' . static::NAME . ']');
$type = Config::getLib(static::NAME, 'type', 'lib');
logger()->info('Building required ' . $type . ' [' . static::NAME . ']');
// extract first if not exists
if (!is_dir($this->source_dir)) {
$this->getBuilder()->emitPatchPoint('before-library[ ' . static::NAME . ']-extract');
SourceManager::initSource(libs: [static::NAME]);
SourceManager::initSource(libs: [static::NAME], source_only: true);
$this->getBuilder()->emitPatchPoint('after-library[ ' . static::NAME . ']-extract');
}
@@ -236,23 +253,19 @@ abstract class LibraryBase
return LIB_STATUS_OK;
}
}
// pkg-config is treated specially. If it is pkg-config, check if the pkg-config binary exists
if (static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) {
$this->tryBuild(true);
return LIB_STATUS_OK;
// current library is package and binary file is not exists
if (Config::getLib(static::NAME, 'type', 'lib') === 'package') {
foreach ($this->getBinaryFiles() as $name) {
if (!file_exists(BUILD_BIN_PATH . "/{$name}")) {
$this->tryBuild(true);
return LIB_STATUS_OK;
}
}
}
// if all the files exist at this point, skip the compilation process
return LIB_STATUS_ALREADY;
}
/**
* Patch before build, overwrite this and return true to patch libs.
*/
public function patchBeforeBuild(): bool
{
return false;
}
public function validate(): void
{
// do nothing, just throw wrong usage exception if not valid
@@ -278,6 +291,46 @@ abstract class LibraryBase
// do something before pack, default do nothing. overwrite this method to do something (e.g. modify pkg-config file)
}
/**
* Patch code before build
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeBuild(): bool
{
return false;
}
/**
* Patch code before ./buildconf
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeBuildconf(): bool
{
return false;
}
/**
* Patch code before ./configure
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeConfigure(): bool
{
return false;
}
/**
* Patch code before make
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeMake(): bool
{
return false;
}
/**
* Build this library.
*

View File

@@ -23,12 +23,12 @@ class amqp extends Extension
return false;
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '--with-amqp --with-librabbitmq-dir=' . BUILD_ROOT_PATH;
return '--with-amqp' . ($shared ? '=shared' : '') . ' --with-librabbitmq-dir=' . BUILD_ROOT_PATH;
}
public function getWindowsConfigureArg(): string
public function getWindowsConfigureArg($shared = false): string
{
return '--with-amqp';
}

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
@@ -21,7 +22,7 @@ class curl extends Extension
{
logger()->info('patching before-configure for curl checks');
$file1 = "AC_DEFUN([PHP_CHECK_LIBRARY], [\n $3\n])";
$files = FileSystem::readFile(SOURCE_PATH . '/php-src/ext/curl/config.m4');
$files = FileSystem::readFile($this->source_dir . '/config.m4');
$file2 = 'AC_DEFUN([PHP_CHECK_LIBRARY], [
save_old_LDFLAGS=$LDFLAGS
ac_stuff="$5"
@@ -40,7 +41,7 @@ class curl extends Extension
$4
])dnl
])';
file_put_contents(SOURCE_PATH . '/php-src/ext/curl/config.m4', $file1 . "\n" . $files . "\n" . $file2);
file_put_contents($this->source_dir . '/config.m4', $file1 . "\n" . $files . "\n" . $file2);
return true;
}
@@ -52,6 +53,72 @@ class curl extends Extension
{
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lcurl/', $this->getLibFilesString() . $frameworks);
$this->patchBeforeSharedConfigure();
return true;
}
public function patchBeforeSharedConfigure(): bool
{
$file = $this->source_dir . '/config.m4';
$content = FileSystem::readFile($file);
// Inject patch before it
$patch = ' save_LIBS="$LIBS"
LIBS="$LIBS $CURL_LIBS"
';
// Check if already patched
if (str_contains($content, $patch)) {
return false; // Already patched
}
// Match the line containing PHP_CHECK_LIBRARY for curl
$pattern = '/(PHP_CHECK_LIBRARY\(\[curl],\s*\[curl_easy_perform],)/';
// Restore LIBS after the check — append this just after the macro block
$restore = '
LIBS="$save_LIBS"';
// Apply patch
$patched = preg_replace_callback($pattern, function ($matches) use ($patch) {
return $patch . $matches[1];
}, $content, 1);
// Inject restore after the matching PHP_CHECK_LIBRARY block
$patched = preg_replace(
'/(PHP_CHECK_LIBRARY\(\[curl],\s*\[curl_easy_perform],.*?\)\n)/s',
"$1{$restore}\n",
$patched,
1
);
if ($patched === null) {
throw new \RuntimeException('Failed to patch config.m4 due to a regex error');
}
FileSystem::writeFile($file, $patched);
return true;
}
public function buildUnixShared(): void
{
if (!$this->builder instanceof LinuxBuilder) {
parent::buildUnixShared();
return;
}
FileSystem::replaceFileStr(
$this->source_dir . '/config.m4',
['$ext_dir/phar.1', '$ext_dir/phar.phar.1'],
['${ext_dir}phar.1', '${ext_dir}phar.phar.1']
);
try {
parent::buildUnixShared();
} finally {
FileSystem::replaceFileStr(
$this->source_dir . '/config.m4',
['${ext_dir}phar.1', '${ext_dir}phar.phar.1'],
['$ext_dir/phar.1', '$ext_dir/phar.phar.1']
);
}
}
}

View File

@@ -10,13 +10,13 @@ use SPC\util\CustomExt;
#[CustomExt('dba')]
class dba extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : '';
return '--enable-dba' . $qdbm;
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH) : '';
return '--enable-dba' . ($shared ? '=shared' : '') . $qdbm;
}
public function getWindowsConfigureArg(): string
public function getWindowsConfigureArg(bool $shared = false): string
{
$qdbm = $this->builder->getLib('qdbm') ? ' --with-qdbm' : '';
return '--with-dba' . $qdbm;

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('dio')]
class dio extends Extension
{
public function patchBeforeBuildconf(): bool
{
if (!file_exists(SOURCE_PATH . '/php-src/ext/dio/php_dio.h')) {
FileSystem::writeFile(SOURCE_PATH . '/php-src/ext/dio/php_dio.h', FileSystem::readFile(SOURCE_PATH . '/php-src/ext/dio/src/php_dio.h'));
return true;
}
return false;
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('dom')]
class dom extends Extension
{
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-dom' . ($shared ? '=shared' : '');
$arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"';
return $arg;
}
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/win32/build/config.w32', 'dllmain.c ', '');
return true;
}
public function getWindowsConfigureArg($shared = false): string
{
return '--with-dom';
}
}

View File

@@ -10,7 +10,7 @@ use SPC\util\CustomExt;
#[CustomExt('enchant')]
class enchant extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
$glibs = [
'/Users/jerry/project/git-project/static-php-cli/buildroot/lib/libgio-2.0.a',

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('ev')]
class ev extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
/*
* replace EXTENSION('ev', php_ev_sources, true, ' /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
* to EXTENSION('ev', php_ev_sources, PHP_EV_SHARED, ' /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
*/
FileSystem::replaceFileLineContainsString(
$this->source_dir . '/config.w32',
'EXTENSION(\'ev\'',
" EXTENSION('ev', php_ev_sources, PHP_EV_SHARED, ' /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');"
);
return true;
}
}

View File

@@ -13,7 +13,7 @@ use SPC\util\CustomExt;
#[CustomExt('event')]
class event extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--with-event-core --with-event-extra --with-event-libevent-dir=' . BUILD_ROOT_PATH;
if ($this->builder->getLib('openssl')) {

View File

@@ -10,12 +10,12 @@ use SPC\util\CustomExt;
#[CustomExt('ffi')]
class ffi extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '--with-ffi --enable-zend-signals';
return '--with-ffi' . ($shared ? '=shared' : '') . ' --enable-zend-signals';
}
public function getWindowsConfigureArg(): string
public function getWindowsConfigureArg(bool $shared = false): string
{
return '--with-ffi';
}

View File

@@ -10,9 +10,9 @@ use SPC\util\CustomExt;
#[CustomExt('gd')]
class gd extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-gd';
$arg = '--enable-gd' . ($shared ? '=shared' : '');
$arg .= $this->builder->getLib('freetype') ? ' --with-freetype' : '';
$arg .= $this->builder->getLib('libjpeg') ? ' --with-jpeg' : '';
$arg .= $this->builder->getLib('libwebp') ? ' --with-webp' : '';

View File

@@ -30,12 +30,12 @@ class glfw extends Extension
return true;
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
}
public function getWindowsConfigureArg(): string
public function getWindowsConfigureArg(bool $shared = false): string
{
return '--enable-glfw=static';
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\builder\windows\WindowsBuilder;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager;
#[CustomExt('grpc')]
class grpc extends Extension
{
public function patchBeforeBuildconf(): bool
{
// soft link to the grpc source code
if ($this->builder instanceof WindowsBuilder) {
// not support windows yet
throw new \RuntimeException('grpc extension does not support windows yet');
}
if (!is_link(SOURCE_PATH . '/php-src/ext/grpc')) {
if (is_dir($this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc')) {
shell()->exec('ln -s ' . $this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
} elseif (is_dir(BUILD_ROOT_PATH . '/grpc_php_ext_src')) {
shell()->exec('ln -s ' . BUILD_ROOT_PATH . '/grpc_php_ext_src ' . SOURCE_PATH . '/php-src/ext/grpc');
} else {
throw new \RuntimeException('Cannot find grpc source code');
}
$macos = $this->builder instanceof MacOSBuilder ? "\n" . ' LDFLAGS="$LDFLAGS -framework CoreFoundation"' : '';
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/grpc/config.m4', '/GRPC_LIBDIR=.*$/m', 'GRPC_LIBDIR=' . BUILD_LIB_PATH . $macos);
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/grpc/config.m4', '/SEARCH_PATH=.*$/m', 'SEARCH_PATH="' . BUILD_ROOT_PATH . '"');
return true;
}
return false;
}
public function patchBeforeMake(): bool
{
// add -Wno-strict-prototypes
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
return true;
}
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-grpc=' . BUILD_ROOT_PATH . '/grpc GRPC_LIB_SUBDIR=' . BUILD_LIB_PATH;
}
}

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\linux\LinuxBuilder;
use SPC\util\CustomExt;
#[CustomExt('imagick')]
@@ -13,17 +12,21 @@ class imagick extends Extension
{
public function patchBeforeMake(): bool
{
// imagick may call omp_pause_all which requires -lgomp
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
if ($this->builder instanceof LinuxBuilder) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . '-lgomp ';
if (PHP_OS_FAMILY !== 'Linux') {
return false;
}
if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) {
return false;
}
// imagick with calls omp_pause_all, which requires openmp, on non-musl we build imagick without openmp
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp');
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
return true;
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '--with-imagick=' . BUILD_ROOT_PATH;
$disable_omp = !(getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) ? '' : ' ac_cv_func_omp_pause_resource_all=no';
return '--with-imagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $disable_omp;
}
}

View File

@@ -33,7 +33,7 @@ class imap extends Extension
}
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--with-imap=' . BUILD_ROOT_PATH;
if ($this->builder->getLib('openssl') !== null) {

View File

@@ -18,9 +18,12 @@ class intl extends Extension
// Also need to use clang++ -std=c++17 to force override the default C++ standard
if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) {
f_putenv('CXX=' . $env . ' -std=c++17');
} else {
f_putenv('CXX=clang++ -std=c++17');
}
return true;
}
public function patchBeforeSharedBuild(): bool
{
return $this->patchBeforeBuildconf();
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('lz4')]
class lz4 extends Extension
{
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-lz4' . ($shared ? '=shared' : '') . ' --with-lz4-includedir=' . BUILD_ROOT_PATH;
}
public function getWindowsConfigureArg(bool $shared = false): string
{
return '--enable-lz4';
}
}

View File

@@ -16,7 +16,7 @@ class mbregex extends Extension
return 'mbstring';
}
public function getConfigureArg(): string
public function getConfigureArg(bool $shared = false): string
{
return '';
}
@@ -26,7 +26,8 @@ class mbregex extends Extension
*/
public function runCliCheckUnix(): void
{
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring" | grep regex', false);
$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 !');
}
@@ -34,7 +35,7 @@ class mbregex extends Extension
public function runCliCheckWindows(): void
{
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring"', false);
[$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 !');
}

View File

@@ -10,9 +10,20 @@ use SPC\util\CustomExt;
#[CustomExt('mbstring')]
class mbstring extends Extension
{
public function getConfigureArg(): string
public function getConfigureArg(bool $shared = false): string
{
$arg = '--enable-mbstring';
$arg = '--enable-mbstring' . ($shared ? '=shared' : '');
if ($this->builder->getExt('mbregex') === null) {
$arg .= ' --disable-mbregex';
} else {
$arg .= ' --enable-mbregex';
}
return $arg;
}
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-mbstring' . ($shared ? '=shared' : '');
if ($this->builder->getExt('mbregex') === null) {
$arg .= ' --disable-mbregex';
} else {

View File

@@ -12,9 +12,9 @@ use SPC\util\CustomExt;
#[CustomExt('memcache')]
class memcache extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-memcache --with-zlib-dir=' . BUILD_ROOT_PATH;
return '--enable-memcache' . ($shared ? '=shared' : '') . ' --with-zlib-dir=' . BUILD_ROOT_PATH;
}
/**

View File

@@ -10,9 +10,13 @@ use SPC\util\CustomExt;
#[CustomExt('memcached')]
class memcached extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
$rootdir = BUILD_ROOT_PATH;
return "--enable-memcached --with-zlib-dir={$rootdir} --with-libmemcached-dir={$rootdir} --disable-memcached-sasl --enable-memcached-json";
return '--enable-memcached' . ($shared ? '=shared' : '') . ' ' .
'--with-zlib-dir=' . BUILD_ROOT_PATH . ' ' .
'--with-libmemcached-dir=' . BUILD_ROOT_PATH . ' ' .
'--disable-memcached-sasl ' .
'--enable-memcached-json ' .
'--with-system-fastlz';
}
}

View File

@@ -10,7 +10,7 @@ use SPC\util\CustomExt;
#[CustomExt('mongodb')]
class mongodb extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = ' --enable-mongodb ';
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';

View File

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

View File

@@ -42,7 +42,7 @@ class opcache extends Extension
return file_put_contents(SOURCE_PATH . '/php-src/.opcache_patched', '1') !== false;
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-opcache';
}

View File

@@ -23,8 +23,9 @@ class openssl extends Extension
return false;
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '--with-openssl=' . BUILD_ROOT_PATH . ' --with-openssl-dir=' . BUILD_ROOT_PATH;
$openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH;
return '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir;
}
}

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager;
#[CustomExt('opentelemetry')]
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');
}
}
public function patchBeforeBuildconf(): bool
{
if (PHP_OS_FAMILY === 'Windows') {
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/opentelemetry/config.w32',
"EXTENSION('opentelemetry', 'opentelemetry.c otel_observer.c', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');",
"EXTENSION('opentelemetry', 'opentelemetry.c otel_observer.c', PHP_OPENTELEMETRY_SHARED, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');"
);
return true;
}
return false;
}
public function patchBeforeMake(): bool
{
// add -Wno-strict-prototypes
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
return true;
}
}

View File

@@ -6,6 +6,7 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('parallel')]
@@ -17,4 +18,10 @@ class parallel extends Extension
throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!');
}
}
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/parallel/config.m4', '/PHP_VERSION=.*/m', '');
return true;
}
}

View File

@@ -18,7 +18,7 @@ class password_argon2 extends Extension
public function runCliCheckUnix(): void
{
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
[$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');
}

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;
#[CustomExt('pdo_odbc')]
class pdo_odbc extends Extension
{
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/pdo_odbc/config.m4', 'PDO_ODBC_LDFLAGS="$pdo_odbc_def_ldflags', 'PDO_ODBC_LDFLAGS="-liconv $pdo_odbc_def_ldflags');
return true;
}
public function getUnixConfigureArg(bool $shared = false): string
{
return '--with-pdo-odbc=' . ($shared ? 'shared,' : '') . 'unixODBC,' . BUILD_ROOT_PATH;
}
public function getWindowsConfigureArg(bool $shared = false): string
{
return '--with-pdo-odbc';
}
}

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('pdo_pgsql')]
class pdo_pgsql extends Extension
{
public function getWindowsConfigureArg(bool $shared = false): string
{
return '--with-pdo-pgsql=yes';
}
}

View File

@@ -6,6 +6,8 @@ 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;
@@ -14,6 +16,8 @@ class pgsql extends Extension
{
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool
{
@@ -24,4 +28,33 @@ class pgsql extends Extension
);
return true;
}
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
if ($this->builder->getPHPVersionID() >= 80400) {
$libfiles = $this->getLibFilesString();
$libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles);
$libfiles = str_replace('.a', '', $libfiles);
return '--with-pgsql' . ($shared ? '=shared' : '') .
' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH .
' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"';
}
return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
}
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getWindowsConfigureArg(bool $shared = false): string
{
if ($this->builder->getPHPVersionID() >= 80400) {
return '--with-pgsql';
}
return '--with-pgsql=' . BUILD_ROOT_PATH;
}
}

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\linux\LinuxBuilder;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('phar')]
class phar extends Extension
{
public function buildUnixShared(): void
{
if (!$this->builder instanceof LinuxBuilder) {
parent::buildUnixShared();
return;
}
FileSystem::replaceFileStr(
$this->source_dir . '/config.m4',
['$ext_dir/phar.1', '$ext_dir/phar.phar.1'],
['${ext_dir}phar.1', '${ext_dir}phar.phar.1']
);
try {
parent::buildUnixShared();
} finally {
FileSystem::replaceFileStr(
$this->source_dir . '/config.m4',
['${ext_dir}phar.1', '${ext_dir}phar.phar.1'],
['$ext_dir/phar.1', '$ext_dir/phar.phar.1']
);
}
}
}

View File

@@ -15,5 +15,9 @@ class protobuf extends Extension
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');
}
// protobuf conflicts with grpc
if ($this->builder->getExt('grpc') !== null) {
throw new \RuntimeException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('rdkafka')]
class rdkafka extends Extension
{
public function patchBeforeBuildconf(): bool
{
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"');
return true;
}
public function patchBeforeMake(): bool
{
// when compiling rdkafka with inline builds, it shows some errors, I don't know why.
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/rdkafka/rdkafka.c',
"#ifdef HAS_RD_KAFKA_TRANSACTIONS\n#include \"kafka_error_exception.h\"\n#endif",
'#include "kafka_error_exception.h"'
);
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/rdkafka/kafka_error_exception.h',
['#ifdef HAS_RD_KAFKA_TRANSACTIONS', '#endif'],
''
);
return true;
}
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 . '"';
}
}

View File

@@ -24,4 +24,18 @@ class readline extends Extension
);
return true;
}
public function getUnixConfigureArg(bool $shared = false): string
{
return '--without-libedit --with-readline=' . BUILD_ROOT_PATH;
}
public function buildUnixShared(): void
{
if (!file_exists(BUILD_BIN_PATH . '/php') || !file_exists(BUILD_INCLUDE_PATH . '/php/sapi/cli/cli.h')) {
logger()->warning('CLI mode is not enabled, skipping readline build');
return;
}
parent::buildUnixShared();
}
}

View File

@@ -10,7 +10,7 @@ use SPC\util\CustomExt;
#[CustomExt('redis')]
class redis extends Extension
{
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-redis';
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
@@ -24,7 +24,7 @@ class redis extends Extension
return $arg;
}
public function getWindowsConfigureArg(): string
public function getWindowsConfigureArg(bool $shared = false): string
{
$arg = '--enable-redis';
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';

View File

@@ -26,7 +26,7 @@ class snappy extends Extension
return true;
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-snappy --with-snappy-includedir="' . BUILD_ROOT_PATH . '"';
}

View File

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

View File

@@ -5,28 +5,28 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('spx')]
class spx extends Extension
{
/**
* @throws WrongUsageException
*/
public function validate(): void
public function getUnixConfigureArg(bool $shared = false): string
{
if ($this->builder->getOption('enable-zts')) {
throw new WrongUsageException('ext-spx is not thread safe, do not build it with ZTS builds');
}
}
public function getUnixConfigureArg(): string
{
$arg = '--enable-spx';
if ($this->builder->getExt('zlib') === null) {
$arg = '--enable-spx' . ($shared ? '=shared' : '');
if ($this->builder->getLib('zlib') !== null) {
$arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH;
}
return $arg;
}
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileStr(
$this->source_dir . '/Makefile.frag',
'@cp -r assets/web-ui/*',
'@cp -r ' . $this->source_dir . '/assets/web-ui/*',
);
return true;
}
}

View File

@@ -35,7 +35,7 @@ class swoole extends Extension
return null;
}
public function getUnixConfigureArg(): string
public function getUnixConfigureArg(bool $shared = false): string
{
// enable swoole
$arg = '--enable-swoole';
@@ -49,7 +49,9 @@ class swoole extends Extension
// additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature)
$arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : '';
$arg .= $this->builder->getLib('brotli') ? (' --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
if (!$shared) {
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
}
$arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : '';
// additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc.

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