簡體   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