mirror of
https://github.com/manos555555/PS5-Suite.git
synced 2026-10-06 10:00:26 +02:00
125 lines
4.7 KiB
YAML
125 lines
4.7 KiB
YAML
name: Native library (Linux)
|
|
|
|
# Builds the LibProsperoPkg shared library (.so) with NativeAOT for linux-x64 and
|
|
# linux-arm64. The AOT and shared-library settings are injected into the project at build
|
|
# time; the committed project is never modified. Each architecture builds on its own runner,
|
|
# so no cross-compilation toolchain is required. After the build the workflow verifies the
|
|
# exported symbol table and packages the library, header, license text and a checksum manifest
|
|
# as an artifact. The workflow also publishes the desktop GUI application for the same
|
|
# architecture into a separate GUI folder within the artifact.
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: native-linux-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- rid: linux-x64
|
|
runner: ubuntu-latest
|
|
- rid: linux-arm64
|
|
runner: ubuntu-24.04-arm
|
|
runs-on: ${{ matrix.runner }}
|
|
env:
|
|
PROJECT: src/LibProsperoPkg/LibProsperoPkg.csproj
|
|
PROJECT_DIR: src/LibProsperoPkg
|
|
NATIVE_DIR: .github/native
|
|
LICENSE_FILE: LICENSE
|
|
NOTICE_FILE: NOTICE
|
|
|
|
steps:
|
|
- name: Check out
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '10.0.x'
|
|
|
|
- name: Install build prerequisites
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y clang zlib1g-dev
|
|
|
|
- name: Inject AOT settings and export surface
|
|
shell: pwsh
|
|
run: |
|
|
$csproj = $env:PROJECT
|
|
$text = Get-Content -Raw $csproj
|
|
if ($text -notmatch '<PublishAot>') {
|
|
$inject = " <PublishAot>true</PublishAot>`n <NativeLib>Shared</NativeLib>`n </PropertyGroup>"
|
|
$idx = $text.IndexOf('</PropertyGroup>')
|
|
$text = $text.Substring(0, $idx) + $inject + $text.Substring($idx + '</PropertyGroup>'.Length)
|
|
Set-Content -NoNewline -Path $csproj -Value $text
|
|
}
|
|
Copy-Item (Join-Path $env:NATIVE_DIR 'NativeExports.cs') (Join-Path $env:PROJECT_DIR 'NativeExports.cs') -Force
|
|
if (-not (Select-String -Path $csproj -Pattern '<PublishAot>true</PublishAot>' -Quiet)) {
|
|
Write-Error 'csproj patch did not apply'
|
|
exit 1
|
|
}
|
|
|
|
- name: Publish shared library
|
|
run: dotnet publish "$PROJECT" -c Release -r ${{ matrix.rid }} --nologo
|
|
|
|
- name: Stage artifacts
|
|
shell: pwsh
|
|
run: |
|
|
$pub = Join-Path $env:PROJECT_DIR "bin/Release/net10.0/${{ matrix.rid }}/publish"
|
|
$mine = Get-ChildItem -Path $pub -Recurse -Include '*LibProsperoPkg.so'
|
|
if (-not $mine) {
|
|
Write-Error "LibProsperoPkg shared library (.so) was not produced in $pub"
|
|
Get-ChildItem -Path $pub -Recurse -Include *.so | ForEach-Object { Write-Host $_.FullName }
|
|
exit 1
|
|
}
|
|
New-Item -ItemType Directory -Force artifacts | Out-Null
|
|
$mine | Copy-Item -Destination artifacts
|
|
# A lib-prefixed alias so downstream consumers can link with -lprosperopkg.
|
|
Copy-Item $mine[0].FullName (Join-Path 'artifacts' 'libprosperopkg.so') -Force
|
|
Copy-Item (Join-Path $env:NATIVE_DIR 'libprosperopkg.h') artifacts
|
|
Copy-Item $env:LICENSE_FILE artifacts
|
|
Copy-Item $env:NOTICE_FILE artifacts
|
|
|
|
- name: Verify exported symbols
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
lib=$(ls artifacts/*LibProsperoPkg.so 2>/dev/null | head -n 1)
|
|
if [ -z "$lib" ]; then
|
|
echo "LibProsperoPkg shared library (.so) not found in artifacts:"
|
|
ls -la artifacts
|
|
exit 1
|
|
fi
|
|
echo "Inspecting $lib"
|
|
syms=$(nm -D --defined-only "$lib" | awk '{print $NF}' | sed -e 's/^_//' -e 's/@.*//')
|
|
missing=0
|
|
for s in $(cat "$NATIVE_DIR/exports.txt"); do
|
|
if ! grep -Fxq "$s" <<< "$syms"; then echo "MISSING: $s"; missing=1; fi
|
|
done
|
|
if [ "$missing" -ne 0 ]; then echo "Expected C exports are missing"; exit 1; fi
|
|
echo "All expected exports present"
|
|
|
|
- name: Checksums
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
( cd artifacts && sha256sum \
|
|
*LibProsperoPkg.so libprosperopkg.so libprosperopkg.h \
|
|
"$(basename "$LICENSE_FILE")" "$(basename "$NOTICE_FILE")" > SHA256SUMS )
|
|
cat artifacts/SHA256SUMS
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: libprosperopkg-${{ matrix.rid }}
|
|
path: artifacts/
|
|
if-no-files-found: error
|