66# question: does mcpp clang-MSVC compile OpenCV's C++ from a clang-cl snapshot.
77# videoio+FFmpeg is a follow-up. Uploads the descriptor AND raw artifacts.
88name : snapshot-windows-opencv
9- on : { workflow_dispatch: {}, push: { branches: [spike /opencv-windows-snapshot ] } }
9+ on : { workflow_dispatch: {}, push: { branches: [feat /opencv-windows-videoio, feat/opencv-full-func ] } }
1010jobs :
1111 snapshot :
1212 runs-on : windows-latest
1313 timeout-minutes : 90
1414 steps :
1515 - uses : actions/checkout@v4
16- - uses : ilammy/msvc-dev-cmd@v1 # MSVC SDK headers/libs for clang-cl
16+ - uses : ilammy/msvc-dev-cmd@v1 # MSVC SDK headers/libs for clang-cl + cl.exe
17+ - uses : msys2/setup-msys2@v2 # make + pkg-config for the ffmpeg prefix build
18+ with : { msystem: UCRT64, install: 'make diffutils tar pkgconf', path-type: inherit }
1719 - name : tools (llvm/clang-cl, nasm, ninja)
1820 shell : pwsh
1921 run : |
20- choco install -y --no-progress nasm ninja llvm | Out-Null
22+ choco install -y --no-progress nasm ninja llvm pkgconfiglite | Out-Null
2123 echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
2224 echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
25+ # pkgconfiglite installs pkg-config.exe to the choco bin — put it on the
26+ # NATIVE windows PATH so cmake's find_package(PkgConfig) sets PKG_CONFIG_FOUND
27+ echo "C:\ProgramData\chocolatey\bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
28+ Get-Command pkg-config | Select-Object -ExpandProperty Source
29+ - name : build shared FFmpeg 8.1.2 prefix (MSVC) for cmake videoio discovery
30+ shell : msys2 {0}
31+ run : |
32+ set -eux
33+ curl -L -fsS -o ffmpeg.tar.gz https://ffmpeg.org/releases/ffmpeg-8.1.2.tar.gz
34+ echo "32faba5ef67340d54724941eae1425580791195312a4fd13bf6f820a2818bf22 ffmpeg.tar.gz" | sha256sum -c -
35+ tar -xzf ffmpeg.tar.gz
36+ mkdir ffbuild && cd ffbuild
37+ # windows path prefix so the generated .pc / clang-cl consumption use C:/… not /c/…
38+ PFX="C:/ffprefix"
39+ ../ffmpeg-8.1.2/configure --toolchain=msvc --prefix="$PFX" \
40+ --enable-shared --disable-static --disable-programs --disable-doc \
41+ --disable-autodetect --disable-network >cfg.log 2>&1 \
42+ && echo "FFMPEG CONFIGURE OK" || { echo FAIL; tail -30 cfg.log; exit 1; }
43+ make -j"$(nproc)" >/dev/null 2>&1 && make install
44+ echo "FFPREFIX=$PFX" >> "$GITHUB_ENV"
45+ ls "$PFX/lib/pkgconfig" || true
2346 - name : probe toolchain
2447 shell : bash
2548 run : |
@@ -34,31 +57,94 @@ jobs:
3457 echo "b0528f5a1d379d59d4701cb28c36e22214cc51cf64594e5b56f2d3e6c0233095 opencv.tar.gz" | sha256sum -c -
3558 tar -xzf opencv.tar.gz
3659 echo "OPENCV_SRC=$PWD/opencv-5.0.0" >> "$GITHUB_ENV"
37- - name : cmake configure (clang-cl, headless core, hermetic)
60+ # Instrument detect_ffmpeg.cmake: at the very end (after ocv_add_external_target),
61+ # confirm the FindFFMPEG shim drove HAVE_FFMPEG=TRUE and the ocv.3rdparty.ffmpeg
62+ # INTERFACE target got created — that target (not HAVE_FFMPEG itself) is what
63+ # videoio/CMakeLists.txt line 161 gates cap_ffmpeg.cpp on.
64+ DF="$PWD/opencv-5.0.0/modules/videoio/cmake/detect_ffmpeg.cmake"
65+ {
66+ echo ''
67+ echo 'message(STATUS "mcpp-dbg: HAVE_FFMPEG=[${HAVE_FFMPEG}] FFMPEG_FOUND=[${FFMPEG_FOUND}]")'
68+ echo 'message(STATUS "mcpp-dbg: versions avcodec=[${FFMPEG_libavcodec_VERSION}] avformat=[${FFMPEG_libavformat_VERSION}] avutil=[${FFMPEG_libavutil_VERSION}] swscale=[${FFMPEG_libswscale_VERSION}]")'
69+ echo 'message(STATUS "mcpp-dbg: FFMPEG_INCLUDE_DIRS=[${FFMPEG_INCLUDE_DIRS}] FFMPEG_LIBRARIES=[${FFMPEG_LIBRARIES}]")'
70+ echo 'if(TARGET ocv.3rdparty.ffmpeg)'
71+ echo ' message(STATUS "mcpp-dbg: TARGET ocv.3rdparty.ffmpeg CREATED -> cap_ffmpeg.cpp will compile")'
72+ echo 'else()'
73+ echo ' message(STATUS "mcpp-dbg: TARGET ocv.3rdparty.ffmpeg MISSING -> cap_ffmpeg.cpp will NOT compile")'
74+ echo 'endif()'
75+ } >> "$DF"
76+ - name : cmake configure (clang-cl, +videoio via FindFFMPEG shim, headless)
3877 shell : bash
3978 run : |
4079 set -eux
80+ # OpenCV's pkg-config FFmpeg path is UNIX/MINGW-gated (never runs under clang-cl /
81+ # windows-MSVC), and forcing HAVE_FFMPEG at the END of detect_ffmpeg is too late:
82+ # ocv_add_external_target(ffmpeg) — which creates the ocv.3rdparty.ffmpeg target
83+ # that videoio gates cap_ffmpeg.cpp on — has already run/skipped. Use OpenCV's
84+ # sanctioned override OPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG + a FindFFMPEG.cmake
85+ # shim: find_package(FFMPEG) runs FIRST in detect_ffmpeg (line 9) → shim sets
86+ # FFMPEG_FOUND → HAVE_FFMPEG=TRUE → version gate passes (real versions) → build
87+ # check skipped → ocv_add_external_target creates the target → cap_ffmpeg compiles.
88+ export PKG_CONFIG_PATH="C:/ffprefix/lib/pkgconfig"
89+ VC=$(pkg-config --modversion libavcodec)
90+ VF=$(pkg-config --modversion libavformat)
91+ VU=$(pkg-config --modversion libavutil)
92+ VS=$(pkg-config --modversion libswscale)
93+ # best-effort import-lib discovery (MSVC shared build names them avcodec.lib etc.,
94+ # in lib/ or bin/); non-fatal — the target is created from the includes alone and
95+ # the build check is skipped, so empty LIBS still compiles cap_ffmpeg.cpp. mcpp
96+ # links compat.ffmpeg (windows) at consume time regardless.
97+ echo "=== C:/ffprefix tree (lib + bin) ==="; ls -la C:/ffprefix/lib/ C:/ffprefix/bin/ 2>/dev/null | head -40 || true
98+ LIBS=$( { ls C:/ffprefix/lib/*.lib C:/ffprefix/bin/*.lib 2>/dev/null || true; } | sed 's#\\#/#g' | tr '\n' ';')
99+ echo "ffmpeg versions: avcodec=$VC avformat=$VF avutil=$VU swscale=$VS"
100+ echo "ffmpeg import libs: ${LIBS:-<none found — using includes-only target>}"
101+ mkdir -p cmakemods
102+ cat > cmakemods/FindFFMPEG.cmake <<CM
103+ # mcpp windows shim: report the MSVC-built shared FFmpeg 8.1.2 as found so OpenCV's
104+ # detect_ffmpeg sets HAVE_FFMPEG=TRUE and compiles cap_ffmpeg.cpp into videoio. The
105+ # libs/include here serve only the snapshot reference build; the mcpp consumer links
106+ # compat.ffmpeg (windows) instead (gen_descriptor strips these via FFMPEG_PREFIX).
107+ set(FFMPEG_FOUND TRUE)
108+ set(FFmpeg_FOUND TRUE)
109+ set(FFMPEG_INCLUDE_DIRS "C:/ffprefix/include")
110+ set(FFMPEG_LIBRARIES "${LIBS}")
111+ set(FFMPEG_libavcodec_VERSION ${VC})
112+ set(FFMPEG_libavformat_VERSION ${VF})
113+ set(FFMPEG_libavutil_VERSION ${VU})
114+ set(FFMPEG_libswscale_VERSION ${VS})
115+ message(STATUS "mcpp FindFFMPEG shim: FOUND (avcodec=${VC})")
116+ CM
41117 cmake -G Ninja -S "$OPENCV_SRC" -B bld \
42118 -DCMAKE_BUILD_TYPE=Release \
43119 -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl \
44- -DBUILD_LIST=core,imgproc,imgcodecs,highgui \
120+ -DCMAKE_MODULE_PATH="$(cygpath -m "$PWD/cmakemods")" \
121+ -DBUILD_LIST=core,imgproc,imgcodecs,highgui,videoio,dnn \
45122 -DBUILD_SHARED_LIBS=OFF -DBUILD_ZLIB=ON -DBUILD_PNG=ON -DBUILD_JPEG=ON \
46123 -DENABLE_LIBJPEG_TURBO_SIMD=OFF \
124+ -DWITH_FFMPEG=ON -DOPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG \
125+ -DOPENCV_FFMPEG_SKIP_DOWNLOAD=ON -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON \
126+ -DOPENCV_FFMPEG_ENABLE_LIBAVDEVICE=OFF \
47127 -DWITH_WIN32UI=OFF -DWITH_DSHOW=OFF -DWITH_MSMF=OFF -DWITH_MSMF_DXVA=OFF \
48128 -DWITH_TIFF=OFF -DWITH_WEBP=OFF -DWITH_OPENJPEG=OFF -DWITH_JASPER=OFF \
49129 -DWITH_OPENEXR=OFF -DWITH_AVIF=OFF -DWITH_JPEGXL=OFF -DWITH_IMGCODEC_GIF=OFF \
50130 -DWITH_OPENCL=OFF -DWITH_IPP=OFF -DWITH_LAPACK=OFF -DWITH_EIGEN=OFF -DWITH_ITT=OFF \
51- -DWITH_QT=OFF -DWITH_OPENGL=OFF -DWITH_FFMPEG=OFF - DWITH_GSTREAMER=OFF \
52- -DWITH_OBSENSOR=OFF -DWITH_PROTOBUF=OFF -DWITH_CAROTENE=OFF -DWITH_FLATBUFFERS=OFF \
131+ -DWITH_QT=OFF -DWITH_OPENGL=OFF -DWITH_GSTREAMER=OFF \
132+ -DWITH_OBSENSOR=OFF -DWITH_PROTOBUF=ON -DBUILD_PROTOBUF=ON -DWITH_CAROTENE=OFF -DWITH_FLATBUFFERS=OFF \
53133 -DWITH_KLEIDICV=OFF -DWITH_NDSRVP=OFF -DWITH_HAL_RVV=OFF \
54134 -DWITH_UNIFONT=OFF -DWITH_ADE=OFF \
55135 -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_EXAMPLES=OFF \
56- -DBUILD_opencv_apps=OFF -DBUILD_JAVA=OFF -DBUILD_opencv_python3=OFF 2>&1 | tail -40
136+ -DBUILD_opencv_apps=OFF -DBUILD_JAVA=OFF -DBUILD_opencv_python3=OFF 2>&1 | tee cfg_out.txt | tail -60
137+ echo "=== mcpp-dbg (detect_ffmpeg: HAVE_FFMPEG + ocv.3rdparty.ffmpeg target) ==="
138+ grep -a "mcpp-dbg\|mcpp FindFFMPEG" cfg_out.txt || echo "(no mcpp-dbg — detect_ffmpeg didn't reach the tail)"
139+ echo "=== FFmpeg cmake cache vars ==="
140+ grep -iE "FFMPEG" bld/CMakeCache.txt | head -20 || true
57141 - name : reference build (materialize generators) + dump commands
58142 shell : bash
59143 run : |
60144 ninja -C bld -k 0 > bld/ninja-build.log 2>&1 || true
61145 ninja -C bld -t commands > bld/ninja-cmds.log
146+ echo "=== videoio FFmpeg backend active? (cap_ffmpeg must compile) ==="
147+ grep -q cap_ffmpeg bld/ninja-cmds.log && echo "cap_ffmpeg: YES ($(grep -c cap_ffmpeg bld/ninja-cmds.log) TUs)" || echo "FATAL: cap_ffmpeg not compiled — FFmpeg videoio backend inactive"
62148 echo "=== windows cvconfig facts ==="
63149 grep -E "HAVE_WIN32UI|WIN32|HAVE_OPENCV_HIGHGUI|BUILTIN_BACKEND" bld/cvconfig.h bld/*highgui* 2>/dev/null | head || true
64150 echo "=== SIMD dispatch TUs present? ==="
69155 shell : bash
70156 run : |
71157 set -eux
72- python tools/compat-opencv/gen_descriptor.py \
158+ # FFMPEG_PREFIX: gen_descriptor excludes these include dirs (served by the
159+ # compat.ffmpeg dependency) and emits the compat.ffmpeg dep line.
160+ FFMPEG_PREFIX="C:/ffprefix" python tools/compat-opencv/gen_descriptor.py \
73161 "$OPENCV_SRC" bld 5.0.0 \
74162 b0528f5a1d379d59d4701cb28c36e22214cc51cf64594e5b56f2d3e6c0233095 \
75163 compat.opencv.wingen.lua || echo "gen_descriptor needs windows tweaks — raw artifacts uploaded for local iteration"
0 commit comments