Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2016-08-30 15:05:18 +0000
committerDoug Schaefer2016-08-31 16:27:36 +0000
commit37ebb67c2a11cf51cd34a68bd1dc5bb029b82136 (patch)
treee878f83f5f11ca21b83b33a0c80afec1c19b5892
parent22cb5e0d7c4966382d3a9de55185d5d78522b37a (diff)
downloadorg.eclipse.cdt-37ebb67c2a11cf51cd34a68bd1dc5bb029b82136.tar.gz
org.eclipse.cdt-37ebb67c2a11cf51cd34a68bd1dc5bb029b82136.tar.xz
org.eclipse.cdt-37ebb67c2a11cf51cd34a68bd1dc5bb029b82136.zip
Allow participants in CMake toolchain file management.
For ESP8266, I want to auto discover the toolchains and friends installed into Eclipse. I also want to handle toolchain files manually added by the user. Adding providers and listeners. Adds prefix to gcc commands. Makes CMake config provider for Local only. ESP8266 has it's own launch config. Add build output to the build config model. And fix up output folders. Change-Id: I5aa178ff23e27dc24e3efe8e79de2e3a8d692cde
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java8
-rw-r--r--build/org.eclipse.cdt.cmake.core/plugin.xml1
-rw-r--r--build/org.eclipse.cdt.cmake.core/schema/toolChainProvider.exsd102
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java5
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeToolChainEvent.java41
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainListener.java17
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainManager.java4
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainProvider.java14
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java11
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java2
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java26
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeToolChainManager.java54
-rw-r--r--build/org.eclipse.cdt.cmake.ui/plugin.xml1
-rw-r--r--build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java3
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java5
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java27
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java17
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfigurationManager.java2
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java2
19 files changed, 297 insertions, 45 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
index 99c169e941a..8be04d5d92d 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
@@ -73,7 +73,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
this.version = version;
this.name = id + " - " + version; //$NON-NLS-1$
this.path = path;
- this.prefix = prefix;
+ this.prefix = prefix != null ? prefix : "";
if (path != null) {
StringBuilder pathString = new StringBuilder();
@@ -393,15 +393,15 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
@Override
public String[] getCompileCommands() {
- return new String[] { "gcc", "g++", "clang", "clang++", "cc", "c++" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ return new String[] { prefix + "gcc", prefix + "g++", prefix + "clang", prefix + "clang++", prefix + "cc", prefix + "c++" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
@Override
public String[] getCompileCommands(ILanguage language) {
if (GPPLanguage.ID.equals(language.getId())) {
- return new String[] { "g++", "clang++", "c++" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return new String[] { prefix + "g++", prefix + "clang++", prefix + "c++" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else if (GCCLanguage.ID.equals(language.getId())) {
- return new String[] { "gcc", "clang", "cc" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return new String[] { prefix + "gcc", prefix + "clang", prefix + "cc" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else {
return new String[0];
}
diff --git a/build/org.eclipse.cdt.cmake.core/plugin.xml b/build/org.eclipse.cdt.cmake.core/plugin.xml
index 14b2864eb46..2673e5b6d95 100644
--- a/build/org.eclipse.cdt.cmake.core/plugin.xml
+++ b/build/org.eclipse.cdt.cmake.core/plugin.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
+ <extension-point id="toolChainProvider" name="CMake ToolChain File Provider" schema="schema/toolChainProvider.exsd"/>
<extension
id="cmakeNature"
point="org.eclipse.core.resources.natures">
diff --git a/build/org.eclipse.cdt.cmake.core/schema/toolChainProvider.exsd b/build/org.eclipse.cdt.cmake.core/schema/toolChainProvider.exsd
new file mode 100644
index 00000000000..19d844273e3
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.core/schema/toolChainProvider.exsd
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.cmake.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.cdt.cmake.core" id="toolChainProvider" name="CMake ToolChain File Provider"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="provider"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.cmake.core.ICMakeToolChainProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java
index b12a8a694da..82cc0aea8de 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java
@@ -22,7 +22,9 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.tools.templates.freemarker.FMProjectGenerator;
import org.eclipse.tools.templates.freemarker.SourceRoot;
import org.osgi.framework.Bundle;
@@ -68,6 +70,9 @@ public class CMakeProjectGenerator extends FMProjectGenerator {
} else {
entries.add(CoreModel.newSourceEntry(getProject().getFullPath()));
}
+
+ entries.add(CoreModel.newOutputEntry(getProject().getFolder("build").getFullPath(),
+ new IPath[] { new Path("**/CMakeFiles/**") }));
CoreModel.getDefault().create(project).setRawPathEntries(entries.toArray(new IPathEntry[entries.size()]),
monitor);
}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeToolChainEvent.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeToolChainEvent.java
new file mode 100644
index 00000000000..962f1f2accc
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeToolChainEvent.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * Event occured with CMake ToolChain Files, either added or removed.
+ */
+public class CMakeToolChainEvent {
+
+ /**
+ * ToolChain file has been added.
+ */
+ public static final int ADDED = 1;
+
+ /**
+ * ToolChain File has been removed.
+ */
+ public static final int REMOVED = 2;
+
+ private final int type;
+ private final ICMakeToolChainFile toolChainFile;
+
+ public CMakeToolChainEvent(int type, ICMakeToolChainFile toolChainFile) {
+ this.type = type;
+ this.toolChainFile = toolChainFile;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public ICMakeToolChainFile getToolChainFile() {
+ return toolChainFile;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainListener.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainListener.java
new file mode 100644
index 00000000000..447fe68fee5
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainListener.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * Listener for toolchain events.
+ */
+public interface ICMakeToolChainListener {
+
+ void handleCMakeToolChainEvent(CMakeToolChainEvent event);
+
+}
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 a6d11e94582..b522fb1d0ef 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
@@ -30,4 +30,8 @@ public interface ICMakeToolChainManager {
Collection<ICMakeToolChainFile> getToolChainFiles();
+ void addListener(ICMakeToolChainListener listener);
+
+ void removeListener(ICMakeToolChainListener listener);
+
}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainProvider.java
new file mode 100644
index 00000000000..1620c5995f3
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/ICMakeToolChainProvider.java
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * 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;
+
+public interface ICMakeToolChainProvider {
+
+ void init(ICMakeToolChainManager manager);
+
+}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
index 6efa8bf43ae..9db982f7ce4 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-// * Copyright (c) 2015, 2016 QNX Software Systems and others.
+ * Copyright (c) 2015, 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
@@ -28,10 +28,13 @@ 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;
@@ -96,7 +99,8 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
if (!Files.exists(buildDir.resolve("Makefile"))) { //$NON-NLS-1$
List<String> command = new ArrayList<>();
- // TODO assuming cmake is in the path here, probably need a preference in case it isn't.
+ // TODO assuming cmake is in the path here, probably need a
+ // preference in case it isn't.
Path cmakePath = CBuildConfiguration.getCommandFromPath(Paths.get("cmake")); //$NON-NLS-1$
if (cmakePath == null) {
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
@@ -127,7 +131,8 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
getToolChain().getErrorParserIds())) {
- // TODO need to figure out which builder to call. Hardcoding to make for now.
+ // TODO need to figure out which builder to call. Hardcoding to
+ // make for now.
List<String> command = Arrays.asList("make"); //$NON-NLS-1$
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile());
setBuildEnvironment(processBuilder.environment());
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 1d862296f6f..a2a5435d23f 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
@@ -55,7 +55,7 @@ public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargete
IToolChain toolChain = tcs.iterator().next();
IProject project = getProject(configuration);
- ICBuildConfiguration config = configManager.createBuildConfiguration(project, toolChain, "run", monitor); //$NON-NLS-1$
+ ICBuildConfiguration config = configManager.getBuildConfiguration(project, toolChain, "run", monitor); //$NON-NLS-1$
if (config != null) {
IProjectDescription desc = project.getDescription();
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 bf0e83536ad..adf1bb8d358 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
@@ -28,35 +28,11 @@ import org.eclipse.launchbar.core.target.ILaunchTargetManager;
public class CMakeLaunchConfigurationProvider extends AbstractLaunchConfigProvider {
- private final ICMakeToolChainManager manager = Activator.getService(ICMakeToolChainManager.class);
- private final IToolChainManager tcManager = Activator.getService(IToolChainManager.class);
-
private Map<IProject, ILaunchConfiguration> configs = new HashMap<>();
@Override
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
- if (ILaunchTargetManager.localLaunchTargetTypeId.equals(target.getTypeId())) {
- return true;
- }
-
- String os = target.getAttribute(ILaunchTarget.ATTR_OS, ""); //$NON-NLS-1$
- if (os.isEmpty()) {
- return false;
- }
-
- String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, ""); //$NON-NLS-1$
- if (arch.isEmpty()) {
- return false;
- }
-
- Map<String, String> properties = new HashMap<>();
- properties.put(IToolChain.ATTR_OS, os);
- properties.put(IToolChain.ATTR_ARCH, arch);
- if (manager.getToolChainFilesMatching(properties).isEmpty()) {
- return false;
- }
-
- return !tcManager.getToolChainsMatching(properties).isEmpty();
+ return ILaunchTargetManager.localLaunchTargetTypeId.equals(target.getTypeId());
}
@Override
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 8d1b2c740cb..15c42839b5d 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
@@ -13,12 +13,22 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import org.eclipse.cdt.cmake.core.CMakeToolChainEvent;
import org.eclipse.cdt.cmake.core.ICMakeToolChainFile;
+import org.eclipse.cdt.cmake.core.ICMakeToolChainListener;
import org.eclipse.cdt.cmake.core.ICMakeToolChainManager;
+import org.eclipse.cdt.cmake.core.ICMakeToolChainProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@@ -30,6 +40,8 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
private static final String N = "n"; //$NON-NLS-1$
private static final String PATH = "__path"; //$NON-NLS-1$
+ private final List<ICMakeToolChainListener> listeners = new LinkedList<>();
+
private Preferences getPreferences() {
return InstanceScope.INSTANCE.getNode(Activator.getId()).node("cmakeToolchains"); //$NON-NLS-1$
}
@@ -57,6 +69,19 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
}
// TODO discovery
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.getId(),
+ "toolChainProvider"); //$NON-NLS-1$
+ for (IConfigurationElement element : point.getConfigurationElements()) {
+ if (element.getName().equals("provider")) { //$NON-NLS-1$
+ try {
+ ICMakeToolChainProvider provider = (ICMakeToolChainProvider) element
+ .createExecutableExtension("class"); //$NON-NLS-1$
+ provider.init(this);
+ } catch (ClassCastException | CoreException e) {
+ Activator.log(e);
+ }
+ }
+ }
}
}
@@ -92,11 +117,14 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
} catch (BackingStoreException e) {
Activator.log(e);
}
+
+ fireEvent(new CMakeToolChainEvent(CMakeToolChainEvent.ADDED, file));
}
@Override
public void removeToolChainFile(ICMakeToolChainFile file) {
init();
+ fireEvent(new CMakeToolChainEvent(CMakeToolChainEvent.REMOVED, file));
files.remove(file.getPath());
String n = ((CMakeToolChainFile) file).n;
@@ -143,4 +171,30 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
return matches;
}
+ @Override
+ public void addListener(ICMakeToolChainListener listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ public void removeListener(ICMakeToolChainListener listener) {
+ listeners.remove(listener);
+ }
+
+ private void fireEvent(CMakeToolChainEvent event) {
+ for (ICMakeToolChainListener listener : listeners) {
+ SafeRunner.run(new ISafeRunnable() {
+ @Override
+ public void run() throws Exception {
+ listener.handleCMakeToolChainEvent(event);
+ }
+
+ @Override
+ public void handleException(Throwable exception) {
+ Activator.log(exception);
+ }
+ });
+ }
+ }
+
}
diff --git a/build/org.eclipse.cdt.cmake.ui/plugin.xml b/build/org.eclipse.cdt.cmake.ui/plugin.xml
index c76595197c8..09a01d710fb 100644
--- a/build/org.eclipse.cdt.cmake.ui/plugin.xml
+++ b/build/org.eclipse.cdt.cmake.ui/plugin.xml
@@ -23,6 +23,7 @@
<extension
point="org.eclipse.ui.preferencePages">
<page
+ category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.cmake.ui.internal.CMakePreferencePage"
id="org.eclipse.cdt.cmake.ui.page1"
name="%cmake.preferences.name">
diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
index e6cae98fb80..94406b75ac5 100644
--- a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
+++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
@@ -184,6 +184,9 @@ public class CMakePreferencePage extends PreferencePage implements IWorkbenchPre
manager.removeToolChainFile(file);
}
+ filesToAdd.clear();
+ filesToRemove.clear();
+
return true;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
index b82751612b9..346a9b70c65 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
@@ -153,7 +153,10 @@ public class BinaryRunner {
*/
public void waitIfRunning() {
try {
- runnerJob.join();
+ Job currentJob = Job.getJobManager().currentJob();
+ if (currentJob != null && !currentJob.equals(runnerJob)) {
+ runnerJob.join();
+ }
} catch (InterruptedException e) {
}
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
index 9f056db9cd1..28b5020222e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
@@ -36,6 +36,8 @@ import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.ProblemMarkerInfo;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.model.ICProject;
@@ -58,6 +60,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -174,15 +177,7 @@ public abstract class CBuildConfiguration extends PlatformObject
}
IFolder buildFolder = buildRootFolder.getFolder(name);
if (!buildFolder.exists()) {
- buildFolder.create(true, true, new NullProgressMonitor());
- buildFolder.setDerived(true, null);
- ICProject cproject = CoreModel.getDefault().create(getProject());
- IOutputEntry output = CoreModel.newOutputEntry(buildFolder.getFullPath());
- IPathEntry[] oldEntries = cproject.getRawPathEntries();
- IPathEntry[] newEntries = new IPathEntry[oldEntries.length + 1];
- System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
- newEntries[oldEntries.length] = output;
- cproject.setRawPathEntries(newEntries, null);
+ buildFolder.create(IResource.FORCE | IResource.DERIVED, true, new NullProgressMonitor());
}
return buildFolder;
@@ -200,6 +195,20 @@ public abstract class CBuildConfiguration extends PlatformObject
CCorePlugin.getDefault().getBuildEnvironmentManager().setEnvironment(env, config, true);
}
+ @Override
+ public IBinary[] getBuildOutput() throws CoreException {
+ ICProject cproject = CoreModel.getDefault().create(config.getProject());
+ IBinaryContainer binaries = cproject.getBinaryContainer();
+ IPath outputPath = getBuildContainer().getFullPath();
+ List<IBinary> outputs = new ArrayList<>();
+ for (IBinary binary : binaries.getBinaries()) {
+ if (binary.isExecutable() && outputPath.isPrefixOf(binary.getPath())) {
+ outputs.add(binary);
+ }
+ }
+ return outputs.toArray(new IBinary[outputs.size()]);
+ }
+
public void setActive(IProgressMonitor monitor) throws CoreException {
IProject project = config.getProject();
if (config.equals(project.getActiveBuildConfig())) {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java
index 59b8a8731f0..dc622120fe9 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java
@@ -10,6 +10,7 @@ package org.eclipse.cdt.core.build;
import java.util.Map;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.core.resources.IBuildConfiguration;
@@ -59,4 +60,20 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider {
void clean(IConsole console, IProgressMonitor monitor) throws CoreException;
+ /**
+ * @return build output IContainer
+ * @throws CoreException
+ * @since 6.1
+ */
+ default IBinary[] getBuildOutput() throws CoreException {
+ return null;
+ }
+
+ /**
+ *
+ * @param env
+ * @since 6.1
+ */
+ default void setBuildEnvironment(Map<String, String> env) {
+ }
}
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 fd655bc2178..44532edd952 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
@@ -56,7 +56,7 @@ public interface ICBuildConfigurationManager {
* @throws CoreException
* @since 6.1
*/
- ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain, String launchMode,
+ ICBuildConfiguration getBuildConfiguration(IProject project, IToolChain toolChain, String launchMode,
IProgressMonitor monitor) throws CoreException;
/**
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 3da80f63bf8..a68e2287b5d 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
@@ -215,7 +215,7 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
}
@Override
- public ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain,
+ public ICBuildConfiguration getBuildConfiguration(IProject project, IToolChain toolChain,
String launchMode, IProgressMonitor monitor) throws CoreException {
ICBuildConfigurationProvider provider = getProvider(project);
if (provider != null) {

Back to the top