# HG changeset patch # User Chris Cannam # Date 1497344804 -3600 # Node ID 5ba2749f202476ee220aeaed522fcabbc533d4ac # Parent 903f217e0ca77af6a900f25e723e74544f31d7c2 Avoid emitting duplicate plugins (where duplicate libraries are installed) diff -r 903f217e0ca7 -r 5ba2749f2024 vamp-stubber/stubber.cpp --- a/vamp-stubber/stubber.cpp Tue Jun 13 10:06:36 2017 +0100 +++ b/vamp-stubber/stubber.cpp Tue Jun 13 10:06:44 2017 +0100 @@ -175,10 +175,21 @@ "static std::string soname(\"" << soname << "\");\n" "\n"; - bool first = true; + // The same plugin key may appear more than once in the available + // list, if the same plugin is installed in more than one location + // on the Vamp path. To avoid emitting its wrapper definition + // multiple times, we need to keep a record of which ones we've + // emitted for each stage + set emitted; for (const auto &plugin: resp.available) { - PlausibleMetadata pm = inventPlausibleMetadata(plugin.pluginKey); + + string key = plugin.pluginKey; + if (emitted.find(key) != emitted.end()) { + continue; + } + + PlausibleMetadata pm = inventPlausibleMetadata(key); cout << "static PiperAdapter<" << pm.className << "> // replace with the actual Vamp plugin class name for \"" @@ -186,7 +197,7 @@ << "(\n soname,\n "; string catString = "{ "; - first = true; + bool first = true; for (auto c: plugin.category) { if (!first) catString += ", "; catString += "\"" + c + "\""; @@ -210,17 +221,24 @@ } cout << "\n }\n"; cout << " );\n\n"; + emitted.insert(key); } cout << "static PiperPluginLibrary library({\n "; - first = true; + emitted.clear(); for (const auto &plugin: resp.available) { - PlausibleMetadata pm = inventPlausibleMetadata(plugin.pluginKey); - if (!first) { + + string key = plugin.pluginKey; + if (emitted.find(key) != emitted.end()) { + continue; + } + + PlausibleMetadata pm = inventPlausibleMetadata(key); + if (!emitted.empty()) { cout << ",\n "; } cout << "&" << pm.adapterName; - first = false; + emitted.insert(key); } cout << "\n});\n\n"; cout << "PIPER_EXPORT_LIBRARY(library);\n" << endl;