-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
232 lines (205 loc) · 8.06 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
<?xml version="1.0"?>
<project name="igraph Java interface" default="usage" basedir="."
xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks"
xmlns:antcontrib="antlib:net.sf.antcontrib">
<!-- Package name and version number -->
<property name="package.name" value="net.sf.igraph" />
<property name="package.slashed.name" value="net/sf/igraph" />
<property name="package.underscored.name" value="net_sf_igraph" />
<property name="package.version" value="0.6" />
<!-- Directories -->
<property name="build" location="build" />
<property name="dist" location="dist" />
<property name="etc" location="etc" />
<property name="lib" location="lib" />
<property name="src" location="src" />
<property name="reports" location="reports" />
<!-- Access to environment -->
<property environment="os" />
<!-- Include and library paths -->
<property name="igraph.include.path" location="../../include" />
<property name="igraph.library.path" location="${os.HOME}/lib" />
<!-- External tools -->
<property name="python.executable" value="python" />
<property name="stimulus.script" location="src/python/stimulus.py" />
<!-- Other configuration stuff -->
<property name="libtype" value="shared" />
<!-- DON'T CHANGE ANYTHING BELOW THIS LINE
UNLESS YOU KNOW WHAT YOU'RE DOING -->
<condition property="jni.library.name" value="libigraph-java-wrapper.jnilib">
<and><os family="mac" /><os family="unix" /></and>
</condition>
<condition property="jni.library.name" value="libigraph-java-wrapper.dll">
<os family="windows" />
</condition>
<condition property="jni.library.name" value="libigraph-java-wrapper.so">
<os family="unix" />
</condition>
<path id="jni.include.path">
<pathelement path="${java.home}/include" />
<pathelement path="${java.home}/include/linux" />
<pathelement path="${java.home}/include/darwin" />
<pathelement path="${java.home}/include/win32" />
<pathelement path="${java.home}/../include" />
<pathelement path="${java.home}/../include/linux" />
<pathelement path="${java.home}/../include/darwin" />
<pathelement path="${java.home}/../include/win32" />
</path>
<property name="generated.enum.classes" value="Connectedness NeighborMode StarMode" />
<!-- Initializes the build tree, creates the necessary directories -->
<target name="-init" description="Initializes the build process">
<mkdir dir="${build}" />
<mkdir dir="${build}/c" />
<mkdir dir="${build}/java" />
<mkdir dir="${build}/tests" />
<mkdir dir="${dist}" />
<mkdir dir="${reports}" />
</target>
<!-- Deletes the existing build -->
<target name="clean" description="Cleans up the build directories">
<!-- Delete build directories -->
<delete dir="${build}/java" />
<delete dir="${build}/c" />
<delete dir="${build}" />
<delete dir="${dist}" />
<delete dir="${reports}" />
<!-- Delete generated Java source files -->
<delete file="${src}/java/Graph.java" />
<antcontrib:for param="classname" list="${generated.enum.classes}"
delimiter=" ">
<sequential>
<delete file="${src}/java/@{classname}.java" />
</sequential>
</antcontrib:for>
<!-- Delete generated C source files -->
<delete file="${src}/c/config.h" />
<delete file="${src}/c/net_sf_igraph_Graph.h" />
</target>
<!-- Generates some Java source files -->
<target name="generate_java_source">
<!-- Generate Graph.java -->
<exec executable="${python.executable}" failonerror="true">
<arg value="${stimulus.script}" />
<arg value="-f" />
<arg value="etc/functions.def" />
<arg value="-i" />
<arg value="${src}/java/Graph.java.in" />
<arg value="-o" />
<arg value="${src}/java/Graph.java" />
<arg value="-t" />
<arg value="types-Java.def" />
<arg value="-l" />
<arg value="JavaJava" />
</exec>
<!-- Generate enum classes -->
<antcontrib:for param="classname" delimiter=" "
list="${generated.enum.classes}">
<sequential>
<copy file="${src}/java/GenericEnum.java.in"
tofile="${src}/java/@{classname}.java" />
<replace file="${src}/java/@{classname}.java"
replacefilterfile="${etc}/enums/@{classname}.properties" />
</sequential>
</antcontrib:for>
</target>
<target name="-generate_java_enum_class">
</target>
<!-- Generates some C source files -->
<target name="generate_c_source">
<copy file="${src}/c/config.h.in" tofile="${src}/c/config.h" />
<replace file="${src}/c/config.h" token="@JAVA_PACKAGE_SLASH@"
value="${package.slashed.name}" />
<javah class="${package.name}.Graph" destdir="${src}/c" verbose="yes" force="yes">
<classpath location="${build}/java" />
</javah>
<exec executable="${python.executable}" failonerror="true">
<arg value="${stimulus.script}" />
<arg value="-f" />
<arg value="etc/functions.def" />
<arg value="-i" />
<arg value="${src}/c/${package.underscored.name}_Graph.c.in" />
<arg value="-o" />
<arg value="${src}/c/${package.underscored.name}_Graph.c" />
<arg value="-t" />
<arg value="types-C.def" />
<arg value="-l" />
<arg value="JavaC" />
</exec>
</target>
<!-- Compiles the Java source code -->
<target name="compile_java" depends="-init, generate_java_source"
description="--> compile Java code">
<javac srcdir="${src}/java" destdir="${build}/java" />
</target>
<!-- Compiles the Java tests -->
<target name="compile_tests" depends="-init"
description="--> compile Java tests">
<javac srcdir="${src}/tests" destdir="${build}/tests">
<classpath>
<pathelement location="${build}/java" />
<pathelement location="${lib}/junit.jar" />
</classpath>
</javac>
</target>
<!-- Compiles the C source code -->
<target name="compile_c" depends="-init, generate_c_source, compile_java"
description="--> compile C code">
<cpptasks:cc outtype="${libtype}" subsystem="console"
multithreaded="true" optimize="speed"
objdir="${build}/c"
outfile="${build}/igraph-java-wrapper"
outputfileproperty="jni.library.outfile">
<fileset dir="${src}/c" includes="*.c" />
<cpptasks:includepath>
<path path="${igraph.include.path}" />
<path refid="jni.include.path" />
</cpptasks:includepath>
<cpptasks:linker libtool="true">
<libset libs="igraph" type="shared" dir="${igraph.library.path}" />
</cpptasks:linker>
</cpptasks:cc>
<move file="${jni.library.outfile}" tofile="${build}/${jni.library.name}" />
</target>
<!-- Compiles the whole thing -->
<target name="compile" depends="compile_java, compile_c" description="Compiles all the source files">
</target>
<!-- Creates the JAR file -->
<target name="jar" depends="compile" description="Creates the JAR file">
<jar destfile="${dist}/igraph-${package.version}.jar" basedir="${build}/java">
<manifest>
<attribute name="Manifest-Version" value="1.0" />
<attribute name="Extension-Name" value="${package.name}" />
<attribute name="Implementation-Version" value="${package.version}" />
<attribute name="Main-Class" value="${package.name}.TestSuite" />
</manifest>
</jar>
<copy file="${build}/${jni.library.name}" todir="${dist}" />
</target>
<!-- Tests the whole thing -->
<target name="test" depends="compile, compile_tests" description="Runs JUnit tests in the distribution">
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath>
<pathelement location="${build}/tests" />
<pathelement location="${build}/java" />
<pathelement location="${lib}/junit.jar" />
</classpath>
<jvmarg value="-Djava.library.path=${build}" />
<formatter type="plain" />
<batchtest todir="${reports}">
<fileset dir="${build}/tests">
<include name="**/*Test*.class" />
<exclude name="**/AllTests.class" />
</fileset>
</batchtest>
</junit>
</target>
<!-- Main targets -->
<target name="build" depends="compile, jar" description="Builds the whole project" />
<target name="rebuild" depends="clean, build" description="Rebuilds the project from scratch" />
<!-- Usage information target -->
<target name="usage" description="Display usage information">
<echo message=" Execute 'ant -projecthelp' for build file help." />
<echo message=" Execute 'ant -help' for Ant hellp." />
</target>
<target name="help" depends="usage" />
</project>