idf-eclipse-plugin icon indicating copy to clipboard operation
idf-eclipse-plugin copied to clipboard

WIP: IEP-1247 Run CMake initial build for newly created project(idf.py reconfigure)

Open sigmaaa opened this issue 1 year ago • 1 comments

Description

Please include a summary of the change and which issue is fixed.

Fixes # (IEP-XXX)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows,Linux and macOS):

Dependent components impacted by this PR:

  • Component 1
  • Component 2

Checklist

  • [ ] PR Self Reviewed
  • [ ] Applied Code formatting
  • [ ] Added Documentation
  • [ ] Added Unit Test
  • [ ] Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • New Features

    • Enhanced project wizard with asynchronous reconfiguration for the IoT Development Framework.
    • Real-time feedback displayed in a console during project setup.
    • Improved cross-platform compatibility for Python executable detection.
  • Bug Fixes

    • Implemented process status checks and logging for potential issues during command execution.

sigmaaa avatar Sep 16 '24 16:09 sigmaaa

[!CAUTION]

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request primarily focus on enhancing the functionality of the com.espressif.idf.core bundle and its associated classes. Key modifications include the addition of a new package to the MANIFEST.MF file, improvements in environment variable handling within the ProcessBuilderFactory and IDFConsoleLauncherDelegate classes, and the introduction of two new utility classes: ConsoleManager and IdfCommandExecutor. Additionally, the UI components have been updated to support new commands and messaging for project creation and reconfiguration.

Changes

Files Change Summary
bundles/com.espressif.idf.core/META-INF/MANIFEST.MF - Added org.eclipse.ui.console to Import-Package.
bundles/com.espressif.idf.core/src/com/espressif/idf/core/ProcessBuilderFactory.java - Modified run method to remove "Path" from environment variables.
- Removed commented-out line in runInBackground method.
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ConsoleManager.java - Added new utility class ConsoleManager with methods to manage console instances.
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IdfCommandExecutor.java - Added new class IdfCommandExecutor for executing IDF commands with methods for handling processes.
bundles/com.espressif.idf.terminal.connector/src/com/espressif/idf/terminal/connector/launcher/IDFConsoleLauncherDelegate.java - Updated environment variable handling logic, particularly for PATH.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/Messages.java - Added new variable IdfReconfigureJobName and made formatting adjustments.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java - Added fields for IProject and MessageConsole, and integrated IdfCommandExecutor in performFinish.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/messages.properties - Added entry for IdfReconfigureJobName and updated existing message formatting.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/templates/Messages.java - Added new variable RunIdfCommandButtonTxt for localized message management.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/templates/NewProjectCreationWizardPage.java - Added checkbox for reconfigure command execution and related methods.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/templates/messages.properties - Added entry for RunIdfCommandButtonTxt related to project creation.
bundles/com.espressif.idf.ui/plugin.xml - Added command com.espressif.idf.ui.reconfigure and handler IdfReconfigureHandler.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/IdfReconfigureHandler.java - Introduced handler for IDF reconfiguration with methods for command execution and workspace management.
bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFEnvironmentVariables.java - Added constant IDF_CCACHE_ENABLE and adjusted formatting for readability.

Possibly related PRs

  • #973: The changes in MANIFEST.MF include modifications to the Require-Bundle section, which is related to the addition of the org.eclipse.ui.console package in the main PR.
  • #961: The changes in ProcessBuilderFactory.java involve modifications to environment variable handling, which may relate to the overall management of console output and processes, similar to the changes made in the main PR.
  • #964: The updates in IDFBuildConfiguration.java include handling of environment variables, which connects to the changes in the main PR regarding the management of console instances and output.
  • #979: The modifications in IDFConsoleLauncherDelegate.java involve changes to environment variable handling, specifically the PATH variable, which is relevant to the main PR's updates.
  • #1022: The addition of the CLANG_FORMAT_FILE constant in this PR is relevant as it relates to the overall management of Clang configurations, which is a theme present in the main PR's updates to the MANIFEST.MF and other files.

Suggested reviewers

  • kolipakakondal
  • sigmaaa

Poem

In the wizard's realm, a change so bright,
Commands now run, bringing delight.
Python paths found, consoles aglow,
As projects take shape, watch them grow!
Hopping with joy, our code takes flight,
Thanks to these changes, all feels right! 🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5e9d471ac2cff9c201aa58517cd8858e6ef14e38 and 422cb581d455a1d7b265c979a29a2cb7d6b0f39a.

