-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
245 lines (204 loc) · 10 KB
/
windows.yml
File metadata and controls
245 lines (204 loc) · 10 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: Windows Server 2025
on:
pull_request:
types: [synchronize, opened]
push:
branches:
- main
env:
OPENCV_VERSION: "4.13.0"
OPENCV_FILES_TAG: "4.13.0.20260207"
TESSERACT_RELEASE_VERSION: "2024.08.19"
jobs:
build-native:
name: build-native (${{ matrix.arch }})
runs-on: windows-2025
strategy:
matrix:
include:
- arch: x64
vcxproj_platform: x64
ffmpeg_dll_src: opencv_files/opencv_win_x64/x64/vc17/bin/opencv_videoio_ffmpeg4130_64.dll
- arch: x86
vcxproj_platform: Win32
ffmpeg_dll_src: opencv_files/opencv_win_x86/x86/vc17/bin/opencv_videoio_ffmpeg4130.dll
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
submodules: true
- name: Download OpenCV binaries
shell: powershell
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download --repo shimat/opencv_files ${env:OPENCV_FILES_TAG} --pattern "opencv_win_${{ matrix.arch }}.zip"
Expand-Archive -Path opencv_win_${{ matrix.arch }}.zip -DestinationPath opencv_files/opencv_win_${{ matrix.arch }} -Force -ErrorAction Stop
ls opencv_files/opencv_win_${{ matrix.arch }}
- name: Download Tesseract binaries
shell: powershell
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download --repo shimat/tesseract_vcpkg ${TESSERACT_RELEASE_VERSION} --pattern "*.zip" --output tesseract.zip
Expand-Archive -Path tesseract.zip -DestinationPath tesseract_files -Force -ErrorAction Stop
ls tesseract_files
Move-Item tesseract_files/tesseract_vcpkg.0.0.9-beta tesseract_files/tesseract_vcpkg
ls tesseract_files/tesseract_vcpkg
New-Item tesseract_files/tesseract_vcpkg -ItemType Directory -Force
Move-Item tesseract_files/tesseract_vcpkg/installed/* tesseract_files/tesseract_vcpkg/
ls tesseract_files/tesseract_vcpkg
- name: NuGet restore
shell: cmd
run: nuget restore
# Commented out: FFmpeg backend is included in opencv_videoio_ffmpeg DLLs
# If video tests fail, uncomment this step
#- name: Install Server-Media-Foundation
# shell: powershell
# run: |
# Install-WindowsFeature Server-Media-Foundation
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build ${{ matrix.arch }}
shell: cmd
run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=${{ matrix.arch }} -maxcpucount
- name: Build slim native runtime (${{ matrix.arch }})
shell: powershell
run: |
$ErrorActionPreference = "Stop"
# Compile OpenCvSharpExtern in "slim" mode by disabling selected wrapper modules.
# These NO_* macros are consumed by OpenCvSharpExtern headers.
$slimDefines = "/DNO_CONTRIB /DNO_STITCHING /DNO_VIDEO /DNO_VIDEOIO /DNO_HIGHGUI /DNO_DNN /DNO_ML /DNO_BARCODE"
$env:CL = "$slimDefines $env:CL"
# Keep slim outputs/intermediates separate from the full Release build artifacts.
$slimOut = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/${{ matrix.vcxproj_platform }}/"
$slimInt = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/obj/${{ matrix.vcxproj_platform }}/"
New-Item -Path $slimOut -ItemType Directory -Force | Out-Null
New-Item -Path $slimInt -ItemType Directory -Force | Out-Null
msbuild src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj `
/t:Rebuild `
/p:Configuration=Release `
/p:Platform=${{ matrix.vcxproj_platform }} `
/p:SolutionDir="${env:GITHUB_WORKSPACE}\\" `
/p:OutDir="$slimOut" `
/p:IntDir="$slimInt" `
/p:PostBuildEventUseInBuild=false `
/p:RunPostBuildEvent=Never `
-maxcpucount
$slimDll = Get-ChildItem "$slimOut" -Recurse -Filter OpenCvSharpExtern.dll | Select-Object -First 1
if (-not $slimDll) { throw "Failed to locate slim OpenCvSharpExtern.dll" }
Copy-Item $slimDll.FullName "src/Release/${{ matrix.vcxproj_platform }}/OpenCvSharpExtern.Slim.dll" -Force
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
- name: Install .NET x86
if: matrix.arch == 'x86'
shell: powershell
run: |
# setup-dotnet does not support architecture selection yet; install x86 runtime manually.
Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1
./dotnet-install.ps1 -Channel 8.0 -Architecture x86 -InstallDir "$env:ProgramFiles(x86)\dotnet"
"$env:ProgramFiles(x86)\dotnet" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Build managed libraries
if: matrix.arch == 'x64'
shell: cmd
run: |
dotnet build src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj -f net8.0 -p:configuration=Release -maxcpucount
dotnet build src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -f net8.0-windows -p:configuration=Release -maxcpucount
- name: Test
shell: powershell
run: |
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests
dotnet test -c Release -f net8.0 --runtime win-${{ matrix.arch }}
- name: Test Windows-only functions
shell: powershell
run: |
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.Windows
dotnet test -c Release -f net8.0-windows --runtime win-${{ matrix.arch }}
- name: Test Windows-only functions (net48)
shell: powershell
run: |
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.Windows
dotnet test -c Release -f net48 --runtime win-${{ matrix.arch }}
- name: Upload native DLLs
uses: actions/upload-artifact@v4
with:
name: native-dlls-${{ matrix.arch }}
path: |
src/Release/${{ matrix.vcxproj_platform }}/OpenCvSharpExtern.dll
src/Release/${{ matrix.vcxproj_platform }}/OpenCvSharpExtern.Slim.dll
${{ matrix.ffmpeg_dll_src }}
pack:
runs-on: windows-2025
needs: build-native
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
submodules: true
- name: Download x64 native DLLs
uses: actions/download-artifact@v4
with:
name: native-dlls-x64
path: native-dlls-x64
- name: Download x86 native DLLs
uses: actions/download-artifact@v4
with:
name: native-dlls-x86
path: native-dlls-x86
- name: Place DLLs in expected locations
shell: powershell
run: |
$ErrorActionPreference = "Stop"
New-Item -Path "src/Release/x64" -ItemType Directory -Force | Out-Null
New-Item -Path "src/Release/Win32" -ItemType Directory -Force | Out-Null
New-Item -Path "opencv_files/opencv_win_x64/x64/vc17/bin" -ItemType Directory -Force | Out-Null
New-Item -Path "opencv_files/opencv_win_x86/x86/vc17/bin" -ItemType Directory -Force | Out-Null
# Full and slim DLLs
Copy-Item "native-dlls-x64/src/Release/x64/OpenCvSharpExtern.dll" "src/Release/x64/" -Force
Copy-Item "native-dlls-x64/src/Release/x64/OpenCvSharpExtern.Slim.dll" "src/Release/x64/" -Force
Copy-Item "native-dlls-x86/src/Release/Win32/OpenCvSharpExtern.dll" "src/Release/Win32/" -Force
Copy-Item "native-dlls-x86/src/Release/Win32/OpenCvSharpExtern.Slim.dll" "src/Release/Win32/" -Force
# FFmpeg DLLs (required by runtime.win NuGet packages)
Copy-Item "native-dlls-x64/opencv_files/opencv_win_x64/x64/vc17/bin/opencv_videoio_ffmpeg4130_64.dll" `
"opencv_files/opencv_win_x64/x64/vc17/bin/" -Force
Copy-Item "native-dlls-x86/opencv_files/opencv_win_x86/x86/vc17/bin/opencv_videoio_ffmpeg4130.dll" `
"opencv_files/opencv_win_x86/x86/vc17/bin/" -Force
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
- name: Pack NuGet packages
shell: powershell
run: |
$ErrorActionPreference = "Stop"
$date = Get-Date -Format "yyyyMMdd"
$version = "${env:OPENCV_VERSION}.${date}-beta"
Write-Host "version = ${version}"
# Pack main libraries (dotnet pack triggers build implicitly)
dotnet pack src/OpenCvSharp/OpenCvSharp.csproj -c Release -o artifacts -p:Version=$version
dotnet pack src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj -c Release -o artifacts -p:Version=$version
dotnet pack src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -c Release -o artifacts -p:Version=$version
# Pack runtime packages
dotnet pack nuget/OpenCvSharp4.runtime.win.csproj -o artifacts -p:Version=$version
dotnet pack nuget/OpenCvSharp4.runtime.win.slim.csproj -o artifacts -p:Version=$version
# Add local artifacts as NuGet source for meta-package
dotnet nuget add source "${env:GITHUB_WORKSPACE}\artifacts" --name LocalPackages
# Pack meta-package (depends on packages built above)
dotnet pack nuget/OpenCvSharp4.Windows.csproj -o artifacts -p:Version=$version -p:PackageVersion=$version
dotnet pack nuget/OpenCvSharp4.Windows.Slim.csproj -o artifacts -p:Version=$version -p:PackageVersion=$version
- name: Run ReleaseMaker
shell: powershell
run: |
cd "${env:GITHUB_WORKSPACE}\tool\OpenCvSharp.ReleaseMaker"
dotnet run -c Release --runtime win-x64 -- "${env:GITHUB_WORKSPACE}" "${env:GITHUB_WORKSPACE}\artifacts" ${{env.OPENCV_VERSION}}
- name: Upload NuGet packages and Release packages
uses: actions/upload-artifact@v6
with:
name: packages_windows
path: ${{ github.workspace }}\artifacts