@@ -39,9 +39,9 @@ SPDX-License-Identifier: Apache-2.0
39
39
<echo message =" Building OpenSMT in version '${opensmt.version}'" />
40
40
41
41
<!-- Create build directories -->
42
- <property name =" path.build" value =" ${opensmt.path}/build" />
42
+ <property name =" path.build" value =" ${opensmt.path}/build" />
43
43
<property name =" path.install" value =" ${opensmt.path}/install" />
44
- <property name =" path.source" value =" ${user.dir}/lib/native/source/opensmt" />
44
+ <property name =" path.source" value =" ${user.dir}/lib/native/source/opensmt" />
45
45
46
46
<mkdir dir =" ${path.build}" />
47
47
<mkdir dir =" ${path.install}" />
@@ -71,13 +71,10 @@ SPDX-License-Identifier: Apache-2.0
71
71
</exec >
72
72
73
73
<!-- Copy swig files to the install directory -->
74
- <copy todir =" ${path.install}" >
75
- <fileset dir =" ${path.source}" includes =" * *" />
74
+ <copy todir =" ${path.install}" >
75
+ <fileset dir =" ${path.source}" includes =" swig/**/ *" />
76
76
</copy >
77
77
78
- <!-- Dump ${opensmt.version} to a file so that we can use it from swig -->
79
- <echo file =" ${path.install}/Version.h" >#define VERSION "${opensmt.version}"</echo >
80
-
81
78
<!-- Run swig to generate java proxies and the jni wrapper -->
82
79
<mkdir dir =" ${path.install}/java/opensmt" />
83
80
<exec executable =" swig" dir =" ${path.install}" failonerror =" true" >
@@ -93,8 +90,7 @@ SPDX-License-Identifier: Apache-2.0
93
90
<arg value =" swig/opensmt.i" />
94
91
</exec >
95
92
96
- <!-- Copy (only!) the required java files to the source tree. This should make sure that compilation fails
97
- if the OpenSMT interface changed, but the swig header wasn't updated -->
93
+ <!-- Copy the generated Java classes and the c++ wrapper to the source tree -->
98
94
<copy todir =" ${path.source}/src/org/sosy_lab/java_smt/solvers/opensmt/api" >
99
95
<fileset dir =" ${path.install}/java/opensmt" >
100
96
<include name =" ArithLogic.java" />
@@ -124,6 +120,13 @@ SPDX-License-Identifier: Apache-2.0
124
120
<include name =" VectorVectorInt.java" />
125
121
</fileset >
126
122
</copy >
123
+ <copy file =" ${path.install}/opensmt-wrap.cpp" toFile =" ${path.source}/opensmt-wrap.cpp" />
124
+
125
+ <!-- Apply the patch to add the license headers -->
126
+ <exec executable =" git" failonerror =" true" >
127
+ <arg value =" apply" />
128
+ <arg value =" ${path.source}/swigWrapper.patch" />
129
+ </exec >
127
130
128
131
<!-- Package swig generated source code -->
129
132
<jar destfile =" opensmt-${opensmt.version}-sources.jar" basedir =" ${path.source}/src" />
@@ -134,35 +137,39 @@ SPDX-License-Identifier: Apache-2.0
134
137
<jar destfile =" opensmt-${opensmt.version}-javadoc.jar" basedir =" ${path.source}/doc" />
135
138
<delete dir =" ${path.source}/doc" />
136
139
137
- <!-- Copy the lib to the root directory for later packaging -->
138
- <copy file =" ${path.install}/lib/libopensmt.so " toFile = " libopensmt- ${opensmt.version}.so " / >
140
+ <!-- Dump ${opensmt.version} to a file so that we can use it for the swig wrapper -->
141
+ <echo file =" ${path.source}/version.h " >#define VERSION " ${opensmt.version}"</ echo >
139
142
140
- <!-- Compile the wrapper and move the object file the source tree -->
141
- <exec executable =" gcc" dir =" ${path.install }" failonerror =" true" >
143
+ <!-- Compile the swig wrapper to create the library -->
144
+ <exec executable =" gcc" dir =" ${path.source }" failonerror =" true" >
142
145
<arg value =" -fPIC" />
143
- <arg value =" -std=c++17 " />
146
+ <arg value =" -std=c++20 " />
144
147
<arg value =" -o" />
145
- <arg value =" ${path.source}/ opensmt-wrap.o" />
148
+ <arg value =" opensmt-wrap.o" />
146
149
<arg value =" -c" />
147
150
<arg value =" opensmt-wrap.cpp" />
151
+ <arg value =" -I${path.install}/include/opensmt/" />
148
152
<arg value =" -I${java.home}/include/" />
149
153
<arg value =" -I${java.home}/include/linux" />
150
154
</exec >
155
+ <delete file =" ${path.source}/version.h" />
151
156
152
157
<!-- Link the wrapper and create a new lib -->
153
- <symlink link =" libopensmt.so" resource =" libopensmt-${opensmt.version}.so" />
154
158
<exec executable =" gcc" dir =" ${path.source}" failonerror =" true" >
155
159
<arg value =" -shared" />
156
160
<arg value =" -o" />
157
161
<arg value =" ${user.dir}/libopensmtjava-${opensmt.version}.so" />
158
162
<arg value =" opensmt-wrap.o" />
159
- <arg value =" -L${user.dir}" />
160
- <arg value =" -lopensmt" />
161
163
<arg value =" -lstdc++" />
162
- <arg value =" -l:libgmp.a" />
164
+ <arg value =" -Wl,--whole-archive" />
165
+ <arg value =" /dependencies/gmp-6.2.1/.libs/libgmp.a" />
166
+ <arg value =" /dependencies/gmp-6.2.1/.libs/libgmpxx.a" />
167
+ <arg value =" ${path.install}/lib/libopensmt.a" />
168
+ <arg value =" -Wl,--no-whole-archive" />
169
+ <arg value =" -lm" />
170
+ <arg value =" -Wl,-z,defs" />
163
171
</exec >
164
- <delete file =" libopensmt.so" />
165
- <delete file =" lib/native/source/opensmt/opensmt-wrap.o" />
172
+ <delete file =" ${path.source}/opensmt-wrap.o" />
166
173
167
174
<!-- Compile java proxies and create jar file -->
168
175
<mkdir dir =" ${path.source}/bin" />
@@ -171,12 +178,10 @@ SPDX-License-Identifier: Apache-2.0
171
178
</javac >
172
179
<jar destfile =" opensmt-${opensmt.version}.jar" basedir =" ${path.source}/bin" />
173
180
<delete dir =" ${path.source}/bin" />
174
- <delete dir =" lib/native/source/opensmt/src" />
175
181
</target >
176
182
177
- <target name =" publish-opensmt" depends =" package-opensmt, load-ivy"
178
- description =" Publish OpenSMT binaries to Ivy repository." >
179
- <ivy : resolve conf =" solver-opensmt" file =" solvers_ivy_conf/ivy_opensmt.xml" />
183
+ <target name =" publish-opensmt" depends =" package-opensmt, load-ivy" description =" Publish OpenSMT binaries to Ivy repository." >
184
+ <ivy : resolve conf =" solver-opensmt" file =" solvers_ivy_conf/ivy_opensmt.xml" />
180
185
<publishToRepository solverName =" OpenSMT" solverVersion =" ${opensmt.version}" />
181
186
</target >
182
187
</project >
0 commit comments