Skip to content

Commit 7d3246d

Browse files
authored
Merge pull request #1816 from shimat/slim
Rename minimal profile to slim and align packaging/docs across Windows and Ubuntu
2 parents a894815 + 8ccf592 commit 7d3246d

20 files changed

+488
-49
lines changed

.github/workflows/linux-arm.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
libx264-dev \
5050
libtesseract-dev
5151
52-
- name: Cache OpenCV
52+
- name: Restore OpenCV cache
5353
id: opencv-cache
54-
uses: actions/cache@v5
54+
uses: actions/cache/restore@v5
5555
with:
5656
path: ${{ github.workspace }}/opencv_artifacts/
5757
key: opencv-arm-${{ env.OPENCV_VERSION }}-rev${{ env.OPENCV_CACHE_VERSION }}
@@ -119,6 +119,13 @@ jobs:
119119
cmake --install opencv/build
120120
sudo ldconfig
121121
ls
122+
123+
- name: Save OpenCV cache
124+
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
125+
uses: actions/cache/save@v5
126+
with:
127+
path: ${{ github.workspace }}/opencv_artifacts/
128+
key: opencv-arm-${{ env.OPENCV_VERSION }}-rev${{ env.OPENCV_CACHE_VERSION }}
122129

123130
- name: Build OpenCvSharpExtern
124131
run: |

.github/workflows/publish_nuget.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,21 @@ jobs:
3434
name: artifacts_ubuntu_24.04
3535
branch: ${{ github.ref_name }}
3636

37+
- name: Download ubuntu 22 slim artifact
38+
uses: dawidd6/action-download-artifact@v14
39+
with:
40+
github_token: ${{secrets.GITHUB_TOKEN}}
41+
workflow: ubuntu-slim.yml
42+
name: artifacts_ubuntu_slim_22.04
43+
branch: ${{ github.ref_name }}
3744

45+
- name: Download ubuntu 24 slim artifact
46+
uses: dawidd6/action-download-artifact@v14
47+
with:
48+
github_token: ${{secrets.GITHUB_TOKEN}}
49+
workflow: ubuntu-slim.yml
50+
name: artifacts_ubuntu_slim_24.04
51+
branch: ${{ github.ref_name }}
3852

3953
- name: Download ubuntu arm artifact
4054
uses: dawidd6/action-download-artifact@v14
@@ -63,6 +77,22 @@ jobs:
6377
- run: |
6478
ls -l
6579
80+
- name: Validate windows slim packages exist
81+
run: |
82+
set -euo pipefail
83+
84+
runtime_count=$(find "$PWD" -type f -name "OpenCvSharp4.runtime.win.slim*.nupkg" | wc -l)
85+
windows_slim_count=$(find "$PWD" -type f -name "OpenCvSharp4.Windows.Slim*.nupkg" | wc -l)
86+
87+
if [ "$runtime_count" -eq 0 ] || [ "$windows_slim_count" -eq 0 ]; then
88+
echo "Expected Windows slim NuGet packages were not found in downloaded artifacts."
89+
echo "runtime.win.slim count: $runtime_count"
90+
echo "Windows.Slim count: $windows_slim_count"
91+
echo "Detected .nupkg files:"
92+
find "$PWD" -maxdepth 4 -type f -name "*.nupkg" -print
93+
exit 1
94+
fi
95+
6696
- name: Install .NET
6797
uses: actions/setup-dotnet@v5
6898
with:

