首页 > 其他分享 >TARGET_DEVICE_DIR取值过程分析

TARGET_DEVICE_DIR取值过程分析

时间:2023-09-06 13:06:28浏览次数:40  
标签:product TARGET mk board DEVICE config DIR


xxx(机型名)为例

在build/core/main.mk中, 会包含build/core/config.mk,在config.mk中,会包含build/core/envsetup.mk,在envsetup.mk中有:


# Read the product specs so we can get TARGET_DEVICE and other          


           # variables that we need in order to locate the output files.          


           include $(BUILD_SYSTEM)           /product_config           .mk          


           .......          


           # Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)          


           # or under vendor/*/$(TARGET_DEVICE).  Search in both places, but          


           # make sure only one exists.          


           # Real boards should always be associated with an OEM vendor.          


           board_config_mk := \          


                      $(strip $(wildcard \          


                      $(SRC_TARGET_DIR)           /board/           $(TARGET_DEVICE)           /BoardConfig           .mk \          


                      $(shell            test            -d device &&            find            device -maxdepth 4 -path            '*/$(TARGET_DEVICE)/BoardConfig.mk'           ) \          


                      $(shell            test            -d vendor &&            find            vendor -maxdepth 4 -path            '*/$(TARGET_DEVICE)/BoardConfig.mk'           ) \          


                      ))          


           ifeq ($(board_config_mk),)          


                      $(error No config            file            found            for            TARGET_DEVICE $(TARGET_DEVICE))          


           endif          


           ifneq ($(words $(board_config_mk)),1)          


                      $(error Multiple board config files            for            TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))          


           endif          


           include $(board_config_mk)          


           ifeq ($(TARGET_ARCH),)          


                      $(error TARGET_ARCH not defined by board config: $(board_config_mk))          


           endif          


           TARGET_DEVICE_DIR := $(patsubst %/,%,$(           dir            $(board_config_mk)))          


           board_config_mk :=


这里首先在main.mk最前面有:

TOPDIR :=

BUILD_SYSTEM := $(TOPDIR)build/core

因此在envsetup.mk中会include build/core/product_config.mk

在product_config.mk中有:


# ---------------------------------------------------------------          


           # Include the product definitions.          


           # We need to do this to translate TARGET_PRODUCT into its          


           # underlying TARGET_DEVICE before we start defining any rules.          


           #          


           include $(BUILD_SYSTEM)           /node_fns           .mk          


           include $(BUILD_SYSTEM)           /product           .mk          


           include $(BUILD_SYSTEM)           /device           .mk          


           ifneq ($(strip $(TARGET_BUILD_APPS)),)          


           # An unbundled app build needs only the core product makefiles.          


           all_product_configs := $(call get-product-makefiles,\          


                      $(SRC_TARGET_DIR)           /product/AndroidProducts           .mk)          


           else          


           # Read in all of the product definitions specified by the AndroidProducts.mk          


           # files in the tree.          


           all_product_configs := $(get-all-product-makefiles)          


           endif


先调用 build/core/product.mk中定义的函数get-all-product-makefiles ,get-all-product-makefiles函数会返回所有的.mk文件中的宏PRODUCT_MAKEFILES ,

在product.mk开始有:


#          


           # Returns the list of all AndroidProducts.mk files.          


           # $(call ) isn't necessary.          


           #          


           define _find-android-products-files          


           $(shell            test            -d device &&            find            device -maxdepth 6 -name AndroidProducts.mk) \          


                      $(shell            test            -d vendor &&            find            vendor -maxdepth 6 -name AndroidProducts.mk) \          


                      $(SRC_TARGET_DIR)           /product/AndroidProducts           .mk          


           endef          


           #          


           # Returns the sorted concatenation of PRODUCT_MAKEFILES          


           # variables set in the given AndroidProducts.mk files.          


           # $(1): the list of AndroidProducts.mk files.          


           #          


           define get-product-makefiles          


           $(           sort            \          


                      $(foreach f,$(1), \          


                      $(           eval            PRODUCT_MAKEFILES :=) \          


                      $(           eval            LOCAL_DIR := $(patsubst %/,%,$(           dir            $(f)))) \          


                      $(           eval            include $(f)) \          


                      $(PRODUCT_MAKEFILES) \          


                      ) \          


                      $(           eval            PRODUCT_MAKEFILES :=) \          


                      $(           eval            LOCAL_DIR :=) \          


                      )          


           endef          


           #          


           # Returns the sorted concatenation of all PRODUCT_MAKEFILES          


           # variables set in all AndroidProducts.mk files.          


           # $(call ) isn't necessary.          


           #          


           define get-all-product-makefiles          


           $(call get-product-makefiles,$(_find-android-products-files))          


           endef


因此这里会找到device下的所有AndroidProducts.mk,不同子目录下的AndroidProducts.mk 中定义了不同的 PRODUCT_NAME, PRODUCT_DEVICE 等信息

# Import all product makefiles.

$(call import-products, $(all_product_makefiles))

调用import-products,读取找到的所有的AndrodProducts.mk文件中定义的产品信息,import-products函数去验证这些产品配置文件是否都包含有必须的配置信息

然后有:


# Convert a short name like "sooner" into the path to the product          


           # file defining that product.          


           #          


           INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT))          


           ifneq ($(current_product_makefile),$(INTERNAL_PRODUCT))          


           $(error PRODUCT_NAME inconsistent            in            $(current_product_makefile) and $(INTERNAL_PRODUCT))          


           endif          


           current_product_makefile :=          


           all_product_makefiles :=          


           all_product_configs :=


