~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to config/pandora-plugin

  • Committer: Monty Taylor
  • Date: 2010-04-16 00:08:16 UTC
  • mto: (1461.2.2 more-valgrind)
  • mto: This revision was merged to the branch mainline in revision 1477.
  • Revision ID: mordred@inaugust.com-20100416000816-ihkknd84g315lmmu
Latest pandora-build. Moves the lint check to only run distcheck.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import datetime, time
23
23
import subprocess
24
24
 
25
 
top_srcdir='.'
26
 
top_builddir='.'
27
 
plugin_ini_fname='plugin.ini'
28
 
plugin_list=[]
29
 
plugin_am_file=None
30
 
plugin_ac_file=None
31
 
plugin_prefix=''
32
 
plugin_suffix='_plugin'
33
 
extra_cflags=''
34
 
extra_cppflags=''
35
 
extra_cxxflags=''
36
 
root_plugin_dir='plugin'
37
 
pkgplugindir='$(libdir)/drizzle'
38
 
default_install='True'
39
 
default_plugin_version=''
 
25
from pandora_plugin_config import *
40
26
 
41
27
class ChangeProtectedFile(object):
42
28
 
143
129
""" % plugin)
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
157
145
 
158
 
%(pname)s_la_SOURCES=%(sources)s
 
146
%(libname)s_la_SOURCES=%(sources)s
159
147
 
160
148
""" % plugin)
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
176
164
  return result
177
165
 
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':
 
170
      return
 
171
    else:
 
172
      print "Dependency loop detected with " % plugin['name']
 
173
      exit(1)
 
174
 
 
175
  plugin['writing_status'] = 'dependencies'
 
176
 
 
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']:
 
180
      found = False
 
181
      for find_plugin in plugin_ini_list:
 
182
        if find_plugin['name'] == dependency:
 
183
          found = True
 
184
          write_plugin(find_plugin, plugin_ini_list)
 
185
          break
 
186
      if found is False:
 
187
        print "Could not find dependency %s" % dependency
 
188
        exit(1)
 
189
 
182
190
  write_plugin_ac(plugin, plugin_ac_file)
183
191
  write_plugin_am(plugin, plugin_am_file)
 
192
  plugin['writing_status'] = 'done'
184
193
 
185
194
def write_plugin_ac(plugin, plugin_ac):
186
195
  #
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"
211
220
 
212
221
""" % plugin)
281
290
    plugin_ac.write("      ])\n")
282
291
 
283
292
 
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"
287
296
      sys.exit(1)
288
297
 
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
292
301
    else:
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']
299
308
    new_sources=""
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]
310
319
    
311
320
    new_headers=""
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
321
330
    
 
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)
 
337
    else:
 
338
      new_install_headers= " ".join(plugin['install_headers'].split())
 
339
    if new_install_headers != "":
 
340
      plugin['install_headers']= new_install_headers
 
341
    
322
342
    # Make a yes/no version for autoconf help messages
323
343
    if plugin['load_by_default']:
324
344
      plugin['default_yesno']="yes"
357
377
    plugin_file= os.path.join(plugin_dir,plugin_ini_fname)
358
378
    plugin_defaults= dict(sources="",
359
379
                          headers="",
 
380
                          install_headers="",
360
381
                          cflags="",
361
382
                          cppflags="",
362
383
                          cxxflags="",
370
391
                          load_by_default="False",
371
392
                          disabled="False",
372
393
                          static="False",
 
394
                          dependencies="",
 
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
414
438
 
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()
 
442
 
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
420
447
 
 
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']
 
455
    else:
 
456
      plugin['dependency_list'] = plugin['dependencies'].split(',')
 
457
      if plugin['dependency_aliases'] != '':
 
458
        plugin['dependencies'] = ','.join([plugin['dependencies'], plugin['dependency_aliases']])
 
459
 
 
460
# Libtool is going to expand:
 
461
#      -DPANDORA_MODULE_AUTHOR='"Padraig O'"'"'Sullivan"'
 
462
# to:
 
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("'","'\"'\"'")
421
468
    return plugin
422
469
 
423
470
 
438
485
""" % plugin)
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
456
505
 
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
459
508
endif
460
509
""" % plugin)
461
510
  else:
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
473
522
 
474
 
  %(root_plugin_dir)s_%(pname)s_la_SOURCES=%(sources)s
 
523
  %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s
475
524
endif
476
525
""" % plugin)
477
526
  plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')
539
588
EXTRA_DIST += \
540
589
        config/pandora-plugin.am \
541
590
        config/pandora-plugin.ac \
542
 
        config/pandora-plugin
 
591
        config/pandora-plugin \
 
592
        config/pandora_plugin_config.py
543
593
 
544
594
 
545
595
# Seed the list of plugin LDADDS which plugins may extend.
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")
 
624
  plugin_ini_list=[]
 
625
 
 
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)
 
631
 
 
632
  for plugin in plugin_ini_list:
 
633
    write_plugin(plugin, plugin_ini_list)
576
634
 
577
635
if plugin_am_file is not None:
578
636
  plugin_am_file.close()