Build Cookbook
这里提供了一些代码,帮助你实现一些普通的编译任务。一、编译一个简单的APK LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # Build all java files in the java subdirectory LOCAL_SRC_FILES := $(call all-subdir-java-files) # Name of the APK to build LOCAL_PACKAGE_NAME := LocalPackage # Tell it to build an APK include $(BUILD_PACKAGE) 二、编译一个依赖某个.jar文件的APK LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # List of static libraries to include in the package LOCAL_STATIC_JAVA_LIBRARIES := static-library # Build all java files in the java subdirectory LOCAL_SRC_FILES := $(call all-subdir-java-files) # Name of the APK to build LOCAL_PACKAGE_NAME := LocalPackage # Tell it to build an APK include $(BUILD_PACKAGE) 三、编译一个用platform key签过名的APK LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # Build all java files in the java subdirectory LOCAL_SRC_FILES := $(call all-subdir-java-files) # Name of the APK to build LOCAL_PACKAGE_NAME := LocalPackage LOCAL_CERTIFICATE := platform # Tell it to build an APK include $(BUILD_PACKAGE) 四、编译一个用vendor key签名的APK LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # Build all java files in the java subdirectory LOCAL_SRC_FILES := $(call all-subdir-java-files) # Name of the APK to build LOCAL_PACKAGE_NAME := LocalPackage LOCAL_CERTIFICATE := vendor/example/certs/app # Tell it to build an APK include $(BUILD_PACKAGE)五、添加一个prebuilt APK LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # Module name should match apk name to be installed. LOCAL_MODULE := LocalModuleName LOCAL_SRC_FILES := $(LOCAL_MODULE).apk LOCAL_MODULE_CLASS := APPS LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) include $(BUILD_PREBUILT) 六、添加一个静态java库 LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # Build all java files in the java subdirectory LOCAL_SRC_FILES := $(call all-subdir-java-files) # Any libraries that this library depends on LOCAL_JAVA_LIBRARIES := android.test.runner # The name of the jar file to create LOCAL_MODULE := sample # Build a static jar file. include $(BUILD_STATIC_JAVA_LIBRARY) 七、Android.mk中的变量 下面列出了一些你在Android.mk文件中常见的变量,先看一下名字前缀: 1、LOCAL_:这类变量每个模块都要设置自己,用include $(CLEAR_VARS)可以清除这类变量,这类变量也是使用最多的。 2、PRIVATE_:这类变量是make-target-specific的变量。只有在编译某个模块时才会用到这类变量。在你从子模块返回时,这类变量不会改变。这个可以对我一下标准的make教程。 3、HOST_和TARGET_:这里包含了一些针对特定的host或target的目录和定义。不要在make文件中设置这类变量。 4、BUILD_和CLEAR_VARS:这类变量通常是一些预定义过的模板make文件的名字。比如CLEAR_VARS和BUILD_HOST_PACKAGE,通常执行某个具体功能。 5、编译系统不可以递归调用,因为所有的变量都是全局的。
Parameter |
Description |
---|---|
LOCAL_AAPT_FLAGS |
|
LOCAL_ACP_UNAVAILABLE |
|
LOCAL_ADDITIONAL_JAVA_DIR |
|
LOCAL_AIDL_INCLUDES |
|
LOCAL_ALLOW_UNDEFINED_SYMBOLS |
|
LOCAL_ARM_MODE |
|
LOCAL_ASFLAGS |
|
LOCAL_ASSET_DIR |
|
LOCAL_ASSET_FILES |
In Android.mkfiles that
|
LOCAL_BUILT_MODULE_STEM |
|
LOCAL_C_INCLUDES |
Additionaldirectories to instruct the C/C++ compilers to look for headerfiles in. These paths are rooted at the top of the tree.Use 如果想C/C++编译器在更多的目录中搜索头文件的话,把这些附加的目录包含在这个属性中。如果这些目录中还有子目录的话,使用 For example:
You should notadd subdirectories of include to 不要把子目录添加到这个属性中去,应该使用 For example:
|
LOCAL_CC |
If you want touse a different C compiler for this module, set LOCAL_CC to thepath to the compiler. If LOCAL_CC is blank, the appropriatedefault compiler is used. 如果你想为当前模块使用一个不同的C编译器,就在这个属性中设置好路径 |
LOCAL_CERTIFICATE |
|
LOCAL_CFLAGS |
If you haveadditional flags to pass into the C or C++ compiler, add themhere. 如果有一些标识需要传递给编译器的话,放在这个属性中。 For example:
|
LOCAL_CLASSPATH |
|
LOCAL_COMPRESS_MODULE_SYMBOLS |
|
LOCAL_COPY_HEADERS |
The set of filesto copy to the install include tree. You must alsosupply This is goingaway because copying headers messes up the error messages, and maylead to people editing those headers instead of the correct ones.It also makes it easier to do bad layering in the system, which wewant to avoid. We also aren't doing a C/C++ SDK, so there is noultimate requirement to copy any headers. 由于这个属性常常引起一些问题,以后会被删除。 |
LOCAL_COPY_HEADERS_TO |
The directorywithin "include" to copy the headers listedin This is goingaway because copying headers messes up the error messages, and maylead to people editing those headers instead of the correct ones.It also makes it easier to do bad layering in the system, which wewant to avoid. We also aren't doing a C/C++ SDK, so there is noultimate requirement to copy any headers. |
LOCAL_CPP_EXTENSION |
If your C++ filesend in something other than " 如果你的C++文件扩展名不是“ For example:
Note that all C++files for a given module must have the same extension; it is notcurrently possible to mix different extensions. 注意,一个模块中,所有的C++文件必须有相同的扩展名。 |
LOCAL_CPPFLAGS |
If you haveadditional flags to pass into only the C++compiler, add them here. 你如果只想传递一些标志给C++编译器,写在这里。 For example:
|
LOCAL_CXX |
If you want touse a different C++ compiler for this module, set LOCAL_CXX to thepath to the compiler. If LOCAL_CXX is blank, the appropriatedefault compiler is used. 如果想为当前模块使用一个不同的C++编译器,把编译器的路径写在这里 |
LOCAL_DX_FLAGS |
|
LOCAL_EXPORT_PACKAGE_RESOURCES |
|
LOCAL_FORCE_STATIC_EXECUTABLE |
If yourexecutable should be linked statically,set 如果你的可执行文件需要静态链接的话,就把这个变量设置为true。只有很少的库需要静态链接,目前只是libc库。事实上,这种形式只用于/sbin目录下的可执行文件。 |
LOCAL_GENERATED_SOURCES |
Files that youadd to 添加到这个属性中的文件会在编译模块时自动生成并链接,可以看一下例子子。 |
LOCAL_INSTRUMENTATION_FOR |
|
LOCAL_INSTRUMENTATION_FOR_PACKAGE_NAME |
|
LOCAL_INTERMEDIATE_SOURCES |
|
LOCAL_INTERMEDIATE_TARGETS |
|
LOCAL_IS_HOST_MODULE |
|
LOCAL_JAR_MANIFEST |
|
LOCAL_JARJAR_RULES |
|
LOCAL_JAVA_LIBRARIES |
When linking Javaapps and libraries,
Note thatsetting 链接Java程序和Java库时,这个属性会标识出哪个Java库会被包含。当前只有两个, |
LOCAL_JAVA_RESOURCE_DIRS |
|
LOCAL_JAVA_RESOURCE_FILES |
|
LOCAL_JNI_SHARED_LIBRARIES |
|
LOCAL_LDFLAGS |
You can passadditional flags to the linker by setting 通过这个属性,你可以向链接器传递一些会加的标识。一定要注意,参数的顺序对ld来说非常重要,多多测试。 |
LOCAL_LDLIBS |
不管是编译可执行文件还是编译库,这个属性允许你添加一些附加库。需要注意的是,编译系统不会生成这些库的依赖关系。通常,这个属性会在编译模拟器时使用,你可能会使用一个已经安装在host上的库。 Some examples:
|
LOCAL_MODULE |
for libkjs,the 这个属性存放你要生成的模块名字。如果是app模块,使用 |
LOCAL_MODULE_PATH |
Instructs thebuild system to put the module somewhere other than what's normalfor its type. If you override this, make sure you alsoset 用新路径替换掉编译系统生成模块的默认存放路径。如果编译目标是一个可执行文件或者一个共享库,还必须设置 See Puttingmodules elsewhere for more. |
LOCAL_MODULE_STEM |
|
LOCAL_MODULE_TAGS |
Set This variablecontrols what build flavors the package gets included in. 该属性的多个值之间以空格分隔。 For example:
|
LOCAL_NO_DEFAULT_COMPILER_FLAGS |
|
LOCAL_NO_EMMA_COMPILE |
|
LOCAL_NO_EMMA_INSTRUMENT |
|
LOCAL_NO_STANDARD_LIBRARIES |
|
LOCAL_OVERRIDES_PACKAGES |
|
LOCAL_PACKAGE_NAME |
属性值是要生成的app的名字。 |
LOCAL_POST_PROCESS_COMMAND |
For hostexecutables, you can specify a command to run on the module afterit's been linked. You might have to go through some contortions toget variables right because of early or late variable evaluation:
|
LOCAL_PREBUILT_EXECUTABLES |
When including$(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these toexecutables that you want copied. They're located automaticallyinto the right bin directory. 使用$(BUILD_PREBUILT)或$(BUILD_HOST_PREBUILT)时,这个属性设置为你想复制的可执行文件列表,它们会被自动定位。 |
LOCAL_PREBUILT_JAVA_LIBRARIES |
|
LOCAL_PREBUILT_LIBS |
When including$(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these tolibraries that you want copied. They're located automatically intothe right lib directory. 使用$(BUILD_PREBUILT)或$(BUILD_HOST_PREBUILT)时,这个属性设置为你想复制的库文件列表,它们会被自动定位。 |
LOCAL_PREBUILT_OBJ_FILES |
|
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES |
|
LOCAL_PRELINK_MODULE |
|
LOCAL_REQUIRED_MODULES |
Set 属性值是有空格分隔的一系列模块名字,如“libblah”或“Email”。如果当前编译的模块被安装,这个列表中所有的模块也会被安装。假如你需要安装一个app时,这种机制可以保证app依赖的共享库或者provider被安装。 |
LOCAL_RESOURCE_DIR |
|
LOCAL_SDK_VERSION |
|
LOCAL_SHARED_LIBRARIES |
These are thelibraries you directly link against. 编译时需要链接的库的列表。 You don't need topass transitively included libraries. Specify the name without thesuffix:
|
LOCAL_SRC_FILES |
The build systemlooks at 需要编译的文件列表,如果某些文件在一个子目录中,而且这个子目录中也包含一个Android.mk,就像下面这样使用。
|
LOCAL_STATIC_JAVA_LIBRARIES |
|
LOCAL_STATIC_LIBRARIES |
These are thestatic libraries that you want to include in your module. Mostly,we use shared libraries, but there are a couple of places, likeexecutables in sbin and host executables where we use staticlibraries instead. 编译模块时需要链接的静态库列表。大部分情况下,我们使用共享库,但链接sbin中的可执行文件和host上的可执行文件时,会使用静态库。
|
LOCAL_UNINSTALLABLE_MODULE |
|
LOCAL_UNSTRIPPED_PATH |
Instructs thebuild system to put the unstripped version of the module somewhereother than what's normal for its type. Usually, you override thisbecause you overrode 告诉编译系统把模块的unstripped版本放在某个地方。通常,你给 See Puttingmodules elsewhere for more. |
LOCAL_WHOLE_STATIC_LIBRARIES |
These are thestatic libraries that you want to include in your module withoutallowing the linker to remove dead code from them. This is mostlyuseful if you want to add a static library to a shared library andhave the static library's content exposed from the shared library. 想把静态库包含在模块中,又不想链接器移除无用的代码时,使用这个属性。通常用于你想把一个静态库添加到共享库中,或者让静态库从共享库中暴露出来时。
|
LOCAL_YACCFLAGS |
Any flags to passto invocations of yacc for your module. A known limitation here isthat the flags will be the same for all invocations of YACC foryour module. This can be fixed. If you ever need it to be, justask. 调用yacc时传递的标记。注意,当前模块中所有的yacc调用都会传递这个标记。
|
OVERRIDE_BUILT_MODULE_PATH |
Build Cookbook相关推荐
- Maven2 的常用命令
http://bakcom.iteye.com/blog/280604 Maven2 的运行命令为 : mvn , usage: mvn [options] [<goal(s)>] [&l ...
- kernel下载,编译
http://www.byywee.com/page/M0/S661/661050.html 信赖很多下载过内核的人都对这个很熟悉 git clone git://android.git.kernel ...
- 【Flutter】Flutter 页面生命周期 ( 初始化期 | createState | initState | 更新期 | build | 销毁期 | dispose)
文章目录 一.Flutter 页面生命周期 1.StatelessWidget 组件生命周期函数 2.StatefulWidget 组件生命周期函数 二.StatefulWidget 组件生命周期 1 ...
- wxpython2.8_wxPython 2.8 Application Development Cookbook英文pdf版
内容介绍热点排行相关文章下载地址↓ 在今天的桌面应用世界上有大量的奖励,以便能够开发应用程序,可以运行在多个环境.目前,有一种跨平台框架可供选择的Python开发桌面应用程序屈指可数. wxPytho ...
- Flex入门的好书——《Flex3 Cookbook 中文版》
本文标题:Flex入门的好书--<Flex3 Cookbook 中文版> 本文链接:http://zengrong.net/post/659.htm Flex3 Cookbook 中文 ...
- python cookbook 豆瓣_学习python求推荐一波书籍?
豆瓣最受好评的20本Python书 No.1 Fluent Python(豆瓣评分:9.6)Many programmers who learn Python basics fall into the ...
- 《iOS5 programming cookbook》学习笔记1
<iOS5 programming cookbook>学习笔记 看到这个同学的这篇文章,把它下了下来,粗粗一看觉得不错,正好进阶一下.我也写个笔记,每章一篇. 这位同学真好学啊,有新东西学 ...
- Facebook Cookbook: Building Applications to Grow Your Facebook Empire
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版.作者信息和本声明.否则将追究法律责任. http://blog.csdn.net/topmvp - topmvp Want to ...
- CMake Cookbook精要
CMake允许您描述如何在所有主要硬件和操作系统上配置.构建和安装项目,无论是构建可执行文件.库还是两者. CTest允许您定义测试.测试套件,并设置它们的执行方式. CPack为您的所有打包需求提供 ...
最新文章
- 高效“炼丹”必备技能:一文实现深度学习数学原理入门,还有吴恩达老师亲授课程...
- 「它将改变一切」,AI「诺奖级」里程碑!DeepMind 破解蛋白质分子折叠问题
- 中国有替代w ndows的产品吗,电信将引入多款Wndows Phone手机 打造年轻品牌“飞Young”...
- 深度拷贝 java_Java深度拷贝方式和性能对比
- 百练OJ:1017:装箱问题
- 【非凡程序员】 OC第一节课 (指针浅析)
- lucene.NET详细使用与优化详解
- DipperRiver.Net通信协议设计
- HTML在线颜色代码选取器源码
- python gc清理无用变量与内存
- 清北学堂2019.5.3
- tomcat配置mysql数据源_Tomcat中配置mysql数据源
- Lua笔记4 闭包、迭代器
- 确认!字节跳动 AI Lab 负责人马维英离职,将赴清华加入张亚勤团队
- ram_flash驱动
- 矩阵求导法则与性质,机器学习必备~
- 易优EyouCMS全套插件使用说明
- 【游戏】蔚蓝与空洞骑士
- 迅为6818/4418开发板Yocto开发指南
- 高并发如何处理,解决方案