Skip to content

Commit 8235d27

Browse files
authored
IEP-925 2.9.1 project combo is empty and launch can throw an exception (#739)
* fix combo is empty and launch exception * default project selection fix * fix: can't change default toolchain for target * fix problem with jtag/uart flash
1 parent 76fcbd7 commit 8235d27

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed

bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.eclipse.cdt.core.IConsoleParser2;
5555
import org.eclipse.cdt.core.build.CBuildConfiguration;
5656
import org.eclipse.cdt.core.build.IToolChain;
57+
import org.eclipse.cdt.core.build.IToolChainManager;
5758
import org.eclipse.cdt.core.envvar.EnvironmentVariable;
5859
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
5960
import org.eclipse.cdt.core.index.IIndexManager;
@@ -141,8 +142,6 @@ public IDFBuildConfiguration(IBuildConfiguration config, String name) throws Cor
141142
{
142143
super(config, name);
143144
buildConfiguration = config;
144-
ICMakeToolChainManager manager = IDFCorePlugin.getService(ICMakeToolChainManager.class);
145-
this.toolChainFile = manager.getToolChainFileFor(getToolChain());
146145
}
147146

148147
public IDFBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain)
@@ -266,8 +265,10 @@ private IBinary[] getBuildOutput(final IBinaryContainer binaries, final IPath ou
266265
.toArray(IBinary[]::new);
267266
}
268267

269-
public ICMakeToolChainFile getToolChainFile()
268+
public ICMakeToolChainFile getToolChainFile() throws CoreException
270269
{
270+
ICMakeToolChainManager manager = IDFCorePlugin.getService(ICMakeToolChainManager.class);
271+
this.toolChainFile = manager.getToolChainFileFor(getToolChain());
271272
return toolChainFile;
272273
}
273274

@@ -799,6 +800,14 @@ private IFolder getIDFComponentsFolder() throws CoreException
799800
return folder;
800801
}
801802

