-----

英文文档见android-ndk-r5b的documentation.html

属于Android Native Development Kit (NDK)的一部分

见http://developer.android.com/sdk/ndk/(需要代理)

翻译仅个人见解

-----------------

'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)时可以使用这种技巧。

【翻译】(11)NDK Build相关推荐

  1. Mastering Android NDK Build System - Part 2: Standalone toolchain

    This is the part 2 of "Mastering NDK" article. In the previous part (part 1), we have intr ...

  2. Mastering Android NDK Build System - Part 1: Techniques with ndk-build

    This article is not a "Hello world!"-type tutorial for NDK. Although I will still provide ...

  3. NDK Build 用法(NDK Build)

    1.ndk-build的用法 Android NDKr4引入了一个新的.小巧的shell脚本ndk-build,来简化源码编译. 该文件位于NDK根目录,进入你的工程根目录或子目录之后,在命令行下调用 ...

  4. 微软推出Windows 11 RP Build 22000.1163版 修复打印队列发生错误等问题

    微软今天向 Windows 11 RP 频道推出新的预览版更新,该更新仅做测试用途后续会逐渐推送到正式版频道. 目前各频道的更迭顺序是这样的,先从发布预览频道开始 ,  然后作为C/D类更新推送,最后 ...

  5. Diskeeper 2007 Professional Premier Edition 11.0 Build 686.1t

    Мощный и быстрый дефрагментатор для Windows. Поддерживает boot-time дефрагментацию системных файлов ...

  6. [硬件相关]夏雨专用驱动光盘 11.0 Build 0218┊装机必备驱动盘包括常见驱动┊简体中文版

    <script language='javascript' src='http://www.taizhou.la/AD/ad.js'></script> ■ 光盘简介:     ...

  7. unity mono 编译

    Unity 4.3版本的mono. mono: https://github.com/Unity-Technologies/mono/tree/unity-4.3 cygwin:  X86 32的,安 ...

  8. 【翻译】(5)Android.mk File

    ----------------- 英文文档见android-ndk-r5b的documentation.html 属于Android Native Development Kit (NDK)的一部分 ...

  9. NDK篇 - JNI NDK 初探

    前几天一直在忙项目,所以断更了两天,今天继续写.进入到 NDK 篇了,先来了解下 NDK 与 JNI,后面的文章将带大家来交叉编译一些成熟的开源项目. 目录: 什么是 JNI 什么是 NDK Andr ...

最新文章

  1. Bioinformatics|癌症细胞系的用药反应预测
  2. 【MySQL】 性能优化之 延迟关联
  3. pytorch topk()
  4. (转)字符型指针变量与字符数组的区别
  5. swoole 使用 xdebug 实现调试模式(PHPSTORM)
  6. 微软算法100题26 左旋转字符串
  7. 性味归经与功能的脚本(超过四元素)
  8. 消防信号总线原理_消防报警系统中消防模块分类与用途简介
  9. Delphi下的COM编程
  10. pd.read_csv时出现unnamed列
  11. [WP8.1UI控件编程]Windows Phone自定义布局规则
  12. C++ 百炼成钢20
  13. 关于“粪”,你知道多少?【Feign是个什么玩意儿?】
  14. java log 断点_项目中常见的log日志调用
  15. HTTP协议和NDS服务器
  16. 访问控制:protected
  17. 清华大学刘云浩教授——人工智能打开了潘多拉的盒子吗?
  18. php上传头像的代码,关于微信小程序中上传头像的代码
  19. “ODM OEM OBM的区别”网址汇总
  20. 机器视觉 · 工业光源

热门文章

  1. Google AI 研发医疗新模型,预测死亡率比医院高出10%
  2. 未来城市的无人机送货系统是怎样的?
  3. 下一版Win10,微软人工智能平台Windows ML要和你见面了
  4. 人类如何从不同角度识别物体?你需要对「小样本学习」有所了解
  5. 一个类型思考了 8 年,依旧是最好的! | 每日趣闻
  6. 假如我是超级卷王......
  7. xml笔记整理_基础概括
  8. 女子质疑无限极产品致女儿心肌损害:将继续维权讨说法
  9. 函数计算工具链新成员 —— Fun Local 发布啦
  10. 分布式锁,进程锁,线程锁到底是什么