Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android.mk file - including all source files in different folders and subfolders

In writing an android .mk file, is there a short way to include many source files which are in different folders and subfolders? Like a loop or a code for iterating the folders? For example:

folder1

|---subfolder1.1

      |---subfolder1.1.1

               |---some cpp files

      |--subfolder1.1.2

           |--some cpp files

folder2

|---subfolder2.1

      |--subfolder2.1.1

           |--some cpp files

|--(so on and so forth, another folders and subfolders and cpp files)

I know I can use include $(call all-subdir-makefiles) for folders and subfolders but it will take too much time if I have so many folders, is there a better way? Like a loop for iterating through the folders? So I will have just one library for folder1 and another for folder2 and so on...

like image 718
Coola Avatar asked Apr 02 '12 01:04

Coola


2 Answers

FILE_LIST := $(wildcard $(LOCAL_PATH)/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/**/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/**/**/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
like image 157
Morozov Grizzly Jr Avatar answered Oct 13 '22 12:10

Morozov Grizzly Jr


You can use ** wildcard to include files from all subdirectories:

LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard folder/**/*.cpp))
like image 25
Mārtiņš Možeiko Avatar answered Oct 13 '22 12:10

Mārtiņš Možeiko