Build Cookbook

whatnamecaniuse發表於2014-10-22

http://blog.csdn.net/a345017062/article/details/6096795


<span style="font-family: 'DejaVu Sans', monospace;">這裡提供了一些程式碼,幫助你實現一些普通的編譯任務。</span>

<span style="font-family: 'DejaVu Sans', monospace;">一、編譯一個簡單的</span>APK
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_PATH := $(call my-dir)</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(CLEAR_VARS)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Build all java files in the java subdirectory</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_SRC_FILES := $(call all-subdir-java-files)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Name of the APK to build</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_PACKAGE_NAME := LocalPackage</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Tell it to build an APK</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(BUILD_PACKAGE)</span></span>
<span style="font-family: 'DejaVu Sans', monospace;">二、編譯一個依賴某個</span>.jar<span style="font-family: 'DejaVu Sans', monospace;">檔案的</span>APK
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_PATH := $(call my-dir)</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(CLEAR_VARS)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># List of static libraries to include in the package</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_STATIC_JAVA_LIBRARIES := static-library</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Build all java files in the java subdirectory</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_SRC_FILES := $(call all-subdir-java-files)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Name of the APK to build</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_PACKAGE_NAME := LocalPackage</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Tell it to build an APK</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(BUILD_PACKAGE)</span></span>
<span style="font-family: 'DejaVu Sans', monospace;">三、編譯一個用</span>platform key<span style="font-family: 'DejaVu Sans', monospace;">簽過名的</span>APK
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_PATH := $(call my-dir)</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(CLEAR_VARS)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Build all java files in the java subdirectory</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_SRC_FILES := $(call all-subdir-java-files)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Name of the APK to build</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_PACKAGE_NAME := LocalPackage</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_CERTIFICATE := platform</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Tell it to build an APK</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(BUILD_PACKAGE)</span></span>
<span style="font-family: 'DejaVu Sans', monospace;">四、編譯一個用</span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">vendor key</span></span><span style="font-family: 'DejaVu Sans', monospace;">簽名的</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">APK</span></span></span>
<span style="color: rgb(0, 112, 0);"><span style="color: rgb(34, 34, 34);">  </span><span style="color: rgb(34, 34, 34);"><span style="font-size:10px;">LOCAL_PATH := $(call my-dir)</span></span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(CLEAR_VARS)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Build all java files in the java subdirectory</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_SRC_FILES := $(call all-subdir-java-files)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Name of the APK to build</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_PACKAGE_NAME := LocalPackage</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_CERTIFICATE := vendor/example/certs/app</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Tell it to build an APK</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(BUILD_PACKAGE)</span></span>

