繁体   English   中英

如何在Android中将多个预建文件添加到system.img?

[英]How can I add multiple prebuilt files to system.img in Android?

我的构建系统是Android 6.0。 我正在从源代码构建AOSP。 我想在生成的system.img中包含多个预建文件。 我知道我可以使用device.mk中的PRODUCT_COPY_FILES复制预构建的文件。 但是,由于某些原因,我无法修改系统文件。 如何在Android.mk中执行此操作?

例如,我想将test1.txt和test2.txt复制到/ system / etc。 我写一个如下的Android.mk。

SMB_CONFIG_FILES := test1.txt test2.txt
SMB_CONFIG_TARGET := $(addprefix $(TARGET_OUT)/etc/, $(SMB_CONFIG_FILES))

ALL_PREBUILT += $(SMB_CONFIG_TARGET)                    
$(SMB_CONFIG_TARGET) : $(TARGET_OUT)/etc/% : $(LOCAL_PATH)/% | $(ACP)
    $(transform-prebuilt-to-target)

然后我运行“ make”以构建整个源,但它显示

build/core/main.mk:517: *** Some files have been added to ALL_PREBUILT.
build/core/main.mk:518: *
build/core/main.mk:519: * ALL_PREBUILT is a deprecated mechanism that
build/core/main.mk:520: * should not be used for new files.
build/core/main.mk:521: * As an alternative, use PRODUCT_COPY_FILES in
build/core/main.mk:522: * the appropriate product definition.
build/core/main.mk:523: * build/target/product/core.mk is the product
build/core/main.mk:524: * definition used in all products.
build/core/main.mk:525: *
build/core/main.mk:526: * unexpected test1.txt in ALL_PREBUILT
build/core/main.mk:526: * unexpected test2.txt in ALL_PREBUILT
build/core/main.mk:527: *
build/core/main.mk:528: *** ALL_PREBUILT contains unexpected files.  Stop.

看来我无法在Android 6.0中使用ALL_PREBUILT。 我该如何解决这个问题? 谢谢。

作为错误消息的详细信息,请在build / target / product / core.mk中添加PRODUCT_COPY_FILES。

将以下行添加到build / target / product / core.mk文件中,并将下面的<dir>替换为$ANDROID_BUILD_TOP的相对目录(即AOSP目录的根目录),分别位于test1.txt和test2.txt文件中:

PRODUCT_COPY_FILE += \
    <dir>/test1.txt:system/etc/test1.txt \
    <dir>/test2.txt:system/etc/test2.txt

您可以在设备配置( device/<vendor>/<device_name> )中使用PRODUCT_COPY_FILES += <my_files> 您可以在其中添加这些文件的相关文件为device.mkdevice-common.mk<device_name>.mk

另一种方法是在Android.mk使用BUILD_PREBUILT规则。 这是一个这样的文件的示例:

LOCAL_PATH := $(my-dir)

########################
include $(CLEAR_VARS)

LOCAL_MODULE := platform.xml

LOCAL_MODULE_CLASS := ETC

# This will install the file in /system/etc/permissions
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions

LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)

当然,如果要复制多个文件,则可以在for循环中生成多个预构建的对象。 例如,将上面的代码放在一个单独的makefile中,用$(MY_MODULE)替换platform.xml ,并在Android.mk中添加一个for循环,在其中设置MY_MODULE := <my_module>include <my_separate_makefile>

但这对我来说似乎是一种解决方法。 我建议您在产品配置中使用PRODUCT_COPY_FILES += <my_files>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM