Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeff Johnston2017-02-09 23:43:05 +0000
committerJeff Johnston2017-10-22 09:38:51 +0000
commitc96d126b86382356caec9b8ee961e37b84313f6b (patch)
treef48f38e68d303c6d8c7d9f1b30d22f3c8ea3c59e /core
parent4c1a6e0ccd90da71cb6d2e7cacfc284a07b180b8 (diff)
downloadorg.eclipse.cdt-c96d126b86382356caec9b8ee961e37b84313f6b.tar.gz
org.eclipse.cdt-c96d126b86382356caec9b8ee961e37b84313f6b.tar.xz
org.eclipse.cdt-c96d126b86382356caec9b8ee961e37b84313f6b.zip
Bug 513589 - Add support to build CDT projects in a Docker Container
- add IOptionalBuildObjectPropertiesContainer interface to use for objects that supply optional build properties - add new IOptionalBuildProperties interface that defines optional build properties donated by external plug-ins - add new - change IConfiguration to an IOptionalBuildObjectPropertiesContainer - change IManagedProject to be an IOptionalBuildObjectPropertiesContainer - fix ProcessClosure to ensure that readers are not null before accessing them - fix Container launch delegate to look at project optional build properties for active configuration to fetch connection and image info and use said info to find a matching launch or create a new one - have Container launch delegate use the image name as part of the launch config name - have Container launch short-cut also use the project's optional build properties for the active config to get connection and image information before any defaulting - change AutotoolsNewMarkerGenerator to store the command launcher as an ICommandLauncher - add new CommandLauncherFactory extension to cdt.core that allows plug-ins to specify a CommandLauncherFactory that will return an ICommandLauncher based on the project - add macros for new extension to CCorePlugin - add new CommandLauncherManager class that loads CommandLauncherFactory extensions and is used to give an ICommandLauncher wrapper that will go through the list of CommandLauncherFactory extensions until one returns non-null ICommandLauncher - add code to RemoteCommandLauncher so it will use the CommandLauncherManager to get the local launcher - also change RemoteCommandLauncher to check at execution time whether the command is local and in that case use the local command launcher - add new ICommandLauncherFactory interface - add new ContainerCommandLauncher to launch - add new ContainerCommandLauncherFactory class for returning a ContainerCommandLauncher instance to launch commands in a Docker Container - change MakeBuilder to use CommandLauncherManager to get its ICommandLauncher - change CommandBuilder to use CommandLauncherManager too - ditto for Builder and AbstractBuiltinSpecsDetector and ExternalToolInvoker - change Configuration to load/store optional build properties as well as return the properties to get/set - ditto for MultiConfiguration - change ManagedProject to implement IOptionalBuildOptionProperties interface - ditto for ProjectType - create new OptionalBuildProperties class to store optional build properties for a configuration - bump cdt.docker.launcher to 1.1.0 - use CommandLauncherFactory extension to define ContainerCommandLauncherFactory - add optional ContainerPropertyTab which allows the end-user to optionally choose to build a C/C++ project in a Container and specify the connection/image to use - in LanguageSettingsSerializableSettings class, call the CommandLauncherManager getLanguageSettingEntries method to get the massaged language setting entries based on the current list - in LanguageSettingsProviderSerializer, try and get the pooled entries using the cfg description so that it will have the project and can use the CommandLauncherManager to get entries from image - in ContainerCommandLauncherFactory move cached headers under a HEADERS directory in the plug-in area - create a sub-directory for the connection and a sub-directory for the image based on cleansed names - store the real names of the connection and image to use later in the DockerHeaderPreferencePage - modify LanguageSettingsEntriesTab to force the horizontal scroll bar to appear (this is a bug in SWT SashForm support and the fix here isn't quite correct, but is better) - add new DockerHeaderPreferencePage that allows user to remove cached headers from images - change C/C++ Docker preferences to be titled: Docker Container - fix LanguageSettingsWorkspaceProvider.getSettingEntries method to use the CommandLauncherManager so entries will be transformed to use cached headers - add BaseDatabindingModel class - add DataVolumeModel class to model a volume mount - add ContainerPropertyVolumes model to model volume specification and selected volumes - add properties to ContainerCommandLauncher to represent volumes and selected volumes for a configuration - add ContainerDataVolumeDialog for specifying a volume mount by the end-user - add a null detector for cfgDescription in LanguageSettingsSerializableProvider - fix AutotoolsNewMakeGenerator.getWinOSType to not specify "." for working dir - fix GCCBuiltinSpecsDetectorCygwin to not map paths to Cygwin if the current configuration is enabled for container build - add logic to ContainerCommandLauncher to look for Windows file formats and change them to unix format and map any "." working dir to be /tmp - fix ContainerLauncherConfigurationDelegate similarly - fix AbstractBuiltinSpecsDetector to pass in the current configuration description when getting the CommandLauncher since the current configuration may not be the active configuration - change ContainerPropertyTab to add Elf and GNU Elf binary parsers when build in Container is chosen so that output executables are treated as Binaries by the CDT project - add documentationl for the ContainerPropertyTab in Build Settings and the Data Volume dialog pop-up it brings up - change CommandBuilder to accept a project as an argument to its constructor and to pass this as an argument to the CommandLauncherManager - have StepBuilder pass project when creating a CommandBuilder Change-Id: Ia78488b93056e6ec7ca83a6c87b3a9d2b9424943
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java8
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java9
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml1
-rw-r--r--core/org.eclipse.cdt.core/schema/CommandLauncherFactory.exsd128
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java11
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherManager.java288
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java54
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java11
10 files changed, 519 insertions, 11 deletions
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
index a6c0a5d2551..db644fd1d62 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
@@ -221,9 +221,11 @@ public class CModelMock {
*/
public static class DummyCConfigurationDescription implements ICConfigurationDescription {
private String id;
+ private ICProjectDescription projectDescription;
public DummyCConfigurationDescription(String id) {
this.id = id;
+ this.projectDescription = new DummyCProjectDescription();
}
@Override
@@ -302,7 +304,7 @@ public class CModelMock {
@Override
public ICProjectDescription getProjectDescription() {
- return null;
+ return projectDescription;
}
@Override
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java
index 839f80e4c60..f14594d452d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java
@@ -17,6 +17,7 @@ import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.internal.core.XmlUtil;
@@ -146,6 +147,9 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
List<? extends ICLanguageSettingEntry> entries) {
String rcProjectPath = rc!=null ? rc.getProjectRelativePath().toString() : null;
fStorage.setSettingEntries(rcProjectPath, languageId, entries);
+ if (cfgDescription != null) {
+ CommandLauncherManager.getInstance().setLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries);
+ }
}
/**
@@ -167,6 +171,10 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
entries = fStorage.getSettingEntries(rcProjectPath, null);
}
}
+
+ if (cfgDescription != null) {
+ entries = CommandLauncherManager.getInstance().getLanguageSettingEntries(cfgDescription.getProjectDescription().getProject(), entries);
+ }
return entries;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java
index 1338d2b704d..cbb1001c69f 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java
@@ -20,6 +20,7 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.language.settings.providers.ICListenerAgent;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsBroadcastingProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeEvent;
@@ -178,6 +179,10 @@ public class LanguageSettingsProvidersSerializer {
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
ILanguageSettingsProvider rawProvider = getRawProvider();
List<ICLanguageSettingEntry> entries = rawProvider!=null ? rawProvider.getSettingEntries(cfgDescription, rc, languageId) : null;
+ if (cfgDescription != null) {
+ IProject project = cfgDescription.getProjectDescription().getProject();
+ entries = CommandLauncherManager.getInstance().getLanguageSettingEntries(project, entries);
+ }
return entries;
}
@@ -1456,6 +1461,10 @@ public class LanguageSettingsProvidersSerializer {
return getSettingEntriesUpResourceTree(provider, cfgDescription, parentFolder, languageId);
}
// if out of parent resources - get default entries
+ entries = getSettingEntriesPooled(provider, cfgDescription, null, languageId);
+ if (entries != null) {
+ return entries;
+ }
entries = getSettingEntriesPooled(provider, null, null, languageId);
if (entries != null) {
return entries;
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index 81354a3bcb3..086b08d5efe 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -692,6 +692,7 @@
<extension-point id="ProblemMarkerFilter" name="%problemMarkerFilter.name" schema="schema/ProblemMarkerFilter.exsd"/>
<extension-point id="buildConfigProvider" name="buildConfigProvider" schema="schema/buildConfigProvider.exsd"/>
<extension-point id="toolChainProvider" name="Tool Chain Provider" schema="schema/toolChainProvider.exsd"/>
+ <extension-point id="CommandLauncherFactory" name="CommandLauncherFactory" schema="schema/CommandLauncherFactory.exsd"/>
<extension
point="org.eclipse.cdt.core.templateProcessTypes">
diff --git a/core/org.eclipse.cdt.core/schema/CommandLauncherFactory.exsd b/core/org.eclipse.cdt.core/schema/CommandLauncherFactory.exsd
new file mode 100644
index 00000000000..a4b0564eb18
--- /dev/null
+++ b/core/org.eclipse.cdt.core/schema/CommandLauncherFactory.exsd
@@ -0,0 +1,128 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core" id="CommandLauncherFactory" name="CommandLauncherFactory"/>
+ </appInfo>
+ <documentation>
+ This extension point is used to contribute a Command Launcher factory to CDT. A Command Launcher factory creates a Command Launcher for running commands.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="factory"/>
+ </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="factory">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string" use="default" value="0">
+ <annotation>
+ <documentation>
+ Integer priority of factory. Default is 0. Use higher values if you want to override an existing factory.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+ Command Launcher factory class that implements org.eclipse.cdt.core.ICommandLauncherFactory.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.ICommandLauncherFactory"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ CDT 9.4.0
+ </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>
+ Plug-ins that want to extend this extension point must implement &lt;samp&gt;org.eclipse.cdt.core.ICommandLauncherFactory&lt;/samp&gt; interface.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2017 Red Hat Inc. and others.&lt;br/&gt;
+All rights reserved. This program and the accompanying materials&lt;br/&gt;
+are made available under the terms of the Eclipse Public License v1.0&lt;br/&gt;
+which accompanies this distribution, and is available at&lt;br/&gt;
+http://www.eclipse.org/legal/epl-v10.html&lt;br/&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
index b639dee57cf..ab980ee9876 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
@@ -156,6 +156,17 @@ public class CCorePlugin extends Plugin {
*/
public static final String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$
+ /**
+ * Name of the extension point for contributing a Command Launcher factory
+ * @since 6.3
+ */
+ public static final String COMMAND_LAUNCHER_FACTORY_SIMPLE_ID = "CommandLauncherFactory"; //$NON-NLS-1$
+ /**
+ * Full unique name of the extension point for contributing a Command Launcher factory
+ * @since 6.3
+ */
+ public static final String COMMAND_LAUNCHER_FACTORY_UNIQ_ID = PLUGIN_ID + "." + COMMAND_LAUNCHER_FACTORY_SIMPLE_ID; //$NON-NLS-1$
+
// default store for pathentry
public static final String DEFAULT_PATHENTRY_STORE_ID = PLUGIN_ID + ".cdtPathEntryStore"; //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherManager.java
new file mode 100644
index 00000000000..ad70f104cc8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherManager.java
@@ -0,0 +1,288 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Red Hat Inc. 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
+ *
+ * Contributors:
+ * Red Hat Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core;
+
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * @since 6.3
+ */
+public class CommandLauncherManager {
+
+ private static CommandLauncherManager instance;
+
+ private List<ICommandLauncherFactory> factories = new ArrayList<>();
+ private Map<ICommandLauncherFactory, Integer> priorityMapping = new HashMap<>();
+
+ private CommandLauncherManager() {
+ loadCommandLauncherFactoryExtensions();
+ }
+
+ public static synchronized CommandLauncherManager getInstance() {
+ if (instance == null) {
+ instance = new CommandLauncherManager();
+ }
+ return instance;
+ }
+
+ public ICommandLauncher getCommandLauncher() {
+ return new CommandLauncherWrapper(this);
+ }
+
+
+ private class CommandLauncherWrapper implements ICommandLauncher {
+
+ private ICommandLauncher launcher;
+ private IProject fProject;
+ private boolean fShowCommand;
+ private String fErrorMessage;
+ private CommandLauncherManager manager;
+
+ public CommandLauncherWrapper(CommandLauncherManager manager) {
+ this.manager = manager;
+ }
+
+ @Override
+ public void setProject(IProject project) {
+ if (launcher != null) {
+ launcher.setProject(project);
+ } else {
+ fProject = project;
+ }
+ }
+
+ @Override
+ public IProject getProject() {
+ if (launcher != null) {
+ return launcher.getProject();
+ }
+ return fProject;
+ }
+
+ @Override
+ public void showCommand(boolean show) {
+ if (launcher != null) {
+ launcher.showCommand(show);
+ } else {
+ fShowCommand = show;
+ }
+ }
+
+ @Override
+ public String getErrorMessage() {
+ if (launcher != null) {
+ return launcher.getErrorMessage();
+ }
+ return fErrorMessage;
+ }
+
+ @Override
+ public void setErrorMessage(String error) {
+ if (launcher != null) {
+ launcher.setErrorMessage(error);
+ } else {
+ fErrorMessage = error;
+ }
+ }
+
+ @Override
+ public String[] getCommandArgs() {
+ if (launcher != null) {
+ return launcher.getCommandArgs();
+ }
+ return new String[0];
+ }
+
+ @Override
+ public Properties getEnvironment() {
+ if (launcher != null) {
+ return launcher.getEnvironment();
+ }
+ return null;
+ }
+
+ @Override
+ public String getCommandLine() {
+ if (launcher != null) {
+ return launcher.getCommandLine();
+ }
+ return null;
+ }
+
+ @Override
+ public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory,
+ IProgressMonitor monitor) throws CoreException {
+ if (launcher == null) {
+ launcher = manager.getCommandLauncher(fProject);
+ launcher.setProject(fProject);
+ launcher.showCommand(fShowCommand);
+ launcher.setErrorMessage(fErrorMessage);
+ }
+ return launcher.execute(commandPath, args, env, workingDirectory, monitor);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public int waitAndRead(OutputStream out, OutputStream err) {
+ if (launcher != null) {
+ return launcher.waitAndRead(out, err);
+ }
+ return 0;
+ }
+
+ @Override
+ public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
+ if (launcher != null) {
+ return launcher.waitAndRead(output, err, monitor);
+ }
+ return 0;
+ }
+
+ }
+
+
+ /**
+ * Get a command launcher.
+ *
+ * @param project - IProject to determine launcher for.
+ * @return an ICommandLauncher for running commands
+ */
+ public ICommandLauncher getCommandLauncher(IProject project) {
+ // loop through list of factories and return launcher returned with
+ // highest priority
+ int highestPriority = -1;
+ ICommandLauncher bestLauncher = null;
+ for (ICommandLauncherFactory factory : factories) {
+ ICommandLauncher launcher = factory.getCommandLauncher(project);
+ if (launcher != null) {
+ if (priorityMapping.get(factory) > highestPriority) {
+ bestLauncher = launcher;
+ }
+ }
+ }
+ if (bestLauncher != null) {
+ return bestLauncher;
+ }
+ // default to local CommandLauncher
+ return new CommandLauncher();
+ }
+
+ /**
+ * Get a command launcher.
+ *
+ * @param cfgd - ICConfigurationDescription to get command launcher for.
+ * @return an ICommandLauncher for running commands
+ */
+ public ICommandLauncher getCommandLauncher(ICConfigurationDescription cfgd) {
+ // loop through list of factories and return launcher returned with
+ // highest priority
+ int highestPriority = -1;
+ ICommandLauncher bestLauncher = null;
+ for (ICommandLauncherFactory factory : factories) {
+ ICommandLauncher launcher = factory.getCommandLauncher(cfgd);
+ if (launcher != null) {
+ if (priorityMapping.get(factory) > highestPriority) {
+ bestLauncher = launcher;
+ }
+ }
+ }
+ if (bestLauncher != null) {
+ return bestLauncher;
+ }
+ // default to local CommandLauncher
+ return new CommandLauncher();
+ }
+
+ /**
+ * Load command launcher factory contributed extensions from extension registry.
+ *
+ */
+ private void loadCommandLauncherFactoryExtensions() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extension = registry.getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.COMMAND_LAUNCHER_FACTORY_SIMPLE_ID);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ for (IExtension ext : extensions) {
+ try {
+ IConfigurationElement element[] = ext.getConfigurationElements();
+ for (IConfigurationElement element2 : element) {
+ if (element2.getName().equalsIgnoreCase("factory")) { //$NON-NLS-1$
+ ICommandLauncherFactory factory = (ICommandLauncherFactory) element2.createExecutableExtension("class"); //$NON-NLS-1$
+ String priorityAttr = element2.getAttribute("priority"); //$NON-NLS-1$
+ int priority = Integer.valueOf(0);
+ if (priorityAttr != null) {
+ try {
+ priority = Integer.valueOf(priorityAttr);
+ } catch (NumberFormatException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ factories.add(factory);
+ priorityMapping.put(factory, priority);
+ }
+ }
+ } catch (Exception e) {
+ CCorePlugin.log("Cannot load CommandLauncherFactory extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ private ICommandLauncherFactory getBestFactory(IProject project) {
+ // loop through list of factories and return launcher returned with
+ // highest priority
+ int highestPriority = -1;
+ ICommandLauncherFactory bestLauncherFactory = null;
+ for (ICommandLauncherFactory factory : factories) {
+ ICommandLauncher launcher = factory.getCommandLauncher(project);
+ if (launcher != null) {
+ if (priorityMapping.get(factory) > highestPriority) {
+ bestLauncherFactory = factory;
+ }
+ }
+ }
+ return bestLauncherFactory;
+ }
+
+ public void setLanguageSettingEntries(IProject project, List<? extends ICLanguageSettingEntry> entries) {
+ ICommandLauncherFactory factory = getBestFactory(project);
+ if (factory != null) {
+ factory.registerLanguageSettingEntries(project, entries);
+ }
+ }
+
+ public List<ICLanguageSettingEntry> getLanguageSettingEntries(IProject project, List<ICLanguageSettingEntry> entries) {
+ List<ICLanguageSettingEntry> verifiedEntries = entries;
+ ICommandLauncherFactory factory = getBestFactory(project);
+ if (factory != null) {
+ verifiedEntries = factory.verifyLanguageSettingEntries(project, entries);
+ }
+ return verifiedEntries;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java
new file mode 100644
index 00000000000..7da2397e784
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Red Hat Inc. 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
+ *
+ * Contributors:
+ * Red Hat Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.core.resources.IProject;
+
+/**
+ * @since 6.3
+ */
+public interface ICommandLauncherFactory {
+
+ /**
+ * Get a Command Launcher for a project (based on active configuration)
+ * @param project - IProject to get command launcher for
+ * @return ICommandLauncher
+ */
+ public ICommandLauncher getCommandLauncher(IProject project);
+
+ /**
+ * Get a Command Launcher for a build configuration descriptor
+ * @param cfgd - ICConfigurationDescription to get command launcher for
+ * @return ICommandLauncher
+ */
+ public ICommandLauncher getCommandLauncher(ICConfigurationDescription cfgd);
+
+ /**
+ * Register language setting entries for a project
+ * @param project - IProject used in obtaining language setting entries
+ * @param entries - List of language setting entries
+ */
+ public void registerLanguageSettingEntries(IProject project, List<? extends ICLanguageSettingEntry> entries);
+
+ /**
+ * Verify language setting entries for a project and change any entries that
+ * have been copied to a local location
+ * @param project - IProject used in obtaining language setting entries
+ * @param entries - List of language setting entries
+ * @return modified List of language setting entries
+ */
+ public List<ICLanguageSettingEntry> verifyLanguageSettingEntries(IProject project, List<ICLanguageSettingEntry> entries);
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java
index 771cb6e4b0b..668457e1d75 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProcessClosure.java
@@ -217,14 +217,18 @@ public class ProcessClosure {
fProcess.destroy();
fProcess = null;
}
- if (!fOutputReader.finished()) {
- fOutputReader.waitFor();
+ if (fOutputReader != null) {
+ if (!fOutputReader.finished()) {
+ fOutputReader.waitFor();
+ }
+ fOutputReader.close();
}
- if (!fErrorReader.finished()) {
- fErrorReader.waitFor();
+ if (fErrorReader != null) {
+ if (!fErrorReader.finished()) {
+ fErrorReader.waitFor();
+ }
+ fErrorReader.close();
}
- fOutputReader.close();
- fErrorReader.close();
fOutputReader = null;
fErrorReader = null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
index 91851f784b4..a7c5be0c706 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
@@ -28,6 +28,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
@@ -39,6 +40,7 @@ import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -375,7 +377,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
*/
private void createTreeForEntries(Composite parent) {
treeEntries = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
- treeEntries.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ treeEntries.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.GRAB_HORIZONTAL));
treeEntries.setHeaderVisible(true);
treeEntries.setLinesVisible(true);
@@ -383,13 +385,14 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
treeEntries.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
- int x = treeEntries.getClientArea().width;
- if (treeCol.getWidth() != x)
- treeCol.setWidth(x);
+ Point p = treeEntries.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ if (treeCol.getWidth() != p.x)
+ treeCol.setWidth(p.x);
}
});
treeCol.setText(Messages.LanguageSettingsProviderTab_SettingEntries);
+
treeCol.setWidth(200);
treeCol.setResizable(false);
treeCol.setToolTipText(Messages.LanguageSettingsProviderTab_SettingEntriesTooltip);

Back to the top