<span style="color: rgb(34, 34, 34);"><span style="font-family: 'DejaVu Sans', monospace;">五、新增一個</span><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">prebuilt APK</span></span></span>
<span style="color: rgb(0, 112, 0);"><span style="color: rgb(34, 34, 34);">  </span><span style="color: rgb(34, 34, 34);"><span style="font-size:10px;">LOCAL_PATH := $(call my-dir)</span></span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(CLEAR_VARS)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Module name should match apk name to be installed.</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_MODULE := LocalModuleName</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_SRC_FILES := $(LOCAL_MODULE).apk</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_MODULE_CLASS := APPS</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(BUILD_PREBUILT)</span></span>
<span style="font-family: 'DejaVu Sans', monospace;"><span style="color: rgb(34, 34, 34);">六</span><span style="color: rgb(34, 34, 34);">、新增一個靜態</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">java</span></span><span style="font-family: 'DejaVu Sans', monospace;">庫</span></span>
<span style="color: rgb(0, 112, 0);"><span style="color: rgb(34, 34, 34);">  </span><span style="color: rgb(34, 34, 34);"><span style="font-size:10px;">LOCAL_PATH := $(call my-dir)</span></span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(CLEAR_VARS)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Build all java files in the java subdirectory</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_SRC_FILES := $(call all-subdir-java-files)</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Any libraries that this library depends on</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_JAVA_LIBRARIES := android.test.runner</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># The name of the jar file to create</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">LOCAL_MODULE := sample</span></span>
<span style="color: rgb(0, 112, 0);">   </span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;"># Build a static jar file.</span></span>
<span style="color: rgb(0, 112, 0);">  <span style="font-size:10px;">include $(BUILD_STATIC_JAVA_LIBRARY)</span></span>
<span style="font-family: 'DejaVu Sans', monospace;"><span style="color: rgb(34, 34, 34);">七</span><span style="color: rgb(34, 34, 34);">、</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">Android.mk</span></span><span style="font-family: 'DejaVu Sans', monospace;">中的變數</span></span>
<span style="font-family: 'DejaVu Sans', monospace;"><span style="color: rgb(34, 34, 34);">下面列出了一些你在</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">Android.mk</span></span><span style="font-family: 'DejaVu Sans', monospace;">檔案中常見的變數,先看一下名字字首:</span></span>
<span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">1</span></span><span style="font-family: 'DejaVu Sans', monospace;">、</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">LOCAL_</span></span><span style="font-family: 'DejaVu Sans', monospace;">:這類變數每個模組都要設定自己,用</span></span><span style="color: rgb(0, 112, 0);"><span style="font-size:10px;">include $(CLEAR_VARS)</span></span><span style="font-family: 'DejaVu Sans', monospace;"><span style="color: rgb(34, 34, 34);">可以清除這類變數</span><span style="color: rgb(34, 34, 34);">,這類變數也是使用最多的。</span></span>
<span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">2</span></span><span style="font-family: 'DejaVu Sans', monospace;">、</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">PRIVATE_</span></span><span style="font-family: 'DejaVu Sans', monospace;">:這類變數是</span></span><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">make-target-specific</span></span><span style="font-family: 'DejaVu Sans', monospace;"><span style="color: rgb(34, 34, 34);">的變數。只有在編譯某個模組時才會用到這類變數。在你從子模組返回時,這類變數不會改變。這個可以對我一下標準的</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">make</span></span><span style="font-family: 'DejaVu Sans', monospace;">教程。</span></span>
<span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">3</span></span><span style="font-family: 'DejaVu Sans', monospace;">、</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">HOST_</span></span><span style="font-family: 'DejaVu Sans', monospace;">和</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">TARGET_</span></span></span><span style="font-family: 'DejaVu Sans', monospace;"><span style="color: rgb(34, 34, 34);">:這裡包含了一些針對特定的</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">host</span></span><span style="font-family: 'DejaVu Sans', monospace;">或</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">target</span></span><span style="font-family: 'DejaVu Sans', monospace;">的目錄和定義</span>。不要在</span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">make</span></span><span style="font-family: 'DejaVu Sans', monospace;">檔案中設定這類變數。</span></span>
<span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">4</span></span><span style="font-family: 'DejaVu Sans', monospace;">、</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">BUILD_</span></span><span style="font-family: 'DejaVu Sans', monospace;">和</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">CLEAR_VARS</span></span><span style="font-family: 'DejaVu Sans', monospace;">:這類變數通常是一些預定義過的模板</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">make</span></span><span style="font-family: 'DejaVu Sans', monospace;">檔案的名字。比如</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">CLEAR_VARS</span></span><span style="font-family: 'DejaVu Sans', monospace;">和</span></span><span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">BUILD_HOST_PACKAGE</span></span><span style="font-family: 'DejaVu Sans', monospace;">,通常執行某個具體功能。</span></span>
<span style="color: rgb(34, 34, 34);"><span style="font-family: arial, sans-serif;"><span style="font-size:10px;">5</span></span><span style="font-family: 'DejaVu Sans', monospace;">、編譯系統不可以遞迴呼叫</span>,因為所有的變數都是全域性的。</span>

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.mk files that include $(BUILD_PACKAGE) set this to the set of files you want built into your app. Usually:

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

呼叫include $(BUILD_PACKAGE),會把這個屬性中列出的檔案編譯到app中。

LOCAL_BUILT_MODULE_STEM

 

LOCAL_C_INCLUDES

Additional directories to instruct the C/C++ compilers to look for header files in. These paths are rooted at the top of the tree. UseLOCAL_PATH if you have subdirectories of your own that you want in the include paths.

