rom_filter: optionally skip top-level node

Since the top-level node of the output ROM is always generated by the
rom_filter, there is no way to pass-through the content of an input ROM
without wrapping in an addition XML node.

genodelabs/genode#4326
This commit is contained in:
Johannes Schlatow 2021-11-16 15:42:39 +01:00 committed by Christian Helmuth
parent 059c7ed74a
commit a65807ff08
3 changed files with 13 additions and 5 deletions

View File

@ -40,7 +40,8 @@ The '<output>' node can contain the following sub nodes:
:'<input>':
Copies the content of the input specified by the 'name' attribute to the
output node.
output node. If the optional attribute 'skip_toplevel' is set and evaluates
to true, the top-level XML node from the input will not be copied.
:'<attribute>':
Adds an attribute with the specified 'name' and 'value'. If the node

View File

@ -434,14 +434,18 @@ class Rom_filter::Input_rom_registry
*
* \throw Nonexistent_input_node
*/
void gen_xml(Input_name const &input_name, Genode::Xml_generator &xml)
void gen_xml(Input_name const &input_name, Genode::Xml_generator &xml, bool skip_toplevel=false)
{
Entry const *e = _lookup_entry_by_name(input_name);
if (!e)
throw Nonexistent_input_node();
e->node().with_raw_node([&] (char const *start, Genode::size_t length) {
xml.append(start, length); });
if (skip_toplevel)
e->node().with_raw_content([&] (char const *start, Genode::size_t length) {
xml.append(start, length); });
else
e->node().with_raw_node([&] (char const *start, Genode::size_t length) {
xml.append(start, length); });
}
};

View File

@ -350,8 +350,11 @@ void Rom_filter::Main::_evaluate_node(Xml_node node, Xml_generator &xml)
Input_name const input_name =
node.attribute_value("name", Input_name());
bool const skip_toplevel =
node.attribute_value("skip_toplevel", false);
try {
_input_rom_registry.gen_xml(input_name, xml); }
_input_rom_registry.gen_xml(input_name, xml, skip_toplevel); }
catch (...) { }
}
};