diff options
Diffstat (limited to 'make/build.xml')
-rwxr-xr-x | make/build.xml | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/make/build.xml b/make/build.xml new file mode 100755 index 0000000..440d194 --- /dev/null +++ b/make/build.xml @@ -0,0 +1,163 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + - Ant build for GlueGen and corresponding ANT tasks. Also builds + - JOGL-specific BuildStaticGLInfo and its corresponding ANT task. + - + - This build has been tested with ANT 1.6.2 and ANTLR 2.7.4. + - + - Public targets: + - all: clean and build GlueGen and GlueGen Ant task + - clean: clean all built + --> +<project name="GlueGen" basedir="." default="all"> + <target name="load.user.properties" unless="user.properties.file"> + <!-- Load the user specified properties file that defines various host + - specific paths. The user will be notified if this is does not + - exist. --> + <property name="user.properties.file" value="${user.home}/gluegen.properties" /> + <property file="${user.properties.file}" /> + <echo message="Loaded ${user.properties.file}." /> + <fail message="antlr.jar was not specified in gluegen.properties. Please see README.txt for instructions" unless="antlr.jar"/> + <echo message="antlr.jar=${antlr.jar}" /> + </target> + + <target name="init" depends="load.user.properties"> + <!-- Declare all paths and user defined variables. --> + + <!-- The source directories. --> + <property name="src.java" value="../src/java" /> + <property name="build" value="../build" /> + + <!-- The generated source directories. --> + <property name="src.generated" value="../build/gensrc" /> + <property name="src.generated.java" value="../build/gensrc/java" /> + + <!-- The compiler output directories. --> + <property name="classes" value="${build}/classes" /> + + <!-- Call the external config validator script to make sure the config is ok and consistent --> + <ant antfile="validate-properties.xml" inheritall="true"/> + + <!-- Create the required output directories. --> + <mkdir dir="${src.generated.java}" /> + <mkdir dir="${classes}" /> + + <!-- Create the classpath for ANTLR. This requires the user-defined + - "antlr.jar" property. --> + <path id="antlr.classpath"> + <pathelement location="${antlr.jar}" /> + </path> + + <!-- The location of the GlueGen source and the C grammar files. --> + <property name="gluegen" value="${src.java}/com/sun/gluegen" /> + <property name="c.grammar" value="${gluegen}/cgram" /> + + <!-- The resulting location of the generated Java files from the + - C grammar via ANTLR. --> + <property name="gluegen.build" value="${src.generated.java}/com/sun/gluegen" /> + <property name="generated.java.from.grammar" value="${gluegen.build}/cgram" /> + </target> + + <!-- + - Using ANTLR generate the specified Java files. + - + - @param target the grammar file to process + - @param output.dir the directory to write the generated files to. If + - the directory does not exist, it will be created. + --> + <target name="generate.c.grammar"> + <!-- Generate the Java files --> + <antlr target="${output.dir}/${target}" outputdirectory="${output.dir}"> + <classpath refid="antlr.classpath" /> + </antlr> + </target> + + <!-- + - Using ANTLR generate the specified Java files with an overridden + - grammar file. + - + - @param target the grammar file to process + - @param glib the overridding grammar file + - @param output.dir the directory to write the generated files to. If + - the directory does not exist, it will be created. + --> + <target name="generate.c.grammar.glib"> + <!-- Generate the Java files --> + <antlr target="${output.dir}/${target}" glib="${output.dir}/${glib}" outputdirectory="${output.dir}"> + <classpath refid="antlr.classpath" /> + </antlr> + </target> + + <!-- ================================================================== --> + <!-- + - Build GlueGen. + --> + <target name="gluegen.build" depends="init"> + <!-- Because ANTLR looks for importVocab files in the current + working directory, it likes to have all of its files, + including supergrammars, in one place, so copy all of the + grammars to the output directory up front so we don't put + temporary files into the source tree --> + <mkdir dir="${generated.java.from.grammar}" /> + <copy todir="${generated.java.from.grammar}"> + <fileset dir="${c.grammar}"> + <include name="*.g" /> + </fileset> + </copy> + + <!-- Generate the Java files from the C grammar using ANTLR. --> + <antcall target="generate.c.grammar"> + <param name="output.dir" value="${generated.java.from.grammar}" /> + <param name="target" value="StdCParser.g" /> + </antcall> + <antcall target="generate.c.grammar.glib"> + <param name="output.dir" value="${generated.java.from.grammar}" /> + <param name="target" value="GnuCParser.g" /> + <param name="glib" value="StdCParser.g" /> + </antcall> + <antcall target="generate.c.grammar"> + <param name="output.dir" value="${generated.java.from.grammar}" /> + <param name="target" value="GnuCTreeParser.g" /> + </antcall> + <antcall target="generate.c.grammar.glib"> + <param name="output.dir" value="${generated.java.from.grammar}" /> + <param name="target" value="GnuCEmitter.g" /> + <param name="glib" value="GnuCTreeParser.g" /> + </antcall> + <antcall target="generate.c.grammar.glib"> + <param name="output.dir" value="${generated.java.from.grammar}" /> + <param name="target" value="HeaderParser.g" /> + <param name="glib" value="GnuCTreeParser.g" /> + </antcall> + + <!-- Build GlueGen using the generated Java files along with the + - original source. --> + <javac destdir="${classes}" source="1.4" debug="true" debuglevel="source,lines"> + <src path="${src.java}" /> + <src path="${src.generated.java}" /> + <classpath refid="antlr.classpath" /> + </javac> + + <!-- Build gluegen.jar. --> + <jar destfile="${build}/gluegen.jar"> + <fileset dir="${classes}"> + <include name="**/*.class" /> + </fileset> + </jar> + + <!-- Build gluegen-rt.jar. --> + <jar destfile="${build}/gluegen-rt.jar"> + <fileset dir="${classes}"> + <include name="com/sun/gluegen/runtime/*.class" /> + </fileset> + </jar> + </target> + + <target name="all" depends="gluegen.build" /> + + <target name="clean"> + <delete includeEmptyDirs="true" quiet="true"> + <fileset dir="../build" /> + </delete> + </target> +</project> |