Skip to content

Commit 6e5637e

Browse files
ondrejmirtesclaude
andcommitted
Windows build spike for the turbo extension
config.w32 for the php-devel-pack phpize/configure/nmake flow (version baked from the PHPSTANTURBO_VERSION environment variable) and a temporary branch-only workflow running the build plus the differential battery on windows-latest. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013j6ePxd1BobZkr8YVLnNet
1 parent c81d12a commit 6e5637e

2 files changed

Lines changed: 125 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Temporary iteration workflow for the Windows turbo extension build.
2+
# Runs alone on pushes to the turbo-windows branch; folded into phar.yml
3+
# (and this file deleted) once the build and the differential tests are
4+
# green on windows-latest.
5+
6+
name: "Turbo Windows Spike"
7+
8+
permissions:
9+
contents: read
10+
11+
on:
12+
push:
13+
branches:
14+
- "turbo-windows"
15+
16+
jobs:
17+
windows:
18+
name: "Windows PHP ${{ matrix.php-version }}"
19+
runs-on: "windows-latest"
20+
timeout-minutes: 40
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
php-version: ["8.4", "8.5"]
26+
27+
steps:
28+
- name: "Checkout"
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30+
with:
31+
persist-credentials: false
32+
# full history: the extension version is baked from git log over
33+
# the watched paths
34+
fetch-depth: 0
35+
36+
- name: "Install PHP"
37+
uses: "shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240" # v2.37.2
38+
with:
39+
coverage: "none"
40+
php-version: "${{ matrix.php-version }}"
41+
42+
- name: "Compute extension version and devel-pack URL"
43+
id: meta
44+
shell: bash
45+
run: |
46+
MAPPED_PHP=$(php -n -r 'echo implode(" ", array_map(static fn ($e) => $e["php"], array_filter(json_decode(file_get_contents("turbo-ext/shadowed-classes.json"), true), static fn ($e) => !($e["vendored"] ?? false))));')
47+
SHA=$(git log -1 --format=%H -- turbo-ext/src $MAPPED_PHP | cut -c1-7)
48+
echo "PHPSTANTURBO_VERSION=$SHA" >> "$GITHUB_ENV"
49+
FULL=$(php -r 'echo PHP_VERSION;')
50+
echo "php full version: $FULL, extension version: $SHA"
51+
echo "devel-pack=php-devel-pack-$FULL-nts-Win32-vs17-x64.zip" >> "$GITHUB_OUTPUT"
52+
53+
- name: "Download PHP devel pack"
54+
shell: bash
55+
run: |
56+
PACK="${{ steps.meta.outputs.devel-pack }}"
57+
curl -fsSLo devel-pack.zip "https://windows.php.net/downloads/releases/$PACK" \
58+
|| curl -fsSLo devel-pack.zip "https://windows.php.net/downloads/releases/archives/$PACK"
59+
unzip -q devel-pack.zip -d /c/php-devel
60+
ls /c/php-devel
61+
62+
- name: "Set up MSVC environment"
63+
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
64+
with:
65+
arch: x64
66+
67+
- name: "Build the extension"
68+
shell: cmd
69+
working-directory: turbo-ext
70+
run: |
71+
for /d %%d in (C:\php-devel\php-*-devel-*) do set DEVEL=%%d
72+
set PATH=%DEVEL%;%PATH%
73+
call phpize.bat
74+
call configure.bat --enable-phpstan-turbo
75+
nmake
76+
77+
- name: "Verify the built extension reports the expected version"
78+
shell: bash
79+
run: |
80+
DLL=$(ls turbo-ext/x64/Release*/php_phpstan_turbo.dll | head -1)
81+
echo "built: $DLL"
82+
REPORTED="$(php -d extension="$(cygpath -w "$PWD/$DLL")" -r 'echo phpversion("phpstan_turbo");')"
83+
EXPECTED="$(sed -n "s/.*EXPECTED_EXTENSION_VERSION = '\([^']*\)'.*/\1/p" src/Turbo/TurboExtensionEnabler.php)"
84+
echo "built extension reports: $REPORTED, enabler expects: $EXPECTED"
85+
[ "$REPORTED" = "$EXPECTED" ]
86+
echo "TURBO_DLL=$(cygpath -w "$PWD/$DLL")" >> "$GITHUB_ENV"
87+
88+
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0
89+
90+
- name: "Smoke test (differential: native vs PHP implementations)"
91+
shell: bash
92+
run: php -d extension="$TURBO_DLL" turbo-ext/tests/smoke.php
93+
94+
- name: "Signature parity (reflect native classes against the PHP twins)"
95+
shell: bash
96+
run: php -d extension="$TURBO_DLL" turbo-ext/tests/signature-parity.php
97+
98+
- name: "Parser corpus (differential: native vs PHP ASTs must be byte-identical)"
99+
shell: bash
100+
run: php -d extension="$TURBO_DLL" -d memory_limit=4G turbo-ext/tests/parser-corpus.php

‎turbo-ext/config.w32‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// phpstan_turbo — Windows build (php-devel-pack: phpize && configure && nmake).
2+
// The extension version is baked from the PHPSTANTURBO_VERSION environment
3+
// variable at configure time (the CI workflow computes it the same way the
4+
// Makefile does); it defaults to "dev", which the enabler rejects.
5+
6+
ARG_ENABLE("phpstan-turbo", "phpstan turbo extension", "no");
7+
8+
if (PHP_PHPSTAN_TURBO != "no") {
9+
var version = WScript.CreateObject("WScript.Shell").Environment("PROCESS")("PHPSTANTURBO_VERSION");
10+
if (!version || version == "") {
11+
version = "dev";
12+
}
13+
14+
// /EHsc: the C++ standard library assumes unwinding; /bigobj: the
15+
// generated parser action files exceed the default section limit.
16+
var flags = "/std:c++17 /EHsc /bigobj /DPHPSTANTURBO_VERSION=\\\"" + version + "\\\"";
17+
18+
EXTENSION("phpstan_turbo",
19+
"src/main.cpp src/support.cpp src/CombinationsHelper.cpp src/ConditionalExpressionHolder.cpp src/ExpressionTypeHolder.cpp src/NodeScanner.cpp src/NodeTraverser.cpp src/ScopeOps.cpp src/TrinaryLogic.cpp src/TypeCombinatorCache.cpp",
20+
true,
21+
flags);
22+
ADD_SOURCES(configure_module_dirname + "/src/parser",
23+
"ParserRunner.cpp ParserRunnerActions1.cpp ParserRunnerActions2.cpp ParserRunnerActions3.cpp ParserRunnerHelpers.cpp",
24+
"phpstan_turbo");
25+
}

0 commit comments

Comments
 (0)