Automatic generation of .list files

When you use a VCS that makes it easy to manage several braches, it’s easy to get conflicts in the .list file used to generate the C marshallers. I recently fixed this problem in WebKit stealing some code used at least by various Telepathy components and by avahi-gobject, and I want to share the solution so every project can benefit from it.

First of all you have to open your and move the myproject-marshal.list file from EXTRA_DIST to BUILT_SOURCES and add somewhere in the file:

myproject-marshal.list: $(myproject_SOURCES)
        ( cd $(srcdir) && \\
        sed -n -e 's/.*myproject_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \\
        $(myproject_SOURCES) ) \\
        | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp
        if cmp -s $@.tmp $@; then \\
                rm $@.tmp; \\
        else \\
                mv $@.tmp $@; \\

Then remember to remove the myproject-marshal.list file from your VCS (svn/git/hg/bzr rm).

The code will search for all the functions looking like myproject_marshal_RETTYPE__ARG1TYPE_ARG2TYPE and generate the myproject-marshal.list from them, regenerating automatically the list when you change a signal signature.

Update: fixed the blackslashes in the code that were misteriously eaten by WordPress.

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.

Other Posts

Reader Comments

[…] Marco: You can also use the libffi CClosure marshaller I wrote for PyGObject. If you use you don’t need to generate the marshal.list at all, it’ll figure out the signature and call the callback just by looking at the signals GValues. […]