Android编译系统(三):官方文档Android Build System

转载 2012年03月28日 17:10:29

本文档位于Android源码树中:build\core\build-system.html

Android Build System

Status: Draft   (as of May 18, 2006)

Contents

Objective

The primary goals of reworking the build system are (1) to make dependencieswork more reliably, so that when files need to rebuilt, they are, and (2) toimprove performance of the build system so that unnecessary modules are notrebuilt, and so doing a top-level build when little or nothing needs to be donefor a build takes as little time as possible.

Principles and Use Cases and Policy

Given the above objective, these are the overall principles and use casesthat we will support. This is not an exhaustive list.

Multiple Targets

It needs to be possible to build the Android platform for multiple targets.This means:

  • The build system will support building tools for the host platform, both ones that are used in the build process itself, and developer tools like the simulator.
  • The build system will need to be able to build tools on Linux (definitely Goobuntu and maybe Grhat), MacOS, and to some degree on Windows.
  • The build system will need to be able to build the OS on Linux, and in the short-term, MacOS. Note that this is a conscious decision to stop building the OS on Windows. We are going to rely on the emulator there and not attempt to use the simulator. This is a requirement change now that the emulator story is looking brighter.

Non-Recursive Make

To achieve the objectives, the build system will be rewritten to use makenon-recursively. For more background on this, read Recursive Make Considered Harmful. For those that don'twant PDF, here is theGoogle translated version.

Rapid Compile-Test Cycles

When developing a component, for example a C++ shared library, it must bepossible to easily rebuild just that component, and not have to wait more than acouple seconds for dependency checks, and not have to wait for unneededcomponents to be built.

Both Environment and Config File Based Settings

To set the target, and other options, some people on the team like to have aconfiguration file in a directory so they do not have an environment setupscript to run, and others want an environment setup script to run so they canrun builds in different terminals on the same tree, or switch back and forthin one terminal. We will support both.

Object File Directory / make clean

Object files and other intermediate files will be generated into a directorythat is separate from the source tree. The goal is to have make clean be"rm -rf " in the tree root directory. The primary goals ofthis are to simplify searching the source tree, and to make "make clean" morereliable.

SDK

The SDK will be a tarball that will allow non-OS-developers to write apps.The apps will actually be built by first building the SDK, and then buildingthe apps against that SDK. This will hopefully (1) make writing apps easierfor us, because we won't have to rebuild the OS as much, and we can use thestandard java-app development tools, and (2) allow us to dog-food the SDK, tohelp ensure its quality. Cedric has suggested (and I agree) that apps builtfrom the SDK should be built with ant. Stay tuned for more details as wefigure out exactly how this will work.

Dependecies

Dependencies should all be automatic. Unless there is a custom tool involved(e.g. the webkit has several), the dependencies for shared and static libraries,.c, .cpp, .h, .java, java libraries, etc., should all work without interventionin the Android.mk file.

Hiding command lines

The default of the build system will be to hide the command lines beingexecuted for make steps. It will be possible to override this by specifyingthe showcommands pseudo-target, and possibly by setting an environmentvariable.

Wildcard source files

Wildcarding source file will be discouraged. It may be useful in somescenarios. The default $(wildcard *) will not work due to thecurrent directory being set to the root of the build tree.

Multiple targets in one directory

It will be possible to generate more than one target from a givensubdirectory. For example, libutils generates a shared library for the targetand a static library for the host.

Makefile fragments for modules

Android.mk is the standard name for the makefile fragments thatcontrol the building of a given module. Only the top directory shouldhave a file named "Makefile".

Use shared libraries

Currently, the simulator is not built to use shared libraries. This shouldbe fixed, and now is a good time to do it. This implies getting sharedlibraries to work on Mac OS.

Nice to Have

These things would be nice to have, and this is a good place to record them,however these are not promises.

Simultaneous Builds

The hope is to be able to do two builds for different combos in the sametree at the same time, but this is a stretch goal, not a requirement.Doing two builds in the same tree, not at the same time must work. (update:it's looking like we'll get the two builds at the same time working)

