I had trouble with Android.mk in PROJECT_FOLDER directory,
//Android.mk
LOCAL_PATH:= $(call my-dir)
include $(call all-makefiles-under,$(LOCAL_PATH))
and in PROJECT_FOLDER, say there were SUB_DIR1 and SUB_DIR2
in SUB_DIR1, I had Android.mk file, but in SUB_DIR2 I did not.
And I've found out that build system doesn't go through SUB_DIR2 but SUB_DIR1,
but I am not sure why.
My guess is that my Android mk goes through every sub directory under Android.mk, searching for another Android.mk or Android.bp,
and if one directory does not have Android.mk at top, it just assumes that the directory is unrelevant?
could anyone enlighten me?
Related
I need to copy a directory tree with XML files recursively to the out directory using Android.mk file
The directory structure is like this:
parent directory has three sub-directories each with an XML file. The parent directory also includes an Android.mk file.
The Android.mk file in parent has the following rules:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := file.xml
LOCAL_MODULE_TAGS := optional debug
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
LOCAL_SRC_FILES := file.xml
include $(BUILD_PREBUILT)
I need to define LOCAL_SRC_FILES and LOCAL_MODULE_PATH as the source and target directories.
Could someone please let me know how to do it?
Basically the issue here is the "LOCAL_MODULE" needs to be defined for each file in this case. And it needs to be unique. If we try to have the same name for all three subdirectories, make fails with an 'already defined' error.
As a workaround, I defined LOCAL_MODULE for each of the three files with unique filenames. I don't think there is any other option of resolving this.
As an aside, I ought to mention that it is possible to copy files by running cp command directly from make. Please see Copy multiple txt files in /system using Android.mk
However, please note that running shell commands directly from within Android.mk files is deprecated starting from Android N.
I have added ndk plugin in Eclipse.
I have imported a NDK project in Eclipse.
But projects requires external .h file from the system, so I have added that folder where .h files files resides by
right click on project-> c/C++ General->Paths and symbols->then click on
include and then click add and given path of that folder
also checked all configurations and all languages.
still when I build the project from Command prompt by moving to path where my project is , then ndk-build I am getting for .h file no such file or directory error.
How can I resolve this issue??
Please help...
Please refer to documentation of LOCAL_C_INCLUDES variable
what you did to add the reference the external headers was only for eclipse, so it correctly resolves all the symbols and files references.
You also need to properly add a reference to these .h inside your ndk configuration files, ie inside Android.mk.
Use LOCAL_C_INCLUDES := path/to/headers in your module, like in this sample Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := main.c
LOCAL_MODULE := mymodule
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../includes
include $(BUILD_SHARED_LIBRARY)
If your .h files are part of a prebuilt module your own module depends on, use LOCAL_EXPORT_C_INCLUDES inside the prebuilt module instead of LOCAL_C_INCLUDES inside yours.
In my Android NDK project, I have the following structure:
jni/
Android.mk
... (more source files)
new-lib/
Android.mk
... (more source files)
In the top level Android.mk I have include $(call all-subdir-makefiles) as the last line. I suppose now all the native codes including those under new-lib/ should get built when run ndk-build.
But when I run ndk-build command under project root path, only the top level native codes get built, the native code in subdir new-lib/ isn't built at all. Why?
I only work with one Android.mk in which I define all include folders, but I think here you'll find what you need. For what I understand, you need to make sure you are using the LOCAL_PATH in all your Android.mk files like this:
LOCAL_PATH := $(call my-dir)
I am having a trouble with this simple task for last couple of hours.
I have ndk-modules directory in root of my Android project and I have following in my Android.mk of jni folder
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
NDK_MODULE_PATH := $(LOCAL_PATH)/../ndk-modules
...
$(call import-module,mymodule)
When I build the mk file, I got
Android NDK: /MyApp/jni/Android.mk: Cannot find module with tag 'mymodule' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
What am I doing wrong here? How can I specify the path correctly?
UPDATE:
The specification was right. I had a problem in mymodule directory. Sorry for the confusion.
NDK_MODULE_PATH must be in your path. I wanted to specify it in my Android.mk file so I added this line before the import-module line:
$(call import-add-path,my_relative_path)
In my case, I fixed it by realizing NDK searches for:
$NDK_MODULE_PATH/module_name/Android.mk
But my "module_name" is an Eclipse project where Android.mk is under:
$NDK_MODULE_PATH/module_name/jni/Android.mk
So NDK cannot find it. I fixed it by:
Move module_name/jni/* to "somewhere/module_name".
In Android.mk:
$(call import-add-path, /path/to/somewhere)
$(call import-module,module_name)
$(call import-module,mymodule) will search $NDK_MODULE_PATH/mymodule, you may set path to top level of the project or create a folder named mymodule under ndk-modules
I would just like to ask what should be written in the Android.mk file to also call the mk files in the sub-directories of the current directory.
Example:
/packages/Android.mk
/package/groupA/Android.mk
/packages/groupA/AppA/Android.mk
/packages/groupA/AppB/Android.mk
I know that by using include $(call all-subdir-makefiles), the Android.mk file in the immediate sub-directory will be read (example: /package/groupA/Android.mk). However, /packages/groupA/AppA/Android.mk and /packages/groupA/AppB/Android.mk will not be read.
I wonder if there is other macro that do the recursive reading of the Android.mk for all sub-directories.
Thanks,
artsylar
The most convenient solution is putting include $(call all-subdir-makefiles) command also inside /package/groupA/Android.mk file.
However, if you want only third-level mk files then you can use the following command:
include $(wildcard $(call my-dir)/*/*/Android.mk)
And here is a fully recursive solution, but it relies on find command from the shell:
include $(filter-out $(call my-dir)/Android.mk,$(shell find $(call my-dir)/ -type f -name Android.mk))