-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.xml
192 lines (182 loc) · 6.47 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
<?xml version="1.0" ?>
<!--
Copyright (c) 2011, Conor McDermottroe
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-->
<project name="osxkeychain" default="jar" basedir=".">
<target name="build" depends="build-c,build-java">
</target>
<target name="build-dest">
<mkdir dir="lib" />
</target>
<target name="build-java" depends="build-dest,codegen">
<javac destdir="lib" includeantruntime="false" debug="true">
<src path="src/java" />
</javac>
</target>
<target name="build-javah" depends="build-java">
<javah destdir="src/c" classpath="lib">
<class name="com.mcdermottroe.apple.OSXKeychain" />
</javah>
</target>
<target name="build-c" depends="build-dest,build-javah">
<exec executable="gcc" dir="src/c">
<arg value="-arch" />
<arg value="i386" />
<arg value="-arch" />
<arg value="x86_64" />
<arg value="-mmacosx-version-min=10.5" />
<arg value="-dynamiclib" />
<arg value="-framework" />
<arg value="CoreFoundation" />
<arg value="-framework" />
<arg value="JavaVM" />
<arg value="-framework" />
<arg value="Security" />
<arg value="-I" />
<arg value="/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers" />
<arg value="-std=c99" />
<arg value="-pedantic" />
<arg value="-Wall" />
<arg value="-o" />
<arg value="${basedir}/lib/com/mcdermottroe/apple/osxkeychain.so" />
<arg value="com_mcdermottroe_apple_OSXKeychain.c" />
</exec>
</target>
<target name="codegen" depends="codegen-generate_enums">
</target>
<target name="codegen-generate_enums" depends="codegen-generate_enums-build">
<exec executable="src/c/codegen/generate_enums">
<arg value="src/java/com/mcdermottroe/apple/OSXKeychainAuthenticationType.java" />
<arg value="src/java/com/mcdermottroe/apple/OSXKeychainProtocolType.java" />
</exec>
</target>
<target name="codegen-generate_enums-build">
<exec executable="gcc" dir="src/c/codegen">
<arg value="-arch" />
<arg value="i386" />
<arg value="-arch" />
<arg value="x86_64" />
<arg value="-mmacosx-version-min=10.5" />
<arg value="-framework" />
<arg value="Security" />
<arg value="-std=c99" />
<arg value="-pedantic" />
<arg value="-Wall" />
<arg value="-o" />
<arg value="generate_enums" />
<arg value="generate_enums.c" />
</exec>
</target>
<target name="jar" depends="build">
<mkdir dir="dist" />
<jar destfile="dist/osxkeychain.jar" basedir="lib" index="true" />
</target>
<target name="dist" depends="jar,doc">
<zip destfile="dist/osxkeychain.zip">
<zipfileset dir="." includes="README.md" prefix="osxkeychain" />
<zipfileset dir="dist" includes="osxkeychain.jar" prefix="osxkeychain" />
<zipfileset dir="doc" prefix="osxkeychain/doc" />
</zip>
</target>
<target name="clean">
<delete dir="doc" />
<delete dir="lib" />
<delete file="src/c/codegen/generate_enums" />
<delete file="src/c/com_mcdermottroe_apple_OSXKeychain.h" />
<delete file="src/java/com/mcdermottroe/apple/OSXKeychainAuthenticationType.java" />
<delete file="src/java/com/mcdermottroe/apple/OSXKeychainProtocolType.java" />
<delete file="test/c/fakejni.o" />
<delete file="test/c/test" />
</target>
<target name="distclean" depends="clean">
<delete dir="dist" />
</target>
<target name="doc" depends="build">
<mkdir dir="doc" />
<javadoc
destdir="doc"
sourcepath="src/java"
use="true"
>
<link href="http://java.sun.com/j2se/1.5.0/docs/api"/>
</javadoc>
</target>
<target name="test" depends="test-c,test-java">
</target>
<target name="test-c" depends="test-c-build">
<exec executable="${basedir}/test/c/test" failonerror="true">
</exec>
</target>
<target name="test-c-build" depends="test-c-build-fakejni,build-javah">
<exec executable="gcc" dir="test/c">
<arg value="-framework" />
<arg value="CoreFoundation" />
<arg value="-framework" />
<arg value="Security" />
<arg value="-I" />
<arg value="/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers" />
<arg value="-std=c99" />
<arg value="-pedantic" />
<arg value="-Wall" />
<arg value="-o" />
<arg value="test" />
<arg value="test.c" />
<arg value="fakejni.o" />
</exec>
</target>
<target name="test-c-build-fakejni">
<exec executable="gcc" dir="test/c">
<arg value="-std=c99" />
<arg value="-pedantic" />
<arg value="-Wall" />
<arg value="-c" />
<arg value="-o" />
<arg value="fakejni.o" />
<arg value="fakejni.c" />
</exec>
</target>
<target name="test-java" depends="test-java-no-junit,test-java-junit">
</target>
<target name="test-java-no-junit" unless="junit.jar">
<echo message="You didn't pass a value for junit.jar. Skipping JUnit tests."></echo>
</target>
<target name="test-java-junit" if="junit.jar">
<antcall target="dist" />
<antcall target="test-java-junit-build" />
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<pathelement location="lib"/>
<pathelement location="${junit.jar}"/>
</classpath>
<batchtest todir="lib">
<fileset dir="test/java">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="test-java-junit-build">
<javac destdir="lib" includeantruntime="false" debug="true" classpath="${junit.jar}">
<src path="test/java" />
</javac>
</target>
</project>