feat(builder): add per-MCU CMSIS PAL + CMSIS-Core to include path#11
feat(builder): add per-MCU CMSIS PAL + CMSIS-Core to include path#11phatpaul wants to merge 1 commit into
Conversation
The PlatformIO Arduino builder only put the core dir and the selected board-pins variant (variants/<build.variant>) on CPPPATH. But the vendor CMSIS device header (e.g. LPC845.h) is a chip-level artifact that lives in variants/<build.mcu>/, which for most boards is a *different* directory than the pins variant (board lpc845brk selects variants/lpc845brk/, while the PAL ships in variants/lpc845/). As a result, code that includes the vendor device header (<LPC845.h>) failed with "No such file or directory", and the transitively-included CMSIS-Core headers (core_cm0plus.h, cmsis_gcc.h) — which live at the framework root in CMSIS/ — were also missing. Add variants/<build.mcu>/ and CMSIS/ to CPPPATH when they exist, so any board on a given MCU can consume the vendor device header regardless of which pins variant it selects. Both additions are guarded by os.path.isdir and the MCU dir is skipped when it coincides with the selected variant, so boards/frameworks without this layout are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis change adds CMSIS include-path resolution to the Arduino framework builder. New variables (MCU, CMSIS_DIR, CMSIS_CORE_DIR) are derived from board.get("build.mcu") and FRAMEWORK_DIR, then conditionally appended to the CPPPATH list used during compilation. ChangesCMSIS Include Path Resolution
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
builder/frameworks/arduino.py (1)
67-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMisleading variable names:
CMSIS_DIR/CMSIS_CORE_DIRdon't match their content.
CMSIS_DIRactually resolves tovariants/<mcu>/(the chip-level device-PAL directory), whileCMSIS_CORE_DIRresolves to the framework-rootCMSIS/directory. The naming is swapped relative to what each path represents — a reader expectingCMSIS_DIRto point at theCMSIS/folder (as the PR description implies) will be confused.♻️ Suggested rename
MCU = board.get("build.mcu", "") -CMSIS_DIR = os.path.join(FRAMEWORK_DIR, "variants", MCU) if MCU else "" -CMSIS_CORE_DIR = os.path.join(FRAMEWORK_DIR, "CMSIS") +MCU_DIR = os.path.join(FRAMEWORK_DIR, "variants", MCU) if MCU else "" +CMSIS_DIR = os.path.join(FRAMEWORK_DIR, "CMSIS")(and update the two usages at lines 119-123 accordingly)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@builder/frameworks/arduino.py` around lines 67 - 70, The path variable names in arduino.py are misleading because CMSIS_DIR points to variants/<mcu> while CMSIS_CORE_DIR points to the framework CMSIS folder. Rename these locals in the module-level setup so each name matches its actual path, and update the two references in the later install/copy logic that consume CMSIS_DIR and CMSIS_CORE_DIR. Use the surrounding symbols MCU, FRAMEWORK_DIR, and the related path-handling block to locate the rename consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@builder/frameworks/arduino.py`:
- Around line 67-70: The path variable names in arduino.py are misleading
because CMSIS_DIR points to variants/<mcu> while CMSIS_CORE_DIR points to the
framework CMSIS folder. Rename these locals in the module-level setup so each
name matches its actual path, and update the two references in the later
install/copy logic that consume CMSIS_DIR and CMSIS_CORE_DIR. Use the
surrounding symbols MCU, FRAMEWORK_DIR, and the related path-handling block to
locate the rename consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9bf0a7d0-4f86-4e04-967d-73e71860bd13
📒 Files selected for processing (1)
builder/frameworks/arduino.py
The PlatformIO Arduino builder only put the core dir and the selected board-pins variant (variants/<build.variant>) on CPPPATH. But the vendor CMSIS device header (e.g. LPC845.h) is a chip-level artifact that lives in variants/<build.mcu>/, which for most boards is a different directory than the pins variant (board lpc845brk selects variants/lpc845brk/, while the PAL ships in variants/lpc845/). As a result, code that includes the vendor device header (<LPC845.h>) failed with "No such file or directory", and the transitively-included CMSIS-Core headers (core_cm0plus.h, cmsis_gcc.h) — which live at the framework root in CMSIS/ — were also missing.
Add variants/<build.mcu>/ and CMSIS/ to CPPPATH when they exist, so any board on a given MCU can consume the vendor device header regardless of which pins variant it selects. Both additions are guarded by os.path.isdir and the MCU dir is skipped when it coincides with the selected variant, so boards/frameworks without this layout are unaffected.
Summary by CodeRabbit