cmake-multi-platform.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # CI workflow for building and testing across multiple platforms
  2. name: CI
  3. on:
  4. push:
  5. branches: [ "master" ]
  6. paths:
  7. - 'src/**'
  8. - 'include/**'
  9. - 'scripts/**'
  10. - 'shaders/**'
  11. - 'CMakeLists.txt'
  12. - '**/CMakeLists.txt'
  13. - '.github/workflows/**'
  14. pull_request:
  15. branches: [ "master" ]
  16. paths:
  17. - 'src/**'
  18. - 'include/**'
  19. - 'scripts/**'
  20. - 'shaders/**'
  21. - 'CMakeLists.txt'
  22. - '**/CMakeLists.txt'
  23. - '.github/workflows/**'
  24. workflow_dispatch: # Manual trigger from GitHub UI
  25. jobs:
  26. build:
  27. runs-on: ${{ matrix.os }}
  28. strategy:
  29. fail-fast: false
  30. # Build matrix: Windows (MSVC + MinGW), Linux (GCC + Clang)
  31. matrix:
  32. os: [ubuntu-latest, windows-latest]
  33. build_type: [Release]
  34. c_compiler: [gcc, clang, cl]
  35. include:
  36. - os: windows-latest
  37. c_compiler: cl
  38. cpp_compiler: cl
  39. - os: windows-latest
  40. c_compiler: gcc
  41. cpp_compiler: g++
  42. - os: ubuntu-latest
  43. c_compiler: gcc
  44. cpp_compiler: g++
  45. - os: ubuntu-latest
  46. c_compiler: clang
  47. cpp_compiler: clang++
  48. exclude:
  49. - os: windows-latest
  50. c_compiler: clang
  51. - os: ubuntu-latest
  52. c_compiler: cl
  53. steps:
  54. - name: Checkout code with submodules
  55. uses: actions/checkout@v4
  56. with:
  57. submodules: 'recursive'
  58. - name: Setup MinGW-w64
  59. if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
  60. uses: msys2/setup-msys2@v2
  61. with:
  62. msystem: MINGW64
  63. update: true
  64. install: >-
  65. mingw-w64-x86_64-gcc
  66. mingw-w64-x86_64-cmake
  67. mingw-w64-x86_64-ninja
  68. mingw-w64-x86_64-python
  69. - name: Install dependencies for Ubuntu
  70. if: runner.os == 'Linux'
  71. run: |
  72. sudo apt update
  73. sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libwayland-bin libxkbcommon-dev
  74. # Cache CMake metadata to speed up builds
  75. - name: Cache dependencies
  76. uses: actions/cache@v4
  77. with:
  78. path: |
  79. ${{ github.workspace }}/build/CMakeFiles
  80. key: ${{ runner.os }}-${{ matrix.c_compiler }}-deps-${{ hashFiles('**/CMakeLists.txt') }}
  81. restore-keys: |
  82. ${{ runner.os }}-${{ matrix.c_compiler }}-deps-
  83. - name: Set reusable strings
  84. id: strings
  85. shell: bash
  86. run: |
  87. echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
  88. - name: Configure CMake (MinGW)
  89. if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
  90. shell: msys2 {0}
  91. run: |
  92. cmake -B build \
  93. -G "Ninja" \
  94. -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
  95. -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
  96. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  97. -DR3D_RAYLIB_VENDORED=ON \
  98. -DR3D_ASSIMP_VENDORED=ON \
  99. -DR3D_BUILD_EXAMPLES=ON \
  100. -DR3D_BUILD_DOCS=OFF \
  101. -S .
  102. - name: Configure CMake (Non-MinGW)
  103. if: runner.os != 'Windows' || matrix.c_compiler != 'gcc'
  104. run: >
  105. cmake -B ${{ steps.strings.outputs.build-output-dir }}
  106. -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
  107. -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
  108. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  109. -DR3D_RAYLIB_VENDORED=ON
  110. -DR3D_ASSIMP_VENDORED=ON
  111. -DR3D_BUILD_EXAMPLES=ON
  112. -DR3D_BUILD_DOCS=OFF
  113. -S ${{ github.workspace }}
  114. - name: Build (MinGW)
  115. if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
  116. shell: msys2 {0}
  117. run: cmake --build build --config ${{ matrix.build_type }} --parallel
  118. - name: Build (Non-MinGW)
  119. if: runner.os != 'Windows' || matrix.c_compiler != 'gcc'
  120. run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel
  121. - name: Test (MinGW)
  122. if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
  123. shell: msys2 {0}
  124. working-directory: build
  125. run: ctest --build-config ${{ matrix.build_type }}
  126. - name: Test (Non-MinGW)
  127. if: runner.os != 'Windows' || matrix.c_compiler != 'gcc'
  128. working-directory: ${{ steps.strings.outputs.build-output-dir }}
  129. run: ctest --build-config ${{ matrix.build_type }}
  130. - name: Upload build artifacts
  131. uses: actions/upload-artifact@v4
  132. with:
  133. name: r3d-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.c_compiler }}
  134. path: |
  135. ${{ steps.strings.outputs.build-output-dir }}/**/*.dll
  136. ${{ steps.strings.outputs.build-output-dir }}/**/*.so
  137. ${{ steps.strings.outputs.build-output-dir }}/**/*.a
  138. ${{ steps.strings.outputs.build-output-dir }}/**/*.lib
  139. ${{ steps.strings.outputs.build-output-dir }}/**/*.dylib
  140. retention-days: 14