| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- 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: 'Build Kernel'
- 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
-
- rm -rf "out"
- GKI_KCONFIG_FRAGMENT_PATH="${{ github.workspace }}/wild_gki.fragment"
- GKI_DEFCONFIG_WRAPPER_PATH="${{ github.workspace }}/wild_gki.wrap.sh"
- cat > "${GKI_DEFCONFIG_WRAPPER_PATH}" <<EOF
- append_cmd POST_DEFCONFIG_CMDS 'if [ -f "${GKI_KCONFIG_FRAGMENT_PATH}" ]; then \${KERNEL_DIR}/scripts/kconfig/merge_config.sh -m -O \${OUT_DIR} \${OUT_DIR}/.config "${GKI_KCONFIG_FRAGMENT_PATH}"; fi && (cd \${KERNEL_DIR} && make O=\${OUT_DIR} olddefconfig)'
- EOF
- # Override expensive GKI build.sh artifact defaults we do not need in CI.
- GKI_BUILD_CONFIG_FRAGMENT_PATH="${{ github.workspace }}/gki_build_overrides.fragment"
- cat > "${GKI_BUILD_CONFIG_FRAGMENT_PATH}" <<'EOF'
- BUILD_GKI_ARTIFACTS=
- BUILD_GKI_CERTIFICATION_TOOLS=0
- BUILD_SYSTEM_DLKM=0
- # Skip heavy packaging steps we don't need in CI
- SKIP_VENDOR_BOOT=1
- SKIP_EXT_MODULES=1
- SKIP_CP_KERNEL_HDR=1
- SKIP_MRPROPER=1
- EOF
- if [ -f "build/build.sh" ]; then
- #SKIP_MRPROPER=1 \
- LTO=thin \
- GKI_DEFCONFIG_FRAGMENT="${GKI_DEFCONFIG_WRAPPER_PATH}" \
- GKI_BUILD_CONFIG_FRAGMENT="${GKI_BUILD_CONFIG_FRAGMENT_PATH}" \
- 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+" \
- LD="${{ github.workspace }}/kernel/common/ld-wrapper" \
- HOSTLD="${{ github.workspace }}/kernel/common/ld-wrapper"
- else
- tools/bazel info output_base
- cp "${{ github.workspace }}/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
- tools/bazel build \
- --linkopt="--thinlto-cache-dir=/home/runner/.ld_cache" \
- --config=local \
- --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment \
- --disk_cache=/home/runner/.cache/bazel/disk \
- //common:kernel_aarch64
- tools/bazel info output_base
- fi
- ls
- ls out
- - name: 'Gather Build Artifacts'
- shell: bash
- working-directory: ${{ github.workspace }}
- run: |
- set -euo pipefail
- PATCH_FILE="${{ github.action_path }}/patches/bypass.patch"
- if [ -f "$PATCH_FILE" ]; then
- patch -d "${{ github.workspace }}/AnyKernel3" -p1 < "$PATCH_FILE"
- fi
- if [ -f "${{ github.workspace }}/kernel/out/${{ inputs.version }}/dist/Image" ]; then
- if [[ ${{ inputs.bypass }} == "true" ]]; then
- cp "${{ github.workspace }}/kernel/out/${{ inputs.version }}/dist/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"
- else
- cp "${{ github.workspace }}/kernel/out/${{ inputs.version }}/dist/Image" "${{ github.workspace }}/AnyKernel3/Image"
- fi
- exit 0
- fi
- if [ -f "${{ github.workspace }}/kernel/bazel-bin/common/kernel_aarch64/Image" ]; then
- if [[ ${{ inputs.bypass }} == "true" ]]; then
- cp "${{ github.workspace }}/kernel/bazel-bin/common/kernel_aarch64/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"
- else
- cp "${{ github.workspace }}/kernel/bazel-bin/common/kernel_aarch64/Image" "${{ github.workspace }}/AnyKernel3/Image"
- fi
- exit 0
- fi
- exit 1
|