This week I've been working on porting the prototype MySQL storage engine developed at
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
href="http://posulliv.github.com/2009/09/29/viewing-memcached-statistics-from-drizzle.html">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:
[plugin]
name=memcached_stats
title=Memcached Stats in DATA_DICTIONARY tables
description=Some DATA_DICTIONARY tables that provide Memcached stats
url=http://memcached.org/
version=0.1
disabled=yes
load_by_default=no
author=Padraig O Sullivan
license=PLUGIN_LICENSE_BSD
headers=stats_table.h analysis_table.h sysvar_holder.h
sources=memcached_stats.cc stats_table.cc analysis_table.cc
build_conditional="${ac_cv_libmemcached}" = "yes" -a "x${MEMCACHED_BINARY}" != "xno"
ldflags=${LTLIBMEMCACHED}
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/ltmain.sh' 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 configure.ac. libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. configure.ac:7: installing `config/compile' configure.ac:7: installing `config/missing' Makefile.am: 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 CXXLD libmemcached_stats_plugin.la 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.