Skip to content

Commit ec39905

Browse files
authored
[3.0] Refactor windows extensions (#1073)
2 parents d2c7fee + ae7552f commit ec39905

138 files changed

Lines changed: 2595 additions & 524 deletions

File tree

Some content is hidden

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

.github/workflows/build-unix.yml

Lines changed: 77 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,19 @@ 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+
fi
185+
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=$ALL_EXTS --ignore-cache-sources=php-src"
186+
BUILD_CMD="$BUILD_CMD $STATIC_EXTS"
187+
if [ -n "$SHARED_EXTS" ]; then
188+
BUILD_CMD="$BUILD_CMD --build-shared=$SHARED_EXTS"
189+
fi
157190
if [ -n "${{ inputs.extra-libs }}" ]; then
158191
DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
159192
BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
@@ -177,6 +210,12 @@ jobs:
177210
if [ ${{ inputs.build-fpm }} == true ]; then
178211
BUILD_CMD="$BUILD_CMD --build-fpm"
179212
fi
213+
if [ "$BUILD_FRANKENPHP" = "true" ]; then
214+
BUILD_CMD="$BUILD_CMD --build-frankenphp"
215+
fi
216+
if [ "$ENABLE_ZTS" = "true" ]; then
217+
BUILD_CMD="$BUILD_CMD --enable-zts"
218+
fi
180219
echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
181220
echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
182221
echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
@@ -199,6 +238,27 @@ jobs:
199238
env:
200239
phpts: nts
201240

241+
- if: ${{ inputs['build-frankenphp'] == true }}
242+
name: "Install go-xcaddy for FrankenPHP"
243+
run: |
244+
case "${{ inputs.os }}" in
245+
linux-x86_64|linux-aarch64)
246+
./bin/spc-alpine-docker install-pkg go-xcaddy
247+
;;
248+
linux-x86_64-glibc|linux-aarch64-glibc)
249+
./bin/spc-gnu-docker install-pkg go-xcaddy
250+
;;
251+
macos-x86_64|macos-aarch64)
252+
composer update --no-dev --classmap-authoritative
253+
./bin/spc doctor --auto-fix
254+
./bin/spc install-pkg go-xcaddy
255+
;;
256+
*)
257+
echo "Unsupported OS for go-xcaddy install: ${{ inputs.os }}"
258+
exit 1
259+
;;
260+
esac
261+
202262
# Cache downloaded source
203263
- id: cache-download
204264
uses: actions/cache@v4
@@ -245,7 +305,22 @@ jobs:
245305
name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
246306
path: buildroot/bin/php-fpm
247307

308+
# Upload frankenphp executable
309+
- if: ${{ inputs['build-frankenphp'] == true }}
310+
name: "Upload FrankenPHP SAPI"
311+
uses: actions/upload-artifact@v4
312+
with:
313+
name: php-frankenphp-${{ inputs.php-version }}-${{ inputs.os }}
314+
path: buildroot/bin/frankenphp
315+
248316
# Upload extensions metadata
317+
- if: ${{ inputs['shared-extensions'] != '' }}
318+
name: "Upload shared extensions"
319+
uses: actions/upload-artifact@v4
320+
with:
321+
name: php-shared-ext-${{ inputs.php-version }}-${{ inputs.os }}
322+
path: |
323+
buildroot/modules/*.so
249324
- uses: actions/upload-artifact@v4
250325
name: "Upload License Files"
251326
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ spc.exe
6767

6868
# dumped files from StaticPHP v3
6969
/dump-*.json
70+
71+
# config parse cache
72+
/.spc.cache.php

TODO.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# v3 TODO List
2+
3+
Tracking items identified during the v2 → v3 migration audit.
4+
5+
---
6+
7+
## Commands
8+
9+
- [ ] Implement `craft` command (drives full build from `craft.yml`; should be easier with v3 vendor/registry mode)
10+
- [x] Migrate `micro:combine` command (combine `micro.sfx` with PHP code + INI injection)
11+
- [ ] Implement `dump-extensions` command (extract required extensions from `composer.json` / `composer.lock`)
12+
- [ ] Design and implement v3 dev toolchain commands (WIP — needs design decision):
13+
- [ ] `dev:extensions` / equivalent listing command
14+
- [ ] `dev:php-version`, `dev:ext-version`, `dev:lib-version`
15+
- [ ] Doc generation commands (`dev:gen-ext-docs`, `dev:gen-ext-dep-docs`, `dev:gen-lib-dep-docs`) — pending v3 doc design
16+
17+
---
18+
19+
## Source Patches (SourcePatcher → Artifact migration)
20+
21+
The following v2 `SourcePatcher` hooks are not yet migrated to v3 `src/Package/Artifact/` classes:
22+
23+
- [ ] Migrate `patchSQLSRVWin32` — removes `/sdl` compile flag to prevent Zend build failure on Windows
24+
- [ ] Migrate `patchSQLSRVPhp85` — fixes `pdo_sqlsrv` directory layout for PHP 8.5
25+
- [ ] Migrate `patchYamlWin32` — patches `config.w32` `_a.lib` detection logic for the `yaml` extension
26+
- [ ] Migrate `patchImagickWith84` — applies PHP 8.4 compatibility patch for `imagick` based on version detection
27+
28+
---
29+
30+
## Extension Package Classes (Unix)
31+
32+
Extensions that had non-trivial v2 build logic and are missing a v3 `src/Package/Extension/` class:
33+
34+
- [x] `gettext` — macOS: fix `config.m4` bracket syntax for cross-version compatibility + append frameworks to linker flags (critical for macOS linking; this is a Unix-side gap, not Windows-only)
35+
36+
---
37+
38+
## Windows Extensions (Early Stage)
39+
40+
Windows extension support is still in early stage. The following extensions had Windows-specific configure args or patches in v2 and are pending v3 Windows implementation:
41+
42+
- [ ] `amqp` — Windows configure args
43+
- [ ] `com_dotnet` — Windows-only extension
44+
- [ ] `dom` — remove `dllmain.c` from `config.w32`
45+
- [ ] `ev` — fix `PHP_EV_SHARED` in `config.w32`
46+
- [ ] `gmssl` — add `CHECK_LIB("gmssl.lib")` to `config.w32`
47+
- [ ] `intl` — fix `PHP_INTL_SHARED` in `config.w32`
48+
- [ ] `lz4` — Windows configure args
49+
- [ ] `mbregex` — Windows configure args
50+
- [ ] `sqlsrv` / `pdo_sqlsrv` — complex conditional build logic (independent `sqlsrv` without `pdo_sqlsrv`)
51+
- [ ] `xml` — remove `dllmain.c` from `config.w32`; handles `soap`, `xmlreader`, `xmlwriter`, `simplexml`
52+
53+
---
54+
55+
## Documentation
56+
57+
- [ ] Write v3 user documentation (currently zero v3 docs)

bin/spc-debug

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#!/usr/bin/env bash
22

3+
# Use SPC_XDEBUG=profile to enable Xdebug profiling mode, which will generate profiling files in /tmp.
4+
# Otherwise, it will enable Xdebug debugging mode, which allows you to connect a debugger to port 9003.
5+
if [ "$SPC_XDEBUG" = "profile" ]; then
6+
XDEBUG_PREFIX="-d xdebug.mode=profile -d xdebug.start_with_request=yes -d xdebug.output_dir=/tmp -d xdebug.output_name=spc-profile.%t.%p.%r"
7+
else
8+
XDEBUG_PREFIX="-d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes"
9+
fi
10+
311
# This script runs the 'spc' command with Xdebug enabled for debugging purposes.
4-
php -d xdebug.mode=debug -d xdebug.client_host=127.0.0.1 -d xdebug.client_port=9003 -d xdebug.start_with_request=yes "$(dirname "$0")/../bin/spc" "$@"
12+
php $XDEBUG_PREFIX "$(dirname "$0")/../bin/spc" "$@"

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"scripts": {
5050
"analyse": "phpstan analyse --memory-limit 300M",
5151
"cs-fix": "php-cs-fixer fix",
52-
"lint-config": "bin/spc dev:lint-config",
52+
"lint-config": "php bin/spc dev:lint-config",
5353
"test": "vendor/bin/phpunit tests/ --no-coverage",
5454
"build:phar": "vendor/bin/box compile"
5555
},
@@ -63,6 +63,9 @@
6363
"optimize-autoloader": true,
6464
"sort-packages": true
6565
},
66+
"suggest": {
67+
"ext-yaml": "Speeds up YAML config file parsing"
68+
},
6669
"funding": [
6770
{
6871
"type": "other",

0 commit comments

Comments
 (0)