~drizzle-trunk/drizzle/development

992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
1
#!/usr/bin/python
2
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
3
#  Copyright (C) 2009 Sun Microsystems, Inc.
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
4
#  Copyright (C) 2010, 2011 Monty Taylor
992.1.25 by Monty Taylor
Moved myisam to new plugin system.
5
#
6
#  This program is free software; you can redistribute it and/or modify
7
#  it under the terms of the GNU General Public License as published by
8
#  the Free Software Foundation; version 2 of the License.
9
#
10
#  This program is distributed in the hope that it will be useful,
11
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
#  GNU General Public License for more details.
14
#
15
#  You should have received a copy of the GNU General Public License
16
#  along with this program; if not, write to the Free Software
17
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
19
pandora_plugin_file = 'config/pandora-plugin.ini'
992.1.25 by Monty Taylor
Moved myisam to new plugin system.
20
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
21
# Find plugins in the tree and add them to the build system
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
22
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
23
import ConfigParser, os, sys
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
24
import datetime, time
1377.3.6 by Monty Taylor
Set the default plugin version for plugins not specifying a version to be
25
import subprocess
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
26
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
27
plugin_am_file=None
28
plugin_ac_file=None
1794.2.5 by Monty Taylor
Added support to pandora for finding and including per-plugin documentation.
29
plugin_doc_index=None
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
30
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
31
class ChangeProtectedFile(object):
32
33
  def __init__(self, fname):
1192.3.11 by Monty Taylor
Fixed a few distcheck issues.
34
    self.bogus_file= False
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
35
    self.real_fname= fname
36
    self.new_fname= "%s.new" % fname
1192.3.11 by Monty Taylor
Fixed a few distcheck issues.
37
    try:
38
      self.new_file= open(self.new_fname,'w+')
39
    except IOError:
40
      self.bogus_file= True
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
41
42
  def write(self, text):
1192.3.11 by Monty Taylor
Fixed a few distcheck issues.
43
    if not self.bogus_file:
44
      self.new_file.write(text)
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
45
46
  # We've written all of this out into .new files, now we only copy them
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
47
  # over the old ones if they are different, so that we don't cause
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
48
  # unnecessary recompiles
49
  def close(self):
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
50
    """Return True if the file had changed."""
1192.3.11 by Monty Taylor
Fixed a few distcheck issues.
51
    if self.bogus_file:
52
      return
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
53
    self.new_file.seek(0)
54
    new_content = self.new_file.read()
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
55
    self.new_file.close()
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
56
    try:
57
        old_file = file(self.real_fname, 'r')
58
        old_content = old_file.read()
59
        old_file.close()
60
    except IOError:
61
        old_content = None
62
    if new_content != old_content:
63
      if old_content != None:
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
64
        os.unlink(self.real_fname)
65
      os.rename(self.new_fname, self.real_fname)
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
66
      return True
67
    else:
68
        try:
69
          os.unlink(self.new_fname)
70
        except:
71
          pass
72
73
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
74
def write_external_configure(plugin, plugin_file):
75
  """Write the initial bits of the configure.ac file"""
76
  if not os.path.exists('m4'):
77
    os.mkdir('m4')
78
  plugin_file.write("""
79
AC_PREREQ(2.59)dnl		Minimum Autoconf version required.
80
AC_INIT([%(name)s],[%(version)s],[%(url)s])
81
AC_CONFIG_SRCDIR([%(main_source)s])
82
AC_CONFIG_AUX_DIR(config)
83
1241.9.5 by Monty Taylor
Fixed the plugin script to not bork plugin visibility.
84
PANDORA_CANONICAL_TARGET(less-warnings, warnings-always-on, require-cxx, force-gcc42,skip-visibility)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
85
86
PANDORA_REQUIRE_LIBPROTOBUF
87
PANDORA_PROTOBUF_REQUIRE_VERSION([2.1.0])
88
PANDORA_REQUIRE_PROTOC
89
90
AC_LANG_PUSH(C++)
91
PANDORA_REQUIRE_PTHREAD
92
PANDORA_REQUIRE_LIBDL
93
AC_LANG_POP
94
95
PANDORA_USE_BETTER_MALLOC
96
97
PANDORA_DRIZZLE_BUILD
98
""" % plugin)
99
100
  write_plugin_ac(plugin, plugin_file)
101
102
  plugin_file.write("""
103
AC_CONFIG_FILES(Makefile)
104
105
AC_OUTPUT
106
107
echo "---"
108
echo "Configuration summary for $PACKAGE_NAME version $VERSION $PANDORA_RELEASE_COMMENT"
109
echo ""
110
echo "   * Installation prefix:       $prefix"
111
echo "   * System type:               $host_vendor-$host_os"
112
echo "   * Host CPU:                  $host_cpu"
113
echo "   * C Compiler:                $CC_VERSION"
114
echo "   * C++ Compiler:              $CXX_VERSION"
115
echo "   * Debug enabled:             $with_debug"
116
echo "   * Warnings as failure:       $ac_cv_warnings_as_errors"
117
echo "   * C++ cstdint location:      $ac_cv_cxx_cstdint"
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
118
echo "   * C++ hash_map location:     $ac_cv_cxx_hash_map"
119
echo "   * C++ hash namespace:        $ac_cv_cxx_hash_namespace"
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
120
echo "   * C++ shared_ptr namespace:  $ac_cv_shared_ptr_namespace"
121
echo ""
122
echo "---"
123
124
  """ % plugin)
