forked from cederberg/grammatica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
238 lines (210 loc) · 7.53 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
build.xml
This program is free software: you can redistribute it and/or
modify it under the terms of the BSD license.
This program 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
LICENSE.txt file for more details.
Copyright (c) 2003-2015 Per Cederberg. All rights reserved.
-->
<project name="grammatica" default="package">
<!-- INITIALIZATION -->
<property name="build.name" value="${ant.project.name}" />
<property name="build.title" value="Grammatica" />
<property name="build.java.package" value="net.percederberg.grammatica" />
<tstamp>
<format property="build.printdate" pattern="yyyy-MM-dd" />
</tstamp>
<property name="build.version" value="${DSTAMP}" />
<property name="build.date" value="${DSTAMP}" />
<property name="build.sysclasspath" value="ignore" />
<path id="project.class.path">
<fileset dir="lib" includes="**/*.jar" />
</path>
<!-- CODE GENERATION TARGETS -->
<target name="codegen">
<antcall target="compile-clean" />
<antcall target="compile-java" />
<taskdef resource="ant-grammatica.properties" classpath="classes" />
<grammatica grammar="src/grammar/grammar.grammar">
<java dir="src/java" package="${build.java.package}" />
</grammatica>
</target>
<!-- COMPILATION TARGETS -->
<target name="compile" description="Builds the project from source code"
depends="codegen,compile-clean,compile-info,compile-java,compile-csharp">
<jar jarfile="lib/${build.name}-${build.version}.jar">
<manifest>
<attribute name="Main-Class" value="${build.java.package}.Grammatica" />
</manifest>
<fileset dir="." includes="LICENSE.txt" />
<fileset dir="classes" />
</jar>
</target>
<target name="compile-clean">
<delete quiet="true">
<fileset dir="classes" />
<fileset dir="lib" includes="${build.name}-*" />
</delete>
<mkdir dir="classes" />
<mkdir dir="lib" />
</target>
<target name="compile-info" unless="build.dotnet">
<echo>WARNING: Use -Dbuild.dotnet=1 to compile C#/.NET version</echo>
</target>
<target name="compile-java">
<javac srcdir="src/java"
destdir="classes"
classpathref="project.class.path"
source="1.4"
target="1.5"
debug="on"
deprecation="on" />
<copy todir="classes">
<fileset dir="src/java" excludes="**/*.java" />
</copy>
</target>
<target name="compile-csharp" if="build.dotnet">
<exec executable="dmcs" dir="src/csharp" failonerror="true">
<arg value="-target:library" />
<arg value="-out:${basedir}/lib/${build.name}-${build.version}.dll" />
<arg value="-debug" />
<arg value="-recurse:*.cs" />
</exec>
</target>
<!-- TEST TARGETS -->
<target name="test" description="Runs all automated tests for the project"
depends="compile,test-codegen,test-java,test-csharp">
</target>
<target name="test-codegen">
<grammatica grammar="test/src/grammar/arithmetic.grammar">
<java dir="test/src/java"
package="${build.java.package}.test" />
<csharp dir="test/src/csharp/PerCederberg.Grammatica.Test"
namespace="PerCederberg.Grammatica.Test" />
</grammatica>
<grammatica grammar="test/src/grammar/regexp.grammar">
<java dir="test/src/java"
package="${build.java.package}.test" />
<csharp dir="test/src/csharp/PerCederberg.Grammatica.Test"
namespace="PerCederberg.Grammatica.Test" />
</grammatica>
</target>
<target name="test-java">
<javac srcdir="test/src/java"
destdir="classes"
classpathref="project.class.path"
source="1.4"
target="1.5"
debug="on"
deprecation="on" />
<junit haltonfailure="on">
<batchtest>
<fileset dir="test/src/java" includes="**/Test*.java" />
</batchtest>
<formatter type="plain" usefile="false" />
<classpath>
<pathelement location="classes" />
<path refid="project.class.path" />
</classpath>
</junit>
</target>
<target name="test-csharp" if="build.dotnet">
<exec executable="dmcs" dir="test/src/csharp" failonerror="true">
<arg value="-target:exe" />
<arg value="-out:${basedir}/lib/cstestall.exe" />
<arg value="-main:TestAll" />
<arg value="-reference:${basedir}/lib/${build.name}-${build.version}.dll" />
<arg value="-debug-" />
<arg value="-recurse:*.cs" />
</exec>
<echo level="info" message="running C# test cases with Mono..." />
<exec executable="mono"
failonerror="true">
<arg value="lib/cstestall.exe" />
</exec>
<delete file="lib/cstestall.exe" />
</target>
<!-- DOCUMENTATION TARGETS -->
<target name="doc" description="Generates the project documentation"
depends="doc-clean,doc-text,doc-html,doc-java,doc-csharp">
</target>
<target name="doc-clean">
<delete quiet="true" dir="doc" />
<mkdir dir="doc" />
<mkdir dir="doc/manual" />
<mkdir dir="doc/api/java" />
<mkdir dir="doc/api/csharp" />
</target>
<target name="doc-text">
<xslt style="src/doc/txt.xsl"
basedir="src/doc/release"
destdir="doc"
extension=".txt"
includes="*.xml">
<param name="version" expression="${build.version}" />
<param name="date" expression="${build.printdate}" />
</xslt>
</target>
<target name="doc-html">
<copy file="src/doc/style.css"
todir="doc" />
<xslt style="src/doc/html.xsl"
basedir="src/doc/release"
destdir="doc"
extension=".html"
includes="*.xml">
<param name="version" expression="${build.version}" />
<param name="date" expression="${build.printdate}" />
<param name="style" expression="style.css" />
</xslt>
<xslt style="src/doc/html.xsl"
basedir="src/doc/manual"
destdir="doc/manual"
extension=".html"
includes="*.xml">
<param name="version" expression="${build.version}" />
<param name="date" expression="${build.printdate}" />
<param name="style" expression="../style.css" />
</xslt>
</target>
<target name="doc-java">
<javadoc packagenames="${build.java.package}.parser.*"
sourcepath="src/java"
destdir="doc/api/java"
classpath="classes"
classpathref="project.class.path"
version="false"
use="true"
author="false"
windowtitle="${build.title} ${build.version} Documentation"
failonerror="true" />
</target>
<target name="doc-csharp" if="build.dotnet">
<exec executable="doxygen"
dir="."
failonerror="true">
<arg value="doxygen.conf" />
</exec>
</target>
<!-- PACKAGING TARGETS -->
<target name="package" description="Builds a complete distribution package"
depends="codegen,compile,test,doc">
<delete quiet="true">
<fileset dir="." includes="${build.name}-*.zip" />
</delete>
<zip destfile="${build.name}-${build.version}.zip">
<zipfileset dir="." prefix="${build.name}-${build.version}">
<include name="LICENSE.txt" />
<include name="README.txt" />
<include name="*.xml" />
<include name="lib/**" />
<include name="src/**" />
<include name="test/**" />
<include name="doc/**" />
</zipfileset>
</zip>
</target>
</project>