Learning Notes Android.mk Automatic search

Source: Internet
Author: User

Recently was android.mk this thing toss of one night, here record. iOS is much more hassle-free, don't worry about so much, Xcode himself solved. Text Tool: Macvim (text Editing tool is very useful to clearly distinguish between tab and space, so as not to write. MK error) This file describes the source code file to the compiler for easy parsing. The following is the basic syntax for the Android.mk file generated when cocos2dx-3.2 new project: "#" comment ": ="   Assignment "+ ="   Append "$"     reference value of a variable # The macro function My-dir returns the current path provided by the compilation system, which is the ANDROID.MK directory # such as (HELLOWORLD/PROJ.ANDROID/JNI/XX) Local_path: = $ (call my-dir) #初始化模块 reset except LOCAL All variables except the _path variable include $ (clear_vars) #导入库目录 $ (call import-add-path,$ (Local_path)/. /.. /COCOS2D) $ (call import-add-path,$ (Local_path)/... /.. /cocos2d/external) $ (call import-add-path,$ (Local_path)/... /.. /cocos2d/cocos) #模块名, the only. Local_module: = cocos2dcpp_shared# module file name, unique (optional) Local_module_filename: = libcocos2dcpp? #把. cpp. C. cc and other implementation file path assignment to Local_ Src_files I use the C + + version of the suffix is. cpp When we create a new file, we need to add the path here. Local_src_files: = Hellocpp/main.cpp. /.. /classes/appdelegate.cpp. /.. /classes/helloworldscene.cpp# Configuration header File Search scope Local_c_includes: = $ (local_path)/... /.. /classes# get static library local_whole_static_libraries: = cocos2dx_static# append static library Local_whole_static_librarIES + = cocosdenshion_static# local_whole_static_libraries + box2d_static# local_whole_static_libraries + = cocosbuilder_static# local_whole_static_libraries + = spine_static# Local_whole_static_libraries + = cocostudio_static # local_whole_static_libraries + = cocos_network_static# Local_whole_static_libraries + = cocos_extension_static# Depending on the compiler provided by the variable build_shared_library generate dynamic library include $ (build_shared_library) #导入模块, the following are several modules commonly used $ (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)


If the file is less directly in the Local_src_files this variable to add the path of the file is good
Unfortunately I have dozens of files, one add is not exhausted, and difficult to maintain, difficult to expand, error-prone, ...


I am a lazy person, refer to the Zilong People's Mk rewrite a bit
Local_path: = $ (call My-dir) include $ (clear_vars) $ (call import-add-path,$ (Local_path)/. /.. /COCOS2D) $ (call import-add-path,$ (Local_path)/... /.. /cocos2d/external) $ (call import-add-path,$ (Local_path)/... /.. /cocos2d/cocos) Local_module: = cocos2dcpp_sharedlocal_module_filename: = Libcocos2dcpp#widcard for Extended wildcard # Traverse directories and subdirectories define walk $ (wildcard $ (1)) $ (foreach E, $ (wildcard $ (1)/*), $ (call Walk, $ (e))) endef# Traverse path classes directory and subdirectory files, and deposit the allfiles variable in allfiles = $ (call walk, $ (local_path)/. /.. /classes) #从ALLFILES目录中提取文件 and stored in File_list #.cc is the default extension for C + + source files under Linux/unix, with. cpp a meaning #.c because I'm going to use sqlite3.c file_list: = Hellocpp/main.cppfile_list + = $ (filter%.cpp, $ (allfiles)) File_list + = $ (filter%.c, $ (allfiles)) File_list + = $ (filter%). CC, $ (allfiles)) #搜索Classes下的子目录文件FILE_INCLUDES + = $ (Shell find $ (local_path)/. /.. /classes-type d) #根据搜索到的文件名 compile the resource file Local_src_files: = $ (file_list:$ (Local_path)/%=%) #提供搜索文件的路径LOCAL_C_INCLUDES: = $ ( Local_path)/.. /.. /classes $ (file_includes) #静态库LOCAL_WHOLE_STATIC_LIBRARIES: = Cocos2dx_statIclocal_whole_static_libraries + = cocosdenshion_static#local_whole_static_libraries + box2d_static#LOCAL_WHOLE_ Static_libraries + = cocosbuilder_static#local_whole_static_libraries + spine_staticlocal_whole_static_libraries + = Cocostudio_staticlocal_whole_static_libraries + = cocos_network_staticlocal_whole_static_libraries + Cocos_ extension_static# compiling the dynamic library include $ (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)


Slot: These bits and pieces should be solved by the engine or the development software.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.