爲何有此記錄?一個project有兩個可供選擇的內核,可是我不知道怎樣經過命令行來解決到底編譯進哪一個內核,最終問題解決了(不是經過命令行,按照device.mk的要求放入指定的目錄就能夠了):html
參考: http://blog.csdn.net/dalianmaoblog/article/details/6614970java
main.mk:node
TARGET_BUILD_VARIANT | tags_to_install | ADDITIONAL_DEFAULT_PROPERTIES |
user | user | ro.secure=1 ro.allow.mock.location=0 |
eng | user debug eng | ro.setupwizard.mode=OPTIONAL |
tests | user debug eng | |
sdk | user debug eng | xmpp.auto-presence=true ro.config.nocheckin=yes |
user debug | user debug | ro.secure=1 dalvik.vm.lockprof.threshold=500 ro.allow.mock.location=0 ro.debuggable=1 persist.service.adb=1 |
.PHONY:checkbuiltlinux checkbuilt: $(modules-to-check)android |
生成沒有定義LOCAL_DONT_CHECK_MODULE的模塊並拷貝到系統目錄shell |
.PHONY:prebuiltwindows prebuit: $(ALL_PREBUILT)app |
拷貝預編譯的文件(好比用include prebuild.mk編譯的)到系統目錄函數 |
.PHONY: files工具 files: prebuilt checkbuilt moduls-to-install $(INSTALLED_ANDROID_INFO_TXT_TARGET) |
生成全部目標文件(包括:prebuile,modules-to-install,modules-to-check,INSTALLED_ANDROID_INFO_TXT_TARGET)並拷貝到系統目錄。INSTALLED_ANDROID_INFO_TXT_TARGET在build/target/board/Android.mk定義=out/target/product/**/android-info.txt |
.PHONY: ramdisk ramdisk: $(INSTALL_RAMDISK_TARGET) |
生成ramdisk.img $(HOST_OUT_EXECUTABLES)/mkbootfs $(PRODUCT_OUT)/root|$(HOST_OUT_EXECUTABLES)/minizip > $(PRODUCT_OUT)/ramdisk.img |
.PHONY: systemimage systemimage: $(INSTALL_SYSTEMIMAGE) |
生成system.img $(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(PRODUCT_OUT)/system$(PRODUCT_OUT)/obj/PACKING/systemimage_unopt_intermediates/system.img cp **/system.img (PRODUCT_OUT)/system.img |
.PHONY: userdataimage userdataimage:$(INSTALL_USERDATAIMAGE_TARGET) |
生成data.img $(HOST_OUT_EXECUTABLES)/mkyaffs2image $(PRODUCT_OUT)/data $(PRODUCT_OUT)/data.img |
.PHONY: bootimage bootimage: $(INSTALL_BOOTIMAGE_TARGET) |
生成boot.img if(TARGET_NO_KERNEL=true), INSTALL_BOOTIMAGE_TARGET=$(PRODUCT_OUT)/boot.img else $(PRODUCT_OUT)/boot.img=. 參數: INTERNAL_BOOTIMAGE_ARGS := \ $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ --kernel $(INSTALLED_KERNEL_TARGET) \ --ramdisk $(INSTALLED_RAMDISK_TARGET) $(HOST_OUT_EXECUTABLES)/mkbootimg --kernel $(PRODUCT_OUT)/kernel –ramdisk $(PRODUCT_OUT)/ramdisk.img >$(PRODUCT_OUT)/boot.img |
.PHONY: recoveryimage recoveryimage:$(INSTALL_RECOVERYIMAGE_TARGET) |
目錄$(PRODUCT_OUT) rm -rf recovery mkdir -p recovery mkdir -p recovery/root mkdir -p recovery/root/etc mkdir -p recovery/root/tmp cp -R root recovery/root cp -f /bootable/recovery/init.rc recovery/root/ cp -f obj/EXECUTABLES/recovery_intermediates/recovery recovery/root/sbin/ cp -rf /bootable/recovery/res recovery/root/ $(foreach item,/build/target/product/**/recovery/res cp -rf $(item) recovery/root/) cp /obj/PACKAGING/ota_keys_ intermediates/keys recovery/res/keys cat root/default.prop system/build.prop > recovery/root/default.prop
$(HOST_OUT_EXECUTABLES)/mkbootfs$(PRODUCT_OUT)/recovery/root|$(HOST_OUT_EXECUTABLES)/minizip > $(PRODUCT_OUT)/ramdisk-recovery.img $(HOST_OUT_EXECUTABLES)/mkbootimg --kernel $(PRODUCT_OUT)/kernel –ramdisk$(PRODUCT_OUT)/ramdisk-recovery.img > $(PRODUCT_OUT)/recovery.img |
.PHONY: droidcore droidcore: files \ systemimage \ $(INSTALLED_BOOTIMAGE_TARGET) \ $(INSTALLED_RECOVERYIMAGE_TARGET) \ $(INSTALLED_USERDATAIMAGE_TARGET) \ $(INSTALLED_FILES_FILE) |
生成整個系統 system.img ramdisk.img/boot.img ramdisk-recovery.img recovery.img userdata.img installed-files.txt |
.PHONY: apps_only |
生成TARGET_BUILD_APPS指定的APPS模塊. 若TARGET_BUILD_APPS包含all就編譯所有APPS模塊 |
droid |
默認target ifneq ($(TARGET_BUILD_APPS),) droid: apps_only else droid:droidcore |
.PHONY: sdk |
生成sdk |
.PHONY: clean |
刪除生成文件 |
.PHONY: clobber |
|
.PHONY: modules
.PHONY: showcommands
|
顯示命令
顯示全部模塊名 |
config.mk:
envsetup.mk:
包含include$(BUILD_SYSTEM)/version_defaults.mk 設置那些咱們須要設置的變量的缺省值。這個文件咱們不該該改動,改動應該在build_id.mk裏。
PLATFORM_VERSION
|
|
PLATFORM_SDK_VERSION
|
|
PLATFORM_VERSION_CODENAME
|
|
DEFAULT_APP_TARGET_SDK
|
|
BUILD_ID
|
|
BUILD_NUMBER |
|
在文件buildspec.mk裏或經過envsetup.sh設置變量的缺省值。
TARGET_PRODUCT |
generic(TARGET_SIMULATOR := false) sim(TARGET_SIMULATOR:=false) |
TARGET_BUILD_VARIANT |
eng |
HOST_OS |
windows/linux/darwin |
HOST_ARCH |
x86/ppc |
HOST_BUILD_TYPE |
release |
TARGET_OS |
linux |
TARGET_ARCH |
arm |
TARGET_BUILD_TYPE |
release |
包含include$(BUILD_SYSTEM)/product_config.mk。定義了兩種MAKECMDGOALS參數形式,根據product和device目錄下的mk文件生成相應的PRODUCTS_xxx_xxx和DEVICES_xxx_xxx變量,中間的是文件的路徑,後面的是文件裏定義的變量。
設置一些列路徑變量。主機路徑以HOST_OUT_* 或HOST_*_OUT_*形式,目標機路徑以TARGET_OUT_* 或TARGET_*_OUT_*形式。
根據MAKECMDGOALS,若其中包含dumpvar-%或dumpvar-abs-%,就生成一個以dumpvar-%或dumpvar-abs-%命名的make目標。實現是打印出%所表示的變量的值。這個變量必需要在這以前已經定義了,後一種在前面還打印出當前的路徑。這兩種狀況必需要先設置CALLED_FROM_SETUP=true。envsetup.sh的get_build_var和get_abs_build_var()函數就是運用的這個原理打印變量的值。
# Get the exact value of a buildvariable. function get_build_var() { T=$(gettop) if [ ! "$T" ]; then echo "Couldn't locate the top of the tree. Try setting TOP." >&2 return fi CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ make--no-print-directory -C "$T" -f build/core/config.mk dumpvar-$1 } # Get the value of a build variable asan absolute path. function get_abs_build_var() { T=$(gettop) if [ ! "$T" ]; then echo "Couldn't locate the top of the tree. Try setting TOP." >&2 return fi CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ make --no-print-directory -C "$T"-f build/core/config.mk dumpvar-abs-$1 }
product_config.mk:
函數名 |
說明 |
node_fns.mk Import- nodes $(1) $(2) $(3) |
import-nodes須要3個入口參數: |
product.mk |
獲得device/和vendor/, 包括子目錄,以及build/target/product/下的AndroidProducts.mk文件列表 |
product.mk |
獲得全部AndroidProducts.mk文件中 PRODUCT_MAKEFILES變量定義的mk文件列表 |
product.mk |
調用import-nodes(node_fns.mk),設置$1=PRODUCTS,設置$3=$(_product_var_list),_product_var_list是以PRODUCT_開頭的變量名。 |
product.mk |
將在全部的PRODUCT_xxx變量值後綴加上'@inherit:<mk文件>' |
product.mk |
檢查PRODUCT_NAME,PRODUCT_BRAND,PRODUCT_COPY_FILES定義的是否正確 |
product.mk |
根據product的名字,獲得定義它的mk文件路徑 (resolve-short-product-name generic → /build/target/product/generic.mk) |
device.mk |
調用import-nodes(node_fns.mk),設置$1=DEVICES,設置$3=$(_device_var_list),_device_var_list是以DEVICE_開頭的變量名。 |
device.mk |
將在全部的DEVICE_變量值後綴加上'@inherit:<mk文件>' |
device.mk |
根據device的名字,獲得定義它的mk文件路徑 |
cleanbuild.mk:
Makefile:
Android.mk的說明,以camera爲例:
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) ifeq ($(USE_CAMERA_STUB),) USE_CAMERA_STUB:=false ifneq ($(filter sooner genericsim,$(TARGET_DEVICE)),) USE_CAMERA_STUB:=true endif #libcamerastub endif ifeq ($(USE_CAMERA_STUB),true) include $(CLEAR_VARS) LOCAL_SRC_FILES:= CameraHardwareStub.cpp FakeCamera.cpp LOCAL_MODULE:= libcamerastub ifeq ($(TARGET_SIMULATOR),true) LOCAL_CFLAGS += -DSINGLE_PROCESS endif LOCAL_SHARED_LIBRARIES:= libui include $(BUILD_STATIC_LIBRARY) endif # USE_CAMERA_STUB include $(CLEAR_VARS) LOCAL_SRC_FILES:= CameraService.cpp LOCAL_SHARED_LIBRARIES:= \ libui libutils libbinder libcutils libmedia libcamera_client \ libsurfaceflinger_client LOCAL_MODULE:= libcameraservice LOCAL_CFLAGS +=-DLOG_TAG=\"CameraService\" ifeq ($(TARGET_SIMULATOR),true) LOCAL_CFLAGS += -DSINGLE_PROCESS endif ifeq ($(USE_CAMERA_STUB), true) LOCAL_STATIC_LIBRARIES += libcamerastub LOCAL_CFLAGS += -includeCameraHardwareStub.h else LOCAL_SHARED_LIBRARIES += libcamera endif include $(BUILD_SHARED_LIBRARY)
BUILD_SHARED_LIBRARY在config.mk裏有定義,指向相應的.mk文件,根據要生成的模塊的類型,包含相應的文件。
BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk
BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk
BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
BUILD_KEY_CHAR_MAP := $(BUILD_SYSTEM)/key_char_map.mk
主要分爲兩種類型:prebuilt和bin/lib文件。這些.mk文件都包含build/core/base_rule.mk。這個文件的做用以下:
2014年11月15日,引述的網站丟了:
main.mk----config.mk----pathmap.mk | |---buildspec.mk(no used) | |---envsetup.mk | |---BoardConfig.mk(vendor\company\plat_name) | |---dumpvar.mk | |---select.mk----TARGET_linux-arm.mk | |---select.mk----HOST_linux-arm.mk | |---javac.mk |---cleanbuild.mk |---definitions.mk |---Android.mk----./build/target/board/Android.mk----include $(TARGET_DEVICE_DIR)/AndroidBoard.mk
\vendor\intel\mfld_cdk\AndroidKernel.mk mfld_cdk----boottarball------bootimage----build_kernel----get_kernel_from_source----(hardware\intel\linux-2.6)AndroidKernel.mk |---systemtarball----|---droid |---ota_iso_image