-
-
Notifications
You must be signed in to change notification settings - Fork 875
220 lines (189 loc) · 8.64 KB
/
build-windows.yml
File metadata and controls
220 lines (189 loc) · 8.64 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
name: Build Windows
on:
workflow_call:
jobs:
build-windows:
runs-on: windows-2022
env:
buildDir: '${{ github.workspace }}\build\'
dependenciesDir: '${{ github.workspace }}\dependencies'
archivePath: '${{ github.workspace }}\dependencies\installed.zip'
BUILD_TYPE: Release
CTEST_OUTPUT_ON_FAILURE: 1
ALICEVISION_ROOT: '${{ github.workspace }}/install'
ALICEVISION_BUNDLE: ${{ github.workspace }}/install/bundle
ALICEVISION_LIBPATH: '${{ github.workspace }}/install/bundle/bin'
PYTHONPATH: '${{ github.workspace }}/install/bundle/lib/python'
SCCACHE_GHA_ENABLED: "true"
CUDA_ENV_FILE: '${{ github.workspace }}\cuda_env.txt'
steps:
# ---- PREPARE ENV -----
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Create Directories
run: |
New-Item -ItemType Directory -Force -Path "${{ env.dependenciesDir }}"
New-Item -ItemType Directory -Force -Path "${{ env.ALICEVISION_ROOT }}"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
# ---- CACHES ----
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~\AppData\Local\pip\Cache
key: pip-${{ runner.os }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-${{ runner.os }}-
- name: Cache vcpkg prebuilt binaries
id: cache-vcpkg
uses: actions/cache@v4
with:
path: ${{ env.dependenciesDir }}\x64-windows-release
key: vcpkg-${{ runner.os }}-${{ env.VCPKG_VERSION }}
- name: Cache CUDA Toolkit
id: cache-cuda
uses: actions/cache@v4
with:
path: |
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\BuildCustomizations
${{ env.CUDA_ENV_FILE }}
key: cuda-${{ runner.os }}-${{ env.CUDA_VERSION }}
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
# ---- REQUIREMENTS -----
- name: Install Python requirements
run: |
pip install -r requirements.txt
- name: Download zip file with prebuilt binaries
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: |
Invoke-WebRequest -Uri "https://github.com/alicevision/vcpkg/releases/download/2026.03.11/x64-windows-release.zip" -OutFile "${{ env.archivePath }}"
- name: vcpkg - Unzip prebuilt binaries
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: |
tar -xvzf "${{ env.archivePath }}" -C "${{ env.dependenciesDir }}"
- name: vcpkg - Remove zip file with prebuilt binaries
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: |
rm ${{ env.archivePath }}
- name: Get CUDA Toolkit
if: steps.cache-cuda.outputs.cache-hit != 'true'
uses: Jimver/cuda-toolkit@v0.2.30
id: cuda-toolkit
with:
cuda: '12.8.0'
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "cusparse", "npp", "npp_dev", "cufft", "cufft_dev", "visual_studio_integration"]'
- name: Save CUDA path metadata
if: steps.cache-cuda.outputs.cache-hit != 'true'
shell: pwsh
run: |
$nvccCommand = Get-Command nvcc -ErrorAction SilentlyContinue
if (!$nvccCommand) {
throw "nvcc not found in PATH"
}
$nvccPath = $nvccCommand.Source
if (!(Test-Path $nvccPath)) {
throw "nvcc.exe not found at $nvccPath"
}
$cudaRoot = Split-Path (Split-Path $nvccPath -Parent) -Parent
"CUDA_PATH=$cudaRoot" | Out-File -FilePath "${{ env.CUDA_ENV_FILE }}" -Encoding utf8
"CUDACXX=$nvccPath" | Out-File -FilePath "${{ env.CUDA_ENV_FILE }}" -Encoding utf8 -Append
- name: Configure CUDA environment
shell: pwsh
run: |
if (!(Test-Path "${{ env.CUDA_ENV_FILE }}")) {
throw "CUDA metadata file not found: ${{ env.CUDA_ENV_FILE }}"
}
Get-Content "${{ env.CUDA_ENV_FILE }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$cudaRoot = (Get-Content "${{ env.CUDA_ENV_FILE }}" | Where-Object { $_ -like "CUDA_PATH=*" } | Select-Object -First 1).Split("=", 2)[1]
if (!(Test-Path "$cudaRoot\bin\nvcc.exe")) {
throw "nvcc.exe not found at $cudaRoot\bin\nvcc.exe"
}
"$cudaRoot\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- uses: lukka/get-cmake@latest
# ------ BUILD -----
- name: Build
uses: lukka/run-cmake@v3
with:
cmakeBuildType: Release
buildWithCMake: true
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
buildDirectory: ${{ env.buildDir }}
buildWithCMakeArgs: '--config Release --target install --parallel ${{ env.NUM_CORES }}'
cmakeAppendedArgs: -DCMAKE_TOOLCHAIN_FILE=${{ env.dependenciesDir }}\x64-windows-release\scripts\buildsystems\vcpkg.cmake
-DVCPKG_TARGET_TRIPLET=x64-windows-release
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
-G "Ninja Multi-Config"
-DBUILD_SHARED_LIBS=ON
-DTARGET_ARCHITECTURE=core
-DCMAKE_INSTALL_PREFIX=${{ env.ALICEVISION_ROOT }}
-DALICEVISION_BUNDLE_PREFIX:PATH=${{ env.ALICEVISION_BUNDLE }}
-DALICEVISION_BUILD_TESTS=ON
-DALICEVISION_USE_OPENCV=ON
-DALICEVISION_USE_CUDA=ON
-DALICEVISION_USE_CCTAG=OFF
-DALICEVISION_USE_POPSIFT=OFF
-DALICEVISION_USE_ALEMBIC=ON
-DALICEVISION_BUILD_PHOTOMETRICSTEREO=OFF
-DALICEVISION_BUILD_SEGMENTATION=OFF
-DALICEVISION_BUILD_SWIG_BINDING=ON
-DALICEVISION_INSTALL_MESHROOM_PLUGIN=OFF
-DBOOST_NO_CXX11=ON
-DVCPKG_MANIFEST_MODE=OFF
-DPython3_EXECUTABLE=${{ env.Python3_ROOT_DIR }}\python.exe
-DCMAKE_C_COMPILER_LAUNCHER=sccache
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
- name: Bundle
uses: lukka/run-cmake@v3
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
buildDirectory: ${{ env.buildDir }}
buildWithCMakeArgs: '--config Release --target bundle --parallel ${{ env.NUM_CORES }}'
cmakeAppendedArgs: -DBUNDLE_INSTALL_PREFIX:PATH=${{ env.ALICEVISION_BUNDLE }}
cmakeBuildType: Release
buildWithCMake: true
# ------ TESTS ------
- name: Python Binding - Unit Tests
run: |
python -m pytest ./pyTests
- name: Unit Tests
uses: lukka/run-cmake@v3
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
buildDirectory: ${{ env.buildDir }}
buildWithCMakeArgs: '--config Release --target test'
cmakeAppendedArgs: -DCMAKE_INSTALL_PREFIX:PATH=${{ env.ALICEVISION_ROOT }}
cmakeBuildType: Release
useVcpkgToolchainFile: true
buildWithCMake: true
# ── Archive & upload for nightly release ────────
# Only runs when called from nightly.yml; skipped on regular CI.
- name: Create archive
if: github.workflow == 'Nightly'
id: archive
shell: pwsh
run: |
$commitShort = (git rev-parse --short=8 HEAD).Trim()
$date = (Get-Date -Format "yyyyMMdd")
$archive = "AliceVision-nightly-${date}-${commitShort}-windows.zip"
Compress-Archive -Path "$env:ALICEVISION_BUNDLE\*" -DestinationPath $archive
echo "filename=$archive" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Upload archive artifact
if: github.workflow == 'Nightly'
uses: actions/upload-artifact@v4
with:
name: windows-package
path: ${{ steps.archive.outputs.filename }}
retention-days: 3