forked from joshua-decoder/joshua
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
379 lines (321 loc) · 13.4 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<?xml version="1.0"?>
<!-- Build file for Joshua. -->
<project name="Joshua Machine Translation Toolkit" default="all" basedir="." xmlns:doxygen="antlib:org.doxygen.tools" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- ~~~~~ Properties, Paths, etc ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<property environment="env" />
<property name="src" value="${env.JOSHUA}/src" />
<property name="test" value="${env.JOSHUA}/test" />
<property name="build" value="${env.JOSHUA}/class" />
<property name="lib" value="${env.JOSHUA}/lib" />
<property name="thraxlib" value="${env.JOSHUA}/thrax/bin" />
<property name="doc" value="${env.JOSHUA}/doc" />
<!-- TODO: should these be made into 'path's instead of 'property's? -->
<property name="testng" value="${lib}/testng-6.7.jar" />
<!-- <property name="bdb" value="${lib}/je-3.2.23.jar"/> -->
<property name="cli" value="commons-cli-2.0-SNAPSHOT.jar" />
<path id="compile.all.classpath">
<fileset dir="${lib}">
<include name="${cli}" />
<!-- Jung uses a BSD-like license, see ./lib/LICENSES/LICENSE-jung.txt -->
<include name="jung-api-2.0.jar" />
<include name="jung-graph-impl-2.0.jar" />
<include name="jung-algorithms-2.0.jar" />
<include name="jung-visualization-2.0.jar" />
<include name="collections-generic-4.01.jar" />
<include name="berkeleylm.jar" />
<include name="junit-4.10.jar" />
</fileset>
<fileset dir="${thraxlib}">
<include name="thrax.jar" />
</fileset>
</path>
<!-- ~~~~~ Init build task ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Create the build directory for compiled class files -->
<target name="init" depends="set-joshua-home, resolve, download-thrax, download-hadoop">
</target>
<!-- Check for environment variables -->
<target name="set-joshua-home" unless="env.JOSHUA">
<fail message="Please set the $JOSHUA environment variable." />
</target>
<target name="set-joshua-version" unless="env.JOSHUA_VERSION">
<fail message="Please set the $JOSHUA_VERSION environment variable." />
</target>
<!-- Check for environment variables -->
<target name="set-java-home" unless="env.JAVA_HOME">
<fail message="Please set the $JAVA_HOME environment variable." />
<!-- TODO: add suggestion to use /System/Library/Frameworks/JavaVM.framework/Home/ iff on OSX -->
</target>
<target name="kenlm" depends="set-joshua-home">
<exec executable="make">
<arg value="-j" />
<arg value="4" />
<arg value="-C" />
<arg value="${src}/joshua/decoder/ff/lm/kenlm/" />
</exec>
</target>
<target name="giza" depends="set-joshua-home">
<exec executable="make">
<arg value="-j" />
<arg value="4" />
<arg value="-C" />
<arg value="scripts/training/giza-pp/" />
<arg value="all" />
<arg value="install" />
</exec>
<exec executable="make">
<arg value="-C" />
<arg value="scripts/training/symal/" />
<arg value="all" />
</exec>
<!-- <exec executable="./configure" dir="scripts/training/MGIZA" /> -->
<!-- <exec executable="make"> -->
<!-- <arg value="-C scripts/training/MGIZA/" /> -->
<!-- </exec> -->
<!-- <exec executable="cp"> -->
<!-- <arg value="-C scripts/training/MGIZA/" /> -->
<!-- </exec> -->
</target>
<target name="parallelize" depends="set-joshua-home">
<exec executable="make">
<arg value="-j" />
<arg value="4" />
<arg value="-C" />
<arg value="scripts/training/parallelize/" />
</exec>
</target>
<target name="download-thrax" depends="set-joshua-home">
<exec executable="git">
<arg value="submodule" />
<arg value="init" />
</exec>
<exec executable="git">
<arg value="submodule" />
<arg value="update" />
</exec>
</target>
<target name="thrax" depends="set-joshua-home">
<subant buildpath="thrax">
<property name="env.HADOOP" value="${lib}" />
<property name="env.HADOOP_VERSION" value="0.20.203.0" />
<property name="env.AWS_SDK" value="${env.JOSHUA}" />
<property name="env.AWS_VERSION" value="1.1.3" />
</subant>
</target>
<!-- Download the hadoop tool tarball (not jar library), which gets used by
pipeline.pl and test/hadoop/ -->
<target name="download-hadoop" depends="set-joshua-home">
<get
src="http://archive.apache.org/dist/hadoop/core/hadoop-0.20.2/hadoop-0.20.2.tar.gz"
dest="${env.JOSHUA}/lib"
usetimestamp="true"
skipexisting="true" />
</target>
<!-- ~~~~~ Java build tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="all" depends="jar, giza, kenlm, parallelize">
</target>
<target name="devel" depends="init, thrax, java, giza, kenlm, parallelize">
</target>
<!-- Compile the Java code. -->
<target name="java" depends="set-joshua-home">
<mkdir dir="${build}" />
<javac compiler="javac1.5" srcdir="${src}" destdir="${build}" classpathref="compile.all.classpath" debug="on" encoding="utf8" sourcepath="" includeantruntime="false">
<!-- We nullify the sourcepath in order to disable Ant's usual resolution mechanism. This makes it an error for our basic code to call into code that has external dependencies, rather than auto-including those files and then having a classpath error. -->
<include name="**/*.java" />
<!-- This should be on, so people see it. But it can be quite verbose...
<compilerarg value="-deprecation"/>
-->
</javac>
</target>
<!-- Create a JAR file -->
<target name="jar" depends="java,set-joshua-home">
<jar destfile="${build}/joshua.jar" index="true">
<fileset dir="${build}">
<include name="**/*.class" />
</fileset>
<manifest>
<attribute name="Main-Class" value="joshua.decoder.JoshuaDecoder" />
</manifest>
</jar>
</target>
<target name="tree_visualizer" depends="java,set-joshua-home">
<jar destfile="examples/tree_visualizer/tree_visualizer.jar" index="true">
<zipgroupfileset dir="lib" includes="*.jar" />
<fileset dir="${build}">
<include name="**/*.class" />
</fileset>
<indexjars>
<fileset dir="${lib}" />
</indexjars>
<manifest>
<attribute name="Class-Path" value="tree_visualizer.jar" />
<attribute name="Main-Class" value="joshua.ui.tree_visualizer.browser.Browser" />
</manifest>
</jar>
</target>
<!-- Create a versioned release -->
<target name="release" depends="set-joshua-version, devel-clean, init, thrax">
<exec executable="./scripts/support/make-release.sh">
<arg value="${env.JOSHUA_VERSION}" />
</exec>
</target>
<!-- Create a JAR file of the source code -->
<target name="source-jar">
<jar destfile="${build}/joshua-src.jar">
<fileset dir="${build}">
<include name="**/*.java" />
</fileset>
</jar>
</target>
<!-- ~~~~~ Cleaning tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Delete the compiled files -->
<target name="clean" depends="clean-thrax,clean-java">
<exec executable="make">
<arg value="-C" />
<arg value="scripts/training/giza-pp" />
<arg value="clean" />
</exec>
<exec executable="/bin/bash" dir="src/joshua/decoder/ff/lm/kenlm">
<arg value="clean" />
</exec>
<delete file="${lib}/libken.so" />
<delete file="tree_visualizer/tree_visualizer.jar" />
<delete dir="doc/html" />
<delete dir="doc/latex" />
</target>
<!-- Delete just the java files -->
<target name="clean-java">
<delete verbose="true" quiet="true">
<fileset dir="${build}">
<include name="**/*.class" />
</fileset>
</delete>
</target>
<target name="clean-thrax">
<delete verbose="true" quiet="true">
<fileset dir="${thraxlib}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<!-- EXPERIMENTAL: Delete *all* generated files -->
<target name="distclean" depends="clean">
<!-- BUG: this doesn't delete empty folders (neither ${build} itself, nor the class dirs (the latter makes sense since we don't traverse them)) -->
<delete verbose="true" quiet="true" includeEmptyDirs="true">
<fileset dir="${build}">
<include name="joshua.jar" />
<include name="joshua-ui.jar" />
</fileset>
</delete>
<!-- HACK: these two work perfectly, but maybe problematic if people reset ${test} or ${doc} -->
<delete verbose="true" quiet="true" includeEmptyDirs="true">
<fileset dir="${test}-output" />
</delete>
<delete verbose="true" quiet="true" includeEmptyDirs="true">
<fileset dir="${doc}" includes="**/*.tmp" />
<fileset dir="${doc}/html" />
<fileset dir="${doc}/latex" />
</delete>
<delete verbose="true" quiet="true" file="joshua-fb.xml" />
<delete verbose="true" quiet="true" includeEmptyDirs="true">
<fileset dir="tree_visualizer">
<include name="tree_visualizer.jar" />
</fileset>
</delete>
</target>
<!-- Delete *all* generated files,
including files and directories not tracked by git -->
<target name="devel-clean">
<input
message="WARNING: all untracked, ignored files will be removed. Continue? (y/n) "
validargs="y,n"
addproperty="do.delete"
/>
<condition property="do.abort">
<equals arg1="n" arg2="${do.delete}"/>
</condition>
<fail if="do.abort">Build aborted by user.</fail>
<!-- Delete untracked, ignored files and directories. -->
<exec executable="git">
<arg value="clean" />
<arg value="-fdX" />
</exec>
</target>
<!-- ~~~~~ Javadoc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Compile the Javadocs into web pages -->
<target name="javadoc">
<mkdir dir="${doc}" />
<javadoc packagenames="joshua.*" classpath="${cli}" sourcepath="${src}" destdir="${doc}" author="true" version="true" charset="utf-8" overview="src/overview.html">
<link href="http://java.sun.com/j2se/1.5.0/docs/api" />
<link href="http://commons.apache.org/cli/api-release" />
</javadoc>
</target>
<!-- ~~~~~ Doxygen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<taskdef uri="antlib:org.doxygen.tools" resource="org/doxygen/tools/antlib.xml" classpath="${lib}/ant-doxygen-1.6.1.jar" />
<!-- Compile the Javadocs and Markdown documentation into web pages -->
<target name="documentation" depends="set-joshua-home">
<doxygen:doxygen configFilename="${doc}/Doxyfile" />
</target>
<!-- ~~~~~ Tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="test" depends="all">
<exec dir="test" executable="/bin/bash" failonerror="false">
<arg line="run-all-tests.sh" />
</exec>
</target>
<!-- ~~~~~ TestNG ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Define the unit testing task -->
<taskdef resource="testngtasks" classpath="${testng}" />
<!-- Compile the unit test code -->
<!-- FIXME: why is this broken out from the 'test' target? -->
<target name="compile-tests" depends="java">
<javac compiler="javac1.5" srcdir="${test}/joshua/ui" destdir="${build}" classpath="${testng}:${build}" debug="on" encoding="utf8" />
</target>
<!-- Run the unit tests -->
<target name="testng" depends="all,compile-tests">
<testng classpath="${build}" sourcedir="${test}">
<jvmarg value="-Dfile.encoding=UTF8" />
<jvmarg value="-Xms256m" />
<jvmarg value="-Xmx256m" />
<xmlfileset dir="${test}" includes="testng.xml" />
</testng>
</target>
<property name="ivy.install.version" value="2.2.0" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${env.JOSHUA}" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<target name="download-ivy" unless="offline">
<!-- Test for Ant Version.-->
<fail message="Ivy requires Ant version 1.8.0 or greater. Please upgrade to the latest version.">
<condition>
<not>
<antversion atleast="1.8.0"/>
</not>
</condition>
</fail>
<property name="ivy.default.ivy.user.dir" value="${env.JOSHUA}/lib" />
<mkdir dir="${ivy.jar.dir}" />
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true" skipexisting="true" />
</target>
<target name="init-ivy" depends="download-ivy">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" description="--> retrieve dependencies with ivy" depends="init-ivy">
<property name="ivy.default.ivy.user.dir" value="${env.JOSHUA}/lib" />
<ivy:configure file="${env.JOSHUA}/lib/ivysettings.xml" />
<ivy:resolve file="${env.JOSHUA}/lib/ivy.xml" />
<ivy:retrieve type="jar" />
</target>
</project>