Skip to content

Commit cfb8cc9

Browse files
committed
Merge branch 'main' into v3-feat/skeleton
# Conflicts: # composer.lock # config/env.ini # src/SPC/ConsoleApplication.php
2 parents dd5762f + 1c28f0f commit cfb8cc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+466
-274
lines changed

bin/spc-alpine-docker

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ RUN apk update; \
108108
wget \
109109
xz \
110110
gettext-dev \
111-
binutils-gold \
112-
patchelf
111+
binutils-gold
113112
114113
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 && \
115114
chmod +x /usr/local/bin/php

bin/spc-gnu-docker

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc
9292
RUN source /etc/bashrc
9393
RUN yum install -y which
9494
95-
RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-$SPC_USE_ARCH.tar.gz && \
96-
mkdir -p /patchelf && \
97-
tar -xzf patchelf.tgz -C /patchelf --strip-components=1 && \
98-
cp /patchelf/bin/patchelf /usr/bin/
99-
10095
RUN curl -o cmake.tgz -#fSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$SPC_USE_ARCH.tar.gz && \
10196
mkdir /cmake && \
10297
tar -xzf cmake.tgz -C /cmake --strip-components 1

config/env.ini

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,20 @@ SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE
122122
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
123123
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
124124

125+
; optional, path to openssl conf. This affects where openssl will look for the default CA.
126+
; default on Debian/Alpine: /etc/ssl, default on RHEL: /etc/pki/tls
127+
OPENSSLDIR=""
128+
125129
[macos]
126130
; build target: macho or macho (possibly we could support macho-universal in the future)
127131
; Currently we do not support universal and cross-compilation for macOS.
128132
SPC_TARGET=native-macos
129133
; compiler environments
130-
CC=${SPC_LINUX_DEFAULT_CC}
131-
CXX=${SPC_LINUX_DEFAULT_CXX}
132-
AR=${SPC_LINUX_DEFAULT_AR}
133-
LD=${SPC_LINUX_DEFAULT_LD}
134+
CC=clang
135+
CXX=clang++
136+
AR=ar
137+
LD=ld
134138
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
135-
; this will be added to all CFLAGS and CXXFLAGS for the library builds
136139
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
137140
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
138141
SPC_DEFAULT_LD_FLAGS=""
@@ -150,3 +153,5 @@ SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-
150153
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
151154
; EXTRA_CFLAGS for `configure` and `make` php
152155
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_C_FLAGS}"
156+
; minimum compatible macOS version (LLVM vars, availability not guaranteed)
157+
MACOSX_DEPLOYMENT_TARGET=12.0

