2016-01-20 12 views
0

我的構建系統是Android 6.0。我正在從源代碼構建AOSP。我想在生成的system.img中包含多個預構建文件。 我知道我可以使用device.mk中的PRODUCT_COPY_FILES來複制預建文件。但是,由於某些原因,我無法修改系統文件。 如何在Android.mk中執行此操作?如何在Android中將多個預建文件添加到system.img中?

例如,我想將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) 

然後我跑「製作」建立整個源代碼,但它顯示

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。 我該如何解決這個問題?謝謝。

回答

0

由於錯誤消息的詳細信息,請在build/target/product/core.mk中添加PRODUCT_COPY_FILES。

以下行添加到編譯/目標/產品/ core.mk文件,並從$ANDROID_BUILD_TOP相對目錄,你的AOSP目錄的根目錄下更換<dir>,到test1.txt的和的test2.txt文件:

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

感謝您的回覆。正如我在我的問題中所描述的,我知道我可以通過使用在目標產品的device.mk中添加的PRODUCT_COPY_FILE來複制文件。但是,由於某些權限原因,我無法更改文件。 –

0

您可以在設備配置(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循環中的多個prebuilts。例如。將上面的代碼放在一個單獨的生成文件中,將platform.xml替換爲$(MY_MODULE),併爲您的Android.mk添加一個for循環,其中您設置了MY_MODULE := <my_module>include <my_separate_makefile>

但是,這看起來像一個解決方法。我會建議在您的產品配置中使用PRODUCT_COPY_FILES += <my_files>

相關問題