Closed zhajio1988 closed 7 months ago
The expectation is that the path
provided by the user to the header generator will already include the file extension since that is the fully defined file path. It would be inappropriate for the tool to implicitly append an additional suffix.
None of the other PeakRDL tools do this, so I would not want to create an inconsistency here.
See the example here: https://peakrdl-cheader.readthedocs.io/en/latest/api.html The output path is provided with the extension:
exporter.export(node=top, path='out.h')
The expectation is that the
path
provided by the user to the header generator will already include the file extension since that is the fully defined file path. It would be inappropriate for the tool to implicitly append an additional suffix. None of the other PeakRDL tools do this, so I would not want to create an inconsistency here.See the example here: https://peakrdl-cheader.readthedocs.io/en/latest/api.html The output path is provided with the extension:
exporter.export(node=top, path='out.h')
Hi Thanks for you replay. If path='out.h', the generated test file name is out.h.test.c? Is it correct?
No not at all.
if path="out.h"
then the resulting file will be out.h
.
PeakRDL-cheader will never mangle or change the file path a user provides it.
@amykyta3 I find blow code snippets, testcase_path = header_path + ".test.c" TestcaseGenerator is called in exporter.py, TestcaseGenerator(ds).run(path, top_nodes) The path argument is from CHeaderExporter path formal argument.
class TestcaseGenerator:
def __init__(self, ds: DesignState) -> None:
self.ds = ds
def run(self, header_path: str, top_nodes: List[AddrmapNode]) -> None:
testcase_path = header_path + ".test.c"
with open(testcase_path, "w", encoding='utf-8') as f:
Yes that is because the testcase directly correlates with the user-generated header, and is an optional output. For primary outputs, it would be surprising behavior to append ".c" unconditionally.
See other command line tools like gcc ... -o output_file
Ok, got it. I think we can close this ticket.
@amykyta3 I use new C header generator, i find C header generate file doesn't have suffix,i modify below code, text in bold. Could you help make sure it? ` class HeaderGenerator(RDLListener): def init(self, ds: DesignState) -> None: self.ds = ds
`