antlr/build.xml

286 lines
12 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project name="ANTLR4" default="distribute" basedir=".">
<target name="basic-init">
<property file="user.build.properties"/>
<property name="dist.dir" value="${basedir}/dist" />
<property name="build.dir" value="${basedir}/build" />
<property name="lib.dir" value="${basedir}/lib" />
</target>
<target name="antlr3-init" depends="basic-init">
<property name="antlr3.version" value="3.5"/>
<property name="antlr3.jar.name" value="antlr-${antlr3.version}-complete-no-st3.jar"/>
<property name="antlr3.jar" value="${lib.dir}/${antlr3.jar.name}"/>
<mkdir dir="${lib.dir}"/>
<get src="http://antlr3.org/download/${antlr3.jar.name}" dest="${antlr3.jar}" skipexisting="true"/>
<path id="cp.antlr3" path="${antlr3.jar}"/>
<property name="build.antlr3.dir" value="${build.dir}/generated-sources/antlr3" />
<property name="antlr3.touch" value="${build.dir}/antlr3-${antlr3.version}.touch"/>
</target>
<target name="antlr4-init" depends="basic-init">
<property name="antlr4.version" value="4.1"/>
<property name="antlr4.jar.name" value="antlr-${antlr4.version}-complete.jar"/>
<property name="antlr4.jar" value="${lib.dir}/${antlr4.jar.name}"/>
<mkdir dir="${lib.dir}"/>
<get src="http://antlr.org/download/${antlr4.jar.name}" dest="${antlr4.jar}" skipexisting="true"/>
<path id="cp.antlr4" path="${antlr4.jar}"/>
<property name="build.antlr4.dir" value="${build.dir}/generated-sources/antlr4" />
<property name="antlr4.touch" value="${build.dir}/antlr4-${antlr4.version}.touch"/>
</target>
<target name="build-init" depends="basic-init">
<property name="version" value="4.1.1-dev"/>
<property name="build.sysclasspath" value="ignore"/>
<property name="install.root.dir" value="${dist.dir}/antlr-${version}" />
<property name="jar.file" value="${dist.dir}/antlr-${version}-complete.jar" />
</target>
<target name="clean" depends="basic-init">
<delete dir="${build.dir}" includeemptydirs="true"/>
<delete dir="${dist.dir}" includeemptydirs="true"/>
</target>
<target name="clean-all" depends="clean">
<delete dir="${lib.dir}" includeemptydirs="true"/>
</target>
<target name="antlr3-up-to-date" depends="basic-init,antlr3-init">
<uptodate targetfile="${antlr3.touch}" property="is.antlr3.uptodate">
<srcfiles dir="${basedir}/tool/src">
<include name="**/*.g"/>
<include name="**/*.tokens"/>
</srcfiles>
<srcfiles file="${antlr3.jar}"/>
</uptodate>
</target>
<target name="antlr4-up-to-date" depends="basic-init,antlr4-init">
<uptodate targetfile="${antlr4.touch}" property="is.antlr4.uptodate">
<srcfiles dir="${basedir}/tool/src">
<include name="**/*.g4"/>
<include name="**/*.tokens"/>
</srcfiles>
<srcfiles file="${antlr4.jar}"/>
</uptodate>
</target>
<target name="up-to-date" depends="antlr3-up-to-date,antlr4-up-to-date,build-init">
<uptodate targetfile="${jar.file}" property="is.source.uptodate">
<srcfiles dir="${basedir}/tool/src">
<include name="**/*.java"/>
<include name="**/*.g"/>
<include name="**/*.tokens"/>
</srcfiles>
<srcfiles dir="${basedir}/tool/resources">
<include name="**/*.st"/>
<include name="**/*.stg"/>
</srcfiles>
<srcfiles dir="${basedir}/runtime/Java/src/">
<include name="**/*.java"/>
<include name="**/*.g"/>
<include name="**/*.st"/>
<include name="**/*.stg"/>
</srcfiles>
<srcfiles dir="${build.antlr3.dir}"/>
<srcfiles file="${basedir}/runtime/Java/lib/org.abego.treelayout.core.jar"/>
<srcfiles file="${antlr3.jar}"/>
</uptodate>
<condition property="is.jar.uptodate">
<and>
<istrue value="${is.source.uptodate}"/>
<istrue value="${is.antlr3.uptodate}"/>
</and>
</condition>
</target>
<macrodef name="antlr3">
<attribute name="srcpath"/>
<element name="args" optional="true"/>
<sequential>
<local name="path.antlr3.local"/>
<local name="sources.antlr3.local"/>
<path id="path.antlr3.local">
<fileset dir="${basedir}/tool/src/@{srcpath}" includes="*.g"/>
</path>
<pathconvert pathsep=" " property="sources.antlr3.local" refid="path.antlr3.local">
<map from="${basedir}/tool/src/@{srcpath}/" to=""/>
</pathconvert>
<mkdir dir="${build.antlr3.dir}/@{srcpath}"/>
<java classname="org.antlr.Tool" fork="true" failonerror="true" maxmemory="300m"
dir="${basedir}/tool/src/@{srcpath}">
<arg value="-o"/>
<arg value="${build.antlr3.dir}/@{srcpath}"/>
<args/>
<arg line="${sources.antlr3.local}"/>
<classpath>
<path refid="cp.antlr3"/>
<pathelement location="${java.class.path}"/>
</classpath>
</java>
</sequential>
</macrodef>
<macrodef name="antlr4">
<attribute name="srcpath"/>
<element name="args" optional="true"/>
<sequential>
<local name="path.antlr4.local"/>
<local name="sources.antlr4.local"/>
<path id="path.antlr4.local">
<fileset dir="${basedir}/runtime/Java/src/@{srcpath}" includes="*.g4"/>
</path>
<pathconvert pathsep=" " property="sources.antlr4.local" refid="path.antlr4.local">
<map from="${basedir}/runtime/Java/src/@{srcpath}/" to=""/>
</pathconvert>
<mkdir dir="${build.antlr4.dir}/@{srcpath}"/>
<java classname="org.antlr.v4.Tool" fork="true" failonerror="true" maxmemory="300m"
dir="${basedir}/runtime/Java/src/@{srcpath}">
<arg value="-o"/>
<arg value="${build.antlr4.dir}/@{srcpath}"/>
<args/>
<arg line="${sources.antlr4.local}"/>
<classpath>
<path refid="cp.antlr4"/>
<pathelement location="${java.class.path}"/>
</classpath>
</java>
</sequential>
</macrodef>
<target name="antlr3" depends="build-init,antlr3-init,antlr3-up-to-date" unless="is.antlr3.uptodate">
<mkdir dir="${build.antlr3.dir}" />
<path id="sources.antlr3">
<fileset dir="${basedir}/tool/src" includes="**/*.g"/>
</path>
<pathconvert pathsep="${line.separator} " property="echo.sources.antlr3" refid="sources.antlr3">
<map from="${basedir}/tool/src/" to=""/>
</pathconvert>
<echo message="Generating ANTLR 3 grammars:${line.separator} ${echo.sources.antlr3}"/>
<antlr3 srcpath="org/antlr/v4/parse"/>
<antlr3 srcpath="org/antlr/v4/codegen">
<args>
<arg value="-lib"/>
<arg value="${build.antlr3.dir}/org/antlr/v4/parse"/>
</args>
</antlr3>
<touch file="${antlr3.touch}" mkdirs="true"/>
</target>
<target name="antlr4" depends="build-init,antlr4-init,antlr4-up-to-date" unless="is.antlr4.uptodate">
<mkdir dir="${build.antlr4.dir}" />
<path id="sources.antlr4">
<fileset dir="${basedir}/runtime/Java/src" includes="**/*.g4"/>
</path>
<pathconvert pathsep="${line.separator} " property="echo.sources.antlr4" refid="sources.antlr4">
<map from="${basedir}/runtime/Java/src/" to=""/>
</pathconvert>
<echo message="Generating ANTLR 4 grammars:${line.separator} ${echo.sources.antlr4}"/>
<antlr4 srcpath="org/antlr/v4/runtime/tree/xpath">
<args>
<arg value="-package"/>
<arg value="org.antlr.v4.runtime.tree.xpath"/>
</args>
</antlr4>
<touch file="${antlr4.touch}" mkdirs="true"/>
</target>
<target name="compile" depends="build-init,antlr3,antlr4,up-to-date" description="Compile for generic OS" unless="is.jar.uptodate">
<mkdir dir="${build.dir}/classes"/>
<javac
destdir="${build.dir}/classes"
source="1.5"
target="1.5"
debug="true"
excludes="org/antlr/v4/test/**">
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
<classpath>
<path refid="cp.antlr3"/>
<pathelement location="${basedir}/runtime/Java/lib/org.abego.treelayout.core.jar"/>
</classpath>
<src path="${basedir}/tool/src:${basedir}/runtime/JavaAnnotations/src:${basedir}/runtime/Java/src:${build.antlr3.dir}:${build.antlr4.dir}"/>
</javac>
</target>
<target name="build-jar" depends="up-to-date,compile" description="Build ANTLR 4.jar" unless="is.jar.uptodate">
<mkdir dir="${dist.dir}"/>
<jar jarfile="${jar.file}">
<fileset dir="${build.dir}/classes" includes="**/*.class"/>
<fileset dir="${basedir}/tool/resources">
<include name="**/*.st"/>
<include name="**/*.stg"/>
</fileset>
<zipfileset includes="org/antlr/**, org/antlr/stringtemplate/**, org/stringtemplate/v4/**" src="${antlr3.jar}"/>
<zipfileset includes="**/*.class" src="${basedir}/runtime/Java/lib/org.abego.treelayout.core.jar"/>
<manifest>
<attribute name="Version" value="${version}"/>
<attribute name="Main-Class" value="org.antlr.v4.Tool"/>
</manifest>
</jar>
</target>
<target name="zip-source" depends="compile">
<mkdir dir="${install.root.dir}"/>
<mkdir dir="${install.root.dir}/src"/>
<copy todir="${install.root.dir}/src">
<fileset dir="${basedir}/tool/src/">
<include name="**/*.java"/>
<include name="**/*.g"/>
<include name="**/*.st"/>
<include name="**/*.stg"/>
</fileset>
<fileset dir="${basedir}/tool/resources/">
<include name="**/*.st"/>
<include name="**/*.stg"/>
</fileset>
<fileset dir="${basedir}/runtime/JavaAnnotations/resources/">
<include name="**/*.Processor"/>
</fileset>
<fileset dir="${basedir}/runtime/JavaAnnotations/src/">
<include name="**/*.java"/>
</fileset>
<fileset dir="${basedir}/runtime/Java/src/">
<include name="**/*.java"/>
<include name="**/*.g"/>
<include name="**/*.st"/>
<include name="**/*.stg"/>
</fileset>
<fileset dir="${build.antlr3.dir}"/>
</copy>
<copy todir="${install.root.dir}">
<fileset dir=".">
<include name="build.properties"/>
<include name="build.xml"/>
<include name="LICENSE.txt"/>
<include name="README.md"/>
<include name="doxyfile"/>
</fileset>
</copy>
<copy todir="${install.root.dir}/lib" file="${antlr3.jar}">
</copy>
<zip destfile="${dist.dir}/antlr-${version}-src.zip">
<zipfileset dir="${install.root.dir}" prefix="antlr-${version}"/>
</zip>
</target>
<target name="distribute" depends="clean, zip-source, build-jar">
</target>
</project>