NDK开发 ndk环境

NDK Development:NDK 开发:----------------
This document describes how one can modify the NDK andgeneratenew experimental release packages for it.本文档介绍了如何来修改 NDK 和为它生成的新的试验性的发布包。
I. Getting the sources:I. 获取源代码:=======================
The sources live under the "ndk" and "development/ndk"directories inthe Android source tree:源代码存留在 Android 源代码树中的 ndk 和 development/ndk 目录下。
- "ndk" contains the main build scripts anddocumentation - ndk 包含主要的生成脚本和文档
- "development/ndk" containsplatform-specific headers and samples - development/ndk 包含特定的平台头文件和示例
If you have downloaded the full Android source tree throughthe "repo"tool, you can start directly there. Otherwise, you can justget thesetwo repositories with the following:如果你有通过 repo 工具下载全部 Android 源代码树,你可以直接在那里开始。否则,你只能用如下方法获得 ndk 和 development 两个目录:
mkdir workdir cd workdir git clonegit://android.git.kernel.org/platform/ndk.git ndk git clonegit://android.git.kernel.org/platform/development.gitdevelopment export NDK=`pwd`/ndk
注:pwd 是 Linux 的输出当前目录全路径命令。

II. Building the platforms tree:II. 生成平台树:================================
You need to do that once if you want to use the content of$NDK to buildsamples, tests or anything else:一旦你想要使用 $NDK 的内容来生成示例,测试或其它事情,你需要做:
$NDK/build/tools/build-platforms.sh
What the script does is populate the $NDK/platforms and$NDK/samplesdirectories from the content of development/ndk.这个脚本做的事情是把 development/ndk 目录下的内容添入到 $NDK/platforms 和$NDK/samples 目录下。
What is under development/ndk is segregated by API level. Thismakes iteasier to add a new platform to the tree, but is notwell-suited to buildingstuff. The build-platforms.sh script will gather all filesappropriatelyand place the result inside $NDK/platforms and$NDK/samples.在 development/ndk 下是以 API 级别来区分的。这样添加一个新的平台到平台树中更容易,但是对生成活动是不便利的。build-platforms.sh 脚本将恰当地收集全部文件并放置到 $NDK/platforms 和$NDK/samples 目录里面。
Note: These directories are listed by $NDK/.gitignore, so theywon't appear onyour git status. You can remove them if you want by running:注意:由 $NDK/.gitignore 列出的这些目录,它们将不是出现在你的 git 状态上。   你想要移除它们可以通过运行如下脚本来实现:
$NDK/build/tools/dev-cleanup.sh
whichalso removes all intermediate files and directories from$NDK. 同样地从$NDK 中移除全部的中间文件和目录。

