AndroidNDKBuild参数

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

AndroidNDKBuild参数
原⽂:
'ndk-build' Overview
ndk-build概述
I. Usage:
⼀、使⽤⽅法:
The Android NDK r4 introduced a new tiny shell script, named 'ndk-build', to simplify building machine code.
Android NDK r4引⼊⼀个新的⼩型shell脚本,名字是ndk-build,以简化机器码的构建。

The script is located at the top-level directory of the NDK, and shall be invoked from the command-line when in your application project directory, or any of its sub-directories. For example:
脚本位于NDK的顶级⽬录,并且将在你的应⽤程序⼯程⽬录,或它的任意⼦⽬录中的命令⾏调⽤。

例如:
cd $PROJECT
$NDK/ndk-build
Where $NDK points to your NDK installation path. You can also create an alias or add $NDK to your PATH to avoid typing it every time.
这⾥$NDK指向你的NDK安装⽬录。

你还可以创建⼀个别名或者添加$NDK到你的PATH环境变量以避免每次都键⼊它(注:PATH区分⼤⼩写)。

II. Options:
⼆、选项:
All parameters to 'ndk-build' are passed directly to the underlying GNU Make command that runs the NDK build scripts. Notable uses include:
所有给ndk-build的参数被直接传递到运⾏NDK构建脚本的底层GNU Make命令。

值得注意的使⽤⽅法包括:
ndk-build --> rebuild required machine code. ndk-build --> 重新构建所需的机器代码。

ndk-build clean --> clean all generated binaries. ndk-build clean --> 清除所有⽣成的⼆进制⽂件。

ndk-build NDK_DEBUG=1 --> generate debuggable native code. ndk-build NDK_DEBUG=1 --> ⽣产可调试的本地代码。

ndk-build V=1 --> launch build, displaying build commands. ndk-build V=1 --> 启动构建,显⽰构建命令。

ndk-build -B --> force a complete rebuild. ndk-build -B --> 强制完全重新构建。

ndk-build -B V=1 --> force a complete rebuild and display build commands. ndk-build -B V=1 --> 强制完全重新构建并且显⽰构建命令。

ndk-build NDK_LOG=1 --> display internal NDK log messages (used for debugging the NDK itself). ndk-build NDK_LOG=1 --> 显⽰内部NDK⽇志消息(⽤于调试NDK⾃⾝)。

ndk-build NDK_DEBUG=1 --> force a debuggable build (see below) ndk-build NDK_DEBUG=1 --> 强制调试版构建(见下)(注:调试版指带调试信息,可以⽤gdb调试的⼆进制⽂件)
ndk-build NDK_DEBUG=0 --> force a release build (see below) ndk-build NDK_DEBUG=0 --> 强制发布版构建(见下)(注:发布版指不带调试信息的⼆进制⽂件)
ndk-build NDK_APP_APPLICATION_MK=<file> --> rebuild, using a specific Application.mk pointed to by the NDK_APP_APPLICATION_MK command-line variable.
ndk-build NDK_APP_APPLICATION_MK=<⽂件名> --> 重新构建,通过NDK_APP_APPLICATION_MK命令⾏变量指向使⽤特定的Application.mk.
ndk-build -C <project> --> build the native code for the project path located at <project>. Useful if you don't want to 'cd' to it in your terminal.
ndk-build -C <⼯程⽬录> --> 构建位于<⼯程⽬录>的⼯程的本地代码。

当你不想在终端上⽤cd切换到那个⽬录时有⽤。

III. Debuggable versus Release builds:
三、调试版和发布版构建:
--------------------------------------
In NDK r5, ndk-build has been modified to make it easier to switch between release and debug builds. This is done by using the NDK_DEBUG variable.
在NDK r5,ndk-build已经被修改成可以更容易地在发布版和调试版构建之间切换。

通过使⽤NDK_DEBUG变量来做到。

For example:
例如:
$NDK/ndk-build NDK_DEBUG=1 => forces the generation of debug binaries
$NDK/ndk-build NDK_DEBUG=1 => 强制⽣成调试版⼆进制⽂件。

$NDK/ndk-build NDK_DEBUG=0 => forces the generation of release binaries
$NDK/ndk-build NDK_DEBUG=0 => 强制⽣成发布版⼆进制⽂件。

If you don't specify NDK_DEBUG, ndk-build will keep its default behaviour, which is to inspect the AndroidManifest.xml, if any, and see if its <application> element has android:debuggable="true".
如果你不指定NDK_DEBUG,ndk-build将保持它的默认⾏为,即检查AndroidManifest.xml,如果有,检查它的<application>元素是否有android:debuggable="true"属性。

IMPORTANT: If you use the build tools of SDK r8 (or higher), you won't need to touch your AndroidManifest.xml file at all!
重要事项:如果你使⽤SDK r8(或更⾼)的构建⼯具,你将完全不必修改你的AndroidManifest.xml⽂件!
That's because if you build a debug package (e.g. with "ant debug" or the corresponding option of the ADT plugin), the tool will automatically pick the native debug files generated with NDK_DEBUG=1.
那是因为如果你构建⼀个调试包(例如,使⽤“ant debug”或ADT插件相应选项),⼯具将⾃动选择⽤NDK_DEBUG=1⽣成原⽣调试版⽂件。

(注:也就是说,Java代码为调试版,则JNI的C代码也⾃动切换为调试版)
Also, as a convenience, the release and debug object files generated by the NDK are now stored in different directories (e.g. obj/local/<abi>/objs and
obj/local/<abi>/objs-debug). This avoids having to recompile all your sources when you switch between these two modes (even when you only modified one or two source files).
同样,⽅便起见,有NDK⽣成的发布版和调试版对象⽂件现在被存放在不同的⽬录中(例如obj/local/<abi>/objs和obj/local/<abi>/objs-debug)。

(注:abi是应⽤⼆进制接⼝的缩写,这⾥指代某类交叉编译器,例如EABI,嵌⼊式应⽤⼆进制接⼝)。

这避免当你在这两种模式之间切换时必须重新编译所有源代码(即便你仅仅修改⼀个或两个源⽂件)。

(注:Makefile的策略导致,Makefile认为xxx.c⼀般只会⽣成xxx.o,也就是说调试版和发布版的.o不能共存,上⾯的⽅法类似Windows,使⽤不同的⽬录输出不同版本的.o,以避免覆盖)
IV. Requirements:
四、要求:
You need GNU Make 3.81 or later to use 'ndk-build' or the NDK in general. The build scripts will detect that you're using a non-compliant Make tool and will complain with an error message.
⼀般你需要GNU Make 3.81或更⾼以使⽤ndk-build或NDK(注:因为GNU的make有两种)。

构建脚本将检测到你正在使⽤不兼容的Make⼯具并且⽤⼀个错误消息解释。

If you have GNU Make 3.81 installed, but that it is not launched by the default 'make' command, define GNUMAKE in your environment to point to it before launching
'ndk-build'. For example:
如果你已经安装GNU Make 3.81以上,但不能⽤默认的make命令启动,可以在运⾏ndk-build之前在你的环境变量中定义GNUMAKE指向它的路径。

例如:
GNUMAKE=/usr/local/bin/gmake ndk-build (注:环境变量的键值对出现在命令之前,常⽤于临时变更环境变量,等效于下⾯的export命令)
Or to make the change more permanent:
或更永久地改变:
export GNUMAKE=/usr/local/bin/gmake
ndk-build
Adapt to your shell and GNU Make 3.81 installation location.
请适配你的shell和GNU Make 3.81的安装位置。

V. Internals:
五、内幕:
'ndk-build' itself is a tiny wrapper around GNU Make, its purpose is simply to invoke the right NDK build script, it is equivalent to;
ndk-build本⾝是对GNU Make的⼀个⼩型封装,它的⽬的是简化正确NDK构建脚本调⽤,它等效于:
$GNUMAKE -f $NDK/build/core/build-local.mk [parameters]
Where '$GNUMAKE' points to GNU Make 3.81 or later, and $NDK points to your NDK installation directory.
这⾥$GNUMAKE指向GNU Make 3.81或更新,⽽$NDK指向你的NDK安装⽬录。

Use this knowledge if you want to invoke the NDK build script from other shell scripts (or even your own Makefiles).
如果你想从其它shell脚本中调⽤NDK构建脚本(或者甚⾄是你⾃⼰的Makefile⽂件)(注:Makefile是make的默认配置⽂件,类似于Ant的build.xml)时可以使⽤这种技巧。

阅读(902) | 评论(0) | 转发(0) |
上⼀篇:
下⼀篇:
相关热门⽂章
给主⼈留下些什么吧!~~
评论热议。

相关文档
最新文档