| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- name: 'Build Kernel'
- description: 'Builds kernel using legacy build.sh or Bazel (kleaf)'
- inputs:
- bypass:
- description: 'Whether to add the bypass hack or not'
- required: true
- version:
- description: 'Kernel config version (e.g., android14-6.1)'
- required: true
- runs:
- using: composite
- steps:
- - name: 'Activate Bypass'
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- run: |
- set -euo pipefail
- if [ "${{ inputs.bypass }}" = "true" ]; then
- if [[ ${{ inputs.version }} == "android14-6.1" || ${{ inputs.version }} == "android15-6.6" || ${{ inputs.version }} == "android16-6.12" ]]; then
- TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module/version.c"
- else
- TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module.c"
- fi
- sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
- if ! grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
- echo "Patch failed! 'return 1;' not found at bad_version:"
- grep -A 10 "bad_version:" "$TARGET_FILE" || true
- exit 1
- fi
- else
- echo "Bypass hack not applied as per input parameter."
- fi
- - name: Setup Kernel Configs
- if: false
- uses: ./.github/actions/set-kernel-config
-
- - name: 'Build Kernel'
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- run: |
- sed -i 's/check_defconfig//' ./common/build.config.gki
- if [ -f "build/build.sh" ]; then
- BUILD_GKI_ARTIFACTS="" \
- BUILD_GKI_CERTIFICATION_TOOLS=0 \
- BUILD_SYSTEM_DLKM=0 \
- SKIP_VENDOR_BOOT=1 \
- SKIP_EXT_MODULES=1 \
- SKIP_CP_KERNEL_HDR=1 \
- OUT_DIR="/home/runner/out" \
- LTO=thin \
- BUILD_CONFIG=common/build.config.gki.aarch64 \
- build/build.sh -j"$(nproc)" \
- CC="/usr/bin/ccache clang" \
- CXX="/usr/bin/ccache clang+" \
- HOSTCC="/usr/bin/ccache clang" \
- HOSTCXX="/usr/bin/ccache clang+"
- else
- if [ "${{ inputs.bypass }}" = "false" ]; then
- sed -i '/name = "kernel_aarch64",/a\ check_defconfig = "disabled",' common/BUILD.bazel
- fi
- tools/bazel build \
- --config=fast \
- --config=stamp \
- --disk_cache=/home/runner/.cache/bazel \
- //common:kernel_aarch64/Image
- fi
- - name: 'Gather Build Artifacts'
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- run: |
- set -euo pipefail
- if [ -f "bazel-bin/common/kernel_aarch64/Image" ]; then
- echo "Found Image at bazel-bin/common/kernel_aarch64/Image"
- if [[ ${{ inputs.bypass }} == "true" ]]; then
- cp "bazel-bin/common/kernel_aarch64/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"
- else
- cp "bazel-bin/common/kernel_aarch64/Image" "${{ github.workspace }}/AnyKernel3/Image"
- fi
- exit 0
- fi
- if [ -f "/home/runner/out/dist/Image" ]; then
- echo "Found Image at /home/runner/out/dist/Image"
- if [[ ${{ inputs.bypass }} == "true" ]]; then
- cp "/home/runner/out/dist/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"
- else
- cp "/home/runner/out/dist/Image" "${{ github.workspace }}/AnyKernel3/Image"
- fi
- exit 0
- fi
- exit 1
- - name: 'Patch AnyKernel3 for Bypass Hack'
- shell: bash
- if: ${{ inputs.bypass == 'true' }}
- working-directory: ${{ github.workspace }}/AnyKernel3
- run: |
- set -euo pipefail
- cp ${{ github.action_path }}/patches/bypass.patch "${{ github.workspace }}/AnyKernel3/bypass.patch"
- patch -p1 < bypass.patch
|