Skip to content

Commit fe2440a

Browse files
ondrejmirtesclaude
andcommitted
Ship the turbo extension as a shared core plus a thin extension per PHP version
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LSeeJXEA18Ma6X4qyx1xMx
2 parents 2b9c4ff + be7f5bc commit fe2440a

86 files changed

Lines changed: 2843 additions & 811 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.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# Shared by the Windows turbo jobs in phar.yml: exports the extension version
3+
# (the short SHA of the last commit touching turbo-ext/src, the Makefile's
4+
# computation) and fetches the php-devel-pack matching the installed PHP
5+
# (MATRIX_TS: nts/zts, MATRIX_VS: its toolset infix) into C:\php-devel and the
6+
# php-sdk-binary-tools at PHP_SDK_COMMIT into C:\php-sdk.
7+
set -euo pipefail
8+
9+
SHA=$(git log -1 --format=%H -- turbo-ext/src | cut -c1-7)
10+
echo "extension version: $SHA"
11+
echo "PHPSTANTURBO_VERSION=$SHA" >> "$GITHUB_ENV"
12+
13+
FULL=$(php -r 'echo PHP_VERSION;')
14+
# thread-safe devel packs carry no infix, NTS ones carry -nts
15+
INFIX=$([ "$MATRIX_TS" = "zts" ] && echo "" || echo "-nts")
16+
PACK="php-devel-pack-$FULL$INFIX-Win32-$MATRIX_VS-x64.zip"
17+
echo "devel pack: $PACK"
18+
curl -fsSLo devel-pack.zip "https://windows.php.net/downloads/releases/$PACK" \
19+
|| curl -fsSLo devel-pack.zip "https://windows.php.net/downloads/releases/archives/$PACK" \
20+
|| curl -fsSLo devel-pack.zip "https://downloads.php.net/~windows/qa/$PACK" \
21+
|| curl -fsSLo devel-pack.zip "https://downloads.php.net/~windows/qa/archives/$PACK"
22+
unzip -q devel-pack.zip -d /c/php-devel
23+
24+
git clone -q https://github.com/php/php-sdk-binary-tools.git /c/php-sdk
25+
git -C /c/php-sdk checkout -q "$PHP_SDK_COMMIT"

‎.github/scripts/find-turbo-origins.sh‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/usr/bin/env bash
2-
# Finds, for every turbo extension binary the compile jobs in phar.yml
3-
# produce, the newest earlier run on $BRANCH that compiled it from build
4-
# inputs identical to HEAD's, and writes {"<artifact name>": <run id>} to
5-
# the `origins` step output. A compile leg whose artifact is listed
6-
# downloads it from that run instead of building it again (see the
7-
# turbo-origins job in phar.yml).
2+
# Finds, for every shared core the turbo-compile-core jobs in phar.yml
3+
# produce (phpstan_turbo_core-<platform>), the newest earlier run on $BRANCH
4+
# that compiled it from build inputs identical to HEAD's, and writes
5+
# {"<artifact name>": <run id>} to the `origins` step output. A core leg
6+
# whose artifact is listed downloads it from that run instead of building
7+
# (and profiling) it again (see the turbo-origins job in phar.yml). The
8+
# per-PHP-version extensions are not reused: they compile in a minute,
9+
# against whichever core this run carries.
810
#
911
# The search walks HEAD's first-parent history (on a pull request's merge
1012
# commit, the base branch) and asks the API for the runs of each commit
@@ -45,11 +47,12 @@ BUILD_INPUT_PATHS=(
4547
.github/turbo-build
4648
.github/scripts/install-alpine-php.sh
4749
.github/scripts/install-php86-windows.sh
50+
.github/scripts/download-php-windows-devel.sh
4851
)
4952
WORKFLOW_PATH=".github/workflows/phar.yml"
50-
# Workflow-level env and the three compile jobs, as JSON: comment-only edits
51-
# do not change it.
52-
COMPILE_JOBS_QUERY='[.env, .jobs["turbo-compile"], .jobs["turbo-compile-musl-arm64"], .jobs["turbo-compile-windows"]]'
53+
# Workflow-level env and the three core compile jobs, as JSON: comment-only
54+
# edits do not change it.
55+
COMPILE_JOBS_QUERY='[.env, .jobs["turbo-compile-core"], .jobs["turbo-compile-core-musl-arm64"], .jobs["turbo-compile-core-windows"]]'
5356
# Commits whose runs are looked up through the API, newest first. The
5457
# commits git alone rules out do not count.
5558
COMMITS_LIMIT=50
@@ -123,7 +126,7 @@ while read -r sha; do
123126
fi
124127
if ! origins="$(jq -c --argjson run "$run_id" --arg artifacts "$artifacts" '
125128
($artifacts | split("\n")) as $names
126-
| reduce ($names[] | select(startswith("phpstan_turbo-"))) as $name (.;
129+
| reduce ($names[] | select(startswith("phpstan_turbo_core-"))) as $name (.;
127130
if has($name) or ($names | any(. == "turbo-reused-" + $name)) then . else .[$name] = $run end)
128131
' <<< "$origins")"; then
129132
origins='{}'
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
# Maps the turbo compile artifacts of a phar.yml run onto the layout
3+
# phpstan/phpstan ships (turbo-ext/<target>/...), printing one
4+
# "<artifact file><TAB><path under turbo-ext/>" line per distributed file.
5+
#
6+
# An artifact phpstan_turbo-<target>-php<minor>[-zts] carries the extension
7+
# of that PHP version (phpstan_turbo.so, php_phpstan_turbo.dll) and the
8+
# platform's shared core next to it (phpstan_turbo_core*.so/.dll), which the
9+
# extension loads from its own directory:
10+
# extension -> <target>/phpstan_turbo-<minor>[-zts].<so|dll>
11+
# core -> <target>/<its own name>
12+
# Every leg of a platform links against the one core turbo-compile-core
13+
# built for it, so each of its artifacts carries the same core: it is listed
14+
# once, and different bytes under one name fail the mapping — such a set
15+
# would ship extensions next to a core they were not linked against.
16+
#
17+
# Usage: turbo-dist-layout.sh <artifacts directory>
18+
set -euo pipefail
19+
20+
artifacts=$1
21+
declare -A core_source=()
22+
status=0
23+
mapped=0
24+
25+
for dir in "$artifacts"/phpstan_turbo-*; do
26+
[ -d "$dir" ] || continue
27+
name="${dir#"$artifacts"/phpstan_turbo-}"
28+
target="${name%-php*}"
29+
minor="${name##*-php}"
30+
for file in "$dir"/*; do
31+
[ -f "$file" ] || continue
32+
base="${file##*/}"
33+
case "$base" in
34+
phpstan_turbo_core*)
35+
dest="$target/$base"
36+
if [ -n "${core_source[$dest]:-}" ]; then
37+
if ! cmp -s "${core_source[$dest]}" "$file"; then
38+
echo "::error::$file and ${core_source[$dest]} carry different cores for $dest" >&2
39+
status=1
40+
fi
41+
continue
42+
fi
43+
core_source[$dest]="$file"
44+
;;
45+
*)
46+
dest="$target/phpstan_turbo-$minor.${base##*.}"
47+
;;
48+
esac
49+
printf '%s\t%s\n' "$file" "$dest"
50+
mapped=$((mapped + 1))
51+
done
52+
done
53+
54+
if [ "$mapped" -eq 0 ]; then
55+
echo "::error::no phpstan_turbo-* artifacts found in $artifacts" >&2
56+
status=1
57+
fi
58+
59+
exit "$status"

0 commit comments

Comments
 (0)