.github/workflows/ubuntu-slim.yml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: Ubuntu Slim
2+
3+
on:
4+
pull_request:
5+
types: [synchronize, opened]
6+
push:
7+
branches:
8+
- main
9+
10+
env:
11+
DEBIAN_FRONTEND: noninteractive
12+
OPENCV_VERSION: 4.13.0
13+
OPENCV_CACHE_VERSION: 1
14+
15+
jobs:
16+
build_test:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- ubuntu: "22.04"
22+
- ubuntu: "24.04"
23+
24+
runs-on: ubuntu-${{ matrix.ubuntu }}
25+
26+
steps:
27+
- uses: actions/checkout@v6
28+
with:
29+
path: opencvsharp
30+
31+
- name: Install dependencies
32+
run: |
33+
sudo apt-get update -y
34+
sudo apt-get install -y --no-install-recommends \
35+
apt-transport-https \
36+
software-properties-common \
37+
ca-certificates \
38+
g++ \
39+
make \
40+
cmake \
41+
libtbb-dev \
42+
libatlas-base-dev \
43+
libjpeg-dev \
44+
libpng-dev \
45+
libtiff-dev \
46+
libopenjp2-7-dev \
47+
zlib1g-dev
48+
49+
- name: Restore OpenCV cache (slim)
50+
id: opencv-cache
51+
uses: actions/cache/restore@v5
52+
with:
53+
path: ${{ github.workspace }}/opencv_artifacts_slim/
54+
key: opencv-${{ env.OPENCV_VERSION }}-ubuntu-${{ matrix.ubuntu }}-slim-rev${{ env.OPENCV_CACHE_VERSION }}
55+
56+
- name: Checkout OpenCV
57+
if: steps.opencv-cache.outputs.cache-hit != 'true'
58+
uses: actions/checkout@v6
59+
with:
60+
repository: opencv/opencv
61+
path: opencv
62+
ref: ${{ env.OPENCV_VERSION }}
63+
64+
- name: Build OpenCV (slim)
65+
if: steps.opencv-cache.outputs.cache-hit != 'true'
66+
run: |
67+
# Keep a practical subset (e.g., features2d/objdetect) while avoiding heavy runtime deps
68+
# from UI/video stacks and contrib modules.
69+
cmake \
70+
-S opencv \
71+
-B opencv/build \
72+
-D CMAKE_BUILD_TYPE=Release \
73+
-D BUILD_SHARED_LIBS=OFF \
74+
-D ENABLE_CXX11=ON \
75+
-D BUILD_LIST=core,imgproc,imgcodecs,calib3d,features2d,flann,objdetect,photo \
76+
-D BUILD_PROTOBUF=OFF \
77+
-D BUILD_opencv_dnn=OFF \
78+
-D BUILD_EXAMPLES=OFF \
79+
-D BUILD_DOCS=OFF \
80+
-D BUILD_PERF_TESTS=OFF \
81+
-D BUILD_TESTS=OFF \
82+
-D BUILD_JAVA=OFF \
83+
-D BUILD_opencv_apps=OFF \
84+
-D WITH_GSTREAMER=OFF \
85+
-D WITH_FFMPEG=OFF \
86+
-D WITH_GTK=OFF \
87+
-D WITH_PROTOBUF=OFF \
88+
-D WITH_ADE=OFF \
89+
-D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_artifacts_slim
90+
cmake --build opencv/build -j 3
91+
cmake --install opencv/build
92+
93+
- name: Validate OpenCV protobuf export (slim)
94+
run: |
95+
set -euo pipefail
96+
97+
modules_dir="${GITHUB_WORKSPACE}/opencv_artifacts_slim/lib/cmake/opencv4"
98+
modules_file="${modules_dir}/OpenCVModules.cmake"
99+
release_file="${modules_dir}/OpenCVModules-release.cmake"
100+
101+
if [ -f "${modules_file}" ]; then
102+
echo "Checking OpenCV module exports for protobuf reference"
103+
grep -n "liblibprotobuf.a\|libprotobuf.a" "${modules_file}" || true
104+
fi
105+
if [ -f "${release_file}" ]; then
106+
grep -n "liblibprotobuf.a\|libprotobuf.a" "${release_file}" || true
107+
fi
108+
109+
bad_ref=0
110+
if [ -f "${modules_file}" ] && grep -q "liblibprotobuf.a" "${modules_file}"; then
111+
bad_ref=1
112+
fi
113+
if [ -f "${release_file}" ] && grep -q "liblibprotobuf.a" "${release_file}"; then
114+
bad_ref=1
115+
fi
116+
117+
if [ "${bad_ref}" -eq 1 ]; then
118+
echo "Found bad liblibprotobuf.a reference, applying compatibility rewrite"
119+
[ -f "${modules_file}" ] && sed -i 's/liblibprotobuf.a/libprotobuf.a/g' "${modules_file}"
120+
[ -f "${release_file}" ] && sed -i 's/liblibprotobuf.a/libprotobuf.a/g' "${release_file}"
121+
fi
122+
123+
if [ -f "${modules_file}" ]; then
124+
grep -n "liblibprotobuf.a" "${modules_file}" && exit 1 || true
125+
fi
126+
if [ -f "${release_file}" ]; then
127+
grep -n "liblibprotobuf.a" "${release_file}" && exit 1 || true
128+
fi
129+
130+
- name: Save OpenCV cache (slim)
131+
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
132+
uses: actions/cache/save@v5
133+
with:
134+
path: ${{ github.workspace }}/opencv_artifacts_slim/
135+
key: opencv-${{ env.OPENCV_VERSION }}-ubuntu-${{ matrix.ubuntu }}-slim-rev${{ env.OPENCV_CACHE_VERSION }}
136+
137+
- name: Build OpenCvSharpExtern (slim)
138+
run: |
139+
# Match OpenCV subset above: keep common CV modules, disable wrappers for disabled modules.
140+
cmake \
141+
-S opencvsharp/src \
142+
-B opencvsharp/src/build-slim \
143+
-D CMAKE_BUILD_TYPE=Release \
144+
-D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_artifacts_slim \
145+
-D NO_CONTRIB=ON \
146+
-D NO_STITCHING=ON \
147+
-D NO_VIDEO=ON \
148+
-D NO_VIDEOIO=ON \
149+
-D NO_HIGHGUI=ON \
150+
-D NO_DNN=ON \
151+
-D NO_ML=ON \
152+
-D NO_BARCODE=ON
153+
cmake --build opencvsharp/src/build-slim -j
154+
cp opencvsharp/src/build-slim/OpenCvSharpExtern/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/nuget/
155+
156+
- name: Check OpenCvSharpExtern dependencies (slim)
157+
run: |
158+
cd ${GITHUB_WORKSPACE}/opencvsharp/nuget/
159+
ldd -r libOpenCvSharpExtern.so
160+
! ldd libOpenCvSharpExtern.so | grep -q "not found"
161+
162+
- name: Smoke test OpenCvSharpExtern (slim)
163+
run: |
164+
cd ${GITHUB_WORKSPACE}/opencvsharp/nuget/
165+
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
166+
gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern
167+
LD_LIBRARY_PATH=. ./test
168+
169+
- name: Install .NET
170+
uses: actions/setup-dotnet@v5
171+
with:
172+
dotnet-version: '8.0.x'
173+
174+
- name: Create NuGet package (slim)
175+
env:
176+
BETA: "-beta"
177+
run: |
178+
yyyymmdd=`date '+%Y%m%d'`
179+
version="${OPENCV_VERSION}.${yyyymmdd}${BETA}"
180+
echo "Package version: $version"
181+
182+
cd ${GITHUB_WORKSPACE}/opencvsharp
183+
package_project="OpenCvSharp4.official.runtime.ubuntu.${{ matrix.ubuntu }}-x64.slim.csproj"
184+
dotnet pack "nuget/${package_project}" -o ${GITHUB_WORKSPACE}/artifacts -p:Version=$version
185+
186+
- uses: actions/upload-artifact@v6
187+
with:
188+
name: artifacts_ubuntu_slim_${{ matrix.ubuntu }}
189+
path: artifacts

