Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

530 lines (481 sloc) 20.652 kb
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
processing.py
Write processing sketches in Python.
This ant build file contains targets both for "Python Mode" for the
Processing Development Environment and for the standalone processing.py
distribution.
This has been tested on Mac OSX and linux. It is not expected to work at
all on Windows.
-jdf
Run
ant test - to run unit tests.
ant mode.zip - to create a Python Mode zip file.
ant make-all-distributions - to create a processing.py release.
ant -Dplatform=macosx make-distribution - to create the OSX processing.py release.
====================================================================== -->
<project name="processing.py" default="mode.zip">
<description>Write Processing sketches in Python</description>
<!--
You can specify the location of the Processing source code by passing
it to ant via -Dprocessing=/path/to/processing
By default, we'll look in a directory next to this one.
The same goes for processing-video (https://github.com/processing/processing-video).
-->
<property name="processing" value="../processing"/>
<property name="processing-video" value="../processing-video"/>
<!-- for <if> and <foreach> tags. -->
<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"/>
<property name="guava" value="buildtime/lib/java/guava-17.0.jar"/>
<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>
<macrodef name="push">
<attribute name="srcfile"/>
<sequential>
<echo message="Pushing @{srcfile} to py.processing.org..." />
<exec executable="/bin/sh" failonerror="true">
<arg value="-c"/>
<arg value="scp -i ~/.ssh/id_rsa-processing.org -r @{srcfile} jdf@py.processing.org:/var/www/py" />
</exec>
</sequential>
</macrodef>
<target name="bumpversion">
<propertyfile
file="runtime/src/jycessing/build.properties"
comment="Python mode build number">
<entry key="build.date" type="date" value="now"/>
<entry key="build.number" type="int" default="0300" operation="+" pattern="0000"/>
</propertyfile>
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<echo message="Bumped to version ${jycessing.build.number}."></echo>
</target>
<target name="mode.jar" depends="build">
<jar destfile="work/PythonMode.jar">
<fileset dir="bin" excludes="jycessing/build/**,test/**"/>
</jar>
</target>
<target name="mode.dist" depends="mode.jar">
<delete dir="work/modedist" />
<property name="bundle" value="work/modedist/PythonMode"/>
<mkdir dir="${bundle}" />
<copy todir="${bundle}" file="LICENSE.txt"/>
<mkdir dir="${bundle}/mode" />
<copy todir="${bundle}/mode" file="work/PythonMode.jar"/>
<copy todir="${bundle}/mode" file="${guava}"/>
<copy todir="${bundle}/mode" file="${jython}"/>
<copy tofile="${bundle}/mode/LICENSE.jython" file="${jython.license}"/>
<copy todir="${bundle}">
<fileset dir="mode/" />
</copy>
<copy todir="${bundle}/theme" file="libraries/runtime/splash.png"/>
<zip destfile="${bundle}/src.zip" basedir="."
includes="runtime/src/**,testing/src/**,testing/resources/**"
excludes="**/_DS.Store" />
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<replaceregexp file="${bundle}/mode.properties" flags="g"
match="@@version@@" replace="${jycessing.build.number}" />
<replaceregexp file="${bundle}/mode.properties" flags="g"
match="@@pretty-version@@"
replace="Build ${jycessing.build.number}, built ${jycessing.build.date}" />
<copy tofile="work/modedist/PythonMode.txt" file="${bundle}/mode.properties"/>
</target>
<target name="mode.zip" depends="mode.dist">
<zip destfile="work/PythonMode.zip" basedir="work/modedist"
excludes="PythonMode.txt,**/_DS.Store" />
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<copy file="work/PythonMode.zip" tofile="work/PythonMode_${jycessing.build.number}.zip" />
</target>
<target name="mode.upload" depends="mode.zip">
<push srcfile="work/PythonMode.zip"/>
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<push srcfile="work/PythonMode_${jycessing.build.number}.zip"/>
<push srcfile="work/modedist/PythonMode.txt"/>
<echo message="Uploaded build ${jycessing.build.number}"></echo>
</target>
<target name="jar" depends="build">
<jar destfile="work/processing-py.jar">
<fileset dir="bin" excludes="jycessing/build/**,test/**"/>
<zipgroupfileset file="${guava}"/>
<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>
<foreach
list="macosx-universal,linux-i586,linux-amd64,windows-i586,windows-amd64"
param="natives.platform"
target="jar.natives"/>
</target>
<target name="jar.natives">
<jar destfile="work/processing-py-natives-${natives.platform}.jar">
<zipgroupfileset
file="${processing}/core/library/gluegen-rt-natives-${natives.platform}.jar"/>
<zipgroupfileset
file="${processing}/core/library/jogl-all-natives-${natives.platform}.jar"/>
</jar>
</target>
<target name="build" depends="build-processing,build-pde,build-video">
<mkdir dir="bin"/>
<javac destdir="bin" includeantruntime="false">
<src path="runtime/src"/>
<classpath>
<pathelement location="${jython}"/>
<pathelement location="${corejar}"/>
<pathelement location="${pdejar}"/>
<pathelement location="${guava}"/>
</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" inheritAll="false"/>
</target>
<target name="check-video-needs-build">
<uptodate property="video-is-uptodate"
targetfile="${processing-video}/library/video.jar">
<srcfiles dir="${processing-video}/src/processing/video"/>
</uptodate>
</target>
<target name="build-video"
depends="check-video-needs-build"
unless="video-is-uptodate">
<echo message="Building processing-video." />
<ant dir="${processing-video}" target="build"/>
</target>
<target name="clean-self">
<rm-rf target="bin"/>
<rm-rf target="dist"/>
<rm-rf target=".cache"/>
<rm-rf target="work"/>
<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="clean" depends="clean-self">
<ant dir="${processing}/build" target="clean"/>
</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 file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<property name="dist.name" value="processing.py-${jycessing.build.number}-@{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-7u72-@{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">
<condition property="platform-lib-cache-exists">
<and>
<uptodate srcfile="${processing}/core/library/gluegen-rt.jar"
targetfile=".cache/libs/${platform}/opengl/gluegen-rt.jar"/>
<uptodate srcfile="${processing-video}/library/video.jar"
targetfile=".cache/libs/${platform}/video/video.jar"/>
</and>
</condition>
</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 todir="${cache}/video">
<fileset dir="${processing-video}/library"
includes="*.txt,*.jar,${platform}/**,${platform}64/**"/>
</copy>
<copy-processing-library dir="${cache}" library="dxf"/>
<copy-processing-library dir="${cache}" library="lwjgl"/>
<copy-processing-library dir="${cache}" library="net"/>
<copy-processing-library dir="${cache}" library="pdf"/>
<copy-processing-library dir="${cache}" library="serial"/>
</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}/work/processing-py.jar" link="${basedir}/${dist.dir}/processing-py.jar"/>
<symlink resource="${basedir}/work/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">
<push srcfile="dist/${dist.compressed}"/>
</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:work/processing-py.jar"
destdir="testing/bin"
includeantruntime="false" deprecation="true">
<src path="testing/src"/>
</javac>
</target>
<target name="test.standalone" depends="build-tests">
<junit fork="true" haltonfailure="true">
<test name="test.jycessing.JycessingTests">
<formatter type="plain" usefile="false"/>
</test>
<classpath>
<pathelement location="testing/bin"/>
<pathelement location="work/processing-py.jar"/>
<pathelement location="testing/library/junit-4.11.jar"/>
<pathelement location="testing/library/hamcrest-core-1.3.jar"/>
</classpath>
</junit>
</target>
<target name="test.mode" depends="build-tests,mode.jar">
<junit fork="true" haltonfailure="true">
<test name="test.jycessing.JycessingTests">
<formatter type="plain" usefile="false"/>
</test>
<classpath>
<pathelement location="testing/bin"/>
<pathelement location="${corejar}"/>
<pathelement location="${processing}/core/library/gluegen-rt.jar"/>
<pathelement location="${processing}/core/library/jogl-all.jar"/>
<pathelement location="work/PythonMode.jar"/>
<pathelement location="${guava}"/>
<pathelement location="${jython}"/>
<pathelement location="testing/library/junit-4.11.jar"/>
<pathelement location="testing/library/hamcrest-core-1.3.jar"/>
</classpath>
</junit>
</target>
<target name="test" depends="test.mode,test.standalone"/>
</project>
Jump to Line
Something went wrong with that request. Please try again.