Android.mk文件 - 包括在不同的文件夹和子文件夹中的所有源文件文件、源文件、文件夹、不同

2023-09-05 03:43:33 作者:訫殇

在写一个Android的.mk文件,有一小段路,包括了许多的源文件在不同的文件夹和子文件夹?就像一个循环或$ C $下遍历文件夹?例如:

  

文件夹1

     

| --- subfolder1.1

  | --- subfolder1.1.1

               | ---有些CPP文件

      | --subfolder1.1.2

           |  - 有些CPP文件
 

     

FOLDER2

     

| --- subfolder2.1

  | --subfolder2.1.1

           |  - 有些CPP文件
 
代码比较工具多,谁更出色

     

| - (等等等等,另外一个文件夹和子文件夹和CPP   文件)

我知道我可以使用包括 $(呼叫全子目录,生成文件)文件夹和子文件夹,但它会花费太多时间,如果我有这么多的文件夹,是有没有更好的办法?像在文件夹迭代循环?因此,我将只有一个库中的文件夹1 的,另一个的 FOLDER2 的等等...

解决方案

  file_list中:= $(通配符$(LOCAL_PATH)/ * CPP)
file_list中+ = $(通配符$(LOCAL_PATH)/ ** / *。CPP)
file_list中+ = $(通配符$(LOCAL_PATH)/ ** / ** / *。CPP)
LOCAL_SRC_FILES:= $(file_list中:$(LOCAL_PATH)/%=%)
 

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...

解决方案

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)/%=%)