@@ -3,6 +3,8 @@ name: ci-windows
33# Windows validation CI for mcpp.
44# Step 1: Verify xlings LLVM toolchain capabilities on Windows.
55# Step 2: xmake bootstrap to produce first mcpp.exe.
6+ # Step 3: Self-host — use the bootstrapped mcpp.exe to build itself.
7+ # Step 4: Package into a distributable zip (same layout as Linux/macOS).
68
79on :
810 push :
2426 windows-llvm-validation :
2527 name : Windows x64 — LLVM toolchain validation
2628 runs-on : windows-latest
27- timeout-minutes : 30
29+ timeout-minutes : 45
2830 steps :
2931 - uses : actions/checkout@v4
3032
@@ -190,7 +192,8 @@ jobs:
190192 xlings.exe install xmake -y || xlings install xmake -y
191193 xmake.exe --version || xmake --version
192194
193- - name : Build mcpp with xmake (MSVC)
195+ - name : Bootstrap mcpp with xmake (MSVC)
196+ id : bootstrap
194197 shell : pwsh
195198 run : |
196199 # Generate xmake.lua for bootstrap
@@ -222,8 +225,117 @@ jobs:
222225 if ($mcpp) {
223226 Write-Host ":: mcpp.exe built at: $($mcpp.FullName)"
224227 & $mcpp.FullName --version
228+ # Export for subsequent steps
229+ "MCPP_BOOTSTRAP=$($mcpp.FullName)" | Out-File -Append $env:GITHUB_ENV
225230 } else {
226231 Write-Host ":: Build produced files:"
227232 Get-ChildItem -Recurse build -Filter *.exe | ForEach-Object { Write-Host " $($_.FullName)" }
228233 exit 1
229234 }
235+
236+ - name : Self-host — mcpp builds itself
237+ shell : bash
238+ run : |
239+ echo "=== Self-host: using bootstrapped mcpp.exe to build mcpp ==="
240+ # Clean xmake artifacts so mcpp starts fresh
241+ rm -rf build xmake.lua .xmake
242+
243+ MCPP_EXE="$MCPP_BOOTSTRAP"
244+ echo "Bootstrap binary: $MCPP_EXE"
245+ "$MCPP_EXE" --version
246+
247+ # mcpp build uses its own build system (not xmake)
248+ export MCPP_VENDORED_XLINGS="$USERPROFILE/.xlings/subos/default/bin/xlings.exe"
249+ "$MCPP_EXE" build
250+
251+ # Find the self-hosted binary
252+ SELF_MCPP=$(find target -name "mcpp.exe" -path "*/bin/*" | head -1)
253+ test -n "$SELF_MCPP" || {
254+ echo "FAIL: self-host build did not produce mcpp.exe"
255+ find target -name "*.exe" 2>/dev/null
256+ exit 1
257+ }
258+ SELF_MCPP=$(cd "$(dirname "$SELF_MCPP")" && pwd)/$(basename "$SELF_MCPP")
259+ echo "Self-hosted binary: $SELF_MCPP"
260+ "$SELF_MCPP" --version
261+
262+ echo "MCPP_SELF=$SELF_MCPP" >> "$GITHUB_ENV"
263+
264+ - name : Package Windows release zip
265+ id : package
266+ shell : bash
267+ run : |
268+ VERSION=$(awk -F '"' '/^version[[:space:]]*=/{print $2; exit}' mcpp.toml)
269+ PLAT="windows-x86_64"
270+ WRAPPER="mcpp-${VERSION}-${PLAT}"
271+ ZIPNAME="${WRAPPER}.zip"
272+
273+ echo "Packaging $ZIPNAME ..."
274+
275+ STAGING=$(mktemp -d)
276+ mkdir -p "$STAGING/$WRAPPER/bin"
277+ mkdir -p "$STAGING/$WRAPPER/registry/bin"
278+
279+ # Binary
280+ cp "$MCPP_SELF" "$STAGING/$WRAPPER/bin/mcpp.exe"
281+
282+ # Launcher batch script (equivalent to the shell wrapper on Linux/macOS)
283+ printf '@echo off\r\n"%%~dp0bin\\mcpp.exe" %%*\r\n' > "$STAGING/$WRAPPER/mcpp.bat"
284+
285+ # Metadata
286+ cp README.md "$STAGING/$WRAPPER/" 2>/dev/null || true
287+ cp LICENSE "$STAGING/$WRAPPER/" 2>/dev/null || true
288+
289+ # Bundle xlings
290+ XLINGS_EXE="$USERPROFILE/.xlings/subos/default/bin/xlings.exe"
291+ if [ -f "$XLINGS_EXE" ]; then
292+ cp "$XLINGS_EXE" "$STAGING/$WRAPPER/registry/bin/xlings.exe"
293+ echo "Bundled xlings.exe"
294+ else
295+ echo "::warning::xlings.exe not found at $XLINGS_EXE"
296+ fi
297+
298+ # Create zip
299+ mkdir -p dist
300+ (cd "$STAGING" && powershell.exe -Command \
301+ "Compress-Archive -Path '$WRAPPER' -DestinationPath '$WRAPPER.zip'")
302+ cp "$STAGING/$ZIPNAME" "dist/$ZIPNAME"
303+
304+ # SHA256
305+ (cd dist && sha256sum "$ZIPNAME" > "$ZIPNAME.sha256")
306+
307+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
308+ echo "zipname=$ZIPNAME" >> "$GITHUB_OUTPUT"
309+ ls -la dist/
310+
311+ - name : Smoke-test the packaged zip
312+ shell : bash
313+ run : |
314+ VERSION="${{ steps.package.outputs.version }}"
315+ ZIPNAME="${{ steps.package.outputs.zipname }}"
316+ WRAPPER="${ZIPNAME%.zip}"
317+
318+ SMOKE=$(mktemp -d)
319+ (cd "$SMOKE" && unzip -q "$GITHUB_WORKSPACE/dist/$ZIPNAME")
320+
321+ echo "=== Layout ==="
322+ find "$SMOKE/$WRAPPER" -type f
323+
324+ echo "=== Version check ==="
325+ "$SMOKE/$WRAPPER/bin/mcpp.exe" --version
326+
327+ echo "=== xlings bundled ==="
328+ test -f "$SMOKE/$WRAPPER/registry/bin/xlings.exe"
329+
330+ echo "=== Launcher ==="
331+ test -f "$SMOKE/$WRAPPER/mcpp.bat"
332+
333+ echo "Smoke-test passed"
334+
335+ - name : Upload artifact
336+ uses : actions/upload-artifact@v4
337+ with :
338+ name : mcpp-windows-x86_64
339+ path : |
340+ dist/*.zip
341+ dist/*.sha256
0 commit comments