Skip to content

Commit

Permalink
Improved regexp for GHDL version, backend, etc..
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Jul 30, 2024
1 parent b024448 commit a8493e1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pyEDAA/CLITool/GHDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ class GHDLVersion(metaclass=ExtendedType, slots=True):
r"(?:Community\s(?P<Year>\d{4})\s\((?P<DateCode>\d{8}-\d{2})\))"
r")"
)
BACKEND_LINE_PATTERN = r"\s*(?P<Backend>\w+)\scode\sgenerator"
BACKEND_LINE_PATTERN = (
r"\s*"
r"(?:static elaboration, )?"
r"(?P<Backend>llvm|mcode|gcc)"
r"(?: (?P<LLVMMajor>\d+)\.(?P<LLVMMinor>\d+)\.(?P<LLVMMicro>\d+))?"
r"(?: JIT)?"
r" code generator"
)

def __init__(self, versionLine: str, gnatLine: str, backendLine: str):
match = re_search("^" + self.VERSION_LINE_PATTERN + "$", versionLine)
Expand All @@ -105,7 +112,7 @@ def __init__(self, versionLine: str, gnatLine: str, backendLine: str):
self._dirty = "Dirty" in match.groups()
self._edition = match["Edition"]

match = re_search("^" + self.GNAT_LINE_PATTERN + "$", versionLine)
match = re_search("^" + self.GNAT_LINE_PATTERN + "$", gnatLine)
if match is None:
raise CLIToolException(f"Unknown second GHDL version string '{gnatLine}'.")

Expand All @@ -114,7 +121,7 @@ def __init__(self, versionLine: str, gnatLine: str, backendLine: str):
else:
self._gnatCompiler = (int(match["Year"]), 0, 0)

match = re_search("^" + self.BACKEND_LINE_PATTERN + "$", versionLine)
match = re_search("^" + self.BACKEND_LINE_PATTERN + "$", backendLine)
if match is None:
raise CLIToolException(f"Unknown third GHDL version string '{backendLine}'.")

Expand Down

0 comments on commit a8493e1

Please sign in to comment.