-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.xml
More file actions
217 lines (186 loc) · 7.41 KB
/
build.xml
File metadata and controls
217 lines (186 loc) · 7.41 KB
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
<?xml version="1.0"?>
<!--
Copyright (c) 2022-2026 GS1 AISBL.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="gs1encoders" default="all" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<description>Java binding for GS1 Barcode Syntax Engine.</description>
<!-- ========== Platform Detection ========== -->
<condition property="os.family" value="darwin">
<os family="mac"/>
</condition>
<condition property="os.family" value="win32">
<os family="windows"/>
</condition>
<condition property="os.family" value="linux">
<os family="unix" name="Linux"/>
</condition>
<!-- ========== Compiler selection ========== -->
<condition property="is.compiler.cl" value="true">
<os family="windows"/>
</condition>
<condition property="is.compiler.cc" value="true">
<not>
<isset property="is.compiler.cl"/>
</not>
</condition>
<!-- ========== JNI Library Naming ========== -->
<condition property="jnilib" value="libgs1encodersjni.dylib">
<os family="mac"/>
</condition>
<condition property="jnilib" value="gs1encodersjni.dll">
<os family="windows"/>
</condition>
<condition property="jnilib" value="libgs1encodersjni.so">
<not>
<isset property="jnilib"/>
</not>
</condition>
<condition property="jnilink" value="libgs1encoders.dylib">
<os family="mac"/>
</condition>
<condition property="jnilink" value="libgs1encoders.so">
<os family="unix" name="Linux"/>
</condition>
<!-- ========== Strip Settings ========== -->
<condition property="should.strip" value="true">
<os family="unix" name="Linux"/>
</condition>
<!-- ========== Linker flags for Unix ========== -->
<condition property="ldargs" value="" else="-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--no-as-needed">
<os family="mac"/>
</condition>
<condition property="ldwholearchive" value="" else="-Wl,--whole-archive">
<os family="mac"/>
</condition>
<condition property="ldnowholearchive" value="" else="-Wl,--no-whole-archive">
<os family="mac"/>
</condition>
<!-- ========== Properties ========== -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="classes" location="${build}/classes"/>
<property name="jar" location="libgs1encoders.jar"/>
<property name="wrapfile" location="gs1encoders_wrap.c"/>
<property name="clib" location="../c-lib"/>
<property name="junit-jar" location="${build}/junit-platform-console-standalone.jar"/>
<!-- For Windows builds -->
<property name="platform" value="x64" />
<property name="configuration" value="Debug" />
<property name="dlldir" value="${clib}/build/library/${platform}/${configuration}/"/>
<target name="init">
<tstamp/>
<mkdir dir="${classes}"/>
</target>
<target name="cc-cc" if="is.compiler.cc">
<exec executable="cc" failonerror="true">
<arg line="-fPIC -O2 -g -Werror -fvisibility=hidden" />
<arg line="-I${clib}" />
<arg line="-I${java.home}/../include" />
<arg line="-I${java.home}/../include/${os.family}" />
<arg line="-I${java.home}/include" />
<arg line="-I${java.home}/include/${os.family}" />
<arg line="${ldargs}" />
<arg line="${ldwholearchive} ${clib}/build/libgs1encoders.a ${ldnowholearchive}" />
<arg line="-shared" />
<arg line="-o ${jnilib}" />
<arg line="${wrapfile}" />
</exec>
</target>
<target name="cc-cl" if="is.compiler.cl">
<exec executable="cl.exe" failonerror="true">
<arg line="/LD /MD /O2 /EHsc" />
<arg line="/I${clib}" />
<arg line="'-I${java.home}/include'" />
<arg line="'-I${java.home}/include/${os.family}'" />
<arg line="/Fe:${jnilib}" />
<arg line="${dlldir}/gs1encoders.lib ${wrapfile}" />
</exec>
</target>
<target name="strip" depends="cc-cc,cc-cl" if="should.strip">
<exec executable="strip" failonerror="true">
<arg line="${jnilib}" />
</exec>
</target>
<target name="symlink" if="jnilink">
<exec executable="ln">
<arg value="-sf"/>
<arg value="${jnilib}"/>
<arg value="${jnilink}"/>
</exec>
</target>
<target name="copydll" unless="jnilink">
<copy file="${dlldir}/gs1encoders.dll" todir="${src}"/>
</target>
<target name="jni" depends="strip,symlink,copydll" if="jnilink"/>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${classes}" includeantruntime="false">
<compilerarg value="-Werror"/>
<exclude name="*"/>
</javac>
</target>
<target name="jar" depends="compile">
<jar destfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Implementation-Vendor" value="GS1 AISBL"/>
<attribute name="Implementation-Title" value="GS1 Encoders Library"/>
<attribute name="Implementation-Version" value="1.3.2"/>
</manifest>
</jar>
</target>
<target name="all" depends="jar,jni"/>
<target name="fetch-junit" depends="init">
<get src="https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.11.4/junit-platform-console-standalone-1.11.4.jar"
dest="${junit-jar}"
skipexisting="true"/>
</target>
<target name="compile-test" depends="all,fetch-junit">
<javac includes="GS1EncoderTest.java" srcdir="${src}" destdir="${src}" includeantruntime="false" classpath=".:${jar}:${junit-jar}">
<compilerarg value="-Werror"/>
</javac>
</target>
<target name="example" depends="all">
<javac includes="Example.java" srcdir="${src}" destdir="${src}" includeantruntime="false" classpath=".:${jar}">
<compilerarg value="-Werror"/>
</javac>
<echo>To run: java -Djava.library.path=${src} -classpath ${src}:${jar} Example</echo>
</target>
<target name="test" depends="example,compile-test">
<copy file="${clib}/gs1-syntax-dictionary.txt" todir="${src}" overwrite="true"/>
<java classname="Example" failonerror="true" classpath="${src}:${jar}" fork="true">
<sysproperty key="java.library.path" path="${src}"/>
<arg value="--version"/>
</java>
<java classname="org.junit.platform.console.ConsoleLauncher" failonerror="true" fork="true">
<classpath>
<pathelement location="${junit-jar}"/>
<pathelement location="${src}"/>
<pathelement location="${jar}"/>
</classpath>
<sysproperty key="java.library.path" path="${src}"/>
<arg value="execute"/>
<arg value="--select-class=GS1EncoderTest"/>
</java>
</target>
<target name="clean" description="clean up">
<delete dir="${build}"/>
<delete file="${jar}"/>
<delete file="${jnilib}"/>
<delete file="${jnilink}"/>
<delete file="${src}/gs1encoders.dll"/>
<delete file="${src}/gs1encodersjni.exp"/>
<delete file="${src}/gs1encodersjni.lib"/>
<delete file="${src}/gs1encoders_wrap.obj"/>
<delete file="${src}/Example.class"/>
<delete file="${src}/GS1EncoderTest.class"/>
<delete file="${src}/gs1-syntax-dictionary.txt"/>
</target>
</project>