Deleting headers (or other dependecies)

Problems can arise if you delete a header file that is referenced in".d" files. The easy way to deal with this is "make clean". Thereshould be a better way to handle it. (from fadden)

One way of solving this is introducing a dependency on the directory. Theproblem is that this can create extra dependecies and slow down the build.It's a tradeoff.

Multiple builds

General way to perform builds across the set of known platforms. Thiswould make it easy to perform multiple platform builds when testing achange, and allow a wide-scale "make clean". Right now the buildspec.mkor environment variables need to be updated before each build. (from fadden)

Aftermarket Locales and Carrier

We will eventually need to add support for creating locales and carriercustomizations to the SDK, but that will not be addressed right now.

Usage

You've read (or scrolled past) all of the motivations for this build system,and you want to know how to use it. This is the place.

Your first build

The Building document describes how do dobuilds.

build/envsetup.sh functions

If you source the file build/envsetup.sh into your bash environment,. build/envsetup.shyou'll get a few helpful shell functions:
  • printconfig - Prints the current configuration as set by thelunch and choosecombo commands.
  • m - Runs make from the top of the tree. This isuseful because you can run make from within subdirectories. If you have theTOP environment variable set, it uses that. If you don't, it looksup the tree from the current directory, trying to find the top of the tree.
  • croot - cd to the top of the tree.
  • sgrep - grep for the regex you provide in all .c, .cpp, .h, .java,and .xml files below the current directory.

Build flavors/types

When building for a particular product, it's often useful to have minorvariations on what is ultimately the final release build. These are thecurrently-defined "flavors" or "types" (we need to settle on a real namefor these).

eng This is the default flavor. A plain "make" is the same as "make eng". droid is an alias for eng.
  • Installs modules tagged with: eng, debug, user, and/or development.
  • Installs non-APK modules that have no tags specified.
  • Installs APKs according to the product definition files, in addition to tagged APKs.
  • ro.secure=0
  • ro.debuggable=1
  • ro.kernel.android.checkjni=1
  • adb is enabled by default.
user "make user"

This is the flavor intended to be the final release bits.

  • Installs modules tagged with user.
  • Installs non-APK modules that have no tags specified.
  • Installs APKs according to the product definition files; tags are ignored for APK modules.
  • ro.secure=1
  • ro.debuggable=0
  • adb is disabled by default.
userdebug "make userdebug"

The same as user, except:

  • Also installs modules tagged with debug.
  • ro.debuggable=1
  • adb is enabled by default.

If you build one flavor and then want to build another, you should run"make installclean" between the two makes to guarantee thatyou don't pick up files installed by the previous flavor. "makeclean" will also suffice, but it takes a lot longer.

More pseudotargets

Sometimes you want to just build one thing. The following pseudotargets arethere for your convenience:

  • droid - make droid is the normal build. This targetis here because the default target has to have a name.
  • all - make all builds everything makedroid does, plus everything whose LOCAL_MODULE_TAGS do notinclude the "droid" tag. The build server runs this to make surethat everything that is in the tree and has an Android.mk builds.
  • clean-$(LOCAL_MODULE) and clean-$(LOCAL_PACKAGE_NAME) - Let you selectively clean one target. For example, you can typemake clean-libutils and it will delete libutils.so and all of theintermediate files, or you can type make clean-Home and it willclean just the Home app.
  • clean - make clean deletes all of the output andintermediate files for this configuration. This is the same as rm -rfout/<configuration>/
  • clobber - make clobber deletes all of the outputand intermediate files for all configurations. This is the same asrm -rf out/.
  • dataclean - make dataclean deletes contents of the data directory inside the current combo directory. This is especially useful on thesimulator and emulator, where the persistent data remains present between builds.
  • showcommands - showcommands is a modifier targetwhich causes the build system to show the actual command lines for the buildsteps, instead of the brief descriptions. Most people don't like seeing theactual commands, because they're quite long and hard to read, but if you needto for debugging purposes, you can add showcommands to the listof targets you build. For example make showcommands will buildthe default android configuration, and make runtime showcommandswill build just the runtime, and targets that it depends on, while displayingthe full command lines. Please note that there are a couple places where thecommands aren't shown here. These are considered bugs, and should be fixed,but they're often hard to track down. Please letandroid-build-team know if you findany.
  • LOCAL_MODULE - Anything you specify as a LOCAL_MODULEin an Android.mk is made into a pseudotarget. For example, makeruntime might be shorthand for makeout/linux-x86-debug/system/bin/runtime (which would work), andmake libkjs might be shorthand for makeout/linux-x86-debug/system/lib/libkjs.so (which would also work).
  • targets - make targets will print a list of all ofthe LOCAL_MODULE names you can make.

