Skip to content

add HybridCompile sdkconfig file to hash#446

Merged
Jason2866 merged 2 commits into
developfrom
hy_file_mtime
Mar 28, 2026
Merged

add HybridCompile sdkconfig file to hash#446
Jason2866 merged 2 commits into
developfrom
hy_file_mtime

Conversation

@Jason2866
Copy link
Copy Markdown

@Jason2866 Jason2866 commented Mar 28, 2026

Description:

Related issue (if applicable): fixes #441

Checklist:

  • The pull request is done against the latest develop branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR, more changes are allowed when changing boards.json
  • I accept the CLA

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection for custom SDK configuration files that reference local external files: referenced paths are now resolved relative to the project when needed, modification times are considered, and missing files are ignored without causing failures.
    • Prevented constructing SDK include paths when framework library directories are unavailable, avoiding spurious rebuilds.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 30a2c668-211f-423b-b0d7-cbc72a06e30d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Both builder/frameworks/arduino.py and builder/frameworks/espidf.py now extract the modification time of referenced files in custom_sdkconfig entries containing file:// paths. This file mtime is prepended to the configuration content for checksum computation, ensuring hash changes when referenced files are modified.

Changes

Cohort / File(s) Summary
Arduino Framework
builder/frameworks/arduino.py
Reads modification time from first file:// reference in custom_sdkconfig and prepends it to entry_custom_sdkconfig for hashing. Silently ignores file access errors (OSError). This mtime-augmented value flows into existing matching_custom_sdkconfig() and reinstall detection logic.
ESP-IDF Framework
builder/frameworks/espidf.py
Derives checksum input from modification time of referenced local file:// entry in custom_sdkconfig (resolved relative to PROJECT_DIR when not absolute). Prepends file mtime to original content before hashing. Falls back to raw content if file lookup fails or no file:// reference is found.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A file changed, but hashes stayed the same—
Poor builders never knew the truth!
Now mtimes whisper their tale,
Hash mismatches bloom, rebuilds reign—
The cache lies no longer! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: including sdkconfig file modification time in the hash for detecting configuration changes.
Linked Issues check ✅ Passed The code changes directly address all primary objectives from issue #441: resolving file:// references and including file contents (via mtime) in hash computation for both arduino.py and espidf.py.
Out of Scope Changes check ✅ Passed All changes are scoped to the specific objective of fixing custom_sdkconfig hash computation by including file modification times; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hy_file_mtime

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Jason2866
Copy link
Copy Markdown
Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
builder/frameworks/arduino.py (1)

76-80: ⚠️ Potential issue | 🟠 Major

PathCache.sdk_dir can still crash when framework libs are missing.

At Line 76-Line 80, Path(self.framework_lib_dir) is evaluated even when framework_lib_dir is None, which raises before downstream guards run.

Suggested fix
 `@property`
 def sdk_dir(self):
     if self._sdk_dir is None:
+        if not self.framework_lib_dir:
+            return None
         self._sdk_dir = fs.to_unix_path(
             str(Path(self.framework_lib_dir) / self.chip_variant / "include")
         )
     return self._sdk_dir
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@builder/frameworks/arduino.py` around lines 76 - 80, The sdk_dir property
(def sdk_dir(self)) can throw when self.framework_lib_dir is None because
Path(self.framework_lib_dir) is evaluated unguarded; update sdk_dir to first
check if self.framework_lib_dir is truthy before constructing
Path/self.chip_variant (e.g., if self._sdk_dir is None: if not
self.framework_lib_dir: return None or leave self._sdk_dir as None; otherwise
compute fs.to_unix_path(str(Path(self.framework_lib_dir) / self.chip_variant /
"include"))). Ensure you only call Path(...) and fs.to_unix_path when
framework_lib_dir is present and preserve existing memoization using
self._sdk_dir.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@builder/frameworks/arduino.py`:
- Around line 280-293: The current loop over entry_custom_sdkconfig only handles
the first "file://" entry and prepends its mtime, which misses additional
references and doesn't use file content for robust invalidation; update the loop
that processes entry_custom_sdkconfig (the block referencing
entry_custom_sdkconfig, project_dir, isabs, file_ref, file_path) to iterate all
lines, for every line starting with "file://" resolve file_path, attempt to open
and read the file content (fall back to mtime if reading fails), and incorporate
each file's content (or its mtime) into the value used for hash computation
(e.g., prepend/append each file's data to entry_custom_sdkconfig) while removing
the stray break and preserving OSError handling so missing/unreadable files
don’t crash the flow.

In `@builder/frameworks/espidf.py`:
- Around line 782-799: The checksum input currently only captures the first
file:// entry mtime; update the logic around
env.GetProjectOption("custom_sdkconfig") and the loop over raw.splitlines() so
that you resolve every file:// reference (not just the first), read each
referenced file’s contents and/or mtime, and include those resolved
contents/mtimes in custom_sdk_config_flags before appending the raw option;
ensure you iterate all entries, resolve relative paths against PROJECT_DIR,
handle OSError for missing files (skip but continue), and concatenate all
resolved file information plus the original raw text (using the existing
raw.rstrip("\n") + "\n" pattern) so changes to any referenced file invalidate
the cache.

---

Outside diff comments:
In `@builder/frameworks/arduino.py`:
- Around line 76-80: The sdk_dir property (def sdk_dir(self)) can throw when
self.framework_lib_dir is None because Path(self.framework_lib_dir) is evaluated
unguarded; update sdk_dir to first check if self.framework_lib_dir is truthy
before constructing Path/self.chip_variant (e.g., if self._sdk_dir is None: if
not self.framework_lib_dir: return None or leave self._sdk_dir as None;
otherwise compute fs.to_unix_path(str(Path(self.framework_lib_dir) /
self.chip_variant / "include"))). Ensure you only call Path(...) and
fs.to_unix_path when framework_lib_dir is present and preserve existing
memoization using self._sdk_dir.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e616bbec-aaf5-481b-b93d-b30bfba59557

📥 Commits

Reviewing files that changed from the base of the PR and between bdaf722 and a36ba76.

📒 Files selected for processing (2)
  • builder/frameworks/arduino.py
  • builder/frameworks/espidf.py

Comment thread builder/frameworks/arduino.py
Comment thread builder/frameworks/espidf.py
@Jason2866 Jason2866 merged commit b800765 into develop Mar 28, 2026
1 check passed
@Jason2866 Jason2866 deleted the hy_file_mtime branch March 28, 2026 21:36
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.

1 participant