build.yml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. name: Kernel Build Process
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. kernel_version:
  9. required: true
  10. type: string
  11. variant:
  12. required: false
  13. type: string
  14. ksu_commit:
  15. required: false
  16. type: string
  17. anykernel_commit:
  18. required: false
  19. type: string
  20. patches_commit:
  21. required: false
  22. type: string
  23. susfs_commit:
  24. required: false
  25. type: string
  26. feature_set:
  27. required: true
  28. type: string
  29. use_repo:
  30. required: false
  31. type: boolean
  32. jobs:
  33. build-gki:
  34. name: "${{ inputs.kernel_version }} (${{ inputs.variant }})"
  35. runs-on: ubuntu-latest
  36. timeout-minutes: 60
  37. steps:
  38. - name: Checkout Repository
  39. uses: actions/checkout@v5
  40. - name: Parse kernel version
  41. id: parse
  42. uses: ./.github/actions/parse-kernel-version
  43. with:
  44. kernel_version: ${{ inputs.kernel_version }}
  45. - name: Free Disk Space
  46. if: true
  47. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  48. with:
  49. remove_android: true
  50. remove_dotnet: true
  51. remove_haskell: true
  52. remove_tool_cache: true
  53. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  54. remove_packages_one_command: true
  55. remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
  56. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  57. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  58. testing: false
  59. - name: Setup more Swap (for LTO)
  60. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  61. with:
  62. swap-size-gb: 25 # 10-24 GB is common for heavy LTO
  63. # swap-space-path: /mnt/swapfile # optional
  64. - name: Setup Build Environment
  65. uses: ./.github/actions/setup-build-environment
  66. env:
  67. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  68. with:
  69. patches_commit: ${{ inputs.patches_commit }}
  70. anykernel_commit: ${{ inputs.anykernel_commit }}
  71. - name: Download Kernel Repository
  72. uses: ./.github/actions/download-kernel
  73. with:
  74. android_version: ${{ steps.parse.outputs.android_version }}
  75. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  76. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  77. use_repo: ${{ inputs.use_repo }}
  78. - name: Grep for vm_flags_clear after download
  79. run: |
  80. grep -n 'vm_flags_clear' ${{ github.workspace }}/kernel/common/mm/mmap.c || echo 'Not found'
  81. - name: Extract Sublevel and Set File Name
  82. id: extract
  83. uses: ./.github/actions/extract-sublevel-file-name
  84. with:
  85. variant: ${{ inputs.variant }}
  86. - name: Kernel Fixes
  87. uses: ./.github/actions/kernel-fixes
  88. with:
  89. android_version: ${{ steps.parse.outputs.android_version }}
  90. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  91. sublevel: ${{ steps.extract.outputs.sublevel }}
  92. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  93. - name: Setup KernelSU-Next
  94. if: contains(inputs.feature_set, 'KSUN') || inputs.feature_set == 'FULL'
  95. uses: ./.github/actions/kernelsu
  96. with:
  97. ksu_commit: ${{ inputs.ksu_commit }}
  98. - name: SUSFS
  99. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'FULL'
  100. uses: ./.github/actions/susfs
  101. with:
  102. android_version: ${{ steps.parse.outputs.android_version }}
  103. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  104. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  105. sublevel: ${{ steps.extract.outputs.sublevel }}
  106. susfs_commit: ${{ inputs.susfs_commit }}
  107. - name: Baseband Guard
  108. if: contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'FULL'
  109. uses: ./.github/actions/bbg
  110. - name: Setup Networking
  111. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'FULL'
  112. uses: ./.github/actions/networking
  113. with:
  114. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  115. android_version: ${{ steps.parse.outputs.android_version }}
  116. - name: Setup Misc Configs
  117. uses: ./.github/actions/misc
  118. with:
  119. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  120. android_version: ${{ steps.parse.outputs.android_version }}
  121. - name: Apply Module Check Bypass
  122. if: ${{ inputs.variant == 'Bypass' }}
  123. uses: ./.github/actions/module-check-bypass
  124. with:
  125. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  126. - name: Apply Device-Specific Patches
  127. uses: ./.github/actions/apply-device-patches
  128. with:
  129. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  130. - name: Apply ABI Compare Bypass
  131. if: false
  132. working-directory: ${{ github.workspace }}/kernel
  133. run: |
  134. # ABI compare bypass per kernel/android version
  135. # Edit each block as needed per version
  136. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  137. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  138. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  139. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  140. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  141. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  142. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  143. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  144. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  145. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  146. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  147. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  148. fi
  149. - name: Apply Kernel Branding
  150. uses: ./.github/actions/apply-kernel-branding
  151. with:
  152. variant: ${{ inputs.variant }}
  153. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  154. android_version: ${{ steps.parse.outputs.android_version }}
  155. sublevel: ${{ steps.extract.outputs.sublevel }}
  156. - name: Remove Protected Exports
  157. uses: ./.github/actions/remove-protected-exports
  158. - name: Clean Kernel Flags
  159. uses: ./.github/actions/clean-kernel-flags
  160. - name: Scan and collect patch rejects
  161. id: scan
  162. if: ${{ always() && inputs.variant == 'Normal' }}
  163. uses: ./.github/actions/scan-patch-rejects
  164. - name: Upload Rejects
  165. if: ${{ always() && inputs.variant == 'Normal' }}
  166. uses: actions/upload-artifact@v7
  167. with:
  168. name: ${{ steps.extract.outputs.file_name }}-Rejects
  169. path: patch-rejects/
  170. if-no-files-found: ignore
  171. compression-level: 9
  172. - name: Grep for vm_flags_clear before build
  173. run: |
  174. grep -n 'vm_flags_clear' ${{ github.workspace }}/kernel/common/mm/mmap.c || echo 'Not found'
  175. - name: Restore build caches (ccache, Bazel)
  176. uses: actions/cache@v4
  177. with:
  178. path: |
  179. .ccache
  180. bazel-*
  181. .cache/bazel
  182. key: buildcache-${{ inputs.kernel_version }}
  183. restore-keys: |
  184. buildcache-
  185. - name: Build Kernel
  186. env:
  187. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  188. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  189. uses: ./.github/actions/build-kernel
  190. - name: List cache contents
  191. run: |
  192. echo "=== .ccache ==="
  193. du -sh .ccache || true
  194. ls -l .ccache || true
  195. echo "=== .cache/bazel ==="
  196. du -sh .cache/bazel || true
  197. ls -l .cache/bazel || true
  198. - name: Save build caches (ccache, Bazel)
  199. if: always()
  200. uses: actions/cache@v4
  201. with:
  202. path: |
  203. .ccache
  204. bazel-*
  205. .cache/bazel
  206. key: buildcache-${{ inputs.kernel_version }}
  207. - name: Create Bootimgs Folder and Build Boot Images
  208. uses: ./.github/actions/build-boot-images
  209. - name: Upload Boot Image (boot.img)
  210. uses: actions/upload-artifact@v7
  211. with:
  212. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot.img
  213. if-no-files-found: error
  214. archive: false
  215. - name: Upload Boot Image (boot-gz.img)
  216. uses: actions/upload-artifact@v7
  217. with:
  218. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-gz.img
  219. if-no-files-found: error
  220. archive: false
  221. - name: Upload Boot Image (boot-lz4.img)
  222. uses: actions/upload-artifact@v7
  223. with:
  224. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-lz4.img
  225. if-no-files-found: error
  226. archive: false
  227. - name: Prepare AnyKernel3 Zip
  228. uses: ./.github/actions/prepare-anykernel3
  229. - name: Upload Artifacts
  230. uses: actions/upload-artifact@v7
  231. with:
  232. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  233. path: ${{ github.workspace }}/AnyKernel3/**
  234. if-no-files-found: ignore
  235. compression-level: 9