当前位置:操作系统 > 安卓/Android >>

andorid系统配置及编译过程

android系统正以迅雷不及掩耳之势冲击着智能手机与平板电脑市场,它颠覆了传统手机的概念,将手机与平板电脑进行了一次大洗牌,最可贵的是他的开放性(虽不是完全开放)吸引了一大批工程师去改造它,完善它,任何人都可以下载到它的源代码一睹它的真面目。这一节讲讲这样从头配置一个属于你的android系统,至于如何获取android源代码这里就不讲了。本文是在假设你已经从android官网上获取了其源代码的基础上讲解的。
1.Create a company directory in //vendor/.
   mkdir vendor/<company_name>
   这一步是先在vendor(供货商) 下新建一个目录,用你公司名字命名,没有的公司的就随便编一个吧(:
2.Create a products directory beneath the company directory you created in step 1.
   mkdir vendor/<company_name>/products/
   同上,创建一个目录,用你产品的名字命名吧
3.Create a product-specific makefile, called vendor/<company_name>/products/<first_product_name>.mk, that includes    at least the following code:
   $(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
   #
   # Overrides
   PRODUCT_NAME := <first_product_name>
   PRODUCT_DEVICE := <board_name>

 在/products/ 目录下建立一个mk文件,内容格式如上所示,拿个mini6410.mk的例子给大家看看:
 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)

 # Overrides
 PRODUCT_MANUFACTURER := FriendlyARM
 PRODUCT_BRAND := FriendlyARM
 PRODUCT_NAME := mini6410
 PRODUCT_DEVICE := mini6410
 ***************************************************
 mini6410.mk的路径为/Android-2.2/vendor/friendly-arm/products/mini6410.mk l;这也验证了上述1,2两步。

 4.在上述*.mk文件中添加可选的定义,这个就不多说了。
 5.In the products directory, create an AndroidProducts.mk file that point to (and is responsible for finding) the          individual product make files.
#
# 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.Create a board-specific directory beneath your company directory that matches the PRODUCT_DEVICE variable <board_name> referenced in the product-specific make file above. This will include a make file that gets accessed by any product using this board.
mkdir vendor/<company_name>/<board_name>

 在你公司的目录下添加一个目录,名字命名为板子的名字,如:Android-2.2/vendor/friendly-arm/mini6410,其中mini6410就是开发板的名字,这个目录下的文件比较重要。接下来为了好叙述,就借用mini6410的例子吧。
 7.在Android-2.2/vendor/friendly-arm/mini6410目录下创建BoardConfig.mk文件
    先看看这个文件的内容是怎样的:
  
[cpp] 
# config.mk  
#  
# Product-specific compile-time definitions.  
#  
 
# The generic product target doesn't have any hardware-specific pieces.  
TARGET_CPU_ABI := armeabi 
TARGET_NO_BOOTLOADER := true 
TARGET_NO_KERNEL := true 
TARGET_PROVIDES_INIT_RC := true 
 
# Customized map  
TARGET_PRELINKER_MAP := vendor/friendly-arm/products/prelink-linux-arm-FA.map 
 
# Hardware 3D  
TARGET_HARDWARE_3D := false 
 
# Audio  
BOARD_USES_ALSA_AUDIO := true 
BUILD_WITH_ALSA_UTILS := true 
 
# Camera  
BOARD_CAMERA_LIBRARIES := libcamera 
BOARD_S3CJPEG_LIBRARIES := libs3cjpeg 
 
# Wi-Fi  
BOARD_HAVE_LIBWIFI := true 
#BOARD_WPA_SUPPLICANT_DRIVER := WEXT  
BOARD_WPA_SUPPLICANT_DRIVER := CUSTOM 
#CONFIG_DRIVER_NL80211 := true  
WPA_BUILD_SUPPLICANT := true 
#WPA_SUPPLICANT_VERSION := VER_0_6_X  
CONFIG_CTRL_IFACE := y 
 
# Bluetooth  
BOARD_HAVE_BLUETOOTH := true 
 
# GPS  
BOARD_GPS_LIBRARIES :=libgps 
   BoardConfig.mk文件是干嘛的呢,从上面的例子代码中你也许能猜出来,BoardConfig.mk是用来定制你的设备具有什么功能的,比如说是否支持摄像头,GPS导航等一些板级定制。该文件是我们定制android系统中比较重要的一个文件。
8.修改系统属性。
   该项不是必须的,但大部分情况下我们深度定制系统时都要修改系统属性。
   如何修改呢,在/Android-2.2/vendor/friendly-arm/mini6410/下创建一个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/ttyS0
 9.在/Android-2.2/vendor/friendly-arm/products添加AndroidProducts.mk文件,该文件下可包含多个board_name.mk文件,即多个设备。代码如下所示:
   PRODUCT_MAKEFILES := /
   $(LOCAL_DIR)/first_product_name.mk /
   $(LOCAL_DIR)/second_product_name.mk
 10.在/Android-2.2/vendor/friendly-arm/mini6410下添加Android.mk文件,该文件至少包含以下内容:
[cpp] view plaincopy
# 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.       

 到此为止,初步定制基本完成,该配置部分的架构如下图所示:
 
Android以模块的形式来组织各个系统中的部件,Eng专业点的词汇就是Module,就是各位在几乎每个目录下都能看到的Android.mk。可以简单地把Android所有的Make文件分为4种:
      1、For config
      这类文件主要来配置product,board,以及根据你的Host和Target选择相应的工具以及设定相应的通用编译选项:
      build/core/config.mk         summary of config
      build/core/envsetup.mk    generate dir config and so on
      build/target/product         product config
      build/target/board            board config
      build/core/combo       &nb

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,