803+
@Override
804+
public IToolChain getToolChain() throws CoreException
805+
{
806+
String typeId = getProperty(TOOLCHAIN_TYPE);
807+
String id = getProperty(TOOLCHAIN_ID);
808+
IToolChainManager toolChainManager = CCorePlugin.<IToolChainManager>getService(IToolChainManager.class);
809+
return toolChainManager.getToolChain(typeId, id);
810+
}
802811
private static IPath getComponentsPath()
803812
{
804813
return new org.eclipse.core.runtime.Path(IDFConstants.BUILD_FOLDER).append("ide").append(ESP_IDF_COMPONENTS); //$NON-NLS-1$

bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfigurationProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public synchronized ICBuildConfiguration getCBuildConfiguration(IBuildConfigurat
6060
try
6161
{
6262
ILaunchTarget target = barManager.getActiveLaunchTarget();
63+
if (target == null)
64+
{
65+
return null;
66+
}
6367
for (IToolChain tc : toolChainManager.getToolChainsMatching(target.getAttributes()))
6468
{
6569
if (tc instanceof AbstractESPToolchain)

bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/internal/SerialFlashLaunchConfigDelegate.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@
4242
import org.eclipse.embedcdt.core.EclipseUtils;
4343
import org.eclipse.embedcdt.core.StringUtils;
4444
import org.eclipse.jface.dialogs.MessageDialog;
45+
import org.eclipse.launchbar.core.ILaunchBarManager;
4546
import org.eclipse.launchbar.core.target.ILaunchTarget;
4647
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
4748
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
4849
import org.eclipse.launchbar.ui.internal.Activator;
4950
import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager;
5051
import org.eclipse.swt.widgets.Display;
5152

53+
import com.espressif.idf.core.IDFCorePlugin;
5254
import com.espressif.idf.core.IDFEnvironmentVariables;
5355
import com.espressif.idf.core.build.IDFLaunchConstants;
5456
import com.espressif.idf.core.logging.Logger;
@@ -75,6 +77,10 @@ public class SerialFlashLaunchConfigDelegate extends CoreBuildGenericLaunchConfi
7577
@Override
7678
public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target)
7779
throws CoreException {
80+
if (target == null) {
81+
ILaunchBarManager barManager = IDFCorePlugin.getService(ILaunchBarManager.class);
82+
target = barManager.getActiveLaunchTarget();
83+
}
7884
return new SerialFlashLaunch(configuration, mode, null, target);
7985
}
8086

@@ -131,7 +137,7 @@ protected void launchInternal(ILaunchConfiguration configuration, String mode, I
131137
if (checkIfPortIsEmpty(configuration)) {
132138
return;
133139
}
134-
String arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS,
140+
String arguments = configuration.getAttribute(IDFLaunchConstants.ATTR_SERIAL_FLASH_ARGUMENTS,
135141
espFlashCommand);
136142
arguments = arguments.replace(ESPFlashUtil.SERIAL_PORT, serialPort);
137143
if (!arguments.isEmpty()) {
@@ -177,7 +183,7 @@ protected void flashOverJtag(ILaunchConfiguration configuration, ILaunch launch)
177183
openocdExe = openocdExe.replace(DEFAULT_PATH, tmp);
178184
commands.add(openocdExe);
179185

180-
String arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
186+
String arguments = configuration.getAttribute(IDFLaunchConstants.ATTR_JTAG_FLASH_ARGUMENTS, ""); //$NON-NLS-1$
181187
arguments = arguments.replace(DEFAULT_PATH, tmp).trim();
182188
commands.addAll(StringUtils.splitCommandLineOptions(arguments));
183189

bundles/com.espressif.idf.terminal.connector.serial/src/com/espressif/idf/terminal/connector/serial/controls/SerialSettingsPage.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import java.util.Optional;
1818

1919
import org.eclipse.cdt.serial.SerialPort;
20-
import org.eclipse.core.resources.IBuildConfiguration;
2120
import org.eclipse.core.resources.IProject;
2221
import org.eclipse.core.resources.ResourcesPlugin;
2322
import org.eclipse.core.runtime.CoreException;
@@ -38,7 +37,7 @@
3837
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer;
3938
import org.osgi.service.prefs.Preferences;
4039

41-
import com.espressif.idf.core.build.IDFBuildConfigurationProvider;
40+
import com.espressif.idf.core.IDFProjectNature;
4241
import com.espressif.idf.core.logging.Logger;
4342
import com.espressif.idf.core.util.StringUtil;
4443
import com.espressif.idf.terminal.connector.serial.activator.Activator;
@@ -105,9 +104,7 @@ public void createControl(Composite parent)
105104
{
106105
try
107106
{
108-
IBuildConfiguration activeBuildConfig = project.getActiveBuildConfig();
109-
if (activeBuildConfig != null
110-
&& activeBuildConfig.getName().startsWith(IDFBuildConfigurationProvider.ID))
107+
if (project.hasNature(IDFProjectNature.ID))
111108
{
112109
projectCombo.add(project.getName());
113110
}

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/EclipseUtil.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.eclipse.ui.IWorkbenchWindow;
1818
import org.eclipse.ui.PlatformUI;
1919

20-
import com.espressif.idf.core.build.IDFBuildConfigurationProvider;
20+
import com.espressif.idf.core.IDFProjectNature;
2121
import com.espressif.idf.core.logging.Logger;
2222

2323
/**
@@ -70,8 +70,7 @@ public static IProject getSelectedIDFProjectInExplorer()
7070
IProject project = getSelectedProject(IPageLayout.ID_PROJECT_EXPLORER);
7171
try
7272
{
73-
if (project != null && project.getActiveBuildConfig() != null
74-
&& project.getActiveBuildConfig().getName().startsWith(IDFBuildConfigurationProvider.ID))
73+
if (project != null && project.hasNature(IDFProjectNature.ID))
7574
{
7675
return project;
7776
}
@@ -94,10 +93,10 @@ private static IProject getSelectedProject(String viewID)
9493
IStructuredSelection structured = (IStructuredSelection) service.getSelection(viewID);
9594
if (structured instanceof IStructuredSelection)
9695
{
97-
Object selectedObject = ((IStructuredSelection) structured).getFirstElement();
96+
Object selectedObject = structured.getFirstElement();
9897
if (selectedObject instanceof IAdaptable)
9998
{
100-
IResource resource = (IResource) ((IAdaptable) selectedObject).getAdapter(IResource.class);
99+
IResource resource = ((IAdaptable) selectedObject).getAdapter(IResource.class);
101100
if (resource != null)
102101
{
103102
return resource.getProject();

0 commit comments

Comments
 (0)