Makefile General advanced writing of Cocos2dx-Android
No nonsense. paste it directly to save time.For more information, seeTo learn together.
LOCAL_PATH: = $ (call my-dir) include $ (CLEAR_VARS) LOCAL_MODULE: = cocos2dcpp_sharedLOCAL_MODULE_FILENAME: = libcocos2dcpp ###################################### ######################################## ########################## manually traverse folders and subdirectories ######## ######################################## ######## this is the first difficult way to write ######################### ######## XLOCAL_C_INCLUDES: ==# $ (LOCAL_PATH)/hellocpp \ # $ (LOCAL_PATH )/.. /.. /Classes # XLOCAL_CPPS: =\# $ (wildcard $ (LOCAL_PATH)/hellocpp /*. cpp) \ # $ (wildcard $ (LOCAL_PATH )/.. /.. /Classes /*. c) \ # $ (wildcard $ (LOCAL_PATH )/.. /.. /Classes /*. cpp) # XLOCAL_SRC_FILES: = $ (XLOCAL_CPPS: $ (LOCAL_PATH)/% = %) # LOCAL_C_INCLUDES + = $ (XLOCAL_C_INCLUDES) # LOCAL_SRC_FILES :=$ (XLOCAL_SRC_FILES) ######################################## ######################################## ######################################## ######################################## ######################## automatically traverse folders and subdirectories ########### ######################################## ##### this is the second convenient way of writing ############################ ### function for Traversing directories and subdirectories # define walk # $ (wildcard $(1 )) $ (foreach e, $ (wildcard $ (1)/*), $ (call walk, $ (e ))) # endef ### traverse the Classes directory # ALLFILES = $ (call walk, $ (LOCAL_PATH )/.. /.. /Classes) # FILE_LIST: = hellocpp/main. cpp # extract all files from all files. cpp file # FILE_LIST + =$ (filter %. cpp, $ (ALLFILES) # LOCAL_SRC_FILES: = $ (FILE_LIST: $ (LOCAL_PATH)/% = %) # LOCAL_C_INCLUDES: = $ (LOCAL_PATH )/.. /.. /Classes \ # $ (LOCAL_PATH )/.. /.. /Classes/LogClass #################################### ######################################## ######################################## ######################################## ########################### automatically traverse folders and subdirectories (source files and header files) ######################################## ##################################### Configuration APP_FILES_PATH: = $ (LOCAL_PATH) \ $ (LOCAL_PATH )/.. /.. /ClassesAPP_FILES_SUFFIX: = %. cpp %. c # recursively traverse all files in the directory rwildcard =$ (wildcard $1 $2) $ (foreach d, $ (wildcard $1 *), $ (call rwildcard, $ d/, $2) # obtain the corresponding source file APP_ALL_FILES: =$ (foreach src_path, $ (APP_FILES_PATH), $ (call rwildcard, $ (src_path ),*. *) APP_ALL_FILES: = $ (APP_ALL_FILES: $ (APP_CPP_PATH )/. /% = $ (APP_CPP_PATH) %) APP_SRC_LIST :=$ (filter $ (APP_FILES_SUFFIX), $ (APP_ALL_FILES) APP_SRC_LIST :=$ (APP_SRC_LIST: $ (LOCAL_PATH) /% = %) # Remove the repeated word define uniq =$ (eval seen: =) $ (foreach _, $1, $ (if $ (filter $ _, $ {seen}), $ (eval seen + =$ _) $ {seen} endef # recursively traverse all directories to obtain APP_ALL_DIRS :=$ (dir $ (foreach src_path, $ (APP_FILES_PATH), $ (call rwildcard, $ (src_path), */) APP_ALL_DIRS :=$ (call uniq, $ (APP_ALL_DIRS )) # assign the value to the NDK compilation system LOCAL_SRC_FILES :=$ (APP_SRC_LIST) LOCAL_C_INCLUDES :=$ (APP_ALL_DIRS) ######################################## ####################################### LOCAL_WHOLE_STATIC_LIBRARIES: = worker + = spine_staticLOCAL_WHOLE_STATIC_LIBRARIES + = worker + = cococos_extension_staticinclude $ (BUILD_SHARED_LIBRARY) $ (call import-module ,.) $ (call import-module, audio/android) $ (call import-module, Box2D) $ (call import-module, editor-support/cocosbuilder) $ (call import-module, editor-support/spine) $ (call import-module, editor-support/cocostudio) $ (call import-module, network) $ (call import-module, extensions)