Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject a dependency on the usermod list #4622

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

willmmiles
Copy link
Member

@willmmiles willmmiles commented Mar 29, 2025

Write the current usermod list to a file, and add it as a dependency to the linked output file. This should hopefully overcome potential poisoning of SCons' build cache with incorrect matches.

Meant to fix #4597, though I haven't been able to reproduce it locally. I tested the dependency injection by disabling the overwite code and manually editing the usermods list file.

Summary by CodeRabbit

  • New Features
    • Introduced an automated post-processing step in the build process that improves how custom modifications are tracked and integrated.
    • Ensured that dependency updates are applied reliably, enhancing overall build consistency and correctness.

Write the current usermod list to a file, and add it as a dependency to
the linked output file.  This should hopefully overcome potential
poisoning of SCons' build cache with incorrect matches.

Meant to fix wled#4597
Copy link

coderabbitai bot commented Mar 29, 2025

Walkthrough

This change introduces a new script, add_usermod_dep.py, that enhances the SCons build system by accurately tracking and updating usermod dependencies. The script writes a usermod list file and enforces a dependency on it for the final program link, triggering rebuilds when changes occur. Additionally, the platformio.ini file is updated to include the new script as a post-processing step in the extra_scripts section, ensuring usermods are correctly recognized and compiled.

Changes

Files Change Summary
pio-scripts/add_usermod_dep.py, platformio.ini Introduced a new script to track and update usermod dependencies and trigger rebuilds; updated config to run this script post-build.

Assessment against linked issues

Objective Addressed Explanation
Include custom usermods in firmware and trigger rebuild on config changes (#4597)

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e76e9a3 and e2f80cb.

📒 Files selected for processing (2)
  • pio-scripts/add_usermod_dep.py (1 hunks)
  • platformio.ini (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
pio-scripts/add_usermod_dep.py

8-8: Undefined name Import

(F821)


12-12: Undefined name env

(F821)


12-12: Undefined name env

(F821)


13-13: Undefined name env

(F821)


25-25: Undefined name env

(F821)


25-25: Undefined name env

(F821)

⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_160)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_160)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_160)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full)
  • GitHub Check: wled_build / Build Environments (esp8266_2m)
  • GitHub Check: wled_build / Build Environments (nodemcuv2)
🔇 Additional comments (5)
platformio.ini (1)

118-118: Effective dependency management enhancement.

The added line correctly integrates the new script as a post-processing step in the build process. This change addresses issue #4597 by ensuring that usermod dependencies are properly tracked, preventing SCons cache poisoning issues.

pio-scripts/add_usermod_dep.py (4)

1-7: Well-documented script purpose.

The comments clearly explain the issue being addressed and the solution approach. This is excellent documentation that will help future maintainers understand why this script exists.


8-15: Good environment setup and path handling.

The script correctly imports the SCons environment and uses pathlib for cross-platform path handling. The construction of file paths using the environment variables ensures compatibility with any PlatformIO setup.

Note: The static analysis hints flagging undefined names like Import and env can be safely ignored as these are provided by the SCons build system, not standard Python.

🧰 Tools
🪛 Ruff (0.8.2)

8-8: Undefined name Import

(F821)


12-12: Undefined name env

(F821)


12-12: Undefined name env

(F821)


13-13: Undefined name env

(F821)


16-23: Efficient file update mechanism.

The implementation efficiently handles file I/O by:

  1. Only opening the file once with "a+" mode (append and read)
  2. Only writing when content has changed
  3. Properly handling file truncation and pointer position

This approach minimizes unnecessary writes and rebuilds.


24-25: Critical dependency declaration.

This line is the key to solving the issue - it creates a dependency relationship between the final program and the usermod list file. This ensures that changes in the usermod list will properly trigger rebuilds of the final program.

🧰 Tools
🪛 Ruff (0.8.2)

25-25: Undefined name env

(F821)


25-25: Undefined name env

(F821)

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Compiling does not include usermods
1 participant