andorid系统的定制

来源:互联网 发布:mc建筑装饰 知乎 编辑:程序博客网 时间:2024/05/16 08:16
配置makefile来为运行android的设备编译系统
1. 在/vendor/目录下创建company目录
make vendor/<company_name>
2. 在company目录下创建一个products目录
mkdir vendor/<company_name>/products/
3. 创建一个设备相关的makefile:vendor/<company_name>/products/<first_product_name>.mk这个 make文件中至少要包含下面代码:
$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
#
#Overrides
PRODUCT_NAME:=<first_product_name>
PRODUCT_DEVICE:=<board_name>
4. 在产品定义文件中添加设备相关的变量
5. 在products目录下,创建一个AndroidProducts.mk文件,这个文件指向设备的make文件
PRODUCT_MAKEFILES:=/
$(LOCAL_DIR)/first_product_name.mk /
6. 在company目录下创建一个包含特定board特征的目录,这个目录需要与PRODUCT_DEVICE这个目录中的<board_name>相匹配。这个目录下会包含一个make文件,这个make文件可以用下面的方式访问到,比如:
mkdir vendor/<company_name>/<board_name>
7. 在上步的目录(vendor/<company_name>/<board_name>)下,创建一个BoardConfig.mk文件。
TARGET_USE_GENERIC_AUDIO:=true
8. 如果想修改系统属性,在目录vendor/<company_name>/<board_name>下创建一个system.prop文件
9. 在products/AndroidProducts.mk文件中添加一个指向<second_product_name>.mk的引用
PRODUCT_MAKEFILE:=/
$(LOCAL_DIR)/first_product_name.mk/
$(LOCAL_DIR)/second_product_name.mk
10. 目录vendor/<company_name>/<board_name>下必须包含一个Android.mk文件,这个文件中至少要包含下面的代码:
LOCAL_PATH:=$(call my-dir)
ifeq( $( TARGET_PREBUILT_KERNEL ), )
TARGET_PREBUILT_KERNEL:=$(LOCAL_PATH)/kernel
endif
file:=$( INSTALLED_KERNEL_TARGET )
ALL_PREBUILT += $( file )
$( file ): $( TARGET_PREBUILT_KERNEL ) | $( ACP )
$(transform-prebuilt-to-target)

LOCAL_PATH:=vendor/<company_name>/<board_name>
include $(CLEAR_VARS)
11. 想为相同的board创建第二个product时,创建一个名字为vendor/company_name/products/<second_product_name>.mk的make文件,这个文件中包含:
$( call inherit-product, $( SRC_TARGET_DIR )/product/generic.mk )
PRODUCT_NAME:=<second_product_name>
PRODUCT_DEVICE:=<board_name>
目前,已经有2个新product,<first_product_name>和<second_product_name>,都属于<company_name>,验证一下一个product是否匹配正确,运行
. build/envsetup.sh
make PRODUCT-<first_product_name>-user
在/out/target/product/<board_name>目录下,可以看到生成的二进制文件。
12. product定义文件
不同产品,在它的product定义文件中会对一些变量赋予不同的值,product定义文件可以从其他product定义文件中继承。product定义文件中包含的变量如下:
ParameterDescriptionExamplePRODUCT_NAMEEnd-user-visible name for the overall product. Appears in the "About the phone" info. PRODUCT_MODELEnd-user-visible name for the end product PRODUCT_LOCALESA space-separated list of two-letter language code, two-letter country code pairs that describe several settings for the user, such as the UI language and time, date and currency formatting. The first locale listed in PRODUCT_LOCALES is is used if the locale has never been set before. 地区标识en_GB de_DE es_ES fr_CAPRODUCT_PACKAGESLists the APKs to install. 在这个product中要安装的APK列表。Calendar ContactsPRODUCT_DEVICEName of the industrial design 生产商的名字dreamPRODUCT_MANUFACTURERName of the manufacturer 制造商的名字acmePRODUCT_BRANDThe brand (e.g., carrier) the software is customized for, if any 软件定制后的分支标识。 PRODUCT_PROPERTY_OVERRIDESList of property assignments in the format "key=value" 属性列表,以"key=value"形式列出。 PRODUCT_COPY_FILESList of words like source_path:destination_path. The file at the source path should be copied to the destination path when building this product. The rules for the copy steps are defined in config/Makefile 当编译时,源路径上的文件会被复制到目标路径上去,具体的复制规则在config/Makefile中定义。 PRODUCT_OTA_PUBLIC_KEYSList of OTA public keys for the product PRODUCT_POLICYIndicate which policy this product should use PRODUCT_PACKAGE_OVERLAYSIndicate whether to use default resources or add any product specific overlaysvendor/acme/overlayPRODUCT_CONTRIBUTORS_FILEHTML file containing the contributors to the project. 包含了项目贡献者名字列表的HTML文件。 PRODUCT_TAGSlist of space-separated words for a given product

下面给出一个经典的product定义文件:
$(call inherit-product, build/target/product/generic.mk)
#Overrides
PRODUCT_NAME:=MyDevice
PRODUCT_MANUFACTURER:=acme
PRODUCT_BRAND:=acme_us
PRODUCT_LOCALES:=en_GB es_ES fr_FR
PRODUCT_PACKAGE_OVERLAYS:=vendor/acme/overlay
0 0