config/ext.json

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@
127127
"sockets"
128128
]
129129
},
130+
"excimer": {
131+
"support": {
132+
"Windows": "wip",
133+
"BSD": "wip"
134+
},
135+
"type": "external",
136+
"source": "ext-excimer"
137+
},
130138
"exif": {
131139
"type": "builtin"
132140
},
@@ -232,11 +240,13 @@
232240
"BSD": "wip"
233241
},
234242
"type": "external",
235-
"source": "grpc",
243+
"source": "ext-grpc",
236244
"arg-type-unix": "enable-path",
237245
"cpp-extension": true,
238246
"lib-depends": [
239-
"grpc"
247+
"zlib",
248+
"openssl",
249+
"libcares"
240250
]
241251
},
242252
"iconv": {
@@ -408,8 +418,7 @@
408418
"ext-depends": [
409419
"zlib",
410420
"session"
411-
],
412-
"build-with-php": true
421+
]
413422
},
414423
"memcached": {
415424
"support": {
@@ -487,6 +496,40 @@
487496
"zlib"
488497
]
489498
},
499+
"mysqlnd_ed25519": {
500+
"type": "external",
501+
"source": "mysqlnd_ed25519",
502+
"arg-type": "enable",
503+
"target": [
504+
"shared"
505+
],
506+
"ext-depends": [
507+
"mysqlnd"
508+
],
509+
"lib-depends": [
510+
"libsodium"
511+
],
512+
"lib-suggests": [
513+
"openssl"
514+
]
515+
},
516+
"mysqlnd_parsec": {
517+
"type": "external",
518+
"source": "mysqlnd_parsec",
519+
"arg-type": "enable",
520+
"target": [
521+
"shared"
522+
],
523+
"ext-depends": [
524+
"mysqlnd"
525+
],
526+
"lib-depends": [
527+
"libsodium"
528+
],
529+
"lib-suggests": [
530+
"openssl"
531+
]
532+
},
490533
"oci8": {
491534
"type": "wip",
492535
"support": {

config/lib.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@
361361
"source": "libargon2",
362362
"static-libs-unix": [
363363
"libargon2.a"
364+
],
365+
"lib-suggests": [
366+
"libsodium"
364367
]
365368
},
366369
"libavif": {

config/source.json

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,23 @@
126126
},
127127
"ext-event": {
128128
"type": "url",
129-
"url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz",
129+
"url": "https://bitbucket.org/osmanov/pecl-event/get/3.1.4.tar.gz",
130130
"path": "php-src/ext/event",
131131
"license": {
132132
"type": "file",
133133
"path": "LICENSE"
134134
}
135135
},
136+
"ext-excimer": {
137+
"type": "url",
138+
"url": "https://pecl.php.net/get/excimer",
139+
"path": "php-src/ext/excimer",
140+
"filename": "excimer.tgz",
141+
"license": {
142+
"type": "file",
143+
"path": "LICENSE"
144+
}
145+
},
136146
"ext-glfw": {
137147
"type": "git",
138148
"url": "https://github.com/mario-deluna/php-glfw",
@@ -151,6 +161,18 @@
151161
"path": "LICENSE"
152162
}
153163
},
164+
"ext-grpc": {
165+
"type": "url",
166+
"url": "https://pecl.php.net/get/grpc",
167+
"path": "php-src/ext/grpc",
168+
"filename": "grpc.tgz",
169+
"license": {
170+
"type": "file",
171+
"path": [
172+
"LICENSE"
173+
]
174+
}
175+
},
154176
"ext-imagick": {
155177
"type": "url",
156178
"url": "https://pecl.php.net/get/imagick",
@@ -670,19 +692,20 @@
670692
}
671693
},
672694
"libpng": {
673-
"type": "git",
674-
"url": "https://github.com/glennrp/libpng.git",
675-
"rev": "libpng16",
695+
"type": "ghtagtar",
696+
"repo": "pnggroup/libpng",
697+
"match": "v1\\.6\\.\\d+",
698+
"query": "?per_page=150",
676699
"provide-pre-built": true,
677700
"license": {
678701
"type": "file",
679702
"path": "LICENSE"
680703
}
681704
},
682705
"librabbitmq": {
683-
"type": "git",
684-
"url": "https://github.com/alanxz/rabbitmq-c.git",
685-
"rev": "master",
706+
"type": "ghtar",
707+
"repo": "alanxz/rabbitmq-c",
708+
"prefer-stable": true,
686709
"license": {
687710
"type": "file",
688711
"path": "LICENSE"
@@ -699,7 +722,7 @@
699722
"libsodium": {
700723
"type": "ghrel",
701724
"repo": "jedisct1/libsodium",
702-
"match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz",
725+
"match": "libsodium-(?!1\\.0\\.21)\\d+(\\.\\d+)*\\.tar\\.gz",
703726
"prefer-stable": true,
704727
"provide-pre-built": true,
705728
"license": {
@@ -771,17 +794,20 @@
771794
]
772795
},
773796
"libwebp": {
774-
"type": "url",
775-
"url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz",
797+
"type": "ghtagtar",
798+
"repo": "webmproject/libwebp",
799+
"match": "v1\\.\\d+\\.\\d+$",
776800
"provide-pre-built": true,
777801
"license": {
778802
"type": "file",
779803
"path": "COPYING"
780804
}
781805
},
782806
"libxml2": {
783-
"type": "url",
784-
"url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.12.5.tar.gz",
807+
"type": "ghtagtar",
808+
"repo": "GNOME/libxml2",
809+
"match": "v2\\.\\d+\\.\\d+$",
810+
"provide-pre-built": false,
785811
"license": {
786812
"type": "file",
787813
"path": "Copyright"
@@ -868,6 +894,24 @@
868894
"path": "LICENSE"
869895
}
870896
},
897+
"mysqlnd_ed25519": {
898+
"type": "pie",
899+
"repo": "mariadb/mysqlnd_ed25519",
900+
"path": "php-src/ext/mysqlnd_ed25519",
901+
"license": {
902+
"type": "file",
903+
"path": "LICENSE"
904+
}
905+
},
906+
"mysqlnd_parsec": {
907+
"type": "pie",
908+
"repo": "mariadb/mysqlnd_parsec",
909+
"path": "php-src/ext/mysqlnd_parsec",
910+
"license": {
911+
"type": "file",
912+
"path": "LICENSE"
913+
}
914+
},
871915
"ncurses": {
872916
"type": "filelist",
873917
"url": "https://ftp.gnu.org/pub/gnu/ncurses/",
@@ -1169,9 +1213,8 @@
11691213
}
11701214
},
11711215
"xdebug": {
1172-
"type": "url",
1173-
"url": "https://pecl.php.net/get/xdebug",
1174-
"filename": "xdebug.tgz",
1216+
"type": "pie",
1217+
"repo": "xdebug/xdebug",
11751218
"license": {
11761219
"type": "file",
11771220
"path": "LICENSE"

docs/en/guide/manual-build.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -549,22 +549,24 @@ otherwise it will be executed repeatedly in other events.
549549

550550
The following are the supported `patch_point` event names and corresponding locations:
551551

552-
| Event name | Event description |
553-
|------------------------------|----------------------------------------------------------------------------------------------------|
554-
| before-libs-extract | Triggered before the dependent libraries extracted |
555-
| after-libs-extract | Triggered after the compiled dependent libraries extracted |
556-
| before-php-extract | Triggered before PHP source code extracted |
557-
| after-php-extract | Triggered after PHP source code extracted |
558-
| before-micro-extract | Triggered before phpmicro extract |
559-
| after-micro-extract | Triggered after phpmicro extracted |
560-
| before-exts-extract | Triggered before the extension (to be compiled) extracted to the PHP source directory |
561-
| after-exts-extract | Triggered after the extension extracted to the PHP source directory |
562-
| before-library[*name*]-build | Triggered before the library named `name` is compiled (such as `before-library[postgresql]-build`) |
563-
| after-library[*name*]-build | Triggered after the library named `name` is compiled |
564-
| before-php-buildconf | Triggered before compiling PHP command `./buildconf` |
565-
| before-php-configure | Triggered before compiling PHP command `./configure` |
566-
| before-php-make | Triggered before compiling PHP command `make` |
567-
| before-sanity-check | Triggered after compiling PHP but before running extended checks |
552+
| Event name | Event description |
553+
|---------------------------------|----------------------------------------------------------------------------------------------------|
554+
| before-libs-extract | Triggered before the dependent libraries extracted |
555+
| after-libs-extract | Triggered after the compiled dependent libraries extracted |
556+
| before-php-extract | Triggered before PHP source code extracted |
557+
| after-php-extract | Triggered after PHP source code extracted |
558+
| before-micro-extract | Triggered before phpmicro extract |
559+
| after-micro-extract | Triggered after phpmicro extracted |
560+
| before-exts-extract | Triggered before the extension (to be compiled) extracted to the PHP source directory |
561+
| after-exts-extract | Triggered after the extension extracted to the PHP source directory |
562+
| before-library[*name*]-build | Triggered before the library named `name` is compiled (such as `before-library[postgresql]-build`) |
563+
| after-library[*name*]-build | Triggered after the library named `name` is compiled |
564+
| after-shared-ext[*name*]-build | Triggered after the shared extension named `name` is compiled |
565+
| before-shared-ext[*name*]-build | Triggered before the shared extension named `name` is compiled |
566+
| before-php-buildconf | Triggered before compiling PHP command `./buildconf` |
567+
| before-php-configure | Triggered before compiling PHP command `./configure` |
568+
| before-php-make | Triggered before compiling PHP command `make` |
569+
| before-sanity-check | Triggered after compiling PHP but before running extended checks |
568570

569571
The following is a simple example of temporarily modifying the PHP source code.
570572
Enable the CLI function to search for the `php.ini` configuration in the current working directory:

docs/zh/guide/manual-build.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ bin/spc dev:sort-config ext
500500
| after-exts-extract | 在要编译的扩展解压到 PHP 源码目录后触发 |
501501
| before-library[*name*]-build | 在名称为 `name` 的库编译前触发(如 `before-library[postgresql]-build`|
502502
| after-library[*name*]-build | 在名称为 `name` 的库编译后触发 |
503+
| after-shared-ext[*name*]-build | 在名称为 `name` 的共享扩展编译后触发(如 `after-shared-ext[redis]-build`|
504+
| before-shared-ext[*name*]-build | 在名称为 `name` 的共享扩展编译前触发 |
503505
| before-php-buildconf | 在编译 PHP 命令 `./buildconf` 前触发 |
504506
| before-php-configure | 在编译 PHP 命令 `./configure` 前触发 |
505507
| before-php-make | 在编译 PHP 命令 `make` 前触发 |

src/SPC/ConsoleApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
final class ConsoleApplication extends Application
3636
{
37-
public const string VERSION = '3.0.0-dev';
37+
public const string VERSION = '2.8.0';
3838

3939
public function __construct()
4040
{

src/SPC/builder/Extension.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ public function buildShared(array $visited = []): void
385385
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
386386
return;
387387
}
388+
if ((string) Config::getExt($this->getName(), 'type') === 'addon') {
389+
return;
390+
}
388391
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
389392
foreach ($this->dependencies as $dependency) {
390393
if (!$dependency instanceof Extension) {
@@ -395,13 +398,12 @@ public function buildShared(array $visited = []): void
395398
$dependency->buildShared([...$visited, $this->getName()]);
396399
}
397400
}
398-
if (Config::getExt($this->getName(), 'type') === 'addon') {
399-
return;
400-
}
401+
$this->builder->emitPatchPoint('before-shared-ext[' . $this->getName() . ']-build');
401402
match (PHP_OS_FAMILY) {
402403
'Darwin', 'Linux' => $this->buildUnixShared(),
403404
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
404405
};
406+
$this->builder->emitPatchPoint('after-shared-ext[' . $this->getName() . ']-build');
405407
} catch (SPCException $e) {
406408
$e->bindExtensionInfo(['extension_name' => $this->getName()]);
407409
throw $e;
@@ -452,12 +454,17 @@ public function buildUnixShared(): void
452454

453455
// process *.so file
454456
$soFile = BUILD_MODULES_PATH . '/' . $this->getName() . '.so';
457+
$soDest = $soFile;
458+
preg_match('/-release\s+(\S*)/', getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), $matches);
459+
if (!empty($matches[1])) {
460+
$soDest = str_replace('.so', '-' . $matches[1] . '.so', $soFile);
461+
}
455462
if (!file_exists($soFile)) {
456463
throw new ValidationException("extension {$this->getName()} build failed: {$soFile} not found", validation_module: "Extension {$this->getName()} build");
457464
}
458465
/** @var UnixBuilderBase $builder */
459466
$builder = $this->builder;
460-
$builder->deployBinary($soFile, $soFile, false);
467+
$builder->deployBinary($soFile, $soDest, false);
461468
}
462469

463470
/**
@@ -543,6 +550,7 @@ protected function getSharedExtensionEnv(): array
543550
'CFLAGS' => $config['cflags'],
544551
'CXXFLAGS' => $config['cflags'],
545552
'LDFLAGS' => $config['ldflags'],
553+
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
546554
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
547555
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
548556
];

0 commit comments

Comments
 (0)