22
22
import datetime, time
27
plugin_ini_fname='plugin.ini'
32
plugin_suffix='_plugin'
36
root_plugin_dir='plugin'
37
pkgplugindir='$(libdir)/drizzle'
38
default_install='True'
39
default_plugin_version=''
25
from pandora_plugin_config import *
41
27
class ChangeProtectedFile(object):
144
130
if plugin['headers'] != "":
145
131
plugin_file.write("noinst_HEADERS = %(headers)s\n" % plugin)
132
if plugin['install_headers'] != "":
133
plugin_file.write("nobase_include_HEADERS += %(install_headers)s\n" % plugin)
146
134
if plugin['testsuite']:
147
135
if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "":
148
136
plugin_file.write("EXTRA_DIST += %(testsuitedir)s\n" % plugin)
149
137
plugin_file.write("""
150
pkgplugin_LTLIBRARIES=%(pname)s.la
151
%(pname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
152
%(pname)s_la_LIBADD=%(libs)s
153
%(pname)s_la_DEPENDENCIES=%(libs)s
154
%(pname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(name)s -DPANDORA_MODULE_AUTHOR="%(author)s" -DPANDORA_MODULE_TITLE="%(title)s" -DPANDORA_MODULE_VERSION="%(version)s" -DPANDORA_MODULE_LICENSE=%(license)s %(cppflags)s
155
%(pname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
156
%(pname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
138
pkgplugin_LTLIBRARIES=%(libname)s.la
139
%(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
140
%(libname)s_la_LIBADD=%(libs)s
141
%(libname)s_la_DEPENDENCIES=%(libs)s
142
%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(name)s -DPANDORA_MODULE_AUTHOR='"%(author)s"' -DPANDORA_MODULE_TITLE='"%(title)s"' -DPANDORA_MODULE_VERSION='"%(version)s"' -DPANDORA_MODULE_LICENSE=%(license)s %(cppflags)s
143
%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
144
%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
158
%(pname)s_la_SOURCES=%(sources)s
146
%(libname)s_la_SOURCES=%(sources)s
161
149
plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')
165
153
def write_external_plugin():
166
154
"""Return True if the plugin had changed."""
167
155
plugin = read_plugin_ini('.')
168
expand_plugin_ini(plugin, '.')
156
expand_plugin_ini(plugin)
169
157
plugin_file = ChangeProtectedFile('configure.ac')
170
158
write_external_configure(plugin, plugin_file)
171
159
result = plugin_file.close()
175
163
result = plugin_file.close() or result
178
def write_plugin(plugin_dir):
179
"""Return True if the plugin had changed."""
180
plugin = read_plugin_ini(plugin_dir)
181
expand_plugin_ini(plugin, plugin_dir)
166
def write_plugin(plugin, plugin_ini_list):
167
# Since this function is recursive, make sure we're not already in it.
168
if plugin.has_key('writing_status'):
169
if plugin['writing_status'] == 'done':
172
print "Dependency loop detected with " % plugin['name']
175
plugin['writing_status'] = 'dependencies'
177
# Write all dependencies first to get around annoying automake bug
178
if plugin['dependency_list'] is not None:
179
for dependency in plugin['dependency_list']:
181
for find_plugin in plugin_ini_list:
182
if find_plugin['name'] == dependency:
184
write_plugin(find_plugin, plugin_ini_list)
187
print "Could not find dependency %s" % dependency
182
190
write_plugin_ac(plugin, plugin_ac_file)
183
191
write_plugin_am(plugin, plugin_am_file)
192
plugin['writing_status'] = 'done'
185
194
def write_plugin_ac(plugin, plugin_ac):
206
215
dnl possible to disable it. Once it is disableable, we will make it non-static.
207
216
with_%(name)s_plugin=yes
208
217
pandora_builtin_list="_drizzled_%(name)s_plugin_,${pandora_builtin_list}"
209
pandora_plugin_libs="${pandora_plugin_libs} \${top_builddir}/%(root_plugin_dir)s/%(pname)s.la"
218
pandora_plugin_libs="${pandora_plugin_libs} \${top_builddir}/%(root_plugin_dir)s/%(libname)s.la"
210
219
PANDORA_PLUGIN_DEP_LIBS="${PANDORA_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
281
290
plugin_ac.write(" ])\n")
284
def expand_plugin_ini(plugin, plugin_dir):
293
def expand_plugin_ini(plugin):
285
294
if plugin['name'] == "**OUT-OF-TREE**":
286
295
print "Out of tree plugins require the name field to be specified in plugin.ini"
289
if plugin_dir == ".":
290
plugin['rel_path']= plugin_dir
298
if plugin['plugin_dir'] == ".":
299
plugin['rel_path']= plugin['plugin_dir']
291
300
plugin['unconditional']=True
293
plugin['rel_path']= plugin_dir[len(top_srcdir)+len(os.path.sep):]
302
plugin['rel_path']= plugin['plugin_dir'][len(top_srcdir)+len(os.path.sep):]
294
303
plugin['unconditional']=False
295
304
# TODO: determine path to plugin dir relative to top_srcdir... append it to
296
305
# source files if they don't already have it
297
306
if plugin['sources'] == "":
298
307
plugin['sources']="%s.cc" % plugin['name']
300
if plugin_dir != ".":
309
if plugin['plugin_dir'] != ".":
301
310
for src in plugin['sources'].split():
302
311
if not src.startswith(plugin['rel_path']):
303
312
src= os.path.join(plugin['rel_path'], src)
309
318
plugin['main_source']= plugin['sources'].split()[0]
312
if plugin_dir != ".":
321
if plugin['plugin_dir'] != ".":
313
322
for header in plugin['headers'].split():
314
323
if not header.startswith(plugin['rel_path']):
315
324
header= os.path.join(plugin['rel_path'], header)
319
328
if new_headers != "":
320
329
plugin['headers']= new_headers
331
new_install_headers=""
332
if plugin['plugin_dir'] != ".":
333
for header in plugin['install_headers'].split():
334
if not header.startswith(plugin['rel_path']):
335
header= os.path.join(plugin['rel_path'], header)
336
new_install_headers= "%s %s" % (new_install_headers, header)
338
new_install_headers= " ".join(plugin['install_headers'].split())
339
if new_install_headers != "":
340
plugin['install_headers']= new_install_headers
322
342
# Make a yes/no version for autoconf help messages
323
343
if plugin['load_by_default']:
324
344
plugin['default_yesno']="yes"
370
391
load_by_default="False",
371
392
disabled="False",
395
dependency_aliases="",
373
396
install=default_install)
374
397
parser=ConfigParser.ConfigParser(defaults= plugin_defaults)
375
398
parser.read(plugin_file)
376
399
plugin=dict(parser.items('plugin'))
400
plugin['plugin_dir'] = plugin_dir
377
401
if plugin_dir == '.':
378
402
if not plugin.has_key('url'):
379
403
print "External Plugins are required to specifiy a url"
412
436
plugin['cppflags']+= extra_cppflags
413
437
plugin['cxxflags']+= extra_cxxflags
415
plugin['pname']= "lib%s%s%s" % (plugin_prefix, plugin['name'], plugin_suffix)
439
plugin['libname']= "lib%s%s%s" % (plugin_prefix, plugin['name'], plugin_suffix)
440
if force_lowercase_libname:
441
plugin['libname']= plugin['libname'].lower()
416
443
plugin['root_plugin_dir']= root_plugin_dir
417
444
plugin['plugin_prefix']= plugin_prefix
418
445
plugin['plugin_suffix']= plugin_suffix
419
446
plugin['pkgplugindir']= pkgplugindir
448
# Dependencies must have a module but dependency aliases are simply added
449
# to the variable passed during compile.
450
plugin['dependencies'] = plugin['dependencies'].replace(' ', '')
451
plugin['dependency_aliases'] = plugin['dependency_aliases'].replace(' ', '')
452
if plugin['dependencies'] == '':
453
plugin['dependency_list'] = None
454
plugin['dependencies'] = plugin['dependency_aliases']
456
plugin['dependency_list'] = plugin['dependencies'].split(',')
457
if plugin['dependency_aliases'] != '':
458
plugin['dependencies'] = ','.join([plugin['dependencies'], plugin['dependency_aliases']])
460
# Libtool is going to expand:
461
# -DPANDORA_MODULE_AUTHOR='"Padraig O'"'"'Sullivan"'
463
# "-DPANDORA_MODULE_AUTHOR=\"Padraig O'Sullivan\""
464
# So we have to replace internal ''s to '"'"'
465
for key in ('author','title','description','version'):
466
plugin[key]=plugin[key].replace('"','\\"')
467
plugin[key]=plugin[key].replace("'","'\"'\"'")
439
486
if plugin['headers'] != "":
440
487
plugin_am.write("noinst_HEADERS += %(headers)s\n" % plugin)
488
if plugin['install_headers'] != "":
489
plugin_am.write("nobase_include_HEADERS += %(install_headers)s\n" % plugin)
441
490
if plugin['testsuite']:
442
491
if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "":
443
492
plugin_am.write("EXTRA_DIST += %(rel_path)s/%(testsuitedir)s\n" % plugin)
446
495
%(root_plugin_dir)s_%(plugin_prefix)s%(name)s_dir=${top_srcdir}/%(rel_path)s
447
496
EXTRA_DIST += %(rel_path)s/plugin.ini
448
497
if %(build_conditional_tag)s
449
noinst_LTLIBRARIES+=%(root_plugin_dir)s/%(pname)s.la
450
%(root_plugin_dir)s_%(pname)s_la_LIBADD=%(libs)s
451
%(root_plugin_dir)s_%(pname)s_la_DEPENDENCIES=%(libs)s
452
%(root_plugin_dir)s_%(pname)s_la_LDFLAGS=$(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
453
%(root_plugin_dir)s_%(pname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_MODULE_NAME=%(name)s -DPANDORA_MODULE_AUTHOR="%(author)s" -DPANDORA_MODULE_TITLE="%(title)s" -DPANDORA_MODULE_VERSION="%(version)s" -DPANDORA_MODULE_LICENSE=%(license)s %(cppflags)s
454
%(root_plugin_dir)s_%(pname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
455
%(root_plugin_dir)s_%(pname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
498
noinst_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la
499
%(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s
500
%(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s
501
%(root_plugin_dir)s_%(libname)s_la_LDFLAGS=$(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
502
%(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_MODULE_NAME=%(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
503
%(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
504
%(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
457
%(root_plugin_dir)s_%(pname)s_la_SOURCES=%(sources)s
458
PANDORA_DYNAMIC_LDADDS+=${top_builddir}/%(root_plugin_dir)s/%(pname)s.la
506
%(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s
507
PANDORA_DYNAMIC_LDADDS+=${top_builddir}/%(root_plugin_dir)s/%(libname)s.la
463
512
%(root_plugin_dir)s_%(plugin_prefix)s%(name)s_dir=${top_srcdir}/%(rel_path)s
464
513
EXTRA_DIST += %(rel_path)s/plugin.ini
465
514
if %(build_conditional_tag)s
466
%(library_type)s_LTLIBRARIES+=%(root_plugin_dir)s/%(pname)s.la
467
%(root_plugin_dir)s_%(pname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
468
%(root_plugin_dir)s_%(pname)s_la_LIBADD=%(libs)s
469
%(root_plugin_dir)s_%(pname)s_la_DEPENDENCIES=%(libs)s
470
%(root_plugin_dir)s_%(pname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(name)s -DPANDORA_MODULE_AUTHOR="%(author)s" -DPANDORA_MODULE_TITLE="%(title)s" -DPANDORA_MODULE_VERSION="%(version)s" -DPANDORA_MODULE_LICENSE=%(license)s %(cppflags)s
471
%(root_plugin_dir)s_%(pname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
472
%(root_plugin_dir)s_%(pname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
515
%(library_type)s_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la
516
%(root_plugin_dir)s_%(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
517
%(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s
518
%(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s
519
%(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(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
520
%(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
521
%(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
474
%(root_plugin_dir)s_%(pname)s_la_SOURCES=%(sources)s
523
%(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s
477
526
plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')
571
621
for plugin_dir in plugin_list:
572
622
plugin_am_file.write("\\\n\t%s/plugin.ini " % plugin_dir)
573
623
plugin_am_file.write("\n\tcd ${top_srcdir} && python config/pandora-plugin write\n")
626
# Load all plugin.ini files first so we can do dependency tracking.
574
627
for plugin_dir in plugin_list:
575
write_plugin(plugin_dir)
628
plugin = read_plugin_ini(plugin_dir)
629
expand_plugin_ini(plugin)
630
plugin_ini_list.append(plugin)
632
for plugin in plugin_ini_list:
633
write_plugin(plugin, plugin_ini_list)
577
635
if plugin_am_file is not None:
578
636
plugin_am_file.close()