@@ -39,9 +39,9 @@ SPDX-License-Identifier: Apache-2.0
3939 <echo message =" Building OpenSMT in version '${opensmt.version}'" />
4040
4141 <!-- Create build directories -->
42- <property name =" path.build" value =" ${opensmt.path}/build" />
42+ <property name =" path.build" value =" ${opensmt.path}/build" />
4343 <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" />
4545
4646 <mkdir dir =" ${path.build}" />
4747 <mkdir dir =" ${path.install}" />
@@ -71,13 +71,10 @@ SPDX-License-Identifier: Apache-2.0
7171 </exec >
7272
7373 <!-- 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/**/ *" />
7676 </copy >
7777
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-
8178 <!-- Run swig to generate java proxies and the jni wrapper -->
8279 <mkdir dir =" ${path.install}/java/opensmt" />
8380 <exec executable =" swig" dir =" ${path.install}" failonerror =" true" >
@@ -93,8 +90,7 @@ SPDX-License-Identifier: Apache-2.0
9390 <arg value =" swig/opensmt.i" />
9491 </exec >
9592
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 -->
9894 <copy todir =" ${path.source}/src/org/sosy_lab/java_smt/solvers/opensmt/api" >
9995 <fileset dir =" ${path.install}/java/opensmt" >
10096 <include name =" ArithLogic.java" />
@@ -124,6 +120,13 @@ SPDX-License-Identifier: Apache-2.0
124120 <include name =" VectorVectorInt.java" />
125121 </fileset >
126122 </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 >
127130
128131 <!-- Package swig generated source code -->
129132 <jar destfile =" opensmt-${opensmt.version}-sources.jar" basedir =" ${path.source}/src" />
@@ -134,35 +137,39 @@ SPDX-License-Identifier: Apache-2.0
134137 <jar destfile =" opensmt-${opensmt.version}-javadoc.jar" basedir =" ${path.source}/doc" />
135138 <delete dir =" ${path.source}/doc" />
136139
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 >
139142
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" >
142145 <arg value =" -fPIC" />
143- <arg value =" -std=c++17 " />
146+ <arg value =" -std=c++20 " />
144147 <arg value =" -o" />
145- <arg value =" ${path.source}/ opensmt-wrap.o" />
148+ <arg value =" opensmt-wrap.o" />
146149 <arg value =" -c" />
147150 <arg value =" opensmt-wrap.cpp" />
151+ <arg value =" -I${path.install}/include/opensmt/" />
148152 <arg value =" -I${java.home}/include/" />
149153 <arg value =" -I${java.home}/include/linux" />
150154 </exec >
155+ <delete file =" ${path.source}/version.h" />
151156
152157 <!-- Link the wrapper and create a new lib -->
153- <symlink link =" libopensmt.so" resource =" libopensmt-${opensmt.version}.so" />
154158 <exec executable =" gcc" dir =" ${path.source}" failonerror =" true" >
155159 <arg value =" -shared" />
156160 <arg value =" -o" />
157161 <arg value =" ${user.dir}/libopensmtjava-${opensmt.version}.so" />
158162 <arg value =" opensmt-wrap.o" />
159- <arg value =" -L${user.dir}" />
160- <arg value =" -lopensmt" />
161163 <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" />
163171 </exec >
164- <delete file =" libopensmt.so" />
165- <delete file =" lib/native/source/opensmt/opensmt-wrap.o" />
172+ <delete file =" ${path.source}/opensmt-wrap.o" />
166173
167174 <!-- Compile java proxies and create jar file -->
168175 <mkdir dir =" ${path.source}/bin" />
@@ -171,12 +178,10 @@ SPDX-License-Identifier: Apache-2.0
171178 </javac >
172179 <jar destfile =" opensmt-${opensmt.version}.jar" basedir =" ${path.source}/bin" />
173180 <delete dir =" ${path.source}/bin" />
174- <delete dir =" lib/native/source/opensmt/src" />
175181 </target >
176182
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" />
180185 <publishToRepository solverName =" OpenSMT" solverVersion =" ${opensmt.version}" />
181186 </target >
182187</project >
0 commit comments