This week I've been working on porting the prototype MySQL storage engine developed at Akiban to Drizzle. While doing this, I discovered that in Drizzle, it is possible to build a plugin out of tree. When I say out of tree, I mean that I can develop a plugin for drizzle and build it without having a copy of the drizzle source code. This is amazingly awesome and is mostly due to the awesome build system that Monty has put together. This build system is called Pandora Build and if you are ever working on a project that needs to use autoconf related tools, you should really check it out. Its friggin awesome. It lets you concentrate on development instead of having to spend a bunch of time trying to get a good build environment set up.
Anyway, here I am going to go through an example of how to build a drizzle plugin out of tree. The code is available at lp:~posulliv/drizzle/out-of-tree-example if anyone is interested in looking at it. I am going to take an existing plugin in the drizzle source tree I developed and show how to build it out of tree. The plugin I'm going to work with is the memcached_stats plugin.
Before starting, its worth noting that Monty is working on creating a one-step tool for taking a plugin that is currently in drizzle's source tree (that is, in the plugin directory of a drizzle tree) and making it possible to build that plugin out of tree. His goal is that there need be no changes in content between a directory that's in the drizzle source tree and one that's outside the source tree.
For this post, we will assume that we are working in a directory named mc-stats-plugin. Before starting. this directory just contains source files. We will be adding all the build-related files that are needed to build it.
The first thing that is needed is a plugin.ini file for a plugin. For an out-of-tree plugin, a name and url is required. Thus, the plugin.ini file for this plugin will look like:
title=Memcached Stats in DATA_DICTIONARY tables
description=Some DATA_DICTIONARY tables that provide Memcached stats
author=Padraig O Sullivan
headers=stats_table.h analysis_table.h sysvar_holder.h
build_conditional="${ac_cv_libmemcached}" = "yes" -a "x${MEMCACHED_BINARY}" != "xno"
Once that's done, we need to create a config directory and copy a few files from drizzle's trunk:
$ cp $DRIZZLE_SRC_ROOT/config/config.rpath ./config/.
$ cp $DRIZZLE_SRC_ROOT/config/pandora-plugin ./config/.
$ cp -R $DRIZZLE_SRC_PORT/m4 .
Like I said before, Monty is working on a tool that will automate the steps above. Now, we can proceed and start compiling our plugin:
$ ./config/pandora-plugin
$ autoreconf -i
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/config.guess'
libtoolize: copying file `config/config.sub'
libtoolize: copying file `config/install-sh'
libtoolize: copying file `config/'
libtoolize: putting macros in `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
libtoolize: Remember to add `LT_INIT' to
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to and
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. installing `config/compile' installing `config/missing' installing `config/depcomp'
$ ./configure
$ make
make  all-am
make[1]: Entering directory `/home/posulliv/repos/drizzle/mc-stats-plugin'
  CXX    libmemcached_stats_plugin_la-memcached_stats.lo
  CXX    libmemcached_stats_plugin_la-stats_table.lo
  CXX    libmemcached_stats_plugin_la-analysis_table.lo
make[1]: Leaving directory `/home/posulliv/repos/drizzle/mc-stats-plugin'
Now, our plugin is built. To install it, we simply do a make install and give the --plugin_add=memcached_stats option to drizzled when we start the server.
I just think this process makes my life a whole lot easier and I wanted to bring some attention to how easy drizzle makes developing plugins.

blog comments powered by Disqus


10 March 2010