mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Introduce Core Build launches and Launch Bar integration.
Unify launching for projects that use the new Core Build system. Starts with CMake projects. We'll do Qt projects next. Change-Id: I14af8e99decd54cc6548095b3ad3e054c550aea2
This commit is contained in:
parent
a6062a2b98
commit
b26917be90
27 changed files with 207 additions and 128 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: CDT CMake Core
|
||||
Bundle-SymbolicName: org.eclipse.cdt.cmake.core;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Version: 1.1.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.cmake.core.internal.Activator
|
||||
Bundle-Vendor: Eclipse CDT
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
@ -14,4 +14,5 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
com.google.gson
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.cdt.cmake.core
|
||||
Export-Package: org.eclipse.cdt.cmake.core,
|
||||
org.eclipse.cdt.cmake.core.internal;x-friends:="org.eclipse.cdt.cmake.ui"
|
||||
|
|
|
@ -11,39 +11,6 @@
|
|||
</run>
|
||||
</runtime>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.launchbar.core.launchBarContributions">
|
||||
<descriptorType
|
||||
class="org.eclipse.cdt.cmake.core.internal.CMakeLaunchDescriptorType"
|
||||
id="org.eclipse.cdt.cmake.core.descriptorType"
|
||||
priority="10">
|
||||
<enablement>
|
||||
<instanceof
|
||||
value="org.eclipse.core.resources.IProject">
|
||||
</instanceof>
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.eclipse.core.resources.projectNature"
|
||||
value="org.eclipse.cdt.cmake.core.cmakeNature">
|
||||
</test>
|
||||
</enablement>
|
||||
</descriptorType>
|
||||
<configProvider
|
||||
class="org.eclipse.cdt.cmake.core.internal.CMakeLaunchConfigurationProvider"
|
||||
descriptorType="org.eclipse.cdt.cmake.core.descriptorType"
|
||||
priority="10">
|
||||
</configProvider>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.core.launchConfigurationTypes">
|
||||
<launchConfigurationType
|
||||
delegate="org.eclipse.cdt.cmake.core.internal.CMakeLaunchConfigurationDelegate"
|
||||
id="org.eclipse.cdt.cmake.core.launchConfigurationType"
|
||||
modes="run"
|
||||
name="CMake Application"
|
||||
public="true">
|
||||
</launchConfigurationType>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.cdt.core.buildConfigProvider">
|
||||
<provider
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.cmake.core</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
|
@ -28,13 +28,10 @@ import org.eclipse.cdt.core.build.IToolChain;
|
|||
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||
import org.eclipse.cdt.core.resources.IConsole;
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
@ -50,11 +47,11 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
public CMakeBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
|
||||
super(config, name);
|
||||
|
||||
ICMakeToolChainManager manager = Activator.getService(ICMakeToolChainManager.class);
|
||||
Preferences settings = getSettings();
|
||||
String pathStr = settings.get(TOOLCHAIN_FILE, ""); //$NON-NLS-1$
|
||||
if (!pathStr.isEmpty()) {
|
||||
Path path = Paths.get(pathStr);
|
||||
ICMakeToolChainManager manager = Activator.getService(ICMakeToolChainManager.class);
|
||||
toolChainFile = manager.getToolChainFile(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: CDT CMake UI
|
||||
Bundle-SymbolicName: org.eclipse.cdt.cmake.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Version: 1.1.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.cmake.ui.internal.Activator
|
||||
Bundle-Vendor: Eclipse CDT
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 630 B |
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.cmake.ui</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
|
@ -18,6 +18,8 @@ public class Activator extends AbstractUIPlugin {
|
|||
|
||||
private static Activator plugin;
|
||||
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.cmake.ui"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
|
@ -34,12 +36,8 @@ public class Activator extends AbstractUIPlugin {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
public static String getId() {
|
||||
return plugin.getBundle().getSymbolicName();
|
||||
}
|
||||
|
||||
public static IStatus errorStatus(String message, Throwable cause) {
|
||||
return new Status(IStatus.ERROR, getId(), message, cause);
|
||||
return new Status(IStatus.ERROR, PLUGIN_ID, message, cause);
|
||||
}
|
||||
|
||||
public static void log(Exception e) {
|
||||
|
|
|
@ -29,8 +29,8 @@ public class NewCMakeProjectWizard extends TemplateWizard {
|
|||
Dialog.applyDialogFont(getControl());
|
||||
}
|
||||
};
|
||||
mainPage.setTitle("New Arduino Project"); //$NON-NLS-1$
|
||||
mainPage.setDescription("Specify properties of new Arduino project."); //$NON-NLS-1$
|
||||
mainPage.setTitle("New CMake Project"); //$NON-NLS-1$
|
||||
mainPage.setDescription("Specify properties of new CMake project."); //$NON-NLS-1$
|
||||
this.addPage(mainPage);
|
||||
}
|
||||
|
||||
|
|
|
@ -117,10 +117,9 @@ public class ScannerInfoCache {
|
|||
// we're already there
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
command.resourcePaths.add(resource.getLocation().toOSString());
|
||||
resourceMap.put(resourcePath, command);
|
||||
}
|
||||
command.resourcePaths.add(resource.getLocation().toOSString());
|
||||
resourceMap.put(resourcePath, command);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -333,6 +333,7 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U
|
|||
<plugin id="org.eclipse.jface.databinding"/>
|
||||
<plugin id="org.eclipse.jface.text"/>
|
||||
<plugin id="org.eclipse.launchbar.core"/>
|
||||
<plugin id="org.eclipse.launchbar.ui"/>
|
||||
<plugin id="org.eclipse.ltk.core.refactoring"/>
|
||||
<plugin id="org.eclipse.ltk.ui.refactoring"/>
|
||||
<plugin id="org.eclipse.osgi"/>
|
||||
|
@ -347,10 +348,10 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U
|
|||
<plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/>
|
||||
<plugin id="org.eclipse.team.core"/>
|
||||
<plugin id="org.eclipse.team.ui"/>
|
||||
<plugin id="org.eclipse.text"/>
|
||||
<plugin id="org.eclipse.tm.terminal.control"/>
|
||||
<plugin id="org.eclipse.tm.terminal.view.core"/>
|
||||
<plugin id="org.eclipse.tm.terminal.view.ui"/>
|
||||
<plugin id="org.eclipse.text"/>
|
||||
<plugin id="org.eclipse.tools.templates.core"/>
|
||||
<plugin id="org.eclipse.tools.templates.ui"/>
|
||||
<plugin id="org.eclipse.ui"/>
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
|
||||
Bundle-Version: 8.0.0.qualifier
|
||||
Bundle-Version: 8.1.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
@ -41,7 +41,8 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.0.0,7.0.0)",
|
|||
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.core.variables;bundle-version="3.2.0",
|
||||
org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)"
|
||||
org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.launchbar.core;bundle-version="2.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Import-Package: com.ibm.icu.text
|
||||
|
|
|
@ -24,6 +24,8 @@ AttachLaunch.name=C/C++ Attach to Application
|
|||
PostMortemLaunch.name=C/C++ Postmortem Debugger
|
||||
RemoteApplicationLaunch.name=C/C++ Remote Application
|
||||
|
||||
localApplicationLaunch.name=C/C++ Local Application (auto)
|
||||
|
||||
CDebugger.name=C/C++ Development Tools Core Debugger Extension
|
||||
BreakpointAction.name=Breakpoint Action Extension
|
||||
SupportedSourceContainerTypes.name=C/C++ Supported Source Container Types Extension
|
||||
|
|
|
@ -461,4 +461,26 @@
|
|||
type="org.eclipse.cdt.debug.core.cFunctionTracepointMarker">
|
||||
</importParticipant>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.core.launchConfigurationTypes">
|
||||
<launchConfigurationType
|
||||
delegate="org.eclipse.cdt.debug.internal.core.launch.CoreBuildLocalRunLaunchDelegate"
|
||||
id="org.eclipse.cdt.debug.core.localLaunchConfigurationType"
|
||||
modes="run"
|
||||
name="%localApplicationLaunch.name">
|
||||
</launchConfigurationType>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.launchbar.core.launchBarContributions">
|
||||
<descriptorType
|
||||
class="org.eclipse.cdt.debug.internal.core.launch.CoreBuildLaunchDescriptorType"
|
||||
id="org.eclipse.cdt.debug.core.coreBuildDescriptorType"
|
||||
priority="20">
|
||||
</descriptorType>
|
||||
<configProvider
|
||||
class="org.eclipse.cdt.debug.internal.core.launch.CoreBuildLocalLaunchConfigProvider"
|
||||
descriptorType="org.eclipse.cdt.debug.core.coreBuildDescriptorType"
|
||||
priority="10">
|
||||
</configProvider>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>8.0.0-SNAPSHOT</version>
|
||||
<version>8.1.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.debug.core</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.eclipse.debug.core.ILaunchDelegate;
|
|||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
/**
|
||||
* The plugin class for C/C++ debug core.
|
||||
|
@ -239,6 +240,15 @@ public class CDebugCorePlugin extends Plugin {
|
|||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 8.1
|
||||
*/
|
||||
public static <T> T getService(Class<T> service) {
|
||||
BundleContext context = plugin.getBundle().getBundleContext();
|
||||
ServiceReference<T> ref = context.getServiceReference(service);
|
||||
return ref != null ? context.getService(ref) : null;
|
||||
}
|
||||
|
||||
private void createCommandAdapterFactory() {
|
||||
IAdapterManager manager= Platform.getAdapterManager();
|
||||
CCommandAdapterFactory actionFactory = new CCommandAdapterFactory();
|
||||
|
@ -319,7 +329,7 @@ public class CDebugCorePlugin extends Plugin {
|
|||
// Set the default launch delegates as early as possible, and do it only once (Bug 312997)
|
||||
ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager();
|
||||
|
||||
HashSet<String> debugSet = new HashSet<String>();
|
||||
HashSet<String> debugSet = new HashSet<>();
|
||||
debugSet.add(ILaunchManager.DEBUG_MODE);
|
||||
|
||||
ILaunchConfigurationType localCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP);
|
||||
|
@ -378,7 +388,7 @@ public class CDebugCorePlugin extends Plugin {
|
|||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
HashSet<String> runSet = new HashSet<String>();
|
||||
HashSet<String> runSet = new HashSet<>();
|
||||
runSet.add(ILaunchManager.RUN_MODE);
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,38 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems and others.
|
||||
* Copyright (c) 2016 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.cmake.core.internal;
|
||||
package org.eclipse.cdt.debug.internal.core.launch;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.cmake.core.CMakeNature;
|
||||
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
||||
import org.eclipse.launchbar.core.internal.Activator;
|
||||
|
||||
public class CMakeLaunchDescriptorType implements ILaunchDescriptorType {
|
||||
|
||||
private Map<IProject, CMakeLaunchDescriptor> descriptors = new HashMap<>();
|
||||
/**
|
||||
* The launch descriptor type for launch objects built with the Core Build System.
|
||||
*/
|
||||
public class CoreBuildLaunchDescriptorType implements ILaunchDescriptorType {
|
||||
|
||||
@Override
|
||||
public ILaunchDescriptor getDescriptor(Object launchObject) throws CoreException {
|
||||
if (launchObject instanceof IProject) {
|
||||
// Make sure it's a new style build
|
||||
IProject project = (IProject) launchObject;
|
||||
if (project.hasNature(CMakeNature.ID)) {
|
||||
CMakeLaunchDescriptor desc = descriptors.get(project);
|
||||
if (desc == null) {
|
||||
desc = new CMakeLaunchDescriptor(this, project);
|
||||
descriptors.put(project, desc);
|
||||
}
|
||||
return desc;
|
||||
if (Activator.getService(ICBuildConfigurationManager.class).supports(project)) {
|
||||
return new CoreBuildProjectLaunchDescriptor(this, project);
|
||||
}
|
||||
}
|
||||
// TODO IBinary
|
||||
return null;
|
||||
}
|
||||
|
|
@ -1,19 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems and others.
|
||||
* Copyright (c) 2016 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.cmake.core.internal;
|
||||
package org.eclipse.cdt.debug.internal.core.launch;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.eclipse.cdt.cmake.core.ICMakeToolChainManager;
|
||||
import org.eclipse.cdt.core.build.IToolChain;
|
||||
import org.eclipse.cdt.core.build.IToolChainManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -26,7 +23,9 @@ import org.eclipse.launchbar.core.ILaunchDescriptor;
|
|||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
|
||||
public class CMakeLaunchConfigurationProvider extends AbstractLaunchConfigProvider {
|
||||
public class CoreBuildLocalLaunchConfigProvider extends AbstractLaunchConfigProvider {
|
||||
|
||||
private static final String TYPE_ID = "org.eclipse.cdt.debug.core.localLaunchConfigurationType"; //$NON-NLS-1$
|
||||
|
||||
private Map<IProject, ILaunchConfiguration> configs = new HashMap<>();
|
||||
|
||||
|
@ -38,8 +37,7 @@ public class CMakeLaunchConfigurationProvider extends AbstractLaunchConfigProvid
|
|||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
return DebugPlugin.getDefault().getLaunchManager()
|
||||
.getLaunchConfigurationType(CMakeLaunchConfigurationDelegate.TYPE_ID);
|
||||
return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(TYPE_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,8 +62,8 @@ public class CMakeLaunchConfigurationProvider extends AbstractLaunchConfigProvid
|
|||
super.populateLaunchConfiguration(descriptor, target, workingCopy);
|
||||
|
||||
// Set the project and the connection
|
||||
CMakeLaunchDescriptor qtDesc = (CMakeLaunchDescriptor) descriptor;
|
||||
workingCopy.setMappedResources(new IResource[] { qtDesc.getProject() });
|
||||
IProject project = descriptor.getAdapter(IProject.class);
|
||||
workingCopy.setMappedResources(new IResource[] { project });
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,12 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems and others.
|
||||
* Copyright (c) 2016 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.cmake.core.internal;
|
||||
package org.eclipse.cdt.debug.internal.core.launch;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -15,23 +17,28 @@ import org.eclipse.cdt.core.build.ICBuildConfiguration;
|
|||
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
|
||||
import org.eclipse.cdt.core.build.IToolChain;
|
||||
import org.eclipse.cdt.core.build.IToolChainManager;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.utils.Platform;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
|
||||
import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate;
|
||||
|
||||
public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargetedDelegate
|
||||
implements ILaunchConfigurationDelegate {
|
||||
public class CoreBuildLocalRunLaunchDelegate extends LaunchConfigurationTargetedDelegate {
|
||||
|
||||
public static final String TYPE_ID = "org.eclipse.cdt.cmake.core.launchConfigurationType"; //$NON-NLS-1$
|
||||
|
||||
private ICBuildConfigurationManager configManager = Activator.getService(ICBuildConfigurationManager.class);
|
||||
private IToolChainManager tcManager = Activator.getService(IToolChainManager.class);
|
||||
private ICBuildConfigurationManager configManager = CDebugCorePlugin.getService(ICBuildConfigurationManager.class);
|
||||
private IToolChainManager tcManager = CDebugCorePlugin.getService(IToolChainManager.class);
|
||||
|
||||
private IProject getProject(ILaunchConfiguration configuration) throws CoreException {
|
||||
return configuration.getMappedResources()[0].getProject();
|
||||
|
@ -42,14 +49,10 @@ public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargete
|
|||
IProgressMonitor monitor) throws CoreException {
|
||||
// Set active build config based on toolchain for target
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
String os = target.getAttribute(ILaunchTarget.ATTR_OS, ""); //$NON-NLS-1$
|
||||
if (!os.isEmpty()) {
|
||||
properties.put(IToolChain.ATTR_OS, os);
|
||||
}
|
||||
String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, ""); //$NON-NLS-1$
|
||||
if (!arch.isEmpty()) {
|
||||
properties.put(IToolChain.ATTR_ARCH, arch);
|
||||
}
|
||||
properties.put(IToolChain.ATTR_OS, Platform.getOS());
|
||||
properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
|
||||
// TODO should really use real architecture of platform, not what Eclipse is using.
|
||||
// Also on 64-bit platforms, try 32-bit if toolchains not found
|
||||
Collection<IToolChain> tcs = tcManager.getToolChainsMatching(properties);
|
||||
if (!tcs.isEmpty()) {
|
||||
IToolChain toolChain = tcs.iterator().next();
|
||||
|
@ -71,8 +74,30 @@ public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargete
|
|||
@Override
|
||||
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
// TODO need to find the binary and launch it.
|
||||
// Though, more likely, need to have launch configs per binary.
|
||||
IProject project = getProject(configuration);
|
||||
ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget();
|
||||
|
||||
ICBuildConfiguration buildConfig = getBuildConfiguration(project, mode, target, monitor);
|
||||
IBinary[] binaries = buildConfig.getBuildOutput();
|
||||
IBinary exeFile = null;
|
||||
for (IBinary binary : binaries) {
|
||||
if (binary.isExecutable()) {
|
||||
exeFile = binary;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (exeFile == null) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, "No binaries"));
|
||||
}
|
||||
|
||||
try {
|
||||
ProcessBuilder builder = new ProcessBuilder(Paths.get(exeFile.getLocationURI()).toString());
|
||||
buildConfig.setBuildEnvironment(builder.environment());
|
||||
Process process = builder.start();
|
||||
DebugPlugin.newProcess(launch, process, exeFile.getPath().lastSegment());
|
||||
} catch (IOException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, "Error launching", e));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,4 +108,19 @@ public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargete
|
|||
return new IProject[] { project };
|
||||
}
|
||||
|
||||
private ICBuildConfiguration getBuildConfiguration(IProject project, String mode, ILaunchTarget target,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
// Set active build config based on toolchain for target
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
properties.put(IToolChain.ATTR_OS, Platform.getOS());
|
||||
properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
|
||||
Collection<IToolChain> tcs = tcManager.getToolChainsMatching(properties);
|
||||
if (!tcs.isEmpty()) {
|
||||
IToolChain toolChain = tcs.iterator().next();
|
||||
return configManager.getBuildConfiguration(project, toolChain, "run", monitor); //$NON-NLS-1$
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +1,40 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems and others.
|
||||
* Copyright (c) 2016 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.cmake.core.internal;
|
||||
package org.eclipse.cdt.debug.internal.core.launch;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
||||
|
||||
public class CMakeLaunchDescriptor extends PlatformObject implements ILaunchDescriptor {
|
||||
/**
|
||||
* A launch descriptor representing a project built with the new Core Build system.
|
||||
*/
|
||||
public class CoreBuildProjectLaunchDescriptor extends PlatformObject implements ILaunchDescriptor {
|
||||
|
||||
private final CMakeLaunchDescriptorType type;
|
||||
private final IProject project;
|
||||
private final CoreBuildLaunchDescriptorType type;
|
||||
|
||||
public CMakeLaunchDescriptor(CMakeLaunchDescriptorType type, IProject project) {
|
||||
public CoreBuildProjectLaunchDescriptor(CoreBuildLaunchDescriptorType type, IProject project) {
|
||||
this.type = type;
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getAdapter(Class<T> adapter) {
|
||||
if (IProject.class.equals(adapter)) {
|
||||
return (T) project;
|
||||
} else {
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return project.getName();
|
||||
|
@ -32,18 +45,4 @@ public class CMakeLaunchDescriptor extends PlatformObject implements ILaunchDesc
|
|||
return type;
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getAdapter(Class<T> adapter) {
|
||||
if (adapter.equals(IProject.class)) {
|
||||
return (T) project;
|
||||
} else {
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -50,14 +50,16 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
|
|||
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.debug.ui;bundle-version="[3.7.0,4.0.0)",
|
||||
org.eclipse.debug.core;bundle-version="[3.7.0,4.0.0)",
|
||||
org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.1.0)",
|
||||
org.eclipse.cdt.debug.core;bundle-version="[7.0.0,9.0.0)",
|
||||
org.eclipse.cdt.ui;bundle-version="[6.0.0,7.0.0)",
|
||||
org.eclipse.cdt.core;bundle-version="[5.0.0,7.0.0)",
|
||||
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)",
|
||||
org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.core.filesystem,
|
||||
org.eclipse.core.expressions
|
||||
org.eclipse.core.expressions,
|
||||
org.eclipse.launchbar.core;bundle-version="2.0.0",
|
||||
org.eclipse.launchbar.ui;bundle-version="2.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Import-Package: com.ibm.icu.text
|
||||
|
|
|
@ -2560,5 +2560,12 @@
|
|||
type="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext">
|
||||
</propertyTester>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.launchbar.ui.launchBarUIContributions">
|
||||
<descriptorUI
|
||||
descriptorTypeId="org.eclipse.cdt.debug.core.coreBuildDescriptorType"
|
||||
labelProvider="org.eclipse.cdt.debug.internal.ui.launch.CoreBuildLaunchLabelProvider">
|
||||
</descriptorUI>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -112,6 +112,7 @@ public class CDebugImages {
|
|||
public static final String IMG_OBJS_PATH_MAP_ENTRY = NAME_PREFIX + "mapentry_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_COMMON_TAB = NAME_PREFIX + "common_tab.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_ARRAY_PARTITION = NAME_PREFIX + "arraypartition_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_C_APP = NAME_PREFIX + "c_app.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$
|
||||
|
@ -206,6 +207,7 @@ public class CDebugImages {
|
|||
public static final ImageDescriptor DESC_OBJS_COMMON_TAB = createManaged(T_OBJ, IMG_OBJS_COMMON_TAB);
|
||||
public static final ImageDescriptor DESC_OBJS_ARRAY_PARTITION = createManaged(T_OBJ, IMG_OBJS_ARRAY_PARTITION);
|
||||
public static final ImageDescriptor DESC_OBJS_DEBUGGER_CONSOLE_SELECT = createManaged(T_OBJ, IMG_DEBUGGER_CONSOLE_SELECT);
|
||||
public static final ImageDescriptor DESC_OBJS_C_APP = createManaged(T_OBJ, IMG_OBJS_C_APP);
|
||||
public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE = createManaged(T_WIZBAN, IMG_WIZBAN_ADD_SOURCE);
|
||||
public static final ImageDescriptor DESC_WIZBAN_PATH_MAPPING = createManaged(T_WIZBAN, IMG_WIZBAN_PATH_MAPPING);
|
||||
public static final ImageDescriptor DESC_WIZBAN_PATH_MAP_ENTRY = createManaged(T_WIZBAN, IMG_WIZBAN_PATH_MAP_ENTRY);
|
||||
|
@ -289,7 +291,7 @@ public class CDebugImages {
|
|||
try {
|
||||
ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
|
||||
if (fgAvoidSWTErrorMap == null) {
|
||||
fgAvoidSWTErrorMap = new HashMap<String, ImageDescriptor>();
|
||||
fgAvoidSWTErrorMap = new HashMap<>();
|
||||
}
|
||||
fgAvoidSWTErrorMap.put(name, result);
|
||||
if (fgImageRegistry != null) {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.launch;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
public class CoreBuildLaunchLabelProvider extends LabelProvider {
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
if (element instanceof ILaunchDescriptor) {
|
||||
return ((ILaunchDescriptor) element).getName();
|
||||
} else {
|
||||
return super.getText(element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if (element instanceof ILaunchDescriptor) {
|
||||
// TODO different icon for binary
|
||||
return CDebugUIPlugin.getDefault().getImage(CDebugImages.IMG_OBJS_C_APP, CDebugImages.DESC_OBJS_C_APP);
|
||||
} else {
|
||||
return super.getImage(element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true
|
||||
Bundle-Version: 9.0.0.qualifier
|
||||
Bundle-Version: 9.0.1.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
@ -19,8 +19,8 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
|
|||
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.cdt.core;bundle-version="[5.0.0,7.0.0)",
|
||||
org.eclipse.cdt.ui;bundle-version="[6.0.0,7.0.0)",
|
||||
org.eclipse.cdt.debug.core;bundle-version="[7.0.0,8.1.0)",
|
||||
org.eclipse.cdt.debug.ui;bundle-version="[7.0.0,8.2.0)",
|
||||
org.eclipse.cdt.debug.core;bundle-version="[7.0.0,9.0.0)",
|
||||
org.eclipse.cdt.debug.ui;bundle-version="[7.0.0,9.0.0)",
|
||||
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
|
||||
org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>9.0.0-SNAPSHOT</version>
|
||||
<version>9.0.1-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.launch</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<descriptorType
|
||||
class="org.eclipse.cdt.arduino.core.internal.launch.ArduinoLaunchDescriptorType"
|
||||
id="org.eclipse.cdt.arduino.core.descriptorType"
|
||||
priority="5">
|
||||
priority="20">
|
||||
<enablement>
|
||||
<instanceof
|
||||
value="org.eclipse.core.resources.IProject">
|
||||
|
|
Loading…
Add table
Reference in a new issue