build.yml 9.4 KB

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