Skip to content

Commit 7f35354

Browse files
ondrejmirtesclaude
andcommitted
Publish self-contained turbo binaries as the PIE release assets
PIE installs a pre-packaged binary by copying the one extension file into the extension directory (phpstan_turbo.so on Unix; on Windows the DLL named like the asset, other DLLs go next to php.exe), so the thin per-version extensions phpstan/phpstan ships since the shared core, which load phpstan_turbo_core from their own directory, cannot be PIE assets: `pie install phpstan/turbo` would install an extension that fails to load. - the turbo-compile, turbo-compile-musl-arm64 and turbo-compile-windows jobs gain a `pie` variant, built only for release tags (and on pull requests labelled turbo-pie): the same version self-contained, with a plain `make pgo` (configure --enable-phpstan-turbo on Windows), uploaded as phpstan_turbo_pie-<target>-php<minor>[-zts] - the new turbo-pie-release job packages them by PIE's asset naming (.github/scripts/turbo-pie-assets.sh) and publishes the phpstan/turbo-ext release of the tag, which the dist release.yml did from the thin binaries until now - the Windows assets carry the Visual Studio generation the leg built against, so PHP 8.6 is published as vs18 (it was named vs17, which PIE on the official vs18 builds of 8.6 never matched) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LSeeJXEA18Ma6X4qyx1xMx
1 parent 9bd33f6 commit 7f35354

2 files changed

Lines changed: 304 additions & 15 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env bash
2+
# Packages the self-contained turbo binaries of a phar.yml run (the `pie`
3+
# variant of the turbo-compile jobs) as PIE release assets for the
4+
# phpstan/turbo-ext release of <version>.
5+
#
6+
# PIE installs a pre-packaged binary by copying one file into the extension
7+
# directory — phpstan_turbo.so on Unix (UnixBuild::prePackagedBinary,
8+
# UnixInstall), the DLL named like the asset on Windows, whose other DLLs it
9+
# puts next to php.exe instead (WindowsInstall) — so the thin extension the
10+
# phpstan/phpstan dist ships, which loads the platform's core from its own
11+
# directory, cannot be one; these are built self-contained.
12+
#
13+
# An artifact phpstan_turbo_pie-<target>-php<minor>[-zts] carries
14+
# phpstan_turbo.so, or on Windows php_phpstan_turbo.dll and a `compiler`
15+
# file naming the Visual Studio generation (vs16/vs17/vs18) the official PHP
16+
# of that minor is built with — PIE matches it against the target PHP's.
17+
# Asset names follow PIE's PrePackagedBinaryAssetName and
18+
# WindowsExtensionAssetName (matched lowercase):
19+
# php_phpstan_turbo-<version>_php<minor>-<arch>-<linux|darwin>-<glibc|musl|bsdlibc>[-zts].zip
20+
# php_phpstan_turbo-<version>-<minor>-<ts|nts>-<vs>-x86_64.zip (with the same-named .dll)
21+
#
22+
# Usage: turbo-pie-assets.sh <artifacts directory> <version> <output directory>
23+
set -euo pipefail
24+
25+
artifacts=$1
26+
version=$2
27+
out=$3
28+
29+
mkdir -p "$out"
30+
work="$(mktemp -d)"
31+
trap 'rm -rf "$work"' EXIT
32+
status=0
33+
packaged=0
34+
found=0
35+
36+
for dir in "$artifacts"/phpstan_turbo_pie-*; do
37+
[ -d "$dir" ] || continue
38+
found=$((found + 1))
39+
name="${dir#"$artifacts"/phpstan_turbo_pie-}"
40+
target="${name%-php*}"
41+
ver="${name##*-php}"
42+
minor="${ver%-zts}"
43+
zts=""
44+
if [ "$ver" != "$minor" ]; then
45+
zts="-zts"
46+
fi
47+
48+
case "$target" in
49+
linux-gnu-* | linux-musl-* | macos-arm64)
50+
case "$target" in
51+
linux-gnu-*) os=linux; libc=glibc; arch="${target#linux-gnu-}" ;;
52+
linux-musl-*) os=linux; libc=musl; arch="${target#linux-musl-}" ;;
53+
*) os=darwin; libc=bsdlibc; arch=arm64 ;;
54+
esac
55+
if [ ! -f "$dir/phpstan_turbo.so" ]; then
56+
echo "::error::$dir carries no phpstan_turbo.so" >&2
57+
status=1
58+
continue
59+
fi
60+
asset="php_phpstan_turbo-${version}_php${minor}-${arch}-${os}-${libc}${zts}"
61+
rm -rf "${work:?}"/*
62+
cp "$dir/phpstan_turbo.so" "$work/phpstan_turbo.so"
63+
(cd "$work" && zip -q -X "$asset.zip" phpstan_turbo.so)
64+
;;
65+
windows-x86_64)
66+
if [ ! -f "$dir/php_phpstan_turbo.dll" ] || [ ! -f "$dir/compiler" ]; then
67+
echo "::error::$dir carries no php_phpstan_turbo.dll and compiler file" >&2
68+
status=1
69+
continue
70+
fi
71+
vs="$(tr -d '[:space:]' < "$dir/compiler")"
72+
case "$vs" in
73+
vs16 | vs17 | vs18) ;;
74+
*)
75+
echo "::error::$dir names an unknown compiler: $vs" >&2
76+
status=1
77+
continue
78+
;;
79+
esac
80+
ts=nts
81+
if [ -n "$zts" ]; then
82+
ts=ts
83+
fi
84+
asset="php_phpstan_turbo-${version}-${minor}-${ts}-${vs}-x86_64"
85+
rm -rf "${work:?}"/*
86+
cp "$dir/php_phpstan_turbo.dll" "$work/$asset.dll"
87+
(cd "$work" && zip -q -X "$asset.zip" "$asset.dll")
88+
;;
89+
*)
90+
echo "::error::$dir is for an unknown target: $target" >&2
91+
status=1
92+
continue
93+
;;
94+
esac
95+
96+
if [ -e "$out/$asset.zip" ]; then
97+
echo "::error::two artifacts map onto $asset.zip" >&2
98+
status=1
99+
continue
100+
fi
101+
mv "$work/$asset.zip" "$out/$asset.zip"
102+
echo "$name -> $asset.zip"
103+
packaged=$((packaged + 1))
104+
done
105+
106+
if [ "$found" -eq 0 ]; then
107+
echo "::error::no phpstan_turbo_pie-* artifacts found in $artifacts" >&2
108+
status=1
109+
fi
110+
if [ "$packaged" -ne "$found" ]; then
111+
echo "::error::packaged $packaged assets from $found artifacts" >&2
112+
status=1
113+
fi
114+
115+
exit "$status"

0 commit comments

Comments
 (0)