build.xml 5.21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<!-- 
 * Copyright (C) 2006,2010  Anders Nilsson <anders.nilsson@control.lth.se>
 *
 * This file is part of OntologyCompiler.
 *
 * OntologyCompiler is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * OntologyCompiler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 
 * You should have received a copy of the GNU General Public License
 * along with OntologyCompiler.  If not, see <http://www.gnu.org/licenses/>.
 *-->

Anders Nilsson's avatar
Anders Nilsson committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<!--
    Targets for working from terminal window:
    build (default) - generates java files and compiles them
    clean           - removes all generated files and class files
    Targets for working from Eclipse:
    gen             - generates java files
    genClean        - removes all generated files and their class files
  -->
<project name="Java1.4Frontend" default="build" basedir=".">

  <!-- "package" is the directory where generated files will be stored -->
  <property name="package" value="AST"/>

  <!-- "tools" is the directory where generators and libraries are located. -->
  <property name="tools" value="tools"/>
35 36

  <property name="javacc.home" value="tools/javacc-4.0"/>
Anders Nilsson's avatar
Anders Nilsson committed
37
  
38 39
  <property name="parser.name" value="OwlParser"/>
  
Anders Nilsson's avatar
Anders Nilsson committed
40
  <!-- "jflex" is an ant task class for the scanner generator in JFlex.jar -->
41
<!--   <taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/> -->
Anders Nilsson's avatar
Anders Nilsson committed
42
  <!-- "beaver" is an ant task class for the parser generator in beaver.jar -->
43
<!--   <taskdef name="beaver" classname="beaver.comp.run.AntTask" classpath="tools/beaver.jar"/> -->
Anders Nilsson's avatar
Anders Nilsson committed
44 45 46 47 48
  <!-- "jastadd" is an ant task class in jastadd2.jar -->
  <taskdef name="jastadd" classname="jastadd.JastAddTask" classpath="tools/jastadd2.jar"/>

  <!-- compile sources -->
  <target name="build" depends="gen">
49
    <javac  debug="true" nowarn="true" srcdir="." includes="AST/*.java *.java" excludes="tools/** " classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/>
Anders Nilsson's avatar
Anders Nilsson committed
50 51 52
  </target>
  
  <!-- generate compiler source files -->
53
  <target name="gen" description="Generate compiler source files">
Anders Nilsson's avatar
Anders Nilsson committed
54 55
    <!-- create AST node types and weave aspect modules -->
    <echo message = "Running JastAdd"/>
56
<!--     <jastadd package="${package}" rewrite="true" beaver="true" novisitcheck="true"> -->
57
    <jastadd package="${package}" grammar="${parser.name}" rewrite="true" jjtree="true">
Anders Nilsson's avatar
Anders Nilsson committed
58
      <fileset dir=".">
59 60 61
	<include name="*.ast"/>
	<include name="*.jrag"/>
	<include name="*.jadd"/>
Anders Nilsson's avatar
Anders Nilsson committed
62 63
      </fileset>
    </jastadd>
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    <jjtree 
       target="owl.jjt" 
       outputdirectory="${package}" 
       javacchome="${javacc.home}"
       buildnodefiles="true"
       static="false"
       multi="true"
       visitor="true"
       nodedefaultvoid="true"
       nodeprefix='""'
       nodepackage="${package}"
       />
    <javacc
       target="${package}/owl.jj"
       outputdirectory="${package}"
       javacchome="${javacc.home}"
       buildparser="true"
       buildtokenmanager="true"
       static="false"
       />
84

Anders Nilsson's avatar
Anders Nilsson committed
85
    <!-- generate the scanner -->
86 87
<!--     <echo message = "Running jflex"/> -->
<!--     <jflex file="parser/java14.flex" outdir="parser" nobak="yes"/> -->
Anders Nilsson's avatar
Anders Nilsson committed
88
    <!-- generate the scanner -->
89
<!--     <jflex file="parser/unicode.flex" outdir="parser" nobak="yes"/> -->
Anders Nilsson's avatar
Anders Nilsson committed
90
    <!-- generate the parser phase 1, create a full .lalr specification from fragments-->
91 92 93 94 95 96
<!--     <echo message = "Running parser phase 1"/> -->
<!--     <concat destfile="parser/JavaParser.all" binary="true"> -->
<!--       <fileset dir="."> -->
<!-- 	<include name="parser/java14.parser"/> -->
<!--       </fileset> -->
<!--     </concat> -->
Anders Nilsson's avatar
Anders Nilsson committed
97
    <!-- generate the parser phase 2, translating .lalr to .beaver -->
98 99 100
<!--     <java classpath="${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main"> -->
<!--       <arg line="parser/JavaParser.all parser/JavaParser.beaver"/> -->
<!--     </java> -->
Anders Nilsson's avatar
Anders Nilsson committed
101
    <!-- generate the parser phase 3, translating .beaver to .java -->
102
<!--     <beaver file="parser/JavaParser.beaver" terminalNames="yes" compress="no" useSwitch="yes"/> -->
Anders Nilsson's avatar
Anders Nilsson committed
103 104
  </target>

105 106 107 108 109 110
  <target name="test" depends="build">
    <java classname="GenCompiler" classpath=".">
      <arg value="GripperOntology_experimental3.owl" />
    </java>
  </target>

Anders Nilsson's avatar
Anders Nilsson committed
111 112 113 114 115 116 117 118 119
  <!-- remove generated source files and .class files -->
  <target name="clean" depends="cleanGen">
    <!-- delete all .class files recursively -->
    <delete>
      <fileset dir="." includes="**/*.class" excludes="beaver/*.class"/>
    </delete>
  </target>

  <target name="jar" depends="build">
Anders Nilsson's avatar
Anders Nilsson committed
120
    <jar destfile="OntologyCompiler.jar" basedir="." includes="**/*.class" excludes="test/**">
Anders Nilsson's avatar
Anders Nilsson committed
121
      <manifest>
122
	<attribute name="Main-Class" value="GenCompiler"/>
Anders Nilsson's avatar
Anders Nilsson committed
123 124 125 126 127 128 129 130 131 132
      </manifest>
    </jar>
  </target>

  <!-- remove generated source files and their .class files -->
  <target name="cleanGen">
    <delete dir="${package}"/>
  </target>
</project>