forked from kwhat/jnativehook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cross.build.xml
368 lines (299 loc) · 14.9 KB
/
cross.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
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
JNativeHook: Global keyboard and mouse hooking for Java.
Copyright (C) 2006-2017 Alexander Barker. All Rights Received.
https://github.com/kwhat/jnativehook/
JNativeHook is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
JNativeHook 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 Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project name="cross-compile" default="all" basedir=".">
<!-- Project Settings -->
<property file="build.num" />
<tstamp>
<format property="ant.build.date" pattern="yyyyMMdd" />
</tstamp>
<property name="ant.build.revision" value="${ant.build.date}" />
<property file="cross.build.properties" />
<property environment="env" />
<!-- Path Settings -->
<property name="dir.maven" value="${basedir}/maven" />
<!-- Class Path Settings -->
<path id="ant.project.class.path">
<fileset dir="${basedir}">
<include name="*.jar" />
</fileset>
<pathelement path="${java.class.path}" />
</path>
<target name="configure" description="Initialize local build environment.">
<echo>Initializing local build environment...</echo>
<!-- Set a few static properties for the project. -->
<property name="ant.build.debug" value="true" />
<property name="ant.build.javac.compiler" value="modern" />
<property name="ant.build.javac.source" value="1.5" />
<property name="ant.build.javac.target" value="1.5" />
<!-- Preform download target checks. -->
<available file="jnitasks/build.xml" property="project.check.jnitasks.download" />
<!-- Try to locate the rt.jar location for ant.build.javac.bootclasspath -->
<condition property="ant.build.javac.bootclasspath" value="${env.JDK_HOME}/jre/lib/rt.jar">
<available file="${env.JDK_HOME}/lib/rt.jar" type="dir" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${env.JAVA_HOME}/lib/rt.jar">
<available file="${env.JAVA_HOME}/lib/rt.jar" type="dir" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${java.home}/lib/rt.jar">
<available file="${java.home}/lib/rt.jar" type="file" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${env.JDK_HOME}/bundle/Classes/classes.jar">
<available file="${env.JDK_HOME}/bundle/Classes/classes.jar" type="dir" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${env.JAVA_HOME}/bundle/Classes/classes.jar">
<available file="${env.JAVA_HOME}/bundle/Classes/classes.jar" type="dir" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${java.home}/bundle/Classes/classes.jar">
<available file="${java.home}/bundle/Classes/classes.jar" type="file" />
</condition>
<fail message="Could not determine ant.build.javac.bootclasspath location. Please set your JDK_HOME / JAVA_HOME environment variable or manually set the ant.build.javac.bootclasspath property to the location of your rt.jar file.">
<condition>
<not>
<or>
<isset property="ant.build.javac.bootclasspath" />
<available file="${ant.build.javac.bootclasspath}" type="file" />
</or>
</not>
</condition>
</fail>
<echo level="info">Found Java lib location: ${ant.build.javac.bootclasspath}</echo>
<property name="ant.build.javac.args" value="-bootclasspath ${ant.build.javac.bootclasspath} -Xlint:-options" />
<!-- Try to locate the env path variable -->
<condition property="native.path" value="">
<isset property="env.PATH" />
</condition>
<condition property="native.path" value="${env.Path}">
<isset property="env.Path" />
</condition>
<condition property="native.path" value="${env.path}">
<isset property="env.path" />
</condition>
<!-- Check for clang before assuming gcc toolchain. -->
<condition property="ant.build.native.toolchain" value="clang" else="gcc">
<and>
<available filepath="${env.PATH};${env.Path};${env.path}" file="clang" type="file" />
<not>
<available filepath="${env.PATH};${env.Path};${env.path}" file="gcc" type="file" />
</not>
</and>
</condition>
<!-- Create property file for the descovered values. -->
<propertyfile file="cross.build.properties" comment="Auto-generated by ant configure">
<entry key="ant.build.debug" value="${ant.build.debug}" />
<entry key="ant.build.javac.compiler" value="${ant.build.javac.compiler}" />
<entry key="ant.build.javac.source" value="${ant.build.javac.source}" />
<entry key="ant.build.javac.target" value="${ant.build.javac.target}" />
<entry key="ant.build.javac.args" value="${ant.build.javac.args}" />
</propertyfile>
</target>
<target name="clean" description="Removes downloaded project files.">
<ant antfile="build.xml" dir="${basedir}" inheritAll="true">
<target name="distclean" />
</ant>
<delete includeEmptyDirs="true" verbose="true" failonerror="false">
<fileset dir="jnitasks" />
<fileset file="jnitasks-0.3.zip" />
<fileset dir="${dir.maven}" />
<fileset file="cross.build.properties" />
<fileset file="pom.xml*" />
</delete>
</target>
<target name="download-jnitasks" depends="configure" unless="project.check.jnitasks.download" description="Download and initialize the JNITasks library.">
<echo>Downloading JNITasks source...</echo>
<mkdir dir="${basedir}/jnitasks" />
<get src="https://github.com/kwhat/jnitasks/archive/0.3.zip" dest="ant-jnitasks-0.3.zip" verbose="true" />
<unzip src="ant-jnitasks-0.3.zip" dest="${basedir}/jnitasks">
<mapper type="glob" from="ant-jnitasks-0.3/*" to="*"/>
</unzip>
<!-- Fix clock skew. -->
<touch>
<fileset dir="jnitasks" includes="**/*" />
</touch>
</target>
<target name="compile-jnitasks" depends="download-jnitasks" description="Build the JNITasks library.">
<echo>Compiling JNITasks source...</echo>
<mkdir dir="${basedir}/jnitasks" />
<ant antfile="${basedir}/jnitasks/build.xml" dir="${basedir}/jnitasks" inheritAll="false">
<target name="compile" />
<target name="jar" />
<!-- We need to override the src and bin locations. -->
<property name="dir.bin" value="${basedir}/jnitasks/bin" />
<property name="dir.src" value="${basedir}/jnitasks/src" />
<property name="dir.jar" value="${basedir}" />
<!-- Set a few of the configurable properties. -->
<property name="ant.build.debug" value="${ant.build.debug}" />
<property name="ant.build.javac.compiler" value="${ant.build.javac.compiler}" />
<property name="ant.build.javac.source" value="${ant.build.javac.source}" />
<property name="ant.build.javac.target" value="${ant.build.javac.target}" />
<property name="ant.build.javac.args" value="${ant.build.javac.args}" />
</ant>
</target>
<!-- Note: This target is called recursivly from the compile task with the aproprate properties. -->
<target name="-compile-cross" description="Cross compile the native portions of the project.">
<fail message="You must set ant.build.native.host to cross compile.">
<condition>
<not>
<isset property="ant.build.native.host" />
</not>
</condition>
</fail>
<delete includeEmptyDirs="true" verbose="true" failonerror="false">
<fileset dir="bin/libuiohook" />
<fileset dir="bin/obj" />
<fileset dir="bin/lib" />
</delete>
<echo>Compiling for ${ant.build.native.host}...</echo>
<ant antfile="build.xml" dir="${basedir}" inheritAll="true">
<target name="compile-libuiohook" />
<target name="compile-jni" />
</ant>
</target>
<target name="compile" depends="compile-jnitasks" description="Compiles both Java and C source files.">
<ant antfile="build.xml" dir="${basedir}" inheritAll="false">
<target name="compile-java" />
<target name="bootstrap-libuiohook" />
<property name="ant.build.javac.source" value="${ant.build.javac.source}" />
<property name="ant.build.javac.target" value="${ant.build.javac.target}" />
<property name="ant.build.javac.args" value="-bootclasspath ${ant.build.javac.bootclasspath}" />
</ant>
<ant antfile="cross.build.xml" target="-compile-cross" dir="${basedir}" inheritAll="false">
<property file="targets/armv6j-hardfloat-linux-gnueabihf.properties" />
</ant>
<ant antfile="cross.build.xml" target="-compile-cross" dir="${basedir}" inheritAll="false">
<property file="targets/x86_64-w64-mingw32.properties" />
</ant>
<ant antfile="cross.build.xml" target="-compile-cross" dir="${basedir}" inheritAll="false">
<property file="targets/x86_64-pc-linux-gnu.properties" />
</ant>
<ant antfile="cross.build.xml" target="-compile-cross" dir="${basedir}" inheritAll="false">
<property file="targets/x86_64-apple-darwin.properties" />
</ant>
<ant antfile="cross.build.xml" target="-compile-cross" dir="${basedir}" inheritAll="false">
<property file="targets/i586-w32-mingw32.properties" />
</ant>
<ant antfile="cross.build.xml" target="-compile-cross" dir="${basedir}" inheritAll="false">
<property file="targets/i586-pc-linux-gnu.properties" />
</ant>
<ant antfile="cross.build.xml" target="-compile-cross" dir="${basedir}" inheritAll="false">
<property file="targets/i586-apple-darwin.properties" />
</ant>
</target>
<target name="package" depends="" description="Creates zip files for distribution.">
<ant antfile="build.xml" dir="${basedir}" target="package" inheritAll="false">
<property name="ant.build.major" value="${ant.build.major}" />
<property name="ant.build.minor" value="${ant.build.minor}" />
<property name="ant.build.revision" value="${ant.build.revision}" />
</ant>
</target>
<target name="maven" description="Creates files required for maven deployment.">
<!-- Define the Maven Ant tasks provided by classpathref. -->
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" classpathref="ant.project.class.path" onerror="failall" />
<!-- Check to see if the build revision matches the date to see if this is a snapshot deployment. -->
<condition property="maven.pom.version" value="${ant.build.major}.${ant.build.minor}.SNAPSHOT" else="${ant.build.major}.${ant.build.minor}.${ant.build.revision}">
<equals arg1="${ant.build.date}" arg2="${ant.build.revision}"/>
</condition>
<condition property="maven.repository.url" value="https://oss.sonatype.org/content/repositories/snapshots" else="https://oss.sonatype.org/service/local/staging/deploy/maven2">
<equals arg1="${ant.build.date}" arg2="${ant.build.revision}"/>
</condition>
<!-- This is the server id in the Maven .m2/settings.xml file. -->
<property name="maven.repository.id" value="ossrh" />
<property name="maven.jar.base" value="jnativehook-${ant.build.major}.${ant.build.minor}" />
<echo>Creating jars for Maven deployment...</echo>
<mkdir dir="${dir.maven}" />
<delete verbose="true" failonerror="false">
<fileset dir="${dir.maven}" includes="**/*" />
</delete>
<copy file="${basedir}/jar/jnativehook-${ant.build.major}.${ant.build.minor}.${ant.build.revision}.jar" tofile="${dir.maven}/${maven.jar.base}.jar"/>
<jar jarfile="${dir.maven}/${maven.jar.base}-sources.jar" basedir="${basedir}" update="true" compress="true" level="9">
<include name="targets/**/*.properties" />
<include name="src/java/**/*" />
<include name="src/jni/**/*" />
<include name="src/test/**/*" />
<exclude name="src/jni/include/org_jnativehook_GlobalScreen.h" />
<exclude name="src/jni/include/org_jnativehook_GlobalScreen_EventDispatchTask.h" />
<exclude name="src/jni/include/org_jnativehook_GlobalScreen_NativeHookThread.h" />
<include name="src/libuiohook/include/uiohook.h" />
<include name="src/libuiohook/m4/ax_*.m4" />
<include name="src/libuiohook/man/*" />
<include name="src/libuiohook/pc/uiohook.pc.in" />
<include name="src/libuiohook/src/**/*" />
<include name="src/libuiohook/test/**/*" />
<include name="src/libuiohook/AUTHORS" />
<include name="src/libuiohook/bootstrap.sh" />
<include name="src/libuiohook/*.am" />
<include name="src/libuiohook/*.md" />
<include name="src/libuiohook/*.ac" />
<include name="build.num" />
<include name="build.xml" />
<include name="cross.build.xml" />
<include name="AUTHORS" />
<include name="*.md" />
</jar>
<jar jarfile="${dir.maven}/${maven.jar.base}-javadoc.jar" basedir="${basedir}/doc" update="true" compress="true" level="9">
<include name="**/*" />
</jar>
<echo>Creating pom.xml file...</echo>
<pom
id="maven.pom.id"
groupId="com.1stleg"
artifactId="jnativehook"
version="${maven.pom.version}"
name="JNativeHook"
description="Global keyboard and mouse listeners for Java."
url="https://github.com/kwhat/jnativehook"
>
<license name="GNU General Public License (GPL), Version 3.0" url="https://www.gnu.org/licenses/gpl-3.0.txt" />
<license name="GNU Lesser General Public License (LGPL), Version 3.0" url="https://www.gnu.org/licenses/lgpl-3.0.txt" />
<developer name="Alexander Barker" email="[email protected]" organization="Personal" organizationurl="https://github.com/kwhat/" />
<scm
connection="scm:git:[email protected]:kwhat/jnativehook.git"
developerconnection="scm:git:[email protected]:kwhat/jnativehook.git"
url="[email protected]:kwhat/jnativehook.git" />
</pom>
<writepom pomRefId="maven.pom.id" file="pom.xml" trim="true" />
<echo>Create GPG signatures and deploy jars...</echo>
<!-- Maven Version is required because gentoo doesnt support maven, again. -->
<mvn mavenVersion="2.2.1">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.6:sign-and-deploy-file" />
<arg value="-Durl=${maven.repository.url}" />
<arg value="-DrepositoryId=${maven.repository.id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dfile=${dir.maven}/${maven.jar.base}.jar" />
<!-- arg value="-Pgpg" /-->
</mvn>
<mvn mavenVersion="2.2.1">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.6:sign-and-deploy-file" />
<arg value="-Durl=${maven.repository.url}" />
<arg value="-DrepositoryId=${maven.repository.id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dfile=${dir.maven}/${maven.jar.base}-sources.jar" />
<arg value="-Dclassifier=sources" />
<!-- arg value="-Pgpg" /-->
</mvn>
<mvn mavenVersion="2.2.1">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.6:sign-and-deploy-file" />
<arg value="-Durl=${maven.repository.url}" />
<arg value="-DrepositoryId=${maven.repository.id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dfile=${dir.maven}/${maven.jar.base}-javadoc.jar" />
<arg value="-Dclassifier=javadoc" />
<!-- arg value="-Pgpg" /-->
</mvn>
</target>
<target name="all" depends="compile,package" description="Compile all source files and create the jar library.">
</target>
</project>