Hola amigos,

1stWeek: 25stMay, 2015 – 31stMay, 2015
Now we are into the coding phase of GSoC 2015. First we finished going through the pysolv, python bindings of libsolv which helped us a lot to understand what all stuff libsolv can do for us.

We had to find a way for the libsolv to work with Tcl, as MacPorts base is largely written in Tcl. So my mentor mentioned SWIG (a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.) as libsolv was written in C. Then luckily we came across solv.i in the bindings/ folder. solv.i contains the interface file for SWIG which helps SWIG to convert it into the destination language (Tcl for us).

We concluded our discussion on libsolv bindings and decided to have a extra meeting on 29stMay, 2015 for adding Tcl related interface code in solv.i. Till then I went through SWIG tutorials and also tried my hand on creating python bindings for MacPorts code (src/machista1.0/machista.i). While doing so I came across a bug, #include was missing from the interface file which was then committed by my mentor with the updated machista_wrap.c file. This wrap file is used to compile against the destination languages library to get the bindings for the destination language.

Tutorials and more information on SWIG can be found SWIG.

In our extra meeting, I wrote the remaining SWIG interface Tcl code and then committed it to neverpanic (my mentors) branch. Which he merged and combined those multiple commits into one and then PR’ed (Pull Request) to the upstream libsolv branch (OpenSuSE/libsolv). Then we compiled everything and run cmake and make on the current build.

Now we had a solv.dylib which can be loaded in the correct Tclsh. We built it against out port-tclsh (A symlink to MacPorts’ copy of Tclsh) by passing some options to cmake, so we can use solv.dylib against that tclsh only as different versions/variants of Tcl would build the SWIG differently and might give errors.

To clone libsolv repository run the following command:

git clone https://github.com/openSUSE/libsolv.git

Now, it is recommended to create a build/ directory and run cmake inside build folder rather than libsolv/ itself as lot of files will be created by cmake which we would have to delete if we run into troubles or need to change the path of Tclsh against which it is built.

You can do so by running the following command in your terminal:

mkdir build; cd build

If you wish to create libsolv bindings against port-tclsh run the following cmake command (Inside libsolv/build):

cmake -DTCL_INCLUDE_PATH=${prefix}/libexec/macports/include -DTCL_LIBRARY=${prefix}/libexec/macports/lib/libtcl8.5.dylib -DTCL_TCLSH=${prefix}/libexec/macports/bin/tclsh8.5 -DENABLE_TCL:BOOL=ON ..
sudo make install

Note: Replace ${prefix} with your MacPorts installation path. By Default it would be /opt/local/. You may want to use a development prefix intended for testing purposes e.g. ~/Development/macports.

Then copy the solv.dylib to the directory where you want to use libsolv bindings for Tcl.

Initially we copied solv.dylib to macports1.0/ and the created a file libsolv.tcl which loads this bindings using “load abosulte/path/to/solv.dylib” and the “package require solv” in macports_libsolv.tcl

Note: The current upstream of libsolv is fixed and improvised for “Implementing Tcl Bindings” in this commit and now we just need to use “package require solv”. The bindings is automatically found by Tclsh in the path.

Let the Windows be open, and feel the Freedom.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s