Move generated error map to cpp file
This commit changes the generation location of error map
from a header file (.hpp) to a source file (.cpp).
This change enhances code organization, separates
declaration from implementation.
In an upcoming change, retaining the map in the header
file results in a duplicate definition error.
Therefore, to avoid these errors and ensure smooth future
updates, the error map needs to be generated in the
.cpp file.
Tests:
Created error log dumps by commiting InternalFailure
Change-Id: I01e4503e24ebf9045793014060107cca4ff440ad
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/errors_map_gen.py b/errors_map_gen.py
index a7fac0d..9fafae9 100755
--- a/errors_map_gen.py
+++ b/errors_map_gen.py
@@ -19,15 +19,23 @@
default="errors_watch.yaml",
help="input errors watch yaml file to parse",
)
+
+ parser.add_argument(
+ "-c",
+ "--cpp_file",
+ dest="cpp_file",
+ default="errors_map.cpp",
+ help="output cpp file",
+ )
args = parser.parse_args()
with open(os.path.join(script_dir, args.errors_map_yaml), "r") as fd:
yamlDict = yaml.safe_load(fd)
- # Render the mako template
- template = os.path.join(script_dir, "errors_map.mako.hpp")
+ # Render the mako template for cpp file
+ template = os.path.join(script_dir, "errors_map.mako.cpp")
t = Template(filename=template)
- with open("errors_map.hpp", "w") as fd:
+ with open(args.cpp_file, "w") as fd:
fd.write(t.render(errDict=yamlDict))