File: build.xml

package info (click to toggle)
jffi 1.2.7-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 1,388 kB
  • sloc: java: 7,186; ansic: 4,683; xml: 523; asm: 36; makefile: 32; sh: 8
file content (385 lines) | stat: -rw-r--r-- 14,098 bytes parent folder | download
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
380
381
382
383
384
385
<?xml version="1.0" encoding="UTF-8"?>
<project name="jffi" default="jar" basedir=".">
  <description>Builds, tests, and runs the project jffi.</description>
  <path id="classpath.test">
    <!--
    <pathelement location="lib/junit_4/junit-4.5.jar"/>
    <pathelement location="lib/junit_4/junit-4.5-api.jar"/>
    -->
    <pathelement location="/usr/share/java/junit4.jar"/>
  </path>

  <target name="clean" depends="-init">
    <delete dir="${build.dir}"/>
    <delete dir="${dist.dir}"/>
  </target>

  <target name="jar" depends="-init,-pre-jar,-do-jar,-post-jar"/>

  <target name="build-native" depends="-init, -build-platform-jar"/>

  <target name="-pre-init">
    <!-- d32/d64 options are not supported on Windows -->
    <condition property="run.jvm.model" value="">
      <os family="Windows"/>
    </condition>
    <condition property="run.jvm.model" value="-d64">
      <or>
        <os arch="amd64"/>
        <os arch="x86_64"/>
        <os arch="sparcv9"/>
        <os arch="s390x"/>
      </or>
    </condition>
    <condition property="run.jvm.model" value="-d32">
      <or>
        <os arch="i386"/>
        <os arch="x86"/>
        <os arch="powerpc"/>
        <os arch="sparc"/>
      </or>
    </condition>
    <condition property="run.jvm.model" value="">
      <not><isset property="run.jvm.model"/></not>
    </condition>
    <property name="run.jvmargs" value="${run.jvm.model} -Djffi.library.path=build/jni -Djffi.boot.library.path=build/jni"/>
  </target>

  <target name="-init-vars">
    <property name="src.dir" location="src/main/java"/>
    <property name="src.test.dir" location="src/test/java"/>
    <property name="build.dir" location="build"/>
    <property name="dist.dir"  location="dist"/>

    <property name="build.classes.dir" location="${build.dir}/classes"/>
    <property name="build.test.dir" location="${build.dir}/test"/>
    <property name="dist.jar"  value="${dist.dir}/jffi.jar"/>
    <property name="complete.jar" value="${dist.dir}/jffi-complete.jar"/>
    <property name="build.native.dir" location="${build.dir}/jni"/>
    <property name="src.native.dir" location="jni"/>
    <property name="ant.build.javac.target" value="1.5"/>
    <property name="ant.build.javac.source" value="1.5"/>
    <property name="ant.build.javac.includeantruntime" value="false"/>
    <property name="test.fork" value="true"/>

    <mkdir dir="${build.native.dir}"/>


    <!-- normalize the various os.arch naming conventions -->
    <condition property="platform.cpu" value="i386">
      <or>
        <os arch="i386"/>
        <os arch="x86"/>
      </or>
    </condition>
    <condition property="platform.cpu" value="x86_64">
      <or>
        <os arch="amd64"/>
        <os arch="x86_64"/>
      </or>
    </condition>
    <condition property="platform.cpu" value="ppc">
      <or>
        <os arch="ppc"/>
        <os arch="powerpc"/>
      </or>
    </condition>
    <condition property="platform.cpu" value="ppc64">
      <or>
        <os arch="ppc64"/>
        <os arch="powerpc64"/>
      </or>
    </condition>
    <condition property="platform.os" value="Windows">
      <os family="Windows"/>
    </condition>
    <!-- Treat GNU/kFreeBSD or Hurd just like Linux platform -->
    <condition property="platform.os" value="Linux">
      <or>
        <os name="GNU/kFreeBSD"/>
        <os name="GNU"/>
      </or>
    </condition>
    <!-- default to os.arch for the cpu -->
    <condition property="platform.cpu" value="${os.arch}">
      <not><isset property="platform.cpu"/></not>
    </condition>
    <condition property="platform.os" value="${os.name}">
      <not><isset property="platform.os"/></not>
    </condition>
    <condition property="platform" value="Darwin">
      <os family="Mac"/>
    </condition>
    <condition property="platform" value="${platform.cpu}-${platform.os}">
      <not><isset property="platform"/></not>
    </condition>

    <condition property="native.jar" value="${build.dir}/native.jar">
      <not><isset property="native.jar"/></not>
    </condition>
    <condition property="make.exe" value="gmake">
      <or>
        <os name="FreeBSD"/>
        <os name="OpenBSD"/>
        <os name="AIX"/>
        <os name="HP-UX"/>
      </or>
    </condition>
    <condition property="make.exe" value="/usr/sfw/bin/gmake">
      <os name="SunOS"/>
    </condition>
    <condition property="make.exe" value="make">
      <not><isset property="make.exe"/></not>
    </condition>
  </target>

  <target name="-init" depends="-pre-init,-init-vars,-post-init">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build.dir}"/>
  </target>

  <import file="version.xml"/>


  <target name="-pre-jar"/>
  <target name="-post-init" depends="-init-vars"/>
  <target name="-pre-compile" depends="-init"/>
  <target name="-post-compile" depends="-build-native-library"/>
  <target name="-pre-compile-test" depends="-init"/>
  <target name="-post-compile-test" depends="-build-native-testlib"/>
  <target name="-post-jar" depends="-assemble-final-jar"/>

  <target name="-do-compile" depends="-init">
    <mkdir dir="${build.classes.dir}"/>
    <mkdir dir="${build.native.dir}"/>
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src.dir}" destdir="${build.classes.dir}" includeantruntime="false" nativeHeaderDir="${build.native.dir}"/>
  </target>

  <target name="-compile-java" depends="-do-compile"/>
  <target name="compile" depends="-init,-pre-compile,-do-compile,-post-compile">
  </target>

  <target name="-do-jar" depends="-init,compile">
    <mkdir dir="${dist.dir}"/>
    <jar destfile="${dist.jar}" basedir="${build.classes.dir}" compress="true"/>
  </target>

  <target name="test" depends="compile,-compile-test">
    <mkdir dir="${build.test.dir}/results"/>
    <junit fork="${test.fork}" printsummary="withOutAndErr" haltonfailure="false">
      <jvmarg value="${run.jvm.model}"/>
      <classpath>
        <pathelement location="${build.classes.dir}"/>
        <pathelement location="${build.test.dir}/classes"/>
        <pathelement location="/usr/share/java/junit4.jar"/>
      </classpath>
      <sysproperty key="java.library.path" value="${build.native.dir}"/>

      <formatter type="plain" /> <!-- to file -->
      <batchtest fork="${test.fork}" todir="${build.test.dir}/results">
        <fileset dir="${src.test.dir}">
          <include name="**/*Test*.java"/>
        </fileset>
      </batchtest>

    </junit>
  </target>

  <target name="ensure-test-name" unless="test">
    <fail message="You must run this target with -Dtest=TestName"/>
  </target>

  <target name="runtest" description="Runs the test you specify on the command 
    line with -Dtest=" depends="compile, -compile-test, ensure-test-name">
    <junit printsummary="withOutAndErr" fork="${test.fork}"> 
      <jvmarg value="${run.jvm.model}"/>
      <classpath>
        <pathelement location="${build.classes.dir}"/>
        <pathelement location="${build.test.dir}/classes"/>
        <pathelement location="/usr/share/java/junit4.jar"/>
      </classpath>
      <sysproperty key="java.library.path" value="${build.native.dir}"/>
      <formatter type="plain" usefile="false"/>
      <batchtest>
        <fileset dir="${src.test.dir}">
          <include name="**/${test}.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="-compile-test" depends="-pre-compile-test,-do-compile-test,-post-compile-test"/>


  <target name="-do-compile-test" depends="-init">
    <mkdir dir="${build.test.dir}/classes"/>
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src.test.dir}" destdir="${build.test.dir}/classes" includeantruntime="false" classpathref="classpath.test">
      <classpath>
        <pathelement location="${build.classes.dir}"/>
        <pathelement location="/usr/share/java/junit4.jar"/>
      </classpath>
    </javac>
  </target>


  <target name="cross-win32" depends="-init, -generate-native-headers">
    <mkdir dir="${build.native.dir}"/>

    <exec executable="${make.exe}" failonerror="true">
      <arg value="JAVA_HOME=${java.home}"/>
      <arg value="OS=cross-mingw32"/>
      <arg value="SRC_DIR=${src.native.dir}"/>
      <arg value="JNI_DIR=${src.native.dir}"/>
      <arg value="BUILD_DIR=${build.native.dir}"/>
      <arg value="VERSION=${jffi.version.major}.${jffi.version.minor}"/>
      <arg value="CPU=i386"/>
      <arg value="-f"/>
      <arg value="jni/GNUmakefile"/>
    </exec>
    <exec executable="i686-w64-mingw32-strip" failonerror="true">
      <arg value="--strip-debug"/> <!-- Strip debug symbols only -->
      <arg value="${build.native.dir}/jffi-${jffi.version.major}.${jffi.version.minor}.dll"/>
    </exec>
    <mkdir dir="${dist.dir}"/>
    <zip destfile="${dist.dir}/jffi-i386-Windows.jar" level="9">
      <zipfileset prefix="jni/i386-Windows" dir="${build.native.dir}">
        <include name="jffi*.dll"/>
      </zipfileset>
    </zip>
  </target>

  <target name="cross-win64" depends="-init, -generate-native-headers">
    <mkdir dir="${build.native.dir}"/>

    <exec executable="${make.exe}" failonerror="true">
      <arg value="JAVA_HOME=${java.home}"/>
      <arg value="OS=cross-win64"/>
      <arg value="SRC_DIR=${src.native.dir}"/>
      <arg value="JNI_DIR=${src.native.dir}"/>
      <arg value="BUILD_DIR=${build.native.dir}"/>
      <arg value="VERSION=${jffi.version.major}.${jffi.version.minor}"/>
      <arg value="CPU=x86_64"/>
      <arg value="-f"/>
      <arg value="jni/GNUmakefile"/>
    </exec>
    <exec executable="x86_64-w64-mingw32-strip" failonerror="true">
      <arg value="--strip-debug"/> <!-- Strip debug symbols only -->
      <arg value="${build.native.dir}/jffi-${jffi.version.major}.${jffi.version.minor}.dll"/>
    </exec>
    <mkdir dir="${dist.dir}"/>
    <zip destfile="${dist.dir}/jffi-x86_64-Windows.jar" level="9">
      <zipfileset prefix="jni/x86_64-Windows" dir="${build.native.dir}">
        <include name="jffi*.dll"/>
      </zipfileset>
    </zip>
  </target>



  <target name="-generate-version" depends="-init,-init-vars,-generate-version-source">
    <javac target="1.6" destdir="${build.classes.dir}" srcdir="${build.dir}/java" includeantruntime="false" nativeHeaderDir="${build.native.dir}"/>
  </target>

  <target name="-generate-native-headers" depends="-init-vars,-generate-version,-compile-java">
  </target>

  <target name="-build-native-library" depends="-init-vars, -generate-native-headers, -generate-version">
    <mkdir dir="${build.native.dir}"/>

    <exec executable="cygpath" outputproperty="jni.GNUmakefile" osfamily="Windows">
      <arg value="-u"/>
      <arg value="${src.native.dir}/GNUmakefile"/>
    </exec>
    <exec executable="cygpath" outputproperty="jni.src.dir" osfamily="Windows">
      <arg value="-u"/>
      <arg value="${src.native.dir}"/>
    </exec>
    <exec executable="cygpath" outputproperty="jni.build.dir" osfamily="Windows">
      <arg value="-u"/>
      <arg value="${build.native.dir}"/>
    </exec>
    <exec executable="cygpath" outputproperty="jni.java.home" osfamily="Windows">
      <arg value="-u"/>
      <arg value="${java.home}"/>
    </exec>
    <condition property="jni.GNUmakefile" value="${src.native.dir}/GNUmakefile">
      <not><isset property="jni.GNUmakefile"/></not>
    </condition>
    <condition property="jni.src.dir" value="${src.native.dir}">
      <not><isset property="jni.src.dir"/></not>
    </condition>
    <condition property="jni.build.dir" value="${build.native.dir}">
      <not><isset property="jni.build.dir"/></not>
    </condition>
    <condition property="jni.java.home" value="${java.home}">
      <not><isset property="jni.java.home"/></not>
    </condition>
    <exec executable="${make.exe}" failonerror="true">
      <arg value="JAVA_HOME=${jni.java.home}"/>
      <arg value="SRC_DIR=${jni.src.dir}"/>
      <arg value="JNI_DIR=${jni.src.dir}"/>
      <arg value="BUILD_DIR=${jni.build.dir}"/>
      <arg value="CPU=${platform.cpu}"/>
      <arg value="VERSION=${jffi.version.major}.${jffi.version.minor}"/>
      <arg value="USE_SYSTEM_LIBFFI=${use.system.libffi}"/>
      <!-- <arg value="USE_SYSTEM_LIBFFI=0"/> -->
      <arg value="-f"/>
      <arg value="${jni.GNUmakefile}"/>
    </exec>

  </target>


  <target name="-build-native-testlib" depends="-init-vars">
    <mkdir dir="${build.native.dir}"/>

    <exec executable="${make.exe}" failonerror="true">
      <arg value="JAVA_HOME=${java.home}"/>
      <arg value="BUILD_DIR=${build.dir}"/>
      <arg value="CPU=${platform.cpu}"/>
      <arg value="-f"/>
      <arg value="libtest/GNUmakefile"/>
    </exec>
  </target>

  <target name="-build-platform-jar" depends="-init-vars, -build-native-library">
    <echo message="platform=${platform}"/>
    <zip destfile="${dist.dir}/jffi-${platform}.jar" level="9">
      <zipfileset prefix="jni/${platform}" dir="${build.native.dir}">
        <include name="jffi*.dll"/>
        <include name="libjffi*.so"/>
        <include name="libjffi*.jnilib"/>
        <include name="libjffi*.dylib"/>
        <include name="libjffi*.a"/>
      </zipfileset>
    </zip>
  </target>

  <target name="-assemble-final-jar" depends="-init-vars, -assemble-native-jar">
    <jar jarfile="${complete.jar}" index="true" update="true" duplicate="preserve"
         filesetmanifest="skip">
      <zipfileset src="${dist.jar}"/>
      <zipfileset src="${native.jar}"/>
    </jar>
  </target>

  <target name="-assemble-native-jar" depends="-init-vars, -build-platform-jar">
    <jar jarfile="${native.jar}" index="true" update="true" duplicate="preserve"
         filesetmanifest="skip">
      <archives>
        <zips>
          <fileset dir="archive" includes="jffi-*.jar"/>
        </zips>
      </archives>
      <zipfileset src="${dist.dir}/jffi-${platform}.jar"/>
    </jar>
  </target>

  <target name="-archive-platform-jar" depends="-build-platform-jar">
    <copy file="${dist.dir}/${platform}.jar" todir="archive" flatten="true"/>
  </target>
</project>