125
126
def write_external_makefile(plugin, plugin_file):
127
128
  plugin_file.write("""
129
ACLOCAL_AMFLAGS = -I m4 --force
130
VERSION=$(PANDORA_RELEASE_VERSION)
131
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
132
pkgplugindir=%(pkgplugindir)s
1241.9.3 by Monty Taylor
Fixed the out-of-tree plugin file generation.
133
EXTRA_DIST = plugin.ini
1192.3.53 by Robert Collins
Build fixes from Robert.
134
1948.1.5 by Monty Taylor
Fixed some issues with out of tree plugin building.
135
noinst_HEADERS=
136
nobase_include_HEADERS=
2157.2.1 by Monty Taylor
Provide pkg-config files and also stick drizzle plugin files in a place
137
nobase_pkginclude_HEADERS=
1948.1.5 by Monty Taylor
Fixed some issues with out of tree plugin building.
138
check_PROGRAMS=
139
noinst_LTLIBRARIES=
140
bin_PROGRAMS=
141
142
1192.3.53 by Robert Collins
Build fixes from Robert.
143
""" % plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
144
  if plugin['headers'] != "":
1948.1.5 by Monty Taylor
Fixed some issues with out of tree plugin building.
145
    plugin_file.write("noinst_HEADERS += %(headers)s\n" % plugin)
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
146
  if plugin['install_headers'] != "":
2157.2.1 by Monty Taylor
Provide pkg-config files and also stick drizzle plugin files in a place
147
    plugin_file.write("nobase_pkginclude_HEADERS += %(install_headers)s\n" % plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
148
  if plugin['testsuite']:
149
    if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "":
1241.9.3 by Monty Taylor
Fixed the out-of-tree plugin file generation.
150
      plugin_file.write("EXTRA_DIST += %(testsuitedir)s\n" % plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
151
  plugin_file.write("""
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
152
pkgplugin_LTLIBRARIES=%(libname)s.la
153
%(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
154
%(libname)s_la_LIBADD=%(libs)s
155
%(libname)s_la_DEPENDENCIES=%(libs)s
2088.4.1 by Monty Taylor
Removed an extra set of quoting.
156
%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='%(author)s' -DPANDORA_MODULE_TITLE='%(title)s' -DPANDORA_MODULE_VERSION='%(version)s' -DPANDORA_MODULE_LICENSE=%(license)s %(cppflags)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
157
%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
158
%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
159
%(libname)s_la_SOURCES=%(sources)s
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
160
check_PROGRAMS += %(tests)s
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
161
""" % plugin)
162
  plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')
163
  if os.path.exists(plugin_am_file):
164
    plugin_file.write('include %s\n' % plugin_am_file)
165
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
166
def write_external_plugin():
167
  """Return True if the plugin had changed."""
168
  plugin = read_plugin_ini('.')
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
169
  expand_plugin_ini(plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
170
  plugin_file = ChangeProtectedFile('configure.ac')
171
  write_external_configure(plugin, plugin_file)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
172
  result = plugin_file.close()
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
173
  plugin_file = ChangeProtectedFile('Makefile.am')
174
  write_external_makefile(plugin, plugin_file)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
175
  # Write some stub configure.ac and Makefile.am files that include the above
176
  result = plugin_file.close() or result
177
  return result
178
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
179
def write_plugin(plugin, plugin_ini_list):
180
  # Since this function is recursive, make sure we're not already in it.
181
  if plugin.has_key('writing_status'):
182
    if plugin['writing_status'] == 'done':
183
      return
184
    else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
185
      print "Dependency loop detected with %s" % plugin['name']
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
186
      exit(1)
187
188
  plugin['writing_status'] = 'dependencies'
189
190
  # Write all dependencies first to get around annoying automake bug
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
191
  for dependency in plugin['dependency_list']:
192
    found = False
193
    for find_plugin in plugin_ini_list:
194
      if find_plugin['module_name'] == dependency:
195
        found = True
196
        write_plugin(find_plugin, plugin_ini_list)
197
        break
198
    if found is False:
199
      print "Could not find dependency %s: %s" % (plugin['name'], dependency)
200
      exit(1)
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
201
1192.3.25 by Monty Taylor
It seems to work.
202
  write_plugin_ac(plugin, plugin_ac_file)
203
  write_plugin_am(plugin, plugin_am_file)
2116.1.56 by Monty Taylor
Have pandora-plugin add the plugin doc files to EXTRA_DIST itself.
204
  write_plugin_docs(plugin, plugin_doc_index, plugin_am_file)
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
205
  plugin['writing_status'] = 'done'
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
206
2116.1.56 by Monty Taylor
Have pandora-plugin add the plugin doc files to EXTRA_DIST itself.
207
def write_plugin_docs(plugin, doc_index, plugin_am):
1794.2.5 by Monty Taylor
Added support to pandora for finding and including per-plugin documentation.
208
  if plugin['docs'] is not None and os.path.isdir("docs/plugins"):
209
    if not os.path.exists(os.path.join("docs/plugins",plugin["name"])):
210
      os.symlink(os.path.abspath(plugin["docs"]), os.path.join("docs/plugins",plugin["name"]))
211
    doc_index.write("""
1794.2.7 by Monty Taylor
Fixed a couple of options around make dist to make sure all the .rst files
212
   %(name)s/index""" % plugin)
2116.1.56 by Monty Taylor
Have pandora-plugin add the plugin doc files to EXTRA_DIST itself.
213
    plugin_am.write("""
2116.1.57 by Monty Taylor
When we use wildcards in EXTRA_DIST, we must give them full paths. Bah.
214
EXTRA_DIST+=${top_srcdir}/docs/plugins/%(name)s/*.rst
2116.1.56 by Monty Taylor
Have pandora-plugin add the plugin doc files to EXTRA_DIST itself.
215
""" % plugin)
1794.2.5 by Monty Taylor
Added support to pandora for finding and including per-plugin documentation.
216
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
217
def write_plugin_ac(plugin, plugin_ac):
218
  #
219
  # Write plugin config instructions into plugin.ac file.
220
  #
992.1.23 by Monty Taylor
New system now runs in parallel to old system.
221
  plugin_ac_file=os.path.join(plugin['rel_path'],'plugin.ac')
222
  plugin_m4_dir=os.path.join(plugin['rel_path'],'m4')
223
  plugin_m4_files=[]
224
  if os.path.exists(plugin_m4_dir) and os.path.isdir(plugin_m4_dir):
225
    for m4_file in os.listdir(plugin_m4_dir):
226
      if os.path.splitext(m4_file)[-1] == '.m4':
227
        plugin_m4_files.append(os.path.join(plugin['rel_path'], m4_file))
1192.3.25 by Monty Taylor
It seems to work.
228
  plugin_ac.write("""
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
229
dnl Config for %(title)s
992.1.23 by Monty Taylor
New system now runs in parallel to old system.
230
""" % plugin)
231
  for m4_file in plugin_m4_files:
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
232
    plugin_ac.write('m4_sinclude([%s])\n' % m4_file)
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
233
  plugin['plugin_dep_libs']=" ".join(["\${top_builddir}/%s" % f for f in plugin['libs'].split()])
234
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
235
  plugin_ac.write("""
1022.2.4 by Monty Taylor
Fixed turning off plugins.
236
AC_ARG_WITH([%(name_with_dashes)s-plugin],[
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
237
dnl indented wierd to make the help output correct
1273.12.6 by Monty Taylor
Added support for disabling plugins
238
AS_HELP_STRING([--with-%(name_with_dashes)s-plugin],[Build %(title)s. @<:@default=%(enabled)s@:>@])
1022.2.4 by Monty Taylor
Fixed turning off plugins.
239
AS_HELP_STRING([--without-%(name_with_dashes)s-plugin],[Disable building %(title)s])
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
240
  ],[
241
    with_%(name)s_plugin="$withval"
1273.23.6 by Monty Taylor
Need to be able to actually disable plugins in the build.
242
    AS_IF([test "x$with_%(name)s_plugin" = "xyes"],[
243
      requested_%(name)s_plugin="yes"
244
    ],[
245
      requested_%(name)s_plugin="no"
246
    ])
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
247
  ],[
1273.12.6 by Monty Taylor
Added support for disabling plugins
248
    with_%(name)s_plugin="%(enabled)s"
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
249
    requested_%(name)s_plugin="no"
250
  ])
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
251
AC_ARG_WITH([static-%(name_with_dashes)s-plugin],[
252
AS_HELP_STRING([--with-static-%(name_with_dashes)s-plugin],[Build Archive Storage Engine. @<:@default=%(static_yesno)s@:>@])
253
AS_HELP_STRING([--without-static-%(name_with_dashes)s-plugin],[Disable building Archive Storage Engine])
254
  ],[
255
    with_static_%(name)s_plugin=${withval}
256
  ],[
257
    with_static_%(name)s_plugin=%(static_yesno)s
258
])
259
AS_IF([test "x${with_static_%(name)s_plugin}" = "xyes" -o "x${with_all_static}" = "xyes"],[
260
  shared_%(name)s_plugin=no
261
  ],[
262
  shared_%(name)s_plugin=yes
263
])
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
264
AC_ARG_ENABLE([%(name_with_dashes)s-plugin],[
265
dnl indented wierd to make the help output correct
1810.4.1 by Andrew Hutchings
Fix plugin --enable/disable messages
266
AS_HELP_STRING([--enable-%(name_with_dashes)s-plugin],[Enable loading %(title)s by default. @<:@default=%(default_yesno)s@:>@])
267
AS_HELP_STRING([--disable-%(name_with_dashes)s-plugin],[Disable loading %(title)s by default.])
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
268
  ],
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
269
  [enable_%(name)s_plugin="$enableval"],
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
270
  [enable_%(name)s_plugin=%(default_yesno)s])
271
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
272
""" % plugin)
273
  if os.path.exists(plugin_ac_file):
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
274
    plugin_ac.write('m4_sinclude([%s])\n' % plugin_ac_file)
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
275
  # The plugin author has specified some check to make to determine
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
276
  # if the plugin can be built. If the plugin is turned on and this
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
277
  # check fails, then configure should error out. If the plugin is not
278
  # turned on, then the normal conditional build stuff should just let
279
  # it silently not build
280
  if plugin['has_build_conditional']:
281
    plugin_ac.write("""
997.2.5 by Monty Taylor
Merged up with trunk properly.
282
AS_IF([test %(build_conditional)s],
1166.1.1 by Monty Taylor
Fixed an accidental logic error that caused any plugin which was availble to be built to be automatically enabled/builtin.
283
      [], dnl build_conditional can only negate
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
284
      [
285
        AS_IF([test "x${requested_%(name)s_plugin}" = "xyes"],
286
              [AC_MSG_ERROR([Plugin %(name)s was explicitly requested, yet failed build dependency checks. Aborting!])])
287
        with_%(name)s_plugin=no
288
      ])
1192.3.53 by Robert Collins
Build fixes from Robert.
289
290
""" % plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
291
  if not plugin['unconditional']:
292
    plugin_ac.write("""
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
293
AM_CONDITIONAL([%(static_build_conditional_tag)s],
294
               [test %(build_conditional)s -a ! %(shared_build)s])
295
AM_CONDITIONAL([%(shared_build_conditional_tag)s],
296
               [test %(build_conditional)s -a %(shared_build)s])
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
297
AM_CONDITIONAL([%(build_conditional_tag)s],
298
               [test %(build_conditional)s])
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
299
    """ % plugin)
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
300
301
  plugin_ac.write("""
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
302
AS_IF([test "x$with_%(name)s_plugin" = "xyes"],[
1192.3.53 by Robert Collins
Build fixes from Robert.
303
""" % plugin)
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
304
  if plugin['testsuite']:
305
    plugin_ac.write("""
306
      pandora_plugin_test_list="%(name)s,${pandora_plugin_test_list}"
307
    """ % plugin)
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
308
  plugin_ac.write("""
309
      AS_IF([test "x${with_static_%(name)s_plugin}" = "xyes" -o "x${with_all_static}" = "xyes"],[
310
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
311
        AS_IF([test "x$enable_%(name)s_plugin" = "xyes"],[
1885.2.3 by Monty Taylor
Finalized the static/load_by_default split, supporting now an array of
312
          pandora_builtin_load_list="%(module_name)s,${pandora_builtin_load_list}"
313
          pandora_builtin_load_symbols_list="_drizzled_%(module_name)s_plugin_,${pandora_builtin_load_symbols_list}"
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
314
          PANDORA_PLUGIN_DEP_LIBS="${PANDORA_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
315
        ])
1885.2.3 by Monty Taylor
Finalized the static/load_by_default split, supporting now an array of
316
        pandora_builtin_list="%(module_name)s,${pandora_builtin_list}"
317
        pandora_builtin_symbols_list="_drizzled_%(module_name)s_plugin_,${pandora_builtin_symbols_list}"
1885.1.1 by Monty Taylor
Minor modification of earlier patch - I don't need to keep static tied to
318
        pandora_plugin_libs="${pandora_plugin_libs} \${top_builddir}/%(root_plugin_dir)s/%(libname)s.la"
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
319
     ],[
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
320
        AS_IF([test "x$enable_%(name)s_plugin" = "xyes"],[
321
          pandora_default_plugin_list="%(name)s,${pandora_default_plugin_list}"
322
        ])
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
323
    ])
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
324
    """ % plugin)
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
325
  plugin_ac.write("])\n")
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
326
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
327
def fix_file_paths(plugin, files):
328
  # TODO: determine path to plugin dir relative to top_srcdir... append it to
329
  # source files if they don't already have it
330
  new_files=""
331
  if plugin['plugin_dir'] != ".":
332
    for file in files.split():
333
      if not file.startswith(plugin['rel_path']):
334
        file= os.path.join(plugin['rel_path'], file)
335
        new_files= "%s %s" % (new_files, file)
336
  else:
337
    new_files= " ".join(plugin['sources'].split())
338
  if new_files != "":
339
    return new_files
340
  return files
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
341
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
342
def expand_plugin_ini(plugin):
1273.23.15 by Monty Taylor
Put in error check for out of tree plugin builds.
343
    if plugin['name'] == "**OUT-OF-TREE**":
344
      print "Out of tree plugins require the name field to be specified in plugin.ini"
345
      sys.exit(1)
346
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
347
    if plugin['plugin_dir'] == ".":
348
      plugin['rel_path']= plugin['plugin_dir']
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
349
      plugin['unconditional']=True
350
    else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
351
      plugin['rel_path']= plugin['plugin_dir'][len(config['top_srcdir'])+len(os.path.sep):]
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
352
      plugin['unconditional']=False
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
353
354
    plugin['sources']= fix_file_paths(plugin, plugin['sources'])
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
355
    plugin['main_source']= plugin['sources'].split()[0]
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
356
    plugin['headers']= fix_file_paths(plugin, plugin['headers'])
357
    plugin['install_headers']= fix_file_paths(plugin, plugin['install_headers'])
358
    plugin['tests']= fix_file_paths(plugin, plugin['tests'])
359
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
360
    # Make a yes/no version for autoconf help messages
1879.2.1 by Monty Taylor
Stop static from implying load_by_default. They are two different things.
361
    if plugin['load_by_default']:
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
362
      plugin['default_yesno']="yes"
363
    else:
364
      plugin['default_yesno']="no"
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
365
1716.1.1 by Monty Taylor
Added files to the tarball that should be there. Removed some that shouldn't
366
    if plugin.has_key('extra_dist'):
367
      plugin['extra_dist']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['extra_dist'].split()])
2426.3.1 by Henrik Ingo
This does 2 things:
368
    if plugin.has_key('bin_scripts'):
369
      plugin['bin_scripts']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['bin_scripts'].split()])
370
    if plugin.has_key('scripts'):
371
      plugin['scripts']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['scripts'].split()])