如果想CC++編譯器在更多的目錄中搜尋標頭檔案的話,把這些附加的目錄包含在這個屬性中。如果這些目錄中還有子目錄的話,使用LOCAL_PATH

For example:

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

You should not add subdirectories of include to LOCAL_C_INCLUDES, instead you should reference those files in the #includestatement with their subdirectories.

不要把子目錄新增到這個屬性中去,應該使用#include去包含子目錄。

For example:

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

LOCAL_CC

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

如果你想為當前模組使用一個不同的C編譯器,就在這個屬性中設定好路徑

LOCAL_CERTIFICATE

 

LOCAL_CFLAGS

If you have additional flags to pass into the C or C++ compiler, add them here.

如果有一些標識需要傳遞給編譯器的話,放在這個屬性中。

For example:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1

LOCAL_CLASSPATH

 

LOCAL_COMPRESS_MODULE_SYMBOLS

 

LOCAL_COPY_HEADERS

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

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

由於這個屬性常常引起一些問題,以後會被刪除。

LOCAL_COPY_HEADERS_TO

The directory within "include" to copy the headers listed in LOCAL_COPY_HEADERS to.

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

LOCAL_CPP_EXTENSION

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

如果你的C++副檔名不是“.cpp的話,把自定義的副檔名寫在這裡。

For example:

LOCAL_CPP_EXTENSION := .cc

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

注意,一個模組中,所有的C++檔案必須有相同的副檔名。

LOCAL_CPPFLAGS

If you have additional flags to pass into only the C++ compiler, add them here.

你如果只想傳遞一些標誌給C++編譯器,寫在這裡。

For example:

LOCAL_CPPFLAGS += -ffriend-injection

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

LOCAL_CXX

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

如果想為當前模組使用一個不同的C++編譯器,把編譯器的路徑寫在這裡

LOCAL_DX_FLAGS

 

LOCAL_EXPORT_PACKAGE_RESOURCES

 

LOCAL_FORCE_STATIC_EXECUTABLE

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

如果你的可執行檔案需要靜態連結的話,就把這個變數設定為true。只有很少的庫需要靜態連結,目前只是libc庫。事實上,這種形式只用於/sbin目錄下的可執行檔案。

LOCAL_GENERATED_SOURCES

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

新增到這個屬性中的檔案會在編譯模組時自動生成並連結,可以看一下例子子。

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 Java apps and libraries, LOCAL_JAVA_LIBRARIES specifies which sets of java classes to include. Currently there are two 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 libraries will be included automatically.

連結Java程式和Java庫時,這個屬性會標識出哪個Java庫會被包含。當前只有兩個,coreframework。大部分情況下,會是這樣的形式:LOCAL_JAVA_LIBRARIES := core framework。注意,當使用"include $(BUILD_PACKAGE)"來編譯APK時,這個屬性不能設定。因為相應庫會自動連結。

LOCAL_JAVA_RESOURCE_DIRS

 

LOCAL_JAVA_RESOURCE_FILES

 

LOCAL_JNI_SHARED_LIBRARIES

 

LOCAL_LDFLAGS

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

通過這個屬性,你可以向連結器傳遞一些會加的標識。一定要注意,引數的順序對ld來說非常重要,多多測試。

LOCAL_LDLIBS

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

不管是編譯可執行檔案還是編譯庫,這個屬性允許你新增一些附加庫。需要注意的是,編譯系統不會生成這些庫的依賴關係。通常,這個屬性會在編譯模擬器時使用,你可能會使用一個已經安裝在host上的庫。

Some examples:

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

LOCAL_MODULE

LOCAL_MODULE is the name of what's supposed to be generated from your Android.mk. For exmample,

for libkjs, theLOCAL_MODULE is "libkjs" (the build system adds the appropriate suffix -- .so .dylib .dll). For app modules, useLOCAL_PACKAGE_NAME instead of LOCAL_MODULE.

這個屬性存放你要生成的模組名字。如果是app模組,使用LOCAL_PACKAGE_NAME屬性。

LOCAL_MODULE_PATH

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

用新路徑替換掉編譯系統生成模組的預設存放路徑。如果編譯目標是一個可執行檔案或者一個共享庫,還必須設定LOCAL_UNSTRIPPED_PATH屬性來儲存unstripped二進位制檔案,如果沒有設定的話,編譯系統會報錯。

