depot_query: 'binary' and 'config' as attributes

By specifying the 'config' of a '<runtime>' as an attribute, we can
distinguish the case where the config is obtained from a ROM session
from the case where the config is specified inline as a '<config>' node.
This commit is contained in:
Norman Feske 2018-01-19 13:30:42 +01:00
parent 506bc023b7
commit 5641ebcd1b
3 changed files with 26 additions and 11 deletions

View File

@ -36,6 +36,7 @@ struct Depot_deploy::Main
typedef String<128> Name;
typedef String<80> Binary;
typedef String<80> Config;
/**
* Generate start node of init configuration
@ -73,8 +74,8 @@ struct Depot_deploy::Main
Xml_node const runtime = pkg.sub_node("runtime");
if (!runtime.has_sub_node("binary")) {
warning("<runtime> node for '", name, "' lacks <binary> node");
if (!runtime.has_attribute("binary")) {
warning("<runtime> node for '", name, "' lacks 'binary' attribute");
return;
}
@ -105,7 +106,8 @@ void Depot_deploy::Main::_gen_start_node(Xml_generator &xml, Xml_node pkg, Xml_n
Xml_node const runtime = pkg.sub_node("runtime");
size_t const caps = runtime.attribute_value("caps", 0UL);
Number_of_bytes const ram = runtime.attribute_value("ram", Number_of_bytes());
Binary const binary = runtime.sub_node("binary").attribute_value("name", Binary());
Binary const binary = runtime.attribute_value("binary", Binary());
Config const config = runtime.attribute_value("config", Config());
xml.attribute("name", name);
xml.attribute("caps", caps);
@ -123,12 +125,24 @@ void Depot_deploy::Main::_gen_start_node(Xml_generator &xml, Xml_node pkg, Xml_n
if (runtime.has_sub_node("config")) {
Xml_node config = runtime.sub_node("config");
xml.node("config", [&] () {
xml.append(config.content_base(), config.content_size());
});
xml.append(config.content_base(), config.content_size()); });
};
xml.node("route", [&] () {
/*
* Redirect config ROM request to label given in the 'config'
* attribute.
*/
if (config.valid()) {
xml.node("service", [&] () {
xml.attribute("name", "ROM");
xml.attribute("label", "config");
xml.node("parent", [&] () {
xml.attribute("label", config); });
});
}
/*
* Add ROM routing rule with the label rewritten to
* the path within the depot.
@ -147,8 +161,7 @@ void Depot_deploy::Main::_gen_start_node(Xml_generator &xml, Xml_node pkg, Xml_n
xml.attribute("name", "ROM");
xml.attribute("label", label);
xml.node("parent", [&] () {
xml.attribute("label", path);
});
xml.attribute("label", path); });
});
});

View File

@ -344,13 +344,17 @@ void Depot_query::Main::_query_blueprint(Directory::Path const &pkg_path, Xml_ge
xml.attribute("name", Archive::name(pkg_path));
xml.attribute("path", pkg_path);
Rom_label const config = node.attribute_value("config", Rom_label());
if (config.valid())
xml.attribute("config", config);
Xml_node env_xml = _config.xml().has_sub_node("env")
? _config.xml().sub_node("env") : "<env/>";
node.for_each_sub_node([&] (Xml_node node) {
/* skip non-rom nodes */
if (!node.has_type("rom") && !node.has_type("binary"))
if (!node.has_type("rom"))
return;
Rom_label const label = node.attribute_value("label", Rom_label());

View File

@ -1,9 +1,7 @@
<runtime ram="32M" caps="1000">
<runtime ram="32M" caps="1000" binary="init">
<timer/>
<binary name="init"/>
<rom label="ld.lib.so"/>
<rom label="ram_fs"/>
<rom label="fs_report"/>