85
87
"""Return True if the plugin had changed."""
86
88
plugin = read_plugin_ini(plugin_dir)
87
89
expand_plugin_ini(plugin, plugin_dir)
88
plugin_file = ChangeProtectedFile(os.path.join(plugin_dir, 'pandora-plugin.ac'))
89
write_plugin_ac(plugin, plugin_file)
90
result = plugin_file.close()
91
plugin_file = ChangeProtectedFile(os.path.join(plugin_dir, 'pandora-plugin.am'))
92
write_plugin_am(plugin, plugin_file)
93
result = plugin_file.close() or result
90
write_plugin_ac(plugin, plugin_ac_file)
91
write_plugin_am(plugin, plugin_am_file)
96
93
def write_plugin_ac(plugin, plugin_ac):
240
237
# The .plugin.ini.stamp avoids changing the datestamp on plugin.ini which can
241
238
# confuse VCS systems.
242
plugin_am.write("""## Generated by register_plugins.py
243
EXTRA_DIST += %(rel_path)s/pandora-plugin.ac %(rel_path)s/.plugin.ini.stamp
245
${top_srcdir}/%(rel_path)s/pandora-plugin.am: ${top_srcdir}/config/register_plugins.py %(rel_path)s/.plugin.ini.stamp
247
${top_srcdir}/%(rel_path)s/pandora-plugin.ac: ${top_srcdir}/config/register_plugins.py %(rel_path)s/.plugin.ini.stamp
249
configure: ${top_srcdir}/%(rel_path)s/pandora-plugin.ac
240
EXTRA_DIST += %(rel_path)s/plugin.ini
251
242
# Prevent errors when a plugin dir is removed
252
243
%(rel_path)s/plugin.ini:
254
# Failures to update the plugin.ini are ignored to permit plugins to be deleted
256
%(rel_path)s/.plugin.ini.stamp: %(rel_path)s/plugin.ini
257
@if [ ! -e ${top_srcdir}/%(rel_path)s/plugin.ini ]; then \\
258
echo "%(rel_path)s/plugin.ini is missing"; \\
261
if [ $$? -ne 0 ]; then \\
262
echo 'cd ${srcdir} && python config/register_plugins.py . . %(rel_path)s'; \\
263
unchanged=`cd ${srcdir} && python config/register_plugins.py . . %(rel_path)s` ;\\
264
if [ $$? -ne 0 ]; then \\
265
echo "**** register_plugins failed ****"; \\
268
for plugin_dir in $$unchanged; do \\
269
echo "plugin $$plugin_dir unchanged." ; \\
270
touch -f -r ${top_srcdir}/$$plugin_dir/pandora-plugin.am $$plugin_dir/.plugin.ini.stamp; \\
272
cp $< $@ || echo "Failed to update $@"; \\
276
245
if plugin['headers'] != "":
277
246
plugin_am.write("noinst_HEADERS += %(headers)s\n" % plugin)
278
247
if plugin['testsuite']:
315
284
if os.path.exists(plugin_am_file):
316
285
plugin_am.write('include %s\n' % plugin_am_file)
319
top_srcdir=sys.argv[1]
320
top_builddir=sys.argv[2]
322
if not os.path.exists("config/plugin.list") or (len(sys.argv)==2 and sys.argv[1]=='plugin.list'):
323
os.system("find plugin -name 'plugin.ini' | xargs -n1 dirname | xargs -n1 basename | sort -b -d > .plugin.scan")
324
os.system("cp .plugin.scan config/plugin.list")
327
if len(sys.argv)>2 or (len(sys.argv)==2 and sys.argv[1]=='plugin-stamp'):
329
plugin_list = [top_srcdir + '/' + plugin_name for plugin_name in sys.argv[3:]]
291
if arg.startswith('--top_srcdir='):
293
elif arg.startswith('--top_builddir='):
294
top_builddir=arg[14:]
295
elif arg == "--force-all":
296
actions=['plugin-list','pandora-plugin.am','write']
331
def accumulate_plugins(arg, dirname, fnames):
332
# plugin_ini_fname is a name in dirname indicating dirname is a plugin.
333
if plugin_ini_fname in fnames:
335
os.path.walk(os.path.join(top_srcdir,"plugin"),accumulate_plugins,plugin_list)
300
if len(actions) == 0:
301
actions.append('write')
303
def accumulate_plugins(arg, dirname, fnames):
304
# plugin_ini_fname is a name in dirname indicating dirname is a plugin.
305
if plugin_ini_fname in fnames:
307
os.path.walk(os.path.join(top_srcdir,"plugin"),accumulate_plugins,plugin_list)
310
if not os.path.exists("config/pandora-plugin.am") or "write" in actions:
311
plugin_am_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.am'))
312
plugin_am_file.write("""
313
# always the current list, generated every build so keep this lean.
314
# plugin.list: datestamp preserved list
315
${srcdir}/config/plugin.list: .plugin.scan
317
@cd ${top_srcdir} && python config/register_plugins.py plugin-list
319
# Plugins affect configure; so to prevent configure running twice in a tarball
320
# build (once up front, once with the right list of plugins, we ship the
321
# generated list of plugins and the housekeeping material for that list so it
322
# is likewise not updated.
324
config/pandora-plugin.am \
325
config/pandora-plugin.ac \
326
config/register_plugins.py
329
# Seed the list of plugin LDADDS which plugins may extend.
330
PANDORA_DYNAMIC_LDADDS=
332
# plugin.stamp: graph dominator for creating all per pandora-plugin.ac/am
333
# files. This is invoked when the code to generate such files has altered.""")
335
if not os.path.exists("config/pandora-plugin.ac") or "write" in actions:
336
plugin_ac_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.ac'))
337
plugin_ac_file.write("dnl Generated file, run make to rebuild\n")
337
340
if os.path.exists('plugin.ini'):
338
341
# Are we in a plugin dir which wants to have a self-sufficient build system?
339
343
write_external_plugin()
345
plugin_list_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.list'))
346
for p in plugin_list:
347
plugin_list_file.write(p)
348
plugin_list_file.write("\n")
341
349
plugin_list.sort()
342
for plugin_dir in plugin_list:
343
if not write_plugin(plugin_dir):
344
if not (len(sys.argv)==2 and sys.argv[1]=='plugin-stamp'):
347
if not os.path.exists("config/plugin-list.am") or (len(sys.argv)==2 and sys.argv[1]=='plugin-list.am'):
348
os.system(r"sed 's,^\(.*\)$,include plugin/\1/pandora-plugin.am,' < config/plugin.list > config/plugin-list.am")
350
if not os.path.exists("config/plugin-list.ac") or (len(sys.argv)==2 and sys.argv[1]=='plugin-list.ac'):
351
os.system(r"sed 's,^\(.*\)$,m4_sinclude(plugin/\1/pandora-plugin.ac),' < config/plugin.list > config/plugin-list.ac")
350
plugin_list_file.close()
352
if not os.path.exists("config/pandora-plugin.am") or 'write' in actions:
353
plugin_am_file.write("\nconfig/pandora-plugin.am: ${top_srcdir}/config/plugin.list ${top_srcdir}/config/register_plugins.py ")
354
for plugin_dir in plugin_list:
355
plugin_am_file.write("\\\n\t%s/plugin.ini " % plugin_dir)
356
plugin_am_file.write("\n\tcd ${top_srcdir} && python config/register_plugins.py write\n")
357
for plugin_dir in plugin_list:
358
write_plugin(plugin_dir)
360
if plugin_am_file is not None:
361
plugin_am_file.close()
362
if plugin_ac_file is not None:
363
plugin_ac_file.close()