1 首先在build/core/envsetup.mk中有:
|
SRC_TARGET_DIR值为$(TOPDIR)build/target,TARGET_DEVICE取值xxx(机型名),
在build/target/xxx 和device、vendor等目录的xxx子目录下查找所有的BoardConfig.mk文件,而且device和vendor下必须符合xxx/BoardConfig.mk的形式,
xxx,只在****/xxx/下存在名为xxx的子目录,因此最终board_config_mk就代表这个文件
对board_config_mk取值的错误情况做出判断后,然后直接通过 include $(board_config_mk)将这个BoardConfig.mk文件include进来,假设这个文件中定义了xxx
2 根据在 ota升级包编译过程中firmware如何添加进来 中的分析可知,BUILT_TARGET_FILES_PACKAGE是编译target-file.zip的目标
在build/core/Makefile中有
|
因此编译target-file.zip的过程中,如果之前在BoardConfig.mk中定义了TARGET_RELEASETOOLS_EXTENSIONS为device/****/xxx,那么tool_extensions就取值device/****/xxx,如果之前没有定义TARGET_RELEASETOOLS_EXTENSIONS,那么这个值就是device/****/xxx/../common
3 在build/core/Makefile接下来,在构建target BUILT_TARGET_FILES_PACKAGE下面要执行的命令行中,还有:
build/core/Makefile
$(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root) /META/misc_info .txt
根据在 ota升级包编译过程中firmware如何添加进来 中的分析,zip_root就是用来产生target-files.zip的中间文件夹,在这里取值就是out/target/product/xxx/obj/PACKAGING/target_files_intermediates/xxx-target_files-eng.username
username/META/misc_info.txt中输入了 tool_extensions=$(tool_extensions)这一行,$(tool_extensions)代表tool_extensions的值
4 在之后执行build/tools/releasetools/ota_from_target_files.py时,在main中有:
build/tools/releasetools/ota_from_target_files.py
OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[ 0 ])
OPTIONS.target_tmp = OPTIONS.input_tmp
OPTIONS.info_dict = common.LoadInfoDict(input_zip)
根据在 ota升级包编译过程中firmware如何添加进来 中的分析,input_zip代表用zipfile.ZipFile打开的target-files.zip文件。
这里调用同目录下common.py中的LoadInfoDict,按行加载misc_info.txt中保存的元数据
build/tools/releasetools/common.py
def LoadInfoDict(input_file):
"""Read and parse the META/misc_info.txt key/value pairs from the
input target files and return a dict."""
def read_helper(fn):
if isinstance (input_file, zipfile.ZipFile):
return input_file.read(fn)
else :
path = os.path.join(input_file, * fn.split( "/" ))
try :
with open (path) as f:
return f.read()
except IOError as e:
if e.errno = = errno.ENOENT:
raise KeyError(fn)
d = {}
try :
d = LoadDictionaryFromLines(read_helper( "META/misc_info.txt" ).split( "\n" ))
except KeyError:
# ok if misc_info.txt doesn't exist
pass
# backwards compatibility: These values used to be in their own
# files. Look for them, in case we're processing an old
# target_files zip.
if "mkyaffs2_extra_flags" not in d:
try :
d[ "mkyaffs2_extra_flags" ] = read_helper(
"META/mkyaffs2-extra-flags.txt" ).strip()
except KeyError:
# ok if flags don't exist
pass
if "recovery_api_version" not in d:
try :
d[ "recovery_api_version" ] = read_helper(
"META/recovery-api-version.txt" ).strip()
except KeyError:
raise ValueError( "can't find recovery API version in input target-files" )
if "tool_extensions" not in d:
try :
d[ "tool_extensions" ] = read_helper( "META/tool-extensions.txt" ).strip()
except KeyError:
# ok if extensions don't exist
pass
if "fstab_version" not in d:
d[ "fstab_version" ] = "1"
try :
data = read_helper( "META/imagesizes.txt" )
for line in data.split( "\n" ):
if not line:
continue
name, value = line.split( " " , 1 )
if not value:
continue
if name = = "blocksize" :
d[name] = value
else :
d[name + "_size" ] = value
except KeyError:
pass
def makeint(key):
if key in d:
d[key] = int (d[key], 0 )
makeint( "recovery_api_version" )
makeint( "blocksize" )
makeint( "system_size" )
makeint( "vendor_size" )
makeint( "userdata_size" )
makeint( "cache_size" )
makeint( "recovery_size" )
makeint( "boot_size" )
makeint( "fstab_version" )
d[ "fstab" ] = LoadRecoveryFSTab(read_helper, d[ "fstab_version" ])
d[ "build.prop" ] = LoadBuildProp(read_helper)
return d
在LoadInfoDict中建立字典d,read_helper("META/misc_info.txt")会读取target-files.zip的META下的misc_info.txt,然后在LoadDictionaryFromLines中按key/value对的形式逐行解析读取到的内容,因此在这里就可以获得d["tool_extensions"] = device/****/xxx 或者 device/****/xxx/../common
如果misc_info.txt中读取tool_extensions失败,接下来还会尝试从META/tool-extensions.txt中读取。最后返回ota_from_target_files.py的main,将字典d传给OPTIONS.info_dict
5 在ota_from_target_files.py的main中,接下来有:
build/tools/releasetools/ota_from_target_files.py
if OPTIONS.device_specific is None :
from_input = os.path.join(OPTIONS.input_tmp, "META" , "releasetools.py" )
if os.path.exists(from_input):
print "(using device-specific extensions from target_files)"
print "releasetools.py exists"
print (from_input)
OPTIONS.device_specific = from_input
else :
print "releasetools.py don't exists"
# device/qcom/common
OPTIONS.device_specific = OPTIONS.info_dict.get( "tool_extensions" , None )
if OPTIONS.device_specific is not None :
OPTIONS.device_specific = os.path.abspath(OPTIONS.device_specific)
这里首先从产生target-files.zip的中间文件夹是out/target/product/xxx/obj/PACKAGING/target_files_intermediates/xxx-target_files-eng.username/META下读取releasetools.py,如果这个文件不存在,就从上一部获得的字典 OPTIONS.info_dict中查找tool_extensions这个键的值,最终赋值给OPTIONS.device_specific。
标签:info,files,target,tool,xxx,extensions,device From: https://blog.51cto.com/u_16248677/7386438