android system.img文件生成过程分析

本文深入剖析了Android系统中system.img文件的生成过程,从build_systemimage_target定义出发,详细解析了build_image.py脚本的功能,接着探讨了mkuserimg.sh在生成过程中所起的作用,从而完整展示了system.img构建的流程。
摘要由CSDN通过智能技术生成

当前目录build

./core/Makefile:802:INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
生成文件位置


./core/Makefile:828:systemimage: $(INSTALLED_SYSTEMIMAGE)

systemimage就是该镜像文件生成的目标项。使用make systemimage可以显式直接生成system.img


 823 $(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)      | $(ACP)
 824     @echo "Install system fs image: $@"
 825     $(copy-file-to-target)
 826     $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(B     OARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
 799 $(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
 800     $(call build-systemimage-target,$@)
最终system.img依赖BUILT_SYSTEMIMAGE,BUILT_SYSTEMIMAGE会调用build-systemimage-target生成。


build-systemimage-target定义:

 790 define build-systemimage-target
 791   @echo "Target system fs image: $(1)"
 792   @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimag     e_intermediates)/system_image_info.txt
 793   $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/s     ystem_image_info.txt, skip_fsck=true)
 794   $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH      \
 795       ./build/tools/releasetools/build_image.py \
 796       $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1)
 797 endef
首先生成镜像文件参数文件,然后根据参数文件和相应目录生成system.img文件。主要会用到build_image.py脚本。


build/tools/releasetools/build_image.py:

#!/usr/bin/env python
#
# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR COND
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值