.github/workflows/ubuntu.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ jobs:
5757
libx264-dev \
5858
libtesseract-dev
5959
60-
- name: Cache OpenCV
60+
- name: Restore OpenCV cache
6161
id: opencv-cache
62-
uses: actions/cache@v5
62+
uses: actions/cache/restore@v5
6363
with:
6464
path: ${{ github.workspace }}/opencv_artifacts/
6565
key: opencv-${{ env.OPENCV_VERSION }}-ubuntu-${{ matrix.ubuntu }}-rev${{ env.OPENCV_CACHE_VERSION }}
@@ -127,6 +127,13 @@ jobs:
127127
cmake --install opencv/build
128128
sudo ldconfig
129129
ls
130+
131+
- name: Save OpenCV cache
132+
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
133+
uses: actions/cache/save@v5
134+
with:
135+
path: ${{ github.workspace }}/opencv_artifacts/
136+
key: opencv-${{ env.OPENCV_VERSION }}-ubuntu-${{ matrix.ubuntu }}-rev${{ env.OPENCV_CACHE_VERSION }}
130137

131138
- name: Build OpenCvSharpExtern
132139
run: |

.github/workflows/wasm.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ jobs:
5454
x264 \
5555
libtesseract-dev
5656
57-
- name: Cache OpenCV
57+
- name: Restore OpenCV cache
5858
id: opencv-cache
59-
uses: actions/cache@v5
59+
uses: actions/cache/restore@v5
6060
with:
6161
path: ${{ github.workspace }}/opencv_wasm/
6262
key: opencv-${{ env.OPENCV_VERSION }}-wasm-${{ env.EM_VERSION }}-rev${{ env.OPENCV_CACHE_VERSION }}
@@ -134,6 +134,13 @@ jobs:
134134
${GITHUB_WORKSPACE}/opencv_wasm/lib/opencv4/3rdparty/*.a
135135
cd ${GITHUB_WORKSPACE}
136136
ls
137+
138+
- name: Save OpenCV cache
139+
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
140+
uses: actions/cache/save@v5
141+
with:
142+
path: ${{ github.workspace }}/opencv_wasm/
143+
key: opencv-${{ env.OPENCV_VERSION }}-wasm-${{ env.EM_VERSION }}-rev${{ env.OPENCV_CACHE_VERSION }}
137144

138145
- name: Build OpenCvSharpExtern
139146
run: |

0 commit comments

Comments
 (0)