• 【转】Application.mk 文件语法规范


    原文网址:http://blog.sina.com.cn/s/blog_4c451e0e0100s6q4.html

    Application.mk file syntax specification
    Application.mk 文件语法规范
     
    Introduction:
    介绍:
    -------------
     
    This document describes the syntax of Application.mk build files
    written to describe the native modules required by your Android
    application. To understand what follows, it is assumed that you have
    read the docs/OVERVIEW.html file that explains their role and
    usage.
    本文档描述了 Application.mk 生成文件的语法,以及根据你的 Android 应用程序要求描述本机模块。
    为了理解下面内容,假设你有读过 docs/OVERVIEW.html 文件,明白了它们的作用和用法。
     
    Readers of this document should have read docs/OVERVIEW.html and
    docs/ANDROID-MK.html
    本文档的读者将有读过 docs/OVERVIEW.html 和 docs/ANDROID-MK.html
     
    Overview:
    概述:
    ---------
     
    The purpose of Application.mk is to describe which native
    'modules' (i.e. static/shared libraries) are needed by your
    application.
    Application.mk 文件的目地是来描述被你的应用程序所需要的本机模块(也就是:静态库或共享库)。
     
    An Application.mk file is usually placed under $PROJECT/jni/Application.mk,
    where $PROJECT points to your application's project directory.
    一个 Application.mk 文件通常是放置在 $PROJECT/jni/Application.mk 这个路径下面,
    $PROJECT 意味着你应用程序的工程目录。
     
    Another alternative is to place it under a sub-directory of the top-level
    $NDK/apps directory, e.g.:
    另一个可放置的地方是在 $NDK/apps 目录的子目录下,例如:
     
       $NDK/apps/<myapp>/Application.mk
     
    Where <myapp> is a short name used to describe your 'application'
    to the NDK build system (this name doesn't go into your generated
    shared libraries or your final packages).
    <myapp>是一个短名称用来为 NDK 生成系统描述你的应用程序
    (这个名字不会进入你的共享库或你的最终包)。
     
    The Application.mk is really a tiny GNU Makefile fragment that must
    define a few variables:
    Application.mk 实际上是一个极小的 GNU Makefile 片断,必然要定义几个变量:
     
    APP_PROJECT_PATH
        This variable should give the *absolute* path to your
        Application's project root directory. This is used to copy/install
        stripped versions of the generated JNI shared libraries to a
        specific location known to the APK-generating tools.
        这个变量将提供你应用程序工程根目录的绝对路径。
        这是用来拷贝或安装已脱离版本的 JNI 共享库到一个 APK 产生工具已知的具体位置。
     
        Note that it is optional for $PROJECT/jni/Application.mk, but
        *mandatory* for $NDK/apps/<myapp>/Application.mk
        注意,对于 $PROJECT/jni/Application.mk 它是可选项的,
           但是对于 $NDK/apps/<myapp>/Application.mk 就是强制的了。
     
    APP_MODULES
        This variable is optional. If not defined, the NDK will build by
        default _all_ the modules declared by your Android.mk, and any
        sub-makefile it may include.
        这个变量是可选的。
        如果没有定义的话,NDK 将通过默认 _all_ 生成由你的 Android.mk 文件声明的所有模块,
        并且可以包含任意子 Makefile 文件。
     
        If APP_MODULES is defined, it must be a space-separated list of module
        names as they appear in the LOCAL_MODULE definitions of Android.mk
        files. Note that the NDK will compute module dependencies automatically.
        如果 APP_MODULES 是定义过的,
        它一定是一个空格分隔的模块名列表,就像它们出现在 Android.mk 文件的 LOCAL_MODULE 定义中一样。
     
        NOTE: This variable's behaviour changed in NDK r4. Before that:
        注意:这个变量的行为方式已在 NDK r4 中改变。之前是:
     
          - the variable was mandatory in your Application.mk
          - 该变量在你的 Application.mk 文件中是强制的。
          - all required modules had to be listed explicitly.
          - 全部需要的模块已明确地列出。
     
    APP_OPTIM
        This optional variable can be defined to either 'release' or
        'debug'. This is used to alter the optimization level when
        building your application's modules.
        这个可选的变量可以定义 发行版 或 调试版 。
        这是用来在生成你应用程序的模块时改变优化级别。
     
        A 'release' mode is the default, and will generate highly
        optimized binaries. The 'debug' mode will generate un-optimized
        binaries which are much easier to debug.
        发行版 模式是默认的,并且将产生高度地优化二进制代码。
        调试版 模式将产生未优化的二进制代码,让调试更容易些。
     
        Note that if your application is debuggable (i.e. if your manifest
        sets the android:debuggable attribute to "true" in its <application>
        tag), the default will be 'debug' instead of 'release'. This can
        be overridden by setting APP_OPTIM to 'release'.
        注意如果你的应用程序是可调试的
        (也就是:如果你的 manifest 在它的 <application> 标签中 设置 android:debuggable 属性为 true ),
        调度版 模式将替代 发行版 模式成为默认方式。
        这可以通过设置 APP_OPTIM 为 release 来不理会。
     
        Note that it is possible to debug both 'release' and 'debug'
        binaries, but the 'release' builds tend to provide less information
        during debugging sessions: some variables are optimized out and
        can't be inspected, code re-ordering can make stepping through
        the code difficult, stack traces may not be reliable, etc...
        注意 发行版 模式 和 调试版 模式都可做调式,但是 发行版 模式在调试作业阶段提供较少的信息:
        一些变量是被优化掉了不能被视察了,代码再排序让单步调试困难,堆栈跟踪不可信赖,等等。
     
    APP_CFLAGS
        A set of C compiler flags passed when compiling any C or C++ source code
        of any of the modules. This can be used to change the build of a given
        module depending on the application that needs it, instead of modifying
        the Android.mk file itself.
        一组 C 编译器的标志在编译任意模块的任何 C 或 C++ 源代码时被传递。
        这可以是应用程序视情况而定来改变特定模块的生成。
     
        IMPORTANT WARNING: 
        重要警告:
        +++++++++++++++++++++++++++++++++++++++++++++++++++
        +
        + All paths in these flags should be relative to the top-level NDK
        + directory. For example, if you have the following setup:
        + 在这些标志中的全部路径将是相对于顶级 NDK 目录。例如,如果你有如下结构: 
        +
        +    sources/foo/Android.mk
        +    sources/bar/Android.mk
        +
        +  To specify in foo/Android.mk that you want to add the path to the
        + 'bar' sources during compilation, you should use:
        + 在 foo/Android.mk 文件中具体指定你想要在编译时期添加 bar 源文件路径,你将使用:
        +
        +   APP_CFLAGS += -Isources/bar
        +
        + Or alternatively: 
        + 或者:
        +
        +   APP_CFLAGS += -I$(LOCAL_PATH)/../bar
        +
        + Using '-I../bar' will *NOT* work since it will be equivalent to
        + '-I$NDK_ROOT/../bar' instead.
        + 使用 -I../bar 将没有效,因为它将相当于 -I$NDK_ROOT/../bar 。
        +
        +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     
        NOTE: In android-ndk-1.5_r1, this only applied to C sources, not C++ ones.
              This has been corrected to match the full Android build system.
        注意:在 android-ndk-1.5_r1 中,这仅适用于 C 源文件,而没有 C++ 编译标志一个。
           这已经改正彻底地匹配 Android 生成系统。
     
    APP_CXXFLAGS
        An alias for APP_CPPFLAGS, to be considered obsolete as it may disappear
        in a future release of the NDK.
        一个 APP_CPPFLAGS 的别名,在未来 NDK 的发行版中考虑到过时的原因,它可能会消失。
     
    APP_CPPFLAGS
        A set of C++ compiler flags passed when building C++ sources *only*.
        一组 C++ 编译器的标志仅在生成 C++ 源文件时被传递。
     
        NOTE: In android-ndk-1.5_r1, this applied to both C and C++ sources.
              This has been corrected to match the full Android build system.
              You can now use APP_CFLAGS for flags that shall apply to C and
              C++ sources.
        注意:在 android-ndk-1.5_r1 中,这适用于 C 和 C++ 两者的源文件。
           这已经改正彻底地匹配 Android 生成系统。
           你可以现在使用 APP_CFLAGS 变量,将适用于 C 和 C++ 源文件。
     
    APP_BUILD_SCRIPT
        By default, the NDK build system will look for a file named Android.mk
        under $(APP_PROJECT_PATH)/jni, i.e. for the file:
        默认情况下,NDK 生成系统将寻找一个名为 Android.mk 文件在 $(APP_PROJECT_PATH)/jni 目录下,
        也就是,如此文件:
     
           $(APP_PROJECT_PATH)/jni/Android.mk
     
        If you want to override this behaviour, you can define APP_BUILD_SCRIPT
        to point to an alternate build script. A non-absolute path will always
        be interpreted as relative to the NDK's top-level directory.
        如果你想要替代这个行为方式,你可以定义 APP_BUILD_SCRIPT 来指出一个供替换的生成脚本。
        一个非绝对路径将一直是被解释为相对于 NDK 顶级目录。
     
    APP_ABI
        By default, the NDK build system will generate machine code for the
        'armeabi' ABI. This corresponds to an ARMv5TE based CPU with software
        floating point operations. You can use APP_ABI to select a different
        ABI.
        默认情况下,NDK 生成系统将产生适用于 armeabi ABI 机器码。
        这符合一个基于 ARMv5TE 的 CPU 对应软件浮点操作。
        你可以使用 APP_ABI 来选择一个不同的 ABI 。
     
        For example, to support hardware FPU instructions on ARMv7 based devices,
        use:
        例如,对于支持硬件 FPU 指令在基于 ARMv7 的设备上,使用:
     
            APP_ABI := armeabi-v7a
     
        Or to support both ARMv5TE and ARMv7 based devices, use:
        或对于基于 ARMv5TE 和 ARMv7 两者都支持的设备,使用:
     
            APP_ABI := armeabi armeabi-v7a
     
        For the list of all supported ABIs and details about their usage and
        limitations, please read docs/CPU-ARCH-ABIS.html
        对于全部支持的 ABI 列表和详细说明关于它们的用法与限制,请阅读 read docs/CPU-ARCH-ABIS.html
     
    APP_STL
        By default, the NDK build system provides C++ headers for the minimal
        C++ runtime library (/system/lib/libstdc++.so) provided by the Android
        system.
        默认情况下,NDK 生成系统为由 Android 系统提供的最低限度的 C++ 运行时库(/system/lib/libstdc++.so)提供头文件。
     
        However, the NDK comes with alternative C++ implementations that you can
        use or link to in your own applications. Define APP_STL to select one of
        them. Examples are:
        然而,NDK 提供任你选择的 C++ 实现,你可以使用或链入你的应用程序中。
        定义 APP_STL 来选择它们中的一个。例如:
     
           APP_STL := stlport_static    --> static STLport library
           APP_STL := stlport_shared    --> shared STLport library
           APP_STL := system            --> default C++ runtime library
     
        For more information on the subject, please read docs/CPLUSPLUS-SUPPORT.html
        就此话题的更多信息,请阅读 docs/CPLUSPLUS-SUPPORT.html
     
    A trivial Application.mk file would be:
    一个普通的 Application.mk 文件将是:
     
    -------------- cut here -------------------------
    APP_PROJECT_PATH := <path to project>
    -------------- cut here -------------------------
  • 相关阅读:
    云? 云! 晕! 云计算适合创业公司么?
    批量转移Windows Server的DNS设置
    Signs that you are a bad programmer
    IsNull Function in PeopleSoft MetaSQL
    JS绘制曲线图
    Why does my shared clipboard not work?
    C#入门详解(2)
    C#入门详解(1)
    分享范玮琪最初的梦想
    像战士一样生活
  • 原文地址:https://www.cnblogs.com/wi100sh/p/4308407.html
Copyright © 2020-2023  润新知