Artifact Content
Not logged in

Artifact c7f1becef1cf0eb6498631204979acc6b0fe5d53:


<?xml version="1.0" encoding="UTF-8"?>

<!-- AndroWish custom rules for ant to setup/cleanup
     the source tree and to run the NDK build tool on
     the native components.
     The targets "-pre-build", "-post-build" and
     "-pre-clean" are triggered by build.xml of the SDK. -->

<project>

  <!-- Certain directories must be prepared before building
       on UN*Xish operating systems symbolic links are used,
       otherwise copies are made. The "canSymlinks" property
       detects UN*Xish operating systems for conditional
       targets. -->
  <condition property="decentOS"><os family="unix"/></condition>
  <condition property="canSymlinks"><os family="unix"/></condition>

  <!-- Link some include and library directories and subproject
       source trees before NDK build. -->
  <target name="-pre-build-links" if="canSymlinks">
    <symlink link="${basedir}/jni/tcl-pkgs"
     resource="tcl/pkgs" overwrite="true"/>
    <symlink link="${basedir}/jni/tcl/tcl"
     resource="." overwrite="true"/>
    <symlink link="${asset.dir}/tcl8.6"
     resource="../jni/tcl/library" overwrite="true"/>
    <symlink link="${asset.dir}/sdl2tk8.6"
     resource="../jni/sdl2tk/library" overwrite="true"/>
  </target>

  <!-- Copy some include and library directories and subproject
       source trees before NDK build. -->
  <target name="-pre-build-copies" unless="canSymlinks">
    <copy todir="jni/tcl-pkgs">
      <fileset dir="jni/tcl/pkgs"/>
    </copy>
    <copy todir="${asset.dir}/tcl8.6">
      <fileset dir="jni/tcl/library"/>
    </copy>
    <copy todir="${asset.dir}/sdl2tk8.6">
      <fileset dir="jni/sdl2tk/library"/>
    </copy>
  </target>

  <!-- Cleanup linked include and library directories and subproject
       source trees during clean. "/bin/rm -f" is used since ant
       thinks the symbolic links are directories. -->
  <target name="-cleanup-links" if="canSymlinks">
    <exec executable="/bin/rm" failonerror="false">
      <arg value="-f"/>
      <arg value="${basedir}/tcl-pkgs"/>
      <arg value="jni/tcl/tcl"/>
      <arg value="${asset.dir}/tcl8.6"/>
      <arg value="${asset.dir}/sdl2tk8.6"/>
    </exec>
  </target>

  <!-- Cleanup copied include and library directories and subproject
       source trees during clean. -->
  <target name="-cleanup-copies" unless="canSymlinks">
    <delete includeEmptyDirs="true">
      <fileset dir="jni/tcl-pkgs"/>
      <fileset dir="${asset.dir}/tcl8.6"/>
      <fileset dir="${asset.dir}/sdl2tk8.6"/>
    </delete>
  </target>

  <!-- Invoke ndk-build depending on platform -->
  <target name="-ndk-build-decent" if="decentOS">
    <exec executable="ndk-build" failonerror="true"/>
  </target>
  <target name="-ndk-build-strange" unless="decentOS">
    <exec executable="ndk-build.cmd" failonerror="true"/>
  </target>
  <target name="-ndk-clean-decent" if="decentOS">
    <exec executable="ndk-build">
      <arg value="clean"/>
    </exec>
  </target>
  <target name="-ndk-clean-strange" unless="decentOS">
    <exec executable="ndk-build.cmd">
      <arg value="clean"/>
    </exec>
  </target>

  <!-- NDK build everything in the jni directory -->
  <target name="ndk-build"
   depends="-pre-build-links, -pre-build-copies, -ndk-build-decent, -ndk-build-strange">
  </target>

  <!-- Rename run helper which is an executable to librun.so
       in order to be later packaged in the APK's lib folder -->
  <target name="-pre-build-do"
   depends="ndk-build">
    <copy failonerror="false"
     file="libs/armeabi/run" tofile="libs/armeabi/librun.so"/>
    <copy failonerror="false"
     file="libs/x86/run" tofile="libs/x86/librun.so"/>
  </target>

  <!-- Rename run helper back -->
  <target name="-post-build">
    <delete failonerror="false" file="libs/armeabi/librun.so"/>
    <delete failonerror="false" file="libs/x86/librun.so"/>
  </target>

  <!-- Clean the native stuff in obj and libs -->
  <target name="ndk-clean"
   depends="-ndk-clean-decent, -ndk-clean-strange">
  </target>

  <!-- Perform project cleanup -->
  <target name="-pre-clean"
   depends="ndk-clean, -cleanup-links, -cleanup-copies">
    <delete failonerror="false" file="libs/armeabi/run"/>
    <delete failonerror="false" file="libs/x86/run"/>
  </target>

  <!-- Perform entire project setup before actual build -->
  <target name="-pre-build"
   depends="-pre-build-links, -pre-build-copies, -pre-build-do">
  </target>

</project>