編輯:Android資訊
本文比較詳細地介紹了Android Make系統,通過手動Makefile編譯Android來提高對Android系統的了解,以下是原文:
它對應的是在./build/core/config.mk中的CLEAR_VARS:=$(BUILD_SYSTEM)/clear_vars.mk
它對應的是在./build/core/config.mk中的BUILD_PACKAGE:=$(BUILD_SYSTEM)/package.mk
.PHONY:checkbuilt .PHONY:prebuilt .PHONY: files .PHONY: ramdisk .PHONY: systemimage .PHONY: userdataimage .PHONY: bootimage .PHONY: recoveryimage .PHONY: droidcore .PHONY: apps_only .PHONY: sdk .PHONY: clean .PHONY: clobber .PHONY: modules .PHONY: showcommands
LOCAL_PATH:=$(call my-dir) //獲取當前目錄 #include $(CLEAR_VARS) //make系統為子模塊定義了很多的私有變量,這個調用是為了初始化所有的私有變量 ... //裡面的內容根據不同的需要會出現不同的LOCAL變量 ... #include $(BUILD_XXX) //執行編譯任務
LOCAL_SRC_FILES:=$(call all-subdir-java-files) LOCAL_PACKAGE_NAME:=packageName include $(BUILD_PACKAGE)
LOCAL_STATIC_JAVA_LIBRARIES:=static-library LOCAL_SRC_FILES:=$(call all-subdir-java-files) LOCAL_PACKAGE_NAME:=packageName include $(BUILD_PACKAGE)
LOCAL_SRC_FILES:=$(call all-subdir-java-files) LOCAL_PACKAGE_NAME:=packageName LOCAL_CERTIFICATE:=platform include $(BUILD_PACKAGE)
LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_PACKAGE_NAME := LocalPackage LOCAL_CERTIFICATE := vendor/example/certs/app include $(BUILD_PACKAGE)
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk LOCAL_MODULE := LocalModuleName LOCAL_MODULE_CLASS := APPS LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) include $(BUILD_PREBUILT) LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_MODULE := sample include $(BUILD_STATIC_JAVA_LIBRARY)
通過CREATE_MODULE_INFO_FILE,build system會將所有的模塊信息列在$(PRODUCT_OUT)/module-info.txt中
HOST_BUILD_TYPE 和 TARGET_BUILD_TYPE 用來設置是debug還是release,debug的帶有調試信息,這兩個參數也可以在 buildspec.mk中進行設置以防止在別處被重復指定
LOCAL_AAPT_FLAGS LOCAL_ACP_UNAVAILABL LOCAL_ADDITIONAL_JAVA_DIR LOCAL_AIDL_INCLUDES LOCAL_ALLOW_UNDEFINED_SYMBOLS LOCAL_ARM_MODE LOCAL_ASFLAGS LOCAL_ASSET_DIR LOCAL_ASSET_FILES 在與BUILD_PACKAGE一起時有效,表示資源文件 LOCAL_BUILT_MODULE_STEM LOCAL_C_INCLUDES 用來指定外面的頭文件路徑 LOCAL_CC 可以指定C編譯器 LOCAL_JAR_MANIFEST LOCAL_JARJAR_RULES LOCAL_JAR_PATH LOCAL_SHARED_LIBRARIES 可鏈接動態庫 LOCAL_SRC_FILES 編譯源文件 LOCAL_STATIC_JAVA_LIBRARIES LOCAL_STATIC_LIBRARIES 可鏈接靜態庫 LOCAL_UNINSTALLABLE_MODULE LOCAL_WHOLE_STATIC_LIBRARIES 禁止在連接時刪除庫中的無用代碼 LOCAL_FORCE_STATIC_EXECUTABLE 如果編譯的可執行程序要進行靜態鏈接(執行時不依賴於任何動態庫) LOCAL_JAVA_LIBRARIES 編譯java應用程序和庫的時候指定包含的java類庫,目前有core和framework兩種 多數情況下定義成:LOCAL_JAVA_LIBRARIES := core framework 注意LOCAL_JAVA_LIBRARIES不是必須的,而且編譯APK時不允許定義(系統會自動添加)
CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.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 以上的*.mk中都包含了base_rules.mk
./build/target/product/AndroidProducts.mk
native code和java的一些通用方法都在./build/core/definitions.mk中
BUILD_SHARE_xxx等變量在./build/core/config.mk中
./build/target/board/$(TARGET_DEVICE)/BoardConfig.mk ./vendor/*/$(TARGET_DEVICE)/BoardConfig.mk
與 LOCAL_MODULE_TAGS相關的定義
include $(BUILD_STATIC_LIBRARY) 編譯成靜態庫 include $(BUILD_SHARED_LIBRARY) 編譯成動態庫。 include $(BUILD_EXECUTABLE) 編譯成可執行程序
call my-dir call all-subdir-java-files call all-java-files-under call all-makefiles-under,$(LOCAL_PATH) call all-clean-step call import-module,android/native_app_glue call inherit-product,xxx.mk call inherit-product-if-exists call device-test call include-path-for,libpagemap call dist-for-goals,dist_files,$(LOCAL_BUILT_MODULE) call _add-charger-image,$(_img) call libfilterfw-all-java-files-under,$(1) call libfilterfw_to_document,$(LOCAL_PATH) call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE,true) call all-named-subdir-makefiles,$(legacy_modules) call RM;call MKDIR call emugl-begin-host-shared-library,libEGL_translator call emugl-import,libOpenglOsUtils call emugl-end-module call emugl-export,LDLIBS,-lGL cal emugl-export,LDFLAGS,$(GL_COMMON_LINKER_FLAGS) call emugl-set-shared-library-subpath,hw call emugl-export,C_INCLUDES,$(intermediates) call all-makefiles-under,$(LOCAL_PATH) 這個和下面的區別還不清楚 call all-subdis-makefiles 這個是通常出現在整個makefile的尾部,以實現遞歸調用子目錄中的makefile,使整個make系統成為一個樹狀結構
本文由碼農網 – 小峰原創,轉載請看清文末的轉載要求,歡迎參與我們的付費投稿計劃! android-media-picker是一個基於Android的圖片
在Google的廣大支持下,便捷開發Android程序的Native工具層出不窮。其實Android開發涉及到的范圍也不小,一些Web工具有時候也會帶來事半功倍的
從 Android 5.0 Lollipop 開始提供一套 API 來支持嵌入的滑動效果。同樣在最新的 Support V4 包中也提供了前向的兼容。有了嵌入滑動
如果Android機頂盒能夠支持IOS設備的Airplay協議,實現為Airplay服務器,能夠接收和處理來自IOS設備的多媒體數據(視頻、照片和音樂),將能提高