diff options
author | Bowgo Tsai <bowgotsai@google.com> | 2022-05-18 15:25:05 +0800 |
---|---|---|
committer | Treehugger Robot <treehugger-gerrit@google.com> | 2022-05-23 16:58:20 +0000 |
commit | 5f16f3e97495fd476113be0712c8ebf2be906832 (patch) | |
tree | 5ce1cfe19afa47c77cbdf11db8ee2ac1e297c4a8 /build_utils.sh | |
parent | 4b0e1bddd1f654cfff30b496e5f4e41e23def188 (diff) | |
download | build-5f16f3e97495fd476113be0712c8ebf2be906832.tar.gz |
Support building a boot.img for x86_64 GKI
e.g., the following config:
BUILD_GKI_ARTIFACTS=1
BUILD_GKI_BOOT_IMG_SIZE=67108864
will generate a boot.img under ${DIST_DIR} by packing
the kernel image ${DIST_DIR}/bzImage with an Android
boot v4 header.
Bug: 232906147
Test: BUILD_CONFIG=common/build.config.gki.x86_64 build/build.sh
Change-Id: I595187596da64c1863038ab6d0b67fa596b6111a
Diffstat (limited to 'build_utils.sh')
-rw-r--r-- | build_utils.sh | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/build_utils.sh b/build_utils.sh index dc0e524..acb0994 100644 --- a/build_utils.sh +++ b/build_utils.sh @@ -505,9 +505,27 @@ function gki_add_avb_footer() { --partition_name boot --partition_size "$2" } -function build_gki_artifacts() { - check_mkbootimg_path +function build_gki_artifacts_x86_64() { + kernel_path="${DIST_DIR}/bzImage" + boot_image_path="${DIST_DIR}/boot.img" + + if ! [ -f "${kernel_path}" ]; then + echo "ERROR: '${kernel_path}' doesn't exist" >&2 + exit 1 + fi + + GKI_MKBOOTIMG_ARGS=("--header_version" "4") + if [ -n "${GKI_KERNEL_CMDLINE}" ]; then + GKI_MKBOOTIMG_ARGS+=("--cmdline" "${GKI_KERNEL_CMDLINE}") + fi + GKI_MKBOOTIMG_ARGS+=("--kernel" "${kernel_path}") + GKI_MKBOOTIMG_ARGS+=("--output" "${boot_image_path}") + "${MKBOOTIMG_PATH}" "${GKI_MKBOOTIMG_ARGS[@]}" + + gki_add_avb_footer "${boot_image_path}" "$(gki_get_boot_img_size)" +} +function build_gki_artifacts_aarch64() { if ! [ -f "${DIST_DIR}/Image" ]; then echo "ERROR: '${DIST_DIR}/Image' doesn't exist" >&2 exit 1 @@ -543,3 +561,16 @@ function build_gki_artifacts() { echo "Creating ${GKI_BOOT_IMG_ARCHIVE} for" "${built_boot_images[@]}" tar -czf "${DIST_DIR}/${GKI_BOOT_IMG_ARCHIVE}" -C "${DIST_DIR}" "${built_boot_images[@]}" } + +function build_gki_artifacts() { + check_mkbootimg_path + + if [ "${ARCH}" = "arm64" ]; then + build_gki_artifacts_aarch64 + elif [ "${ARCH}" = "x86_64" ]; then + build_gki_artifacts_x86_64 + else + echo "ERROR: unknown ARCH to BUILD_GKI_ARTIFACTS: '${ARCH}'" >&2 + exit 1 + fi +} |