summaryrefslogtreecommitdiffstats
path: root/java/build.xml
blob: 66dc02c9519b906acf7b5b29246675265ed15ed9 (plain)
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
<?xml version="1.0"?>
<!-- 
 * Copyright (C) 2008 Martin Pischky (mailto:martin@pischky.de)  
 *
 * This file (build.xml) is part of libk8055/jk8055.
 * jk8055 - a java wrapper for libk8055
 *
 *
 * libk8055/jk8055 is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 *
 * $Id: build.xml,v 1.4 2008/07/28 09:58:30 pischky Exp $ 
-->
<project name="jk8055" default="all">
    <description>
            java wrapper for libk8055
    </description>
	
    <property environment="env" />

    <!-- some files -->
	
	<property name="file.base" value="jk8055" />
	<property name="file.c"    location="src/c/${file.base}.c" />
	
	<property name="version"   value="0.3" />
		
    <!-- set global properties for building -->
	
    <property file="build.properties" />
    <property file="${user.home}/build.properties" />
    <!-- example (build.properties is not stored in cvs):
    # My installation of M$ VS 2003. 
    # Use VS 2003 Command Prompt to get the value
    VSINSTALLDIR=D:\\Programme\\Visual Studio .NET 2003\\Common7\\IDE
    VCINSTALLDIR=D:\\Programme\\Microsoft Visual Studio .NET 2003
    # My installation of the java development kit
    jdk.home=D:\\j2sdk1.4.2_11
    # My installation of the Velleman "K8055D_C.lib", "K8055D_C.DLL",
    # "K8055D_C.h" and "K8055D.DLL"
    VellemanDir=D:\\Programme\\Velleman\\K8055
    -->

	<!-- set properties if not definded in build.properties -->
	
	<!-- guess java development kit -->
	<property name="jdk.home" value="${env.JDK_HOME}" />
	
	<!-- guess c compiler for windows (eg.: microsoft visual studio 2003) -->
	<property name="VSINSTALLDIR"
	          location="${env.ProgramFiles}\Microsoft Visual Studio .NET 2003\Common7\IDE" />
	<property name="VCINSTALLDIR" 
              location="${env.ProgramFiles}\Microsoft Visual Studio .NET 2003" />
	<property name="MSVCDir"
		      location="${VCINSTALLDIR}\VC7" />
	<property name="DevEnvDir"
	          location="${VSINSTALLDIR}" />
	<property name="VellemanDir"
	          location="C:\Program Files\Velleman\K8055" />
	
	<target name="init">
        <echo message="running ant '${ant.version}'" level="info" />
        <echo message="on java '${ant.java.version}'" level="info" />
        <echo message="java.home='${java.home}'" level="info" />
        <echo message="jdk.home ='${jdk.home}'" level="info" />
		<mkdir dir="build/java" />
		<mkdir dir="build/c"    />
		<mkdir dir="dist"       />
        <mkdir dir="dist/win32" />
        <mkdir dir="dist/linux" />
	</target>

    <target name="compile-java" depends="init">
        <javac srcdir="src/java" destdir="build/java">
		    <include name="**/*.java"/>
        	<exclude name="**/*Test.java"/>
        </javac>
    	<javah classpath="build/java"
    		   class="net.sf.libk8055.jk8055.JK8055" 
    		   outputfile="build/c/jk8055.h" />
    </target>
	
	<target name="compile-c" depends="compile-java">
    	<javah classpath="build/java"
    		   class="net.sf.libk8055.jk8055.JK8055" 
    		   outputfile="build/c/jk8055.h" />
		<exec executable="gcc" dir="build/c" os="Linux">
			<arg line='-o lib${file.base}.so 
				       -shared 
				       -Wl,-soname,lib${file.base}.so 
				       -I${jdk.home}/include 
                       -I${jdk.home}/include/linux 
				       -I. 
				       -lk8055
				       "${file.c}"' />
		</exec>
		<exec executable="${MSVCDir}\BIN\cl.exe" dir="build/c" 
			  os="Windows 2000, Windows XP" failonerror="true">
			<!-- be carefull with case here ! -->
			<env key="Path" path="${DevEnvDir};${MSVCDir}\BIN;${env.Path}" />
            <env key="INCLUDE" path="${MSVCDir}\INCLUDE;${env.INCLUDE}" />
            <env key="LIB" path="${MSVCDir}\LIB;${env.LIB}" />
			<arg line='-I "${jdk.home}\include" 
			           -I "${jdk.home}\include\win32" 
                       -I "${VellemanDir}" 
                       -I. 
			           -DUSE_VELLEMAN_DLL
                       -LD 
                       "${file.c}"
                       -Fe${file.base}.dll
			           -link "${VellemanDir}\K8055D_C.lib"' />
		</exec>
	</target>
	
	<target name="dist" depends="compile-c" 
        description="create files for distribution">
        <copy todir="dist/linux" failonerror="false">
            <fileset dir="build/c">
                <include name="lib${file.base}.so"/>
            </fileset>
        </copy>
        <copy todir="dist/win32" failonerror="false">
            <fileset dir="build/c">
                <include name="${file.base}.dll"/>
            </fileset>
            <fileset dir="${VellemanDir}">
                <include name="K8055D_C.DLL"/>
                <include name="K8055D.DLL"/>
            </fileset>
        </copy>
		<jar destfile="dist/${file.base}-${version}.jar" basedir="build/java">
            <manifest>
            	<attribute name="Built-By" value="${user.name}"/>
                <attribute name="JK8055-Version" value="${version}"/>
            </manifest>
		</jar>
	</target>
	
   <target name="javadoc" depends="compile-java" 
   	       description="create component Javadoc documentation">
	   <mkdir dir="build/docs"/>
	   <mkdir dir="build/docs/api"/>
       <javadoc destdir="build/docs/api" 
       	        overview="src/java/net/sf/libk8055/jk8055/overview.html" 
       	        packagenames="net.sf.libk8055.jk8055" 
       	        author="true" 
       	        version="true" 
       	        doctitle="&lt;h1&gt;JK8055&lt;/h1&gt;" 
       	        windowtitle="JK8055 (Version ${version})" 
       	        bottom="Copyright &amp;copy; 2008 by Martin Pischky" 
       	        use="true" 
       	        link="http://java.sun.com/j2se/1.4/docs/api/">
            <fileset dir="src/java">
                <include name="**/*.java"/>
                <exclude name="**/*Test.java"/>
       		</fileset>
	    </javadoc>
        <jar jarfile="dist/${file.base}-${version}-javadoc.jar" 
        	 basedir="build/docs/api" />
    </target>
	
	<target name="junit" depends="compile-c" 
		    description="run junit tests" >
		<!-- we assume that junit.jar is in ant's lib directory -->
		<mkdir dir="build/reports" />
        <mkdir dir="build/junit" />
        <javac srcdir="src/java" destdir="build/junit">
            <include name="**/*Test.java"/>
        </javac>
		<junit printsummary="yes" 
		       haltonfailure="yes" showoutput="yes">
			<classpath>
                <pathelement location="build/java" />
                <pathelement location="build/junit" />
                <pathelement path="${java.class.path}" />
			</classpath>
			<env key="Path" path="build/c;${VellemanDir};${env.Path}"/>
            <env key="LD_LIBRARY_PATH" path="build/c:${env.LD_LIBRARY_PATH}"/>
            <formatter type="plain"/>
		    <batchtest fork="yes" todir="build/reports">
		    	 <fileset dir="src/java">
		    	     <include name="**/*Test.java"/>
                 </fileset>
			</batchtest>
		</junit>
	</target>
	
	<target name="all" depends="dist, javadoc"  
	        description="--> java wrapper for libk8055">
	</target>

	<target name="clean">
		<delete dir="build"/>
	</target>
	
	<target name="distclean" depends="clean">
        <delete dir="dist"/>
	</target>

</project>