372
    if plugin.has_key('sbin_scripts'):
373
      plugin['sbin_scripts']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['sbin_scripts'].split()])
374
    if plugin.has_key('libexec_scripts'):
375
      plugin['libexec_scripts']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['libexec_scripts'].split()])
376
    if plugin.has_key('pkg_scripts'):
377
      plugin['pkg_scripts']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['pkg_scripts'].split()])
378
    if plugin.has_key('data'):
379
      plugin['data']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['data'].split()])
380
    if plugin.has_key('pkg_data'):
381
      plugin['pkg_data']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['pkg_data'].split()])
382
    if plugin.has_key('sysconf_data'):
383
      plugin['sysconf_data']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['sysconf_data'].split()])
384
    
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
385
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
386
    if plugin['static']:
387
      plugin['static_yesno']="yes"
388
    else:
389
      plugin['static_yesno']="no"
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
390
    plugin['build_conditional_tag']= "BUILD_%s_PLUGIN" % plugin['name'].upper()
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
391
    plugin['shared_build_conditional_tag']= "BUILD_%s_PLUGIN_SHARED" % plugin['name'].upper()
392
    plugin['static_build_conditional_tag']= "BUILD_%s_PLUGIN_STATIC" % plugin['name'].upper()
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
393
    plugin['name_with_dashes']= plugin['name'].replace('_','-')
