Add argument for errors.hpp to pdmgen.py, fix race
pdmgen.py is now given a "-e" argument to specify where to write
errors.hpp.
Previously it was hardcoded to 'errors.hpp', this could
hit a race where the src/test run of pdmgen.py could overwrite
the actual errors.hpp with an empty file.
That resulted in missing definitions with a compile error such as
...phosphor-dbus-monitor/1.0+gitAUTOINC+413a485715-r1/recipe-sysroot/usr/include/c++/12.1.0/type_traits:1447:38: error: invalid use of incomplete type 'struct sdbusplus::xyz::openbmc_project::Sensor::Threshold::Error::CriticalHigh'
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
Change-Id: Ib982631e506ade18c587a3e6552e4109760758ef
diff --git a/src/pdmgen.py b/src/pdmgen.py
index 925dd21..ea7cd13 100755
--- a/src/pdmgen.py
+++ b/src/pdmgen.py
@@ -926,7 +926,7 @@
super(Elog, self).__init__(**kw)
def construct(self, loader, indent):
- with open('errors.hpp', 'a') as fd:
+ with open(args.gen_errors, 'a') as fd:
fd.write(
self.render(
loader,
@@ -976,7 +976,7 @@
super(ElogWithMetadata, self).__init__(**kw)
def construct(self, loader, indent):
- with open('errors.hpp', 'a') as fd:
+ with open(args.gen_errors, 'a') as fd:
fd.write(
self.render(
loader,
@@ -1347,7 +1347,7 @@
def generate_cpp(self, loader):
'''Render the template with the provided data.'''
# errors.hpp is used by generated.hpp to included any error.hpp files
- open('errors.hpp', 'w+')
+ open(args.gen_errors, 'w+')
with open(args.output, 'w') as fd:
fd.write(
@@ -1395,6 +1395,10 @@
default='generated.mako.hpp',
help='The top level template to render.')
parser.add_argument(
+ '-e', '--errors', dest='gen_errors',
+ default='errors.hpp',
+ help='Generated errors.hpp output filename.')
+ parser.add_argument(
'-p', '--template-path', dest='template_search',
default=script_dir,
help='The space delimited mako template search path.')