Skip to content

Commit 8b75ff0

Browse files
author
Alex J Lennon
committed
Add linux-arm64 build support and CI workflow
- Add build-linux-arm64.sh script for local builds - Add GitHub Actions CI workflow for automated linux-arm64 builds - Output artifacts to bin/Release/net8.0/linux-arm64/publish/ for Yocto integration - Add BUILD.md with build instructions - Add YOCTO_BUILD_LOCATIONS.md comparing main vs development branch structures - CI builds self-contained single-file executable for embedded Linux targets
1 parent fd404d6 commit 8b75ff0

4 files changed

Lines changed: 339 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI Build for linux-arm64
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
name: Build linux-arm64 Artifacts
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: '8.0.x'
23+
24+
- name: Clean build artifacts
25+
run: |
26+
rm -rf obj bin publish
27+
28+
- name: Build and Publish for linux-arm64
29+
run: |
30+
dotnet publish InstDotNet.csproj \
31+
-c Release \
32+
-r linux-arm64 \
33+
--self-contained true \
34+
-p:PublishSingleFile=true \
35+
-p:IncludeNativeLibrariesForSelfExtract=true \
36+
-o bin/Release/net8.0/linux-arm64/publish
37+
38+
- name: Verify build artifacts
39+
run: |
40+
echo "Build artifacts:"
41+
ls -lh bin/Release/net8.0/linux-arm64/publish/
42+
echo ""
43+
echo "Main executable:"
44+
file bin/Release/net8.0/linux-arm64/publish/InstDotNet
45+
echo ""
46+
echo "File size:"
47+
du -h bin/Release/net8.0/linux-arm64/publish/InstDotNet
48+
49+
- name: Create archive
50+
run: |
51+
cd bin/Release/net8.0/linux-arm64/publish
52+
tar -czf ../../../../InstDotNet-linux-arm64.tar.gz .
53+
cd ../../../../..
54+
55+
- name: Upload build artifacts
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: InstDotNet-linux-arm64
59+
path: |
60+
bin/Release/net8.0/linux-arm64/publish/
61+
InstDotNet-linux-arm64.tar.gz
62+
retention-days: 90
63+

BUILD.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Build Instructions for linux-arm64
2+
3+
This document describes how to build InstDotNet for linux-arm64 targets, typically used with Yocto-based embedded Linux systems.
4+
5+
## Automated Builds
6+
7+
The project includes a GitHub Actions CI workflow (`.github/workflows/ci.yml`) that automatically builds linux-arm64 artifacts on every push to the main branch. The artifacts are available as GitHub Actions artifacts and can be downloaded from the Actions tab.
8+
9+
## Prerequisites
10+
11+
- .NET 8.0 SDK installed
12+
- Linux ARM64 runtime available (usually installed with SDK)
13+
14+
## Building for linux-arm64
15+
16+
### Using the Build Script
17+
18+
The simplest way to build for linux-arm64 is to use the provided build script:
19+
20+
```bash
21+
./build-linux-arm64.sh
22+
```
23+
24+
This script will:
25+
1. Clean previous build artifacts
26+
2. Build and publish the application as a self-contained single-file executable
27+
3. Output artifacts to `bin/Release/net8.0/linux-arm64/publish/`
28+
29+
### Manual Build
30+
31+
You can also build manually using dotnet CLI:
32+
33+
```bash
34+
dotnet publish InstDotNet.csproj \
35+
-c Release \
36+
-r linux-arm64 \
37+
--self-contained true \
38+
-p:PublishSingleFile=true \
39+
-p:IncludeNativeLibrariesForSelfExtract=true \
40+
-o bin/Release/net8.0/linux-arm64/publish
41+
```
42+
43+
## Build Output Location
44+
45+
The build artifacts are placed in:
46+
```
47+
bin/Release/net8.0/linux-arm64/publish/
48+
```
49+
50+
### Key Artifacts
51+
52+
- **InstDotNet** - Main executable (self-contained single file)
53+
- **InstDotNet.deps.json** - Dependency manifest
54+
- **InstDotNet.runtimeconfig.json** - Runtime configuration
55+
- **libcoreclr.so**, **libclrjit.so**, **libclrgc.so** - .NET runtime libraries (if not single-file)
56+
- **createdump** - Core dump utility
57+
58+
## Yocto Integration
59+
60+
For Yocto recipes, the build output location `bin/Release/net8.0/linux-arm64/publish/` should be used as the source for copying artifacts to the target filesystem.
61+
62+
### Comparison with Development Branch
63+
64+
- **Main branch**: Files are in root directory, output: `bin/Release/net8.0/linux-arm64/publish/`
65+
- **Development branch**: Files are in `src/` directory, output: `src/bin/Release/net8.0/linux-arm64/publish/`
66+
67+
Yocto recipes should be updated to match the branch structure being used.
68+
69+
## Build Configuration
70+
71+
The project file (`InstDotNet.csproj`) is configured for:
72+
- Target Framework: .NET 8.0
73+
- Runtime: linux-arm64
74+
- Self-contained: true (includes .NET runtime)
75+
- Single-file: true (packs everything into one executable)
76+
- Native libraries: Extracted automatically
77+
78+
## Troubleshooting
79+
80+
### Build Errors
81+
82+
If you encounter duplicate assembly attribute errors:
83+
1. Clean build artifacts: `rm -rf obj bin`
84+
2. Run `dotnet clean`
85+
3. Rebuild
86+
87+
### Missing Runtime
88+
89+
If the linux-arm64 runtime is not available:
90+
```bash
91+
dotnet --list-runtimes
92+
```
93+
94+
Install the runtime if needed:
95+
```bash
96+
# The runtime should be included with the SDK, but if missing:
97+
# Follow .NET installation instructions for your platform
98+
```
99+
100+
## Testing the Build
101+
102+
After building, you can verify the executable:
103+
```bash
104+
file bin/Release/net8.0/linux-arm64/publish/InstDotNet
105+
# Should show: ELF 64-bit LSB executable, ARM aarch64
106+
107+
# Check dependencies (should be minimal for self-contained):
108+
ldd bin/Release/net8.0/linux-arm64/publish/InstDotNet
109+
```
110+

YOCTO_BUILD_LOCATIONS.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Yocto Build Artifact Locations
2+
3+
This document compares the build output locations between the main branch and the ajl/development branch to help configure Yocto recipes correctly.
4+
5+
## Branch Structure Comparison
6+
7+
### Main Branch
8+
- **Source files location**: Root directory (`/`)
9+
- `InstDotNet.csproj`
10+
- `Program.cs`
11+
- `MQTTControl.cs`
12+
- `UWB2GPSConverter.cs`
13+
- `UWBManager.cs`
14+
- `VectorExtensions.cs`
15+
- `WGS84Converter.cs`
16+
17+
- **Build output location**:
18+
```
19+
bin/Release/net8.0/linux-arm64/publish/
20+
```
21+
22+
- **Main executable**:
23+
```
24+
bin/Release/net8.0/linux-arm64/publish/InstDotNet
25+
```
26+
27+
### Development Branch (ajl/development)
28+
- **Source files location**: `src/` subdirectory
29+
- `src/InstDotNet.csproj`
30+
- `src/Program.cs`
31+
- `src/MQTTControl.cs`
32+
- `src/UWB2GPSConverter.cs`
33+
- `src/UWBManager.cs`
34+
- `src/VectorExtensions.cs`
35+
- `src/WGS84Converter.cs`
36+
- Plus additional files: `src/AppConfig.cs`, `src/HealthCheck.cs`, etc.
37+
38+
- **Build output location**:
39+
```
40+
src/bin/Release/net8.0/linux-arm64/publish/
41+
```
42+
43+
- **Main executable**:
44+
```
45+
src/bin/Release/net8.0/linux-arm64/publish/InstDotNet
46+
```
47+
48+
## Yocto Recipe Configuration
49+
50+
### For Main Branch
51+
52+
When building from the main branch, Yocto recipes should:
53+
54+
1. **Build command**:
55+
```bash
56+
dotnet publish InstDotNet.csproj \
57+
-c Release \
58+
-r linux-arm64 \
59+
--self-contained true \
60+
-p:PublishSingleFile=true \
61+
-p:IncludeNativeLibrariesForSelfExtract=true \
62+
-o ${WORKDIR}/build/bin/Release/net8.0/linux-arm64/publish
63+
```
64+
65+
2. **Copy artifacts** from:
66+
```
67+
${WORKDIR}/build/bin/Release/net8.0/linux-arm64/publish/
68+
```
69+
70+
3. **Install executable** to target:
71+
```
72+
${D}${bindir}/InstDotNet
73+
```
74+
75+
### For Development Branch
76+
77+
When building from the ajl/development branch:
78+
79+
1. **Build command**:
80+
```bash
81+
dotnet publish src/InstDotNet.csproj \
82+
-c Release \
83+
-r linux-arm64 \
84+
--self-contained true \
85+
-p:PublishSingleFile=true \
86+
-p:IncludeNativeLibrariesForSelfExtract=true \
87+
-o ${WORKDIR}/build/src/bin/Release/net8.0/linux-arm64/publish
88+
```
89+
90+
2. **Copy artifacts** from:
91+
```
92+
${WORKDIR}/build/src/bin/Release/net8.0/linux-arm64/publish/
93+
```
94+
95+
## Key Differences
96+
97+
| Aspect | Main Branch | Development Branch |
98+
|--------|-------------|-------------------|
99+
| Project file | `InstDotNet.csproj` (root) | `src/InstDotNet.csproj` |
100+
| Build directory | `bin/Release/...` | `src/bin/Release/...` |
101+
| Relative path | `bin/Release/net8.0/linux-arm64/publish/` | `src/bin/Release/net8.0/linux-arm64/publish/` |
102+
103+
## Dockerfile Reference
104+
105+
The Dockerfile in `/data_drive/dd/containers/cga-coordinate-mapping/Dockerfile` currently expects:
106+
- Source: `src/InstDotNet.csproj` (development branch structure)
107+
- Output: `/app/publish/InstDotNet`
108+
109+
This matches the development branch structure. If using the main branch, update the Dockerfile to:
110+
- Source: `InstDotNet.csproj` (root)
111+
- Output: `/app/publish/InstDotNet`
112+
113+
## Build Artifacts
114+
115+
Both branches produce the same artifacts:
116+
- `InstDotNet` - Main executable (self-contained)
117+
- `InstDotNet.deps.json` - Dependency manifest
118+
- `InstDotNet.runtimeconfig.json` - Runtime configuration
119+
- Native libraries (if not single-file): `libcoreclr.so`, `libclrjit.so`, `libclrgc.so`
120+
- `createdump` - Core dump utility
121+
122+
## Notes
123+
124+
- The main branch uses a simpler, flatter directory structure
125+
- The development branch uses a more organized `src/` structure
126+
- Both produce identical executables, just from different source locations
127+
- Yocto recipes need to account for the different source/build paths
128+

build-linux-arm64.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# Build script for linux-arm64 target
3+
# This script builds the application for Yocto/embedded Linux ARM64 targets
4+
#
5+
# Output location: bin/Release/net8.0/linux-arm64/publish/
6+
# This matches the structure expected by Yocto recipes which typically
7+
# copy artifacts from the build output directory.
8+
9+
set -e
10+
11+
echo "Building InstDotNet for linux-arm64..."
12+
echo "Cleaning previous build artifacts..."
13+
14+
# Clean previous builds to avoid conflicts
15+
dotnet clean InstDotNet.csproj -c Release 2>/dev/null || true
16+
rm -rf bin/Release/net8.0/linux-arm64 obj/Release/net8.0/linux-arm64
17+
18+
echo "Building and publishing for linux-arm64..."
19+
20+
# Build and publish for linux-arm64 as self-contained
21+
dotnet publish InstDotNet.csproj \
22+
-c Release \
23+
-r linux-arm64 \
24+
--self-contained true \
25+
-p:PublishSingleFile=true \
26+
-p:IncludeNativeLibrariesForSelfExtract=true \
27+
-o bin/Release/net8.0/linux-arm64/publish
28+
29+
echo ""
30+
echo "Build completed successfully!"
31+
echo ""
32+
echo "Output location: bin/Release/net8.0/linux-arm64/publish/"
33+
echo ""
34+
echo "Build artifacts:"
35+
ls -lh bin/Release/net8.0/linux-arm64/publish/ | grep -E "InstDotNet|\.so|createdump" || ls -lh bin/Release/net8.0/linux-arm64/publish/
36+
echo ""
37+
echo "Main executable: bin/Release/net8.0/linux-arm64/publish/InstDotNet"
38+

0 commit comments

Comments
 (0)