See Putting modules elsewhere for more.

LOCAL_MODULE_STEM

 

LOCAL_MODULE_TAGS

Set LOCAL_MODULE_TAGS to any number of whitespace-separated tags.

This variable controls what build flavors the package gets included in.

該屬性的多個值之間以空格分隔。

For example:

  • user: include this in user/userdebug builds

  • eng: include this in eng builds

  • tests: the target is a testing target and makes it available for tests

  • optional: don't include this

LOCAL_NO_DEFAULT_COMPILER_FLAGS

 

LOCAL_NO_EMMA_COMPILE

 

LOCAL_NO_EMMA_INSTRUMENT

 

LOCAL_NO_STANDARD_LIBRARIES

 

LOCAL_OVERRIDES_PACKAGES

 

LOCAL_PACKAGE_NAME

LOCAL_PACKAGE_NAME is the name of an app. For example, Dialer, Contacts, etc.

屬性值是要生成的app的名字。

LOCAL_POST_PROCESS_COMMAND

For host executables, you can specify a command to run on the module after it's been linked. You might have to go through some contortions to 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 to executables that you want copied. They're located automatically into 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 to libraries that you want copied. They're located automatically into the right lib directory.

使用$(BUILD_PREBUILT) $(BUILD_HOST_PREBUILT)時,這個屬性設定為你想複製的庫檔案列表,它們會被自動定位。

LOCAL_PREBUILT_OBJ_FILES

 

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES

 

LOCAL_PRELINK_MODULE

 

LOCAL_REQUIRED_MODULES

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

屬性值是有空格分隔的一系列模組名字,如“libblah”或“Email”。如果當前編譯的模組被安裝,這個列表中所有的模組也會被安裝。假如你需要安裝一個app時,這種機制可以保證app依賴的共享庫或者provider被安裝。

LOCAL_RESOURCE_DIR

 

LOCAL_SDK_VERSION

 

LOCAL_SHARED_LIBRARIES

These are the libraries you directly link against.

編譯時需要連結的庫的列表。

You don't need to pass 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 source files to compile -- .cpp .c .y .l .java. For lex and yacc files, it knows how to correctly do the intermediate .h and .c/.cpp files automatically. If the files are in a subdirectory of the one containing the Android.mk, prefix them with the directory name:

需要編譯的檔案列表,如果某些檔案在一個子目錄中,而且這個子目錄中也包含一個Android.mk,就像下面這樣使用。

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

LOCAL_STATIC_JAVA_LIBRARIES

 

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, like executables in sbin and host executables where we use static libraries instead.

編譯模組時需要連結的靜態庫列表。大部分情況下,我們使用共享庫,但連結sbin中的可執行檔案和host上的可執行檔案時,會使用靜態庫。

LOCAL_STATIC_LIBRARIES := /
    libutils /
    libtinyxml

LOCAL_UNINSTALLABLE_MODULE

 

LOCAL_UNSTRIPPED_PATH

Instructs the build system to put the unstripped version of the module somewhere other than what's normal for its type. Usually, you override this because you overrode LOCAL_MODULE_PATH for an executable or a shared library. If you overrodeLOCAL_MODULE_PATH, but not LOCAL_UNSTRIPPED_PATH, an error will occur.

告訴編譯系統把模組的unstripped版本放在某個地方。通常,你給LOCAL_MODULE_PATH 賦值時才會給這個屬性賦值。如果你給LOCAL_MODULE_PATH 賦值,但不給這個屬性賦值,系統會報錯。

See Putting modules elsewhere for more.

LOCAL_WHOLE_STATIC_LIBRARIES

These are the static libraries that you want to include in your module without allowing the linker to remove dead code from them. This is mostly useful if you want to add a static library to 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 limitation here is that the flags will be the same for all invocations of YACC for your module. This can be fixed. If you ever need it to be, just ask.

呼叫yacc時傳遞的標記。注意,當前模組中所有的yacc呼叫都會傳遞這個標記。

LOCAL_YACCFLAGS := -p kjsyy

OVERRIDE_BUILT_MODULE_PATH

 

相關文章