build.xml 5.78 KB
Newer Older
Anders Nilsson's avatar
Anders Nilsson committed
1
2
3
4
5
6
<!--
 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
Oscar Olsson's avatar
Oscar Olsson committed
7
       cleanGen        - removes all generated files and their class files
Anders Nilsson's avatar
Anders Nilsson committed
8
9
10
11
12
13
14
15
16
17
-->
<project name="LabComm" 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"/>
	
<!-- "test" is the directory where tests are located. -->
18
<property name="test" value="../test"/>
Anders Nilsson's avatar
Anders Nilsson committed
19
20
21
22
	
<!-- "jflex" is an ant task class for the scanner generator in JFlex.jar -->
<taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/>
<!-- "beaver" is an ant task class for the parser generator in beaver.jar -->
23
<taskdef name="beaver" classname="beaver.comp.run.AntTask" classpath="tools/beaver-ant.jar"/>
Anders Nilsson's avatar
Anders Nilsson committed
24
25
<!-- "jastadd" is an ant task class in jastadd2.jar -->
<taskdef name="jastadd" classname="jastadd.JastAddTask"
26
         classpath="tools/jastadd2.jar"/>
Anders Nilsson's avatar
Anders Nilsson committed
27
28
29
30
31

	
<!-- compile sources -->
<target name="test" depends="jar">
  <echo message = "Running tests"/>
32
  <exec executable="./run" dir="../test"> 
Anders Nilsson's avatar
Anders Nilsson committed
33
34
35
36
37
38
39
40
    <env key="PYTHONPATH" value="../lib/python"/>
    <!--arg value="hej"/-->
  </exec>
</target>
	
<!-- remove generated source files and .class files -->
<target name="clean" depends="cleanGen">
     <!-- delete all .class files recursively -->
41
    <delete dir="gen"/>
Anders Nilsson's avatar
Anders Nilsson committed
42
43
    <delete>
      <fileset dir="." includes="**/*.class"/>
44
      <fileset dir="." includes="gen"/>
45
      <fileset dir="." includes="labcomm_compiler.jar"/>
Anders Nilsson's avatar
Anders Nilsson committed
46
    </delete>
Oscar Olsson's avatar
Oscar Olsson committed
47

Anders Nilsson's avatar
Anders Nilsson committed
48
49
50
51
52
</target>


<!-- remove generated source files and their .class files -->
<target name="cleanGen">
53
  <delete dir="${package}"/>
Anders Nilsson's avatar
Anders Nilsson committed
54
55
</target>

Anders Blomdell's avatar
Anders Blomdell committed
56
57
58
59
60
61
62
63
64
65
66
<target name="jar_version" depends="build">
  <jar destfile="labcomm${version}_compiler.jar">
    <fileset dir="gen" 
             includes="se/lth/control/labcomm${version}/compiler/*.class"/>
    <zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
    <manifest>
      <attribute name="Main-Class" 
                 value="se.lth.control.labcomm${version}.compiler.LabComm"/>
    </manifest>
  </jar>
</target>
Anders Nilsson's avatar
Anders Nilsson committed
67
68

<target name="jar" depends="build">
Anders Blomdell's avatar
Anders Blomdell committed
69
70
71
72
73
74
  <antcall target="jar_version">
    <param name="version" value="2006"/>
  </antcall>
  <antcall target="jar_version">
    <param name="version" value="2014"/>
  </antcall>
75
  <jar destfile="labcomm_compiler.jar">
76
    <fileset dir="gen" includes="**/*.class"/>
Anders Nilsson's avatar
Anders Nilsson committed
77
78
79
80
81
82
    <zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
    <manifest>
      <attribute name="Main-Class" value="LabComm"/>
    </manifest>
  </jar>
</target>
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168

<!-- generate compiler source files -->
<target name="gen_compiler_version">
  <local name="package"/>
  <local name="package_path"/>
  <property name="package" value="se.lth.control.labcomm${version}.compiler"/>
  <loadresource property="package_path">
    <propertyresource name="package"/>
    <filterchain>
      <tokenfilter>
        <filetokenizer/>
        <replacestring from="." to="/"/>
      </tokenfilter>
    </filterchain>
  </loadresource>  

  <mkdir dir="${outdir}"/>

  <!-- create AST node types and weave aspect modules -->
  <echo message = "Running JastAdd"/>
  <jastadd package="${package}" rewrite="true" beaver="true" 
           novisitcheck="true" lazyMaps="true" outdir="${outdir}">
    <fileset dir=".">
      <include name="${version}/*.ast"/>
      <include name="${version}/*.jrag"/>
      <include name="${version}/*.jadd"/>
    </fileset>
  </jastadd>

  <!-- generate the scanner -->
  <echo message = "Running jflex -> ${package} ${package_path}"/>
  <jflex file="${version}/LabCommScanner.flex" 
         outdir="${outdir}/${package_path}" nobak="yes"/>

  <!-- generate the parser phase 1, create a full .lalr specification 
       from fragments-->
  <echo message = "Running parser phase 1"/>
  <concat destfile="${outdir}/${package_path}/LabCommParser.all" binary="true">
    <fileset dir=".">
      <include name="${version}/*.parser"/>
    </fileset>
  </concat>

  <!-- generate the parser phase 2, translating .lalr to .beaver -->
  <echo message = "translating .lalr to .beaver"/>
  <java fork="true" dir="${basedir}" 
        classpath="${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main">
    <arg line="${outdir}/${package_path}/LabCommParser.all 
               ${outdir}/${package_path}/LabCommParser.beaver"/>
  </java>

  <!-- generate the parser phase 3, translating .beaver to .java -->
  <echo message = "translating .beaver to .java"/>
  <beaver file="${outdir}/${package_path}/LabCommParser.beaver"
          terminalNames="yes" compress="yes" useSwitch="yes"/>

  <echo message = "compiling .java"/>
<!--
  <javac debug="true" srcdir="." destdir="${outdir}"
         includes="${version}/*.java ${outdir}/${package_path}/*.java" 
         classpath="gen:${tools}/beaver-rt.jar:${tools}/junit.jar"
         includeantruntime="false"
         fork="true" memoryMaximumSize="128M">
    <!- -compilerarg value="-Xlint"/- ->
  </javac>
-->
</target>

<target name="build">
  <antcall target="gen_compiler_version">
    <param name="version" value="2006"/>
    <param name="outdir" value="gen"/>
  </antcall>
  <antcall target="gen_compiler_version">
    <param name="version" value="2014"/>
    <param name="outdir" value="gen"/>
  </antcall>
  <echo message = "compiling main"/>
  <javac debug="true" srcdir="." destdir="gen"
         includes="*.java 2006/*.java 2014/*.java gen/**/*.java" 
         classpath="gen:${tools}/beaver-rt.jar:${tools}/junit.jar"
         includeantruntime="false"
         fork="true" memoryMaximumSize="128M">
    <!--compilerarg value="-Xlint"/-->
  </javac>
</target>
Anders Nilsson's avatar
Anders Nilsson committed
169
170
171
172

</project>