xxx(机型名)

调用函数resolve-short-product-name,它将返回TARGET_PRODUCT代表的配置文件路径,并赋给INTERNAL_PRODUCT,因此这里就是device/***/xxx/xxx.mk

# Find the device that this product maps to.

TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)

之后TARGET_DEVICE取值xxx

回到envsetup.mk中,


board_config_mk := \          


                      $(strip $(wildcard \          


                      $(SRC_TARGET_DIR)           /board/           $(TARGET_DEVICE)           /BoardConfig           .mk \          


                      $(shell            test            -d device &&            find            device -maxdepth 4 -path            '*/$(TARGET_DEVICE)/BoardConfig.mk'           ) \          


                      $(shell            test            -d vendor &&            find            vendor -maxdepth 4 -path            '*/$(TARGET_DEVICE)/BoardConfig.mk'           ) \          


                      ))          


           ifeq ($(board_config_mk),)          


                      $(error No config            file            found            for            TARGET_DEVICE $(TARGET_DEVICE))          


           endif          


           ifneq ($(words $(board_config_mk)),1)          


                      $(error Multiple board config files            for            TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))          


           endif          


           include $(board_config_mk)          


           ifeq ($(TARGET_ARCH),)          


                      $(error TARGET_ARCH not defined by board config: $(board_config_mk))          


           endif          


           TARGET_DEVICE_DIR := $(patsubst %/,%,$(           dir            $(board_config_mk)))          


           board_config_mk :=


这里先在device下按照xxx/BoardConfig.mk这个规则搜索,会找到device/***/xxx/下的BoardConfig.mk文件,将路径赋值给TARGET_DEVICE_DIR

***/xxx

 

标签:product,TARGET,mk,board,DEVICE,config,DIR
From: https://blog.51cto.com/u_16248677/7385153

相关文章

  • Android官方资料--Device-Specific Code
    Device-SpecificCodeINTHISDOCUMENTPartitionmapRecoveryUIHeaderanditemfunctionsCustomizingCheckKeyScreenRecoveryUIDeviceClassStartRecoverySupplyingandmanagingrecoverymenuBuildandlinktodevicerecoveryRecoveryUIimagesAndroid5.xAndroid......
  • <br /> <font size= 1 ><table class= xdebug-error xe-notice dir= ltr border= 1
    PHP传给前端的值有大量html代码错误1:html代码中,发送请求,多加了引号 ......
  • Android - Get Bluetooth UUID for this device
    StackOverflowisacommunityof4.7millionprogrammers,justlikeyou,helpingeachother.Jointhem,itonlytakesaminute:Android-GetBluetoothUUIDforthisdeviceupvote9downvotefavorite7IwasbrowingStackandtheinternetforasimplesolut......
  • dotnet 已知问题 使用 Directory
    在dotnet里面,可以使用Directory.EnumerateXXX系列方法进行枚举文件或文件夹。在准备枚举驱动器根路径的文件或文件夹时,可能获取到错误的路径。错误的步骤在于传入的是如C:不带斜杠的路径,且存在同驱动器磁盘下的非根路径工作路径特别感谢神樹桜乃和若凡两位大佬,让我明白......
  • dotnet 读 WPF 源代码笔记 GlyphRun 的 DeviceFontName 的功能是什么
    在WPF里面的GlyphRun里,有一个令人迷惑的DeviceFontName属性,似乎给这个属性传入什么值,结果都不会有变更。通过阅读源代码,可以了解到,这是一个没什么用途的属性。本文将告诉大家这个属性的细节逻辑在上一篇博客WPF简单聊聊如何使用DrawGlyphRun绘制文本里面就提到如何创......
  • 解决命令行提示“cannot create temp file for here-document: No space left on devi
    问题如题,出现“cannotcreatetempfileforhere-document:Nospaceleftondevice”,且部分应用出现故障,比如重启后Docker容器无法启动先使用df-h检查磁盘使用率,显示使用率50%还不到继续排查,使用lsof|grepdeleted 或lsof-w|grepdeleted检查是否存在未释放的已......
  • homebrew安装软件出现git问题fatal: not in a git directory,Error: Command failed w
    homebrew安装软件出现git问题问题fatal:notinagitdirectoryError:Commandfailedwithexit128:git问题查找1.brew-v查看问题logsuyf@suyfdeMac-mini~%brew-vHomebrew4.0.18-18-g64259a4fatal:detecteddubiousownershipinrepositoryat'/op......
  • virsh启动kvm时提示No such device
    几年前的一个openstack环境,虚机状态异常,手工登陆计算节点启动kvm时报Nosuchdevice[root@server-02~]#virshstartinstance-e346589e-baca-4ae9-8d71-273f23809d98error:Failedtostartdomaininstance-e346589e-baca-4ae9-8d71-273f23809d98error:Cannotgetinterface......
  • oracle 创建、查看、修改、删除、赋权directory目录
    如下:directory用于数据泵导入、导出创建的目录。1、查询directory目录select*fromdba_directories;2、创建或者修改directory目录createorreplacedirectory目录名称as'/存放目录路径'3、赋权directory目录grantread,writeondirectory目录名称t......
  • OGG-01496 Failed to open target trail file ./dirdat/ra000002, at RBA 2179
    1.问题描述在启动OGG源端的投递进程时,报错:OGG-01496OGG-01496Failedtoopentargettrailfile./dirdat/ra000002,atRBA2179 2.原因分析目标端trail文件丢失,查看目标端的${OGG_HOME}/dirdat下确实没有文件存在。3.解决办法源端OGG:alter extract pump1 etrollover......