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
102 changes: 102 additions & 0 deletions .github/workflows/codegen-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Codegen Tool Tests

# Builds the codegen tool and runs the unit-test suite (xUnit).
# Runs on Linux (fast, cheap) and can be extended to macOS/Windows.

on:
push:
paths:
- 'tools/codegen/**'
- 'src/Framework/**'
- 'src/Framework.Tests/**'
- '.github/workflows/codegen-tests.yml'
- 'Directory.Build.props'
pull_request:
paths:
- 'tools/codegen/**'
- 'src/Framework/**'
- 'src/Framework.Tests/**'
- '.github/workflows/codegen-tests.yml'
- 'Directory.Build.props'

permissions:
contents: read

jobs:
test:
name: Test (.NET ${{ matrix.dotnet }})
runs-on: ubuntu-24.04
strategy:
matrix:
dotnet: ['9.0.x']

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}

- name: Restore
run: |
FerrumSkipMobile=true dotnet restore tools/codegen/Ferrum.Codegen.csproj
FerrumSkipMobile=true dotnet restore src/Framework/Ferrum.Framework.csproj
FerrumSkipMobile=true dotnet restore src/Framework.Tests/Ferrum.Framework.Tests.csproj

- name: Build
run: |
FerrumSkipMobile=true dotnet build tools/codegen/Ferrum.Codegen.csproj --no-restore -c Release
FerrumSkipMobile=true dotnet build src/Framework/Ferrum.Framework.csproj --no-restore -c Release
FerrumSkipMobile=true dotnet build src/Framework.Tests/Ferrum.Framework.Tests.csproj --no-restore -c Release

- name: Test
run: |
FerrumSkipMobile=true dotnet test src/Framework.Tests/Ferrum.Framework.Tests.csproj \
--no-build -c Release \
--logger "trx;LogFileName=test-results.trx" \
--logger "console;verbosity=normal"

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.dotnet }}
path: '**/*.trx'

# Smoke-test the CLI: parse the in-tree add.h and verify zero exit code
codegen-smoke:
name: Codegen smoke test
runs-on: ubuntu-24.04
needs: test

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Build codegen
run: FerrumSkipMobile=true dotnet build tools/codegen/Ferrum.Codegen.csproj -c Release

- name: Run codegen on test stub header
run: |
FerrumSkipMobile=true dotnet run --project tools/codegen/Ferrum.Codegen.csproj \
--configuration Release \
-- \
--input native/test_stub/include/add.h \
--output /tmp/AddBindings.cs \
--ns Ferrum.Generated \
--class AddBindings \
--lib __Internal

- name: Verify output
run: |
echo "=== Generated bindings ==="
cat /tmp/AddBindings.cs
# Ensure [LibraryImport] and the function name are present
grep -q "\[LibraryImport" /tmp/AddBindings.cs
grep -q "ferrum_add" /tmp/AddBindings.cs
echo "==> Smoke test passed"
106 changes: 106 additions & 0 deletions .github/workflows/maui-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: MAUI Build

# Builds the Ferrum.Framework library and the MinimalDemo sample app.
# The iOS build requires macOS; Android can be built on ubuntu.
#
# NOTE: The native libraries (XCFramework / .so) must already be available
# as artifacts from the native-build workflow before this workflow can
# produce a fully linkable app binary. In the absence of the native libs,
# this workflow validates that the managed code compiles cleanly.

on:
push:
paths:
- 'src/**'
- 'samples/**'
- '.github/workflows/maui-build.yml'
- 'Directory.Build.props'
pull_request:
paths:
- 'src/**'
- 'samples/**'
- '.github/workflows/maui-build.yml'
- 'Directory.Build.props'

permissions:
contents: read

jobs:
# ── Framework library build ────────────────────────────────────────────────
framework:
name: Framework (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-15]

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Install MAUI workload
run: dotnet workload install maui

- name: Build Ferrum.Framework (all TFMs)
run: |
dotnet build src/Framework/Ferrum.Framework.csproj \
-c Release

# ── MAUI iOS build ─────────────────────────────────────────────────────────
ios-maui:
name: MAUI iOS build
runs-on: macos-15
needs: framework

steps:
- uses: actions/checkout@v4

- name: Select Xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Install MAUI workload
run: dotnet workload install maui

- name: Build MinimalDemo (iOS — no signing)
run: |
dotnet build samples/MinimalDemo/MinimalDemo.csproj \
-f net9.0-ios \
-c Release \
/p:RuntimeIdentifier=ios-arm64 \
/p:CodesignKey="" \
/p:CodesignProvision=""

