Introduce PLUGIN_VARIANT #40
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We need a way to run multiple Edge Impulse models in the same GStreamer pipeline, but the plugin can only be loaded once per process. This is annoying when you want to compare models or run different configurations side-by-side.
So I added a
PLUGIN_VARIANTenvironment variable that lets you build multiple variants of the plugin. Each one gets unique names for everything: the library file, plugin name, element names, and GObject types. That way they can all coexist without stepping on each other.The tricky part was that GStreamer derives the plugin registration function name from the library filename, and Cargo doesn't let us change the output library name dynamically. So we generate the plugin definition code in
build.rsbased on the variant, and then rename the library after build with a simple script. We also generate unique GObject type names to avoid the "type already registered" panic you'd get otherwise.Usage is pretty straightforward: