Create the generated FRU Map in cpp.
Change-Id: Id83220e5e2876f4112ba76d698b2062e2a08dd3d
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/scripts/fru_gen.py b/scripts/fru_gen.py
index aca86e8..2771498 100755
--- a/scripts/fru_gen.py
+++ b/scripts/fru_gen.py
@@ -7,7 +7,7 @@
from mako.template import Template
-def generate_hpp(inventory_yaml, output_dir):
+def generate_cpp(inventory_yaml, output_dir):
with open(os.path.join(script_dir, inventory_yaml), 'r') as f:
ifile = yaml.safe_load(f)
if not isinstance(ifile, dict):
@@ -17,9 +17,9 @@
t = Template(filename=os.path.join(
script_dir,
- "writefru.mako.hpp"))
+ "writefru.mako.cpp"))
- output_hpp = os.path.join(output_dir, "fru-gen.hpp")
+ output_hpp = os.path.join(output_dir, "fru-gen.cpp")
with open(output_hpp, 'w') as fd:
fd.write(t.render(fruDict=ifile))
@@ -27,7 +27,7 @@
def main():
valid_commands = {
- 'generate-hpp': generate_hpp
+ 'generate-cpp': generate_cpp
}
parser = argparse.ArgumentParser(
description="IPMI FRU parser and code generator")
diff --git a/scripts/writefru.mako.cpp b/scripts/writefru.mako.cpp
new file mode 100644
index 0000000..7573862
--- /dev/null
+++ b/scripts/writefru.mako.cpp
@@ -0,0 +1,28 @@
+// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
+#include <iostream>
+#include "frup.hpp"
+
+extern const FruMap frus = {
+% for key in fruDict.iterkeys():
+ {${key},{
+<%
+ fru = fruDict[key]
+%>
+ % for object,interfaces in fru.iteritems():
+ {"${object}",{
+ % for interface,properties in interfaces.iteritems():
+ {"${interface}",{
+ % for dbus_property,property_value in properties.iteritems():
+ {"${dbus_property}",{
+ % for name,value in property_value.iteritems():
+ {"${name}","${value}"},
+ % endfor
+ }},
+ % endfor
+ }},
+ % endfor
+ }},
+ % endfor
+ }},
+% endfor
+};
diff --git a/scripts/writefru.mako.hpp b/scripts/writefru.mako.hpp
deleted file mode 100644
index a5c2f24..0000000
--- a/scripts/writefru.mako.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
-#pragma once
-
-#include <iostream>
-
-#include <string>
-#include <list>
-#include <map>
-
-using IPMIFruMetadata = std::string;
-using IPMIFruMetadataValue = std::string;
-using IPMIFruMap = std::map<IPMIFruMetadata,IPMIFruMetadataValue>;
-
-using DbusProperty = std::string;
-using DbusPropertyMap = std::map<DbusProperty,IPMIFruMap>;
-
-using DbusInterface = std::string;
-using DbusInterfaceMap = std::map<DbusInterface,DbusPropertyMap>;
-
-using FruInstancePath = std::string;
-using FruInstanceMap = std::map<FruInstancePath,DbusInterfaceMap>;
-
-using FruId = uint32_t;
-using FruMap = std::map<FruId,FruInstanceMap>;
-
-
-const FruMap frus = {
-% for key in fruDict.iterkeys():
- {${key},{
-<%
- fru = fruDict[key]
-%>
- % for object,interfaces in fru.iteritems():
- {"${object}",{
- % for interface,properties in interfaces.iteritems():
- {"${interface}",{
- % for dbus_property,property_value in properties.iteritems():
- {"${dbus_property}",{
- % for name,value in property_value.iteritems():
- {"${name}","${value}"},
- % endfor
- }},
- % endfor
- }},
- % endfor
- }},
- % endfor
- }},
-% endfor
-};