如何在Android中向system.img添加多个预构建文件?
我的构建系统是安卓6.0。我正在从源代码构建AOSP。我想在生成的system.img中包含多个预构建文件。 我知道我可以使用device.mk中的PRODUCT_copy_文件复制预构建的文件。但是,由于某些原因,我无法修改系统文件。 我如何在Android.mk中实现它 例如,我想将test1.txt和test2.txt复制到/system/etc如何在Android中向system.img添加多个预构建文件?,android,Android,我的构建系统是安卓6.0。我正在从源代码构建AOSP。我想在生成的system.img中包含多个预构建文件。 我知道我可以使用device.mk中的PRODUCT_copy_文件复制预构建的文件。但是,由于某些原因,我无法修改系统文件。 我如何在Android.mk中实现它 例如,我想将test1.txt和test2.txt复制到/system/etc SMB_CONFIG_FILES := test1.txt test2.txt SMB_CONFIG_TARGET := $(addprefix
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中的预建功能。
我怎样才能解决这个问题?谢谢。作为错误消息的详细信息,请在build/target/PRODUCT/core.mk中添加PRODUCT\u COPY\u文件 将以下行添加到build/target/product/core.mk文件中,并将下面的
替换为从AOSP目录的根目录$ANDROID\u build\u TOP
到test1.txt和test2.txt文件的相对目录:
PRODUCT_COPY_FILE += \
<dir>/test1.txt:system/etc/test1.txt \
<dir>/test2.txt:system/etc/test2.txt
产品拷贝文件+=\
/txt:system/etc/test1.txt\
/test2.txt:system/etc/test2.txt
您可以在设备配置中使用产品拷贝文件+=
(设备//
)。您可以在其中添加这些文件的相关文件有device.mk
、device common.mk
或.mk
另一种方法是在Android.mk
中使用BUILD\u prebuild
规则。下面是这样一个文件的外观示例:
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中,将platform.xml
替换为$(MY_模块)
,并在Android.mk
中添加一个for循环,您可以在其中设置MY_模块:=
和include
但这对我来说就像一个解决办法。我建议您在产品配置中使用
PRODUCT\u COPY\u FILES+=
。谢谢您的回复。正如我在问题中所描述的,我知道我可以使用目标产品的device.mk中添加的PRODUCT_copy_文件来复制文件。但是,由于某些权限原因,我无法更改该文件。您能否详细说明多个模块的循环?