Skip to content
Merged
66 changes: 0 additions & 66 deletions bundles/com.espressif.idf.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,72 +244,6 @@ config-only component and an interface library is created instead."
name="KCONFIG_PROJBUILD">
</property>
</extension>
<extension point="com.espressif.idf.core.toolchain">
<ToolChain
arch="xtensa"
compilerPattern="(?:xtensa-esp-elf|xtensa-esp32-elf)[\\/]+bin[\\/]+xtensa-esp32-elf-gcc(?:\.exe)?$"
debuggerPattern="xtensa-esp32-elf-gdb(\.exe)?$"
fileName="toolchain-esp32.cmake"
id="xtensa-esp32-elf"
name="esp32">
</ToolChain>
<ToolChain
arch="xtensa"
compilerPattern="(?:xtensa-esp-elf|xtensa-esp32s2-elf)[\\/]+bin[\\/]+xtensa-esp32s2-elf-gcc(?:\.exe)?$"
debuggerPattern="xtensa-esp32s2-elf-gdb(\.exe)?$"
fileName="toolchain-esp32s2.cmake"
id="xtensa-esp32s2-elf"
name="esp32s2">
</ToolChain>
<ToolChain
arch="xtensa"
compilerPattern="(?:xtensa-esp-elf|xtensa-esp32s3-elf)[\\/]+bin[\\/]+xtensa-esp32s3-elf-gcc(?:\.exe)?$"
debuggerPattern="xtensa-esp32s3-elf-gdb(\.exe)?$"
fileName="toolchain-esp32s3.cmake"
id="xtensa-esp32s3-elf"
name="esp32s3">
</ToolChain>
<ToolChain
arch="riscv32"
compilerPattern="riscv32-esp-elf[\\/]+bin[\\/]+riscv32-esp-elf-gcc(?:\.exe)?$"
debuggerPattern="riscv32-esp-elf-gdb(\.exe)?$"
fileName="toolchain-esp32c2.cmake"
id="riscv32-esp-elf"
name="esp32c2">
</ToolChain>
<ToolChain
arch="riscv32"
compilerPattern="riscv32-esp-elf[\\/]+bin[\\/]+riscv32-esp-elf-gcc(?:\.exe)?$"
debuggerPattern="riscv32-esp-elf-gdb(\.exe)?$"
fileName="toolchain-esp32c3.cmake"
id="riscv32-esp-elf"
name="esp32c3">
</ToolChain>
<ToolChain
arch="riscv32"
compilerPattern="riscv32-esp-elf[\\/]+bin[\\/]+riscv32-esp-elf-gcc(?:\.exe)?$"
debuggerPattern="riscv32-esp-elf-gdb(\.exe)?$"
fileName="toolchain-esp32c6.cmake"
id="riscv32-esp-elf"
name="esp32c6">
</ToolChain>
<ToolChain
arch="riscv32"
compilerPattern="riscv32-esp-elf[\\/]+bin[\\/]+riscv32-esp-elf-gcc(?:\.exe)?$"
debuggerPattern="riscv32-esp-elf-gdb(\.exe)?$"
fileName="toolchain-esp32h2.cmake"
id="riscv32-esp-elf"
name="esp32h2">
</ToolChain>
<ToolChain
arch="riscv32"
compilerPattern="riscv32-esp-elf[\\/]+bin[\\/]+riscv32-esp-elf-gcc(?:\.exe)?$"
debuggerPattern="riscv32-esp-elf-gdb(\.exe)?$"
fileName="toolchain-esp32p4.cmake"
id="riscv32-esp-elf"
name="esp32p4">
</ToolChain>
</extension>
<extension point="org.eclipse.core.variables.dynamicVariables">
<variable
description="%openocd_bin_path"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public String getDefaultBoard(String targetName)
{
List<Board> boardsList = this.espConfigParser.getBoardsForTarget(targetName);
String[] boards = boardsList.stream().map(Board::name).toArray(String[]::new);

if (boards.length == 0)
{
return EspTarget.enumOf(targetName).board;
}

return boards[getIndexOfDefaultBoard(targetName, boards)];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.build.IToolChainProvider;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
Expand Down Expand Up @@ -74,23 +72,27 @@ public ESPToolChainManager()

private static Map<String, ESPToolChainElement> readESPToolchainRegistry()
{
IConfigurationElement[] configElements = Platform.getExtensionRegistry()
.getConfigurationElementsFor("com.espressif.idf.core.toolchain"); //$NON-NLS-1$
for (IConfigurationElement iConfigurationElement : configElements)
// Read targets dynamically from ESP-IDF constants.py instead of plugin.xml
String idfPath = IDFUtil.getIDFPath();
IDFTargets idfTargets = IDFTargetsReader.readTargetsFromEspIdf(idfPath);

// Convert dynamic targets to toolchain elements
for (IDFTargets.IDFTarget target : idfTargets.getAllTargets())
{
String name = iConfigurationElement.getAttribute("name"); //$NON-NLS-1$
String id = iConfigurationElement.getAttribute("id"); //$NON-NLS-1$
String arch = iConfigurationElement.getAttribute("arch"); //$NON-NLS-1$
String fileName = iConfigurationElement.getAttribute("fileName"); //$NON-NLS-1$
String compilerPattern = iConfigurationElement.getAttribute("compilerPattern"); //$NON-NLS-1$
String debuggerPatten = iConfigurationElement.getAttribute("debuggerPattern"); //$NON-NLS-1$
String name = target.getName();
String id = target.getToolchainId();
String arch = target.getArchitecture();
String fileName = target.getToolchainFileName();
String compilerPattern = target.getCompilerPattern();
String debuggerPattern = target.getDebuggerPattern();

String uniqueToolChainId = name.concat("/").concat(arch).concat("/").concat(fileName); //$NON-NLS-1$ //$NON-NLS-2$

toolchainElements.put(uniqueToolChainId,
new ESPToolChainElement(name, id, arch, fileName, compilerPattern, debuggerPatten));

new ESPToolChainElement(name, id, arch, fileName, compilerPattern, debuggerPattern));
}

Logger.log("Dynamically loaded " + toolchainElements.size() + " toolchain elements from ESP-IDF"); //$NON-NLS-1$ //$NON-NLS-2$
return toolchainElements;
}

Expand Down
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);
}
}
}
Loading
Loading