2011年4月21日 星期四

[Android] Build NDK by Ant

Sometimes, we would like to aotu-build by Ant, including the native code.
In past, we always use cygwin, enter the command 'ndk-build' then run the project to build.
Now, we could execute bash command in Build.xml as below.
So that Ant will automatically build the ndk part.

    <property name="bash" location="c:\cygwin\bin\bash.exe" />

    <target name="native-build">
        <exec executable="${bash}">
            <arg value="--login" />
            <arg value="-c"/>
            <arg value="cd /<project-path>/jni; ndk-build"/>
        </exec>
    </target>


If you don't want to regard the <project-path>, doing as below.
In this case, you have to set the make.exe path and ndk-build path in System Variable.

    <property name="bash" location="c:\cygwin\bin\bash.exe" />

    <target name="native-build"
        <exec executable="${bash}">
            <arg value="-c"/>
            <arg value="cd jni; ndk-build"/>
        </exec>
    </target>


Reference:
http://stackoverflow.com/questions/4279931/trouble-executing-bash-exe-from-an-ant-buildfile-in-eclipse

http://o0o.cse.tw/post/901059732/android
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.user/gettingStarted/qs-81_basics.htm
http://www.coolsun.idv.tw/modules/xhnewbb/viewtopic.php?topic_id=1123&viewmode=thread

沒有留言:

張貼留言