gen_descriptor: fix empty baseline_m (arm) -> cxxflags={,"-w"} lua sy… #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # TEMP spike: capture a windows-x86_64 compat.opencv config snapshot on a real | |
| # windows-latest runner using clang-cl (mcpp's windows toolchain is clang targeting | |
| # the MSVC ABI; OpenCV emits GCC-style -mavx2 SIMD flags under CV_CLANG even with | |
| # clang-cl -> mcpp-compatible). CORE profile first (core/imgproc/imgcodecs/highgui, | |
| # headless via WITH_WIN32UI=OFF, WITH_FFMPEG=OFF) to isolate the make-or-break | |
| # question: does mcpp clang-MSVC compile OpenCV's C++ from a clang-cl snapshot. | |
| # videoio+FFmpeg is a follow-up. Uploads the descriptor AND raw artifacts. | |
| name: snapshot-windows-opencv | |
| on: { workflow_dispatch: {}, push: { branches: [feat/opencv-windows-videoio, feat/opencv-full-func] } } | |
| jobs: | |
| snapshot: | |
| runs-on: windows-latest | |
| timeout-minutes: 90 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ilammy/msvc-dev-cmd@v1 # MSVC SDK headers/libs for clang-cl + cl.exe | |
| - uses: msys2/setup-msys2@v2 # make + pkg-config for the ffmpeg prefix build | |
| with: { msystem: UCRT64, install: 'make diffutils tar pkgconf', path-type: inherit } | |
| - name: tools (llvm/clang-cl, nasm, ninja) | |
| shell: pwsh | |
| run: | | |
| choco install -y --no-progress nasm ninja llvm pkgconfiglite | Out-Null | |
| echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 | |
| echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 | |
| # pkgconfiglite installs pkg-config.exe to the choco bin — put it on the | |
| # NATIVE windows PATH so cmake's find_package(PkgConfig) sets PKG_CONFIG_FOUND | |
| echo "C:\ProgramData\chocolatey\bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 | |
| Get-Command pkg-config | Select-Object -ExpandProperty Source | |
| - name: build shared FFmpeg 8.1.2 prefix (MSVC) for cmake videoio discovery | |
| shell: msys2 {0} | |
| run: | | |
| set -eux | |
| curl -L -fsS -o ffmpeg.tar.gz https://ffmpeg.org/releases/ffmpeg-8.1.2.tar.gz | |
| echo "32faba5ef67340d54724941eae1425580791195312a4fd13bf6f820a2818bf22 ffmpeg.tar.gz" | sha256sum -c - | |
| tar -xzf ffmpeg.tar.gz | |
| mkdir ffbuild && cd ffbuild | |
| # windows path prefix so the generated .pc / clang-cl consumption use C:/… not /c/… | |
| PFX="C:/ffprefix" | |
| ../ffmpeg-8.1.2/configure --toolchain=msvc --prefix="$PFX" \ | |
| --enable-shared --disable-static --disable-programs --disable-doc \ | |
| --disable-autodetect --disable-network >cfg.log 2>&1 \ | |
| && echo "FFMPEG CONFIGURE OK" || { echo FAIL; tail -30 cfg.log; exit 1; } | |
| make -j"$(nproc)" >/dev/null 2>&1 && make install | |
| echo "FFPREFIX=$PFX" >> "$GITHUB_ENV" | |
| ls "$PFX/lib/pkgconfig" || true | |
| - name: probe toolchain | |
| shell: bash | |
| run: | | |
| set -eux | |
| which clang-cl cmake ninja nasm | |
| clang-cl --version | |
| - name: fetch + extract OpenCV 5.0.0 | |
| shell: bash | |
| run: | | |
| set -eux | |
| curl -L -fsS -o opencv.tar.gz https://github.com/opencv/opencv/archive/refs/tags/5.0.0.tar.gz | |
| echo "b0528f5a1d379d59d4701cb28c36e22214cc51cf64594e5b56f2d3e6c0233095 opencv.tar.gz" | sha256sum -c - | |
| tar -xzf opencv.tar.gz | |
| echo "OPENCV_SRC=$PWD/opencv-5.0.0" >> "$GITHUB_ENV" | |
| # Instrument detect_ffmpeg.cmake: at the very end (after ocv_add_external_target), | |
| # confirm the FindFFMPEG shim drove HAVE_FFMPEG=TRUE and the ocv.3rdparty.ffmpeg | |
| # INTERFACE target got created — that target (not HAVE_FFMPEG itself) is what | |
| # videoio/CMakeLists.txt line 161 gates cap_ffmpeg.cpp on. | |
| DF="$PWD/opencv-5.0.0/modules/videoio/cmake/detect_ffmpeg.cmake" | |
| { | |
| echo '' | |
| echo 'message(STATUS "mcpp-dbg: HAVE_FFMPEG=[${HAVE_FFMPEG}] FFMPEG_FOUND=[${FFMPEG_FOUND}]")' | |
| echo 'message(STATUS "mcpp-dbg: versions avcodec=[${FFMPEG_libavcodec_VERSION}] avformat=[${FFMPEG_libavformat_VERSION}] avutil=[${FFMPEG_libavutil_VERSION}] swscale=[${FFMPEG_libswscale_VERSION}]")' | |
| echo 'message(STATUS "mcpp-dbg: FFMPEG_INCLUDE_DIRS=[${FFMPEG_INCLUDE_DIRS}] FFMPEG_LIBRARIES=[${FFMPEG_LIBRARIES}]")' | |
| echo 'if(TARGET ocv.3rdparty.ffmpeg)' | |
| echo ' message(STATUS "mcpp-dbg: TARGET ocv.3rdparty.ffmpeg CREATED -> cap_ffmpeg.cpp will compile")' | |
| echo 'else()' | |
| echo ' message(STATUS "mcpp-dbg: TARGET ocv.3rdparty.ffmpeg MISSING -> cap_ffmpeg.cpp will NOT compile")' | |
| echo 'endif()' | |
| } >> "$DF" | |
| - name: cmake configure (clang-cl, +videoio via FindFFMPEG shim, headless) | |
| shell: bash | |
| run: | | |
| set -eux | |
| # OpenCV's pkg-config FFmpeg path is UNIX/MINGW-gated (never runs under clang-cl / | |
| # windows-MSVC), and forcing HAVE_FFMPEG at the END of detect_ffmpeg is too late: | |
| # ocv_add_external_target(ffmpeg) — which creates the ocv.3rdparty.ffmpeg target | |
| # that videoio gates cap_ffmpeg.cpp on — has already run/skipped. Use OpenCV's | |
| # sanctioned override OPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG + a FindFFMPEG.cmake | |
| # shim: find_package(FFMPEG) runs FIRST in detect_ffmpeg (line 9) → shim sets | |
| # FFMPEG_FOUND → HAVE_FFMPEG=TRUE → version gate passes (real versions) → build | |
| # check skipped → ocv_add_external_target creates the target → cap_ffmpeg compiles. | |
| export PKG_CONFIG_PATH="C:/ffprefix/lib/pkgconfig" | |
| VC=$(pkg-config --modversion libavcodec) | |
| VF=$(pkg-config --modversion libavformat) | |
| VU=$(pkg-config --modversion libavutil) | |
| VS=$(pkg-config --modversion libswscale) | |
| # best-effort import-lib discovery (MSVC shared build names them avcodec.lib etc., | |
| # in lib/ or bin/); non-fatal — the target is created from the includes alone and | |
| # the build check is skipped, so empty LIBS still compiles cap_ffmpeg.cpp. mcpp | |
| # links compat.ffmpeg (windows) at consume time regardless. | |
| echo "=== C:/ffprefix tree (lib + bin) ==="; ls -la C:/ffprefix/lib/ C:/ffprefix/bin/ 2>/dev/null | head -40 || true | |
| LIBS=$( { ls C:/ffprefix/lib/*.lib C:/ffprefix/bin/*.lib 2>/dev/null || true; } | sed 's#\\#/#g' | tr '\n' ';') | |
| echo "ffmpeg versions: avcodec=$VC avformat=$VF avutil=$VU swscale=$VS" | |
| echo "ffmpeg import libs: ${LIBS:-<none found — using includes-only target>}" | |
| mkdir -p cmakemods | |
| cat > cmakemods/FindFFMPEG.cmake <<CM | |
| # mcpp windows shim: report the MSVC-built shared FFmpeg 8.1.2 as found so OpenCV's | |
| # detect_ffmpeg sets HAVE_FFMPEG=TRUE and compiles cap_ffmpeg.cpp into videoio. The | |
| # libs/include here serve only the snapshot reference build; the mcpp consumer links | |
| # compat.ffmpeg (windows) instead (gen_descriptor strips these via FFMPEG_PREFIX). | |
| set(FFMPEG_FOUND TRUE) | |
| set(FFmpeg_FOUND TRUE) | |
| set(FFMPEG_INCLUDE_DIRS "C:/ffprefix/include") | |
| set(FFMPEG_LIBRARIES "${LIBS}") | |
| set(FFMPEG_libavcodec_VERSION ${VC}) | |
| set(FFMPEG_libavformat_VERSION ${VF}) | |
| set(FFMPEG_libavutil_VERSION ${VU}) | |
| set(FFMPEG_libswscale_VERSION ${VS}) | |
| message(STATUS "mcpp FindFFMPEG shim: FOUND (avcodec=${VC})") | |
| CM | |
| cmake -G Ninja -S "$OPENCV_SRC" -B bld \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl \ | |
| -DCMAKE_MODULE_PATH="$(cygpath -m "$PWD/cmakemods")" \ | |
| -DBUILD_LIST=core,imgproc,imgcodecs,highgui,videoio,dnn \ | |
| -DBUILD_SHARED_LIBS=OFF -DBUILD_ZLIB=ON -DBUILD_PNG=ON -DBUILD_JPEG=ON \ | |
| -DENABLE_LIBJPEG_TURBO_SIMD=OFF \ | |
| -DWITH_FFMPEG=ON -DOPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG \ | |
| -DOPENCV_FFMPEG_SKIP_DOWNLOAD=ON -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON \ | |
| -DOPENCV_FFMPEG_ENABLE_LIBAVDEVICE=OFF \ | |
| -DWITH_WIN32UI=OFF -DWITH_DSHOW=OFF -DWITH_MSMF=OFF -DWITH_MSMF_DXVA=OFF \ | |
| -DWITH_TIFF=OFF -DWITH_WEBP=OFF -DWITH_OPENJPEG=OFF -DWITH_JASPER=OFF \ | |
| -DWITH_OPENEXR=OFF -DWITH_AVIF=OFF -DWITH_JPEGXL=OFF -DWITH_IMGCODEC_GIF=OFF \ | |
| -DWITH_OPENCL=OFF -DWITH_IPP=OFF -DWITH_LAPACK=OFF -DWITH_EIGEN=OFF -DWITH_ITT=OFF \ | |
| -DWITH_QT=OFF -DWITH_OPENGL=OFF -DWITH_GSTREAMER=OFF \ | |
| -DWITH_OBSENSOR=OFF -DWITH_PROTOBUF=ON -DBUILD_PROTOBUF=ON -DWITH_CAROTENE=OFF -DWITH_FLATBUFFERS=OFF \ | |
| -DWITH_KLEIDICV=OFF -DWITH_NDSRVP=OFF -DWITH_HAL_RVV=OFF \ | |
| -DWITH_UNIFONT=OFF -DWITH_ADE=OFF \ | |
| -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_EXAMPLES=OFF \ | |
| -DBUILD_opencv_apps=OFF -DBUILD_JAVA=OFF -DBUILD_opencv_python3=OFF 2>&1 | tee cfg_out.txt | tail -60 | |
| echo "=== mcpp-dbg (detect_ffmpeg: HAVE_FFMPEG + ocv.3rdparty.ffmpeg target) ===" | |
| grep -a "mcpp-dbg\|mcpp FindFFMPEG" cfg_out.txt || echo "(no mcpp-dbg — detect_ffmpeg didn't reach the tail)" | |
| echo "=== FFmpeg cmake cache vars ===" | |
| grep -iE "FFMPEG" bld/CMakeCache.txt | head -20 || true | |
| - name: reference build (materialize generators) + dump commands | |
| shell: bash | |
| run: | | |
| ninja -C bld -k 0 > bld/ninja-build.log 2>&1 || true | |
| ninja -C bld -t commands > bld/ninja-cmds.log | |
| echo "=== videoio FFmpeg backend active? (cap_ffmpeg must compile) ===" | |
| 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" | |
| echo "=== windows cvconfig facts ===" | |
| grep -E "HAVE_WIN32UI|WIN32|HAVE_OPENCV_HIGHGUI|BUILTIN_BACKEND" bld/cvconfig.h bld/*highgui* 2>/dev/null | head || true | |
| echo "=== SIMD dispatch TUs present? ===" | |
| grep -oE '\.(avx[0-9_a-z]*|sse4_[12]|fp16|neon[a-z0-9_]*)\.cpp' bld/ninja-cmds.log | sort | uniq -c || true | |
| echo "=== SIMD flag style (-mavx expected, NOT /arch) ===" | |
| grep -oE '(\-mavx[0-9]*|/arch:[A-Z0-9]+)' bld/ninja-cmds.log | sort | uniq -c || true | |
| - name: gen descriptor (relabel linux->windows; raw artifacts uploaded regardless) | |
| shell: bash | |
| run: | | |
| set -eux | |
| # FFMPEG_PREFIX: gen_descriptor excludes these include dirs (served by the | |
| # compat.ffmpeg dependency) and emits the compat.ffmpeg dep line. | |
| FFMPEG_PREFIX="C:/ffprefix" python tools/compat-opencv/gen_descriptor.py \ | |
| "$OPENCV_SRC" bld 5.0.0 \ | |
| b0528f5a1d379d59d4701cb28c36e22214cc51cf64594e5b56f2d3e6c0233095 \ | |
| compat.opencv.wingen.lua || echo "gen_descriptor needs windows tweaks — raw artifacts uploaded for local iteration" | |
| if [ -f compat.opencv.wingen.lua ]; then | |
| # relabel linux->windows (xpm key + per-OS block) and drop linux ldflags | |
| # (-lpthread/-ldl don't exist on windows; the build spike surfaces any | |
| # real LNK deps, added back per-OS afterwards). | |
| sed -e 's/^ linux = {/ windows = {/' \ | |
| -e 's/name = "compat.opencv"/name = "compat.opencvwin"/' \ | |
| -e 's/ldflags = { "-lpthread", "-ldl" }/ldflags = { "-lole32" }/' \ | |
| compat.opencv.wingen.lua > compat.opencvwin.lua || true | |
| echo "=== descriptor head ==="; head -50 compat.opencvwin.lua || true | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: opencv-windows-snapshot | |
| path: | | |
| compat.opencvwin.lua | |
| compat.opencv.wingen.lua | |
| bld/cvconfig.h | |
| bld/cv_cpu_config.h | |
| bld/ninja-cmds.log | |
| bld/ninja-build.log |