394
    if plugin.has_key('build_conditional'):
395
      plugin['has_build_conditional']=True
1273.12.6 by Monty Taylor
Added support for disabling plugins
396
      plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes" -a %(build_conditional)s' % plugin
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
397
    else:
398
      plugin['has_build_conditional']=False
399
      plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
400
    plugin['shared_build']='"x${shared_%(name)s_plugin}" = "xyes"' %plugin
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
401
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
402
    if plugin['install']:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
403
      plugin['library_type']= 'pkgplugin'
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
404
    else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
405
      plugin['library_type']= 'noinst'
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
406
1192.3.20 by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites.
407
def find_testsuite(plugin_dir):
408
  for testdir in ['drizzle-tests','tests']:
409
    if os.path.isdir(os.path.join(plugin_dir,testdir)):
410
      return testdir
411
  if os.path.isdir(os.path.join('tests','suite',os.path.basename(plugin_dir))):
412
    return ""
413
  return None
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
414
1794.2.5 by Monty Taylor
Added support to pandora for finding and including per-plugin documentation.
415
def find_docs(plugin_dir):
416
  if os.path.isfile(os.path.join(plugin_dir, "docs", "index.rst")):
417
    return os.path.join(plugin_dir, "docs")
418
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
419
def read_plugin_ini(plugin_dir):
1948.1.5 by Monty Taylor
Fixed some issues with out of tree plugin building.
420
    sources_default=""
1273.23.15 by Monty Taylor
Put in error check for out of tree plugin builds.
421
    if plugin_dir == ".":
422
      plugin_name="**OUT-OF-TREE**"
1948.1.5 by Monty Taylor
Fixed some issues with out of tree plugin building.
423
      module_name="**OUT-OF-TREE**"
1273.23.15 by Monty Taylor
Put in error check for out of tree plugin builds.
424
    else:
1948.1.5 by Monty Taylor
Fixed some issues with out of tree plugin building.
425
      sources_default="%s.cc" % os.path.basename(plugin_dir)
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
426
      plugin_name = plugin_dir[plugin_dir.index(config['root_plugin_dir']) + len(config['root_plugin_dir']) + 1:]
427
      module_name = plugin_name.replace("/", config['module_name_separator']).replace("\\", config['module_name_separator'])
428
      plugin_name = plugin_name.replace("/", config['plugin_name_separator']).replace("\\", config['plugin_name_separator'])
429
430
431
    plugin_file= os.path.join(plugin_dir,config['plugin_ini_fname'])
1948.1.5 by Monty Taylor
Fixed some issues with out of tree plugin building.
432
    plugin_defaults= dict(sources=sources_default,
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
433
                          headers="",
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
434
                          install_headers="",
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
435
                          cflags="",
436
                          cppflags="",
437
                          cxxflags="",
438
                          libs="",
439
                          ldflags="",
440
                          author="",
441
                          title="",
442
                          description="",
443
                          license="PLUGIN_LICENSE_GPL",
1273.23.15 by Monty Taylor
Put in error check for out of tree plugin builds.
444
                          name=plugin_name,
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
445
                          module_name=module_name,
446
                          load_by_default=config['default_load_by_default'],
1273.12.6 by Monty Taylor
Added support for disabling plugins
447
                          disabled="False",
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
448
                          static="False",
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
449
                          dependencies="",
450
                          dependency_aliases="",
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
451
                          tests="",
452
                          install=config['default_install'])
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
453
    parser=ConfigParser.ConfigParser(defaults= plugin_defaults)
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
454
    parser.read(plugin_file)
455
    plugin=dict(parser.items('plugin'))
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
456
    plugin['plugin_dir'] = plugin_dir
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
457
    if plugin_dir == '.':
458
      if not plugin.has_key('url'):
459
        print "External Plugins are required to specifiy a url"
460
        plugin['url']= 'http://launchpad.net/%(name)s' % plugin
461
        sys.exit(1)
462
      if plugin_dir == '.' and not plugin.has_key('version'):
463
        print "External Plugins are required to specifiy a version"
464
        sys.exit(1)
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
465
    if not plugin.has_key('version'):
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
466
      plugin['version'] = config['default_plugin_version']
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
467
    if plugin.has_key('load_by_default'):
468
      plugin['load_by_default']=parser.getboolean('plugin','load_by_default')
1273.12.6 by Monty Taylor
Added support for disabling plugins
469
    if plugin.has_key('disabled'):
470
      plugin['disabled']=parser.getboolean('plugin','disabled')
471
    if plugin['disabled']:
472
      plugin['enabled']="no"
473
    else:
474
      plugin['enabled']="yes"
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
475
    if plugin.has_key('static'):
1861.3.3 by Monty Taylor
Add support platform conditional static plugins.
476
      try:
477
        plugin['static']= parser.getboolean('plugin','static')
478
      except:
479
        if plugin['static'][:5] == os.sys.platform[:5]:
480
          plugin['static']= True
481
        else:
482
          plugin['static']= False
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
483
    if plugin.has_key('install'):
484
      plugin['install']= parser.getboolean('plugin','install')
1192.3.20 by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites.
485
    if plugin.has_key('testsuite'):
486
      if plugin['testsuite'] == 'disable':
487
        plugin['testsuite']= False
1716.1.1 by Monty Taylor
Added files to the tarball that should be there. Removed some that shouldn't
488
        plugin['dist_testsuite']= find_testsuite(plugin_dir)
1192.3.20 by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites.
489
    else:
490
      plugin_testsuite= find_testsuite(plugin_dir)
491
      plugin['testsuitedir']=plugin_testsuite
492
      if plugin_testsuite is not None:
493
        plugin['testsuite']=True
494
      else:
495
        plugin['testsuite']=False
1794.2.5 by Monty Taylor
Added support to pandora for finding and including per-plugin documentation.
496
    plugin['docs']= find_docs(plugin_dir)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
497
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
498
    plugin['cflags']+= ' ' + config['extra_cflags']
499
    plugin['cppflags']+= ' ' + config['extra_cppflags']
500
    plugin['cxxflags']+= ' ' + config['extra_cxxflags']
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
501
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
502
    plugin['libname']= "lib%s%s%s" % (config['plugin_prefix'],
503
                                      plugin['name'],
504
                                      config['plugin_suffix'])
505
    if config['force_lowercase_libname']:
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
506
      plugin['libname']= plugin['libname'].lower()
507
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
508
    plugin['root_plugin_dir']= config['root_plugin_dir']
509
    plugin['plugin_prefix']= config['plugin_prefix']
510
    plugin['plugin_suffix']= config['plugin_suffix']
511
    plugin['pkgplugindir']= config['pkgplugindir']
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
512
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
513
    # Dependencies must have a module but dependency aliases are simply added
514
    # to the variable passed during compile.
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
515
    plugin['dependency_list'] = plugin['dependencies'].split()
516
    dependency_aliases = plugin['dependency_aliases'].split()
517
    plugin['dependencies'] = ','.join(plugin['dependency_list'] +
518
                                      plugin['dependency_aliases'].split())
519
    dependency_libs = ["%s/lib%s%s.la" % (config['root_plugin_dir'],
520
                                          dependency.lower().replace('::', '_'),
521
                                          config['plugin_suffix'])
522
                       for dependency in plugin['dependency_list']]
523
    plugin['libs'] = " ".join(plugin['libs'].split() + dependency_libs);
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
524
525
# Libtool is going to expand:
526
#      -DPANDORA_MODULE_AUTHOR='"Padraig O'"'"'Sullivan"'
527
# to:
528
# "-DPANDORA_MODULE_AUTHOR=\"Padraig O'Sullivan\""
529
# So we have to replace internal ''s to '"'"'
530
    for key in ('author','title','description','version'):
531
      plugin[key]=plugin[key].replace('"','\\"')
532
      plugin[key]=plugin[key].replace("'","'\"'\"'")
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
533
    return plugin
534
535
536
def write_plugin_am(plugin, plugin_am):
537
  """Write an automake fragment for this plugin.
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
538
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
539
  :param plugin: The plugin dict.
540
  :param plugin_am: The file to write to.
541
  """
542
  # The .plugin.ini.stamp avoids changing the datestamp on plugin.ini which can
543
  # confuse VCS systems.
1192.3.25 by Monty Taylor
It seems to work.
544
  plugin_am.write("""
545
EXTRA_DIST += %(rel_path)s/plugin.ini
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
546
547
# Prevent errors when a plugin dir is removed
548
%(rel_path)s/plugin.ini:
1192.3.53 by Robert Collins
Build fixes from Robert.
549
550
""" % plugin)
1716.1.1 by Monty Taylor
Added files to the tarball that should be there. Removed some that shouldn't
551
  if plugin.has_key('extra_dist') and plugin['extra_dist'] != "":
552
    plugin_am.write("EXTRA_DIST += %(extra_dist)s\n" % plugin)
2426.3.1 by Henrik Ingo
This does 2 things:
553
  if plugin.has_key('bin_scripts') and plugin['bin_scripts'] != "":
554
    plugin_am.write("dist_bin_SCRIPTS += %(bin_scripts)s\n" % plugin)
555
  if plugin.has_key('scripts') and plugin['scripts'] != "":
556
    plugin_am.write("dist_bin_SCRIPTS += %(scripts)s\n" % plugin)
557
  if plugin.has_key('sbin_scripts') and plugin['sbin_scripts'] != "":
558
    plugin_am.write("dist_sbin_SCRIPTS += %(sbin_scripts)s\n" % plugin)
559
  if plugin.has_key('libexec_scripts') and plugin['libexec_scripts'] != "":
560
    plugin_am.write("dist_libexec_SCRIPTS += %(libexec_scripts)s\n" % plugin)
561
  if plugin.has_key('pkg_scripts') and plugin['pkg_scripts'] != "":
562
    plugin_am.write("dist_pkgdata_SCRIPTS += %(pkg_scripts)s\n" % plugin)
563
  if plugin.has_key('data') and plugin['data'] != "":
564
    plugin_am.write("dist_data_DATA += %(data)s\n" % plugin)
565
  if plugin.has_key('pkg_data') and plugin['pkg_data'] != "":
566
    plugin_am.write("dist_pkgdata_DATA += %(pkg_data)s\n" % plugin)
567
  if plugin.has_key('sysconf_data') and plugin['sysconf_data'] != "":
568
    plugin_am.write("dist_sysconf_DATA += %(sysconf_data)s\n" % plugin)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
569
  if plugin['headers'] != "":
570
    plugin_am.write("noinst_HEADERS += %(headers)s\n" % plugin)
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
571
  if plugin['install_headers'] != "":
2157.2.1 by Monty Taylor
Provide pkg-config files and also stick drizzle plugin files in a place
572
    plugin_am.write("nobase_pkginclude_HEADERS += %(install_headers)s\n" % plugin)
1192.3.20 by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites.
573
  if plugin['testsuite']:
574
    if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "":
575
      plugin_am.write("EXTRA_DIST += %(rel_path)s/%(testsuitedir)s\n" % plugin)
1716.1.1 by Monty Taylor
Added files to the tarball that should be there. Removed some that shouldn't
576
  if plugin.has_key('dist_testsuite') and plugin['dist_testsuite'] != "":
577
    plugin_am.write("EXTRA_DIST += %(rel_path)s/%(dist_testsuite)s\n" % plugin)
1794.2.7 by Monty Taylor
Fixed a couple of options around make dist to make sure all the .rst files
578
  if plugin['docs'] is not None:
579
    plugin_am.write("EXTRA_DIST += ${top_srcdir}/%(rel_path)s/docs/*.rst\n" % plugin)
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
580
  plugin_am.write("""
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
581
%(root_plugin_dir)s_%(plugin_prefix)s%(name)s_dir=${top_srcdir}/%(rel_path)s
2093.1.2 by Monty Taylor
Make sure we distribute all the source files, even if configure didn't find
582
# Include sources in EXTRA_DIST because we might not build this, but we
583
# still want the sources to wind up in a tarball
584
EXTRA_DIST += %(rel_path)s/plugin.ini %(sources)s
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
585
if %(static_build_conditional_tag)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
586
  noinst_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la
587
  %(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s
588
  %(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s
589
  %(root_plugin_dir)s_%(libname)s_la_LDFLAGS=$(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
2088.4.1 by Monty Taylor
Removed an extra set of quoting.
590
  %(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='%(author)s' -DPANDORA_MODULE_TITLE='%(title)s' -DPANDORA_MODULE_VERSION='%(version)s' -DPANDORA_MODULE_LICENSE=%(license)s -DPANDORA_MODULE_DEPENDENCIES='%(dependencies)s' %(cppflags)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
591
  %(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
592
  %(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
593
  %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
594
  check_PROGRAMS += %(tests)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
595
  PANDORA_DYNAMIC_LDADDS+=${top_builddir}/%(root_plugin_dir)s/%(libname)s.la
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
596
endif
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
597
EXTRA_DIST += %(rel_path)s/plugin.ini
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
598
if %(shared_build_conditional_tag)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
599
  %(library_type)s_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la
600
  %(root_plugin_dir)s_%(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
601
  %(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s
602
  %(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s
2088.4.1 by Monty Taylor
Removed an extra set of quoting.
603
  %(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='%(author)s' -DPANDORA_MODULE_TITLE='%(title)s' -DPANDORA_MODULE_VERSION='%(version)s' -DPANDORA_MODULE_LICENSE=%(license)s -DPANDORA_MODULE_DEPENDENCIES='%(dependencies)s' %(cppflags)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
604
  %(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
605
  %(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
606
  %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
607
  check_PROGRAMS += %(tests)s
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
608
endif
609
""" % plugin)
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
610
  plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')
611
  if os.path.exists(plugin_am_file):
612
    plugin_am.write('include %s\n' % plugin_am_file)
613
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
614
#
615
# MAIN STARTS HERE:
616
#
617
618
# Parse the pandora-plugin config file
619
620
config_defaults= dict(
621
  top_srcdir='.',
622
  top_builddir='.',
623
  plugin_ini_fname='plugin.ini',
624
  plugin_prefix='',
625
  plugin_suffix='',
626
  extra_cflags='',
627
  extra_cppflags='',
628
  extra_cxxflags='',
629
  root_plugin_dir='',
630
  pkgplugindir='',
631
  default_install='True',
632
  default_plugin_version='',
633
  default_load_by_default='False',
634
  force_lowercase_libname='True',
635
  plugin_name_separator='_',
636
  module_name_separator='::'
637
)
638
639
config_parser = ConfigParser.ConfigParser(defaults=config_defaults)
640
config_parser.read(pandora_plugin_file)
641
config = dict(config_parser.items('pandora-plugin'))
642
config['force_lowercase_libname']=config_parser.getboolean('pandora-plugin','force_lowercase_libname')
1192.3.25 by Monty Taylor
It seems to work.
643
1377.3.8 by Monty Taylor
Let's not hardcode bzr.
644
# I'm 3 seconds away from writing a comprehensive build solution
1377.3.7 by Monty Taylor
Read out the vcinfo file if it's there.
645
if not os.path.exists('config/pandora_vc_revinfo'):
1377.3.8 by Monty Taylor
Let's not hardcode bzr.
646
  if os.path.exists('.bzr'):
647
    bzr_revno= subprocess.Popen(["bzr", "revno"], stdout=subprocess.PIPE).communicate()[0].strip()
648
    rev_date= datetime.date.fromtimestamp(time.time())
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
649
    config['default_plugin_version'] = "%d.%02d.%s" % (rev_date.year, rev_date.month, bzr_revno)
1377.3.8 by Monty Taylor
Let's not hardcode bzr.
650
  else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
651
    config['default_plugin_version']=datetime.date.fromtimestamp(time.time()).isoformat()
1377.3.6 by Monty Taylor
Set the default plugin version for plugins not specifying a version to be
652
else:
653
  # need to read config/pandora_vc_revno
1377.3.7 by Monty Taylor
Read out the vcinfo file if it's there.
654
  pandora_vc_revno=open('config/pandora_vc_revinfo','r').read().split()
655
  rev_date=""
656
  bzr_revno=""
657
  for revno_line in pandora_vc_revno:
658
    (revno_key,revno_val)= revno_line.split("=")
659
    if revno_key == 'PANDORA_VC_REVNO':
660
      bzr_revno=revno_val.strip()
661
    elif revno_key == 'PANDORA_RELEASE_DATE':
662
      rev_date=revno_val.strip()
663
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
664
  config['default_plugin_version'] = "%s.%s" % (rev_date, bzr_revno)
1377.3.7 by Monty Taylor
Read out the vcinfo file if it's there.
665
1192.3.25 by Monty Taylor
It seems to work.
666
actions=[]
667
for arg in sys.argv:
668
  if arg.startswith('--top_srcdir='):
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
669
    config['top_srcdir']=arg[12:]
1192.3.25 by Monty Taylor
It seems to work.
670
  elif arg.startswith('--top_builddir='):
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
671
    config['top_builddir']=arg[14:]
1192.3.25 by Monty Taylor
It seems to work.
672
  elif arg == "--force-all":
673
    actions=['plugin-list','pandora-plugin.am','write']
674
    break
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
675
  else:
1192.3.25 by Monty Taylor
It seems to work.
676
    actions.append(arg)
677
if len(actions) == 0:
678
  actions.append('write')
