cmake.yml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. name: CMake
  2. on:
  3. push:
  4. paths:
  5. - '.github/workflows/cmake.yml'
  6. - 'src/**'
  7. - 'CMakeModules/**'
  8. - CMakeLists.txt
  9. - 'protocols/**'
  10. branches: [ main ]
  11. tags: [ 'v*' ]
  12. pull_request:
  13. paths:
  14. - '.github/workflows/cmake.yml'
  15. - 'src/**'
  16. - 'CMakeModules/**'
  17. - CMakeLists.txt
  18. - 'protocols/**'
  19. branches: [ main ]
  20. workflow_dispatch:
  21. jobs:
  22. formatting:
  23. name: Formatting check
  24. runs-on: ubuntu-latest
  25. steps:
  26. - uses: actions/checkout@v4
  27. - name: Run clang-format style check for C/C++ programs.
  28. uses: jidicula/clang-format-action@v4.18.0
  29. with:
  30. check-path: "src"
  31. exclude-regex: "(src/External)"
  32. - run: echo "Formatted with clang-format version ${{ steps.clang-format.outputs.clang-format-version }}"
  33. tests:
  34. #needs: formatting
  35. env:
  36. BUILD_TYPE: Release
  37. strategy:
  38. matrix:
  39. os: [ubuntu-24.04]
  40. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  41. # You can convert this to a matrix build if you need cross-platform coverage.
  42. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  43. runs-on: ${{ matrix.os }}
  44. steps:
  45. - uses: actions/checkout@v3
  46. with:
  47. submodules: true
  48. # cache some build information
  49. - name: ccache
  50. uses: hendrikmuhs/ccache-action@v1.2
  51. with:
  52. key: ${{ github.job }}-${{ matrix.os }}
  53. - name: Install dependencies
  54. run: sudo apt-get update && sudo apt-get -y install libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libfftw3-dev libfreetype-dev libdbus-1-dev
  55. - name: Configure CMake
  56. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  57. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  58. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=1 -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  59. - name: Build
  60. # Build your program with the given configuration
  61. run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target tests --verbose
  62. - name: Run tests
  63. # Run the unit tests available
  64. run: ${{github.workspace}}/build/output/tests
  65. build:
  66. needs: tests
  67. permissions:
  68. actions: read
  69. contents: read
  70. security-events: write
  71. strategy:
  72. matrix:
  73. include:
  74. - build_type: Release
  75. variant: kde
  76. disable_kde: 'OFF'
  77. - build_type: Release
  78. variant: generic
  79. disable_kde: 'ON'
  80. - build_type: Debug
  81. variant: kde
  82. disable_kde: 'OFF'
  83. runs-on: ubuntu-24.04
  84. steps:
  85. - uses: actions/checkout@v3
  86. with:
  87. submodules: true
  88. - name: ccache
  89. uses: hendrikmuhs/ccache-action@v1.2
  90. with:
  91. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}-${{ matrix.variant }}
  92. - name: Initialize CodeQL
  93. # Initializes the CodeQL tools for scanning.
  94. uses: github/codeql-action/init@v3
  95. if: ${{ matrix.build_type == 'Debug' }}
  96. with:
  97. languages: 'cpp'
  98. - name: Install dependencies
  99. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev libdbus-1-dev wayland-scanner++ wayland-protocols libwayland-dev
  100. - name: Configure CMake
  101. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DDISABLE_KDE_FEATURES=${{matrix.disable_kde}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  102. - name: Build
  103. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose
  104. - name: Perform CodeQL Analysis
  105. if: ${{ matrix.build_type == 'Debug' }}
  106. uses: github/codeql-action/analyze@v3
  107. - name: Package
  108. if: ${{ matrix.build_type == 'Release' }}
  109. run: |
  110. name=linux-wallpaperengine-${{ matrix.variant }}-ubuntu-24.04-x86_64
  111. cmake --install build --prefix "$RUNNER_TEMP/install"
  112. # the install also carries the dependencies' own tools, headers and static libs, keep only what runs
  113. pkg="$RUNNER_TEMP/$name"
  114. mkdir -p "$pkg/lib"
  115. cd "$RUNNER_TEMP/install"
  116. cp -a linux-wallpaperengine liblinux-wallpaperengine-lib.so libcef.so libEGL.so libGLESv2.so \
  117. libvk_swiftshader.so vk_swiftshader_icd.json chrome-sandbox icudtl.dat v8_context_snapshot.bin \
  118. *.pak locales "$pkg/"
  119. cp -a lib/libkissfft-float.so* "$pkg/lib/"
  120. # CEF ships libcef.so with debug symbols, 1.4 GB instead of about 220 MB
  121. strip --strip-unneeded "$pkg/linux-wallpaperengine" "$pkg/liblinux-wallpaperengine-lib.so" "$pkg/libcef.so"
  122. tar -czf "$RUNNER_TEMP/$name.tar.gz" -C "$RUNNER_TEMP" "$name"
  123. - uses: actions/upload-artifact@v4
  124. if: ${{ matrix.build_type == 'Release' }}
  125. with:
  126. name: linux-wallpaperengine-${{ matrix.variant }}
  127. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-ubuntu-24.04-x86_64.tar.gz
  128. if-no-files-found: error
  129. release:
  130. needs: build
  131. if: startsWith(github.ref, 'refs/tags/v')
  132. runs-on: ubuntu-latest
  133. permissions:
  134. contents: write
  135. steps:
  136. - uses: actions/checkout@v4
  137. - uses: actions/download-artifact@v4
  138. with:
  139. path: release
  140. merge-multiple: true
  141. - name: Create release
  142. env:
  143. GH_TOKEN: ${{ github.token }}
  144. run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes release/*.tar.gz
  145. clang-build:
  146. needs: tests
  147. permissions:
  148. actions: read
  149. contents: read
  150. security-events: write
  151. strategy:
  152. matrix:
  153. build_type: [Debug, Release]
  154. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  155. # You can convert this to a matrix build if you need cross-platform coverage.
  156. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  157. runs-on: ubuntu-24.04
  158. steps:
  159. - uses: actions/checkout@v3
  160. with:
  161. submodules: true
  162. - name: ccache
  163. uses: hendrikmuhs/ccache-action@v1.2
  164. with:
  165. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}
  166. - name: Install dependencies
  167. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev libdbus-1-dev wayland-scanner++ wayland-protocols libwayland-dev
  168. - name: Configure CMake
  169. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  170. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  171. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++
  172. - name: Build
  173. # Build your program with the given configuration
  174. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose