Skip to content

Commit

Permalink
IEP-925 2.9.1 project combo is empty and launch can throw an exception (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
sigmaaa committed Apr 6, 2023
1 parent 76fcbd7 commit 8235d27
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.eclipse.cdt.core.IConsoleParser2;
import org.eclipse.cdt.core.build.CBuildConfiguration;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.envvar.EnvironmentVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.index.IIndexManager;
Expand Down Expand Up @@ -141,8 +142,6 @@ public IDFBuildConfiguration(IBuildConfiguration config, String name) throws Cor
{
super(config, name);
buildConfiguration = config;
ICMakeToolChainManager manager = IDFCorePlugin.getService(ICMakeToolChainManager.class);
this.toolChainFile = manager.getToolChainFileFor(getToolChain());
}

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

public ICMakeToolChainFile getToolChainFile()
public ICMakeToolChainFile getToolChainFile() throws CoreException
{
ICMakeToolChainManager manager = IDFCorePlugin.getService(ICMakeToolChainManager.class);
this.toolChainFile = manager.getToolChainFileFor(getToolChain());
return toolChainFile;
}

Expand Down Expand Up @@ -799,6 +800,14 @@ private IFolder getIDFComponentsFolder() throws CoreException
return folder;
}

@Override
public IToolChain getToolChain() throws CoreException
{
String typeId = getProperty(TOOLCHAIN_TYPE);
String id = getProperty(TOOLCHAIN_ID);
IToolChainManager toolChainManager = CCorePlugin.<IToolChainManager>getService(IToolChainManager.class);
return toolChainManager.getToolChain(typeId, id);
}
private static IPath getComponentsPath()
{
return new org.eclipse.core.runtime.Path(IDFConstants.BUILD_FOLDER).append("ide").append(ESP_IDF_COMPONENTS); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public synchronized ICBuildConfiguration getCBuildConfiguration(IBuildConfigurat
try
{
ILaunchTarget target = barManager.getActiveLaunchTarget();
if (target == null)
{
return null;
}
for (IToolChain tc : toolChainManager.getToolChainsMatching(target.getAttributes()))
{
if (tc instanceof AbstractESPToolchain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
import org.eclipse.embedcdt.core.EclipseUtils;
import org.eclipse.embedcdt.core.StringUtils;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager;
import org.eclipse.swt.widgets.Display;

import com.espressif.idf.core.IDFCorePlugin;
import com.espressif.idf.core.IDFEnvironmentVariables;
import com.espressif.idf.core.build.IDFLaunchConstants;
import com.espressif.idf.core.logging.Logger;
Expand All @@ -75,6 +77,10 @@ public class SerialFlashLaunchConfigDelegate extends CoreBuildGenericLaunchConfi
@Override
public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target)
throws CoreException {
if (target == null) {
ILaunchBarManager barManager = IDFCorePlugin.getService(ILaunchBarManager.class);
target = barManager.getActiveLaunchTarget();
}
return new SerialFlashLaunch(configuration, mode, null, target);
}

Expand Down Expand Up @@ -131,7 +137,7 @@ protected void launchInternal(ILaunchConfiguration configuration, String mode, I
if (checkIfPortIsEmpty(configuration)) {
return;
}
String arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS,
String arguments = configuration.getAttribute(IDFLaunchConstants.ATTR_SERIAL_FLASH_ARGUMENTS,
espFlashCommand);
arguments = arguments.replace(ESPFlashUtil.SERIAL_PORT, serialPort);
if (!arguments.isEmpty()) {
Expand Down Expand Up @@ -177,7 +183,7 @@ protected void flashOverJtag(ILaunchConfiguration configuration, ILaunch launch)
openocdExe = openocdExe.replace(DEFAULT_PATH, tmp);
commands.add(openocdExe);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Optional;

import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -38,7 +37,7 @@
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer;
import org.osgi.service.prefs.Preferences;

import com.espressif.idf.core.build.IDFBuildConfigurationProvider;
import com.espressif.idf.core.IDFProjectNature;
import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.core.util.StringUtil;
import com.espressif.idf.terminal.connector.serial.activator.Activator;
Expand Down Expand Up @@ -105,9 +104,7 @@ public void createControl(Composite parent)
{
try
{
IBuildConfiguration activeBuildConfig = project.getActiveBuildConfig();
if (activeBuildConfig != null
&& activeBuildConfig.getName().startsWith(IDFBuildConfigurationProvider.ID))
if (project.hasNature(IDFProjectNature.ID))
{
projectCombo.add(project.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

import com.espressif.idf.core.build.IDFBuildConfigurationProvider;
import com.espressif.idf.core.IDFProjectNature;
import com.espressif.idf.core.logging.Logger;

/**
Expand Down Expand Up @@ -70,8 +70,7 @@ public static IProject getSelectedIDFProjectInExplorer()
IProject project = getSelectedProject(IPageLayout.ID_PROJECT_EXPLORER);
try
{
if (project != null && project.getActiveBuildConfig() != null
&& project.getActiveBuildConfig().getName().startsWith(IDFBuildConfigurationProvider.ID))
if (project != null && project.hasNature(IDFProjectNature.ID))
{
return project;
}
Expand All @@ -94,10 +93,10 @@ private static IProject getSelectedProject(String viewID)
IStructuredSelection structured = (IStructuredSelection) service.getSelection(viewID);
if (structured instanceof IStructuredSelection)
{
Object selectedObject = ((IStructuredSelection) structured).getFirstElement();
Object selectedObject = structured.getFirstElement();
if (selectedObject instanceof IAdaptable)
{
IResource resource = (IResource) ((IAdaptable) selectedObject).getAdapter(IResource.class);
IResource resource = ((IAdaptable) selectedObject).getAdapter(IResource.class);
if (resource != null)
{
return resource.getProject();
Expand Down

0 comments on commit 8235d27

Please sign in to comment.