build.yml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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: DroidSpaces-OSS Patches
  117. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'FULL'
  118. uses: ./.github/actions/droidspaces
  119. with:
  120. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  121. - name: Setup Misc Configs
  122. uses: ./.github/actions/misc
  123. with:
  124. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  125. android_version: ${{ steps.parse.outputs.android_version }}
  126. - name: Apply Module Check Bypass
  127. if: ${{ inputs.variant == 'Bypass' }}
  128. uses: ./.github/actions/module-check-bypass
  129. with:
  130. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  131. - name: Apply Device-Specific Patches
  132. uses: ./.github/actions/apply-device-patches
  133. with:
  134. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  135. - name: Apply ABI Compare Bypass
  136. if: false
  137. working-directory: ${{ github.workspace }}/kernel
  138. run: |
  139. # ABI compare bypass per kernel/android version
  140. # Edit each block as needed per version
  141. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  142. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  143. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  144. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  145. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  146. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  147. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  148. 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
  149. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  150. 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
  151. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  152. 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
  153. fi
  154. - name: Apply Kernel Branding
  155. uses: ./.github/actions/apply-kernel-branding
  156. with:
  157. variant: ${{ inputs.variant }}
  158. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  159. android_version: ${{ steps.parse.outputs.android_version }}
  160. sublevel: ${{ steps.extract.outputs.sublevel }}
  161. - name: Remove Protected Exports
  162. uses: ./.github/actions/remove-protected-exports
  163. - name: Clean Kernel Flags
  164. uses: ./.github/actions/clean-kernel-flags
  165. - name: Scan and collect patch rejects
  166. id: scan
  167. if: ${{ always() && inputs.variant == 'Normal' }}
  168. uses: ./.github/actions/scan-patch-rejects
  169. - name: Upload Rejects
  170. if: ${{ always() && inputs.variant == 'Normal' }}
  171. uses: actions/upload-artifact@v7
  172. with:
  173. name: ${{ steps.extract.outputs.file_name }}-Rejects
  174. path: patch-rejects/
  175. if-no-files-found: ignore
  176. compression-level: 9
  177. - name: Grep for vm_flags_clear before build
  178. run: |
  179. grep -n 'vm_flags_clear' ${{ github.workspace }}/kernel/common/mm/mmap.c || echo 'Not found'
  180. - name: Restore build caches (ccache, Bazel)
  181. uses: actions/cache@v4
  182. with:
  183. path: |
  184. kernel/.ccache
  185. kernel/bazel-*
  186. kernel/.cache/bazel
  187. key: buildcache-${{ inputs.kernel_version }}
  188. restore-keys: |
  189. buildcache-
  190. - name: Build Kernel
  191. env:
  192. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  193. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  194. uses: ./.github/actions/build-kernel
  195. - name: List cache contents
  196. working-directory: ${{ github.workspace }}/kernel
  197. run: |
  198. echo "=== .ccache ==="
  199. du -sh .ccache || true
  200. ls -l .ccache || true
  201. echo "=== .cache/bazel ==="
  202. du -sh .cache/bazel || true
  203. ls -l .cache/bazel || true
  204. - name: Create Bootimgs Folder and Build Boot Images
  205. uses: ./.github/actions/build-boot-images
  206. - name: Upload Boot Image (boot.img)
  207. uses: actions/upload-artifact@v7
  208. with:
  209. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot.img
  210. if-no-files-found: error
  211. archive: false
  212. - name: Upload Boot Image (boot-gz.img)
  213. uses: actions/upload-artifact@v7
  214. with:
  215. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-gz.img
  216. if-no-files-found: error
  217. archive: false
  218. - name: Upload Boot Image (boot-lz4.img)
  219. uses: actions/upload-artifact@v7
  220. with:
  221. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-lz4.img
  222. if-no-files-found: error
  223. archive: false
  224. - name: Prepare AnyKernel3 Zip
  225. uses: ./.github/actions/prepare-anykernel3
  226. - name: Upload Artifacts
  227. uses: actions/upload-artifact@v7
  228. with:
  229. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  230. path: ${{ github.workspace }}/AnyKernel3/**
  231. if-no-files-found: ignore
  232. compression-level: 9