摘自: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
Spatiotemporal ConvolutionsSpatiotemporal ConvolutionsSpatiotemporal ConvolutionsSpatiotemporal ConvolutionsSpatiotemporal ConvolutionsSpatiotemporal ConvolutionsSpatiotemporal ...
[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动作识别时空卷积的进一步研究
With each project, you'll be one step closer to building full-featured, responsive, and well designed apps that feel like they’re a part of the operating system. Windows 8 App Projects - XAML and ...
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 ...
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 ...
有些边缘的资料 不过英文版对学习计算机的朋友已经很习惯了 这些可以作为初学者入门材料 很清晰
To round the topic off I’ll show you a few available unit testing frameworks for JavaScript, discuss their pros and cons, and take a closer look at the one we’ll be using the most throughout the ...
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!
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 ...
恶意软件查杀助理 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 ...