# ── MAUI Android build ─────────────────────────────────────────────────────
android-maui:
name: MAUI Android build
runs-on: ubuntu-24.04
needs: framework

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Install Android workload
run: dotnet workload install android
Comment on lines +96 to +97

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Build MinimalDemo (Android)
run: |
dotnet build samples/MinimalDemo/MinimalDemo.csproj \
-f net9.0-android \
-c Release
149 changes: 149 additions & 0 deletions .github/workflows/native-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Native Build (iOS & Android)

# Builds the native static/shared libraries for all supported platforms and
# ABIs, then uploads the artifacts for use by the MAUI build workflow.
#
# Triggered on every push and pull request that touches native code or the
# build scripts.

on:
push:
paths:
- 'native/**'
- '.github/workflows/native-build.yml'
pull_request:
paths:
- 'native/**'
- '.github/workflows/native-build.yml'

permissions:
contents: read

jobs:
# ── iOS XCFramework ────────────────────────────────────────────────────────
ios:
name: iOS XCFramework (${{ matrix.platform }})
runs-on: macos-15
strategy:
matrix:
include:
- platform: OS64
sysroot: iphoneos
label: device-arm64
- platform: SIMULATORARM64
sysroot: iphonesimulator
label: sim-arm64
- platform: SIMULATOR64
sysroot: iphonesimulator
label: sim-x86_64

steps:
- uses: actions/checkout@v4

- name: Select Xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app

- name: Configure CMake
run: |
cmake -S native \
-B .build/ios/${{ matrix.label }} \
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/native/cmake/ios.toolchain.cmake" \
-DPLATFORM=${{ matrix.platform }} \
-DDEPLOYMENT_TARGET=15.0 \
-DCMAKE_BUILD_TYPE=Release \
-GXcode

- name: Build
run: |
cmake --build .build/ios/${{ matrix.label }} \
--config Release \
--target ferrum_test_stub

- name: Upload slice artifact
uses: actions/upload-artifact@v4
with:
name: ios-${{ matrix.label }}
path: .build/ios/${{ matrix.label }}/Release-${{ matrix.sysroot }}/libferrum_test_stub.a

# Assemble the full XCFramework from the three slices
ios-xcframework:
name: Assemble XCFramework
runs-on: macos-15
needs: ios
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: ios-device-arm64
path: .slices/device

- uses: actions/download-artifact@v4
with:
name: ios-sim-arm64
path: .slices/sim-arm64

- uses: actions/download-artifact@v4
with:
name: ios-sim-x86_64
path: .slices/sim-x86_64

- name: Create fat simulator library
run: |
lipo -create \
.slices/sim-arm64/libferrum_test_stub.a \
.slices/sim-x86_64/libferrum_test_stub.a \
-output .slices/sim-fat/libferrum_test_stub.a

- name: Create XCFramework
run: |
mkdir -p artifacts/ios
xcodebuild -create-xcframework \
-library .slices/device/libferrum_test_stub.a \
-library .slices/sim-fat/libferrum_test_stub.a \
-output artifacts/ios/libferrum_test_stub.xcframework

- name: Upload XCFramework
uses: actions/upload-artifact@v4
with:
name: ios-xcframework
path: artifacts/ios/libferrum_test_stub.xcframework

# ── Android .so per ABI ────────────────────────────────────────────────────
android:
name: Android (${{ matrix.abi }})
runs-on: ubuntu-24.04
strategy:
matrix:
abi: [arm64-v8a, armeabi-v7a, x86_64, x86]

steps:
- uses: actions/checkout@v4

- name: Set up NDK
uses: android-actions/setup-android@v3

- name: Install NDK
run: sdkmanager "ndk;27.2.12479018"

- name: Configure CMake
run: |
NDK_ROOT="${ANDROID_SDK_ROOT}/ndk/27.2.12479018"
cmake -S native \
-B .build/android/${{ matrix.abi }} \
-DCMAKE_TOOLCHAIN_FILE="${NDK_ROOT}/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI=${{ matrix.abi }} \
-DANDROID_PLATFORM=android-24 \
-DCMAKE_BUILD_TYPE=Release

- name: Build
run: |
cmake --build .build/android/${{ matrix.abi }} \
--config Release \
--target ferrum_test_stub

- name: Upload .so artifact
uses: actions/upload-artifact@v4
with:
name: android-${{ matrix.abi }}
path: .build/android/${{ matrix.abi }}/libferrum_test_stub.so
17 changes: 17 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project>
<!--
Directory.Build.props — common MSBuild properties applied to every
project in this repository. Keep this file minimal; project-specific
settings belong in the .csproj file.
-->
<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<!-- Reproducible builds -->
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>
</Project>
Loading
Loading