action.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: 'Build Kernel'
  2. description: 'Builds kernel using legacy build.sh or Bazel (kleaf)'
  3. inputs:
  4. bypass:
  5. description: 'Whether to add the bypass hack or not'
  6. required: true
  7. version:
  8. description: 'Kernel config version (e.g., android14-6.1)'
  9. required: true
  10. runs:
  11. using: composite
  12. steps:
  13. - name: 'Activate Bypass'
  14. shell: bash
  15. working-directory: ${{ github.workspace }}/kernel
  16. run: |
  17. set -euo pipefail
  18. if [ "${{ inputs.bypass }}" = "true" ]; then
  19. if [[ ${{ inputs.version }} == "android14-6.1" || ${{ inputs.version }} == "android15-6.6" || ${{ inputs.version }} == "android16-6.12" ]]; then
  20. TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module/version.c"
  21. else
  22. TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module.c"
  23. fi
  24. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
  25. if ! grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
  26. echo "Patch failed! 'return 1;' not found at bad_version:"
  27. grep -A 10 "bad_version:" "$TARGET_FILE" || true
  28. exit 1
  29. fi
  30. else
  31. echo "Bypass hack not applied as per input parameter."
  32. fi
  33. - name: Setup Kernel Configs
  34. if: false
  35. uses: ./.github/actions/set-kernel-config
  36. - name: 'Build Kernel'
  37. shell: bash
  38. working-directory: ${{ github.workspace }}/kernel
  39. run: |
  40. sed -i 's/check_defconfig//' ./common/build.config.gki
  41. if [ -f "build/build.sh" ]; then
  42. BUILD_GKI_ARTIFACTS= \
  43. BUILD_GKI_CERTIFICATION_TOOLS=0 \
  44. BUILD_SYSTEM_DLKM=0 \
  45. SKIP_VENDOR_BOOT=1 \
  46. SKIP_EXT_MODULES=1 \
  47. SKIP_CP_KERNEL_HDR=1 \
  48. SKIP_MRPROPER=1 \
  49. OUT_DIR="/home/runner/out" \
  50. LTO=thin \
  51. BUILD_CONFIG=common/build.config.gki.aarch64 \
  52. build/build.sh -j"$(nproc)" \
  53. CC="/usr/bin/ccache clang" \
  54. CXX="/usr/bin/ccache clang+" \
  55. HOSTCC="/usr/bin/ccache clang" \
  56. HOSTCXX="/usr/bin/ccache clang+" \
  57. LD="${{ github.workspace }}/kernel/common/ld-wrapper" \
  58. HOSTLD="${{ github.workspace }}/kernel/common/ld-wrapper"
  59. else
  60. tools/bazel info output_base
  61. cp "${{ github.workspace }}/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
  62. if [[ ${{ inputs.version }} == "android16-6.12" ]]; then
  63. tools/bazel run \
  64. --config=fast \
  65. --config=stamp \
  66. --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment \
  67. --disk_cache=/home/runner/.cache/bazel \
  68. //common:kernel_aarch64_dist \
  69. -- --destdir=/home/runner/out
  70. else
  71. tools/bazel run \
  72. --config=fast \
  73. --config=stamp \
  74. --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment \
  75. --disk_cache=/home/runner/.cache/bazel \
  76. //common:kernel_aarch64_dist \
  77. -- --dist_dir=/home/runner/out
  78. fi
  79. fi
  80. echo "Contents of /home/runner/out"
  81. ls /home/runner/out
  82. - name: 'Gather Build Artifacts'
  83. shell: bash
  84. working-directory: ${{ github.workspace }}
  85. run: |
  86. set -euo pipefail
  87. if [ -f "/home/runner/out/dist/Image" ]; then
  88. echo "Found Image at /home/runner/out/dist/Image"
  89. if [[ ${{ inputs.bypass }} == "true" ]]; then
  90. cp "/home/runner/out/dist/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"
  91. else
  92. cp "/home/runner/out/dist/Image" "${{ github.workspace }}/AnyKernel3/Image"
  93. echo "Kernel Version:"
  94. strings "/home/runner/out/dist/Image" | grep -m1 "^Linux version "
  95. fi
  96. exit 0
  97. fi
  98. if [ -f "/home/runner/out/Image" ]; then
  99. echo "Found Image at /home/runner/out/Image"
  100. if [[ ${{ inputs.bypass }} == "true" ]]; then
  101. cp "/home/runner/out/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"
  102. else
  103. cp "/home/runner/out/Image" "${{ github.workspace }}/AnyKernel3/Image"
  104. fi
  105. exit 0
  106. fi
  107. exit 1
  108. - name: 'Patch AnyKernel3 for Bypass Hack'
  109. shell: bash
  110. if: ${{ inputs.bypass == 'true' }}
  111. working-directory: ${{ github.workspace }}/AnyKernel3
  112. run: |
  113. set -euo pipefail
  114. cp ${{ github.action_path }}/patches/bypass.patch "${{ github.workspace }}/AnyKernel3/bypass.patch"
  115. patch -p1 < bypass.patch