Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[submodule "avalonia-src"]
path = avalonia-src
url = https://github.com/mamoreau-devolutions/Avalonia.git
branch = main
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions rust/build-app.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions rust/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
38 changes: 38 additions & 0 deletions rust/package-shared.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions rust/regenerate-and-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 -- `
Expand Down