III. Prebuilt binaries:III. 预先生成的二进制代码文件:=======================
The NDK requires several prebuilt binary executables to workproperly, theseinclude the following:NDK 需要几个预先生成的二进制可执行文件来适时工作,这些包括如下:
- toolchain binaries for the cross-compilerand associated tools - 工具链二进制代码文件为交叉编译器和相关工具 - gdbserver binaries required for nativedebugging - 本机调试需要的 gdbserver 二进制代码文件
These are not provided in the NDK's git repositories. However,there areseveral ways to get them:在 NDK git 存放库中这些是不提供的。然而,这是几个得到它们的方法:
1/ From a previous NDK releasepackage: 1/ 来自一个之前的 NDK 发行包:
Byfar the easiest thing to do is to copy the binaries from aprevious NDKinstallation. You can do that with a command like the followingone: 最容易的做法是从一个以前的 NDK 安装中拷贝二进制代码文件。你可以执行像如下一个命令:
cp -r$PREVIOUS_NDK/toolchains/* $NDK/toolchains/
NOTE:The binaries are listed in $NDK/.gitignore and will notappear in yourgit status. 注意:在$NDK/.gitignore 中列出的这些二进制代码文件将不是出现在你的 git 状态上。

2/ Download and rebuild directly from theinternet: 2/ 从互联网上下载且直接重新生成:
IMPORTANT: This is *very* long. 要点:这个过程很长。 TheNDK comes with several scripts that can be used to rebuildthe binaries from scratch, after downloading their sources from android.git.kernel.org. 在从android.git.kernel.org 下载完它们的源代码文件之后, NDK附赠的几个脚本文件可以从头开始重新生成二进制代码文件。
Thereare several ways to do that, the most naive one, which will always work but will be *very* long (expect a few hours on atypical dual-core machine) is to do the following: 几个方法中最幼稚的,也是耗时最长的(预计一个典型的双核机器上快一小时)一个如下:
$NDK/build/tools/rebuild-all-prebuilt.sh
Thiswill perform all the steps required to rebuild the binaries, whichinclude: 这将完成全部需要重新生成二进制代码文件的步骤,包括:
- downloading the sources fromandroid.git.kernel.org - 从 android.git.kernel.org 下载源代码文件
- patching them with appropriate changes, ifneeded - 如果需要的话,适当的改变修理它们
- rebuilding everything from scratch - 从头重新生成一切
- copying the generated binaries to the properlocation under $NDK - 拷贝产生的二进制代码文件到 $NDK 适合的位置下面
Youwill need about 30G of free space in your /tmp directory tobe ableto do that, and *plenty* of free time. 你将需要你的 /tmp 目录有大约 30GB 的空闲空间并且有大量的空闲时间。
IMPORTANT: If you plan to generate NDK release packages, even experimental ones, we strongly suggest you to use theindividual stepsdescribed in 3/ below. 重点:如果你计划产生 NDK 发布包,即使是试验性的,我们强烈建议你使用下面 3/ 中描述的特有的步骤。
IMPORTANT: Since NDK r5, Windowsbinaries can be built on Linux by using the --mingw option, whichrequires that you have the "mingw32" package installed on your system. Forexample: 重点: 从 NDK r5 以后,Windows二进制代码文件可以是通过使用 --mingw 选项生成在 Linux 之上, 需要你有在你的系统上安装 mingw32包。例如:
$NDK/build/tools/rebuild-all-prebuilt.sh--mingw
We do not officially supportbuilding these binaries directly on Windows (either throughCygwin or MSys) anymore, due to the vast number of problems theseenvironments create when trying to do so. 我们不再正式支持直接生成这些二进制代码文件在Windows 上(通过 Cygwin 或 MSys 两者中的任何一个), 因为当尝试那么做时这些环境产生大量问题。
3/ Download, rebuild, package, install inseparate steps: 3/ 下载、重新生成、打包、安装用独立的步骤:
Ifyou plan to generate your own NDK release packages, it isbetter torebuild your binaries using separate steps, as in: 如果你计划产生你自己的 NDK 发布包,使用独立的步骤重新生成你的二进制代码文件是比较好的,如:
- Download the sources fromthe Internet, patch them, then package theresult in a simple tarball. - 从互联网上下载源代码文件,修理它们,然后打包简单的tarball 结果。
- For every target system(linux-x86, darwin-x86 and windows), rebuild thebinaries from the same source tarball. -对于每一个目标板系统(Linux-x86,darwin-x86 和 Windows), 从相同源tarball 中重新生成二进制代码文件。 注:打包工具 tarball 是 linux下最方便的打包工具。
- Package and collect allprebuilt binaries into a single directorythat will be used when packaging NDK releases. -打包且收集全部重新生成的二进制代码文件到一个单独的目录, 在打 NDK发布包时被使用。
Hereare more details on how to do that: 这里是更多如何做的细节:
3.a/Download + patching + packaging sources: 3.a/下载 + 修理 + 打包源代码文件:
Use the following command to download, patch andpackage the sources: 使用如下命令去 下载、修理 和 打包 源代码文件:
$NDK/build/tools/download-toolchain-sources.sh--package
This will create a large tarball containing allsources ready to be used by the following step. The generated filepath will be dumped at the script when it completes its operation andshould be something like: 这将创建一个大的 tarball 包含全部源代码文件准备由在如下步骤使用。 产生文件路径将是转储在脚本完成它的操作时,类似如下:
/tmp/android-ndk-toolchain-<date>.tar.bz2
Note that if you don't use the --package option,you will need to provide the name of a directory where thepatched sources will be copied instead, as in: 注意如果你不使用 --package选项,你将需要提供目录名替代修理后的源代码文件将拷贝到的目录,如:
$NDK/build/tools/download-toolchain-sources.sh<target-src-dir>

3.b/ Build the binaries: 3.b/ 生成二进制代码文件:
Use the following command to rebuild thebinaries from the source tarball that was created in the previous sectionwith the --package option: 使用如下命令从之前用 --package 选项创建的源 tarball重新生成二进制代码文件:
$NDK/build/tools/rebuild-all-prebuilt.sh--toolchain-pkg=<file>
Where <file>points to the package generated by the download-toolchain-sources.sh script. <file>指明包是由download-toolchain-sources.sh 脚本创建的。
In the case where you downloaded the sources toa directory instead, use the --toolchain-src-dir option instead, aswith: 既然如此你下载源代码文件的目录可以使用 --toolchain-src-dir选项来替换:
$NDK/build/tools/rebuild-all-prebuilt.sh--toolchain-src-dir=<path>
This will rebuild all the prebuilt binaries foryour host platforms and place them in a directory named: 这将为你的主机平台重新生成全部预先生成的二进制代码文件并放置它们到一个已命名的目录中:
/tmp/ndk-prebuilt/prebuilt-<date>/
These binary packages include thefollowing: 这些二进制包包含如下:
-host-specific toolchain binaries. e.g. -特定主机工具链二进制代码文件,例如: arm-eabi-4.4.0-linux-x86.tar.bz2
-toolchain specific device binaries, e.g. -工具链特定的设备二进制代码文件,例如: arm-eabi-4.4.0-gdbserver.tar.bz2
IMPORTANT: 重点: Togenerate Windows binaries on Windows, install the "mingw32" package onyour system, then use the --mingw option, as in: 在 Windows上产生 Windows 二进制代码文件,安装 mingw32 包在你的系统上, 然后使用--mingw 选项,如:
$NDK/build/tools/rebuild-all-prebuilt.sh --mingw--toolchain-pkg=<file>
Note thatdevice-specific binaries (e.g. gdbserver) cannot be rebuiltwith this option. 注意特定的设备二进制代码文件(例如:gdbserver)不能用这个选项重新编译。
3.c/ Copy the binaries to your NDK tree: 3.c/ 拷贝二进制代码文件到你的 NDK 树:
Simply go to your NDK tree, and unpack thebinary tarballs in place, for example: 只不过到你的 NDK 树,解包二进制 tarball 在合适的位置,例如:
cd$NDK tar xjf<path>/*.tar.bz2
Where <path> is adirectory containing all the tarballs (e.g. it could be simply/tmp/ndk-prebuilt/prebuilt-<date>) <path>是一个包含全部tarball 的目录(例如:它可以单纯地是/tmp/ndk-prebuilt/prebuilt-<date>)
This will put the corresponding files at thecorrect location. 这将放置相应的文件到合适的位置。
3.c/
It isa good idea to save the generated toolchain binaries into anarchive. To do that, use the --package option, as in: 保存产生的工具链二进制代码文件到一个压缩文件中是一个好主意。 使用--package 选项来实现,如:
$NDK/build/tools/rebuild-all-prebuilt.sh--package
Thiswill generate a package file containing all the prebuilts,that canbe unpacked directly into your $NDK directory. The package nameis printed at the end,e.g."android-ndk-prebuild-<date>-<system>.tar.bz2". 这将产生一个包文件包含全部的预先生成的二进制代码文件,可以直接解开包到你的 $NDK 目录下。 包名是在最后打印出来,例如:android-ndk-prebuild-<date>-<system>.tar.bz2
Where<date> is the current date, and<system> is your system name. Then,to unpack: <date>是当前日期,<system>是你的系统名称,然后,解包:
cd $NDK tar xjf/tmp/android-ndk-prebuilt-<date>-<system>.tar.bz2

Thegenerated package can easily be shared with other people. 产生的包可以很容易与其他人共享。

IV. Generate new package releases:IV. 产生新包发布:==================================
You can generate new experimental NDK release packages onceyou're satisfiedwith your changes, in order to share them with other people.There are twoways to do that:一旦你对你的改变感到满意,你可以产生新的试验性的 NDK 发布包以便与其他人共享。这有两种方法可以做到:
1/ Using the 'make-release.sh'script: 1/ 使用 make-release.sh 脚本:
The simplest, and alsothe slowest way, to generate a new NDK release is to invoke thisscript, with: 最简单且最慢的方法,调用如下脚本产生一个新的NDK 发布:
$NDK/build/tools/make-release.sh
NOTE: THIS WILL BE VERYVERY LONG. The script will do all the steps described in section III*from* scratch, and this can take several hours on a dual-coremachine. 注:这将是非常非常漫长。脚本将从头做在 III部分中描述的全部步骤,   并且在一个双核机器上花费数小时。
You should only use itin case of desperation, or if you don't want to deal with all thedetails exposed in section III or below. 别无它法或者你不想处理 III部分或后面暴露的细节时你只能用这个方法。
1/ Using a previous NDK releasepackage: 1/ 使用一个之前 NDK 发布包:
This is the secondsimplest way to generate a new package, and it will be extremely quickbecause it will pick the prebuilt binaries directly from the previouspackage. 这是产生一个新包的第二简单的方法,并且它将极其快速,因为它将直接从之前的包中选择预先生成的二进制代码文件。
Do the following: 做下面操作:
cd $NDK build/tools/package-release.sh--prebuilt-ndk=<file>
Where<file> points to a previous NDKpackage (i.e. archive file). <file>指出一个之前 NDK 包(也就是档案文件)。
NOTE: This method canonly be used to generate a single release package for the current hostsystem. 注意:这个方法仅可以为当前主机系统产生一个单独的发行包。
2/ Using prebuilt tarballs: 2/ 使用预先生成的 tarball:
If you have generatedprebuilt binary tarballs with the steps described in section III.3 above,you can use these to generate release packages as well. 如果你已在上文 III.3部分中描述的步骤产生了预先生成二进制代码文件 tarball, 你也可以使用这些产生发布包。
Assuming that you havecollected prebuilt tarballs for all three supported host systems (i.e.linux-x86, darwin-x86 and windows) under a directory, do the following: 假设你有收集全部三个主机系统的预先生成的tarball (也就是:linux-x86、darwin-x86 和 Windows)到一个目录下,做如下操作:
cd $NDK build/tools/package-release.sh--prebuilt-dir=<path>
The generated NDKpackage release will have a name that looks like: 产生 NDK包发布将有一个看起来像如下的一个名字:
/tmp/ndk-release/android-ndk-<release>-<system>.zip
Where<release> is by default the currentdate in ISO format (e.g. 20100915), and<system> corresponds to the hostsystem where the NDK release is supposedto run. <release>默认情况下是 ISO格式的日期(例如:20100915), <system>符合这个 NDK 发布版支持运行的主机系统。
The script'package-release.sh' provides a few additional options: 脚本 package-release.sh提供少许附加选项:
--release=<name> Change thename of the release 改变发布的名字
NDK开发 ndk环境
--systems=<list> Change thelist of host systems to package for 改变主机系统的列表
--platforms=<list> List of API levels to packagein the NDK 在 NDK 中的 API 级别列表
--out-dir=<path> Specify adifferent output directory for the final packages (instead of/tmp/ndk-release) 为最终包指定一个不同的输出目录(代替 /tmp/ndk-release)
Use --help to list themall. 使用 --help 列出它们全部。

  

爱华网本文地址 » http://www.413yy.cn/a/25101015/265173.html

更多阅读

JDK安装配置教程 精 jdk安装配置教程

JDK作为JAVA开发的环境,不管是做JAVA开发的学生,还是做安卓开发的同学,都必须在电脑上安装JDK。下面就教大家如何安装JDK。JDK安装配置教程 精——工具/原料电脑一台JDK安装包JDK安装配置教程 精——一:JDK的安装JDK安装配置教程 精

安卓手机开发平台搭建 mac 安卓开发环境搭建

android手机开发平台搭建www.111cn.net2012-02-09 编辑:jimmy本文章来给想做android手机开的朋友介绍一下android手机开发平台环境配置教程,有需要的同学可以参考一下本教程。初学Android,以便记录学习过程,增强学习效果。1.下载搭建a

中国第一征集网 中国第一征集网官网

两江新区北碚蔡家组团森林公园(暂名)名称征集为了进一步提升两江新区北碚蔡家组团城市形象,改善开发开放环境,蔡家组团正加快建设位于城市中心地段的森林公园,项目一期工程即将竣工。该公园建成后,将成为蔡家组团重要的城市地标和精美名

环境搭建VS2008+WDK+DDKWzard zard1991

开发驱动,首先就是搭建开发的环境。既然是开发windows下的驱动程序,那MS的开发工具是一定要的。现在vs都到2010了,所以,也不能总是抱着vs6.0写代码,也要与时俱进~当然又不能太潮流吗……所以选用vs2008开发驱动。好了废话不多说了,下面记

美国机械工程专业就业前景分析 机械专业就业前景

  机械工程是传统的工程专业,培养学生设计开发和制造各种机械零件和生产设备。将来有志于学习汽车工程的学生,也应选择机械工程作为基础。  该专业的美国就业市场巨大,在工程类专业中,机械工程的市场需求率排名第一。约有80%的毕业

声明:《NDK开发 ndk环境》为网友雨橙汉子分享!如侵犯到您的合法权益请联系我们删除