cmake-multi-platform.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. name: Multi-Platform Build
  2. on:
  3. push:
  4. branches: [ "master" ]
  5. paths:
  6. - 'src/**'
  7. - 'include/**'
  8. - 'scripts/**'
  9. - 'shaders/**'
  10. - 'CMakeLists.txt'
  11. - '**/CMakeLists.txt'
  12. - '.github/workflows/**'
  13. pull_request:
  14. branches: [ "master" ]
  15. paths:
  16. - 'src/**'
  17. - 'include/**'
  18. - 'scripts/**'
  19. - 'shaders/**'
  20. - 'CMakeLists.txt'
  21. - '**/CMakeLists.txt'
  22. - '.github/workflows/**'
  23. workflow_dispatch:
  24. jobs:
  25. build:
  26. runs-on: ${{ matrix.os }}
  27. strategy:
  28. fail-fast: false
  29. matrix:
  30. os: [ubuntu-latest, windows-latest]
  31. build_type: [Release]
  32. c_compiler: [gcc, clang, cl]
  33. include:
  34. - os: windows-latest
  35. c_compiler: cl
  36. cpp_compiler: cl
  37. - os: windows-latest
  38. c_compiler: gcc
  39. cpp_compiler: g++
  40. - os: ubuntu-latest
  41. c_compiler: gcc
  42. cpp_compiler: g++
  43. - os: ubuntu-latest
  44. c_compiler: clang
  45. cpp_compiler: clang++
  46. exclude:
  47. - os: windows-latest
  48. c_compiler: clang
  49. - os: ubuntu-latest
  50. c_compiler: cl
  51. steps:
  52. - name: Checkout code
  53. uses: actions/checkout@v4
  54. with:
  55. submodules: recursive
  56. - name: Setup ccache
  57. uses: hendrikmuhs/[email protected]
  58. with:
  59. key: ${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
  60. max-size: 500M
  61. - name: Install Ninja (Windows MSVC)
  62. if: runner.os == 'Windows' && matrix.c_compiler == 'cl'
  63. run: choco install ninja
  64. - name: Setup MinGW-w64
  65. if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
  66. uses: msys2/setup-msys2@v2
  67. with:
  68. msystem: MINGW64
  69. update: true
  70. install: >-
  71. mingw-w64-x86_64-gcc
  72. mingw-w64-x86_64-cmake
  73. mingw-w64-x86_64-ninja
  74. mingw-w64-x86_64-python
  75. mingw-w64-x86_64-ccache
  76. - name: Install Linux dependencies
  77. if: runner.os == 'Linux'
  78. run: |
  79. sudo apt-get update
  80. sudo apt-get install -y --no-install-recommends \
  81. ninja-build \
  82. libglfw3 libglfw3-dev \
  83. libx11-dev libxcursor-dev libxrandr-dev \
  84. libxinerama-dev libxi-dev libxext-dev libxfixes-dev \
  85. libwayland-dev libwayland-bin libxkbcommon-dev
  86. - name: Configure CMake (MinGW)
  87. if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
  88. shell: msys2 {0}
  89. run: |
  90. cmake -B build -G "Ninja" \
  91. -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
  92. -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
  93. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  94. -DCMAKE_C_COMPILER_LAUNCHER=ccache \
  95. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
  96. -DBUILD_SHARED_LIBS=OFF \
  97. -DR3D_RAYLIB_VENDORED=ON \
  98. -DR3D_ASSIMP_VENDORED=ON \
  99. -DR3D_BUILD_EXAMPLES=ON \
  100. -DR3D_BUILD_DOCS=OFF
  101. - name: Configure CMake (Windows MSVC)
  102. if: runner.os == 'Windows' && matrix.c_compiler == 'cl'
  103. shell: cmd
  104. run: |
  105. call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  106. cmake -B build -G "Ninja" ^
  107. -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} ^
  108. -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} ^
  109. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ^
  110. -DCMAKE_C_COMPILER_LAUNCHER=ccache ^
  111. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^
  112. -DBUILD_SHARED_LIBS=OFF ^
  113. -DR3D_RAYLIB_VENDORED=ON ^
  114. -DR3D_ASSIMP_VENDORED=ON ^
  115. -DR3D_BUILD_EXAMPLES=ON ^
  116. -DR3D_BUILD_DOCS=OFF
  117. - name: Configure CMake (Linux)
  118. if: runner.os == 'Linux'
  119. run: |
  120. cmake -B build -G "Ninja" \
  121. -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
  122. -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
  123. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  124. -DCMAKE_C_COMPILER_LAUNCHER=ccache \
  125. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
  126. -DBUILD_SHARED_LIBS=OFF \
  127. -DR3D_RAYLIB_VENDORED=ON \
  128. -DR3D_ASSIMP_VENDORED=ON \
  129. -DR3D_BUILD_EXAMPLES=ON \
  130. -DR3D_BUILD_DOCS=OFF
  131. - name: Build (MinGW)
  132. if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
  133. shell: msys2 {0}
  134. run: cmake --build build --config ${{ matrix.build_type }} --parallel
  135. - name: Build (Windows MSVC)
  136. if: runner.os == 'Windows' && matrix.c_compiler == 'cl'
  137. shell: cmd
  138. run: |
  139. call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  140. cmake --build build --config ${{ matrix.build_type }} --parallel
  141. - name: Build (Linux)
  142. if: runner.os == 'Linux'
  143. run: cmake --build build --config ${{ matrix.build_type }} --parallel
  144. - name: Print ccache statistics
  145. run: ccache -s
  146. - name: Run tests (MinGW)
  147. if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
  148. shell: msys2 {0}
  149. run: |
  150. cd build
  151. ctest --build-config ${{ matrix.build_type }}
  152. - name: Run tests (Windows MSVC)
  153. if: runner.os == 'Windows' && matrix.c_compiler == 'cl'
  154. shell: cmd
  155. working-directory: build
  156. run: ctest --build-config ${{ matrix.build_type }}
  157. - name: Run tests (Linux)
  158. if: runner.os == 'Linux'
  159. working-directory: build
  160. run: ctest --build-config ${{ matrix.build_type }}
  161. - name: Upload artifacts
  162. uses: actions/upload-artifact@v4
  163. with:
  164. name: r3d-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.c_compiler }}
  165. path: |
  166. build/**/*.dll
  167. build/**/*.so
  168. build/**/*.a
  169. build/**/*.lib
  170. build/**/*.dylib
  171. retention-days: 14
  172. trigger-bindings:
  173. needs: build
  174. runs-on: ubuntu-latest
  175. if: github.event_name == 'push' && github.ref == 'refs/heads/master'
  176. steps:
  177. - name: Trigger binding generation
  178. uses: peter-evans/repository-dispatch@v3
  179. with:
  180. token: ${{ secrets.BINDGEN_PAT }}
  181. repository: Bigfoot71/r3d-odin-bindgen
  182. event-type: r3d-updated
  183. client-payload: |
  184. {
  185. "ref": "${{ github.ref }}",
  186. "sha": "${{ github.sha }}",
  187. "repository": "${{ github.repository }}",
  188. "commit_message": ${{ toJSON(github.event.head_commit.message) }},
  189. "run_id": "${{ github.run_id }}"
  190. }