Build ffmpeg-master #91
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
| env: | |
| MSYS2_PATH_TYPE: inherit | |
| SDK_VER: 10.0.22621.0 | |
| REF_NAME: ${{ inputs.ref_name||github.ref_name }} | |
| name: Build | |
| run-name: Build ${{inputs.ref_name||github.ref_name}} | |
| on: | |
| push: | |
| branches: | |
| - ffmpeg-master | |
| workflow_call: | |
| inputs: | |
| ref_name: | |
| description: "Tag" | |
| required: false | |
| type: string | |
| release_name: | |
| description: "Custom release name" | |
| required: false | |
| type: string | |
| changelog: | |
| description: "Custom changelog content" | |
| required: false | |
| type: string | |
| jobs: | |
| prepare: | |
| uses: ./.github/workflows/cache.yml | |
| with: | |
| ref_name: ${{inputs.ref_name||github.ref_name}} | |
| build: | |
| needs: prepare | |
| strategy: | |
| matrix: | |
| arch: [amd64, arm64] | |
| fail-fast: false | |
| runs-on: windows-2022 | |
| env: | |
| name: ffmpeg-${{ inputs.ref_name||github.ref_name }}-gpl-${{matrix.arch}}-static | |
| release_name: ffmpeg-gpl-${{matrix.arch}}-static | |
| target: ${{contains(matrix.arch,'arm')&&format('amd64_{0}',matrix.arch)||matrix.arch}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{env.REF_NAME}} | |
| # submodules: recursive | |
| - name: Setup Env | |
| shell: bash | |
| id: setup | |
| run: | | |
| echo "installationPath=$(vswhere -all -legacy -property installationPath)">>$GITHUB_OUTPUT | |
| # KEY=$(git ls-tree -r ${{env.REF_NAME}}|grep ^160000|sort -d|md5sum|cut -d' ' -f1) | |
| # echo "cache-key=$KEY" >>$GITHUB_OUTPUT | |
| - name: Restore cached submodules | |
| id: cache-submodules-restore | |
| uses: actions/cache@v4 | |
| with: | |
| path: .git/modules | |
| # key: ${{ runner.os }}-${{steps.setup.outputs.cache-key}}-submodules | |
| key: ${{ needs.prepare.outputs.cache-key }} | |
| - name: Pull submodules | |
| shell: bash | |
| run: | | |
| git submodule update --init --recursive --depth 1 | |
| - uses: msys2/setup-msys2@v2 | |
| with: | |
| install: >- | |
| diffutils | |
| make | |
| zip | |
| pkgconf | |
| yasm | |
| nasm | |
| libtool | |
| bison | |
| automake | |
| autoconf | |
| quilt | |
| clang | |
| - name: Setup Python for Meson | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Install Meson and Ninja | |
| shell: cmd | |
| run: | | |
| pip install meson ninja | |
| - name: Install CUDA Toolkit | |
| if: matrix.arch == 'amd64' | |
| uses: N-Storm/cuda-toolkit@master | |
| id: cuda-toolkit | |
| with: | |
| cuda: "12.6.3" | |
| sub-packages: '["nvcc", "cudart", "npp_dev"]' | |
| - name: Test CUDA Installation | |
| if: matrix.arch == 'amd64' | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| echo CUDA Installation Check: | |
| echo ======================== | |
| echo CUDA_PATH: %CUDA_PATH% | |
| nvcc --version | findstr "release" | |
| echo. | |
| echo Directory Structure: | |
| echo =================== | |
| echo CUDA root subdirectories: | |
| dir "%CUDA_PATH%" /b /ad | |
| echo. | |
| echo Checking for lib directory: | |
| if exist "%CUDA_PATH%\lib" ( | |
| echo lib directory found, contents: | |
| dir "%CUDA_PATH%\lib" /b /ad | |
| ) | |
| echo. | |
| echo Searching for .lib files: | |
| dir "%CUDA_PATH%" /s /b 2>nul | findstr /i "\.lib$" | |
| echo. | |
| echo Searching for NPP headers: | |
| dir "%CUDA_PATH%" /s /b 2>nul | findstr /i "npp.*\.h$" | |
| echo. | |
| echo NPP Libraries Check: | |
| if exist "%CUDA_PATH%\lib\x64\nppc.lib" ( | |
| echo nppc.lib: FOUND | |
| ) else ( | |
| echo nppc.lib: NOT FOUND | |
| ) | |
| if exist "%CUDA_PATH%\include\npp.h" ( | |
| echo npp.h: FOUND | |
| ) else ( | |
| echo npp.h: NOT FOUND | |
| ) | |
| echo. | |
| echo CUDA Compilation Test: | |
| echo __global__ void test() {} > test.cu | |
| nvcc -c test.cu -o test.obj | |
| if exist test.obj ( | |
| echo CUDA compilation test: PASSED | |
| del test.obj test.cu | |
| ) else ( | |
| echo CUDA compilation test: FAILED | |
| exit 1 | |
| ) | |
| - name: Remove MSYS2 link | |
| shell: msys2 {0} | |
| run: | | |
| rm $(which link) | |
| rm -rf /usr/local | |
| - name: Build OpenCL | |
| if: ${{ success() }} | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| REM Add MSYS2 tools to PATH | |
| set PATH=D:\a\_temp\msys64\usr\bin;%PATH% | |
| REM Build OpenCL headers | |
| echo Building OpenCL headers... | |
| cd opencl-headers | |
| if not exist build mkdir build | |
| cd build | |
| cmake .. -G "NMake Makefiles" ^ | |
| --install-prefix=D:\a\_temp\msys64\usr\local ^ | |
| -DCMAKE_BUILD_TYPE=Release ^ | |
| -DBUILD_TESTING=OFF | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cmake --build . --config Release | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cmake --install . --config Release | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cd ..\.. | |
| REM Build OpenCL ICD Loader | |
| echo Building OpenCL ICD Loader... | |
| cd opencl-icd-loader | |
| if not exist build mkdir build | |
| cd build | |
| cmake .. -G "NMake Makefiles" ^ | |
| --install-prefix=D:\a\_temp\msys64\usr\local ^ | |
| -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ | |
| -DCMAKE_BUILD_TYPE=Release ^ | |
| -DBUILD_SHARED_LIBS=OFF ^ | |
| -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^ | |
| -DOPENCL_ICD_LOADER_DISABLE_OPENCLON12=ON ^ | |
| -DOPENCL_ICD_LOADER_REQUIRE_WDK=OFF ^ | |
| -DOPENCL_ICD_LOADER_HEADERS_DIR=D:/a/_temp/msys64/usr/local/include ^ | |
| -DBUILD_TESTING=OFF | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cmake --build . --config Release | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cmake --install . --config Release | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cd ..\.. | |
| REM Create pkg-config file | |
| if not exist D:\a\_temp\msys64\usr\local\lib\pkgconfig mkdir D:\a\_temp\msys64\usr\local\lib\pkgconfig | |
| ( | |
| echo prefix=/usr/local | |
| echo exec_prefix=${prefix} | |
| echo libdir=${exec_prefix}/lib | |
| echo includedir=${prefix}/include | |
| echo. | |
| echo Name: OpenCL | |
| echo Description: OpenCL ICD Loader | |
| echo Version: 3.0 | |
| echo Libs: -L${libdir} -lOpenCL -ladvapi32 -lole32 -lcfgmgr32 | |
| echo Cflags: -I${includedir} | |
| ) > D:\a\_temp\msys64\usr\local\lib\pkgconfig\OpenCL.pc | |
| - name: Build shaderc | |
| if: ${{ success() }} | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| set PATH=D:\a\_temp\msys64\usr\bin;%PATH% | |
| echo Building shaderc... | |
| cd shaderc | |
| REM Use pinned top-level submodules instead of git-sync-deps (avoids dynamic fetches) | |
| if exist third_party\spirv-tools rd /s /q third_party\spirv-tools | |
| if exist third_party\spirv-headers rd /s /q third_party\spirv-headers | |
| if exist third_party\glslang rd /s /q third_party\glslang | |
| xcopy /E /I /Y /Q ..\spirv-tools third_party\spirv-tools | |
| xcopy /E /I /Y /Q ..\spirv-headers third_party\spirv-headers | |
| xcopy /E /I /Y /Q ..\glslang third_party\glslang | |
| REM Build shaderc libraries for target architecture | |
| if not exist build mkdir build | |
| cd build | |
| set CC=${{steps.setup.outputs.installationPath}}\VC\Tools\Llvm\x64\bin\clang-cl.exe | |
| set CXX=${{steps.setup.outputs.installationPath}}\VC\Tools\Llvm\x64\bin\clang-cl.exe | |
| if "${{matrix.arch}}" == "arm64" ( | |
| set CMAKE_SYSTEM_ARGS=-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 | |
| set CMAKE_FLAGS=-DCMAKE_C_FLAGS="--target=arm64-pc-windows-msvc /MT" -DCMAKE_CXX_FLAGS="--target=arm64-pc-windows-msvc /MT" | |
| ) else ( | |
| set CMAKE_SYSTEM_ARGS= | |
| set CMAKE_FLAGS=-DCMAKE_C_FLAGS="/MT" -DCMAKE_CXX_FLAGS="/MT" | |
| ) | |
| cmake -G Ninja ^ | |
| -DCMAKE_BUILD_TYPE=Release ^ | |
| -DCMAKE_C_COMPILER="%CC%" ^ | |
| -DCMAKE_CXX_COMPILER="%CC%" ^ | |
| %CMAKE_SYSTEM_ARGS% ^ | |
| %CMAKE_FLAGS% ^ | |
| -DCMAKE_INSTALL_PREFIX=D:/a/_temp/msys64/usr/local ^ | |
| -DSHADERC_SKIP_TESTS=ON ^ | |
| -DSHADERC_SKIP_EXAMPLES=ON ^ | |
| -DSHADERC_SKIP_COPYRIGHT_CHECK=ON ^ | |
| -DSHADERC_SKIP_EXECUTABLES=ON ^ | |
| -DENABLE_EXCEPTIONS=ON ^ | |
| -DENABLE_CTEST=OFF ^ | |
| -DENABLE_GLSLANG_BINARIES=OFF ^ | |
| -DSPIRV_SKIP_EXECUTABLES=ON ^ | |
| -DSPIRV_TOOLS_BUILD_STATIC=ON ^ | |
| -DBUILD_SHARED_LIBS=OFF ^ | |
| .. | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| ninja | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cmake --install . --config Release | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| REM Remove shared library files to force static linking | |
| echo Removing shaderc shared library files... | |
| del /Q D:\a\_temp\msys64\usr\local\bin\shaderc_shared.dll 2>nul | |
| del /Q D:\a\_temp\msys64\usr\local\lib\shaderc_shared.lib 2>nul | |
| del /Q D:\a\_temp\msys64\usr\local\lib\libshaderc_shared.lib 2>nul | |
| REM Manually copy libshaderc_util if it wasn't installed (same as Linux script does) | |
| if exist libshaderc_util\shaderc_util.lib ( | |
| echo Copying libshaderc_util.lib... | |
| copy libshaderc_util\shaderc_util.lib D:\a\_temp\msys64\usr\local\lib\ | |
| ) | |
| REM Create shaderc.pc alias from shaderc_combined.pc (same as Linux script does) | |
| if exist D:\a\_temp\msys64\usr\local\lib\pkgconfig\shaderc_combined.pc ( | |
| echo Creating shaderc.pc from shaderc_combined.pc... | |
| copy D:\a\_temp\msys64\usr\local\lib\pkgconfig\shaderc_combined.pc D:\a\_temp\msys64\usr\local\lib\pkgconfig\shaderc.pc | |
| ) | |
| cd .. | |
| REM Build glslc natively (x64) so it can run during whisper.cpp build | |
| if not exist native_build mkdir native_build | |
| cd native_build | |
| REM Use x64 compiler for native build (even for ARM64 target) | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" amd64 ${{env.SDK_VER}} | |
| cmake -G Ninja ^ | |
| -DCMAKE_BUILD_TYPE=Release ^ | |
| -DSHADERC_SKIP_TESTS=ON ^ | |
| -DSHADERC_SKIP_EXAMPLES=ON ^ | |
| -DSHADERC_SKIP_COPYRIGHT_CHECK=ON ^ | |
| -DENABLE_EXCEPTIONS=ON ^ | |
| -DSPIRV_TOOLS_BUILD_STATIC=ON ^ | |
| -DBUILD_SHARED_LIBS=OFF ^ | |
| .. | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| ninja glslc\glslc.exe | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| REM Copy native glslc to a location in PATH | |
| copy glslc\glslc.exe D:\a\_temp\msys64\usr\local\bin\ | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cd ..\.. | |
| - name: Build Vulkan-Shim-Loader | |
| if: ${{ success() }} | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| echo Building Vulkan-Shim-Loader... | |
| REM Copy vulkan-headers from root to Vulkan-Shim-Loader (it expects it as submodule) | |
| cd Vulkan-Shim-Loader | |
| if exist Vulkan-Headers rd /s /q Vulkan-Headers | |
| xcopy /E /I /Y ..\vulkan-headers Vulkan-Headers | |
| if not exist build mkdir build | |
| cd build | |
| set CC=${{steps.setup.outputs.installationPath}}\VC\Tools\Llvm\x64\bin\clang-cl.exe | |
| set CXX=${{steps.setup.outputs.installationPath}}\VC\Tools\Llvm\x64\bin\clang-cl.exe | |
| if "${{matrix.arch}}" == "arm64" ( | |
| set CMAKE_SYSTEM_ARGS=-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 | |
| set CMAKE_C_FLAGS=-DCMAKE_C_FLAGS="--target=arm64-pc-windows-msvc /MT" | |
| set CMAKE_CXX_FLAGS=-DCMAKE_CXX_FLAGS="--target=arm64-pc-windows-msvc /MT" | |
| ) else ( | |
| set CMAKE_SYSTEM_ARGS= | |
| set CMAKE_C_FLAGS=-DCMAKE_C_FLAGS="/MT" | |
| set CMAKE_CXX_FLAGS=-DCMAKE_CXX_FLAGS="/MT" | |
| ) | |
| cmake -G Ninja ^ | |
| -DCMAKE_BUILD_TYPE=Release ^ | |
| -DCMAKE_C_COMPILER="%CC%" ^ | |
| -DCMAKE_CXX_COMPILER="%CXX%" ^ | |
| %CMAKE_SYSTEM_ARGS% ^ | |
| %CMAKE_C_FLAGS% ^ | |
| %CMAKE_CXX_FLAGS% ^ | |
| -DCMAKE_INSTALL_PREFIX=D:/a/_temp/msys64/usr/local ^ | |
| -DVULKAN_SHIM_IMPERSONATE=ON ^ | |
| .. | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| ninja | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cmake --install . --config Release | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cd ..\.. | |
| REM Install Vulkan headers from root vulkan-headers submodule | |
| echo Installing Vulkan headers... | |
| cd %GITHUB_WORKSPACE% | |
| xcopy /E /I /Y vulkan-headers\include\* D:\a\_temp\msys64\usr\local\include\ | |
| REM Fix library name (add lib prefix for pkg-config compatibility) | |
| cd D:\a\_temp\msys64\usr\local\lib | |
| if exist vulkan-1.lib ( | |
| if not exist libvulkan-1.lib ( | |
| echo Creating libvulkan-1.lib from vulkan-1.lib | |
| copy vulkan-1.lib libvulkan-1.lib | |
| ) | |
| ) | |
| cd %GITHUB_WORKSPACE% | |
| - name: Build whisper.cpp | |
| if: ${{ success() }} | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| REM Add MSYS2 tools to PATH | |
| set PATH=D:\a\_temp\msys64\usr\bin;%PATH% | |
| echo Building whisper.cpp with clang-cl... | |
| cd whisper.cpp | |
| if not exist build mkdir build | |
| cd build | |
| REM Set architecture-specific GGML flags and CMake configuration | |
| set CLANG_CL_PATH=${{steps.setup.outputs.installationPath}}\VC\Tools\Llvm\x64\bin\clang-cl.exe | |
| if "${{matrix.arch}}" == "arm64" ( | |
| set GGML_NEON=-DGGML_NEON=ON | |
| set GGML_X64_FLAGS= | |
| set CMAKE_SYSTEM_PROCESSOR=-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 | |
| set CMAKE_C_FLAGS=-DCMAKE_C_FLAGS="--target=arm64-pc-windows-msvc /MT" | |
| set CMAKE_CXX_FLAGS=-DCMAKE_CXX_FLAGS="--target=arm64-pc-windows-msvc /MT /EHsc" | |
| REM Create host toolchain file for vulkan-shaders-gen (x64 tool that runs during build) | |
| REM This is needed because vcvarsall amd64_arm64 sets paths for ARM64, not x64 | |
| echo set(CMAKE_SYSTEM_NAME Windows^) > host-toolchain-x64.cmake | |
| echo set(CMAKE_SYSTEM_PROCESSOR AMD64^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_C_COMPILER "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe"^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_CXX_COMPILER "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe"^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_C_FLAGS_RELEASE "-O2" CACHE STRING "C flags" FORCE^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_CXX_FLAGS_RELEASE "-O2 /EHsc" CACHE STRING "CXX flags" FORCE^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER^) >> host-toolchain-x64.cmake | |
| echo set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER^) >> host-toolchain-x64.cmake | |
| REM Set x64 link directories (vcvarsall amd64_arm64 sets ARM64 in LIB environment variable) | |
| echo link_directories("C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.44.35207/lib/x64"^) >> host-toolchain-x64.cmake | |
| echo link_directories("C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64"^) >> host-toolchain-x64.cmake | |
| echo link_directories("C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/ucrt/x64"^) >> host-toolchain-x64.cmake | |
| echo include_directories("C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.44.35207/include"^) >> host-toolchain-x64.cmake | |
| echo include_directories("C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um"^) >> host-toolchain-x64.cmake | |
| echo include_directories("C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt"^) >> host-toolchain-x64.cmake | |
| echo include_directories("C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared"^) >> host-toolchain-x64.cmake | |
| echo Created host toolchain file: | |
| type host-toolchain-x64.cmake | |
| set VULKAN_TOOLCHAIN_FLAG=-DGGML_VULKAN_SHADERS_GEN_TOOLCHAIN=%CD%/host-toolchain-x64.cmake | |
| ) else ( | |
| set GGML_NEON= | |
| set GGML_X64_FLAGS=-DGGML_SSE42=ON -DGGML_AVX=ON -DGGML_F16C=ON -DGGML_AVX2=ON -DGGML_BMI2=ON -DGGML_FMA=ON | |
| set CMAKE_SYSTEM_PROCESSOR= | |
| set CMAKE_C_FLAGS=-DCMAKE_C_FLAGS="/MT" | |
| set CMAKE_CXX_FLAGS=-DCMAKE_CXX_FLAGS="/MT /EHsc" | |
| set VULKAN_TOOLCHAIN_FLAG= | |
| ) | |
| REM Check for Vulkan-Shim (built earlier) and enable Vulkan support | |
| if exist "D:\a\_temp\msys64\usr\local\lib\vulkan-1.lib" ( | |
| echo Vulkan-Shim found, enabling Vulkan support | |
| set VULKAN_FLAGS=-DGGML_VULKAN=ON -DVulkan_LIBRARY=D:/a/_temp/msys64/usr/local/lib/vulkan-1.lib -DVulkan_INCLUDE_DIR=D:/a/_temp/msys64/usr/local/include | |
| ) else ( | |
| echo Vulkan-Shim not found, disabling Vulkan support | |
| set VULKAN_FLAGS=-DGGML_VULKAN=OFF | |
| ) | |
| cmake .. -G "NMake Makefiles" ^ | |
| -DCMAKE_C_COMPILER="%CLANG_CL_PATH%" ^ | |
| -DCMAKE_CXX_COMPILER="%CLANG_CL_PATH%" ^ | |
| %CMAKE_SYSTEM_PROCESSOR% ^ | |
| %CMAKE_C_FLAGS% ^ | |
| %CMAKE_CXX_FLAGS% ^ | |
| -DCMAKE_PREFIX_PATH=D:\a\_temp\msys64\usr\local ^ | |
| -DCMAKE_INSTALL_PREFIX=D:\a\_temp\msys64\usr\local ^ | |
| -DCMAKE_BUILD_TYPE=Release ^ | |
| -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ | |
| -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^ | |
| -DBUILD_SHARED_LIBS=OFF ^ | |
| -DWHISPER_BUILD_TESTS=OFF ^ | |
| -DWHISPER_BUILD_EXAMPLES=OFF ^ | |
| -DWHISPER_BUILD_SERVER=OFF ^ | |
| -DWHISPER_USE_SYSTEM_GGML=OFF ^ | |
| -DGGML_CCACHE=OFF ^ | |
| -DGGML_OPENMP=OFF ^ | |
| -DGGML_OPENCL=ON ^ | |
| -DGGML_OPENCL_USE_ADRENO_KERNELS=OFF ^ | |
| -DOpenCL_LIBRARY=D:/a/_temp/msys64/usr/local/lib/OpenCL.lib ^ | |
| -DOpenCL_LIBRARIES=D:/a/_temp/msys64/usr/local/lib/OpenCL.lib ^ | |
| -DOpenCL_INCLUDE_DIR=D:/a/_temp/msys64/usr/local/include ^ | |
| -DOpenCL_INCLUDE_DIRS=D:/a/_temp/msys64/usr/local/include ^ | |
| -DGGML_NATIVE=OFF ^ | |
| %GGML_NEON% ^ | |
| %GGML_X64_FLAGS% ^ | |
| %VULKAN_FLAGS% ^ | |
| %VULKAN_TOOLCHAIN_FLAG% | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cmake --build . --config Release | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cmake --install . --config Release | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| cd ..\.. | |
| REM Fix library names (add lib prefix for pkg-config compatibility) | |
| cd D:\a\_temp\msys64\usr\local\lib | |
| for %%f in (ggml*.lib whisper.lib) do ( | |
| if not exist lib%%f ( | |
| echo Creating lib%%f from %%f | |
| copy %%f lib%%f | |
| ) | |
| ) | |
| cd %GITHUB_WORKSPACE% | |
| REM Create pkg-config file for whisper.cpp | |
| if not exist D:\a\_temp\msys64\usr\local\lib\pkgconfig mkdir D:\a\_temp\msys64\usr\local\lib\pkgconfig | |
| REM Check if Vulkan-Shim was built (indicates Vulkan support is enabled) | |
| if exist "D:\a\_temp\msys64\usr\local\lib\vulkan-1.lib" ( | |
| set GGML_LIBS=-lggml -lggml-base -lggml-cpu -lggml-opencl -lggml-vulkan | |
| set VULKAN_LIBS=-lvulkan-1 | |
| ) else ( | |
| set GGML_LIBS=-lggml -lggml-base -lggml-cpu -lggml-opencl | |
| set VULKAN_LIBS= | |
| ) | |
| ( | |
| echo prefix=/usr/local | |
| echo exec_prefix=${prefix} | |
| echo libdir=${exec_prefix}/lib | |
| echo includedir=${prefix}/include | |
| echo. | |
| echo Name: whisper | |
| echo Description: OpenAI Whisper speech recognition library | |
| echo Version: 1.8.2 | |
| echo Requires: OpenCL | |
| echo Cflags: -I${includedir} | |
| echo Libs: -L${libdir} -lwhisper %VULKAN_LIBS% | |
| echo Libs.private: %GGML_LIBS% -lstdc++ | |
| ) > D:\a\_temp\msys64\usr\local\lib\pkgconfig\whisper.pc | |
| - name: Build dav1d | |
| if: ${{ success() }} | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| REM Add MSYS2 tools (nasm, yasm) to PATH | |
| set PATH=D:\a\_temp\msys64\usr\bin;%PATH% | |
| REM Build dav1d (AV1 decoder) | |
| echo Building dav1d... | |
| cd dav1d | |
| REM Create cross-file for ARM64 builds | |
| if "${{matrix.arch}}" == "arm64" ( | |
| echo [binaries] > cross.txt | |
| echo c = 'cl' >> cross.txt | |
| echo ar = 'lib' >> cross.txt | |
| echo [host_machine] >> cross.txt | |
| echo system = 'windows' >> cross.txt | |
| echo cpu_family = 'aarch64' >> cross.txt | |
| echo cpu = 'aarch64' >> cross.txt | |
| echo endian = 'little' >> cross.txt | |
| REM Disable assembly for ARM64 cross-compilation | |
| meson setup build --cross-file cross.txt --prefix=D:\a\_temp\msys64\usr\local --buildtype=release --default-library=static -Denable_tools=false -Denable_tests=false -Denable_asm=false -Db_vscrt=mt | |
| ) else ( | |
| meson setup build --prefix=D:\a\_temp\msys64\usr\local --buildtype=release --default-library=static -Denable_tools=false -Denable_tests=false -Db_vscrt=mt | |
| ) | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| meson compile -C build | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| meson install -C build | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| REM Meson installs as libdav1d.a, but FFmpeg expects dav1d.lib | |
| REM Copy the library with both naming conventions | |
| if exist D:\a\_temp\msys64\usr\local\lib\libdav1d.a ( | |
| echo Found static library: D:\a\_temp\msys64\usr\local\lib\libdav1d.a | |
| copy D:\a\_temp\msys64\usr\local\lib\libdav1d.a D:\a\_temp\msys64\usr\local\lib\dav1d.lib | |
| copy D:\a\_temp\msys64\usr\local\lib\libdav1d.a D:\a\_temp\msys64\usr\local\lib\libdav1d.lib | |
| ) else ( | |
| echo ERROR: Static library libdav1d.a not found! | |
| exit /b 1 | |
| ) | |
| cd .. | |
| - name: Build zimg | |
| if: ${{ success() }} | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| echo Applying zimg patch (ignoring errors if already applied)... | |
| git -C zimg apply --ignore-whitespace "%CD%\patches\zimg.patch" || ver > nul | |
| REM Build zimg using MSBuild | |
| echo Building zimg... | |
| cd zimg\_msvc | |
| REM Determine platform for MSBuild | |
| if "${{matrix.arch}}" == "arm64" ( | |
| set PLATFORM=ARM64 | |
| ) else ( | |
| set PLATFORM=x64 | |
| ) | |
| MSBuild zimg\zimg.vcxproj -p:Configuration=Release -p:Platform=%PLATFORM% | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| REM Install headers | |
| if not exist D:\a\_temp\msys64\usr\local\include\zimg mkdir D:\a\_temp\msys64\usr\local\include\zimg | |
| copy ..\src\zimg\api\zimg.h D:\a\_temp\msys64\usr\local\include\zimg\ | |
| REM The path to the created library is relative to the vcxproj | |
| set LIB_PATH=zimg\%PLATFORM%\Release\z.lib | |
| REM Install the library | |
| if not exist D:\a\_temp\msys64\usr\local\lib mkdir D:\a\_temp\msys64\usr\local\lib | |
| if exist %LIB_PATH% ( | |
| echo Found static library: %LIB_PATH% | |
| copy "%LIB_PATH%" D:\a\_temp\msys64\usr\local\lib\zimg.lib | |
| copy "%LIB_PATH%" D:\a\_temp\msys64\usr\local\lib\libzimg.lib | |
| ) else ( | |
| echo ERROR: Static library z.lib not found at %LIB_PATH%! | |
| exit /b 1 | |
| ) | |
| REM Create pkg-config file | |
| if not exist D:\a\_temp\msys64\usr\local\lib\pkgconfig mkdir D:\a\_temp\msys64\usr\local\lib\pkgconfig | |
| ( | |
| echo prefix=/usr/local | |
| echo exec_prefix=${prefix} | |
| echo libdir=${exec_prefix}/lib | |
| echo includedir=${prefix}/include | |
| echo. | |
| echo Name: zimg | |
| echo Description: Scaling, colorspace conversion, and dithering library | |
| echo Version: 3.0 | |
| echo Libs: -L${libdir} -lzimg -llibcpmt | |
| echo Cflags: -I${includedir}/zimg | |
| ) > D:\a\_temp\msys64\usr\local\lib\pkgconfig\zimg.pc | |
| cd ..\.. | |
| - name: Build LAME | |
| if: ${{ success() }} | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| REM Build LAME MP3 encoder | |
| echo Building LAME... | |
| cd lame | |
| REM Copy configMS.h to config.h | |
| copy configMS.h config.h | |
| REM Set architecture-specific options and machine type | |
| if "${{matrix.arch}}" == "arm64" ( | |
| REM Patch Makefile.MSVC to use correct machine type for ARM64 | |
| powershell -Command "(Get-Content Makefile.MSVC) -replace 'MACHINE = /machine:I386', 'MACHINE = /machine:ARM64' | Set-Content Makefile.MSVC" | |
| ) else ( | |
| REM Patch Makefile.MSVC to use correct machine type for x64 | |
| powershell -Command "(Get-Content Makefile.MSVC) -replace 'MACHINE = /machine:I386', 'MACHINE = /machine:X64' | Set-Content Makefile.MSVC" | |
| ) | |
| REM Also remove obsolete compiler flags that cause warnings | |
| powershell -Command "(Get-Content Makefile.MSVC) -replace '/QIfdiv /QI0f /YX', '' | Set-Content Makefile.MSVC" | |
| REM Build static library only (no frontend) using documented approach | |
| REM comp=msvc ensures we use Microsoft compiler | |
| REM asm=no disables assembly optimizations (safer for cross-compilation) | |
| REM CFG=RH uses Robert's optimizations (default) | |
| nmake -f Makefile.MSVC comp=msvc asm=no libmp3lame-static.lib | |
| if %errorlevel% neq 0 exit /b %errorlevel% | |
| REM Install headers and library | |
| if not exist D:\a\_temp\msys64\usr\local\include\lame mkdir D:\a\_temp\msys64\usr\local\include\lame | |
| copy include\lame.h D:\a\_temp\msys64\usr\local\include\lame\ | |
| if not exist D:\a\_temp\msys64\usr\local\lib mkdir D:\a\_temp\msys64\usr\local\lib | |
| REM Copy library with both naming conventions for maximum compatibility | |
| if exist output\libmp3lame-static.lib ( | |
| echo Found static library: output\libmp3lame-static.lib | |
| copy output\libmp3lame-static.lib D:\a\_temp\msys64\usr\local\lib\libmp3lame.lib | |
| copy output\libmp3lame-static.lib D:\a\_temp\msys64\usr\local\lib\mp3lame.lib | |
| copy output\libmp3lame-static.lib D:\a\_temp\msys64\usr\local\lib\lame.lib | |
| ) else ( | |
| echo ERROR: Static library libmp3lame-static.lib not found! | |
| exit /b 1 | |
| ) | |
| REM Create pkg-config file - use absolute path for MSVC compatibility | |
| if not exist D:\a\_temp\msys64\usr\local\lib\pkgconfig mkdir D:\a\_temp\msys64\usr\local\lib\pkgconfig | |
| ( | |
| echo prefix=/usr/local | |
| echo exec_prefix=${prefix} | |
| echo libdir=${exec_prefix}/lib | |
| echo includedir=${prefix}/include | |
| echo. | |
| echo Name: libmp3lame | |
| echo Description: LAME MP3 encoding library | |
| echo Version: 3.100 | |
| echo Libs: -LD:/a/_temp/msys64/usr/local/lib -lmp3lame | |
| echo Cflags: -I${includedir}/lame | |
| ) > D:\a\_temp\msys64\usr\local\lib\pkgconfig\libmp3lame.pc | |
| cd .. | |
| - name: Build | |
| shell: cmd | |
| run: | | |
| CALL "${{steps.setup.outputs.installationPath}}\VC\Auxiliary\Build\vcvarsall.bat" ${{env.target}} ${{env.SDK_VER}} | |
| msys2 -c "export CUDA_PATH=\"$CUDA_PATH\"; ./build.sh ${{matrix.arch}}" | |
| - name: Debug log | |
| if: ${{ failure() }} | |
| shell: bash | |
| run: | | |
| echo [Debug] | |
| cat FFmpeg/ffbuild/config.log | |
| cat FFmpeg/ffbuild/config.mak | |
| cat FFmpeg/config.h | |
| - name: Pack | |
| shell: msys2 {0} | |
| run: | | |
| CWD=$(pwd) | |
| cd /usr/local | |
| # Add FFmpeg config headers to the package | |
| echo "Adding FFmpeg config headers..." | |
| mkdir -p include/ffmpeg | |
| # Copy all config*.h files | |
| CONFIG_FILES=$(find "${CWD}/FFmpeg" -maxdepth 1 -name "config*.h" -type f) | |
| if [[ -z "$CONFIG_FILES" ]]; then | |
| echo "ERROR: No config*.h files found in ${CWD}/FFmpeg/" | |
| exit 1 | |
| fi | |
| for config_file in $CONFIG_FILES; do | |
| cp "$config_file" include/ffmpeg/ | |
| echo "Added $(basename $config_file)" | |
| done | |
| echo "Successfully added all config*.h files" | |
| # # Add SDK libraries to the package | |
| # mkdir -p sdk | |
| # # Add Vulkan SDK libraries (architecture-specific) | |
| # if [[ -n "$VULKAN_SDK" && -d "$VULKAN_SDK" ]]; then | |
| # echo "Adding Vulkan SDK libraries..." | |
| # mkdir -p sdk/vulkan | |
| # cp -r "$VULKAN_SDK/Include" sdk/vulkan/ 2>/dev/null || true | |
| # if [[ "${{matrix.arch}}" == "arm64" ]]; then | |
| # cp -r "$VULKAN_SDK/Lib-ARM64" sdk/vulkan/Lib/ 2>/dev/null || true | |
| # else | |
| # cp -r "$VULKAN_SDK/Lib" sdk/vulkan/ 2>/dev/null || true | |
| # fi | |
| # # Add Vulkan runtime DLLs | |
| # cp -r "$VULKAN_SDK/runtime" sdk/vulkan/ 2>/dev/null || true | |
| # cp -r "$VULKAN_SDK/Bin" sdk/vulkan/ 2>/dev/null || true | |
| # fi | |
| # # Add CUDA SDK libraries (x64 only) | |
| # if [[ "${{matrix.arch}}" == "amd64" && -n "$CUDA_PATH" && -d "$CUDA_PATH" ]]; then | |
| # echo "Adding CUDA SDK libraries..." | |
| # mkdir -p sdk/cuda | |
| # cp -r "$CUDA_PATH/include" sdk/cuda/ 2>/dev/null || true | |
| # cp -r "$CUDA_PATH/lib/x64" sdk/cuda/lib/ 2>/dev/null || true | |
| # # Add CUDA runtime DLLs | |
| # cp -r "$CUDA_PATH/bin" sdk/cuda/ 2>/dev/null || true | |
| # fi | |
| zip -9 ${CWD}/${{env.name}}.zip -r . | |
| cd ${CWD} | |
| sha1sum ${{env.name}}.zip >${{env.name}}.sha1 | |
| - name: Generate changelog | |
| shell: bash | |
| run: | | |
| # Use custom changelog if provided, otherwise generate from git commits | |
| if [ -n "${{ inputs.changelog }}" ]; then | |
| echo "${{ inputs.changelog }}" > changelog | |
| else | |
| echo "Generating changelog from git commits..." | |
| # For autobuild tags, find the previous autobuild tag | |
| # For other tags, find the previous tag of any kind | |
| if [[ "${{env.REF_NAME}}" == autobuild-* ]]; then | |
| LAST_TAG=$(git tag -l 'autobuild-*' | grep -v "^${{env.REF_NAME}}$" | sort -V | tail -n 1) | |
| else | |
| LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| fi | |
| { | |
| echo "## Changes" | |
| echo "" | |
| if [ -z "$LAST_TAG" ]; then | |
| echo "Showing last 10 commits:" | |
| echo "" | |
| git log -10 --pretty=format:"- %s (%h)" --no-merges | |
| else | |
| echo "Changes since $LAST_TAG:" | |
| echo "" | |
| CHANGELOG=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges) | |
| if [ -z "$CHANGELOG" ]; then | |
| echo "No new commits since last tag" | |
| else | |
| echo "$CHANGELOG" | |
| fi | |
| fi | |
| } > changelog | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{env.name}} | |
| path: | | |
| ${{env.name}}.zip | |
| ${{env.name}}.sha1 | |
| changelog | |
| retention-days: 30 | |
| - name: Prepare release files | |
| if: ${{ inputs.release_name != '' }} | |
| shell: bash | |
| run: | | |
| # Rename files for release | |
| cp ${{env.name}}.zip ${{env.release_name}}.zip | |
| cp ${{env.name}}.sha1 ${{env.release_name}}.sha1 | |
| - name: Release | |
| if: ${{ inputs.release_name != '' }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{env.REF_NAME}} | |
| name: ${{ inputs.release_name }} | |
| body_path: changelog | |
| prerelease: ${{contains(env.REF_NAME,'dev')}} | |
| files: | | |
| ${{env.release_name}}.zip | |
| ${{env.release_name}}.sha1 |