📒 Files selected for processing (14)
  • bundles/com.espressif.idf.core/META-INF/MANIFEST.MF (1 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFEnvironmentVariables.java (4 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/ProcessBuilderFactory.java (2 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ConsoleManager.java (1 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IdfCommandExecutor.java (1 hunks)
  • bundles/com.espressif.idf.terminal.connector/src/com/espressif/idf/terminal/connector/launcher/IDFConsoleLauncherDelegate.java (1 hunks)
  • bundles/com.espressif.idf.ui/plugin.xml (2 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/IdfReconfigureHandler.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/templates/Messages.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/templates/NewProjectCreationWizardPage.java (12 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/templates/messages.properties (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/Messages.java (2 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java (6 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/messages.properties (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

coderabbitai[bot] avatar Sep 16 '24 16:09 coderabbitai[bot]

@alirana01 @kolipakakondal hi guys! please, review.

AndriiFilippov avatar Nov 13 '24 07:11 AndriiFilippov

@sigmaaa hi ! Tested under: OS - Windows 11 ESP-IDF: v5.3.1

got this error during tool installation:

Successfully installed annotated-types-0.7.0 bitarray-2.9.3 bitstring-4.2.3 certifi-2024.8.30 cffi-1.17.1 charset-normalizer-3.4.0 click-8.1.7 colorama-0.4.6 construct-2.10.70 cryptography-42.0.8 ecdsa-0.19.0 esp-coredump-1.12.0 esp-idf-kconfig-2.3.0 esp-idf-monitor-1.5.0 esp-idf-nvs-partition-gen-0.1.6 esp-idf-panic-decoder-1.2.1 esp-idf-size-1.6.1 esptool-4.8.1 freertos_gdb-1.0.3 idf-component-manager-2.0.4 idna-3.10 intelhex-2.3.0 jsonref-1.1.0 markdown-it-py-3.0.0 mdurl-0.1.2 packaging-24.2 pyclang-0.5.0 pycparser-2.22 pydantic-2.9.2 pydantic-core-2.23.4 pydantic-settings-2.6.1 pyelftools-0.31 pygdbmi-0.11.0.0 pygments-2.18.0 pyparsing-3.2.0 pyserial-3.5 python-dotenv-1.0.1 pyyaml-6.0.2 reedsolo-1.7.0 requests-2.32.3 requests-file-2.1.0 requests-toolbelt-1.0.0 rich-13.9.4 six-1.16.0 tqdm-4.67.0 typing-extensions-4.12.2 urllib3-1.26.20 windows-curses-2.4.0

Executing C:\Python311\python.exe C:\Users\AndriiFilippov\e\esp-idf-v5.3.1\tools\idf_tools.py export --format=key-value
Traceback (most recent call last):
  File "C:\Users\AndriiFilippov\e\esp-idf-v5.3.1\tools\idf_tools.py", line 3239, in <module>
    main(sys.argv[1:])
  File "C:\Users\AndriiFilippov\e\esp-idf-v5.3.1\tools\idf_tools.py", line 3231, in main
    action_func(args)
  File "C:\Users\AndriiFilippov\e\esp-idf-v5.3.1\tools\idf_tools.py", line 2211, in action_export
    paths_to_check = rf'{export_vars["PATH"]}{os.environ["PATH"]}'
                                              ~~~~~~~~~~^^^^^^^^
  File "<frozen os>", line 678, in __getitem__
KeyError: 'PATH'

image

AndriiFilippov avatar Nov 18 '24 09:11 AndriiFilippov

@sigmaaa hi ! Tested under: OS - Windows 11 ESP-IDF: v5.3.1

got this error during tool installation:

Successfully installed annotated-types-0.7.0 bitarray-2.9.3 bitstring-4.2.3 certifi-2024.8.30 cffi-1.17.1 charset-normalizer-3.4.0 click-8.1.7 colorama-0.4.6 construct-2.10.70 cryptography-42.0.8 ecdsa-0.19.0 esp-coredump-1.12.0 esp-idf-kconfig-2.3.0 esp-idf-monitor-1.5.0 esp-idf-nvs-partition-gen-0.1.6 esp-idf-panic-decoder-1.2.1 esp-idf-size-1.6.1 esptool-4.8.1 freertos_gdb-1.0.3 idf-component-manager-2.0.4 idna-3.10 intelhex-2.3.0 jsonref-1.1.0 markdown-it-py-3.0.0 mdurl-0.1.2 packaging-24.2 pyclang-0.5.0 pycparser-2.22 pydantic-2.9.2 pydantic-core-2.23.4 pydantic-settings-2.6.1 pyelftools-0.31 pygdbmi-0.11.0.0 pygments-2.18.0 pyparsing-3.2.0 pyserial-3.5 python-dotenv-1.0.1 pyyaml-6.0.2 reedsolo-1.7.0 requests-2.32.3 requests-file-2.1.0 requests-toolbelt-1.0.0 rich-13.9.4 six-1.16.0 tqdm-4.67.0 typing-extensions-4.12.2 urllib3-1.26.20 windows-curses-2.4.0

Executing C:\Python311\python.exe C:\Users\AndriiFilippov\e\esp-idf-v5.3.1\tools\idf_tools.py export --format=key-value
Traceback (most recent call last):
  File "C:\Users\AndriiFilippov\e\esp-idf-v5.3.1\tools\idf_tools.py", line 3239, in <module>
    main(sys.argv[1:])
  File "C:\Users\AndriiFilippov\e\esp-idf-v5.3.1\tools\idf_tools.py", line 3231, in main
    action_func(args)
  File "C:\Users\AndriiFilippov\e\esp-idf-v5.3.1\tools\idf_tools.py", line 2211, in action_export
    paths_to_check = rf'{export_vars["PATH"]}{os.environ["PATH"]}'
                                              ~~~~~~~~~~^^^^^^^^
  File "<frozen os>", line 678, in __getitem__
KeyError: 'PATH'

image

Hi @AndriiFilippov ,

thanks for reporting this. Fixed in the last commit

sigmaaa avatar Nov 18 '24 11:11 sigmaaa

@sigmaaa hi !

Now I am able to install tools, however this error occurs after Project Creation:

ERROR: C:\Espressif\espidf.constraints.v5.3.txt doesn't exist. Perhaps you've forgotten to run the install scripts. Please check the installation guide for more information.

ESP-IDF v5.3.1-dirty

unable to open Menu Config. image

java.lang.reflect.InvocationTargetException: Build directory is not found: C:\Users\AndriiFilippov\workspaceDENYSTESTPRDELETELATERCMAKEBUILDreconfigure\wewewe\build
	at com.espressif.idf.sdk.config.ui.SDKConfigurationEditor.lambda$0(SDKConfigurationEditor.java:190)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:124)

AndriiFilippov avatar Nov 18 '24 15:11 AndriiFilippov

@sigmaaa hi !

Tested under: OS - Windows 11 / Mac arm64

Once project is created - the "idf.py reconfigure" executes. ✅ Able to open Menu Config. ✅ Do see the option to turn off "idf.py reconfigure" after project created, works as expected ✅
image

  1. The other thing that bothers me is the execution time of the command on Windows 11 - between 25-40 seconds.

2.After "idf.py reconfigure" is done there is a weird behave - it execute full "confserver" command on every Menu Config opening. it is building 20 seconds every time on my machine. But once project is built, there is very brief execution and process takes 2-4 seconds only:

Executing action: confserver
Running ninja in directory C:\Users\AndriiFilippov\workspaceTESTdenysPR\bl1\build
Executing "ninja confserver"...
Server running, waiting for requests on stdin...
[0/1] cmd.exe /C "cd /D C:\Users\AndriiFilippov\workspaceTESTdenysPR\bl1\build && C:\Users\AndriiFilippov\........
  1. I was thinking perhaps we could improve the error message when a user tries to open the Menu Config without a built project, now it looks like this:

image

there is a better description in the Error logs, but it is not default window. image

could we improve it ?

AndriiFilippov avatar Nov 21 '24 16:11 AndriiFilippov

@sigmaaa hi !

  1. still after idf.py reconfigure it compile full idf.py menuconfig command. I don't see this behave using terminal. In terminal it does not execute full configserver command

  2. Should this feature be available for the custom build folder ? I tried different approaches but it still use workspace build folder

AndriiFilippov avatar Nov 26 '24 17:11 AndriiFilippov

@sigmaaa hi !

  1. still after idf.py reconfigure it compile full idf.py menuconfig command. I don't see this behave using terminal. In terminal it does not execute full configserver command
  2. Should this feature be available for the custom build folder ? I tried different approaches but it still use workspace build folder

Hi @AndriiFilippov,

In the last commit, I've replaced the idf.py reconfigure command with the corresponding cmake command to allow the -B argument.

sigmaaa avatar Nov 29 '24 10:11 sigmaaa

@sigmaaa hi !

OS - Windows 11

create project - select "execute idf.py reconfigure with Project Creation" -> error on re-configure

Cannot run program "cmake" (in directory "C:\Users\AndriiFilippov\workspaceTEW21w23\kkmk"): CreateProcess error=2, The system cannot find the file specified
Cannot run program "cmake" (in directory "C:\Users\AndriiFilippov\workspaceTEW21w23\kkmk"): CreateProcess error=2, The system cannot find the file specified

AndriiFilippov avatar Dec 10 '24 12:12 AndriiFilippov

@sigmaaa hi ! Tested: OS - Windows 11 ESP-IDF: v5.4

create project with Execute idf.py reconfigure with Project Creation then create project without Execute idf.py reconfigure with Project Creation -> run MenuConfig on project without Execute idf.py reconfigure with Project Creation -> it takes build folder from 1 project:

image

AndriiFilippov avatar Dec 11 '24 12:12 AndriiFilippov

@sigmaaa hi ! Tested: OS - Windows 11 ESP-IDF: v5.4

create project with Execute idf.py reconfigure with Project Creation then create project without Execute idf.py reconfigure with Project Creation -> run MenuConfig on project without Execute idf.py reconfigure with Project Creation -> it takes build folder from 1 project:

image

Hi @AndriiFilippov,

seems it's not caused by this PR so we can handle this in a separate PR

sigmaaa avatar Dec 11 '24 15:12 sigmaaa

@sigmaaa hi !

ok, ticket created.

LGTM 👍

AndriiFilippov avatar Dec 11 '24 17:12 AndriiFilippov