CI C conformance #26
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
| # This is a copy of ci-unix-shared-installed.yml for finding bugs when adding warnings. | |
| name: CI C conformance | |
| on: [push, pull_request] | |
| permissions: | |
| contents: read | |
| # Cancel the workflow if a new one is triggered from the same PR, branch, or tag, except on main. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| jobs: | |
| build-shared-installed: | |
| strategy: | |
| fail-fast: false | |
| # Generate the configurations: | |
| # case 0: nodiscard, case 1: use stdbool, case 2: use enums | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| case: [0, 1, 2] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: ./.github/actions/setup-linux | |
| if: runner.os == 'Linux' | |
| with: | |
| codec-aom: "SYSTEM" | |
| codec-dav1d: "SYSTEM" | |
| libjpeg-turbo: "SYSTEM" | |
| libyuv: "SYSTEM" | |
| zlibpng: "SYSTEM" | |
| - uses: ./.github/actions/setup-windows | |
| id: windows_setup | |
| if: runner.os == 'Windows' | |
| with: | |
| codec-aom: "SYSTEM" | |
| codec-dav1d: "SYSTEM" | |
| libjpeg-turbo: "SYSTEM" | |
| libyuv: "SYSTEM" | |
| zlibpng: "SYSTEM" | |
| - name: Set clang as compiler on Linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| echo "AVIF_CMAKE_C_COMPILER=-DCMAKE_C_COMPILER=clang" >> $GITHUB_ENV | |
| echo "AVIF_CMAKE_CXX_COMPILER=-DCMAKE_CXX_COMPILER=clang++" >> $GITHUB_ENV | |
| - name: Leave compiler as MSVC on Windows | |
| if: runner.os == 'Windows' | |
| run: | | |
| echo "AVIF_CMAKE_C_COMPILER=" >> $env:GITHUB_ENV | |
| echo "AVIF_CMAKE_CXX_COMPILER=" >> $env:GITHUB_ENV | |
| - name: Enable nodiscard | |
| if: ${{ matrix.case == 0}} | |
| run: echo "CMAKE_AVIF_FLAGS=\"-DAVIF_ENABLE_NODISCARD=ON\"" >> $GITHUB_ENV | |
| - name: Use stdbool for AVIF_TRUE/AVIF_FALSE | |
| if: ${{ matrix.case == 1}} | |
| run: | | |
| sed -i 's/#include <stdint.h>/#include <stdint.h>\n#include <stdbool.h>/' include/avif/avif.h | |
| sed -i 's/typedef int avifBool;/typedef bool avifBool;/' include/avif/avif.h | |
| sed -i 's/#define AVIF_TRUE 1/#define AVIF_TRUE true/' include/avif/avif.h | |
| sed -i 's/#define AVIF_FALSE 0/#define AVIF_FALSE false/' include/avif/avif.h | |
| - name: Use enums for AVIF_TRUE/AVIF_FALSE | |
| if: ${{ matrix.case == 2}} | |
| run: | | |
| sed -i 's/#define AVIF_TRUE 1/enum avifTrueFalse_{ AVIF_TRUE = 1,/' include/avif/avif.h | |
| sed -i 's/#define AVIF_FALSE 0/AVIF_FALSE = 0};/' include/avif/avif.h | |
| - name: Prepare libavif (cmake) | |
| run: > | |
| cmake ${{ steps.windows_setup.outputs.vcpkg-cmake-config }} -G Ninja -S . -B build | |
| -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON | |
| -DAVIF_CODEC_AOM=SYSTEM | |
| -DAVIF_CODEC_AOM_DECODE=OFF -DAVIF_CODEC_AOM_ENCODE=ON | |
| -DAVIF_CODEC_DAV1D=SYSTEM | |
| -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON | |
| -DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL | |
| -DAVIF_BUILD_GDK_PIXBUF=ON -DCMAKE_INSTALL_PREFIX=./build/install | |
| -DAVIF_ENABLE_WERROR=ON ${{ env.AVIF_CMAKE_C_COMPILER}} ${{ env.AVIF_CMAKE_CXX_COMPILER }} | |
| ${{ env.CMAKE_AVIF_FLAGS }} | |
| - name: Build libavif | |
| run: cmake --build build --config Release --parallel 4 | |
| - name: Run AVIF Tests | |
| working-directory: ./build | |
| run: ctest -j $(getconf _NPROCESSORS_ONLN) --output-on-failure |