Skip to content

Commit 0a1019c

Browse files
committed
Add shared-exts, frankenphp and zts to build-unix
1 parent 4625c6a commit 0a1019c

3 files changed

Lines changed: 94 additions & 6 deletions

File tree

.github/workflows/build-unix.yml

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ on:
2929
description: Extensions to build (comma separated)
3030
required: true
3131
type: string
32+
shared-extensions:
33+
description: Shared extensions to build (optional, comma separated)
34+
type: string
3235
extra-libs:
3336
description: Extra libraries to build (optional, comma separated)
3437
type: string
@@ -42,6 +45,14 @@ on:
4245
build-fpm:
4346
description: Build fpm binary
4447
type: boolean
48+
build-frankenphp:
49+
description: Build frankenphp binary (requires ZTS)
50+
type: boolean
51+
default: false
52+
enable-zts:
53+
description: Enable ZTS
54+
type: boolean
55+
default: false
4556
prefer-pre-built:
4657
description: Prefer pre-built binaries (reduce build time)
4758
type: boolean
@@ -73,6 +84,9 @@ on:
7384
description: Extensions to build (comma separated)
7485
required: true
7586
type: string
87+
shared-extensions:
88+
description: Shared extensions to build (optional, comma separated)
89+
type: string
7690
extra-libs:
7791
description: Extra libraries to build (optional, comma separated)
7892
type: string
@@ -86,6 +100,14 @@ on:
86100
build-fpm:
87101
description: Build fpm binary
88102
type: boolean
103+
build-frankenphp:
104+
description: Build frankenphp binary (requires ZTS)
105+
type: boolean
106+
default: false
107+
enable-zts:
108+
description: Enable ZTS
109+
type: boolean
110+
default: false
89111
prefer-pre-built:
90112
description: Prefer pre-built binaries (reduce build time)
91113
type: boolean
@@ -152,8 +174,29 @@ jobs:
152174
RUNS_ON="macos-15"
153175
;;
154176
esac
155-
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"
156-
BUILD_CMD="$BUILD_CMD ${{ inputs.extensions }}"
177+
STATIC_EXTS="${{ inputs.extensions }}"
178+
SHARED_EXTS="${{ inputs['shared-extensions'] }}"
179+
BUILD_FRANKENPHP="${{ inputs['build-frankenphp'] }}"
180+
ENABLE_ZTS="${{ inputs['enable-zts'] }}"
181+
ALL_EXTS="$STATIC_EXTS"
182+
if [ -n "$SHARED_EXTS" ]; then
183+
ALL_EXTS="$ALL_EXTS,$SHARED_EXTS"
184+
case "${{ inputs.os }}" in
185+
linux-x86_64|linux-aarch64)
186+
echo "Shared extensions (e.g. xdebug) require glibc/macOS targets. Use linux-*-glibc or macos-*."
187+
exit 1
188+
;;
189+
esac
190+
fi
191+
if [ "$BUILD_FRANKENPHP" = "true" ] && [ "$ENABLE_ZTS" != "true" ]; then
192+
echo "FrankenPHP build requires ZTS. Set enable-zts=true."
193+
exit 1
194+
fi
195+
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=$ALL_EXTS --ignore-cache-sources=php-src"
196+
BUILD_CMD="$BUILD_CMD $STATIC_EXTS"
197+
if [ -n "$SHARED_EXTS" ]; then
198+
BUILD_CMD="$BUILD_CMD --build-shared=$SHARED_EXTS"
199+
fi
157200
if [ -n "${{ inputs.extra-libs }}" ]; then
158201
DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
159202
BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
@@ -177,6 +220,12 @@ jobs:
177220
if [ ${{ inputs.build-fpm }} == true ]; then
178221
BUILD_CMD="$BUILD_CMD --build-fpm"
179222
fi
223+
if [ "$BUILD_FRANKENPHP" = "true" ]; then
224+
BUILD_CMD="$BUILD_CMD --build-frankenphp"
225+
fi
226+
if [ "$ENABLE_ZTS" = "true" ]; then
227+
BUILD_CMD="$BUILD_CMD --enable-zts"
228+
fi
180229
echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
181230
echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
182231
echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
@@ -199,6 +248,27 @@ jobs:
199248
env:
200249
phpts: nts
201250

