build.xml 5.15 KB
Newer Older
1
<project name="cup" default ="dist" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
petter's avatar
petter committed
2 3 4
  <property name="etc"       location="etc"       />
  <property name="bin"       location="bin"       />
  <property name="lib"       location="lib"       />
5 6 7 8 9 10
  <property name="src"       location="src"      />
  <property name="java"      location="src/java"      />
  <property name="flex"      location="src/jflex"      />
  <property name="cup"       location="src/cup"       />
  <property name="classes"   location="target/classes"   />
  <property name="dist"      location="target/dist"      />
petter's avatar
petter committed
11 12 13 14 15
  <!--property name="test"      location="test"      /-->

  <!-- initialize the workspace -->
  <target name="init">
    <tstamp />
16 17
    <available file="version.txt" property="version.present" />
    <touch unless:set="version.present" file="version.txt" />
petter's avatar
petter committed
18 19
    <mkdir dir="${java}" />
    <mkdir dir="${classes}" />
20
    <mkdir dir="${dist}" />
21 22 23 24 25 26 27 28 29 30
    <loadfile property="cupversion" srcFile="version.txt" failonerror="false" />
    <property name="cupversion" value="custombuild" unless:set="cupversion"/>
    <exec executable="git" outputproperty="gitversion">
      <arg value="log"/>
      <arg value="-1"/>
      <arg value="--format=%h"/>
    </exec>
    <exec executable="git" outputproperty="changed">
      <arg value="status"/>
      <arg value="--porcelain"/>
31 32
      <redirector>
	<outputfilterchain>
33 34 35 36 37 38 39 40
	<linecontainsregexp>
	  <regexp pattern='^M.*'/>
	</linecontainsregexp>
	<tokenfilter>
	  <replaceregex pattern=".*" replace="modifications based on "/>
	</tokenfilter>
	</outputfilterchain>
	</redirector>
41
    </exec>
42
    <property name="svnversion">${changed}${gitversion}</property>
petter's avatar
petter committed
43
  </target>
petter's avatar
petter committed
44

petter's avatar
petter committed
45 46
  <property environment="env" />

petter's avatar
petter committed
47 48 49 50 51 52 53 54 55 56 57
  <path id="libraries">
     <fileset dir="${lib}">
	<include name="**/*.jar" />
     </fileset>
  </path>

  <path id="binaries">
     <fileset dir="${bin}">
	<include name="**/*.jar" />
     </fileset>
  </path>
petter's avatar
petter committed
58 59

  <target name="clean">
60 61 62
    <delete file="${java}/java_cup/parser.java" />
    <delete file="${java}/java_cup/sym.java" />
    <delete file="${java}/java_cup/Lexer.java" />
petter's avatar
petter committed
63 64 65 66
    <delete dir="${classes}" />
    <delete dir="${dist}" />
  </target>

petter's avatar
petter committed
67 68
  <taskdef name="cup" classname="java_cup.anttask.CUPTask" classpath="${bin}/java-cup-11.jar" />
  <taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="${bin}/JFlex.jar" />
petter's avatar
petter committed
69 70 71 72 73 74 75 76 77 78

  <target name="cup" depends="init">
    <cup srcfile="${cup}/parser.cup" interface="on" destdir="${java}" parser="parser" symbols="sym" quiet="false" nonterms="true"/>
  </target>

  <target name="jflex" depends="cup">
    <jflex file="${flex}/Lexer.jflex" destdir="${java}" />
  </target>

  <target name="compile" depends="jflex">
79 80
    <replace file="${java}/java_cup/version.java"
       token="+ version_str"
81
       value='+ "v0.11b ${cupversion} (GIT ${svnversion})"'>
82
    </replace>
83
    <javac srcdir="${java}" destdir="${classes}" verbose="off" listfiles="off" debug="on" source="1.8" target="1.8">
petter's avatar
petter committed
84 85 86 87 88
      <classpath refid="libraries"/>
    </javac>
  </target>

  <target name="dist" depends="compile">
petter's avatar
petter committed
89
   <jar jarfile="${dist}/java-cup-11b.jar" basedir="${classes}">
petter's avatar
petter committed
90 91
      <manifest>
        <attribute name="Main-Class" value="java_cup/Main" />
petter's avatar
petter committed
92
	<attribute name="Class-Path" value="java-cup-11b-runtime.jar" />
petter's avatar
petter committed
93 94
      </manifest>
    </jar>
95 96 97 98
    <jar jarfile="${dist}/java-cup-11b-runtime.jar" basedir="${classes}" includes="java_cup/runtime/**">
      <manifest>
	<attribute name="Class-Path" value="commons-jxpath-1.3.jar" />
      </manifest>
petter's avatar
petter committed
99
    </jar>
100 101 102 103 104 105 106 107 108 109
   <tar longfile="gnu"  destfile="${dist}/java-cup-bin-11b-${cupversion}.tar.gz" compression="gzip">
     <tarfileset dir="${dist}" username="ant" group="ant">
       <depth max="0"/>
       <include name="*.jar"/>
     </tarfileset>
   </tar>
  </target>

 <target name="src-dist" depends="dist">
   <tar longfile="gnu"  destfile="${dist}/java-cup-src-11b-${cupversion}.tar.gz" compression="gzip">
110
     <tarfileset dir="${src}" username="ant" group="ant" prefix="src">
111 112 113 114 115 116 117 118 119 120 121 122 123
       <include name="**"/>
     </tarfileset>
     <tarfileset dir="${bin}" username="ant" group="ant" prefix="bin/">
       <include name="**"/>
     </tarfileset>
     <tarfileset dir="${lib}" username="ant" group="ant" prefix="lib/">
       <include name="**"/>
     </tarfileset>
     <tarfileset dir="${src}/.." username="ant" group="ant">
       <depth max="0"/>
       <include name="*"/>
     </tarfileset>
   </tar>
petter's avatar
petter committed
124
  </target>
petter's avatar
petter committed
125

126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
  <target name="versionbump" depends="init">
    <echo message="${DSTAMP}" file="version.txt" />
  </target>  

  <target name="scp" depends="src-dist">
    <exec executable="scp">
      <arg value="${dist}/java-cup-src-11b-${cupversion}.tar.gz" />
      <arg value="${dist}/java-cup-bin-11b-${cupversion}.tar.gz" />
      <arg value="${dist}/../manual.html" />
      <arg value="petter@www2.in.tum.de:/srv/www/htdocs/projects/cup/releases" />
    </exec>
  </target>
  
  <target name="help" depends="init">
    <echo message="Targets:" />
    <echo message="  dist           to create CUP jars" />
    <echo message="  src-dist       to create release packages" />
    <echo message="  scp            to deploy relase to homepage" />
    <echo message="  versionbump    to inc release" />
  </target>
petter's avatar
petter committed
146
</project>