Android源碼使用一個可定製的編譯系統來產生 特定的,針對自己硬體平台的Android系統,比如不使用預設的out/target/prodect/generic目錄,
本文檔簡單介紹了這個編譯系統,並做一個針對自己硬體平台的Android,
這部分工作主要是由Android原始碼中的Vendor檔案夾來實現,如果該檔案夾不成立,
自己可以在Android原始碼的根目錄下建立該檔案夾,這個檔案夾裡面存放特定的檔案,比如自己板子上的3G驅動,WIFI驅動,
自己的應用程式,都可以放在這裡。提取檔案系統的時候,可以把這個檔案夾裡面的東東放到檔案系統裡面,這樣使用者可以清晰的
看到你的板子特有的功能。
一、細節描述下面幾步描述了如何配置makefile來為運行Android的裝置編譯系統。1、在/vendor/目錄下建立company目錄mkdir 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檔案。 # # This file should set PRODUCT_MAKEFILES to a list of product makefiles # to expose to the build system. LOCAL_DIR will already be set to # the directory containing this file. # # This file may not rely on the value of any variable other than # LOCAL_DIR; do not use any conditionals, and do not look up the # value of any variable that isn't set in this file or in a file that # it includes. # 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檔案# These definitions override the defaults in config/config.make for <board_name> # # TARGET_NO_BOOTLOADER := false # TARGET_USE_GENERIC_AUDIO := true8、如果你想修改系統屬性,在目錄vendor/<company_name>/<board_name>下建立一個system.prop檔案。# system.prop for # This overrides settings in the products/generic/system.prop file # # rild.libpath=/system/lib/libreference-ril.so # rild.libargs=-d /dev/ttyS09、在products/AndroidProducts.mk檔案中添加一個指向<second_product_name>.mk的引用。PRODUCT_MAKEFILES := / $(LOCAL_DIR)/first_product_name.mk / $(LOCAL_DIR)/second_product_name.mk10、目錄vendor/<company_name>/<board_name>下必須包含一個Android.mk檔案,這個檔案中至少包含下面的代碼: # make file for new hardware from # LOCAL_PATH := $(call my-dir) # # this is here to use the pre-built kernel 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) # # no boot loader, so we don't need any of that stuff.. # LOCAL_PATH := vendor/<company_name>/<board_name> # include $(CLEAR_VARS) # # include more board specific stuff here? Such as Audio parameters. #11、想為相同的board建立第二個product時,建立一個名字為vendor/company_name/products/<second_product_name>.mk的make檔案,這個檔案中包含:$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk) # # Overrides PRODUCT_NAME := <second_product_name> PRODUCT_DEVICE := <board_name>目前為止,你已經有了兩個新product,<first_product_name>和<second_product_name>,都屬於<company_name>。驗證一下一個product是否配置正確,運行 . build/envsetup.sh make PRODUCT-<first_product_name>-user在/out/target/product/<board_name>目錄下,你可以看到產生的二進位檔案。二、產品檔案樹沒有翻譯三、product定義檔案不同的產品,在它的product定義檔案中會對一些變數賦予不同的值,product定義檔案可以從其它product定義檔案中繼承。Product定義檔案中包含的變數如下:
Parameter |
Description |
Example |
PRODUCT_NAME |
End-user-visible name for the overall product. Appears in the "About the phone" info. |
|
PRODUCT_MODEL |
End-user-visible name for the end product |
|
PRODUCT_LOCALES |
A 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_CA
|
PRODUCT_PACKAGES |
Lists the APKs to install. 在這個product中要安裝的APK列表。 |
Calendar Contacts
|
PRODUCT_DEVICE |
Name of the industrial design 生產商的名字 |
dream
|
PRODUCT_MANUFACTURER |
Name of the manufacturer 製造商的名字 |
acme
|
PRODUCT_BRAND |
The brand (e.g., carrier) the software is customized for, if any 軟體定製後的分支標識。 |
|
PRODUCT_PROPERTY_OVERRIDES |
List of property assignments in the format "key=value" 屬性列表,以"key=value"形式列出。 |
|
PRODUCT_COPY_FILES |
List 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_KEYS |
List of OTA public keys for the product |
|
PRODUCT_POLICY |
Indicate which policy this product should use |
|
PRODUCT_PACKAGE_OVERLAYS |
Indicate whether to use default resources or add any product specific overlays |
vendor/acme/overlay
|
PRODUCT_CONTRIBUTORS_FILE |
HTML file containing the contributors to the project. 包含了項目貢獻者名字列表的HTML檔案。 |
|
PRODUCT_TAGS |
list of space-separated words for a given product |
|
下面給出了一個經典的product定義檔案$(call inherit-product, build/target/product/generic.mk)#OverridesPRODUCT_NAME := MyDevicePRODUCT_MANUFACTURER := acmePRODUCT_BRAND := acme_usPRODUCT_LOCALES := en_GB es_ES fr_FRPRODUCT_PACKAGE_OVERLAYS := vendor/acme/overlay
本部落格參考CSDN網友 http://blog.csdn.net/a345017062/archive/2010/12/24/6096807.aspx ,最近自己需要製作Vendor,非常需要這樣的資料,在此感謝網友的部落格。