summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-08-29 02:12:27 +0000
committerDavid Robillard <d@drobilla.net>2015-08-29 02:12:27 +0000
commit9e346cb4e4fc4bd4fc25115be9fad111ec326ae8 (patch)
tree55f43d6604846bc12378a5df333e36f55e9b88b6 /src
parentd3768319106a5cf7824579ec3bf9ff1776c09383 (diff)
downloadingen-9e346cb4e4fc4bd4fc25115be9fad111ec326ae8.tar.gz
ingen-9e346cb4e4fc4bd4fc25115be9fad111ec326ae8.tar.bz2
ingen-9e346cb4e4fc4bd4fc25115be9fad111ec326ae8.zip
Save plugin version information in bundles.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5710 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/Serialiser.cpp54
-rw-r--r--src/server/LV2Plugin.cpp23
2 files changed, 73 insertions, 4 deletions
diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp
index 79660fa6..30c58163 100644
--- a/src/Serialiser.cpp
+++ b/src/Serialiser.cpp
@@ -19,6 +19,7 @@
#include <cassert>
#include <cstdlib>
+#include <set>
#include <string>
#include <utility>
@@ -69,8 +70,8 @@ struct Serialiser::Impl {
void start_to_filename(const std::string& filename);
- void serialise_graph(SPtr<const Node> p,
- const Sord::Node& id);
+ std::set<const Resource*> serialise_graph(SPtr<const Node> p,
+ const Sord::Node& id);
void serialise_block(SPtr<const Node> n,
const Sord::Node& class_id,
@@ -92,6 +93,9 @@ struct Serialiser::Impl {
SPtr<const Node> graph,
const std::string& graph_symbol);
+ void write_plugins(const std::string& bundle_path,
+ const std::set<const Resource*> plugins);
+
void serialise_arc(const Sord::Node& parent,
SPtr<const Arc> a)
throw (std::logic_error);
@@ -148,6 +152,38 @@ Serialiser::Impl::write_manifest(const std::string& bundle_path,
}
void
+Serialiser::Impl::write_plugins(const std::string& bundle_path,
+ const std::set<const Resource*> plugins)
+{
+ const string plugins_path(Glib::build_filename(bundle_path, "plugins.ttl"));
+
+ start_to_filename(plugins_path);
+
+ Sord::World& world = _model->world();
+ const URIs& uris = _world.uris();
+
+ for (const auto& p : plugins) {
+ const Atom& minor = p->get_property(uris.lv2_minorVersion);
+ const Atom& micro = p->get_property(uris.lv2_microVersion);
+
+ _model->add_statement(Sord::URI(world, p->uri()),
+ Sord::URI(world, uris.rdf_type),
+ Sord::URI(world, uris.lv2_Plugin));
+
+ if (minor.is_valid() && micro.is_valid()) {
+ _model->add_statement(Sord::URI(world, p->uri()),
+ Sord::URI(world, uris.lv2_minorVersion),
+ Sord::Literal::integer(world, minor.get<int32_t>()));
+ _model->add_statement(Sord::URI(world, p->uri()),
+ Sord::URI(world, uris.lv2_microVersion),
+ Sord::Literal::integer(world, micro.get<int32_t>()));
+ }
+ }
+
+ finish();
+}
+
+void
Serialiser::write_bundle(SPtr<const Node> graph,
const std::string& path)
{
@@ -179,11 +215,15 @@ Serialiser::Impl::write_bundle(SPtr<const Node> graph,
start_to_filename(root_file);
const Raul::Path old_root_path = _root_path;
_root_path = graph->path();
- serialise_graph(graph, Sord::URI(_model->world(), root_file, _base_uri));
+
+ std::set<const Resource*> plugins = serialise_graph(
+ graph, Sord::URI(_model->world(), root_file, _base_uri));
+
_root_path = old_root_path;
finish();
write_manifest(path, graph, symbol);
+ write_plugins(path, plugins);
}
/** Begin a serialization to a file.
@@ -278,7 +318,7 @@ Serialiser::serialise(SPtr<const Node> object) throw (std::logic_error)
}
}
-void
+std::set<const Resource*>
Serialiser::Impl::serialise_graph(SPtr<const Node> graph,
const Sord::Node& graph_id)
{
@@ -312,6 +352,8 @@ Serialiser::Impl::serialise_graph(SPtr<const Node> graph,
const Node::Properties props = graph->properties(Resource::Graph::INTERNAL);
serialise_properties(graph_id, props);
+ std::set<const Resource*> plugins;
+
const Store::const_range kids = _world.store()->children_range(graph);
for (Store::const_iterator n = kids.first; n != kids.second; ++n) {
if (n->first.parent() != graph->path())
@@ -359,6 +401,8 @@ Serialiser::Impl::serialise_graph(SPtr<const Node> graph,
Sord::URI(world, uris.ingen_block),
block_id);
serialise_block(block, class_id, block_id);
+
+ plugins.insert(block->plugin());
}
}
@@ -380,6 +424,8 @@ Serialiser::Impl::serialise_graph(SPtr<const Node> graph,
for (const auto& a : graph->arcs()) {
serialise_arc(graph_id, a.second);
}
+
+ return plugins;
}
void
diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp
index 3dc87030..ddc80f70 100644
--- a/src/server/LV2Plugin.cpp
+++ b/src/server/LV2Plugin.cpp
@@ -38,6 +38,29 @@ LV2Plugin::LV2Plugin(World* world, const LilvPlugin* lplugin)
, _lilv_plugin(lplugin)
{
set_property(_uris.rdf_type, _uris.lv2_Plugin);
+
+ LilvNode* minor = lilv_world_get(world->lilv_world(),
+ lilv_plugin_get_uri(lplugin),
+ _uris.lv2_minorVersion,
+ NULL);
+ LilvNode* micro = lilv_world_get(world->lilv_world(),
+ lilv_plugin_get_uri(lplugin),
+ _uris.lv2_minorVersion,
+ NULL);
+
+ if (lilv_node_is_int(minor) && lilv_node_is_int(micro)) {
+ fprintf(stderr, "%s version %d.%d\n",
+ lilv_node_as_uri(lilv_plugin_get_uri(lplugin)),
+ lilv_node_as_int(minor),
+ lilv_node_as_int(micro));
+ set_property(_uris.lv2_minorVersion,
+ world->forge().make(lilv_node_as_int(minor)));
+ set_property(_uris.lv2_microVersion,
+ world->forge().make(lilv_node_as_int(micro)));
+ }
+
+ lilv_node_free(minor);
+ lilv_node_free(micro);
}
const Raul::Symbol