Chinaunix首页 | 论坛 | 博客
  • 博客访问: 123575
  • 博文数量: 16
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 222
  • 用 户 组: 普通用户
  • 注册时间: 2014-07-23 22:32
个人简介

这个博客已经停止更新,请访问blog.mxslly.com

文章分类
文章存档

2018年(4)

2016年(3)

2015年(8)

2014年(1)

我的朋友

分类: Android平台

2015-02-25 14:26:25

Doc: Building Basics

目录

 [

·        

·        

·        

·        

·         5 Shortcut commands every CM dev should know

o   

o   

o   

Basic language info基本的语言信息

Android is written in a combination of C, C++, and Java. Here's a bit of a breakdown:

安卓是一个C语言、c++语言和java语言的结合体,这里是一些分析。

·         the very low-level stuff  like the kernel, libc (or bionic as it's known in the android world), and many Linux-ish parts of Android are written in C.

·         非常低层的组件像内核、c库(在安卓的世界被称作bionic)和安卓的linux的部分,都是用c语言写的。

·         Slightly "higher"-up stuff, as well as external, 3rd-party open-source programs incorporated into Android may be written in C or C++. This includes everything from the Dalvik virtual machine (which runs end-user programs), networking tools, sound processors, shell tools, graphics drivers, and that sort of thing.

·         稍微高层的组件,以及被结合进安卓的第三方开源程序可能是用c或者c++写的。这包括从dalvik虚拟机(用来运行终端用户程序)、网络工具、声音处理器、shell工具、图形驱动等一类东西。

·         The Android "framework" stuff such as the UI elements, as well as the apps themselves, are written in Java. This is the stuff that most people think of when they think of Android, because it deals with much of what they see and interact with.

·         安卓框架组件例如ui元素,以及应用程序本身,是用java写的。这是大多数人想到安卓就会想到的那部分组件,因为他处理人们看到的和交互的东西。

You can learn more about any of these languages from the external .

你可以从在线资源了解到任何这些语言的版本。

.mk files, Makefiles, and the /build directory

.mk文件,makefiles文件和/build文件夹

There is a whole build system which is used to create a flashable .zip file from source. The various Makefile scripts used to control this process are primarily located in the /build directory.

这是用源码来创建一个可以烧录的.zip文件的整个编译系统。各种makefile脚本主要就位于/build目录,他们被用来控制这个编译过程。

It may be useful to know the basics of how it works-- essentially, the various components/programs which together make up Android are each built independently through Android-specific Makefiles called Android.mk. The Android.mk generally exists for each sub-project (or "module") in its source-code directory. This file directs the build system on exactly how to build that module, and where to put it in Android's directory structure.

了解一下编译系统工作的基本的知识似乎是有用的。基本上,各种各样的组件或者说程序一起组成安卓,他们是通过叫做Android.mk的安卓特定的makefiles文件来独立地编译的。Android.mk存在于每个主项目或者说模块的源码目录下面。这个文件精确地告诉编译系统怎样去构建那个模块,把它放在安卓源码树的哪个位置。

The files, once built, end up in the /out/target/project/CODENAME directory (replace CODENAME with the code name of the device). From there, they are zipped up and the final flashable (by recovery) .zip and flashable (by fastboot) .img files are produced.

这些文件一旦被编译,就会输出在/out/target/project/CODENAME目录(codename就是设备的开发代号名)。在哪里他们被压缩,最终可被recovery烧录的zip文件和可被fastboot烧录的img文件就被生成了。

You can actually get a peek at what's been built there in /out, as the directories that are turned into the .img and .zip files are still around.

你确实可以了解在out文件夹里什么被创建了,因为那些被转换成zipimg的文件夹还在附近。

The various source code directories

各种各样的源代码目录

In addition to the /build directory, the Android source code is organized into a hierarchy of folders.  at a brief description of what's where in the source code.

包括/build文件夹,安卓源代码被组织成为一个树状文件夹。点击这里可以简单了解下什么东西在源代码的什么地方。

The $OUT directory

out文件夹

Helpful Tip

After you build, you can type cd $OUT to automatically go to the /out/target/project/CODENAME directory.

有帮助的建议

在你创建完后,你可以键入cd $out来自动到达/out/target/project/codename目录

kernel This is the kernel, obviously.

显而易见这是内核目录

/system -- this contains all the stuff that will become the /system folder on Android.

包含将会成为安卓system文件夹的所有组件

/root -- these files contain the files that are turned into the ram disk loaded and run by the kernel. The first program to be run by the kernel is called init, and it uses the init.rc and init.CODENAME.rc files to determine what happens next. See an discussion of that .

包含被内核载入和运行的内存盘的文件。第一个被内核运行的程序叫做init,它使用init.rcinit.codename.rc决定接下来运行什么。点击这里看一下有关的讨论。

/recovery/root The ramdisk that contains the recovery mode is here.

包含recovery模式的内存盘是在这里。

Shortcut commands every CM dev should know

每个CM设备开发者应该知道的快捷命令

These commands are really useful for developing w/CM. All these commands are meant to be typed from your computer, not the shell on your device (except where indicated).

这些命令对于开发cm真的非常有用。所有这些命令默认是从你的电脑输入的,而不是从你设备上的shell(除非另有说明)。

Commands命令

·         $ . build/envsetup.sh -- Note the ". at the beginning. This will load the environment variables to your shell as well as aliases needed for the rest of these shortcuts.

·         $ . build/envsetup.sh注意开始的点。这会载入环境变量到你的shell,以及剩余的这些需要的快捷方式的别名也会载入。

Helpful Tip有帮助的建议

If you want to know more about what "$ . build/envsetup.sh" does or simply want to know more about the breakfastbrunch and lunch commands, you can head over to the  page

如果你想了解更多的关于$ . build/envsetup.sh命令或者就是想知道更多关于breakfastbrunch,和lunch命令,你可以看看envsetup的帮助网页。

·         croot -- this command will take you to the root of the source code.

·         这个命令会带你到源代码的根目录

·         mm and mm -B -- this is the "make module" command and it is very useful if you are working on a particular module (that is, a section of the code to be built) and don't want to have to rebuild everything just to test it. To use it, cd into the directory that you want to test, then just type mm to build just the module in the working directory. If you want to start the build from scratch, add the -B. This is a good companion with adb sync system below, which you can use to push the newly built files directly to your device for testing without having to reflash everything.

·         mm and mm –B这是建造模块的命令,如果你致力于某一个模块,它会非常有用(就是说代码的一部分要被建造),不想去重新构建一切而且没有必要,只是要测试它。为了达到这个目的,先cd到你想去测试的目录,然后键入mm在工作目录下构建模块。如果你想从头开始构建,加上-B。这些能和下面的adb sync system良好的协作。它能发送最新被构建的文件到你的设备来测试,而不用重新烧录所有的东西。

Make

Make命令

·         make modules -- this command will show all available targets. You can build a single one by make my_target.

·         这个命令会显示所有可获得的目标。你可以构建一个单独的模块用make my_target

·         make showcommands -- this command will enable the verbose build mode.

·         这个命令会启动冗长构建模式。(就是编译器什么废话都输出来,很废话的感觉)

ADB安卓调试桥

See also: 

·         adb shell -- assuming you have  installed, this will give you a command line shell inside your device. See  for more.

·         如果你安装了adb,这会给你一个进入你设备的命令行。

·         adb reboot -- If you've got  installed, this will quickly make your device reboot. Or try adb reboot recovery to reboot directly into recovery. adb reboot bootloader similarly does just what you'd expect.

·         adb remount -- If you've gotten errors trying to push files to /system due to it being in read-only mode, adb remount will remount /system into read-write mode--- provided that the shell has the correct root permissions to do so. This replaces having to type a longer command by hand such as mount -o rw,remount /system (as root) or something.

·         adb sync system -- assuming you have  installed, this little-known, but powerful command will sync the contents of $OUT/system with the /system directory on your device. It does require that you have write access to /system. This command is very useful for making and testing quick changes to your device. Note though that adb sync system sometimes has problems with permissions and symlinks.

·        

 

阅读(1268) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~