Skip to content

Instantly share code, notes, and snippets.

@monkstone
Created November 11, 2013 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monkstone/7414856 to your computer and use it in GitHub Desktop.
Save monkstone/7414856 to your computer and use it in GitHub Desktop.
Build file for python mode processing
<?xml version="1.0"?>
<project name="ProcessingPythonMode" default="release" basedir="./">
<!-- Based on mode template http://github.com/martinleopold/TemplateMode -->
<!-- Note: now compiles two separate jars- one for python mode, and one that's a wrapper for the processing core that can run python files -->
<!-- You'll want to change these to compile. -->
<property name="processing.base" location="/usr/share/processing" /> <!-- The directory that you unpacked Processing into. -->
<property name="processing.sketchfolder" location="/home/tux/sketchbook" /> <!-- Your sketchbook folder. -->
<property name="java.target.bootclasspath" location="/opt/jdk1.7.0_45/jre/rt.jar" /> <!-- If you're using a newer jdk -->
<!-- Leave these be. -->
<description>Python Mode for Processing 2.0.</description>
<property name="lib.name" value="PythonMode" />
<property name="wrap.name" value="ProcessingJythonWrapper" />
<property name="release" value="0.1" />
<property name="java.target.version" value="1.7" />
<property name="src" value="src" />
<property name="gen" value="generated" />
<property name="build" value="build" />
<property name="dist" value="dist" />
<property name="releasedir" value="release" />
<property name="lib.path" value="info/sansgills/mode/python" />
<property name="wrap.path" value="info/sansgills/mode/python/wrapper" />
<property name="preproc.path" value="info/sansgills/mode/python/preproc" />
<path id="library-classpath">
<fileset dir="${processing.base}/core/library/" > <!-- processing core -->
<include name="*.jar" />
</fileset>
<fileset dir="${processing.base}/lib/" > <!-- pde and ant -->
<include name="*.jar" />
</fileset>
<fileset dir="lib" >
<include name="*.jar" /> <!-- jython and antlr runtime -->
</fileset>
</path>
<condition property="gen.present">
<available file="${gen}" />
</condition>
<!-- - - - - - - - - - - - - - - - - - - - - - -
GET
- - - - - - - - - - - - - - - - - - - - - - - -->
<target name="get">
<mkdir dir="lib" />
<mkdir dir="tool" />
<get
src="http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7-b1/jython-standalone-2.7-b1.jar"
dest="lib/jython-standalone-2.7-b1.jar"
skipexisting="true"
verbose="true" /> <!-- download latest jython (note: update this if jython updates) -->
<get
src="http://www.antlr.org/download/antlr-runtime-4.1.jar"
dest="lib/antlr-runtime-4.1.jar"
skipexisting="true"
verbose="true" /> <!-- download latest ANTLR runtime (to include with the mode) -->
<get
src="http://antlr4.org/download/antlr-4.1-complete.jar"
dest="tool/antlr-4.1-complete.jar"
skipexisting="true"
verbose="true" /> <!-- download latest ANTLR compiler (to compile our grammars; not included) -->
</target>
<target name="generate" depends="get" unless="gen.present">
<mkdir dir="${gen}" />
<java jar="tool/antlr-4.1-complete.jar" fork="true">
<arg value="-lib" />
<arg value="${basedir}/${src}/${preproc.path}" />
<arg value="-o" />
<arg value="${basedir}/${gen}/${preproc.path}" />
<arg value="${basedir}/${src}/${preproc.path}/PyPde.g4" />
</java>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - -
BUILD
- - - - - - - - - - - - - - - - - - - - - - - -->
<target name="build" depends="get,generate">
<propertyfile file="build.number" /> <!-- create the build.number file if it doesn't exist -->
<buildnumber file="build.number" />
<mkdir dir="${build}" />
<javac destdir="${build}" source="${java.target.version}" target="${java.target.version}" bootclasspath="${java.target.bootclasspath}" includeantruntime="false" debug="true">
<src path="${src}" />
<src path="${gen}" />
<classpath>
<path refid="library-classpath"/>
</classpath>
</javac>
<copy file="${src}/${wrap.path}/prepend.py" tofile="${build}/${wrap.path}/prepend.py" />
<copy file="${src}/${wrap.path}/scrub.py" tofile="${build}/${wrap.path}/scrub.py" />
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - -
PACKAGE
- - - - - - - - - - - - - - - - - - - - - - - -->
<target name="package" depends="build">
<delete dir="${dist}" />
<property name="bundle" value="${dist}/${lib.name}"/>
<mkdir dir="${bundle}" />
<mkdir dir="${bundle}/mode" />
<!-- make mode jar -->
<jar jarfile="${bundle}/mode/${lib.name}.jar" basedir="build" includes="${lib.path}/*.class ${preproc.path}/*.class"/>
<!-- make wrapper jar -->
<jar jarfile="${bundle}/mode/${wrap.name}.jar" basedir="build" includes="${wrap.path}/*"/> <!-- include *.py -->
<copy todir="${bundle}">
<fileset dir="resources/" />
</copy>
<copy todir="${bundle}/examples">
<fileset dir="examples/" />
</copy>
<copy todir="${bundle}/mode">
<fileset dir="lib/" />
</copy>
<replaceregexp file="${bundle}/mode.properties" flags="g"
match="@@version@@" replace="${build.number}" />
<replaceregexp file="${bundle}/mode.properties" flags="g"
match="@@pretty-version@@" replace="${release}" />
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - -
INSTALL
- - - - - - - - - - - - - - - - - - - - - - - -->
<target name="install" depends="package" >
<delete dir="${processing.sketchfolder}/modes/${lib.name}" />
<copy todir="${processing.sketchfolder}/modes/">
<fileset dir="${dist}" />
</copy>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - -
RELEASE
- - - - - - - - - - - - - - - - - - - - - - - -->
<target name="release" depends="package" >
<zip destfile="${releasedir}/${lib.name}.zip" basedir="${dist}/${lib.name}" />
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - -
CLEAN
- - - - - - - - - - - - - - - - - - - - - - - -->
<target name="clean" >
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
<target name="cleangen" depends="clean" >
<delete dir="${gen}" />
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment