-
Notifications
You must be signed in to change notification settings - Fork 44
Add espressif esp-idf-size to the build engine to show firmware metrics #178
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
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant BuildSystem
participant PythonDeps
participant Linker
participant MetricsTool
User->>BuildSystem: Start ESP-IDF build
BuildSystem->>PythonDeps: Ensure required packages (incl. esp-idf-size)
BuildSystem->>Linker: Build firmware (with SHOW_METRICS flag)
Linker->>BuildSystem: Generate .map file if SHOW_METRICS is set
BuildSystem->>MetricsTool: Run esp-idf-size on .map file (post-build)
MetricsTool->>BuildSystem: Output firmware size metrics
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
builder/main.py (1)
361-376
: Well-implemented firmware metrics functionThe
firmware_metrics
function is well implemented with proper file existence checks and error handling. It attempts to locate the map file in either the build directory or project directory before running the metrics tool.One small suggestion: consider adding a log message when an exception occurs to help with debugging in case the metrics functionality fails.
except Exception: + print("Warning: Failed to run firmware metrics. Is esp-idf-size installed?") pass
builder/frameworks/espidf.py (1)
1792-1810
: Well-structured refactoring to support metrics feature.The CMake arguments construction has been refactored into a list for better organization and to support conditional flags. The new code checks for the
SHOW_METRICS
define and appropriately adds the map file generation linker flag when needed.However, I notice a potential optimization opportunity with the map file path definition:
# At the beginning of the file map_file = os.path.join(env.subst("$PROJECT_DIR"), env.subst("$PROGNAME") + ".map") # ... if "CPPDEFINES" in env: flatten_cppdefines = env.Flatten(env['CPPDEFINES']) if "SHOW_METRICS" in flatten_cppdefines: - # This will add the linker flag for the map file - extra_cmake_args.append( - f'-DCMAKE_EXE_LINKER_FLAGS=-Wl,-Map={os.path.join(BUILD_DIR, env.subst("$PROGNAME") + ".map")}' - ) + # Use the same map file path defined earlier + extra_cmake_args.append( + f'-DCMAKE_EXE_LINKER_FLAGS=-Wl,-Map={os.path.join(BUILD_DIR, env.subst("$PROGNAME") + ".map")}' + )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (5)
builder/frameworks/arduino.py
(1 hunks)builder/frameworks/espidf.py
(3 hunks)builder/main.py
(6 hunks)examples/espidf-blink/platformio.ini
(3 hunks)examples/espidf-coap-server/platformio.ini
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: build (macos-15, examples/espidf-ulp-lp)
- GitHub Check: build (macos-15, examples/arduino-zigbee-switch)
- GitHub Check: build (macos-15, examples/espidf-hello-world)
- GitHub Check: build (macos-15, examples/espidf-arduino-blink)
- GitHub Check: build (windows-latest, examples/espidf-coap-server)
- GitHub Check: build (windows-latest, examples/espidf-ulp-riscv)
- GitHub Check: build (windows-latest, examples/espidf-blink)
- GitHub Check: build (windows-latest, examples/espidf-arduino-blink)
- GitHub Check: build (windows-latest, examples/arduino-NimBLE-ext_client)
- GitHub Check: build (windows-latest, examples/tasmota)
- GitHub Check: build (windows-latest, examples/arduino-wifiscan)
- GitHub Check: build (windows-latest, examples/arduino-blink)
🔇 Additional comments (9)
builder/frameworks/arduino.py (1)
106-108
: New dependency added correctlyThe addition of the
esp-idf-size
Python package dependency looks good. This aligns with the PR objective to show firmware metrics.examples/espidf-blink/platformio.ini (1)
20-20
: SHOW_METRICS flag added to enable firmware size reportingGood addition of the
SHOW_METRICS
flag to all environments. This preprocessor definition enables the map file generation required for the firmware size metrics feature.Also applies to: 31-31, 42-42
examples/espidf-coap-server/platformio.ini (1)
21-22
: SHOW_METRICS flag added correctlyGood addition of the
build_flags
section with theSHOW_METRICS
flag to enable firmware size reporting for this example too.builder/main.py (3)
24-26
: New imports added for firmware metrics functionalityThe new imports are correctly added to support the firmware metrics functionality.
229-229
: Added support for esp32c5 MCUGood addition of "esp32c5" to the MCU lists for both toolchain architecture and GDB tool selection.
Also applies to: 250-250
391-393
: Clean integration as a silent post-build actionGood approach to add the firmware metrics as a silent post-build action to avoid cluttering the output. The hack to silence the scons command output works well.
builder/frameworks/espidf.py (3)
59-63
: Good preparation for the metrics feature.The code properly removes any existing map file in the project root before building, ensuring clean metrics generation when the feature is enabled.
91-92
: Added necessary dependencies for metrics feature.The addition of
esp-idf-size
as a dependency is required for the new firmware metrics functionality, and the PyYAML version has been appropriately updated.
1815-1815
: Completed the refactoring.The changes correctly pass the constructed
extra_cmake_args
list to theget_cmake_code_model
function, completing the argument refactoring.
Awesome!, I will test this today 😄 |
Description:
The needed map file for this is default generated in Arduino projects. Only for espidf projects
SHOW_METRICS
needs to be added to thebuild_flags
to generate the needed map file. Like thisbuild_flags = -D SHOW_METRICS
@h2zero please test, ping me on Discord for questions or suggestions
Checklist:
Summary by CodeRabbit
New Features
Configuration
Chores