Skip to content

feat: report EDA tool version from a dedicated version query - #242

Open
hcallahan-lowrisc wants to merge 1 commit into
lowRISC:masterfrom
hcallahan-lowrisc:report_tool_version
Open

feat: report EDA tool version from a dedicated version query#242
hcallahan-lowrisc wants to merge 1 commit into
lowRISC:masterfrom
hcallahan-lowrisc:report_tool_version

Conversation

@hcallahan-lowrisc

@hcallahan-lowrisc hcallahan-lowrisc commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

Replace the hardcoded "unknown" tool version in reports with a value probed from the tool at runtime. Each SimTool plugin declares a VersionQuery (command + regex) as data, and a single generic runner executes it, so adding a tool needs no new logic. Any failure falls back to "unknown".

A tool version is now printed inside the final report badge. E.g.
image

Checklist

  • All commits are signed off (git commit -s), indicating acceptance of the CLA
  • Commit messages follow the conventional commit format (<type>[(<scope>)][!]: <description>)
    • The commit type correctly reflects the semver impact of the change
    • Breaking changes are marked with ! or a BREAKING CHANGE: footer
  • New behaviour is covered by tests

Replace the hardcoded "unknown" tool version in reports with a value
probed from the tool at runtime. Each SimTool plugin declares a
VersionQuery (command + regex) as data, and a single generic runner
executes it, so adding a tool needs no new logic. Any failure falls back
to "unknown".

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
@hcallahan-lowrisc hcallahan-lowrisc added the enhancement New feature or request label Aug 17, 2026

@rswarbrick rswarbrick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really sensible to me. Lots of nitty comments (sorry), but it looks good.

Comment on lines +26 to +29
cmd: the command that makes the tool print its version.
pattern: a regex applied (in multiline mode) to the combined
stdout/stderr of ``cmd``. The first capture group is used as the
version string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a Python expert, but I'm slightly surprised by this. Is there a reason not to use this text to decorate the fields, rather than as a string at the top?

Comment thread src/dvsim/sim/tool/vcs.py
class VCS:
"""Implement VCS tool support."""

# `vcs -id` reports a line like: "Compiler version = VCS X-2025.06-SP2-1_Full64".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably either explain the 64 bit thing, or give "vcs -full64 -id" in the string here.

Comment thread src/dvsim/sim/tool/vcs.py
# `vcs -id` reports a line like: "Compiler version = VCS X-2025.06-SP2-1_Full64".
version_query: ClassVar[VersionQuery | None] = VersionQuery(
cmd="vcs -full64 -id",
pattern=r"^Compiler version\s*=\s*(?:VCS\s+)?(\S+)",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it that some versions don't include "VCS"? Maybe this needs a comment explaining why the extra group is here.

Alternatively, would something like this work?

^Compiler version\s*=.*\s([^ ]+)$

# `xrun -version` reports a line like: "TOOL: xrun(64) 24.03-s007".
version_query: ClassVar[VersionQuery | None] = VersionQuery(
cmd="xrun -version",
pattern=r"^TOOL:\s*xrun\(\d+\)\s+(\S+)",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the VCS example, I'd suggest being floppier. How about something like this?

^TOOL:.*xrun.*\s([^ ]+)$

Comment thread src/dvsim/sim/flow.py
revision_info=self.revision,
)
tool = ToolMeta(name=self.tool.lower(), version="unknown")
tool = ToolMeta(name=self.tool.lower(), version=query_tool_version(self.tool) or "unknown")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be split over 2 lines to avoid falsy strings with "is None".

Comment thread src/dvsim/tool/utils.py
"z01x": Z01X,
}

# EDA tools should respond to a `--version`-style query near-instantly, but guard

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that it doesn't sound like "EDA tools should do X but might guard Y", I'd suggest splitting the string. "... query near-instantly. This timeout is just to ensure that a hung/misconfigured tool can't block things forever."

Comment thread src/dvsim/tool/utils.py
"""
try:
result = subprocess.run( # noqa: S603
shlex.split(cmd),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd to me. Since subprocess.run will do the splitting, there's no reason to do it ourselves - things are already globbed together, so we don't know any more than the library code.

Comment thread src/dvsim/tool/utils.py
log.debug("Failed to query tool version via '%s': %s", cmd, e)
return None

return result.stdout + result.stderr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: If the order doesn't matter, I'd suggest doing them the other way round (because the result is more like what normally happens on the terminal)

Comment thread src/dvsim/tool/utils.py
log.debug("Could not parse %s version from output of '%s'", tool, query.cmd)
return None

return match.group(1).strip()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but does it make sense to catch IndexErrors here and spit out an explicit error to make it easier to write the EDA backend? Or is this just "the author should read the docs..."? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants