~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to config/register_plugins.py

Merge Devananda's BENCHMARK UDF plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
plugin_list=[]
27
27
autogen_header="This file is generated, re-run %s to rebuild\n" % sys.argv[0]
28
28
 
29
 
class ChangeProtectedFile(object):
30
 
 
31
 
  def __init__(self, fname):
32
 
    self.real_fname= fname
33
 
    self.new_fname= "%s.new" % fname
34
 
    self.new_file= open(self.new_fname,'w')
35
 
 
36
 
  def write(self, text):
37
 
    self.new_file.write(text)
38
 
 
39
 
  # We've written all of this out into .new files, now we only copy them
40
 
  # over the old ones if they are different, so that we don't cause 
41
 
  # unnecessary recompiles
42
 
  def close(self):
43
 
    self.new_file.close()
44
 
    if os.system('diff %s %s >/dev/null 2>&1' % (self.new_fname,self.real_fname)):
45
 
      try:
46
 
        os.unlink(self.real_fname)
47
 
      except:
48
 
        pass
49
 
      os.rename(self.new_fname, self.real_fname)
50
 
    try:
51
 
      os.unlink(self.new_fname)
52
 
    except:
53
 
      pass
54
 
 
55
29
if len(sys.argv)>1:
56
30
  top_srcdir=sys.argv[1]
57
31
  top_builddir=top_srcdir
58
32
if len(sys.argv)>2:
59
33
  top_builddir=sys.argv[2]
60
34
 
61
 
plugin_ac=ChangeProtectedFile(os.path.join(top_builddir,'config','plugin.ac'))
62
 
plugin_am=ChangeProtectedFile(os.path.join(top_srcdir,'config','plugin.am'))
63
 
 
 
35
plugin_ac=open(os.path.join(top_builddir,'config','plugin.ac.new'),'w')
 
36
plugin_am=open(os.path.join(top_srcdir,'config','plugin.am.new'),'w')
64
37
plugin_ac.write("dnl %s" % autogen_header)
65
38
plugin_am.write("# %s" % autogen_header)
66
 
plugin_am.write("PANDORA_DYNAMIC_LDADDS=\n")
67
39
 
68
40
def accumulate_plugins(arg, dirname, fnames):
69
41
  if plugin_ini_fname in fnames:
75
47
 
76
48
for plugin_dir in plugin_list:
77
49
  plugin_file= os.path.join(plugin_dir,plugin_ini_fname)
78
 
  parser=ConfigParser.ConfigParser(defaults=dict(sources="",headers="", cflags="",cppflags="",cxxflags="", libs="", ldflags="", testsuite=""))
 
50
  parser=ConfigParser.ConfigParser(defaults=dict(sources="",headers="", cflags="",cppflags="",cxxflags="", libs="", ldflags=""))
79
51
  parser.read(plugin_file)
80
52
  plugin=dict(parser.items('plugin'))
81
53
  plugin['rel_path']= plugin_dir[len(top_srcdir)+len(os.path.sep):]
96
68
      header= os.path.join(plugin['rel_path'], header)
97
69
      new_headers= "%s %s" % (new_headers, header)
98
70
  plugin['headers']= new_headers
99
 
 
 
71
  
100
72
  if plugin.has_key('load_by_default'):
101
73
    plugin['load_by_default']=parser.getboolean('plugin','load_by_default')
102
74
  else:
125
97
    plugin['has_build_conditional']=False
126
98
    plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin
127
99
 
128
 
  # Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN %(cppflags)s
 
100
  # Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DDRIZZLE_DYNAMIC_PLUGIN %(cppflags)s
129
101
 
130
102
  #
131
103
  # Write plugin build instructions into plugin.am file.
145
117
  plugin_lib%(name)s_plugin_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
146
118
 
147
119
  plugin_lib%(name)s_plugin_la_SOURCES=%(sources)s
148
 
  PANDORA_DYNAMIC_LDADDS+=${top_builddir}/plugin/lib%(name)s_plugin.la
149
120
endif
150
121
""" % plugin)
151
122
  # Add this once we're actually doing dlopen (and remove -avoid-version if
152
123
  # we move to ltdl
153
124
  #pkgplugin_LTLIBRARIES+=plugin/lib%(name)s_plugin.la
154
125
  #plugin_lib%(name)s_plugin_la_LDFLAGS=-module -avoid-version -rpath $(pkgplugindir) %(libs)s
155
 
 
 
126
  #drizzled_drizzled_LDADD+=${top_builddir}/plugin/lib%(name)s_plugin.la
156
127
 
157
128
  if os.path.exists(plugin_am_file):
158
 
    plugin_am.write('include %s\n' % plugin_am_file)
 
129
    plugin_am.write('include %s\n' % plugin_am_file) 
159
130
 
160
131
  #
161
132
  # Write plugin config instructions into plugin.am file.
162
133
  #
163
134
  plugin_ac.write("\n\ndnl Config for %(title)s\n" % plugin)
164
135
  for m4_file in plugin_m4_files:
165
 
    plugin_ac.write('m4_sinclude([%s])\n' % m4_file)
 
136
    plugin_ac.write('m4_sinclude([%s])\n' % m4_file) 
166
137
 
167
138
  plugin_ac.write("""
168
139
AC_ARG_WITH([%(name_with_dashes)s-plugin],[
194
165
               [test %(build_conditional)s])
195
166
AS_IF([test "x$with_%(name)s_plugin" = "xyes"],
196
167
      [
197
 
  """ % plugin)
198
 
  if plugin['testsuite'] != "":
199
 
    plugin_ac.write("""
200
 
        pandora_plugin_test_list="%(testsuite)s,${pandora_plugin_test_list}"
201
 
    """ % plugin)
202
 
 
203
 
  plugin_ac.write("""
204
 
        pandora_default_plugin_list="%(name)s,${pandora_default_plugin_list}"
205
 
        pandora_builtin_list="builtin_%(name)s_plugin,${pandora_builtin_list}"
206
 
        pandora_plugin_libs="${pandora_plugin_libs} \${top_builddir}/plugin/lib%(name)s_plugin.la"
207
 
        PANDORA_PLUGIN_DEP_LIBS="${PANDORA_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
 
168
        drizzled_default_plugin_list="%(name)s,${drizzled_default_plugin_list}"
 
169
        drizzled_builtin_list="builtin_%(name)s_plugin,${drizzled_builtin_list}"
 
170
        drizzled_plugin_libs="${drizzled_plugin_libs} \${top_builddir}/plugin/lib%(name)s_plugin.la"
 
171
        DRIZZLED_PLUGIN_DEP_LIBS="${DRIZZLED_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
208
172
      ])
209
173
""" % plugin)
210
 
 
 
174
 
211
175
plugin_ac.close()
212
176
plugin_am.close()
213
177
 
 
178
# We've written all of this out into .new files, now we only copy them
 
179
# over the old ones if they are different, so that we don't cause 
 
180
# unnecessary recompiles
 
181
for f in ('plugin.ac','plugin.am'):
 
182
  fname= os.path.join(top_builddir,'config',f)
 
183
  if os.system('diff %s.new %s >/dev/null 2>&1' % (fname,fname)):
 
184
    try:
 
185
      os.unlink(fname)
 
186
    except:
 
187
      pass
 
188
    os.rename('%s.new' % fname, fname)
 
189
  try:
 
190
    os.unlink("%s.new" % fname)
 
191
  except:
 
192
    pass