-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
189 lines (168 loc) · 7.24 KB
/
Copy pathlinux-arm64.yml
File metadata and controls
189 lines (168 loc) · 7.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Linux ARM64
on:
pull_request:
types: [synchronize, opened]
push:
branches:
- main
env:
DEBIAN_FRONTEND: noninteractive
OPENCV_VERSION: 5.0.0
CACHE_VERSION: "2"
jobs:
build:
name: Linux (arm64)
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
apt-transport-https \
software-properties-common \
ca-certificates \
g++ \
make \
cmake \
libtbb-dev \
libatlas-base-dev \
libgtk-3-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libdc1394-dev \
libxine2-dev \
libv4l-dev \
libtheora-dev \
libvorbis-dev \
libxvidcore-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
libx264-dev \
libtesseract-dev \
ninja-build
- name: Restore OpenCV cache
id: opencv-cache
uses: actions/cache/restore@v6
with:
path: |
${{ github.workspace }}/opencv_artifacts/include
${{ github.workspace }}/opencv_artifacts/lib
key: opencv-arm-v${{ env.CACHE_VERSION }}-${{ env.OPENCV_VERSION }}-${{ hashFiles('cmake/opencv_build_options.cmake', '.github/workflows/linux-arm64.yml') }}
- name: Configure OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
run: |
# Disable the generic ASM language so OpenCV 5's vendored MLAS skips its
# ASM kernels and reports MLAS unavailable (DNN falls back to its
# built-in SGEMM). On aarch64 the MLAS FP16/GQA path references
# MlasHGemmSupported(), which OpenCV 5.0.0 declares and calls but never
# defines, breaking the extern link with an undefined reference.
# GCC 12+ builds libjpeg-turbo/libpng SIMD via NEON intrinsics (not GAS),
# so dropping the ASM compiler does not affect the image codecs here.
cmake \
-G Ninja \
-C cmake/opencv_build_options.cmake \
-S opencv \
-B opencv/build \
-D OPENCV_EXTRA_MODULES_PATH=${GITHUB_WORKSPACE}/opencv_contrib/modules \
-D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_artifacts \
-D CMAKE_ASM_COMPILER="" \
2>&1 | tee /tmp/opencv-configure.log
- name: Verify OpenCV cmake features
if: steps.opencv-cache.outputs.cache-hit != 'true'
run: |
log=/tmp/opencv-configure.log
fail=0
for feature in Tesseract FFMPEG JPEG PNG TIFF WEBP; do
val=$(grep -E "^--\s+${feature}:\s+" "$log" | tail -1 | sed -E "s/^.*${feature}:[[:space:]]+//")
if [[ -n "$val" ]] && [[ "$val" != NO* ]]; then
echo "OK: $feature = $val"
else
echo "MISSING or DISABLED: $feature"
grep -iE "${feature}" "$log" | tail -3 || true
fail=1
fi
done
[ "$fail" -eq 0 ]
- name: Build OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
run: |
cmake --build opencv/build -j 3
cmake --install opencv/build
sudo ldconfig
ls
- name: Save OpenCV cache
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/cache/save@v6
with:
path: |
${{ github.workspace }}/opencv_artifacts/include
${{ github.workspace }}/opencv_artifacts/lib
key: opencv-arm-v${{ env.CACHE_VERSION }}-${{ env.OPENCV_VERSION }}-${{ hashFiles('cmake/opencv_build_options.cmake', '.github/workflows/linux-arm64.yml') }}
- name: Build OpenCvSharpExtern
run: |
cmake \
-G Ninja \
-S src \
-B src/build \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_artifacts
cmake --build src/build -j
ls src/build/OpenCvSharpExtern
cp src/build/OpenCvSharpExtern/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/packaging/nuget/
- name: Check OpenCvSharpExtern
run: |
cd ${GITHUB_WORKSPACE}/packaging/nuget/
ldd libOpenCvSharpExtern.so
nm libOpenCvSharpExtern.so
echo -ne "#include <stdio.h> \n int core_Mat_sizeof(); int main(){ int i = core_Mat_sizeof(); printf(\"sizeof(Mat) = %d\", i); return 0; }" > test.c
gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern
LD_LIBRARY_PATH=. ./test
- name: Install .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
- name: Create NuGet package
env:
BETA: "-beta"
run: |
yyyymmdd=`date '+%Y%m%d'`
echo $yyyymmdd
version="${OPENCV_VERSION}.${yyyymmdd}${BETA}"
echo "Package version: $version"
cd ${GITHUB_WORKSPACE}
dotnet pack packaging/nuget/OpenCvSharp5.runtime.linux-arm64.csproj -o ${GITHUB_WORKSPACE}/artifacts_arm64 -p:Version=$version
dotnet pack packaging/nuget/OpenCvSharp5.runtime.linux-arm.csproj -o ${GITHUB_WORKSPACE}/artifacts_arm64 -p:Version=$version --no-restore
ls ${GITHUB_WORKSPACE}/artifacts_arm64
- uses: actions/upload-artifact@v7
with:
name: artifacts_linux_arm64
path: artifacts_arm64
- name: Test
run: |
cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests
dotnet build -c Release -f net10.0
cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/bin/Release/net10.0/
cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/
sudo cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so /usr/lib/
# Preserve the executed-test sequence and a native dump when the test host crashes,
# including failures that happen during process teardown after all tests complete.
LD_LIBRARY_PATH=. dotnet test --project OpenCvSharp.Tests.csproj -c Release -f net10.0 --runtime linux-arm64 \
--results-directory TestResults --report-xunit-trx --report-xunit-trx-filename test-results.trx \
--crashdump --crashdump-type Full < /dev/null
- name: Upload crash dumps on failure
if: failure()
uses: actions/upload-artifact@v7
with:
name: linux-arm64-crash-dumps
path: test/OpenCvSharp.Tests/TestResults/
if-no-files-found: ignore
- name: Test Avalonia extensions
run: |
cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests.Avalonia
dotnet build -c Release -f net10.0
cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests.Avalonia/bin/Release/net10.0/
LD_LIBRARY_PATH=. dotnet test --project OpenCvSharp.Tests.Avalonia.csproj -c Release -f net10.0 --runtime linux-arm64 < /dev/null