Android.mk traverse all the files subdirectory

Android.mk traverse all the files subdirectory

  1.  
    define all-cpp-files-under
  2.  
    $(patsubst ./%,%, \
  3.  
    $(shell cd $(LOCAL_PATH) ; \
  4.  
    find $( 1) -name "*.cpp" -and -not -name ".*" -and -not -name "CCEditBoxImplWindow.cpp") \
  5.  
    )
  6.  
    endef
  7.  
     
  8.  
    define all-subdir-cpp-files
  9.  
    $(call all-cpp-files-under,.)
  10.  
    endef
  11.  
     
  12.  
    LOCAL_SRC_FILES := $(call all-subdir-cpp-files)

Using this method can traverse all subdirectories .cpp files, replace find the parameters and filters can be achieved traverse arbitrary files.

Android.mk writing has become very simple and convenient, no longer need to maintain a list of files.

Attached a more simple macro can be achieved through all the files in a directory (but not recursive calls)

 

LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/../*.c)

Files can be traversed by a wildcard, if a single directory structure, the same can be achieved by this very simple effect. If c ++ code words (* .cpp file), you need to use the following way, or it may not find the file:

 

 

  1.  
    FILE_LIST := $(wildcard $(LOCAL_PATH)/../*.cpp)
  2.  
    LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)

 

Enhanced version (through all the files, but ignore a directory of files)

 

  1.  
    define all-cpp-files-under
  2.  
    $(patsubst ./%,%, \
  3.  
    $(shell cd $(LOCAL_PATH) ; \
  4.  
    find $( 1) -name LogicLayer -prune -o -name "*.cpp" -and -not -name ".*") \
  5.  
    )
  6.  
    endef
You can specify ignore "LogicLayer" directory by -prune

Guess you like

Origin www.cnblogs.com/adong7639/p/11350055.html