~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to config/register_plugins.py

MergedĀ inĀ pandora-build

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
 
29
55
if len(sys.argv)>1:
30
56
  top_srcdir=sys.argv[1]
31
57
  top_builddir=top_srcdir
32
58
if len(sys.argv)>2:
33
59
  top_builddir=sys.argv[2]
34
60
 
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')
 
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
 
37
64
plugin_ac.write("dnl %s" % autogen_header)
38
65
plugin_am.write("# %s" % autogen_header)
 
66
plugin_am.write("PANDORA_DYNAMIC_LDADDS=\n")
39
67
 
40
68
def accumulate_plugins(arg, dirname, fnames):
41
69
  if plugin_ini_fname in fnames:
68
96
      header= os.path.join(plugin['rel_path'], header)
69
97
      new_headers= "%s %s" % (new_headers, header)
70
98
  plugin['headers']= new_headers
71
 
  
 
99
 
72
100
  if plugin.has_key('load_by_default'):
73
101
    plugin['load_by_default']=parser.getboolean('plugin','load_by_default')
74
102
  else:
97
125
    plugin['has_build_conditional']=False
98
126
    plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin
99
127
 
100
 
  # Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DDRIZZLE_DYNAMIC_PLUGIN %(cppflags)s
 
128
  # Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN %(cppflags)s
101
129
 
102
130
  #
103
131
  # Write plugin build instructions into plugin.am file.
117
145
  plugin_lib%(name)s_plugin_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
118
146
 
119
147
  plugin_lib%(name)s_plugin_la_SOURCES=%(sources)s
 
148
  PANDORA_DYNAMIC_LDADDS+=${top_builddir}/plugin/lib%(name)s_plugin.la
120
149
endif
121
150
""" % plugin)
122
151
  # Add this once we're actually doing dlopen (and remove -avoid-version if
123
152
  # we move to ltdl
124
153
  #pkgplugin_LTLIBRARIES+=plugin/lib%(name)s_plugin.la
125
154
  #plugin_lib%(name)s_plugin_la_LDFLAGS=-module -avoid-version -rpath $(pkgplugindir) %(libs)s
126
 
  #drizzled_drizzled_LDADD+=${top_builddir}/plugin/lib%(name)s_plugin.la
 
155
 
127
156
 
128
157
  if os.path.exists(plugin_am_file):
129
 
    plugin_am.write('include %s\n' % plugin_am_file) 
 
158
    plugin_am.write('include %s\n' % plugin_am_file)
130
159
 
131
160
  #
132
161
  # Write plugin config instructions into plugin.am file.
133
162
  #
134
163
  plugin_ac.write("\n\ndnl Config for %(title)s\n" % plugin)
135
164
  for m4_file in plugin_m4_files:
136
 
    plugin_ac.write('m4_sinclude([%s])\n' % m4_file) 
 
165
    plugin_ac.write('m4_sinclude([%s])\n' % m4_file)
137
166
 
138
167
  plugin_ac.write("""
139
168
AC_ARG_WITH([%(name_with_dashes)s-plugin],[
168
197
  """ % plugin)
169
198
  if plugin['testsuite'] != "":
170
199
    plugin_ac.write("""
171
 
        drizzled_plugin_test_list="%(testsuite)s,${drizzled_plugin_test_list}"
 
200
        pandora_plugin_test_list="%(testsuite)s,${pandora_plugin_test_list}"
172
201
    """ % plugin)
173
202
 
174
203
  plugin_ac.write("""
175
 
        drizzled_default_plugin_list="%(name)s,${drizzled_default_plugin_list}"
176
 
        drizzled_builtin_list="builtin_%(name)s_plugin,${drizzled_builtin_list}"
177
 
        drizzled_plugin_libs="${drizzled_plugin_libs} \${top_builddir}/plugin/lib%(name)s_plugin.la"
178
 
        DRIZZLED_PLUGIN_DEP_LIBS="${DRIZZLED_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
 
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"
179
208
      ])
180
209
""" % plugin)
181
 
 
 
210
 
182
211
plugin_ac.close()
183
212
plugin_am.close()
184
213
 
185
 
# We've written all of this out into .new files, now we only copy them
186
 
# over the old ones if they are different, so that we don't cause 
187
 
# unnecessary recompiles
188
 
for f in ('plugin.ac','plugin.am'):
189
 
  fname= os.path.join(top_builddir,'config',f)
190
 
  if os.system('diff %s.new %s >/dev/null 2>&1' % (fname,fname)):
191
 
    try:
192
 
      os.unlink(fname)
193
 
    except:
194
 
      pass
195
 
    os.rename('%s.new' % fname, fname)
196
 
  try:
197
 
    os.unlink("%s.new" % fname)
198
 
  except:
199
 
    pass