Skip to content

Commit d7b5d49

Browse files
Ellerbachjosesimoes
authored andcommitted
Add nanoCLR POSIX for MacOS and Linux (#3400)
1 parent 43c8317 commit d7b5d49

63 files changed

Lines changed: 3894 additions & 597 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: posix-nanoclr
2+
3+
on:
4+
push:
5+
paths:
6+
- "targets/posix/**"
7+
- "src/CLR/**"
8+
- "src/HAL/**"
9+
- "src/PAL/**"
10+
- ".github/workflows/posix-nanoclr.yml"
11+
pull_request:
12+
paths:
13+
- "targets/posix/**"
14+
- "src/CLR/**"
15+
- "src/HAL/**"
16+
- "src/PAL/**"
17+
- ".github/workflows/posix-nanoclr.yml"
18+
19+
jobs:
20+
build-posix-nanoclr:
21+
strategy:
22+
matrix:
23+
include:
24+
- os: macos-14
25+
label: macOS-arm64
26+
posix_rid: osx-arm64
27+
- os: macos-latest
28+
label: macOS-x64
29+
posix_rid: osx-x64
30+
- os: ubuntu-22.04
31+
label: Linux-x64
32+
posix_rid: linux-x64
33+
- os: ubuntu-22.04
34+
label: Linux-arm64
35+
posix_rid: linux-arm64
36+
fail-fast: false
37+
38+
runs-on: ${{ matrix.os }}
39+
name: Build (${{ matrix.label }})
40+
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Install arm64 cross-toolchain
46+
if: matrix.posix_rid == 'linux-arm64'
47+
run: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
48+
49+
- name: Configure
50+
run: |
51+
# Derive cmake arch from the RID matrix variable.
52+
case "${{ matrix.posix_rid }}" in
53+
osx-arm64|linux-arm64) NANO_ARCH=arm64 ;;
54+
osx-x64|linux-x64) NANO_ARCH=x86_64 ;;
55+
esac
56+
# For linux-arm64, cross-compile via the aarch64-linux-gnu toolchain.
57+
TOOLCHAIN_ARG=""
58+
if [ "${{ matrix.posix_rid }}" = "linux-arm64" ]; then
59+
TOOLCHAIN_ARG="-DCMAKE_TOOLCHAIN_FILE=$(pwd)/targets/posix/toolchain-aarch64-linux-gnu.cmake"
60+
fi
61+
cmake -S targets/posix -B build/posix -G Ninja \
62+
-DNANO_POSIX_ARCH=${NANO_ARCH} \
63+
-DNANO_POSIX_ENABLE_SMOKE=ON \
64+
${TOOLCHAIN_ARG}
65+
66+
- name: Build
67+
run: cmake --build build/posix --verbose
68+
69+
- name: Smoke Run
70+
run: |
71+
set -euo pipefail
72+
# Normalise host CPU name: Linux arm64 reports 'aarch64'; macOS reports 'arm64'.
73+
case "$(uname -m)" in
74+
arm64|aarch64) HOST_CANONICAL=arm64 ;;
75+
x86_64) HOST_CANONICAL=x86_64 ;;
76+
*) HOST_CANONICAL="$(uname -m)" ;;
77+
esac
78+
case "${{ matrix.posix_rid }}" in
79+
*-arm64) TARGET_ARCH=arm64 ;;
80+
*-x64) TARGET_ARCH=x86_64 ;;
81+
esac
82+
if [ "${HOST_CANONICAL}" = "${TARGET_ARCH}" ]; then
83+
# Run the test binary; with no assemblies the CLR engine may assert/abort,
84+
# so ignore the exit code and just validate the version banner was printed.
85+
set +e
86+
./build/posix/bin/nanoFramework.nanoCLR.test 2>&1 | tee build/posix/smoke.log
87+
set -e
88+
if ! grep -Eq '[0-9]+\.[0-9]+\.[0-9]+' build/posix/smoke.log; then
89+
echo "ERROR: smoke output validation failed."
90+
exit 1
91+
fi
92+
else
93+
echo "Skipping smoke run: host=$(uname -m) (${HOST_CANONICAL}), target=${TARGET_ARCH} (cross-compiled binary cannot execute on this runner)."
94+
fi
95+
96+
- name: Upload Artifacts
97+
if: always()
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: posix-nanoclr-${{ matrix.label }}
101+
path: |
102+
build/posix/lib/nanoFramework.nanoCLR.*
103+
build/posix/bin/nanoFramework.nanoCLR.test
104+
build/posix/smoke.log

0 commit comments

Comments
 (0)