Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-11-07 03:39:52 +0000
committerDoug Schaefer2017-11-07 16:01:15 +0000
commit76e1842644f2af46213ab01a8a428a234d965f39 (patch)
tree1af6f003245263d6a4dff10e15d432fa69bc1c80 /core/org.eclipse.cdt.core
parent9a9e80e115dc943e9964b238d9b9697682d47e6a (diff)
downloadorg.eclipse.cdt-76e1842644f2af46213ab01a8a428a234d965f39.tar.gz
org.eclipse.cdt-76e1842644f2af46213ab01a8a428a234d965f39.tar.xz
org.eclipse.cdt-76e1842644f2af46213ab01a8a428a234d965f39.zip
Implement ordering of toolchains.
Introduce toolchain types independent of providers. Change-Id: I2cf3145920fcf4e7132468b6e653d7ea3e211127
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/.settings/.api_filters151
-rw-r--r--core/org.eclipse.cdt.core/schema/toolChainProvider.exsd241
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java8
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java14
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java32
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java16
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java196
7 files changed, 364 insertions, 294 deletions
diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters
index 3f75336083e..cc9a57dda17 100644
--- a/core/org.eclipse.cdt.core/.settings/.api_filters
+++ b/core/org.eclipse.cdt.core/.settings/.api_filters
@@ -1,74 +1,77 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.cdt.core" version="2">
- <resource path="src/org/eclipse/cdt/core/build/ICBuildConfiguration.java" type="org.eclipse.cdt.core.build.ICBuildConfiguration">
- <filter id="403767336">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="TOOLCHAIN_ID"/>
- </message_arguments>
- </filter>
- <filter id="403767336">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="TOOLCHAIN_TYPE"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="getLaunchMode()"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="getProperty(String)"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="removeProperty(String)"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
- <message_argument value="setProperty(String, String)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java" type="org.eclipse.cdt.core.build.ICBuildConfigurationProvider">
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/>
- <message_argument value="getSupportedToolchains(Collection&lt;IToolChain&gt;)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/cdt/core/build/IToolChainProvider.java" type="org.eclipse.cdt.core.build.IToolChainProvider">
- <filter comment="This interface is still pretty new. Assuming low risk." id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
- <message_argument value="addToolChain(IToolChain)"/>
- </message_arguments>
- </filter>
- <filter id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
- <message_argument value="getToolChain(String)"/>
- </message_arguments>
- </filter>
- <filter comment="Newish interface. Assuming low risk." id="404000815">
- <message_arguments>
- <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
- <message_argument value="removeToolChain(IToolChain)"/>
- </message_arguments>
- </filter>
- <filter comment="This is a newish interface. Assuming low risk." id="1211105284">
- <message_arguments>
- <message_argument value="removeToolChain(IToolChain)"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.cdt.core" version="2">
+ <resource path="src/org/eclipse/cdt/core/build/ICBuildConfiguration.java" type="org.eclipse.cdt.core.build.ICBuildConfiguration">
+ <filter id="403767336">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="TOOLCHAIN_ID"/>
+ </message_arguments>
+ </filter>
+ <filter id="403767336">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="TOOLCHAIN_TYPE"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="getLaunchMode()"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="getProperty(String)"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="removeProperty(String)"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfiguration"/>
+ <message_argument value="setProperty(String, String)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/cdt/core/build/ICBuildConfigurationProvider.java" type="org.eclipse.cdt.core.build.ICBuildConfigurationProvider">
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/>
+ <message_argument value="getSupportedToolchains(Collection&lt;IToolChain&gt;)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/cdt/core/build/IToolChain.java" type="org.eclipse.cdt.core.build.IToolChain">
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChain"/>
+ <message_argument value="getTypeId()"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/cdt/core/build/IToolChainProvider.java" type="org.eclipse.cdt.core.build.IToolChainProvider">
+ <filter comment="This interface is still pretty new. Assuming low risk." id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="addToolChain(IToolChain)"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="getToolChain(String)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Newish interface. Assuming low risk." id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="removeToolChain(IToolChain)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd b/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd
index 44873b6b79a..78c09ea5a12 100644
--- a/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd
+++ b/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd
@@ -1,109 +1,132 @@
-<?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="ToolChainProvider" name="Tool Chain Provider"/>
- </appInfo>
- <documentation>
- A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren&apos;t called unless there&apos;s a good chance they have toolchains to offer.
- </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="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainProvider"/>
- </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>
+<?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="ToolChainProvider" name="Tool Chain Provider"/>
+ </appInfo>
+ <documentation>
+ A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren&apos;t called unless there&apos;s a good chance they have toolchains to offer.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="provider"/>
+ <element ref="type"/>
+ </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="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="type">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </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/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 edd0c89dd84..8eda72d5a19 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
@@ -23,7 +23,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -119,11 +118,8 @@ public abstract class CBuildConfiguration extends PlatformObject
if (tc == null) {
// check for other versions
- Collection<IToolChain> tcs = toolChainManager.getToolChains(typeId, id);
- if (!tcs.isEmpty()) {
- // TODO grab the newest version
- tc = tcs.iterator().next();
- } else {
+ tc = toolChainManager.getToolChain(typeId, id);
+ if (tc == null) {
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID,
CCorePlugin.STATUS_BUILD_CONFIG_NOT_VALID,
String.format(Messages.CBuildConfiguration_ToolchainMissing, config.getName()),
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java
index 3d3cb0dda58..3e9bd08818a 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java
@@ -62,8 +62,10 @@ public interface IToolChain extends IAdaptable {
/**
* The version of the toolchain
*
+ * @deprecated the version doesn't matter. id's for a given type must be unique.
* @return toolchain version
*/
+ @Deprecated
String getVersion();
/**
@@ -74,6 +76,18 @@ public interface IToolChain extends IAdaptable {
String getName();
/**
+ * The type id for the toolchain. The combination of type id and toolchain id
+ * uniquely identify the toolchain in the system.
+ *
+ * @since 6.4
+ */
+ default String getTypeId() {
+ // Subclasses really need to override this. There can be multiple providers for
+ // a given toolchain type.
+ return getProvider().getId();
+ }
+
+ /**
* Returns an property of the toolchain. Used to determine applicability of
* a toolchain for a given situation.
*
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java
index 08d210cf79f..e1e254dd79f 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java
@@ -33,9 +33,18 @@ public interface IToolChainManager {
IToolChainProvider getProvider(String providerId) throws CoreException;
/**
+ * Return the UI label for the toolchain type.
+ *
+ * @param id
+ * type toolchain type id
+ * @return name of the type
+ * @since 6.4
+ */
+ String getToolChainTypeName(String typeId);
+
+ /**
* Return the toolchain from the given provider with the given id and version.
*
- * @deprecated Version is now irrelevant. id's are unique.
* @param providerId
* id of provider
* @param id
@@ -44,6 +53,7 @@ public interface IToolChainManager {
* version of toolchain
* @return the toolchain
* @throws CoreException
+ * @deprecated version is now irrelevant. id's are unique.
*/
@Deprecated
default IToolChain getToolChain(String providerId, String id, String version) throws CoreException {
@@ -51,17 +61,17 @@ public interface IToolChainManager {
}
/**
- * Return the toolChain from the given provider with the given id.
+ * Return the toolChain with the given type and id.
*
- * @param providerId
- * id of provider
+ * @param typeId
+ * id of toolchain type
* @param id
* id of toolchain
* @return the toolchain
* @throws CoreException
* @since 6.4
*/
- IToolChain getToolChain(String providerId, String id) throws CoreException;
+ IToolChain getToolChain(String typeId, String id) throws CoreException;
/**
* Return the toolchains provided by the given provider
@@ -70,8 +80,12 @@ public interface IToolChainManager {
* id of provider
* @return toolchains the provider provides
* @throws CoreException
+ * @deprecated we no longer organize toolchains by provider id.
*/
- Collection<IToolChain> getToolChains(String providerId) throws CoreException;
+ @Deprecated
+ default Collection<IToolChain> getToolChains(String providerId) throws CoreException {
+ return null;
+ }
/**
* Return all versions of toolchains with the given id provided by the given
@@ -83,8 +97,12 @@ public interface IToolChainManager {
* id of toolchains
* @return toolchains with the given id provided by the provider
* @throws CoreException
+ * @deprecated toolchains no longer have multiple versions per id
*/
- Collection<IToolChain> getToolChains(String providerId, String id) throws CoreException;
+ @Deprecated
+ default Collection<IToolChain> getToolChains(String providerId, String id) throws CoreException {
+ return null;
+ }
/**
* Returns the list of toolchains that have the given properties.
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java
index d1c11e2fbbe..d23350bb83a 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java
@@ -36,28 +36,16 @@ public interface IToolChainProvider {
/**
* Called by the manager to dynamically create the toolchain.
*
- * @deprecated We have dropped the concept of version. All ids must be unique.
* @param id
* the id of the toolchain
* @param version
* the version of the toolchain
* @return the toolchain initialized with the settings.
+ * @deprecated providers do not manage toolchains, call
+ * IToolManager.getToolChain() instead.
*/
@Deprecated
default IToolChain getToolChain(String id, String version) throws CoreException {
- return getToolChain(id);
- }
-
- /**
- * Called by the manager to dynamically create the toolchain.
- *
- * @param id
- * the id of the toolchain
- * @return the toolchain initialized with the settings.
- * @since 6.4
- */
- default IToolChain getToolChain(String id) throws CoreException {
- // By default, assumes all toolchains were added at init time.
return null;
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
index 1ac9b8b7df7..ed36904ad05 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
@@ -9,6 +9,7 @@ package org.eclipse.cdt.internal.core.build;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -24,12 +25,16 @@ import org.eclipse.core.runtime.IExtensionRegistry;
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;
public class ToolChainManager implements IToolChainManager {
private Map<String, IConfigurationElement> providerElements;
private Map<String, IToolChainProvider> providers;
- private Map<List<String>, IToolChain> toolChains;
+ private Map<String, Map<String, IToolChain>> toolChains;
+ private Map<String, String> toolChainTypeNames = new HashMap<>();
private List<IToolChain> orderedToolChains;
private List<ISafeRunnable> listeners = new ArrayList<>();
@@ -49,39 +54,110 @@ public class ToolChainManager implements IToolChainManager {
// Load the discovered toolchains
toolChains = new HashMap<>();
- orderedToolChains = new ArrayList<>();
for (IConfigurationElement element : providerElements.values()) {
- // TODO check for enablement
+ switch (element.getName()) {
+ case "provider": //$NON-NLS-1$
+ // TODO check for enablement
+ try {
+ IToolChainProvider provider = (IToolChainProvider) element
+ .createExecutableExtension("class"); //$NON-NLS-1$
+ providers.put(element.getAttribute("id"), provider); //$NON-NLS-1$
+ provider.init(this);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ break;
+ case "type": //$NON-NLS-1$
+ toolChainTypeNames.put(element.getAttribute("id"), element.getAttribute("name")); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ }
+ }
+
+ orderedToolChains = new ArrayList<>();
+ Preferences prefs = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID)
+ .node(getClass().getSimpleName()).node("order"); //$NON-NLS-1$
+ String nString = prefs.get("n", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!nString.isEmpty()) {
try {
- IToolChainProvider provider = (IToolChainProvider) element
- .createExecutableExtension("class"); //$NON-NLS-1$
- providers.put(element.getAttribute("id"), provider); //$NON-NLS-1$
- provider.init(this);
- } catch (CoreException e) {
+ int n = Integer.parseInt(nString);
+ for (int i = 0; i < n; ++i) {
+ String typeId = prefs.get(Integer.toString(i) + ".type", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ String id = prefs.get(Integer.toString(i) + ".id", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ IToolChain toolChain = getToolChain(typeId, id);
+ if (toolChain != null) {
+ orderedToolChains.add(toolChain);
+ }
+ }
+ } catch (NumberFormatException e) {
CCorePlugin.log(e);
+ } catch (CoreException e) {
+ CCorePlugin.log(e.getStatus());
+ }
+ }
+
+ for (Map<String, IToolChain> type : toolChains.values()) {
+ for (IToolChain toolChain : type.values()) {
+ if (!orderedToolChains.contains(toolChain)) {
+ orderedToolChains.add(toolChain);
+ }
}
}
}
}
- private List<String> getId(IToolChain toolChain) {
- List<String> id = new ArrayList<>(3);
- id.add(toolChain.getProvider().getId());
- id.add(toolChain.getId());
- return id;
+ @Override
+ public String getToolChainTypeName(String typeId) {
+ init();
+ String name = toolChainTypeNames.get(typeId);
+ return name != null ? name : typeId;
+ }
+
+ private void saveToolChainOrder() {
+ Preferences prefs = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID)
+ .node(getClass().getSimpleName()).node("order"); //$NON-NLS-1$
+ prefs.put("n", Integer.toString(orderedToolChains.size())); //$NON-NLS-1$
+ int i = 0;
+ for (IToolChain toolChain : orderedToolChains) {
+ prefs.put(Integer.toString(i) + ".type", toolChain.getTypeId()); //$NON-NLS-1$
+ prefs.put(Integer.toString(i) + ".id", toolChain.getId()); //$NON-NLS-1$
+ i++;
+ }
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ CCorePlugin.log(e);
+ }
}
@Override
public void addToolChain(IToolChain toolChain) {
- orderedToolChains.add(toolChain);
- toolChains.put(getId(toolChain), toolChain);
+ Map<String, IToolChain> type = toolChains.get(toolChain.getTypeId());
+ if (type == null) {
+ type = new HashMap<>();
+ toolChains.put(toolChain.getTypeId(), type);
+ }
+ type.put(toolChain.getId(), toolChain);
+
+ if (orderedToolChains != null) {
+ // is null at init time where order will be established later
+ orderedToolChains.add(toolChain);
+ saveToolChainOrder();
+ }
+
fireChange();
}
@Override
public void removeToolChain(IToolChain toolChain) {
- orderedToolChains.remove(toolChain);
- toolChains.remove(getId(toolChain));
+ Map<String, IToolChain> type = toolChains.get(toolChain.getTypeId());
+ if (type != null) {
+ type.remove(toolChain.getId());
+ }
+
+ if (orderedToolChains.remove(toolChain)) {
+ saveToolChainOrder();
+ }
+
fireChange();
}
@@ -100,95 +176,47 @@ public class ToolChainManager implements IToolChainManager {
}
@Override
- public IToolChain getToolChain(String providerId, String id) throws CoreException {
+ public IToolChain getToolChain(String typeId, String id) throws CoreException {
init();
- List<String> tid = new ArrayList<>(3);
- tid.add(providerId);
- tid.add(id);
-
- IToolChain toolChain = toolChains.get(tid);
- if (toolChain != null) {
- return toolChain;
- }
-
- // Try the provider
- IToolChainProvider realProvider = providers.get(providerId);
- if (realProvider != null) {
- toolChain = realProvider.getToolChain(id);
- if (toolChain != null) {
- toolChains.put(getId(toolChain), toolChain);
- return toolChain;
- }
- }
-
- return null;
+ Map<String, IToolChain> type = toolChains.get(typeId);
+ return type != null ? type.get(id) : null;
}
@Override
public Collection<IToolChain> getToolChainsMatching(Map<String, String> properties) {
init();
List<IToolChain> tcs = new ArrayList<>();
- for (IToolChain toolChain : toolChains.values()) {
- boolean matches = true;
- for (Map.Entry<String, String> property : properties.entrySet()) {
- String tcProperty = toolChain.getProperty(property.getKey());
- if (tcProperty != null) {
- if (!property.getValue().equals(tcProperty)) {
- matches = false;
- break;
+ for (Map<String, IToolChain> type : toolChains.values()) {
+ for (IToolChain toolChain : type.values()) {
+ boolean matches = true;
+ for (Map.Entry<String, String> property : properties.entrySet()) {
+ String tcProperty = toolChain.getProperty(property.getKey());
+ if (tcProperty != null) {
+ if (!property.getValue().equals(tcProperty)) {
+ matches = false;
+ break;
+ }
}
}
- }
- if (matches) {
- tcs.add(toolChain);
- }
- }
-
- // Allow 32-bit compilers on 64-bit machines
- // TODO is there a cleaner way to do this?
- if ("x86_64".equals(properties.get(IToolChain.ATTR_ARCH))) { //$NON-NLS-1$
- Map<String, String> properties32 = new HashMap<>(properties);
- properties32.put(IToolChain.ATTR_ARCH, "x86"); //$NON-NLS-1$
- tcs.addAll(getToolChainsMatching(properties32));
- }
-
- return tcs;
- }
-
- @Override
- public Collection<IToolChain> getToolChains(String providerId) {
- init();
- List<IToolChain> tcs = new ArrayList<>();
- for (IToolChain toolChain : toolChains.values()) {
- if (toolChain.getProvider().getId().equals(providerId)) {
- tcs.add(toolChain);
+ if (matches) {
+ tcs.add(toolChain);
+ }
}
}
- return tcs;
- }
- @Override
- public Collection<IToolChain> getToolChains(String providerId, String id) throws CoreException {
- init();
- List<IToolChain> tcs = new ArrayList<>();
- for (IToolChain toolChain : toolChains.values()) {
- if (toolChain.getProvider().getId().equals(providerId) && toolChain.getId().equals(id)) {
- tcs.add(toolChain);
- }
- }
return tcs;
}
@Override
public Collection<IToolChain> getAllToolChains() throws CoreException {
init();
- return orderedToolChains;
+ return Collections.unmodifiableCollection(orderedToolChains);
}
@Override
public void setToolChainOrder(List<IToolChain> orderedToolchains) throws CoreException {
- // TODO Auto-generated method stub
-
+ this.orderedToolChains = orderedToolchains;
+ saveToolChainOrder();
}
@Override

Back to the top