<commit_before><?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
     processing.py
     Write processing sketches in Python.

     This build file has only been tested on mac osx, but is expected to
     work just fine on Linux. It is not expected to work at all on Windows.

     jdf

     Run
      "ant make-all-distributions" to create release.
      "ant –Dplatform=macosx make-distribution" to create a release for OSX.

     ====================================================================== -->
<project name="processing.py" default="jar">
  <description>Write Processing sketches in Python</description>

  <fail unless="processing"
    message="You have to specify where to find processing with -Dprocessing=/path/to/processing"/>

  <!-- for <if> tag -->
  <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="buildtime/lib/java/ant-contrib.jar"/>

  <property name="pdejar" value="${processing}/app/pde.jar"/>
  <property name="corejar" value="${processing}/core/library/core.jar"/>
  <property name="jython" value="buildtime/lib/jython/jython.jar"/>
  <property name="jython.license" value="buildtime/lib/jython/LICENSE.txt"/>

  <!-- jycessing.buildnumber is the current version string -->
  <property file="runtime/src/jycessing/buildnumber.properties" prefix="jycessing"/>

  <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="buildtime/lib/java/appbundler-1.0.jar"/>

  <macrodef name="rm-rf">
    <attribute name="target"/>
    <sequential>
      <exec executable="/bin/rm" failonerror="true">
        <arg value="-rf"/>
        <arg value="${basedir}/@{target}"/>
      </exec>
    </sequential>
  </macrodef>

  <target name="newversion" depends="bump-version,clean,make-all-distributions"/>

  <target name="modejar" depends="build">
    <jar destfile="PythonMode.jar">
      <fileset dir="bin" excludes="jycessing/build/**,test/**"/>
    </jar>
  </target>

  <target name="modedist" depends="modejar">
    <delete dir="modedist" />
    <property name="bundle" value="modedist/PythonMode"/>
    <mkdir dir="${bundle}" />
    <mkdir dir="${bundle}/mode" />

    <copy todir="${bundle}/mode" file="PythonMode.jar"/>
    <copy todir="${bundle}" file="LICENSE.txt"/>
    <copy todir="${bundle}/mode" file="${jython}"/>
    <copy tofile="${bundle}/mode/LICENSE.jython" file="${jython.license}"/>

    <copy todir="${bundle}">
      <fileset dir="mode/" />
    </copy>

    <replaceregexp file="${bundle}/mode.properties" flags="g"
                 match="@@version@@" replace="${jycessing.buildnumber}" />
    <replaceregexp file="${bundle}/mode.properties" flags="g"
                 match="@@pretty-version@@" replace="${jycessing.buildnumber}" />
  </target>
	
  <target name="zip-mode" depends="modedist">
    <zip destfile="PythonMode.zip" basedir="modedist" excludes="**/_DS.Store" />
    <copy file="PythonMode.zip" tofile="PythonMode_${jycessing.buildnumber}.zip" />
  </target>

  <target name="upload-mode" depends="zip-mode">
    <echo message="Pushing modedist to py.processing.org..." />
    <exec executable="/bin/sh">
      <arg value="-c"/>
      <arg value="scp -i ~/.ssh/id_rsa-processing.org -r PythonMode.zip j<EMAIL>:/var/www/py" />
    </exec>
    <exec executable="/bin/sh">
      <arg value="-c"/>
      <arg value="scp -i ~/.ssh/id_rsa-processing.org -r PythonMode_${jycessing.buildnumber}.zip j<EMAIL>:/var/www/py" />
    </exec>
  </target>

  <target name="jar" depends="build">
    <fail unless="platform" message="You have to specify a platform."/>
    <jar destfile="processing-py.jar">
      <fileset dir="bin" excludes="jycessing/build/**,test/**"/>
      <zipgroupfileset file="${jython}"/>
      <zipgroupfileset file="${corejar}"/>
      <zipgroupfileset file="${processing}/core/library/gluegen-rt.jar"/>
      <zipgroupfileset file="${processing}/core/library/jogl-all.jar"/>
      <manifest>
        <attribute name="Main-Class" value="jycessing.Runner"/>
      </manifest>
    </jar>
    <jar destfile="processing-py-natives-${gl.platform}.jar">
      <zipgroupfileset file="${processing}/core/library/gluegen-rt-natives-${gl.platform}.jar"/>
      <zipgroupfileset file="${processing}/core/library/jogl-all-natives-${gl.platform}.jar"/>
    </jar>
  </target>

  <target name="build" depends="build-processing,build-pde">
    <mkdir dir="bin"/>
    <javac destdir="bin" includeantruntime="false">
      <src path="runtime/src"/>
      <classpath>
        <pathelement location="${jython}"/>
        <pathelement location="${corejar}"/>
        <pathelement location="${pdejar}"/>
        <fileset dir="libraries/fisica">
          <include name="*.jar"/>
        </fileset>
      </classpath>
    </javac>
    <copy todir="bin">
      <fileset dir="runtime/src" excludes="**/*.java"/>
    </copy>
    <!-- Update the internal launch script with the external one-->
    <copy tofile="processing-py.app/Contents/Resources/script" file="processing-py.sh"/>
    <chmod file="processing-py.app/Contents/MacOS/processing-py" perm="755"/>
  </target>

  <target name="check-pde-needs-build">
    <uptodate property="pde-is-uptodate"
              targetfile="${pdejar}">
      <srcfiles dir="${processing}/app/src/processing/app"/>
    </uptodate>
  </target>
  <target name="build-pde"
    depends="check-pde-needs-build"
    unless="pde-is-uptodate">
    <echo message="Building pde." />
    <ant dir="${processing}/build" target="build"/>
  </target>

  <target name="check-processing-needs-build">
    <uptodate property="processing-is-uptodate"
              targetfile="${corejar}">
      <srcfiles dir="${processing}/core/src/processing/core"/>
    </uptodate>
  </target>
  <target name="build-processing"
    depends="check-processing-needs-build"
    unless="processing-is-uptodate">
    <echo message="Building processing." />
    <ant dir="${processing}/build" target="build"/>
  </target>

  <target name="clean">
    <ant dir="${processing}/build" target="clean"/>
    <rm-rf target="bin"/>
    <rm-rf target="dist"/>
    <rm-rf target=".cache"/>
    <delete file="runtime/generated/jycessing/DriverImpl.java"/>
    <delete file="processing-py-macosx.jar"/>
    <delete file="processing-py-linux32.jar"/>
    <delete file="processing-py-linux64.jar"/>
    <delete file="processing-py-windows32.jar"/>
    <delete file="processing-py-windows64.jar"/>
    <delete>
      <fileset dir="buildtime/py" includes="*.class"/>
    </delete>
    <exec executable="find" failonerror="true">
      <arg line=". -name .DS_Store -depth -exec rm {} ;"/>
    </exec>
  </target>

  <target name="bump-version">
    <propertyfile file="runtime/src/jycessing/buildnumber.properties">
      <entry key="buildnumber" type="int" operation="+" pattern="0000" default="0000"/>
    </propertyfile>
  </target>

  <!--
    At the moment creating this launcher requires a few manual steps:
      1) Run this target ("ant launcher.mac")
      2.1) Remove the content of the contained "Java" folder
      2.2) Adjust the included Info.plist so our python code recognizes it (TODO!)
      3) Zip the app folder
      4) Place the zip into the runtime's deployment folder.
  -->
  <target name="launcher.mac">
    <mkdir dir="launcher.mac"/>
    <touch file="Info.plist"/>
    <bundleapp outputdirectory="launcher.mac" name="Processing" displayname="Processing.py Launcher" identifier="processing.py.launcher" shortversion="1.0" applicationCategory="public.app-category.developer-tools" mainclassname="jycessing.Runner">
      <argument value="--internal"/>
      <classpath file="processing-py.jar"/>
    </bundleapp>
    <delete>
      <fileset file="Info.plist"/>
    </delete>
  </target>

  <!--
    The following macros define properties for building, compressing, and distributing
    platform-specific distributions.
  -->
  <macrodef name="for-platform">
    <attribute name="platform"/>
    <attribute name="target"/>
    <element name="actions" implicit="true"/>
    <sequential>
      <local name="dist.name"/>
      <property name="dist.name" value="processing.py-${jycessing.buildnumber}-@{platform}"/>
      <local name="compression"/>
      <if>
        <matches pattern="^windows.*$" string="@{platform}"/>
        <then>
          <property name="compression" value="zip"/>
        </then>
        <else>
          <property name="compression" value="tgz"/>
        </else>
      </if>
      <local name="gl.platform"/>
      <switch value="@{platform}">
        <case value="macosx"><property name="gl.platform" value="macosx-universal"/></case>
        <case value="linux32"><property name="gl.platform" value="linux-i586"/></case>
        <case value="linux64"><property name="gl.platform" value="linux-amd64"/></case>
        <case value="windows32"><property name="gl.platform" value="windows-i586"/></case>
        <case value="windows64"><property name="gl.platform" value="windows-amd64"/></case>
      </switch>
      <echo message="Executing target @{target} for platform @{platform}."/>
      <antcall target="@{target}">
        <param name="platform" value="@{platform}"/>
        <param name="dist.name" value="${dist.name}"/>
        <param name="dist.compressed" value="${dist.name}.${compression}"/>
        <param name="dist.dir" value="dist/${dist.name}"/>
        <param name="dist.jre" value="dist/${dist.name}/jre"/>
        <param name="jre.remote" value="http://processing.py.s3.amazonaws.com/jre-7u25-@{platform}.tgz"/>
        <param name="jre.local.dir" value="JREs/@{platform}"/>
        <param name="jre.local.compressed" value="JREs/@{platform}.tgz"/>
        <param name="gl.platform" value="${gl.platform}"/>
      </antcall>
    </sequential>
  </macrodef>

  <macrodef name="for-all-platforms">
    <attribute name="target"/>
    <sequential>
      <for-platform platform="macosx" target="@{target}"/>
      <for-platform platform="linux32" target="@{target}"/>
      <for-platform platform="linux64" target="@{target}"/>
      <for-platform platform="windows32" target="@{target}"/>
      <for-platform platform="windows64" target="@{target}"/>
    </sequential>
  </macrodef>

  <!-- For debugging the platform macros. -->
  <target name="dump-platform">
    <echo message="Dumping ${platform}:"/>
    <echo message="  $${dist.name} = ${dist.name}"/>
    <echo message="  $${dist.dir} = ${dist.dir}"/>
    <echo message="  $${dist.compressed} = ${dist.compressed}"/>
    <echo message="  $${dist.jre} = ${dist.jre}"/>
    <echo message="  $${jre.remote} = ${jre.remote}"/>
    <echo message="  $${jre.local.dir} = ${jre.local.dir}"/>
    <echo message="  $${jre.local.compressed} = ${jre.local.compressed}"/>
    <echo message="  $${gl.platform} = ${gl.platform}"/>
  </target>
  <target name="dump-all-platforms">
    <for-all-platforms target="dump-platform"/>
  </target>

  <!--
    The following targets can only be run for particular platforms, as in
       <for-platform platform="windows64" target="targetname"/>
    They all refer to properties defined by the for-platform macro.
  -->
  <target name="getjre">
    <if>
      <not><available file="JREs/${platform}"/></not>
      <then>
        <echo message="Fetching JRE for ${platform}" />
        <get src="${jre.remote}" dest="${jre.local.compressed}" usetimestamp="true"/>
        <mkdir dir="${jre.local.dir}"/>
        <exec executable="tar" dir="JREs">
          <arg line="zxf ${platform}.tgz -C ${platform} --strip-components 1 "/>
        </exec>
        <if>
          <equals arg1="${platform}" arg2="macosx"/>
          <then>
            <echo message="Moving mac JRE to sane location."/>
            <exec executable="/bin/sh" dir="${jre.local.dir}" failonerror="true">
              <arg value="-c"/>
              <arg value="mv Contents/Home/* ."/>
            </exec>
          </then>
        </if>
      </then>
    </if>
    <chmod dir="${jre.local.dir}/bin" includes="*" perm="755"/>
  </target>

  <macrodef name="compress">
    <attribute name="from"/>
    <attribute name="to"/>
    <attribute name="dir"/>
    <sequential>
      <if>
        <matches pattern="^.*zip$" string="@{to}"/>
        <then>
          <echo message="Creating zip archive @{to}."/>
          <exec executable="zip" dir="@{dir}">
            <arg line="-q -r @{to} @{from}"/>
          </exec>
        </then>
        <else>
          <echo message="Creating gzipped tar archive @{to}."/>
          <exec executable="tar" dir="@{dir}">
            <arg line="zcfh @{to} @{from}"/>
          </exec>
        </else>
      </if>
    </sequential>
  </macrodef>

  <macrodef name="copy-processing-library">
    <attribute name="library"/>
    <attribute name="dir"/>
    <sequential>
      <mkdir dir="@{dir}/@{library}"/>
      <copy todir="@{dir}/@{library}">
        <!--
          The business about ${platform}/**, ${platform}64/** is for
          catching both macosx/*.dylib and macosx64/*.dylib, for those
          libraries that still have legacy OSX DLLs. Right now, that's
          only video.
        -->
        <fileset dir="${processing}/java/libraries/@{library}/library"
                 includes="*.txt,*.jar,${platform}/**,${platform}64/**"/>
      </copy>
    </sequential>
  </macrodef>

  <target name="check-for-platform-lib-cache">
    <uptodate property="platform-lib-cache-exists"
              srcfile="${processing}/core/library/gluegen-rt.jar"
              targetfile=".cache/libs/${platform}/opengl/gluegen-rt.jar"/>
  </target>
  <target name="platform-lib-cache"
      depends="check-for-platform-lib-cache"
      unless="platform-lib-cache-exists">
    <local name="cache"/>
    <property name="cache" value=".cache/libs/${platform}"/>
    <mkdir dir="${cache}"/>
    <mkdir dir="${cache}/opengl"/>
    <copy todir="${cache}/opengl">
      <fileset dir="${processing}/core/library" includes="*.jar" excludes="core.jar"/>
    </copy>
    <copy-processing-library dir="${cache}" library="dxf"/>
    <copy-processing-library dir="${cache}" library="lwjgl"/>
    <copy-processing-library dir="${cache}" library="minim"/>
    <copy-processing-library dir="${cache}" library="net"/>
    <copy-processing-library dir="${cache}" library="pdf"/>
    <copy-processing-library dir="${cache}" library="serial"/>
    <copy-processing-library dir="${cache}" library="video"/>
  </target>

  <target name="make-one-distribution" depends="jar,platform-lib-cache">
    <echo message="Building distribution for ${platform}" />
    <for-platform platform="${platform}" target="getjre"/>
    <rm-rf target="${dist.dir}"/>
    <mkdir dir="${dist.dir}"/>
    <copy todir="${dist.dir}">
      <fileset file="LICENSE.txt"/>
      <fileset dir="." includes="workspace/**"/>
      <fileset dir="." includes="libraries/**"/>
      <fileset dir="." includes="*.sh,*.bat,processing-py.app/**"/>
    </copy>
    <chmod file="${dist.dir}/processing-py.sh" perm="755"/>
    <chmod file="${dist.dir}/processing-py.bat" perm="755"/>
    <chmod file="${dist.dir}/processing-py.app/Contents/Resources/script" perm="755"/>
    <chmod file="${dist.dir}/processing-py.app/Contents/MacOS/processing-py" perm="755"/>

    <symlink resource="${basedir}/.cache/libs/${platform}"
        link="${basedir}/${dist.dir}/libraries/processing"/>
    <symlink resource="${basedir}/${jre.local.dir}" link="${basedir}/${dist.jre}"/>
    <symlink resource="${basedir}/examples.py" link="${basedir}/${dist.dir}/examples.py"/>
    <symlink resource="${basedir}/processing-py.jar" link="${basedir}/${dist.dir}/processing-py.jar"/>
    <symlink resource="${basedir}/processing-py-natives-${gl.platform}.jar"
        link="${basedir}/${dist.dir}/processing-py-natives-${gl.platform}.jar"/>

    <compress from="${dist.name}" to="${dist.compressed}" dir="dist"/>
  </target>

  <target name="make-all-distributions">
    <for-all-platforms target="make-one-distribution"/>
  </target>

  <!--
    $ ant –Dplatform=macosx make-distribution
  -->
  <target name="make-distribution">
    <for-platform platform="${platform}" target="make-one-distribution"/>
  </target>

  <target name="upload-one-distribution">
    <echo message="Pushing ${dist.compressed} to py.processing.org..." />
    <exec executable="/bin/sh">
      <arg value="-c"/>
      <arg value="scp -i ~/.ssh/id_rsa-processing.org dist/${dist.compressed} j<EMAIL>:/var/www/py" />
    </exec>
  </target>

  <target name="upload-all-distributions">
    <echo message="If you're not feinberg, this target will fail for you."/>
    <for-all-platforms target="upload-one-distribution"/>
  </target>

  <!--
    $ ant –Dplatform=macosx upload-distribution
  -->
  <target name="upload-distribution" depends="jar">
    <for-platform platform="${platform}" target="upload"/>
  </target>

  <!--
	Testing-related targets.
  -->
  <target name="build-tests" depends="jar">
    <mkdir dir="testing/bin"/>
    <javac classpath="testing/library/junit-4.11.jar:processing-py.jar" destdir="testing/bin"
        includeantruntime="false" deprecation="true">
      <src path="testing/src"/>
    </javac>
  </target>
  <target name="runtest" depends="build-tests">
    <java classname="org.junit.runner.JUnitCore" fork="true">
      <arg value="test.jycessing.JycessingTests"/>
      <classpath>
        <pathelement location="testing/bin"/>
        <pathelement location="processing-py.jar"/>
        <pathelement location="testing/library/junit-4.11.jar"/>
        <pathelement location="testing/library/hamcrest-core-1.3.jar"/>
      </classpath>
    </java>
  </target>

  <!--
    $ ant –Dplatform=macosx test
  -->
  <target name="test">
    <for-platform platform="${platform}" target="runtest"/>
  </target>

</project>
<commit_msg>Give a useful default value to processing location in build.xml.<commit_after><?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
     processing.py
     Write processing sketches in Python.

     This build file has only been tested on mac osx, but is expected to
     work just fine on Linux. It is not expected to work at all on Windows.

     jdf

     Run
      "ant make-all-distributions" to create release.
      "ant –Dplatform=macosx make-distribution" to create a release for OSX.

     ====================================================================== -->
<project name="processing.py" default="jar">
  <description>Write Processing sketches in Python</description>

  <property name="processing" value="../processing"/>

  <!-- for <if> tag -->
  <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="buildtime/lib/java/ant-contrib.jar"/>

  <property name="pdejar" value="${processing}/app/pde.jar"/>
  <property name="corejar" value="${processing}/core/library/core.jar"/>
  <property name="jython" value="buildtime/lib/jython/jython.jar"/>
  <property name="jython.license" value="buildtime/lib/jython/LICENSE.txt"/>

  <!-- jycessing.buildnumber is the current version string -->
  <property file="runtime/src/jycessing/buildnumber.properties" prefix="jycessing"/>

  <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="buildtime/lib/java/appbundler-1.0.jar"/>

  <macrodef name="rm-rf">
    <attribute name="target"/>
    <sequential>
      <exec executable="/bin/rm" failonerror="true">
        <arg value="-rf"/>
        <arg value="${basedir}/@{target}"/>
      </exec>
    </sequential>
  </macrodef>

  <target name="newversion" depends="bump-version,clean,make-all-distributions"/>

  <target name="modejar" depends="build">
    <jar destfile="PythonMode.jar">
      <fileset dir="bin" excludes="jycessing/build/**,test/**"/>
    </jar>
  </target>

  <target name="modedist" depends="modejar">
    <delete dir="modedist" />
    <property name="bundle" value="modedist/PythonMode"/>
    <mkdir dir="${bundle}" />
    <mkdir dir="${bundle}/mode" />

    <copy todir="${bundle}/mode" file="PythonMode.jar"/>
    <copy todir="${bundle}" file="LICENSE.txt"/>
    <copy todir="${bundle}/mode" file="${jython}"/>
    <copy tofile="${bundle}/mode/LICENSE.jython" file="${jython.license}"/>

    <copy todir="${bundle}">
      <fileset dir="mode/" />
    </copy>

    <replaceregexp file="${bundle}/mode.properties" flags="g"
                 match="@@version@@" replace="${jycessing.buildnumber}" />
    <replaceregexp file="${bundle}/mode.properties" flags="g"
                 match="@@pretty-version@@" replace="${jycessing.buildnumber}" />
  </target>
	
  <target name="zip-mode" depends="modedist">
    <zip destfile="PythonMode.zip" basedir="modedist" excludes="**/_DS.Store" />
    <copy file="PythonMode.zip" tofile="PythonMode_${jycessing.buildnumber}.zip" />
  </target>

  <target name="upload-mode" depends="zip-mode">
    <echo message="Pushing modedist to py.processing.org..." />
    <exec executable="/bin/sh">
      <arg value="-c"/>
      <arg value="scp -i ~/.ssh/id_rsa-processing.org -r PythonMode.zip <EMAIL>:/var/www/py" />
    </exec>
    <exec executable="/bin/sh">
      <arg value="-c"/>
      <arg value="scp -i ~/.ssh/id_rsa-processing.org -r PythonMode_${jycessing.buildnumber}.zip <EMAIL>:/var/www/py" />
    </exec>
  </target>

  <target name="jar" depends="build">
    <fail unless="platform" message="You have to specify a platform."/>
    <jar destfile="processing-py.jar">
      <fileset dir="bin" excludes="jycessing/build/**,test/**"/>
      <zipgroupfileset file="${jython}"/>
      <zipgroupfileset file="${corejar}"/>
      <zipgroupfileset file="${processing}/core/library/gluegen-rt.jar"/>
      <zipgroupfileset file="${processing}/core/library/jogl-all.jar"/>
      <manifest>
        <attribute name="Main-Class" value="jycessing.Runner"/>
      </manifest>
    </jar>
    <jar destfile="processing-py-natives-${gl.platform}.jar">
      <zipgroupfileset file="${processing}/core/library/gluegen-rt-natives-${gl.platform}.jar"/>
      <zipgroupfileset file="${processing}/core/library/jogl-all-natives-${gl.platform}.jar"/>
    </jar>
  </target>

  <target name="build" depends="build-processing,build-pde">
    <mkdir dir="bin"/>
    <javac destdir="bin" includeantruntime="false">
      <src path="runtime/src"/>
      <classpath>
        <pathelement location="${jython}"/>
        <pathelement location="${corejar}"/>
        <pathelement location="${pdejar}"/>
        <fileset dir="libraries/fisica">
          <include name="*.jar"/>
        </fileset>
      </classpath>
    </javac>
    <copy todir="bin">
      <fileset dir="runtime/src" excludes="**/*.java"/>
    </copy>
    <!-- Update the internal launch script with the external one-->
    <copy tofile="processing-py.app/Contents/Resources/script" file="processing-py.sh"/>
    <chmod file="processing-py.app/Contents/MacOS/processing-py" perm="755"/>
  </target>

  <target name="check-pde-needs-build">
    <uptodate property="pde-is-uptodate"
              targetfile="${pdejar}">
      <srcfiles dir="${processing}/app/src/processing/app"/>
    </uptodate>
  </target>
  <target name="build-pde"
    depends="check-pde-needs-build"
    unless="pde-is-uptodate">
    <echo message="Building pde." />
    <ant dir="${processing}/build" target="build"/>
  </target>

  <target name="check-processing-needs-build">
    <uptodate property="processing-is-uptodate"
              targetfile="${corejar}">
      <srcfiles dir="${processing}/core/src/processing/core"/>
    </uptodate>
  </target>
  <target name="build-processing"
    depends="check-processing-needs-build"
    unless="processing-is-uptodate">
    <echo message="Building processing." />
    <ant dir="${processing}/build" target="build"/>
  </target>

  <target name="clean">
    <ant dir="${processing}/build" target="clean"/>
    <rm-rf target="bin"/>
    <rm-rf target="dist"/>
    <rm-rf target=".cache"/>
    <delete file="runtime/generated/jycessing/DriverImpl.java"/>
    <delete file="processing-py-macosx.jar"/>
    <delete file="processing-py-linux32.jar"/>
    <delete file="processing-py-linux64.jar"/>
    <delete file="processing-py-windows32.jar"/>
    <delete file="processing-py-windows64.jar"/>
    <delete>
      <fileset dir="buildtime/py" includes="*.class"/>
    </delete>
    <exec executable="find" failonerror="true">
      <arg line=". -name .DS_Store -depth -exec rm {} ;"/>
    </exec>
  </target>

  <target name="bump-version">
    <propertyfile file="runtime/src/jycessing/buildnumber.properties">
      <entry key="buildnumber" type="int" operation="+" pattern="0000" default="0000"/>
    </propertyfile>
  </target>

  <!--
    At the moment creating this launcher requires a few manual steps:
      1) Run this target ("ant launcher.mac")
      2.1) Remove the content of the contained "Java" folder
      2.2) Adjust the included Info.plist so our python code recognizes it (TODO!)
      3) Zip the app folder
      4) Place the zip into the runtime's deployment folder.
  -->
  <target name="launcher.mac">
    <mkdir dir="launcher.mac"/>
    <touch file="Info.plist"/>
    <bundleapp outputdirectory="launcher.mac" name="Processing" displayname="Processing.py Launcher" identifier="processing.py.launcher" shortversion="1.0" applicationCategory="public.app-category.developer-tools" mainclassname="jycessing.Runner">
      <argument value="--internal"/>
      <classpath file="processing-py.jar"/>
    </bundleapp>
    <delete>
      <fileset file="Info.plist"/>
    </delete>
  </target>

  <!--
    The following macros define properties for building, compressing, and distributing
    platform-specific distributions.
  -->
  <macrodef name="for-platform">
    <attribute name="platform"/>
    <attribute name="target"/>
    <element name="actions" implicit="true"/>
    <sequential>
      <local name="dist.name"/>
      <property name="dist.name" value="processing.py-${jycessing.buildnumber}-@{platform}"/>
      <local name="compression"/>
      <if>
        <matches pattern="^windows.*$" string="@{platform}"/>
        <then>
          <property name="compression" value="zip"/>
        </then>
        <else>
          <property name="compression" value="tgz"/>
        </else>
      </if>
      <local name="gl.platform"/>
      <switch value="@{platform}">
        <case value="macosx"><property name="gl.platform" value="macosx-universal"/></case>
        <case value="linux32"><property name="gl.platform" value="linux-i586"/></case>
        <case value="linux64"><property name="gl.platform" value="linux-amd64"/></case>
        <case value="windows32"><property name="gl.platform" value="windows-i586"/></case>
        <case value="windows64"><property name="gl.platform" value="windows-amd64"/></case>
      </switch>
      <echo message="Executing target @{target} for platform @{platform}."/>
      <antcall target="@{target}">
        <param name="platform" value="@{platform}"/>
        <param name="dist.name" value="${dist.name}"/>
        <param name="dist.compressed" value="${dist.name}.${compression}"/>
        <param name="dist.dir" value="dist/${dist.name}"/>
        <param name="dist.jre" value="dist/${dist.name}/jre"/>
        <param name="jre.remote" value="http://processing.py.s3.amazonaws.com/jre-7u25-@{platform}.tgz"/>
        <param name="jre.local.dir" value="JREs/@{platform}"/>
        <param name="jre.local.compressed" value="JREs/@{platform}.tgz"/>
        <param name="gl.platform" value="${gl.platform}"/>
      </antcall>
    </sequential>
  </macrodef>

  <macrodef name="for-all-platforms">
    <attribute name="target"/>
    <sequential>
      <for-platform platform="macosx" target="@{target}"/>
      <for-platform platform="linux32" target="@{target}"/>
      <for-platform platform="linux64" target="@{target}"/>
      <for-platform platform="windows32" target="@{target}"/>
      <for-platform platform="windows64" target="@{target}"/>
    </sequential>
  </macrodef>

  <!-- For debugging the platform macros. -->
  <target name="dump-platform">
    <echo message="Dumping ${platform}:"/>
    <echo message="  $${dist.name} = ${dist.name}"/>
    <echo message="  $${dist.dir} = ${dist.dir}"/>
    <echo message="  $${dist.compressed} = ${dist.compressed}"/>
    <echo message="  $${dist.jre} = ${dist.jre}"/>
    <echo message="  $${jre.remote} = ${jre.remote}"/>
    <echo message="  $${jre.local.dir} = ${jre.local.dir}"/>
    <echo message="  $${jre.local.compressed} = ${jre.local.compressed}"/>
    <echo message="  $${gl.platform} = ${gl.platform}"/>
  </target>
  <target name="dump-all-platforms">
    <for-all-platforms target="dump-platform"/>
  </target>

  <!--
    The following targets can only be run for particular platforms, as in
       <for-platform platform="windows64" target="targetname"/>
    They all refer to properties defined by the for-platform macro.
  -->
  <target name="getjre">
    <if>
      <not><available file="JREs/${platform}"/></not>
      <then>
        <echo message="Fetching JRE for ${platform}" />
        <get src="${jre.remote}" dest="${jre.local.compressed}" usetimestamp="true"/>
        <mkdir dir="${jre.local.dir}"/>
        <exec executable="tar" dir="JREs">
          <arg line="zxf ${platform}.tgz -C ${platform} --strip-components 1 "/>
        </exec>
        <if>
          <equals arg1="${platform}" arg2="macosx"/>
          <then>
            <echo message="Moving mac JRE to sane location."/>
            <exec executable="/bin/sh" dir="${jre.local.dir}" failonerror="true">
              <arg value="-c"/>
              <arg value="mv Contents/Home/* ."/>
            </exec>
          </then>
        </if>
      </then>
    </if>
    <chmod dir="${jre.local.dir}/bin" includes="*" perm="755"/>
  </target>

  <macrodef name="compress">
    <attribute name="from"/>
    <attribute name="to"/>
    <attribute name="dir"/>
    <sequential>
      <if>
        <matches pattern="^.*zip$" string="@{to}"/>
        <then>
          <echo message="Creating zip archive @{to}."/>
          <exec executable="zip" dir="@{dir}">
            <arg line="-q -r @{to} @{from}"/>
          </exec>
        </then>
        <else>
          <echo message="Creating gzipped tar archive @{to}."/>
          <exec executable="tar" dir="@{dir}">
            <arg line="zcfh @{to} @{from}"/>
          </exec>
        </else>
      </if>
    </sequential>
  </macrodef>

  <macrodef name="copy-processing-library">
    <attribute name="library"/>
    <attribute name="dir"/>
    <sequential>
      <mkdir dir="@{dir}/@{library}"/>
      <copy todir="@{dir}/@{library}">
        <!--
          The business about ${platform}/**, ${platform}64/** is for
          catching both macosx/*.dylib and macosx64/*.dylib, for those
          libraries that still have legacy OSX DLLs. Right now, that's
          only video.
        -->
        <fileset dir="${processing}/java/libraries/@{library}/library"
                 includes="*.txt,*.jar,${platform}/**,${platform}64/**"/>
      </copy>
    </sequential>
  </macrodef>

  <target name="check-for-platform-lib-cache">
    <uptodate property="platform-lib-cache-exists"
              srcfile="${processing}/core/library/gluegen-rt.jar"
              targetfile=".cache/libs/${platform}/opengl/gluegen-rt.jar"/>
  </target>
  <target name="platform-lib-cache"
      depends="check-for-platform-lib-cache"
      unless="platform-lib-cache-exists">
    <local name="cache"/>
    <property name="cache" value=".cache/libs/${platform}"/>
    <mkdir dir="${cache}"/>
    <mkdir dir="${cache}/opengl"/>
    <copy todir="${cache}/opengl">
      <fileset dir="${processing}/core/library" includes="*.jar" excludes="core.jar"/>
    </copy>
    <copy-processing-library dir="${cache}" library="dxf"/>
    <copy-processing-library dir="${cache}" library="lwjgl"/>
    <copy-processing-library dir="${cache}" library="minim"/>
    <copy-processing-library dir="${cache}" library="net"/>
    <copy-processing-library dir="${cache}" library="pdf"/>
    <copy-processing-library dir="${cache}" library="serial"/>
    <copy-processing-library dir="${cache}" library="video"/>
  </target>

  <target name="make-one-distribution" depends="jar,platform-lib-cache">
    <echo message="Building distribution for ${platform}" />
    <for-platform platform="${platform}" target="getjre"/>
    <rm-rf target="${dist.dir}"/>
    <mkdir dir="${dist.dir}"/>
    <copy todir="${dist.dir}">
      <fileset file="LICENSE.txt"/>
      <fileset dir="." includes="workspace/**"/>
      <fileset dir="." includes="libraries/**"/>
      <fileset dir="." includes="*.sh,*.bat,processing-py.app/**"/>
    </copy>
    <chmod file="${dist.dir}/processing-py.sh" perm="755"/>
    <chmod file="${dist.dir}/processing-py.bat" perm="755"/>
    <chmod file="${dist.dir}/processing-py.app/Contents/Resources/script" perm="755"/>
    <chmod file="${dist.dir}/processing-py.app/Contents/MacOS/processing-py" perm="755"/>

    <symlink resource="${basedir}/.cache/libs/${platform}"
        link="${basedir}/${dist.dir}/libraries/processing"/>
    <symlink resource="${basedir}/${jre.local.dir}" link="${basedir}/${dist.jre}"/>
    <symlink resource="${basedir}/examples.py" link="${basedir}/${dist.dir}/examples.py"/>
    <symlink resource="${basedir}/processing-py.jar" link="${basedir}/${dist.dir}/processing-py.jar"/>
    <symlink resource="${basedir}/processing-py-natives-${gl.platform}.jar"
        link="${basedir}/${dist.dir}/processing-py-natives-${gl.platform}.jar"/>

    <compress from="${dist.name}" to="${dist.compressed}" dir="dist"/>
  </target>

  <target name="make-all-distributions">
    <for-all-platforms target="make-one-distribution"/>
  </target>

  <!--
    $ ant –Dplatform=macosx make-distribution
  -->
  <target name="make-distribution">
    <for-platform platform="${platform}" target="make-one-distribution"/>
  </target>

  <target name="upload-one-distribution">
    <echo message="Pushing ${dist.compressed} to py.processing.org..." />
    <exec executable="/bin/sh">
      <arg value="-c"/>
      <arg value="scp -i ~/.ssh/id_rsa-processing.org dist/${dist.compressed} <EMAIL>:/var/www/py" />
    </exec>
  </target>

  <target name="upload-all-distributions">
    <echo message="If you're not feinberg, this target will fail for you."/>
    <for-all-platforms target="upload-one-distribution"/>
  </target>

  <!--
    $ ant –Dplatform=macosx upload-distribution
  -->
  <target name="upload-distribution" depends="jar">
    <for-platform platform="${platform}" target="upload"/>
  </target>

  <!--
	Testing-related targets.
  -->
  <target name="build-tests" depends="jar">
    <mkdir dir="testing/bin"/>
    <javac classpath="testing/library/junit-4.11.jar:processing-py.jar" destdir="testing/bin"
        includeantruntime="false" deprecation="true">
      <src path="testing/src"/>
    </javac>
  </target>
  <target name="runtest" depends="build-tests">
    <java classname="org.junit.runner.JUnitCore" fork="true">
      <arg value="test.jycessing.JycessingTests"/>
      <classpath>
        <pathelement location="testing/bin"/>
        <pathelement location="processing-py.jar"/>
        <pathelement location="testing/library/junit-4.11.jar"/>
        <pathelement location="testing/library/hamcrest-core-1.3.jar"/>
      </classpath>
    </java>
  </target>

  <!--
    $ ant –Dplatform=macosx test
  -->
  <target name="test">
    <for-platform platform="${platform}" target="runtest"/>
  </target>

</project>

{'fraction_non_alphanumeric': 0.20499365213711385, 'fraction_numerical': 0.005473268444068275, 'mean_word_length': 3.2798840859695724, 'pattern_counts': {'":': 0, '<': 755, '<?xml version=': 2, '>': 755, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '848374', 'n_tokens_mistral': 11354, 'n_tokens_neox': 10947, 'n_words': 2076}