-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
150 lines (125 loc) · 5.83 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
<!--
Areca's ant compilation script
Builds Areca's main jar file (areca.jar) and library file (libarecafs.so ... for unix-like operating systems)
Syntax : ant -buildfile compile.xml
-->
<project name="Areca compilation" default="compileall" xmlns:ivy="antlib:org.apache.ivy.ant">
<description>Areca's compilation script</description>
<property name="root" value="."/>
<!-- Path to SWT libraries (download the SWT package if this file is missing on your system) -->
<property name="swtfile" value="${root}/lib/swt.jar"/>
<property name="scripts.dir" value="${root}/building/scripts"/>
<import file="${scripts.dir}/swt-platform.xml"/>
<import file="${scripts.dir}/dependency-manager.xml"/>
<import file="${scripts.dir}/bundlers.xml"/>
<!-- Test the OS -->
<condition property="isWindows">
<and>
<os family="windows"/>
</and>
</condition>
<!-- (2017) javah until Java 9 -->
<available property="javah.present" file="javah" type="file"/>
<target name="generate-jni-header-until-java-9" if="javah.present" description="javah until Java 9 (2017)">
<javah destdir="${root}/jni" force="yes" classpath="${root}/lib/areca.jar">
<class name="com.myJava.file.metadata.posix.jni.wrapper.FileAccessWrapper"/>
</javah>
</target>
<target name="generate-jni-header-since-java-10" unless="javah.present">
<exec dir="${root}" executable="javac">
<arg value="-h"/>
<arg value="${root}/jni"/>
<arg value="-classpath"/>
<arg value="${root}/lib/areca.jar"/>
<arg value="${root}/src/com/myJava/file/metadata/posix/jni/wrapper/FileAccessWrapper.java"/>
</exec>
</target>
<target name="compilejava">
<description>Java compilation task (builds areca.jar)</description>
<delete dir="${root}/classes"/>
<mkdir dir="${root}/classes"/>
<javac srcdir="${root}/src"
destdir="${root}/classes"
debug="off"
source="8"
encoding="ISO-8859-1"
>
<classpath>
<fileset dir="${root}/lib">
<include name="**/*.jar"/>
</fileset>
<fileset file="${swtfile}"/>
</classpath>
</javac>
<jar destfile="${root}/lib/areca.jar">
<fileset dir="${root}/classes"/>
<fileset dir="${root}">
<include name="icons/**"/>
</fileset>
</jar>
<delete dir="${root}/classes"/>
</target>
<target name="jnicheck" if="isWindows">
<echo>No JNI needed on Windows</echo>
</target>
<target name="compilejni" unless="isWindows">
<description>JNI compilation task (builds libarecafs.so ... for unix-like operating systems only)</description>
<!--Generate the JNI header-->
<antcall target="generate-jni-header-until-java-9"/>
<antcall target="generate-jni-header-since-java-10"/>
<chmod file="${scripts.dir}/install-c-header-dependencies-from-dep-packges.sh" perm="755" type="file"/>
<exec dir="${scripts.dir}" executable="./install-c-header-dependencies-from-dep-packges.sh" os="Linux"/>
<chmod file="${scripts.dir}/locate-jni-headers.sh" perm="755" type="file"/>
<exec dir="${scripts.dir}" executable="./locate-jni-headers.sh" os="Linux" outputproperty="jni.h.dir"/>
<available type="file" file="${jni.h.dir}/linux/jni_md.h" property="jni_md.h.dir" value="${jni.h.dir}/linux"/>
<chmod file="${scripts.dir}/locate-jni-headers.sh" perm="755" type="file"/>
<exec dir="${scripts.dir}" executable="./locate-jni-headers.sh" os="Linux" outputproperty="jni.h.dir"/>
<available type="file" file="${jni.h.dir}/linux/jni_md.h" property="jni_md.h.dir" value="${jni.h.dir}/linux"/>
<!-- Compile the JNI code -->
<exec dir="${root}/jni" executable="gcc">
<arg value="-c"/>
<arg value="-fPIC"/>
<arg value="-lacl"/>
<arg value="com_myJava_file_metadata_posix_jni_wrapper_FileAccessWrapper.c"/>
<arg value="-o"/>
<arg value="com_myJava_file_metadata_posix_jni_wrapper_FileAccessWrapper.o"/>
<arg value="-I${jni.h.dir}"/>
<arg value="-I${jni_md.h.dir}"/>
</exec>
<exec dir="${root}/jni" executable="gcc">
<arg value="-shared"/>
<arg value="-lacl"/>
<arg value="-o"/>
<arg value="libarecafs.so"/>
<arg value="com_myJava_file_metadata_posix_jni_wrapper_FileAccessWrapper.o"/>
</exec>
<delete file="${root}/jni/com_myJava_file_metadata_posix_jni_wrapper_FileAccessWrapper.o"/>
<delete file="${root}/jni/com_myJava_file_metadata_posix_jni_wrapper_FileAccessWrapper.h"/>
<move file="${root}/jni/libarecafs.so" todir="${root}/lib"/>
</target>
<target name="setpermissions" unless="isWindows">
<description>Set executable permissions</description>
<chmod perm="755">
<fileset dir="${root}/bin">
<include name="**"/>
</fileset>
<fileset dir="${root}/jni">
<include name="*.sh"/>
</fileset>
<fileset dir="${root}/building/scripts">
<include name="*.sh"/>
</fileset>
<fileset dir="${root}">
<include name="*.sh"/>
</fileset>
</chmod>
</target>
<target name="compileall">
<description>Global compilation task (builds areca.jar and libarecafs.so)</description>
<antcall target="get-java-dependencies"/>
<antcall target="compilejava"/>
<antcall target="jnicheck"/>
<antcall target="compilejni"/>
<antcall target="setpermissions"/>
</target>
</project>