Ryan/feat/srlow - #5
Conversation
Also factored out find_repo_root to be used by both srbuild and srlow
…e for srlow analyse
… some godforsaken reason
There was a problem hiding this comment.
🟡 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
commandstakesinstall, andprojects'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
--presetoption. The parser makes--presetmandatory foranalyse 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 buildprovidescompile_commands.json, but this build path never enablesCMAKE_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:
dirctoryshould bedirectory.
# - 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 enableCMAKE_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.txtexamples describe MISRA-C analysis of.cfiles, but the Understand database is created with only thec++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 custombinaryDiris incorrectly reported as not built and skipped. The analysis path should use the actual binary directory and itscompile_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, ifunddisappears after the license check),resultis never assigned; after thefinallyblock line 206 raisesUnboundLocalErrorinstead of returning a module failure. Catch launch errors and returnResult.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 issuingcreatefor 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.
| for module in (repo_root/SRC_DIR).iterdir(): | ||
| if not module.is_dir(): | ||
| continue |
| check=True | ||
| ) | ||
| subprocess.run( | ||
| ["cmake", "--install", f"./build/{preset}", "--prefix", str(repo_root / INSTALL_FOLDER_NAME)], |
There was a problem hiding this comment.
This is fine, it's a CubeMx presets.json thing and will always be the same unless we change it
| if safe_rmdir(build_dir): | ||
| num_pass.append(module.name) | ||
| else: | ||
| num_fail.append(module.name) |
| # ================================================================================================= | ||
| # MAIN | ||
| # ================================================================================================= | ||
| def main() -> int: |
SR-Dev-Tools v3.0.0