ANDROID.MK file: Compile the required CPP file, generate. So dynamic library for Android side call.
First on a android.mk file:
The first time you create a project, you need to compile the entire COCOS2DX library through the Android.mk file when compiling the Android platform (the first compile we need to wait a long time ...). )。
First know the role of the $ (call Import-module,dir_name), and then follow the Lib/proj.android directory to continue to find the corresponding directory of the android.mk file
Similar to recursion, the android.mk files in all directories are compiled once, and eventually the COCOS2DX Library and its own CPP files are packaged as. so files.
1) Local_whole_static_libraries: = Quickcocos2dx
The above meaning is a static library containing QUICKCOCOS2DX, but where is the static library of the QUICKCOCOS2DX?
Step into the D:\quick-x\quick-cocos2d-x\lib\proj.android to see the android.mk file under this directory, probably as follows:
Local_path: = $ (call My-dir)
Include $ (clear_vars)
Local_module: = Quickcocos2dx #库名
Local_module_filename: = LIBQUICKCOCOS2DX
....
....
Include $ (build_static_library) #编译静态的quickcocos2dx库
$ (call IMPORT-MODULE,COCOS2DX) #继续编译cocos2dx目录下的android. mk File
$ (call import-module,cocosdenshion/android) #继续编译CocosDenshion android.mk file in the/android directory
$ (call import-module,extensions) #继续编译extensions目录下的android. mk File
$ (call import-module,scripting/lua/proj.android) #继续编译scripting android.mk file in the/lua/proj.android directory
...
...
As you can see from the above android.mk, this is the static library of QUICKCOCOS2DX.
In this way, by constantly compiling the android.mk file, several static libraries of COCOS2DX are generated, resulting in the target. So dynamic library.
In this way, under the Android platform, you can use JNI to call COCOS2DX's library so you can play the game on your phone.
2) The difference between Local_module and Local_module_filename
Look at the specific code:
Local_module: = QUICKCOCOS2DX
Local_module_filename: = LIBQUICKCOCOS2DX
The above two lines of code, I understand:
in the process of compiling the Android.mk file ,
The name used is QUICKCOCOS2DX (the variable name used by the ANDROID.MK runtime, and the other Mk file can refer to this module by QUICKCOCOS2DX),
But when the compilation is complete, stored to external memory, which is the hard disk (Local_module_filename), the name used is: LIBQUICKCOCOS2DX
Online about android.mk A lot of documents, recommend a good, give me cloud See month Blog:
Http://www.cnblogs.com/yaozhongxiao/archive/2012/03/06/2382362.html
and excerpts of some useful text:
++++++++++++++++++++++++++ Split Line ++++++++++++++++++++++++++++++
1. Android compilation system Analysis--- system variable parsing
Local_path-Directory at compile time
Local_module-target object for compilation
Local_src_files-Compiled source file
Local_c_includes-The header file directory that needs to be included
Local_shared_libraries-External libraries required for linking
Local_prelink_module-whether prelink processing is required
Build_static_library-Indicates that you want to compile into a static library
Build_shared_library-Indicates to be compiled into a dynamic library
(1). Local_path-Directory at compile time
$ (call directory, directory ....) Directory introduction Operator: If there is a folder name src in this directory, then you can write the "$", then you will get the full path of the SRC directory
(2). Include $ (clear_vars)-clear some of the previous system variables
Clear_vars:= $ (Build_system)/clear_vars.mk
In BUILD/CORE/CONFIG.MK definition clear_vars:= $ (build_system)/clear_vars.mk
Include a custom. mk file (that is, a custom compilation rule) or another. mk file (System-defined compilation rule) from the system by using include.
(3). local_src_files-Compiled source files
Can be. C,. cpp,. Java,. S (assembly file) or. aidl format, different files are separated by spaces.
If you compile a directory subdirectory, take a relative path, such as a subdirectory/file name.
You can also use the $ (call directory) to indicate that all the. c/.cpp/.java/are compiled under a directory. s/. aidl file. Append file Local_src_files + = File
(4). local_c_includes-The header file directory to include
This can be either a system-defined path or a relative path. If there is an include directory under the compilation directory, the notation is include/*.h
(5). Local_module-target object for compilation
Module refers to the system's native code, which is typically for c,c++ codes
./system/core/sh/android.mk:32:local_module:= SH
./system/core/libcutils/android.mk:71:local_module: = Libcutils
(6). Local_package_name
The name of the Java application is defined with this variable
./packages/apps/music/android.mk:9:local_package_name: = Music
./packages/apps/browser/android.mk:14:local_package_name: = Browser
(7) . dependent libraries
local_shared_libraries-External shared libraries required for linking
local_static_libraries-External external static required when linking
local_java_libraries Add jar package
(8). Build_shared_library-Indicates that you want to compile into a dynamic library. The target of the compilation, using the Include operator
BUILD_STATIC_LIBRARY ---to indicate that it is to be compiled into a static library.
If it is a Java file, use Build_package to specify it. will use the system's compiled script host_java_library.mk,