From 465d4e6b5daa914f1e8a241b2423feef80a4b068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 9 Sep 2026 10:57:02 -0400 Subject: [PATCH] Ensure builds use the pinned Avalonia producer --- .gitmodules | 1 - CONTRIBUTING.md | 4 ++++ rust/build-app.ps1 | 2 ++ rust/build.ps1 | 2 ++ rust/package-shared.ps1 | 38 +++++++++++++++++++++++++++++++++++ rust/regenerate-and-build.ps1 | 2 ++ 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index bd125f9..2b08127 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ [submodule "avalonia-src"] path = avalonia-src url = https://github.com/mamoreau-devolutions/Avalonia.git - branch = main diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b77c716..d1cb301 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,6 +17,10 @@ pwsh .\avalonia-patches\apply-avalonia-patches.ps1 -AvaloniaRoot .\avalonia-src pwsh .\rust\regenerate-and-build.ps1 -Configuration Release ``` +The Rust build entry points also initialize the in-repository producer at the +revision recorded by the checkout, so a fresh or reused checkout cannot build +against a different `avalonia-src` revision. + Open `Rustolonia.slnx` to navigate the eleven Rustolonia-owned managed projects. Producer projects remain transitive project references, with their own build configuration. When adding a project to the solution, pass diff --git a/rust/build-app.ps1 b/rust/build-app.ps1 index e561920..03fd164 100644 --- a/rust/build-app.ps1 +++ b/rust/build-app.ps1 @@ -257,6 +257,8 @@ function Invoke-ConsumerPackage { Write-Host "Package layout ready at $bundle" } +$rustoloniaRootPath = (Resolve-Path -LiteralPath $RustoloniaRoot).Path +Initialize-LocalProducerSubmodule -RustoloniaRoot $rustoloniaRootPath -ProducerRoot $ProducerRoot $producer = (Resolve-Path -LiteralPath $ProducerRoot).Path $manifestPath = (Resolve-Path -LiteralPath $Manifest).Path $document = Read-ConsumerManifest $manifestPath diff --git a/rust/build.ps1 b/rust/build.ps1 index 4e125e4..35e6804 100644 --- a/rust/build.ps1 +++ b/rust/build.ps1 @@ -16,7 +16,9 @@ $PSNativeCommandUseErrorActionPreference = $true # The Rustolonia repository root is the parent of rust/. $repositoryRoot = Split-Path -Parent $PSScriptRoot +. (Join-Path $PSScriptRoot 'package-shared.ps1') $avaloniaRoot = Join-Path $repositoryRoot 'avalonia-src' +Initialize-LocalProducerSubmodule -RustoloniaRoot $repositoryRoot -ProducerRoot $avaloniaRoot $nativeArchitecture = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) { 'X64' { 'x64' } 'Arm64' { 'arm64' } diff --git a/rust/package-shared.ps1 b/rust/package-shared.ps1 index 31ae32d..30eb952 100644 --- a/rust/package-shared.ps1 +++ b/rust/package-shared.ps1 @@ -421,6 +421,44 @@ function Resolve-CallerRelativePath { ) } +function Initialize-LocalProducerSubmodule { + param( + [Parameter(Mandatory)][string]$RustoloniaRoot, + [Parameter(Mandatory)][string]$ProducerRoot + ) + + $rootPath = Resolve-CallerRelativePath $RustoloniaRoot + $producerPath = Resolve-CallerRelativePath $ProducerRoot + $expectedProducerPath = [IO.Path]::GetFullPath((Join-Path $rootPath 'avalonia-src')) + if (-not [String]::Equals($producerPath, $expectedProducerPath, [StringComparison]::OrdinalIgnoreCase)) { + return + } + + $expectedRevision = & git -C $rootPath rev-parse 'HEAD:avalonia-src' 2>$null + if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($expectedRevision)) { + throw "Cannot determine the pinned avalonia-src revision from $rootPath." + } + + $actualRevision = if (Test-Path -LiteralPath $producerPath -PathType Container) { + & git -C $producerPath rev-parse HEAD 2>$null + } + else { + '' + } + if ($LASTEXITCODE -ne 0 -or $actualRevision -ne $expectedRevision) { + Write-Host "==> Initializing avalonia-src at $expectedRevision" + & git -C $rootPath submodule update --init --recursive -- avalonia-src + if ($LASTEXITCODE -ne 0) { + throw 'Cannot initialize avalonia-src at the pinned producer revision.' + } + } + + $actualRevision = & git -C $producerPath rev-parse HEAD 2>$null + if ($LASTEXITCODE -ne 0 -or $actualRevision -ne $expectedRevision) { + throw "avalonia-src must be at $expectedRevision; found '$actualRevision'." + } +} + function Invoke-ArtifactSigning { param( [Parameter(Mandatory)][string]$ArtifactDirectory, diff --git a/rust/regenerate-and-build.ps1 b/rust/regenerate-and-build.ps1 index 9626ad6..a6c343f 100644 --- a/rust/regenerate-and-build.ps1 +++ b/rust/regenerate-and-build.ps1 @@ -14,6 +14,8 @@ $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true # The Rustolonia repository root is the parent of rust/. $repositoryRoot = Split-Path -Parent $PSScriptRoot +. (Join-Path $PSScriptRoot 'package-shared.ps1') +Initialize-LocalProducerSubmodule -RustoloniaRoot $repositoryRoot -ProducerRoot (Join-Path $repositoryRoot 'avalonia-src') Write-Host '==> [1/4] Regenerating object-model projection IR, C# COM sources, and native ABI header' dotnet run --project (Join-Path $repositoryRoot 'projection' 'Avalonia.Projection.Tool') -c $Configuration -- `