http://blog.csdn.net/u011913612/article/details/52434445
通过上一节“android编译系统(三)-make”的分析,初步理清楚了编译初期加载产品相关信息的流程,整个过程主要涉及三个文件:1.AndroidProducts.mk,2.具体产品的配置文件,3.BoardConfig.mk,加上lunch需要的vendorsetup.sh文件,总共只需要四个文件就可以了,所以我们不妨成热打铁,赶紧尝试下如何新增一个产品。因此,android编译系统镜像文件的创建过程方到下一节。
一.文件创建
在device下创建如下目录:
cat
--fish
就是说我们的公司是cat,我们的产品fish。然后在fish下创建四个文件:
1.1vendorsetup.sh
这个文件内容如下:
- add_lunch_combo fish-eng
1.2AndroidProducts.mk
- PRODUCT_MAKEFILES :=
- $(LOCAL_DIR)/fish.mk
1.3fish.mk
- $(call inherit-product, device/generic/armv7-a-neon/mini_common.mk)
- PRODUCT_NAME := fish
- PRODUCT_DEVICE := fish
- PRODUCT_BRAND := Android
1.4BoardConfig.mk
- TARGET_NO_BOOTLOADER := true
- TARGET_NO_KERNEL := true
- TARGET_ARCH := x86
- TARGET_CPU_ABI := x86
- SMALLER_FONT_FOOTPRINT := true
- MINIMAL_FONT_FOOTPRINT := true
- # Some framework code requires this to enable BT
- BOARD_HAVE_BLUETOOTH := true
- BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/generic/common/bluetooth
- # Build OpenGLES emulation libraries
- BUILD_EMULATOR_OPENGL := true
- BUILD_EMULATOR_OPENGL_DRIVER := true
- USE_OPENGL_RENDERER := true
- BOARD_USE_LEGACY_UI := true
- # share the same one across all mini-emulators
- BOARD_EGL_CFG := device/generic/goldfish/opengl/system/egl/egl.cfg
- # PDK does not use ext4 image, but it is added here to prevent build break.
- TARGET_USERIMAGES_USE_EXT4 := true
- BOARD_SYSTEMIMAGE_PARTITION_SIZE := 576716800
- BOARD_USERDATAIMAGE_PARTITION_SIZE := 419430400
- BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
- BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
- BOARD_FLASH_BLOCK_SIZE := 512
- TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
二.尝试编译
首先source build/envsetup.sh,然后执行lunch :
菜单输出如下:
- Lunch menu... pick a combo:
- 1. aosp_arm-eng
- 2. aosp_arm64-eng
- 3. aosp_mips-eng
- 4. aosp_mips64-eng
- 5. aosp_x86-eng
- 6. aosp_x86_64-eng
- 7. fish-eng
- 8. mini_emulator_arm64-userdebug
- 9. m_e_arm-userdebug
- 10. mini_emulator_mips-userdebug
- 11. mini_emulator_x86_64-userdebug
- 12. mini_emulator_x86-userdebug
- Which would you like? [aosp_arm-eng] 7
- ============================================
- PLATFORM_VERSION_CODENAME=REL
- PLATFORM_VERSION=6.0
- TARGET_PRODUCT=fish
- TARGET_BUILD_VARIANT=eng
- TARGET_BUILD_TYPE=release
- TARGET_BUILD_APPS=
- TARGET_ARCH=x86
- TARGET_ARCH_VARIANT=x86
- TARGET_CPU_VARIANT=
- TARGET_2ND_ARCH=
- TARGET_2ND_ARCH_VARIANT=
- TARGET_2ND_CPU_VARIANT=
- HOST_ARCH=x86_64
- HOST_OS=linux
- HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty
- HOST_BUILD_TYPE=release
- BUILD_ID=MRA58K
- OUT_DIR=out
- ============================================
可以看到打印出了配置信息,TARGET_PRODUCT=fish,TARGET_BUILD_TYPE=eng等。
最后尝试编译,首先make clean,然后再make
编译结束后在out下生成对应产品的文件:
这只是一个简单的尝试,更加复杂的产品定制期待与大家共同探讨。