Skip to content

Ryan/feat/srlow - #5

Merged
ryan-wong157 merged 31 commits into
mainfrom
ryan/feat/srlow
Sep 21, 2026
Merged

ryan-wong157 merged 31 commits into
mainfrom
ryan/feat/srlow

Conversation

@ryan-wong157

Copy link
Copy Markdown
Member

SR-Dev-Tools v3.0.0

  1. Added srlow. CLI helper for SR-Amsvartnir
  2. It can build, test and analyse (using Understand). Has some requirements mentioned in the README

Also factored out find_repo_root to be used by both srbuild and srlow

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved correctness, safety, documentation, and lockfile consistency issues remain.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds the srlow CLI for firmware build, test, clean, and Understand analysis workflows.

Changes:

  • Adds and documents srlow.
  • Refactors shared CLI helpers.
  • Updates packaging, lockfile, and integration-test expectations.
File summaries
File Summary
uv.lock Updates locked package metadata.
tests/test_srbuild_integration.py Adjusts error-output assertions.
src/sr_dev_tools/srlow.py Implements low-level firmware tooling.
src/sr_dev_tools/srbuild.py Uses shared helpers and formatted output.
src/sr_dev_tools/common_helpers.py Adds shared utility functions.
README.md Documents srlow usage and setup.
pyproject.toml Registers the CLI and updates version metadata.
Review details

Suppressed comments (9)

README.md:183

  • This sentence has two grammatical errors: plural commands takes install, and projects' should be singular possessive because each module has one project. Please correct the documentation so the installation instructions are clear.
All `srlow build...` commands also installs generated binaries into a repo root `deploy/module_name/` directory. In each STM32 projects' CMakeLists.txt, the following addition is required:

README.md:222

  • This example omits the required --preset option. The parser makes --preset mandatory for analyse target, so copying this command exits with an argparse error; include a preset in the example.
srlow analyse target my_project

README.md:170

  • The README says running srlow build provides compile_commands.json, but this build path never enables CMAKE_EXPORT_COMPILE_COMMANDS. A module whose preset does not set that option can build successfully and still fail during analysis; state the preset requirement or have the build configure it.
Runs Scitools Understand `codecheck` (MISRA-C 2025) on each module. Requires `und` to be installed and licensed, a `misra-c2025.json` config file at the repo root, and a `compile_commands.json`. This can easily be gotten by running srlow build.

src/sr_dev_tools/srlow.py:8

  • There is a spelling error in this newly added header comment: dirctory should be directory.
#   - Then installs each module's binary into a root "deploy" dirctory

src/sr_dev_tools/srlow.py:89

  • The analysis path unconditionally consumes build/{preset}/compile_commands.json, but this configure command does not enable CMAKE_EXPORT_COMPILE_COMMANDS; a normal preset therefore completes the build without producing the file and the documented build-then-analyse workflow fails. Enable export here or require every preset to set it.
            ["cmake", "--preset", preset],

src/sr_dev_tools/srlow.py:176

  • The README and analyse.txt examples describe MISRA-C analysis of .c files, but the Understand database is created with only the c++ language. Those C sources will not be configured for the advertised MISRA-C analysis; create the database with the C language (or explicitly include both if C++ is also required).
        ("create",   ["und", "-db", db, "create", "-languages", "c++"]),

src/sr_dev_tools/srlow.py:170

  • Analysis repeats the same fixed build/{preset} assumption, so a module built with a valid custom binaryDir is incorrectly reported as not built and skipped. The analysis path should use the actual binary directory and its compile_commands.json, or the preset layout must be made an explicit requirement.
    if not (module_root/"build"/preset).is_dir():
        logger.warning(f"Preset: {preset} was not found in {module_root}/build/")
        return Result.SKIP

src/sr_dev_tools/srlow.py:191

  • If launching the CodeCheck subprocess raises an OSError (for example, if und disappears after the license check), result is never assigned; after the finally block line 206 raises UnboundLocalError instead of returning a module failure. Catch launch errors and return Result.FAIL.
        result = subprocess.run(

src/sr_dev_tools/srlow.py:176

  • The database path is deterministic and is never removed by srlow build clean, but every analysis starts by issuing create for that same path. After the first analysis, a subsequent analysis therefore attempts to create an existing database and fails instead of being rerunnable; reuse/reset the database or include it in the cleanup lifecycle.
        ("create",   ["und", "-db", db, "create", "-languages", "c++"]),
  • Files reviewed: 6/7 changed files
  • Comments generated: 9
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/sr_dev_tools/srlow.py
Comment on lines +316 to +318
for module in (repo_root/SRC_DIR).iterdir():
if not module.is_dir():
continue
Comment thread src/sr_dev_tools/srlow.py
check=True
)
subprocess.run(
["cmake", "--install", f"./build/{preset}", "--prefix", str(repo_root / INSTALL_FOLDER_NAME)],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is fine, it's a CubeMx presets.json thing and will always be the same unless we change it

Comment thread src/sr_dev_tools/srlow.py Outdated
Comment thread src/sr_dev_tools/srlow.py
if safe_rmdir(build_dir):
num_pass.append(module.name)
else:
num_fail.append(module.name)
Comment thread README.md Outdated
Comment thread src/sr_dev_tools/srlow.py Outdated
Comment thread src/sr_dev_tools/srlow.py Outdated
Comment thread src/sr_dev_tools/srlow.py Outdated
Comment thread src/sr_dev_tools/srlow.py
# =================================================================================================
# MAIN
# =================================================================================================
def main() -> int:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ceebs rn

@ryan-wong157
ryan-wong157 merged commit bed886b into main Sep 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants