name: Multi-Platform Build on: push: branches: [ "master" ] paths: - 'src/**' - 'include/**' - 'scripts/**' - 'shaders/**' - 'CMakeLists.txt' - '**/CMakeLists.txt' - '.github/workflows/**' pull_request: branches: [ "master" ] paths: - 'src/**' - 'include/**' - 'scripts/**' - 'shaders/**' - 'CMakeLists.txt' - '**/CMakeLists.txt' - '.github/workflows/**' workflow_dispatch: jobs: build: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] build_type: [Release] c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl - os: windows-latest c_compiler: gcc cpp_compiler: g++ - os: ubuntu-latest c_compiler: gcc cpp_compiler: g++ - os: ubuntu-latest c_compiler: clang cpp_compiler: clang++ exclude: - os: windows-latest c_compiler: clang - os: ubuntu-latest c_compiler: cl steps: - name: Checkout code uses: actions/checkout@v4 with: submodules: recursive - name: Setup ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }} max-size: 500M - name: Install Ninja (Windows MSVC) if: runner.os == 'Windows' && matrix.c_compiler == 'cl' run: choco install ninja - name: Setup MinGW-w64 if: runner.os == 'Windows' && matrix.c_compiler == 'gcc' uses: msys2/setup-msys2@v2 with: msystem: MINGW64 update: true install: >- mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-python mingw-w64-x86_64-ccache - name: Install Linux dependencies if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ ninja-build \ libglfw3 libglfw3-dev \ libx11-dev libxcursor-dev libxrandr-dev \ libxinerama-dev libxi-dev libxext-dev libxfixes-dev \ libwayland-dev libwayland-bin libxkbcommon-dev - name: Configure CMake (MinGW) if: runner.os == 'Windows' && matrix.c_compiler == 'gcc' shell: msys2 {0} run: | cmake -B build -G "Ninja" \ -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DBUILD_SHARED_LIBS=OFF \ -DR3D_RAYLIB_VENDORED=ON \ -DR3D_ASSIMP_VENDORED=ON \ -DR3D_BUILD_EXAMPLES=ON \ -DR3D_BUILD_DOCS=OFF - name: Configure CMake (Windows MSVC) if: runner.os == 'Windows' && matrix.c_compiler == 'cl' shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cmake -B build -G "Ninja" ^ -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} ^ -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} ^ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ^ -DCMAKE_C_COMPILER_LAUNCHER=ccache ^ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^ -DBUILD_SHARED_LIBS=OFF ^ -DR3D_RAYLIB_VENDORED=ON ^ -DR3D_ASSIMP_VENDORED=ON ^ -DR3D_BUILD_EXAMPLES=ON ^ -DR3D_BUILD_DOCS=OFF - name: Configure CMake (Linux) if: runner.os == 'Linux' run: | cmake -B build -G "Ninja" \ -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DBUILD_SHARED_LIBS=OFF \ -DR3D_RAYLIB_VENDORED=ON \ -DR3D_ASSIMP_VENDORED=ON \ -DR3D_BUILD_EXAMPLES=ON \ -DR3D_BUILD_DOCS=OFF - name: Build (MinGW) if: runner.os == 'Windows' && matrix.c_compiler == 'gcc' shell: msys2 {0} run: cmake --build build --config ${{ matrix.build_type }} --parallel - name: Build (Windows MSVC) if: runner.os == 'Windows' && matrix.c_compiler == 'cl' shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cmake --build build --config ${{ matrix.build_type }} --parallel - name: Build (Linux) if: runner.os == 'Linux' run: cmake --build build --config ${{ matrix.build_type }} --parallel - name: Print ccache statistics run: ccache -s - name: Run tests (MinGW) if: runner.os == 'Windows' && matrix.c_compiler == 'gcc' shell: msys2 {0} run: | cd build ctest --build-config ${{ matrix.build_type }} - name: Run tests (Windows MSVC) if: runner.os == 'Windows' && matrix.c_compiler == 'cl' shell: cmd working-directory: build run: ctest --build-config ${{ matrix.build_type }} - name: Run tests (Linux) if: runner.os == 'Linux' working-directory: build run: ctest --build-config ${{ matrix.build_type }} - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: r3d-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.c_compiler }} path: | build/**/*.dll build/**/*.so build/**/*.a build/**/*.lib build/**/*.dylib retention-days: 14 trigger-bindings: needs: build runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' steps: - name: Trigger binding generation uses: peter-evans/repository-dispatch@v3 with: token: ${{ secrets.BINDGEN_PAT }} repository: Bigfoot71/r3d-odin-bindgen event-type: r3d-updated client-payload: | { "ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "repository": "${{ github.repository }}", "commit_message": ${{ toJSON(github.event.head_commit.message) }}, "run_id": "${{ github.run_id }}" }