679
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
680
plugin_list=[]
681
1192.3.25 by Monty Taylor
It seems to work.
682
def accumulate_plugins(arg, dirname, fnames):
683
  # plugin_ini_fname is a name in dirname indicating dirname is a plugin.
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
684
  if config['plugin_ini_fname'] in fnames:
1192.3.25 by Monty Taylor
It seems to work.
685
    arg.append(dirname)
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
686
687
os.path.walk(os.path.join(config['top_srcdir'],
688
                          config['root_plugin_dir']),
689
             accumulate_plugins,
690
             plugin_list)
1192.3.25 by Monty Taylor
It seems to work.
691
692
if not os.path.exists("config/pandora-plugin.am") or "write" in actions:
693
  plugin_am_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.am'))
694
  plugin_am_file.write("""
695
# always the current list, generated every build so keep this lean.
1192.3.74 by Robert Collins
Finish the renaming of plugin.list -> pandora-plugin.list that mtaylor started.
696
# pandora-plugin.list: datestamp preserved list
697
${srcdir}/config/pandora-plugin.list: .plugin.scan
1192.3.25 by Monty Taylor
It seems to work.
698
.plugin.scan:
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
699
	@cd ${top_srcdir} && python config/pandora-plugin plugin-list
1192.3.25 by Monty Taylor
It seems to work.
700
701
# Plugins affect configure; so to prevent configure running twice in a tarball
702
# build (once up front, once with the right list of plugins, we ship the
703
# generated list of plugins and the housekeeping material for that list so it
704
# is likewise not updated.
705
EXTRA_DIST += \
706
	config/pandora-plugin.am \
707
	config/pandora-plugin.ac \
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
708
	config/pandora-plugin \
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
709
	config/pandora-plugin.ini
1192.3.25 by Monty Taylor
It seems to work.
710
711
712
# Seed the list of plugin LDADDS which plugins may extend.
713
PANDORA_DYNAMIC_LDADDS=
714
715
# plugin.stamp: graph dominator for creating all per pandora-plugin.ac/am
716
# files. This is invoked when the code to generate such files has altered.""")
717
718
if not os.path.exists("config/pandora-plugin.ac") or "write" in actions:
719
  plugin_ac_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.ac'))
720
  plugin_ac_file.write("dnl Generated file, run make to rebuild\n")
2093.1.1 by Monty Taylor
Adds ability to build plugins static.
721
  plugin_ac_file.write("""
722
AC_ARG_WITH([all-static],[
723
AS_HELP_STRING([--with-all-static],[Link all plugins staticly into the server @<:@default=no@:>@])
724
],[
725
    with_all_static="$withval"
726
    ],[
727
    with_all_static=no
728
])
729
  """)
1192.3.25 by Monty Taylor
It seems to work.
730
1794.2.5 by Monty Taylor
Added support to pandora for finding and including per-plugin documentation.
731
if os.path.exists("docs/plugins"):
732
  if not os.path.exists("docs/plugins/list.rst") or "write" in actions:
733
    plugin_doc_index = ChangeProtectedFile("docs/plugins/list.rst")
734
    plugin_doc_index.write("""
735
Plugin Documentation
736
====================
737
738
.. toctree::
739
   :maxdepth: 2
740
""")
741
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
742
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
743
if os.path.exists('plugin.ini'):
744
  # Are we in a plugin dir which wants to have a self-sufficient build system?
1192.3.25 by Monty Taylor
It seems to work.
745
  plugin_list=['.']
1241.9.3 by Monty Taylor
Fixed the out-of-tree plugin file generation.
746
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
747
  write_external_plugin()
748
else:
1192.3.25 by Monty Taylor
It seems to work.
749
  plugin_list_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.list'))
750
  for p in plugin_list:
751
    plugin_list_file.write(p)
752
    plugin_list_file.write("\n")
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
753
  plugin_list.sort()
1192.3.25 by Monty Taylor
It seems to work.
754
  plugin_list_file.close()
755
756
if not os.path.exists("config/pandora-plugin.am") or 'write' in actions:
1192.3.74 by Robert Collins
Finish the renaming of plugin.list -> pandora-plugin.list that mtaylor started.
757
  plugin_am_file.write("\n${top_srcdir}/config/pandora-plugin.am: ${top_srcdir}/config/pandora-plugin.list ${top_srcdir}/config/pandora-plugin ")
1192.3.25 by Monty Taylor
It seems to work.
758
  for plugin_dir in plugin_list:
759
    plugin_am_file.write("\\\n\t%s/plugin.ini " % plugin_dir)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
760
  plugin_am_file.write("\n\tcd ${top_srcdir} && python config/pandora-plugin write\n")
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
761
  plugin_ini_list=[]
762
763
  # Load all plugin.ini files first so we can do dependency tracking.
1192.3.25 by Monty Taylor
It seems to work.
764
  for plugin_dir in plugin_list:
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
765
    plugin = read_plugin_ini(plugin_dir)
766
    expand_plugin_ini(plugin)
767
    plugin_ini_list.append(plugin)
768
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
769
  # Check for duplicates
770
  plugin_name_list = [plugin['libname'] for plugin in plugin_ini_list]
771
  for plugin in plugin_ini_list:
772
    if plugin_name_list.count(plugin['libname']) != 1:
773
      print "Duplicate module name %s" % plugin['libname']
774
      exit(1)
775
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
776
  for plugin in plugin_ini_list:
777
    write_plugin(plugin, plugin_ini_list)
1192.3.25 by Monty Taylor
It seems to work.
778
779
if plugin_am_file is not None:
780
  plugin_am_file.close()
781
if plugin_ac_file is not None:
782
  plugin_ac_file.close()
1794.2.5 by Monty Taylor
Added support to pandora for finding and including per-plugin documentation.
783
if plugin_doc_index is not None:
784
  plugin_doc_index.close()