-
Notifications
You must be signed in to change notification settings - Fork 133
Dynamic ESP-IDF Target Discovery and Support Preview Targets #1302
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5c8de8f
fix: toolchain refactoring and support preview targets
kolipakakondal c54f0bf
fix: remove the fallback approach
kolipakakondal 7023f7d
fix: set the targets based on the idf setup
kolipakakondal ffa3fad
fix: show targets based on the esp-idf
kolipakakondal 014477a
resolving review comments
alirana01 f3b7996
Respecting dynamic targets
alirana01 4510d2f
Revert "Respecting dynamic targets"
alirana01 6952d2a
Revert "resolving review comments"
alirana01 db964d1
updated to resolve review comments
alirana01 51c14c6
project creation updated to fetch targets from the updated class
alirana01 feef302
small bug fix for reading targets
alirana01 3cb1caa
fixed unified directory name
alirana01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
215 changes: 215 additions & 0 deletions
215
bundles/com.espressif.idf.core/src/com/espressif/idf/core/toolchain/IDFTargets.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| /******************************************************************************* | ||
| * Copyright 2025 Espressif Systems (Shanghai) PTE LTD. All rights reserved. | ||
| * Use is subject to license terms. | ||
| *******************************************************************************/ | ||
|
|
||
| package com.espressif.idf.core.toolchain; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Class to hold ESP-IDF target information including preview status | ||
| * | ||
| * @author Kondal Kolipaka <[email protected]> | ||
| * | ||
| */ | ||
| public class IDFTargets | ||
| { | ||
| private static final Set<String> XTENSA_CHIPS = Set.of("esp32", "esp32s2", "esp32s3"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ | ||
| private static final String XTENSA = "xtensa"; //$NON-NLS-1$ | ||
| private static final String RISCV32 = "riscv32"; //$NON-NLS-1$ | ||
| private static final String XTENSA_TOOLCHAIN_ID = XTENSA + "-%s-elf"; //$NON-NLS-1$ | ||
| private static final String RISCV32_TOOLCHAIN_ID = RISCV32 + "-esp-elf"; //$NON-NLS-1$ | ||
| private static final String XTENSA_UNIFIED_DIR = XTENSA + "-esp32-elf"; //$NON-NLS-1$ | ||
| private static final String TOOLCHAIN_NAME = "toolchain-%s.cmake"; //$NON-NLS-1$ | ||
| private List<IDFTarget> supportedTargets; | ||
| private List<IDFTarget> previewTargets; | ||
|
|
||
| public IDFTargets() | ||
| { | ||
| this.supportedTargets = new ArrayList<>(); | ||
| this.previewTargets = new ArrayList<>(); | ||
| } | ||
|
|
||
| public void addSupportedTarget(String target) | ||
| { | ||
| supportedTargets.add(new IDFTarget(target, false)); | ||
| } | ||
|
|
||
| public void addPreviewTarget(String target) | ||
| { | ||
| previewTargets.add(new IDFTarget(target, true)); | ||
| } | ||
|
|
||
| public List<IDFTarget> getAllTargets() | ||
| { | ||
| List<IDFTarget> allTargets = new ArrayList<>(); | ||
| allTargets.addAll(supportedTargets); | ||
| allTargets.addAll(previewTargets); | ||
| return allTargets; | ||
| } | ||
|
|
||
| public List<IDFTarget> getSupportedTargets() | ||
| { | ||
| return supportedTargets; | ||
| } | ||
|
|
||
| public List<IDFTarget> getPreviewTargets() | ||
| { | ||
| return previewTargets; | ||
| } | ||
|
|
||
| public boolean hasTarget(String targetName) | ||
| { | ||
| return getAllTargets().stream().anyMatch(target -> target.getName().equals(targetName)); | ||
| } | ||
|
|
||
| /** | ||
| * Get a specific target by name | ||
| * | ||
| * @param targetName Name of the target to find | ||
| * @return IDFTarget if found, null otherwise | ||
| */ | ||
| public IDFTarget getTarget(String targetName) | ||
| { | ||
| return getAllTargets().stream().filter(target -> target.getName().equals(targetName)).findFirst().orElse(null); | ||
| } | ||
|
|
||
| /** | ||
| * Get all target names as strings | ||
| * | ||
| * @return List of target names | ||
| */ | ||
| public List<String> getAllTargetNames() | ||
| { | ||
| return getAllTargets().stream().map(IDFTarget::getName).collect(java.util.stream.Collectors.toList()); | ||
| } | ||
|
|
||
| /** | ||
| * Get supported target names as strings | ||
| * | ||
| * @return List of supported target names | ||
| */ | ||
| public List<String> getSupportedTargetNames() | ||
| { | ||
| return getSupportedTargets().stream().map(IDFTarget::getName).collect(java.util.stream.Collectors.toList()); | ||
| } | ||
|
|
||
| /** | ||
| * Get preview target names as strings | ||
| * | ||
| * @return List of preview target names | ||
| */ | ||
| public List<String> getPreviewTargetNames() | ||
| { | ||
| return getPreviewTargets().stream().map(IDFTarget::getName).collect(java.util.stream.Collectors.toList()); | ||
| } | ||
|
|
||
| /** | ||
| * Inner class representing a single IDF target | ||
| */ | ||
| public static class IDFTarget | ||
| { | ||
| private final String name; | ||
| private final boolean isPreview; | ||
|
|
||
| public IDFTarget(String name, boolean isPreview) | ||
| { | ||
| this.name = name; | ||
| this.isPreview = isPreview; | ||
| } | ||
|
|
||
| public String getName() | ||
| { | ||
| return name; | ||
| } | ||
|
|
||
| public boolean isPreview() | ||
| { | ||
| return isPreview; | ||
| } | ||
|
|
||
| /** | ||
| * Get the architecture for this target | ||
| * | ||
| * @return "xtensa" for esp32/esp32s2/esp32s3, "riscv32" for others | ||
| */ | ||
| public String getArchitecture() | ||
| { | ||
| return XTENSA_CHIPS.contains(name) ? XTENSA : RISCV32; | ||
| } | ||
|
|
||
| /** | ||
| * Get the toolchain ID for this target | ||
| * | ||
| * @return toolchain ID string | ||
| */ | ||
| public String getToolchainId() | ||
| { | ||
| return XTENSA_CHIPS.contains(name) ? String.format(XTENSA_TOOLCHAIN_ID, name) : RISCV32_TOOLCHAIN_ID; | ||
| } | ||
|
|
||
| /** | ||
| * Get the compiler pattern for this target | ||
| * | ||
| * @return regex pattern for compiler | ||
| */ | ||
| public String getCompilerPattern() | ||
| { | ||
| String executableName = getExecutableName(); | ||
|
|
||
| // Support both old and new unified directory structures | ||
| String targetSpecificDir = getTargetSpecificDirectoryName(); | ||
| String unifiedDir = getUnifiedDirectoryName(); | ||
|
|
||
| // Create pattern that matches either directory structure | ||
| return "(?:" + targetSpecificDir + "|" + unifiedDir + ")[\\\\/]+bin[\\\\/]+" + executableName //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ | ||
| + "-gcc(?:\\.exe)?$"; //$NON-NLS-1$ | ||
| } | ||
|
|
||
| /** | ||
| * Get the debugger pattern for this target | ||
| * | ||
| * @return regex pattern for debugger | ||
| */ | ||
| public String getDebuggerPattern() | ||
| { | ||
| String executableName = getExecutableName(); | ||
| return executableName + "-gdb(?:\\.exe)?$"; //$NON-NLS-1$ | ||
| } | ||
|
|
||
| /** | ||
| * Get the executable name prefix for this target (different from directory structure in ESP-IDF v5.5+) | ||
| * | ||
| * @return executable name prefix | ||
| */ | ||
| private String getExecutableName() | ||
| { | ||
| return XTENSA_CHIPS.contains(name) ? String.format(XTENSA_TOOLCHAIN_ID, name) | ||
| : RISCV32_TOOLCHAIN_ID; | ||
| } | ||
|
|
||
| private String getTargetSpecificDirectoryName() | ||
| { | ||
| return XTENSA_CHIPS.contains(name) ? String.format(XTENSA_TOOLCHAIN_ID, name) | ||
| : RISCV32_TOOLCHAIN_ID; | ||
| } | ||
|
|
||
| private String getUnifiedDirectoryName() | ||
| { | ||
| return XTENSA_CHIPS.contains(name) ? XTENSA_UNIFIED_DIR : RISCV32_TOOLCHAIN_ID; | ||
| } | ||
|
|
||
| /** | ||
| * Get the CMake toolchain file name for this target | ||
| * | ||
| * @return toolchain file name | ||
| */ | ||
| public String getToolchainFileName() | ||
| { | ||
| return String.format(TOOLCHAIN_NAME, name); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.