AndroidProducts.mk

We included all product definition Makefiles in this file. The AOSP build system will start to search all product definitions using this file. The following is the content of AndroidProducts.mk:

PRODUCT_MAKEFILES :=  
$(LOCAL_DIR)/x86emu_x86.mk
$(LOCAL_DIR)/x86emu_x86_64.mk

As we can see, we defined two product variants for x86 and x86_64 builds.

Both x86emu_x86.mk and x86emu_x86_64.mk are very similar. They define the same set of product definition variables for 32 bit and 64 bit.

The following table compares the product definition Makefiles for 32-bit and 64-bit build:

x86emu_x86.mk

x86emu_x86_64.mk

$(call inherit-product, device/generic/x86emu/device.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/full.mk)
# Overrides
PRODUCT_BRAND := x86emu_x86
PRODUCT_NAME := x86emu_x86
PRODUCT_DEVICE = x86emu
PRODUCT_MODEL := x86emu_x86_ch4
TARGET_ARCH := x86
TARGET_KERNEL_CONFIG := i386_ranchu_defconfig
$(call inherit-product, $(LOCAL_PATH)/x86emu_base.mk)
$(call inherit-product, device/generic/x86emu/device.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_x86_64.mk)
# Overrides
PRODUCT_BRAND := x86emu_x86_64
PRODUCT_NAME := x86emu_x86_64
PRODUCT_DEVICE = x86emu
PRODUCT_MODEL := x86emu_x86_64_ch4
TARGET_SUPPORTS_32_BIT_APPS := true
TARGET_SUPPORTS_64_BIT_APPS := true
TARGET_ARCH := x86_64
TARGET_KERNEL_CONFIG := x86_64_ranchu_defconfig
$(call inherit-product, $(LOCAL_PATH)/x86emu_base.mk)

You may notice that we inherit the common product definition files for 32-bit and 64-bit first at the beginning:

$(call inherit-product, $(SRC_TARGET_DIR)/product/full.mk) 

And:

$(call inherit-product, $(SRC_TARGET_DIR)/product/full_x86_64.mk) 

There are many generic product definitions defined by the AOSP build system. You can find them at $AOSP/build/target/product:

$ ls build/target/product
AndroidProducts.mk full_base.mk sdk_base.mk
aosp_arm64.mk full_base_telephony.mk sdk_mips.mk
aosp_arm.mk full_mips64.mk sdk.mk
aosp_base.mk full_mips.mk sdk_phone_arm64.mk
aosp_base_telephony.mk full.mk sdk_phone_armv7.mk
aosp_mips64.mk full_x86_64.mk sdk_phone_mips64.mk
aosp_mips.mk full_x86.mk sdk_phone_mips.mk
aosp_x86_64.mk generic_armv5.mk sdk_phone_x86_64.mk
aosp_x86.mk generic_mips.mk sdk_phone_x86.mk
base.mk generic.mk sdk_x86_64.mk
core_64_bit.mk generic_no_telephony.mk sdk_x86.mk
core_base.mk generic_x86.mk security
core_minimal.mk languages_full.mk telephony.mk
core.mk languages_small.mk vboot.mk
core_tiny.mk locales_full.mk verity.mk
embedded.mk runtime_libart.mk
emulator.mk sdk_arm64.mk

After that, a set of product definition variables PRODUCT_BRAND, PRODUCT_NAME, PRODUCT_DEVICE, and PRODUCT_MODEL are defined with different values. TARGET_ARCH and TARGET_KERNEL_CONFIG are also defined for 32 bit and 64 bit separately. Pay attention to PRODUCT_MODEL. Since we will change Makefiles in each chapter, in this book we use PRODUCT_MODEL to indicate the build for each chapter. In this chapter, we define PRODUCT_MODEL as x86emu_x86_ch4 for the build in this chapter. At the end of the file, we also include a common Makefile x86emu_base.mk for both 32-bit and 64-bit products. This file includes additional configurations for the kernel build:

TARGET_KERNEL_SOURCE := kernel 

PRODUCT_OUT ?= out/target/product/x86emu

include $(TARGET_KERNEL_SOURCE)/AndroidKernel.mk

# define build targets for kernel
.PHONY: $(TARGET_PREBUILT_KERNEL)

LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)

PRODUCT_COPY_FILES +=
$(LOCAL_KERNEL):kernel

The kernel build is usually not included in the AOSP build. You have to build them separately according to the instructions from Google. In this book, we integrate the kernel build in our own Makefile here. The kernel AndroidKernel.mk Makefile is created based on the Makefile of the Qualcomm kernel source at https://android.googlesource.com/kernel/msm/.

There are many product definition variables used in the preceding Makefiles. Let's review the product definition variables that we used here. Refer to the Google documents for the complete list:

  • PRODUCT_BRAND: This is the brand that the software is customized for. We just defined it as our device name.
  • PRODUCT_NAME: This is the product name that we give to the device. We set it to x86emu_x86 in this book. It is also the prefix that we can select in the lunch combo, such as x86emu_x86-eng. The suffix is the build variants.
  • PRODUCT_DEVICE: The name of the actual product. TARGET_DEVICE derives from this variable. This is also the board name that the build system uses to locate BoardConfig.mk. It is the x86emu for our device and it is also the directory name of our device at $AOSP/device/generic/x86emu.
  • PRODUCT_MODEL: This is the name that we can see in the settings in Model. As I mentioned earlier, we use this variable to differentiate the build of each chapter in this book.
  • PRODUCT_OUT: This is the output folder of the build result. It is the same as the environment variable $OUT.
  • PRODUCT_COPY_FILES: This is a list of specific files that we would like to copy to the target's filesystem. The list of words looks like source_path:destination_path. The file at the source path should be copied to the destination path during the build process.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.218.130