How to add another component to the build - Android.mk templates

You have a new library, a new app, or a new executable. For each of thecommon types of modules, there is a corresponding file in the templatesdirectory. It will usually be enough to copy one of these, and fill in yourown values. Some of the more esoteric values are not included in thetemplates, but are instead just documented here, as is the documentationon using custom tools to generate files.

Mostly, you can just look for the TODO comments in the templates and dowhat it says. Please remember to delete the TODO comments when you're doneto keep the files clean. The templates have minimal documentation in them,because they're going to be copied, and when that gets stale, the copies justwon't get updated. So read on...

Apps

Use the templates/apps file.

This template is pretty self-explanitory. See the variables below for moredetails.

Java Libraries

Use the templates/java_library file.

The interesting thing here is the value of LOCAL_MODULE, which becomesthe name of the jar file. (Actually right now, we're not making jar files yet,just directories of .class files, but the directory is named according towhat you put in LOCAL_MODULE). This name will be what goes in the LOCAL_JAVA_LIBRARIES variable in modules that depend on your java library.

C/C++ Executables

Use the templates/executable file, or thetemplates/executable_host file.

This template has a couple extra options that you usually don't need.Please delete the ones you don't need, and remove the TODO comments. It makesthe rest of them easier to read, and you can always refer back to the templatesif you need them again later.

By default, on the target these are built into /system/bin, and on thehost, they're built into /host/bin. These can be overridden by settingLOCAL_MODULE_PATH. SeePutting targets elsewherefor more.

Shared Libraries

Use the templates/shared_library file, or thetemplates/shared_library_host file.

Remember that on the target, we use shared libraries, and on the host,we use static libraries, since executable size isn't as big an issue, and itsimplifies distribution in the SDK.

Static Libraries

Use the templates/static_library file, or thetemplates/static_library_host file.

Remember that on the target, we use shared libraries, and on the host,we use static libraries, since executable size isn't as big an issue, and itsimplifies distribution in the SDK.

Using Custom Tools

If you have a tool that generates source files for you, it's possibleto have the build system get the dependencies correct for it. Here area couple of examples. $@ is the make built-in variable for"the current target." The red parts are the parts you'llneed to change.

You need to put this after you have declared LOCAL_PATH andLOCAL_MODULE, because the $(local-intermediates-dir)and $(local-host-intermediates-dir) macros use these variablesto determine where to put the files.

Example 1

Here, there is one generated file, calledchartables.c, which doesn't depend on anything. And is built by the toolbuilt to $(HOST_OUT_EXECUTABLES)/dftables. Note on the second to last linethat a dependency is created on the tool.

intermediates:= $(local-intermediates-dir)
GEN := $(intermediates)/chartables.c
$(GEN): PRIVATE_CUSTOM_TOOL = $(HOST_OUT_EXECUTABLES)/dftables $@
$(GEN): $(HOST_OUT_EXECUTABLES)/dftables
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
Example 2

Here as a hypothetical example, we use use cat as if it were to transforma file. Pretend that it does something useful. Note how we use atarget-specific variable called PRIVATE_INPUT_FILE to store the name of theinput file.

intermediates:= $(local-intermediates-dir)
GEN := $(intermediates)/file.c
$(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/input.file
$(GEN): PRIVATE_CUSTOM_TOOL = cat $(PRIVATE_INPUT_FILE) > $@
$(GEN): $(LOCAL_PATH)/file.c
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
Example 3

If you have several files that are all similar inname, and use the same tool, you can combine them. (here the *.lut.h files arethe generated ones, and the *.cpp files are the input files)

intermediates:= $(local-intermediates-dir)
GEN := $(addprefix $(intermediates)/kjs/, \
            array_object.lut.h \
            bool_object.lut.h \
        )
$(GEN): PRIVATE_CUSTOM_TOOL = perl libs/WebKitLib/WebKit/JavaScriptCore/kjs/create_hash_table $< -i > $@
$(GEN): $(intermediates)/%.lut.h : $(LOCAL_PATH)/%.cpp
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

Platform specific conditionals

Sometimes you need to set flags specifically for different platforms. Hereis a list of which values the different build-system defined variables will beset to and some examples.

For a device build, TARGET_OS is linux (we're usinglinux!), and TARGET_ARCH is arm.

For a simulator build, TARGET_OS and TARGET_ARCHare set to the same as HOST_OS and HOST_ARCH areon your platform. TARGET_PRODUCT is the name of the targethardware/product you are building for. The value sim is usedfor the simulator. We haven't thought through the full extent of customizationthat will happen here, but likely there will be additional UI configurationsspecified here as well.

HOST_OS
linux
darwin
(cygwin)
HOST_ARCH
x86
HOST_BUILD_TYPE
release
debug
TARGET_OS
linux
darwin
(cygwin)
TARGET_ARCH
arm
x86
TARGET_BUILD_TYPE
release
debug
TARGET_PRODUCT
sim
dream
sooner

TARGET_SIMULATOR

If we're building the simulator, as opposed to the arm or emulator builds,TARGET_SIMULATOR will be set to true.

Some Examples

ifeq ($(TARGET_SIMULATOR),true)
LOCAL_CFLAGS += -DSIMULATOR
endif

ifeq ($(TARGET_BUILD_TYPE),release)
LOCAL_CFLAGS += -DNDEBUG=1
endif

# from libutils
ifeq ($(TARGET_OS),linux)
# Use the futex based mutex and condition variable
# implementation from android-arm because it's shared mem safe
LOCAL_SRC_FILES += futex_synchro.c
LOCAL_LDLIBS += -lrt -ldl
endif

Putting modules elsewhere

If you have modules that normally go somewhere, and you need to have thembuild somewhere else, read this. One use of this is putting files onthe root filesystem instead of where they normally go in /system. Add theselines to your Android.mk:

LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)

For executables and libraries, you need to also specify aLOCAL_UNSTRIPPED_PATH location, because on target builds, we keepthe unstripped executables so GDB can find the symbols.

Look in config/envsetup.make for all of the variables definingplaces to build things.

FYI: If you're installing an executable to /sbin, you probably also want toset LOCAL_FORCE_STATIC_EXCUTABLE := true in your Android.mk, whichwill force the linker to only accept static libraries.

Android.mk variables

These are the variables that you'll commonly see in Android.mk files, listedalphabetically.

But first, a note on variable naming:

  • LOCAL_ - These variables are set per-module. They are cleared by the include $(CLEAR_VARS) line, so you can rely on them being empty after including that file. Most of the variables you'll use in most modules are LOCAL_ variables.
  • PRIVATE_ - These variables are make-target-specific variables. That means they're only usable within the commands for that module. It also means that they're unlikely to change behind your back from modules that are included after yours. This link to the make documentation describes more about target-specific variables. Please note that there are a couple of these laying around the tree that aren't prefixed with PRIVATE_. It is safe, and they will be fixed as they are discovered. Sorry for the confusion.
  • INTERNAL_ - These variables are critical to functioning of the build system, so you shouldn't create variables named like this, and you probably shouldn't be messing with these variables in your makefiles.
  • HOST_ and TARGET_ - These contain the directories and definitions that are specific to either the host or the target builds. Do not set variables that start with HOST_ or TARGET_ in your makefiles.
  • BUILD_ and CLEAR_VARS - These contain the names of well-defined template makefiles to include. Some examples are CLEAR_VARS and BUILD_HOST_PACKAGE.
  • Any other name is fair-game for you to use in your Android.mk. However, remember that this is a non-recursive build system, so it is possible that your variable will be changed by another Android.mk included later, and be different when the commands for your rule / module are executed.

LOCAL_ASSET_FILES

In Android.mk files that include $(BUILD_PACKAGE) set thisto the set of files you want built into your app. Usually:

LOCAL_ASSET_FILES += $(call find-subdir-assets)

This will probably change when we switch to ant for the apps' buildsystem.

LOCAL_CC

If you want to use a different C compiler for this module, set LOCAL_CCto the path to the compiler. If LOCAL_CC is blank, the appropriate defaultcompiler is used.

LOCAL_CXX

If you want to use a different C++ compiler for this module, set LOCAL_CXXto the path to the compiler. If LOCAL_CXX is blank, the appropriate defaultcompiler is used.

LOCAL_CFLAGS

If you have additional flags to pass into the C or C++ compiler, addthem here. For example:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1

LOCAL_CPPFLAGS

If you have additional flags to pass into only the C++ compiler, addthem here. For example:

LOCAL_CPPFLAGS += -ffriend-injection

LOCAL_CPPFLAGS is guaranteed to be after LOCAL_CFLAGSon the compile line, so you can use it to override flags listed inLOCAL_CFLAGS.

LOCAL_CPP_EXTENSION

If your C++ files end in something other than ".cpp",you can specify the custom extension here. For example:

LOCAL_CPP_EXTENSION := .cc

Note that all C++ files for a given module must have the sameextension; it is not currently possible to mix different extensions.

LOCAL_NO_DEFAULT_COMPILER_FLAGS

Normally, the compile line for C and C++ files includes global includepaths and global cflags. If LOCAL_NO_DEFAULT_COMPILER_FLAGSis non-empty, none of the default includes or flags will be used when compilingC and C++ files in this module.LOCAL_C_INCLUDES, LOCAL_CFLAGS, andLOCAL_CPPFLAGS will still be used in this case, as willany DEBUG_CFLAGS that are defined for the module.

LOCAL_COPY_HEADERS

This will be going away.

The set of files to copy to the install include tree. You must alsosupply LOCAL_COPY_HEADERS_TO.

This is going away because copying headers messes up the error messages, andmay lead to people editing those headers instead of the correct ones. It alsomakes it easier to do bad layering in the system, which we want to avoid. Wealso aren't doing a C/C++ SDK, so there is no ultimate requirement to copy anyheaders.

LOCAL_COPY_HEADERS_TO

This will be going away.

The directory within "include" to copy the headers listed inLOCAL_COPY_HEADERS to.

This is going away because copying headers messes up the error messages, andmay lead to people editing those headers instead of the correct ones. It alsomakes it easier to do bad layering in the system, which we want to avoid. Wealso aren't doing a C/C++ SDK, so there is no ultimate requirement to copy anyheaders.

LOCAL_C_INCLUDES

Additional directories to instruct the C/C++ compilers to look for headerfiles in. These paths are rooted at the top of the tree. UseLOCAL_PATH if you have subdirectories of your own that youwant in the include paths. For example:

LOCAL_C_INCLUDES += extlibs/zlib-1.2.3
LOCAL_C_INCLUDES += $(LOCAL_PATH)/src

You should not add subdirectories of include toLOCAL_C_INCLUDES, instead you should reference those filesin the #include statement with their subdirectories. Forexample:

#include <utils/KeyedVector.h>
not #include <KeyedVector.h>

There are some components that are doing this wrong, and should be cleanedup.

LOCAL_MODULE_TAGS

Set LOCAL_MODULE_TAGS to any number of whitespace-separatedtags. If the tag list is empty or contains droid, the modulewill get installed as part of a make droid. Otherwise, it willonly get installed by running make <your-module>or with the make all pseudotarget.

LOCAL_REQUIRED_MODULES

Set LOCAL_REQUIRED_MODULES to any number of whitespace-separatedmodule names, like "libblah" or "Email". If this module is installed, allof the modules that it requires will be installed as well. This can beused to, e.g., ensure that necessary shared libraries or providers areinstalled when a given app is installed.

LOCAL_FORCE_STATIC_EXECUTABLE

If your executable should be linked statically, set LOCAL_FORCE_STATIC_EXECUTABLE:=true. There is a very shortlist of libraries that we have in static form (currently only libc). This isreally only used for executables in /sbin on the root filesystem.

LOCAL_GENERATED_SOURCES

Files that you add to LOCAL_GENERATED_SOURCES will beautomatically generated and then linked in when your module is built.See the Custom Tools template makefile for anexample.

LOCAL_JAVACFLAGS

If you have additional flags to pass into the javac compiler, addthem here. For example:

LOCAL_JAVACFLAGS += -Xlint:deprecation

LOCAL_JAVA_LIBRARIES

When linking Java apps and libraries, LOCAL_JAVA_LIBRARIESspecifies which sets of java classes to include. Currently there aretwo of these: core and framework.In most cases, it will look like this:

LOCAL_JAVA_LIBRARIES := core framework

Note that setting LOCAL_JAVA_LIBRARIES is not necessary(and is not allowed) when building an APK with"include $(BUILD_PACKAGE)". The appropriate librarieswill be included automatically.

LOCAL_LDFLAGS

You can pass additional flags to the linker by settingLOCAL_LDFLAGS. Keep in mind that the order of parameters isvery important to ld, so test whatever you do on all platforms.

LOCAL_LDLIBS

LOCAL_LDLIBS allows you to specify additional librariesthat are not part of the build for your executable or library. Specifythe libraries you want in -lxxx format; they're passed directly to the link line. However, keep in mind that there will be no dependency generatedfor these libraries. It's most useful in simulator builds where you wantto use a library preinstalled on the host. The linker (ld) is a particularlyfussy beast, so it's sometimes necessary to pass other flags here if you'redoing something sneaky. Some examples:

LOCAL_LDLIBS += -lcurses -lpthread
LOCAL_LDLIBS += -Wl,-z,origin

LOCAL_NO_MANIFEST

If your package doesn't have a manifest (AndroidManifest.xml), thenset LOCAL_NO_MANIFEST:=true. The common resources packagedoes this.

LOCAL_PACKAGE_NAME

LOCAL_PACKAGE_NAME is the name of an app. For example,Dialer, Contacts, etc. This will probably change or go away when we switchto an ant-based build system for the apps.

LOCAL_PATH

The directory your Android.mk file is in. You can set it by putting thefollowing as the first line in your Android.mk:

LOCAL_PATH := $(my-dir)

The my-dir macro uses the MAKEFILE_LISTvariable, so you must call it before you include any other makefiles. Also,consider that any subdirectories you inlcude might reset LOCAL_PATH, so do yourown stuff before you include them. This also means that if you try to writeseveral include lines that reference LOCAL_PATH,it won't work, because those included makefiles might reset LOCAL_PATH.

LOCAL_POST_PROCESS_COMMAND

For host executables, you can specify a command to run on the moduleafter it's been linked. You might have to go through some contortionsto get variables right because of early or late variable evaluation:

module := $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)
LOCAL_POST_PROCESS_COMMAND := /Developer/Tools/Rez -d __DARWIN__ -t APPL\
       -d __WXMAC__ -o $(module) Carbon.r

LOCAL_PREBUILT_EXECUTABLES

When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these toexecutables that you want copied. They're located automatically into theright bin directory.

LOCAL_PREBUILT_LIBS

When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these tolibraries that you want copied. They're located automatically into theright lib directory.

LOCAL_SHARED_LIBRARIES

These are the libraries you directly link against. You don't need topass transitively included libraries. Specify the name without the suffix:

LOCAL_SHARED_LIBRARIES := \
    libutils \
    libui \
    libaudio \
    libexpat \
    libsgl

LOCAL_SRC_FILES

The build system looks at LOCAL_SRC_FILES to know what sourcefiles to compile -- .cpp .c .y .l .java. For lex and yacc files, it knowshow to correctly do the intermediate .h and .c/.cpp files automatically. Ifthe files are in a subdirectory of the one containing the Android.mk, prefixthem with the directory name:

LOCAL_SRC_FILES := \
    file1.cpp \
    dir/file2.cpp

LOCAL_STATIC_LIBRARIES

These are the static 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 static libraries instead.

LOCAL_STATIC_LIBRARIES := \
    libutils \
    libtinyxml

LOCAL_MODULE

LOCAL_MODULE is the name of what's supposed to be generatedfrom your Android.mk. For exmample, for libkjs, the LOCAL_MODULEis "libkjs" (the build system adds the appropriate suffix -- .so .dylib .dll).For app modules, use LOCAL_PACKAGE_NAME instead of LOCAL_MODULE. We're planning on switching to ant for the apps,so this might become moot.

LOCAL_MODULE_PATH

Instructs the build system to put the module somewhere other than what'snormal for its type. If you override this, make sure you also setLOCAL_UNSTRIPPED_PATH if it's an executable or a shared libraryso the unstripped binary has somewhere to go. An error will occur if you forgetto.

See Putting modules elsewhere for more.

LOCAL_UNSTRIPPED_PATH

Instructs the build system to put the unstripped version of the modulesomewhere other than what's normal for its type. Usually, you override thisbecause you overrode LOCAL_MODULE_PATH for an executable or ashared library. If you overrode LOCAL_MODULE_PATH, but not LOCAL_UNSTRIPPED_PATH, an error will occur.

See Putting modules elsewhere for more.

LOCAL_WHOLE_STATIC_LIBRARIES

These are the static libraries that you want to include in your module without allowingthe linker to remove dead code from them. This is mostly useful if you want to add a static libraryto a shared library and have the static library's content exposed from the shared library.

LOCAL_WHOLE_STATIC_LIBRARIES := \
    libsqlite3_android

LOCAL_YACCFLAGS

Any flags to pass to invocations of yacc for your module. A known limitationhere is that the flags will be the same for all invocations of YACC for yourmodule. This can be fixed. If you ever need it to be, just ask.

LOCAL_YACCFLAGS := -p kjsyy

Implementation Details

You should never have to touch anything in the config directory unlessyou're adding a new platform, new tools, or adding new features to thebuild system. In general, please consult with the build system owner(s)(android-build-team) before you gomucking around in here. That said, here are some notes on what's going onunder the hood.

Environment Setup / buildspec.mk Versioning

In order to make easier for people when the build system changes, whenit is necessary to make changes to buildspec.mk or to rerun the environmentsetup scripts, they contain a version number in the variableBUILD_ENV_SEQUENCE_NUMBER. If this variable does not match what the buildsystem expects, it fails printing an error message explaining what happened.If you make a change that requires an update, you need to update two placesso this message will be printed.

  • In config/envsetup.make, increment the CORRECT_BUILD_ENV_SEQUENCE_NUMBER definition.
  • In buildspec.mk.default, update the BUILD_ENV_SEQUENCE_DUMBER definition to match the one in config/envsetup.make
The scripts automatically get the value from the build system, so they willtrigger the warning as well.

Additional makefile variables

You probably shouldn't use these variables. Please consultandroid-build-team before using them.These are mostly there for workarounds for other issues, or things that aren'tcompletely done right.

LOCAL_ADDITIONAL_DEPENDENCIES

If your module needs to depend on anything else thatisn't actually built in to it, you can add those make targets to LOCAL_ADDITIONAL_DEPENDENCIES. Usually this is a workaroundfor some other dependency that isn't created automatically.

LOCAL_BUILT_MODULE

When a module is built, the module is created in an intermediatedirectory then copied to its final location. LOCAL_BUILT_MODULE isthe full path to the intermediate file. See LOCAL_INSTALLED_MODULEfor the path to the final installed location of the module.

LOCAL_HOST

Set by the host_xxx.make includes to tell base_rules.make and the otherincludes that we're building for the host. Kenneth did this as part ofopenbinder, and I would like to clean it up so the rules, includes anddefinitions aren't duplicated for host and target.

LOCAL_INSTALLED_MODULE

The fully qualified path name of the final location of the module.See LOCAL_BUILT_MODULE for the location of the intermediate file thatthe make rules should actually be constructing.

LOCAL_REPLACE_VARS

Used in some stuff remaining from the openbinder for building scriptswith particular values set,

LOCAL_SCRIPTS

Used in some stuff remaining from the openbinder build system that wemight find handy some day.

LOCAL_MODULE_CLASS

Which kind of module this is. This variable is used to construct othervariable names used to locate the modules. See base_rules.make andenvsetup.make.

LOCAL_MODULE_NAME

Set to the leaf name of the LOCAL_BUILT_MODULE. I'm not sure,but it looks like it's just used in the WHO_AM_I variable to identifyin the pretty printing what's being built.

LOCAL_MODULE_SUFFIX

The suffix that will be appended to LOCAL_MODULE to formLOCAL_MODULE_NAME. For example, .so, .a, .dylib.

LOCAL_STRIP_MODULE

Calculated in base_rules.make to determine if this module should actuallybe stripped or not, based on whether LOCAL_STRIPPABLE_MODULEis set, and whether the combo is configured to ever strip modules. WithIliyan's stripping tool, this might change.

LOCAL_STRIPPABLE_MODULE

Set by the include makefiles if that type of module is strippable. Executables and shared libraries are.

LOCAL_SYSTEM_SHARED_LIBRARIES

Used while building the base libraries: libc, libm, libdl. Usuallyit should be set to "none," as it is in $(CLEAR_VARS). When buildingthese libraries, it's set to the ones they link against. For example,libc, libstdc++ and libdl don't link against anything, and libm links againstlibc. Normally, when the value is none, these libraries are automaticallylinked in to executables and libraries, so you don't need to specify themmanually.


举报

相关文章推荐

Android平台开发 -Android build system-编译系统分析

本文转自:http://blog.sina.com.cn/s/blog_569a151b0100nmym.html 一、预习Makefile二、Android编译系统的层次三、Android编译系统的...

谷歌安卓官方文档之编译系统

下面的说明来构建Android源代码树适用于所有 分支机构,包括master。 基本的构建命令序列 如下: 注意:如果你正在构建Android 6.0或更高版本, 请参阅编译与杰克在这个信息 新的...

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

android官方文档:ubuntu10.04下编译android源码Building the System

在编译前请先看 http://blog.csdn.net/wufenglong/archive/2011/05/11/6411688.aspx 初始化编译环境 Initiali...

android编译系统分析一:source build/envsetup.sh与lunch

虽然已经有很多人分析过android的编译系统的代码了,我也看过他们的博客,也学到了不少知识,但单纯的看别人分析,终究还是理解的不深入,所以,我还是要自己再认真的分析一遍。 1. source bui...

Android编译系统详解(一)——build/envsetup.sh

准备好编译环境后,编译Rom的第一步是 source build/envsetup.sh,该步骤把envsetup.sh里的函数声明为当前会话终端可用的命令。这些命令能让我们切换目录,提交代码,编译R...

Android编译系统详解(一)——build/envsetup.sh

Android编译系统详解(一)——build/envsetup.sh http://www.cloudchou.com/android/post-134.html 准...

最值得看的android系统fragment教程--翻译自安卓官方文档

注意:如果你是用的是V4包中的API.你需要 1.Activity必须继承FragmentActivity 2.使用getSupportFragmentManager()而不是getFragmentM...

Android 5.x OTA Update官方文档(五、Recovery系统下分区映射)

Recovery系统包含了很多钩子程序,因此OAT更新除了可以更新Android系统也可以更新设备的其他部分。(如基带、无线电处理器)。 分区映射    从Android2.3起,平台开始...

Android编译系统分析五:system.img的生成过程

我们在完整编译android系统的时候,最终会生成几个重要的镜像文件,其中有system.img,userdata.img,ramdisk.img等。这篇文章的目的是分析system.img的生成过程...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)