992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
1 |
#!/usr/bin/python
|
2 |
||
3 |
# Find plugins in the tree and add them to the build system
|
|
4 |
||
5 |
import os, ConfigParser, sys |
|
6 |
||
7 |
top_srcdir='.' |
|
8 |
top_builddir='.' |
|
9 |
plugin_ini_fname='plugin.ini' |
|
10 |
plugin_list=[] |
|
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
11 |
autogen_header="This file is generated, re-run %s to rebuild\n" % sys.argv[0] |
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
12 |
|
13 |
if len(sys.argv)>1: |
|
14 |
top_srcdir=sys.argv[1] |
|
15 |
top_builddir=top_srcdir |
|
16 |
if len(sys.argv)>2: |
|
17 |
top_builddir=sys.argv[2] |
|
18 |
||
19 |
plugin_ac=open(os.path.join(top_builddir,'config','plugin.ac.new'),'w') |
|
20 |
plugin_am=open(os.path.join(top_srcdir,'config','plugin.am.new'),'w') |
|
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
21 |
plugin_ac.write("dnl %s" % autogen_header) |
22 |
plugin_am.write("# %s" % autogen_header) |
|
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
23 |
|
24 |
def accumulate_plugins(arg, dirname, fnames): |
|
25 |
if plugin_ini_fname in fnames: |
|
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
26 |
arg.append(dirname) |
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
27 |
|
28 |
||
29 |
os.path.walk(top_srcdir,accumulate_plugins,plugin_list) |
|
30 |
||
31 |
for plugin_dir in plugin_list: |
|
32 |
plugin_file= os.path.join(plugin_dir,plugin_ini_fname) |
|
992.1.24
by Monty Taylor
Ported InnoDB to register_plugins. |
33 |
parser=ConfigParser.ConfigParser(defaults=dict(sources="",cflags="",cppflags="",cxxflags="", libs="", ldflags="")) |
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
34 |
parser.read(plugin_file) |
35 |
plugin=dict(parser.items('plugin')) |
|
992.1.22
by Monty Taylor
Moved towards having register_plugins.py make builtin plugins, so we can have a first step. |
36 |
plugin['rel_path']= plugin_dir[len(top_srcdir)+len(os.path.sep):] |
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
37 |
# TODO: determine path to plugin dir relative to top_srcdir... append it
|
38 |
# to source files if they don't already have it
|
|
39 |
new_sources="" |
|
40 |
for src in plugin['sources'].split(): |
|
992.1.22
by Monty Taylor
Moved towards having register_plugins.py make builtin plugins, so we can have a first step. |
41 |
if not src.startswith(plugin['rel_path']): |
992.1.24
by Monty Taylor
Ported InnoDB to register_plugins. |
42 |
src= os.path.join(plugin['rel_path'], src) |
43 |
new_sources= "%s %s" % (new_sources, src) |
|
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
44 |
plugin['sources']= new_sources |
45 |
||
46 |
if plugin.has_key('load_by_default'): |
|
47 |
plugin['load_by_default']=parser.getboolean('plugin','load_by_default') |
|
48 |
else: |
|
49 |
plugin['load_by_default']=False |
|
50 |
# Make a yes/no version for autoconf help messages
|
|
51 |
if plugin['load_by_default']: |
|
52 |
plugin['default_yesno']="yes" |
|
53 |
else: |
|
54 |
plugin['default_yesno']="no" |
|
55 |
||
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
56 |
plugin_ac_file=os.path.join(plugin['rel_path'],'plugin.ac') |
57 |
plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am') |
|
58 |
plugin_m4_dir=os.path.join(plugin['rel_path'],'m4') |
|
59 |
||
60 |
plugin_m4_files=[] |
|
61 |
if os.path.exists(plugin_m4_dir) and os.path.isdir(plugin_m4_dir): |
|
62 |
for m4_file in os.listdir(plugin_m4_dir): |
|
63 |
if os.path.splitext(m4_file)[-1] == '.m4': |
|
64 |
plugin_m4_files.append(os.path.join(plugin['rel_path'], m4_file)) |
|
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
65 |
|
66 |
plugin['build_conditional_tag']= "BUILD_%s_PLUGIN" % plugin['name'].upper() |
|
67 |
if plugin.has_key('build_conditional'): |
|
68 |
plugin['has_build_conditional']=True |
|
69 |
else: |
|
70 |
plugin['has_build_conditional']=False |
|
71 |
plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin |
|
72 |
||
992.1.22
by Monty Taylor
Moved towards having register_plugins.py make builtin plugins, so we can have a first step. |
73 |
# Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DDRIZZLE_DYNAMIC_PLUGIN %(cppflags)s
|
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
74 |
|
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
75 |
#
|
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
76 |
# Write plugin build instructions into plugin.am file.
|
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
77 |
#
|
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
78 |
plugin_am.write(""" |
992.1.22
by Monty Taylor
Moved towards having register_plugins.py make builtin plugins, so we can have a first step. |
79 |
plugin_lib%(name)s_dir=${top_srcdir}/%(rel_path)s |
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
80 |
if %(build_conditional_tag)s |
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
81 |
noinst_LTLIBRARIES+=plugin/lib%(name)s_plugin.la |
992.1.24
by Monty Taylor
Ported InnoDB to register_plugins. |
82 |
plugin_lib%(name)s_plugin_la_LIBADD=%(libs)s |
83 |
plugin_lib%(name)s_plugin_la_LDFLAGS=$(AM_LDFLAGS) %(ldflags)s |
|
992.1.22
by Monty Taylor
Moved towards having register_plugins.py make builtin plugins, so we can have a first step. |
84 |
plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) %(cppflags)s |
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
85 |
plugin_lib%(name)s_plugin_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s |
86 |
plugin_lib%(name)s_plugin_la_CFLAGS=$(AM_CFLAGS) %(cflags)s |
|
87 |
||
88 |
plugin_lib%(name)s_plugin_la_SOURCES=%(sources)s |
|
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
89 |
endif
|
90 |
""" % plugin) |
|
91 |
# Add this once we're actually doing dlopen (and remove -avoid-version if
|
|
92 |
# we move to ltdl
|
|
93 |
#pkgplugin_LTLIBRARIES+=plugin/lib%(name)s_plugin.la
|
|
992.1.24
by Monty Taylor
Ported InnoDB to register_plugins. |
94 |
#plugin_lib%(name)s_plugin_la_LDFLAGS=-module -avoid-version -rpath $(pkgplugindir) %(libs)s
|
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
95 |
# Add this and remove $drizzled_plugin_libs once drizzled is built from .
|
992.1.22
by Monty Taylor
Moved towards having register_plugins.py make builtin plugins, so we can have a first step. |
96 |
#drizzled_drizzled_LDADD+=${top_builddir}/plugin/lib%(name)s_plugin.la
|
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
97 |
|
98 |
if os.path.exists(plugin_am_file): |
|
99 |
plugin_am.write('include %s\n' % plugin_am_file) |
|
100 |
||
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
101 |
#
|
102 |
# Write plugin config instructions into plugin.am file.
|
|
103 |
#
|
|
104 |
plugin_ac.write("\n\ndnl Config for %(title)s\n" % plugin) |
|
105 |
for m4_file in plugin_m4_files: |
|
106 |
plugin_ac.write('m4_sinclude([%s])\n' % m4_file) |
|
107 |
||
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
108 |
plugin_ac.write(""" |
109 |
AC_ARG_WITH([plugin-%(name)s],[ |
|
110 |
dnl indented werid to make the help output correct
|
|
111 |
AS_HELP_STRING([--with-%(name)s-plugin],[Build %(title)s and enable it. @<:@default=%(default_yesno)s@:>@]) |
|
112 |
AS_HELP_STRING([--without-%(name)s-plugin],[Disable building %(title)s]) |
|
113 |
],
|
|
114 |
[with_%(name)s_plugin="$withval"], |
|
115 |
[AS_IF([test "x$ac_with_all_plugins" = "yes"],
|
|
116 |
[with_%(name)s_plugin=yes], |
|
117 |
[with_%(name)s_plugin=%(default_yesno)s])]) |
|
118 |
""" % plugin) |
|
119 |
if os.path.exists(plugin_ac_file): |
|
120 |
plugin_ac.write('m4_sinclude([%s])\n' % plugin_ac_file) |
|
121 |
# The plugin author has specified some check to make to determine
|
|
122 |
# if the plugin can be built. If the plugin is turned on and this
|
|
123 |
# check fails, then configure should error out. If the plugin is not
|
|
124 |
# turned on, then the normal conditional build stuff should just let
|
|
125 |
# it silently not build
|
|
126 |
if plugin['has_build_conditional']: |
|
127 |
plugin_ac.write(""" |
|
128 |
AS_IF([test "x$with_%(name)s_plugin" = "xyes" -a !%(build_conditional)s], |
|
129 |
[Build prerequisites not found for %(title)s, yet it was slated to be enabled by default. Aborting!])""" % plugin) |
|
130 |
plugin_ac.write(""" |
|
131 |
AM_CONDITIONAL([%(build_conditional_tag)s], |
|
132 |
[test %(build_conditional)s]) |
|
133 |
AS_IF([test "x$with_%(name)s_plugin" = "xyes"], |
|
992.1.22
by Monty Taylor
Moved towards having register_plugins.py make builtin plugins, so we can have a first step. |
134 |
[
|
135 |
drizzled_default_plugin_list="%(name)s,${drizzled_default_plugin_list}" |
|
136 |
drizzled_builtin_list="builtin_%(name)s_plugin,${drizzled_builtin_list}" |
|
992.1.23
by Monty Taylor
New system now runs in parallel to old system. |
137 |
drizzled_plugin_libs="${drizzled_plugin_libs} \${top_builddir}/plugin/lib%(name)s_plugin.la" |
992.1.24
by Monty Taylor
Ported InnoDB to register_plugins. |
138 |
DRIZZLED_PLUGIN_DEP_LIBS="${DRIZZLED_PLUGIN_DEP_LIBS} %(libs)s" |
992.1.22
by Monty Taylor
Moved towards having register_plugins.py make builtin plugins, so we can have a first step. |
139 |
])
|
992.1.21
by Monty Taylor
First pass at replacing plugin.m4. |
140 |
""" % plugin) |
141 |
||
142 |
plugin_ac.close() |
|
143 |
plugin_am.close() |
|
144 |
||
145 |
# We've written all of this out into .new files, now we only copy them
|
|
146 |
# over the old ones if they are different, so that we don't cause
|
|
147 |
# unnecessary recompiles
|
|
148 |
for f in ('plugin.ac','plugin.am'): |
|
149 |
fname= os.path.join(top_builddir,'config',f) |
|
150 |
if os.system('diff %s.new %s >/dev/null 2>&1' % (fname,fname)): |
|
151 |
try: |
|
152 |
os.unlink(fname) |
|
153 |
except: |
|
154 |
pass
|
|
155 |
os.rename('%s.new' % fname, fname) |
|
156 |
try: |
|
157 |
os.unlink("%s.new" % fname) |
|
158 |
except: |
|
159 |
pass
|