251+
- if: ${{ inputs['build-frankenphp'] == true }}
252+
name: "Install go-xcaddy for FrankenPHP"
253+
run: |
254+
case "${{ inputs.os }}" in
255+
linux-x86_64|linux-aarch64)
256+
./bin/spc-alpine-docker install-pkg go-xcaddy
257+
;;
258+
linux-x86_64-glibc|linux-aarch64-glibc)
259+
./bin/spc-gnu-docker install-pkg go-xcaddy
260+
;;
261+
macos-x86_64|macos-aarch64)
262+
composer update --no-dev --classmap-authoritative
263+
./bin/spc doctor --auto-fix
264+
./bin/spc install-pkg go-xcaddy
265+
;;
266+
*)
267+
echo "Unsupported OS for go-xcaddy install: ${{ inputs.os }}"
268+
exit 1
269+
;;
270+
esac
271+
202272
# Cache downloaded source
203273
- id: cache-download
204274
uses: actions/cache@v4
@@ -245,7 +315,23 @@ jobs:
245315
name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
246316
path: buildroot/bin/php-fpm
247317

318+
# Upload frankenphp executable
319+
- if: ${{ inputs['build-frankenphp'] == true }}
320+
name: "Upload FrankenPHP SAPI"
321+
uses: actions/upload-artifact@v4
322+
with:
323+
name: php-frankenphp-${{ inputs.php-version }}-${{ inputs.os }}
324+
path: buildroot/bin/frankenphp
325+
248326
# Upload extensions metadata
327+
- if: ${{ inputs['shared-extensions'] != '' }}
328+
name: "Upload shared extensions"
329+
uses: actions/upload-artifact@v4
330+
with:
331+
name: php-shared-ext-${{ inputs.php-version }}-${{ inputs.os }}
332+
path: |
333+
buildroot/modules/*.so
334+
buildroot/modules/*.dylib
249335
- uses: actions/upload-artifact@v4
250336
name: "Upload License Files"
251337
with:

docs/en/guide/action-build.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ while also defining the extensions to compile.
1616

1717
1. Fork project.
1818
2. Go to the Actions of the project and select `CI`.
19-
3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of extensions. (extensions comma separated, e.g. `bcmath,curl,mbstring`)
20-
4. After waiting for about a period of time, enter the corresponding task and get `Artifacts`.
19+
3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of static extensions. (comma separated, e.g. `bcmath,curl,mbstring`)
20+
4. If you need shared extensions (for example `xdebug`), set `shared-extensions` (comma separated, e.g. `xdebug`).
21+
5. If you need FrankenPHP, enable `build-frankenphp` and also enable `enable-zts`.
22+
6. After waiting for about a period of time, enter the corresponding task and get `Artifacts`.
2123

2224
If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting.
2325

src/SPC/builder/Extension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public function buildUnixShared(): void
456456
// process *.so file
457457
$soFile = BUILD_MODULES_PATH . '/' . $this->getName() . '.so';
458458
$soDest = $soFile;
459-
preg_match('/-release\s+(\S*)/', getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), $matches);
459+
preg_match('/-release\s+(\S*)/', getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: '', $matches);
460460
if (!empty($matches[1])) {
461461
$soDest = str_replace('.so', '-' . $matches[1] . '.so', $soFile);
462462
}
@@ -551,7 +551,7 @@ protected function getSharedExtensionEnv(): array
551551
'CFLAGS' => $config['cflags'],
552552
'CXXFLAGS' => $config['cflags'],
553553
'LDFLAGS' => $config['ldflags'],
554-
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
554+
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: '',
555555
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
556556
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
557557
];

0 commit comments

Comments
 (0)