androidlinuxmakefileandroid-sourceprebuild

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


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.

Solution

  • Here is an example from the book "Embedded Android" that will help you. Create a folder in the root of your aosp project called rootfs-glibc, put there the code that you want to copy, and create there Android.mk file with the following content:

    LOCAL_PATH:= $(call my-dir)
    include $(CLEAR_VARS)
    # This part is a hack, we're doing "addprefix" because if we don't,
    # this dependency will be stripped out by the build system
    GLIBC_ROOTFS := $(addprefix $(TARGET_ROOT_OUT)/, rootfs-glibc)
    $(GLIBC_ROOTFS): mkdir -p $(TARGET_ROOT_OUT) cp -af $(TOPDIR)rootfs-glibc/* $(TARGET_ROOT_OUT) rm
    # The last command just gets rid of this very .mk since it's copied as-is
    ALL_PREBUILT += $(GLIBC_ROOTFS)
    

    There is a note that this is true for Gingerbread. Maybe in newer versions of Android the make system has been changed.