【问题标题】:Use ant (build.xml) to compile jni directory使用ant(build.xml)编译jni目录
【发布时间】:2011-02-25 22:48:36
【问题描述】:

我正在使用 ant 构建我的 android 应用程序(ant compileant install 等),并且我正在添加一些 NDK 源代码(在 jni/ 目录中),我想要一个规则来重新编译jni/ 带有 ant 的目录,然后将我的应用程序安装到我的设备/模拟器中,如下所示:

$ ant jni-and-install

代替:

$ make -f jni/Makefile APP=myapp    
(jni compilation & installation)
...
$ ant install

我试图找到将规则放入 build.xml 的位置,但我不知道在哪里。

在安装到设备之前,我应该编辑什么让 ant 在 jni/ 目录上调用 make

【问题讨论】:

    标签: android ant build-automation


    【解决方案1】:

    您可以使用exec ant task

    <target name="install">
        <!-- ... -->
    </target>
    
    <target name="jni">
        <exec executable="make">
            <arg line="-f jni/Makefile APP=myapp"/>
        </exec>
    </target>
    
    <target name="jni-and-install" depends="jni, install"/>
    

    【讨论】:

      【解决方案2】:

      您可以为此使用 exec ant 任务。我认为将以下内容放在 build.xml 中的 -pre-build 目标中就可以了:

      <exec executable="make" failonerror="true">
          <arg line="-f jni/Makefile APP=myapp"/>
      </exec>

      编辑:JB 的解决方案允许像 ant jni 这样的东西来构建 jni 代码,而无需构建项目的其余部分。您可以通过将上述内容包装在名为“jni”的目标中,然后将 depends="jni" 添加到您的 -pre-build 目标中来获得两全其美。

      【讨论】:

        猜你喜欢
        • 2015-01-15
        • 1970-01-01
        • 1970-01-01
        • 2014-02-03
        • 1970-01-01
        • 1970-01-01
        • 2013-10-13
        • 2013-09-15
        • 1970-01-01
        相关资源
        最近更新 更多