Frequently used syntax in ANDROID.MK

Source: Internet
Author: User


Android.mk compiled files are used to describe your c,c++ source files to the Android NDK, and today we look at some of the commonly used grammars.


An overview: A android.mk file is used to describe your source code to the compilation system.
In detail: This file is a small part of the GNU Makefile, which is compiled by the system to parse one or many other build systems.




You can define one or more modules in each android.mk file,
You can also use the same source file in several modules.


Two Syntax 1 You must define the content first by looking at what must be defined:

Local_path: = $ (call My-dir) include $ (clear_vars) Local_module: = xxxlocal_files: = XXX.cpp ... Include $ (build_xxx)

Detailed meanings such as the following:
Local_path: = $ (call My-dir)
Each android.mk file must start with a definition of local_path. It is used to find source files in the development tree.


My-dir is a macro function. There is a build system available. Returns the current path. The file folder that includes the android.mk.


Include $ (clear_vars)
The Clear_vars variable is provided by the compilation. Points to a GNU Makefile, which is responsible for cleaning up the local_xxx variable (does not clean up local_path).


Because all compilation control files are parsed and run by the same GNU make. Its variables are global, so the ability to clean up after cleaning to avoid mutual influence.




Local_module: = XXX
Local_module is the module name and must be defined before the include $ (build_xxxxx), unique and does not include spaces.


Local_src_files: = XXX.cpp
The list of source files. You must include C + + source code that will be packaged as a module.


Instead of listing header files, the compilation system will proactively identify the dependent header files.
The default C + + source code extension is. cpp. can also be changed. Through Local_cpp_extension.


Include $ (XXX)
Responsible for collecting all local_xxx information since the last call to include $ (clear_vars). and decide what to compile.
Simply introduce the two frequently used:
Build_static_library: Compile as a static library and generate a file named lib$ (Local_module). So.
Build_shared_library: Compile as a dynamic library and generate a file named lib$ (Local_module). A.




2 frequently used optional content local_module_filename: = XXX
It is generally defined after local_module: = XXX, which is used to overwrite the Local_module and again defines the name of the target file that was finally generated.


Local_cpp_extension: =. CXX
Indicates the C + + extension. For example: local_cpp_extension: =. cxx. CPP. cc.




Local_c_includes: = XXX
Specifies to include the path, which will be appended to the compilation.
For example:
Local_c_includes: = $ (Local_path)/. /.. /classes \
$ (local_path)/. /.. /classes/sdkcontroller \
$ (local_path)/. /.. /classes/sdkcontroller/android \
$ (local_path)/. /.. /classes/sharecontroller \
$ (local_path)/. /.. /.. /.. /.. /cocos2dx/platform/android/jni


local_cflags: = xxx, local_cppflags: = XXX
is used to add the compile option when compiling C + +.
For example:
Local_cflags: = \
-wno-multichar \
-dandroid \
-dlibdir= "C" \
-dbuilding_libiconv \
-din_ Library


Local_whole_static_libraries: = XXX
Static library full link, the compiler will complete the static library link without pruning optimization. The
differs from local_static_libraries, similar to using--whole-archive.


Like what:
Local_whole_static_libraries: = cocos2dx_static
Local_whole_static_libraries + = Cocosdenshion_static
Local_whole_static_libraries + = Cocos_lua_static


Import-module:
Agree to find and import other modules into this android.mk. It will look for the specified module name from Ndk_module_path.
$ (call import-module,<name>)
Like what:
$ (call IMPORT-MODULE,COCOS2DX)
$ (call import-module,cocosdenshion/android)
$ (call import-module,scripting/lua/proj.android)


Appendix: Participation Kauboven
Http://www.cnblogs.com/wainiwann/p/3837936.html
Http://www.cnblogs.com/leaven/archive/2011/01/25/1944688.html

Frequently used syntax in ANDROID.MK

Related Article

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.