source: branches/4.2/components/native/bf-cpp/build.xml @ 7270

Revision 7270, 7.1 KB checked in by melissa, 9 years ago (diff)

Merged r7253 into 4.2.

Line 
1<!--
2build.xml
3
4Ant build file for the Bio-Formats C++ bindings.
5Download Apache Ant from http://ant.apache.org/.
6Type "ant -p" for a list of targets.
7-->
8
9<project name="bfcpp" default="compile-proxies" basedir=".">
10  <description>
11    Build file for Bio-Formats C++ bindings
12  </description>
13  <property name="root.dir" location="../../.."/>
14  <import file="${root.dir}/ant/java.xml"/>
15  <property file="build.properties"/>
16
17  <target name="check-jace">
18    <available file="${jace.home}/release/lib" property="jaceFound"/>
19    <if>
20      <isset property="jaceFound"/>
21      <else>
22<echo>
23This component requires Jace, available from:
24  http://sourceforge.net/projects/jace/
25
26Please set the jace.home property to point to
27your Jace installation directory. E.g.:
28</echo>
29        <!-- HACK - Document need for forward slashes even on Windows. -->
30        <if>
31          <isset property="isWindows"/>
32          <then>
33<echo>
34  ant -Djace.home=C:/jace
35</echo>
36          </then>
37          <else>
38<echo>
39  ant -Djace.home=${user.home}/jace
40</echo>
41          </else>
42        </if>
43<echo>
44Please use an absolute path, not a relative one,
45and use forward slashes (/), not backslashes (\).
46
47You can check out the latest Jace code from
48the Subversion repository using the command:
49  svn co https://jace.svn.sourceforge.net/svnroot/jace/trunk jace
50</echo>
51        <fail message="Jace not found."/>
52      </else>
53    </if>
54  </target>
55
56  <target name="compile-jace" depends="check-jace"
57    description="compile Jace Java classes and create libraries">
58    <available file="${jace.home}/release/lib/jace.jar"
59      property="jaceJarsExist"/>
60    <if>
61      <isset property="jaceJarsExist"/>
62      <then>
63<echo>Jace libraries exist; run clean-jace target first to recompile.</echo>
64      </then>
65      <else>
66        <ant dir="${jace-java.dir}"/>
67      </else>
68    </if>
69  </target>
70
71  <target name="gen-proxies" depends="compile-jace, compile"
72    description="generate C++ proxies for Bio-Formats Java library">
73    <available file="${proxies.dir}" property="proxiesExist"/>
74    <if>
75      <isset property="proxiesExist"/>
76      <then>
77<echo>Proxies exist; run clean-proxies target first to regenerate.</echo>
78      </then>
79      <else>
80        <mkdir dir="${proxies.dir}/include"/>
81        <mkdir dir="${proxies.dir}/source"/>
82        <if>
83          <isset property="isWindows"/>
84          <then>
85            <!-- Generate proxies for Visual C++ builds. -->
86
87            <!-- NB: Need to fork or else Ant raises a cryptic exception. -->
88            <java classname="jace.proxy.AutoProxy" fork="true">
89              <arg path="include"/>
90              <arg path="source"/>
91              <arg path="${proxies.dir}/include"/>
92              <arg path="${proxies.dir}/source"/>
93              <arg path="${proxies.cp}"/>
94              <classpath>
95                <pathelement path="jace"/><!-- for logback.xml -->
96                <fileset dir="${jace.home}/release/lib">
97                  <include name="*.jar"/>
98                </fileset>
99              </classpath>
100              <arg value="-mindep"/>
101              <arg value="-exportsymbols"/> <!-- required for Visual C++ -->
102            </java>
103          </then>
104          <else>
105            <!-- Generate proxies for GCC and other builds. -->
106
107            <!-- NB: Need to fork or else Ant raises a cryptic exception. -->
108            <java classname="jace.proxy.AutoProxy" fork="true">
109              <arg path="include"/>
110              <arg path="source"/>
111              <arg path="${proxies.dir}/include"/>
112              <arg path="${proxies.dir}/source"/>
113              <arg path="${proxies.cp}"/>
114              <classpath>
115                <pathelement path="jace"/><!-- for logback.xml -->
116                <fileset dir="${jace.home}/release/lib">
117                  <include name="*.jar"/>
118                </fileset>
119              </classpath>
120              <arg value="-mindep"/>
121            </java>
122          </else>
123        </if>
124        <!-- Escape certain constants to dodge global namespace conflicts. -->
125        <java fork="true" classname="${component.main-class}"
126          classpath="${classes.dir}:${component.runtime-cp}">
127          <arg value="${proxies.dir}"/>
128        </java>
129      </else>
130    </if>
131  </target>
132
133  <target name="gen-makefile" depends="check-jace, gen-proxies"
134    description="generate build system for Bio-Formats C++ bindings">
135    <mkdir dir="${build.dir}"/>
136    <if>
137      <isset property="isWindows"/>
138      <then>
139        <property name="cmake.generator" value="${cmake.generator.windows}"/>
140      </then>
141      <else>
142        <property name="cmake.generator" value="${cmake.generator.other}"/>
143      </else>
144    </if>
145    <exec executable="cmake" dir="${build.dir}" failonerror="true">
146      <arg value="-G${cmake.generator}"/>
147      <arg value="-DJACE_DIR=${jace.home}"/>
148      <arg value=".."/>
149    </exec>
150  </target>
151
152  <target name="copy-libs" depends="check-jace, compile-jace">
153    <mkdir dir="${build.dir}"/>
154    <copy file="${artifact.dir}/loci_tools.jar" todir="${build.dir}"/>
155    <copy file="${jace.home}/release/lib/jace-runtime.jar"
156      todir="${build.dir}"/>
157    <if>
158      <isset property="isWindows"/>
159      <then>
160        <copy file="${build.dir}/jace-runtime.jar"
161          todir="${build.dir}/Debug"/>
162        <copy file="${build.dir}/loci_tools.jar"
163          todir="${build.dir}/Debug"/>
164        <copy file="${build.dir}/jace-runtime.jar"
165          todir="${build.dir}/release"/>
166        <copy file="${build.dir}/loci_tools.jar"
167          todir="${build.dir}/release"/>
168      </then>
169    </if>
170  </target>
171
172  <target name="compile-proxies" depends="gen-makefile, copy-libs"
173    description="build Bio-Formats C++ library">
174    <if>
175      <isset property="isWindows"/>
176      <then>
177        <exec executable="cmd" dir="${build.dir}" failonerror="true">
178          <arg value="/c"/>
179          <arg value="start"/>
180          <arg value="bfcpp.sln"/>
181        </exec>
182<echo>
183Please use Visual Studio to complete the build.
184In Visual Studio, press F7, or select
185"Build solution" from the "Build" menu.
186
187After the build is complete, you will need to
188copy jace.dll from ${build.dir}\jace\Debug to ${build.dir}\Debug
189before the executables will run.
190</echo>
191      </then>
192      <else>
193        <exec executable="make" dir="${build.dir}" failonerror="true"/>
194        <copy todir="${build.dir}" preservelastmodified="true">
195          <fileset dir="${build.dir}/jace" includes="*jace*"/>
196        </copy>
197        <chmod file="${build.dir}/libjace.jnilib" perm="ugo+x"/>
198        <if>
199          <isset property="isMac"/>
200          <then>
201            <copy file="${build.dir}/libjace.jnilib"
202              tofile="${build.dir}/libjace.dylib"/>
203            <chmod file="${build.dir}/libjace.dylib" perm="ugo+x"/>
204          </then>
205        </if>
206      </else>
207    </if>
208  </target>
209
210  <target name="clean-jace" depends="check-jace"
211    description="remove Jace build files and libraries">
212    <ant dir="${jace-java.dir}" target="clean"/>
213    <delete file="${jace.home}/release/lib/jace.jar"/>
214    <delete file="${jace.home}/release/lib/jace-runtime.jar"/>
215  </target>
216
217  <target name="clean-proxies" description="remove generated C++ proxies">
218    <delete dir="${proxies.dir}"/>
219  </target>
220</project>
Note: See TracBrowser for help on using the repository browser.