Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy multiple txt files in /system using Android.mk

Aim : I want to copy multiple txt files in /system ( of Android Device ) using Android.mk

My Findings :

We can copy file using two approach 1) Use PRODUCT_COPY_FILES. This is done from devices/ / makefile.mk

ex:

PRODUCT_COPY_FILES := \
  frameworks/base/data/etc/telephony.gsm.xml:system/etc/permissions/telephony.gsm.xml \
  some/other/sourc/file:some/destination \
  some/other/sourcefile2: some/destination

2) Using BUILD_PREBUILD

ex :

##############copy txt file##################
include $(CLEAR_VARS)
#LOCAL_MODULE := mydata.txt
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/myfolder
LOCAL_SRC_FILES := mydata.txt
include $(BUILD_PREBUILT)

for above to work make entry of mydata.txt in build/target/product/core.mk

My Specific Query is : Now i can copy multiple files using 2nd approach by re-writing the above code one after the other. But i want to use 2nd approach (BUILD_PERBUILD ) to copy multiple txt files without re-writing code for all files.

1) Can i do that with just one include $(BUILD_PREBUILT) call ?

2 )Can BUILD_MULTI_PREBUILD be used to solve the purpose? how ?

like image 600
Akshay Avatar asked Jan 17 '13 13:01

Akshay


1 Answers

Ok, I found one hack ( which i knew exists ) ,which i was not looking for but it worked and solved my problem in a very simple way.

You can run shell commands in mk file.

So if you want to copy multiple files just in a single go use following code and place it in your mk file.

In following scenario the files i need to copy are present in file_folder ( directory ) , which is in same directory where my mk file is. And i wan to copy all the files present in file_folder to system/file_folder.

#create a directory in /system/
    $(shell mkdir -p $(TARGET_OUT)/file_folder/)
#copy stuff
    $(shell cp $(LOCAL_PATH)/file_folder/* `pwd`/$(TARGET_OUT)/file_folder/)

This worked fine. So now in all we have 3 ways to do it. Hope it will help someone like me.

like image 187
Akshay Avatar answered Oct 06 '22 00:10

Akshay