2014年6月5日 星期四

How to add a new program to the external folder of Android

1. Create a folder named "myprog" in external folder.
2. Create two files,Android.mk and main.c.
     Example:
     Android.mk
    ===============================
    LOCAL_PATH:=$(call my-dir)

   include $(CLEAR_VARS)

   LOCAL_SRC_FILES:= /
                                            main.c

   LOCAL_MODULE:= myprog

   LOCAL_MODULE_TAGS:=optional

   include $(BUILD_EXECUTABLE)
   ================================
   main.c
   ================================
   #include <stdio.h>
   void main(void)
  {
       printf("Hello World!!");
  }

3. The all Android.mk will be all scanned before source compilation so that the LOCAL_MODULE_TAGS is important.

4. LOCAL_MODULE_TAGS is related with TARGET_BUILD_VARIANT.

    The new program is definitely built up when TARGET_BUILD_VARIANT is equal to LOCAL_MODULE_TAGS.
     For example, presume the several lunch methods.
     -- lunch testplatform-userdebug
     -- lunch testplatform-user
     -- lunch testplatform-eng
  After lunch-ing them,TARGET_BUILD_VARIANT can be set to "userdebug","user" and "eng".The program will be definitely built with
    -- LOCAL_MODULE_TAGS := debug
    --LOCAL_MODULE_TAGS :=user
    --LOCAL_MODULE_TAGS:=eng

5.why needs LOCAL_MODULE_TAGS := optional

   LOCAL_MODULE_TAGS is set to optional can indicate system compilier to check make file for the build. The new program can be add to package build at the Android source/device/testplatform/xxx.mk. The "curl" can be used for the example of package add in xxx.mk. If the new program is not added in package build of makefile,system won't compiler the new program. 

沒有留言:

張貼留言