Adding prebuilt set of files structured in folders to android out folder

Rookie picture Rookie · Feb 6, 2013 · Viewed 9.5k times · Source

I have glibc compiled for arm which is different from Android glibc or the bionic C as the glibc environment I have complied will help in providing more api's. Now I can copy the glibc environment on /system/ folder while Android is running, and on doing chroot I can run my programs on glibc environment.

Currently I am compiling glibc and Android separately and then tarring the glibc and copying it on Android emulator sdcard and then untarring it on /system folder and then doing chroot on /system/glibc

I compile glibc separately and then place it somewhere in Android source code. Now while compiling Android source, what should I do so that the entire prebuilt folder structure of glibc gets copied to /system folder and become part of part of system.img.

With this when I copy the system.img to Android emulator and launch it, glibc is already present in /system folder and just need to run the apps in glibc environment.

UPDATE

after I did as per Yuri mentioned in his answer (I created glibc folder and copied everything into it), when I compile the code I get below output.

build/core/main.mk:490: * Some files have been added to ALL_PREBUILT.
build/core/main.mk:491: *
build/core/main.mk:492: * ALL_PREBUILT is a deprecated mechanism that
build/core/main.mk:493: * should not be used for new files.
build/core/main.mk:494: * As an alternative, use PRODUCT_COPY_FILES in
build/core/main.mk:495: * the appropriate product definition.
build/core/main.mk:496: * build/target/product/core.mk is the product
build/core/main.mk:497: * definition used in all products.
build/core/main.mk:498: *
build/core/main.mk:499: * unexpected glibc in ALL_PREBUILT
build/core/main.mk:500: *
build/core/main.mk:501: * ALL_PREBUILT contains unexpected files. Stop.

So I added glibc in build/core/legacy_prebuilts.mk

But then I get

make: * No rule to make target mkdir', needed byout/target/product/generic/root/glibc'. Stop.

Answer

Rookie picture Rookie · Feb 12, 2013

Finally I did it in a very unusual way.

I had 3 options:

  1. Use BUILD_PREBUILT variable, but drawback it you can do it for a single file, but I had multiple files and in a particular forlder structure
  2. Use PRODUCT_COPY_FILES. But somehow it was not working for me PRODUCT_COPY_FILES is for a device, and it was not a new device for me. I was working on emulator.
  3. Using the solution given by Yuri, using ALL_PREBUILT +=, but as Yuri mentioned it was for GB and I am using JB and ICS and hence was not working for me.

The approach i took is to use shell script within the Android.mk file. I used some like this: Assume you have a folder named my_folder containing entire prebuilt folder structure which needs to be copied to anddroid out folder as is, inside my_folder, I created Android.mk and entered below text:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

$(shell mkdir -p $(TARGET_OUT)/my_folder/)
$(shell cp -rf $(LOCAL_PATH)/* `pwd`/$(TARGET_OUT)/my_folder/)

This way all my prebuilt set of files and folders in my_folder directory were copied as is to system folder in android out.

I hope this helps someone.