Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2016-08-29 21:53:41 +0000
committerDoug Schaefer2016-08-30 04:19:23 +0000
commit22cb5e0d7c4966382d3a9de55185d5d78522b37a (patch)
treeed468f82906b9bc45a8207865e64e19c0036e88b
parent3a9f193816cb1eb130af1da6df436d3afe052480 (diff)
downloadorg.eclipse.cdt-22cb5e0d7c4966382d3a9de55185d5d78522b37a.tar.gz
org.eclipse.cdt-22cb5e0d7c4966382d3a9de55185d5d78522b37a.tar.xz
org.eclipse.cdt-22cb5e0d7c4966382d3a9de55185d5d78522b37a.zip
CMake and build architecture changes to improve launching
Right now launch configuration delegates need to know too much about the specific build system for a project (cmake versus qt, for example) Start decoupling this and test out the theory with CMake. Change-Id: I8a362f16cddca77b37a5ab5920ee19318035d478 (cherry picked from commit 5426847cbbbfb03b944e5a82c80803ab06f48c36)
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainManager.java2
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java29
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java27
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java2
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeToolChainManager.java2
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java17
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java21
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java12
8 files changed, 88 insertions, 24 deletions
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainManager.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainManager.java
index d7879a932c3..a6d11e94582 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainManager.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainManager.java
@@ -26,7 +26,7 @@ public interface ICMakeToolChainManager {
ICMakeToolChainFile getToolChainFile(Path path);
- Collection<ICMakeToolChainFile> getToolChainsFileMatching(Map<String, String> properties);
+ Collection<ICMakeToolChainFile> getToolChainFilesMatching(Map<String, String> properties);
Collection<ICMakeToolChainFile> getToolChainFiles();
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
index 9a2dcfe82c2..6478a621260 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
@@ -71,31 +71,38 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
}
}
- public CMakeBuildConfiguration getCBuildConfiguration(IProject project, Map<String, String> properties,
- String launchMode, IProgressMonitor monitor) throws CoreException {
+ @Override
+ public ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain, String launchMode,
+ IProgressMonitor monitor) throws CoreException {
+ // See if there is one already
for (IBuildConfiguration config : project.getBuildConfigs()) {
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
if (cconfig != null) {
CMakeBuildConfiguration cmakeConfig = cconfig.getAdapter(CMakeBuildConfiguration.class);
- if (cmakeConfig != null && cmakeConfig.getToolChain().matches(properties)) {
- return cmakeConfig;
+ if (cmakeConfig != null && cmakeConfig.getToolChain().equals(toolChain)) {
+ return cconfig;
}
}
}
- Collection<IToolChain> tcs = tcManager.getToolChainsMatching(properties);
- if (tcs.isEmpty()) {
- return null;
+ // get matching toolchain file if any
+ Map<String, String> properties = new HashMap<>();
+ String os = toolChain.getProperty(IToolChain.ATTR_OS);
+ if (os != null && !os.isEmpty()) {
+ properties.put(IToolChain.ATTR_OS, os);
+ }
+ String arch = toolChain.getProperty(IToolChain.ATTR_ARCH);
+ if (!arch.isEmpty()) {
+ properties.put(IToolChain.ATTR_ARCH, arch);
}
- IToolChain toolChain = tcs.iterator().next();
-
ICMakeToolChainFile file = null;
- Collection<ICMakeToolChainFile> files = manager.getToolChainsFileMatching(properties);
+ Collection<ICMakeToolChainFile> files = manager.getToolChainFilesMatching(properties);
if (!files.isEmpty()) {
file = files.iterator().next();
}
- String configName = "cmake." + toolChain.getId(); //$NON-NLS-1$
+ // create config
+ String configName = "cmake." + launchMode + '.' + toolChain.getId(); //$NON-NLS-1$
IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, monitor);
CMakeBuildConfiguration cmakeConfig = new CMakeBuildConfiguration(config, configName, toolChain, file);
configManager.addBuildConfiguration(config, cmakeConfig);
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java
index f698335c046..1d862296f6f 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java
@@ -7,11 +7,14 @@
*******************************************************************************/
package org.eclipse.cdt.cmake.core.internal;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+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.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
@@ -28,6 +31,7 @@ public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargete
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 IProject getProject(ILaunchConfiguration configuration) throws CoreException {
return configuration.getMappedResources()[0].getProject();
@@ -36,10 +40,7 @@ public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargete
@Override
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
IProgressMonitor monitor) throws CoreException {
- // Set active build config based on target
- CMakeBuildConfigurationProvider provider = (CMakeBuildConfigurationProvider) configManager
- .getProvider(CMakeBuildConfigurationProvider.ID);
-
+ // 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()) {
@@ -49,15 +50,21 @@ public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargete
if (!arch.isEmpty()) {
properties.put(IToolChain.ATTR_ARCH, arch);
}
+ Collection<IToolChain> tcs = tcManager.getToolChainsMatching(properties);
+ if (!tcs.isEmpty()) {
+ IToolChain toolChain = tcs.iterator().next();
- IProject project = getProject(configuration);
- CMakeBuildConfiguration config = provider.getCBuildConfiguration(project, properties, mode, monitor);
- if (config != null) {
- IProjectDescription desc = project.getDescription();
- desc.setActiveBuildConfig(config.getBuildConfiguration().getName());
- project.setDescription(desc, monitor);
+ IProject project = getProject(configuration);
+ ICBuildConfiguration config = configManager.createBuildConfiguration(project, toolChain, "run", monitor); //$NON-NLS-1$
+
+ if (config != null) {
+ IProjectDescription desc = project.getDescription();
+ desc.setActiveBuildConfig(config.getBuildConfiguration().getName());
+ project.setDescription(desc, monitor);
+ }
}
+ // proceed with the build
return superBuildForLaunch(configuration, mode, monitor);
}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java
index ffc81526676..bf0e83536ad 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java
@@ -52,7 +52,7 @@ public class CMakeLaunchConfigurationProvider extends AbstractLaunchConfigProvid
Map<String, String> properties = new HashMap<>();
properties.put(IToolChain.ATTR_OS, os);
properties.put(IToolChain.ATTR_ARCH, arch);
- if (manager.getToolChainsFileMatching(properties).isEmpty()) {
+ if (manager.getToolChainFilesMatching(properties).isEmpty()) {
return false;
}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeToolChainManager.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeToolChainManager.java
index 4ac5b957d12..8d1b2c740cb 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeToolChainManager.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeToolChainManager.java
@@ -125,7 +125,7 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
}
@Override
- public Collection<ICMakeToolChainFile> getToolChainsFileMatching(Map<String, String> properties) {
+ public Collection<ICMakeToolChainFile> getToolChainFilesMatching(Map<String, String> properties) {
List<ICMakeToolChainFile> matches = new ArrayList<>();
for (ICMakeToolChainFile file : getToolChainFiles()) {
boolean match = true;
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java
index 34aa66a9457..fd655bc2178 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java
@@ -43,6 +43,23 @@ public interface ICBuildConfigurationManager {
String configName, IProgressMonitor monitor) throws CoreException;
/**
+ * Create a new build configuration for a given project using a given
+ * toolchain and builds for a given launch mode.
+ *
+ * @param project
+ * project for the config
+ * @param toolChain
+ * toolchain the build config will use
+ * @param launchMode
+ * launch mode the buld config will build for
+ * @return new build configuration
+ * @throws CoreException
+ * @since 6.1
+ */
+ ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain, String launchMode,
+ IProgressMonitor monitor) throws CoreException;
+
+ /**
* Called by providers to add new build configurations as they are created.
*
* @param buildConfig
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java
index 40bf781ee0e..6de0c38e49c 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java
@@ -8,7 +8,9 @@
package org.eclipse.cdt.core.build;
import org.eclipse.core.resources.IBuildConfiguration;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
/**
* A CBuildConfigurationProvider provides C build configurations.
@@ -32,4 +34,23 @@ public interface ICBuildConfigurationProvider {
*/
ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException;
+ /**
+ * Create a new build configuration for a given project using a given
+ * toolchain and builds for a given launch mode.
+ *
+ * @param project
+ * project for the config
+ * @param toolChain
+ * toolchain the build config will use
+ * @param launchMode
+ * launch mode the buld config will build for
+ * @return new build configuration or null combination not supported
+ * @throws CoreException
+ * @since 6.1
+ */
+ default ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain,
+ String launchMode, IProgressMonitor monitor) throws CoreException {
+ return null;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java
index ad0105bbcf3..3da80f63bf8 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java
@@ -23,6 +23,7 @@ import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
+import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
@@ -214,6 +215,17 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
}
@Override
+ public ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain,
+ String launchMode, IProgressMonitor monitor) throws CoreException {
+ ICBuildConfigurationProvider provider = getProvider(project);
+ if (provider != null) {
+ return provider.createBuildConfiguration(project, toolChain, launchMode, monitor);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.PRE_CLOSE
|| event.getType() == IResourceChangeEvent.PRE_DELETE) {

Back to the top