Stored procedures

I just found this tool that generates code to wrap stored procedures.

Stored procedures are a problem when you try to migrate from MS SQL to any other DB supported by Mono because they are more stuff to translate into the new backend. By using code wrappers, specially if they are generated automatically, the programmer can ignore that problem.

It would be nice to have such a thing for PostgreSQL too or even for other DBs that don't support stored procedures. Any volunteer?

Good news

Yahoo! Not only they fire one of the biggest news manipulator of the previous Spanish government, but they offer the job to one of the most independent journalist: El Mundo.

Sorry, couldn't resist. I'm so happy I can watch the news on TV again... :)

Mono + Windows hacking

After months of being unable to test or implement missing features on the Windows© side of the Mono™ I'm back.

Big thanks to Atsushi, Sebastien and, specially, Urs, who gave the last hint to make this work from CVS: just chmod +x all the ICU dlls!!!

Mini-guide on autotools and mono

Imagine you want to start a new project that uses C#. You think about autotools so that you get all those nice 'dist', 'distcheck', 'install'... targets. Don't be afraid. It's easy, just read on.

First of all, download this small file, save it to 'bush.tar.gz' and uncompress it (tar -xzvf bush.tar.gz). You will have these files:

bush/autogen.sh
bush/configure.in
bush/Makefile.am
bush/NEWS
bush/README
bush/AUTHORS
bush/ChangeLog
bush/man/bush.1
bush/man/Makefile.am
bush/src/AssemblyInfo.cs.in
bush/src/Makefile.am
bush/src/main.cs
bush/resources/dummy.txt
bush/resources/Makefile.am

It contains a small dummy project called 'bush'. Now I will explain what's in the relevant files. While you read this, you should be editing the files to see what's in there.

autogen.sh

This file is a shell script that is used to create and run the configure script, which will generate all the output files we need. Don't run anything yet.

Makefile.am

In this file, we tell automake which subdirectories to process. They will be processed in the same order as they appear in the SUBDIRS variable.

configure.in

The first line in this file (AC_INIT) initializes autoconf. The argument is parenthesis must be an existing file in the project.

In AM_INIT_AUTOMAKE, we initialize automake, providing the project name and version. AM_MAINTAINER_MODE will allow us to run configure with the --enable-maintainer-mode option. This is useful while you're modifying any Makefile.am or configure.in, as it will rebuild every Makefile without the need of running autogen.sh.

After that, we check for pkg-config and a C# compiler. If they are not available, configure will error out.

Then we use PKG_CHECK_MODULES macro to check for Gtk# (at least version 0.18). We get in GTKSHARP_LIBS the command line options that we need to pass to the C# compiler to use Gtk#.

Finally, we tell configure to substitute the variable MCS with the path to the executable we found before and provide the list of files that will be generated.

man/Makefile.am

Here we use man_MANS to tell automake to install the manual page. We also put that manual page in EXTRA_DIST so that the file is included in source tarballs (wait, wait...)

resources/Makefile.am

This dummy.txt file here will not be installed, but, again, we have to put it in EXTRA_DIST.

src/AssemblyInfo.cs.in

This file is a template in which configure will perform substitutions. We use it to get the VERSION variable replaced by the version we provided in AM_INIT_AUTOMAKE, which will be 0.0.1 for the first time.

src/Makefile.am

And last, but not least, here's the file that tells how to build the executable and where to install it.

bushdir tells that we will install 'bush' in the bin directory, $(bindir). You also have $(prefix) which is the prefix suplied with --prefix=XXX option, $(sysconfdir), $(libdir)...

bush_SCRIPTS tells the files that will be installed in $(bushdir).

In EXTRA_DIST we put the same files as we have initially, i.e., main.cs and AssemblyInfo.cs.in. CLEANFILES tells the files that will be removed when you run 'make clean'.

And then we setup the variables that will generate the command line to run when compiling the source files.

Let's play

Now it's time to run some commands and enjoy. The first one you need to run is:

./autogen.sh --prefix=/usr/local --enable-maintainer-mode

Then try make, make clean, make install, make uninstall, make dist, make distcheck...

Oh, btw, those NEWS, README, AUTHORS and ChangeLog files are mandatory. Keep them updated!

UPDATE: Todd told me that 'pkg-config --libs gtk-sharp' only works with CVS Gtk#. If you're not using CVS you will have to either wait for gtk-sharp 0.19 or add the -r:gtk-sharp.dll and any other mcs option in src/Makefile.am.

egg-sharp

I've uploaded a new egg-sharp.dll that has been generated after latest changes in gtk-sharp constructors.

This is a personal web page. Things said here do not represent the position of my employer.