摘自:http://www.androidenea.com/2009/04/closer-look-at-android-project-build_27.html
This is the second post on the build system where we will take a closer look at the Android.mk file and what options are available. An Android.mk file describes the build for any native module that should go in the platform. We will start by looking at the makefile for the external ping facility found inexternal/ping
.
ifneq ($(TARGET_SIMULATOR),true) LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= ping.c LOCAL_MODULE := ping LOCAL_STATIC_LIBRARIES := libcutils libc include $(BUILD_EXECUTABLE) endif # TARGET_SIMULATOR != true
The first line is just a check if we are building for the (obsolete?) simulator. The next line sets the local path to the current directory (the directory of this Android.mk file). This is handled by a function called mydir that can be found in the definitions.mk file in the build system.
The next step is to include a makefile that will clear all local variables with the lineinclude $(CLEAR_VARS)
. CLEAR_VARS is set in the build configuration inconfig.mk
and will include theclear_vars.mk
file at this point. The main purpose of this include is to make sure that we do not use any local variables set by another module.
After the two initial lines that basically prepares the build system to start with this module we set the build variables. These are
LOCAL_SRC_FILES - the source files that make up this module LOCAL_MODULE - the name of the module LOCAL_STATIC_LIBRARIES - libraries to statically link to this module
Since ping will be an executable command placed in /system/bin in the Android file system the make file for building an executable should be used. This done with the line:
include $(BUILD_EXECUTABLE)
There are makefiles available in the build system that can be used to build a number of different types of module. To include them you may use one of the variables set in theconfig.mk
file. A few important ones are:
BUILD_EXECUTABLE - Build an executable module BUILD_SHARED_LIBRARY - Build a shared library BUILD_STATIC_LIBRARY - Build a static library BUILD_PREBUILT - Add prebuilt components
There is also a number of local variables that are recognized by the build system and that needs to be set in order to build your module.
LOCAL_C_INCLUDES - path to include files needed by your module, e.g. ($KERNEL_HEADERS) LOCAL_CFLAGS - Any additional flags to pass to the compiler LOCAL_LDFLAGS - Any additional flags to pass to the linker LOCAL_SHARED_LIBRARIES - Shared libraries that the module directly links against LOCAL_SRC_FILES - The source files to compile LOCAL_STATIC_LIBRARIES - Static libraries to include in the module
You may use oneAndroid.mk
to build several items. It is possible to build both a library and an executable using the same makefile. To illustrate how to write a makefile for some native functionality we will look at another example. This makefile will build a shared library and an executable. It links to a couple of shared libraries in the system.
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) #Name of target to build LOCAL_MODULE:= libmylibrary #Source files to compile LOCAL_SRC_FILES:= mysrcfile.c mysothersrcfile.c #The shared libraries to link against LOCAL_SHARED_LIBRARIES := libcutils #No special headers needed LOCAL_C_INCLUDES += #Prelink this library, also need to add it to the prelink map LOCAL_PRELINK_MODULE := true include $(BUILD_SHARED_LIBRARY) #Clear variables and build the executable include $(CLEAR_VARS) LOCAL_MODULE:= myinfocmd LOCAL_SRC_FILES:= mycmdsrcfile.c include $(BUILD_EXECUTABLE)
The output of the build system is put in the out folder in the Android project. Build output is directed to a subfolder based on the product. A default build is for the generic product and will output everything target related to that folder. A shared library ends up in/out/target/product/generic/system/lib
. In the same way an executable will end up in/out/target/product/generic/system/bin
. The object files and intermediates are kept in the obj folder. The root, system, and data folders will be used to generate the file system images needed for Android in the last build step.
相关推荐
Your State is Not Mine A Closer Look at Evading Stateful Internet Censorship
### 深度解析时空卷积在动作识别中的应用 #### 摘要与引言概览 本文探讨了多种形式的时空卷积在视频分析中的应用,并研究了它们对动作识别的影响。作者的主要动机来源于观察到:在动作识别领域,应用于单个视频帧...
[1] This paper will provide such a project model and is donated to the FreeBSD Documentation project where it can evolve together with the project so that it can at any point in time reflect the way ...
标题中的"【CVPR2018】A Closer Look at Spatiotemporal Convolutions for Action Recognition"指的是在2018年的计算机视觉与模式识别大会(CVPR)上发表的一篇研究论文,该论文主要探讨了针对动作识别的时空卷积...
A comparison of the PIAT and WRAT: A closer look A COMPARISON OF THE PIAT AND WRAT: A CLOSER LOOK’ JOHN WALDEN, JR. BriuonliU Central S c h k , Troy, NY A sam le of 46 white fourth-grade ...
Before that, have a closer look at the preceding code and hypertext syntax. The link text is enclosed between the "$" symbols and the corresponding dialog's resource value 100 (About Box), enclosed ...
计算机专业英语是编程和IT领域中的重要组成部分,尤其对于那些希望深入学习国际最新技术或阅读英文原版文档的初学者而言。这份“计算机专业英语”PDF教程为学习者提供了宝贵的资源,帮助他们提升专业词汇和阅读理解...
A Closer Look at Android Activities Chapter 4: Understanding Fragments Fundamental Android UI Design Android User Interface Fundamentals Introducing Layouts To-Do List Example Introducing Fragments ...
suite, and you’ll get a close look at how the protocols of TCP/IP build the foundation for the rich ecosystem of tools and services we know as the Internet. The fifth edition includes new material on...
Project Management is a fast-growing and increasingly 'professionalised' discipline with record numbers of practitioners now gaining the PRINCE qualification. The formal tools and techniques of ...
Thus the short feedback loop becomes a business feedback loop—Scrum tests early and often whether the system being developed will deliver value and exactly what that value will look like. This ...
Are you facing some, or all, of ... Come to this session to get a look into the Cisco SD-Access architecture, including a closer look at each of the technologies that brings this architecture to life!
恶意软件查杀助理 11.05 简体绿软版_查杀超过460多款恶意 更多精彩,欢迎来我的论坛逛逛! 快乐论坛630 http://hanranran.5d6d.com/bbs.php 快乐网赚论坛 http://wangzhuan630.5d6d.com/bbs.php ...
Chapter 3 Red State Blues: Averages and Aggregates—A Closer Look at Summary Statistics Chapter 4 Are You Smarter Than an iPhone-Using, Radiohead-Loving Republican?: Understanding Correlation Versus ...
In this book, you will learn about the nitty-gritty of automated trading and have a closer look at Java, the Spring Framework, event-driven programming, and other open source APIs, notably Google's ...