[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] patches for Multi version tool chain support ( bugzilla #89872)
|
Here I attached ‘core’ & ‘ui’
patches that contains code for Converter Extension Point, UI support for multiple
tool chain versions in Manage configuration dialog box and migration support while
loading a project.
Thanks & Regards,
Sunil
|
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/plugin.xml,v
retrieving revision 1.25
diff -u -r1.25 plugin.xml
--- plugin.xml 9 Jun 2005 16:27:56 -0000 1.25
+++ plugin.xml 9 Jun 2005 20:43:52 -0000
@@ -25,6 +25,7 @@
<extension-point id="ManagedBuildInfo" name="Managed Build Tools 2.0 (Deprecated)" schema="schema/ManagedBuildTools.exsd"/>
<extension-point id="buildDefinitions" name="Managed Build Definitions" schema="schema/buildDefinitions.exsd"/>
+ <extension-point id="projectConverter" name="Managed Build Project Converter" schema="schema/Converter.exsd"/>
<!-- =================================================================================== -->
<!-- Extension Point: IScannerInfoProvider for the managed Builder -->
Index: src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java,v
retrieving revision 1.46
diff -u -r1.46 ManagedBuildManager.java
--- src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java 9 Jun 2005 17:34:45 -0000 1.46
+++ src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java 9 Jun 2005 20:44:09 -0000
@@ -24,6 +24,8 @@
import java.util.ListIterator;
import java.util.Map;
import java.util.Random;
+import java.util.SortedMap;
+import java.util.TreeMap;
import java.net.URL;
import javax.xml.parsers.DocumentBuilder;
@@ -139,13 +141,13 @@
// Resource configurations defined in the manifest files
private static Map extensionResourceConfigurationMap;
// Tool-chains defined in the manifest files
- private static Map extensionToolChainMap;
+ private static SortedMap extensionToolChainMap;
// Tools defined in the manifest files
- private static Map extensionToolMap;
+ private static SortedMap extensionToolMap;
// Target Platforms defined in the manifest files
private static Map extensionTargetPlatformMap;
// Builders defined in the manifest files
- private static Map extensionBuilderMap;
+ private static SortedMap extensionBuilderMap;
// Options defined in the manifest files
private static Map extensionOptionMap;
// Option Categories defined in the manifest files
@@ -178,10 +180,8 @@
getEnvironmentVariableProvider().subscribe(
fEnvironmentBuildPathsChangeListener = new IEnvironmentBuildPathsChangeListener(){
public void buildPathsChanged(IConfiguration configuration, int buildPathType){
- if(buildPathType == IEnvVarBuildPath.BUILDPATH_INCLUDE){
- initializePathEntries(configuration,null);
+ if(buildPathType == IEnvVarBuildPath.BUILDPATH_INCLUDE)
notifyListeners(configuration,null);
- }
}
});
}
@@ -247,14 +247,6 @@
* @return IProjectType
*/
public static IProjectType getProjectType(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IProjectType)getExtensionProjectTypeMap().get(id);
}
@@ -306,9 +298,9 @@
*
* @return Map
*/
- protected static Map getExtensionToolChainMap() {
+ public static SortedMap getExtensionToolChainMap() {
if (extensionToolChainMap == null) {
- extensionToolChainMap = new HashMap();
+ extensionToolChainMap = new TreeMap();
}
return extensionToolChainMap;
}
@@ -318,9 +310,9 @@
*
* @return Map
*/
- protected static Map getExtensionToolMap() {
+ public static SortedMap getExtensionToolMap() {
if (extensionToolMap == null) {
- extensionToolMap = new HashMap();
+ extensionToolMap = new TreeMap();
}
return extensionToolMap;
}
@@ -342,9 +334,9 @@
*
* @return Map
*/
- protected static Map getExtensionBuilderMap() {
+ public static SortedMap getExtensionBuilderMap() {
if (extensionBuilderMap == null) {
- extensionBuilderMap = new HashMap();
+ extensionBuilderMap = new TreeMap();
}
return extensionBuilderMap;
}
@@ -434,14 +426,6 @@
* @return IProjectType
*/
public static IProjectType getExtensionProjectType(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IProjectType) getExtensionProjectTypeMap().get(id);
}
@@ -453,14 +437,6 @@
* @return IConfiguration
*/
public static IConfiguration getExtensionConfiguration(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IConfiguration) getExtensionConfigurationMap().get(id);
}
@@ -472,14 +448,6 @@
* @return IResourceConfiguration
*/
public static IResourceConfiguration getExtensionResourceConfiguration(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IResourceConfiguration) getExtensionResourceConfigurationMap().get(id);
}
@@ -491,14 +459,6 @@
* @return IToolChain
*/
public static IToolChain getExtensionToolChain(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IToolChain) getExtensionToolChainMap().get(id);
}
@@ -510,14 +470,6 @@
* @return ITool
*/
public static ITool getExtensionTool(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (ITool) getExtensionToolMap().get(id);
}
@@ -529,14 +481,6 @@
* @return ITargetPlatform
*/
public static ITargetPlatform getExtensionTargetPlatform(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (ITargetPlatform) getExtensionTargetPlatformMap().get(id);
}
@@ -548,14 +492,6 @@
* @return IBuilder
*/
public static IBuilder getExtensionBuilder(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IBuilder) getExtensionBuilderMap().get(id);
}
@@ -567,14 +503,6 @@
* @return IOption
*/
public static IOption getExtensionOption(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IOption) getExtensionOptionMap().get(id);
}
@@ -586,14 +514,6 @@
* @return IInputType
*/
public static IInputType getExtensionInputType(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IInputType) getExtensionInputTypeMap().get(id);
}
@@ -605,14 +525,6 @@
* @return IOutputType
*/
public static IOutputType getExtensionOutputType(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (IOutputType) getExtensionOutputTypeMap().get(id);
}
@@ -624,14 +536,6 @@
* @return ITarget
*/
public static ITarget getExtensionTarget(String id) {
- try {
- // Make sure the extensions are loaded
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
return (ITarget) getExtensionTargetMap().get(id);
}
@@ -782,32 +686,6 @@
}
}
- public static void initializePathEntries(IConfiguration config, IOption option){
- try{
- if(option != null
- && option.getValueType() != IOption.INCLUDE_PATH
- && option.getValueType() != IOption.PREPROCESSOR_SYMBOLS
- && option.getValueType() != IOption.LIBRARIES
- )
- return;
- } catch (BuildException e){
- return;
- }
- IResource rc = config.getOwner();
- if(rc != null){
- IManagedBuildInfo info = getBuildInfo(rc);
- if(info instanceof ManagedBuildInfo && config.equals(info.getDefaultConfiguration()))
- ((ManagedBuildInfo)info).initializePathEntries();
- }
-
- }
-
- public static void initializePathEntries(IResourceConfiguration resConfig, IOption option){
- IConfiguration cfg = resConfig.getParent();
- if(cfg != null)
- initializePathEntries(cfg,option);
- }
-
private static void notifyListeners(IResourceConfiguration resConfig, IOption option) {
// Continue if change is something that effect the scanreser
try {
@@ -860,7 +738,6 @@
try {
// Request a value change and set dirty if real change results
retOpt = config.setOption(holder, option, value);
- initializePathEntries(config,option);
notifyListeners(config, option);
} catch (BuildException e) {
return null;
@@ -887,7 +764,6 @@
try {
// Request a value change and set dirty if real change results
retOpt = resConfig.setOption(holder, option, value);
- initializePathEntries(resConfig,option);
notifyListeners(resConfig, option);
} catch (BuildException e) {
return null;
@@ -912,7 +788,6 @@
IOption retOpt;
try {
retOpt = config.setOption(holder, option, value);
- initializePathEntries(config,option);
notifyListeners(config, option);
} catch (BuildException e) {
return null;
@@ -938,7 +813,6 @@
IOption retOpt;
try {
retOpt = resConfig.setOption(holder, option, value);
- initializePathEntries(resConfig,option);
notifyListeners(resConfig, option);
} catch (BuildException e) {
return null;
@@ -963,7 +837,6 @@
IOption retOpt;
try {
retOpt = config.setOption(holder, option, value);
- initializePathEntries(config,option);
notifyListeners(config, option);
} catch (BuildException e) {
return null;
@@ -989,7 +862,6 @@
IOption retOpt;
try {
retOpt = resConfig.setOption(holder, option, value);
- initializePathEntries(resConfig,option);
notifyListeners(resConfig, option);
} catch (BuildException e) {
return null;
@@ -1507,21 +1379,61 @@
NodeList nodes = document.getElementsByTagName(ROOT_NODE_NAME);
if (nodes.getLength() > 0) {
Node node = nodes.item(0);
+
+ // Create the internal representation of the project's MBS information
buildInfo = new ManagedBuildInfo(project, (Element)node, fileVersion);
if (fileVersion != null) {
buildInfo.setVersion(fileVersion);
}
- if(!UpdateManagedProjectManager.isCompatibleProject(buildInfo)){
- UpdateManagedProjectManager.updateProject(project,buildInfo);
+ // Check to see if all elements could be loaded correctly - for example,
+ // if references in the project file could not be resolved to extension
+ // elements
+ if (buildInfo.getManagedProject() == null ||
+ (!buildInfo.getManagedProject().isValid())) {
+ // The load failed
+ throw new Exception(ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.id.nomatch", project.getName())); //$NON-NLS-1$
}
+
+ // Each ToolChain/Tool/Builder element maintain two separate
+ // converters if available
+ // 0ne for previous Mbs versions and one for current Mbs version
+ // walk through the project hierarchy and call the converters
+ // written for previous mbs versions
+ if ( checkForMigrationSupport(buildInfo, false) != true ) {
+ // display an error message that the project is no loadable
+ if (buildInfo.getManagedProject() == null ||
+ (!buildInfo.getManagedProject().isValid())) {
+ // The load failed
+ throw new Exception(ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.id.nomatch", project.getName())); //$NON-NLS-1$
+ }
+ }
+
+ // Upgrade the project's CDT version if necessary
+ if (!UpdateManagedProjectManager.isCompatibleProject(buildInfo)) {
+ UpdateManagedProjectManager.updateProject(project, buildInfo);
+ }
+ // Check to see if the upgrade (if required) succeeded
if (buildInfo.getManagedProject() == null ||
(!buildInfo.getManagedProject().isValid())) {
// The load failed
throw new Exception(ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.id.nomatch", project.getName())); //$NON-NLS-1$
}
+
+ // Walk through the project hierarchy and call the converters
+ // written for current mbs version
+ if ( checkForMigrationSupport(buildInfo, true) != true ) {
+ // display an error message.that the project is no loadable
+ if (buildInfo.getManagedProject() == null ||
+ (!buildInfo.getManagedProject().isValid())) {
+ // The load failed
+ throw new Exception(ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.id.nomatch", project.getName())); //$NON-NLS-1$
+ }
+ }
+
+ // Finish up
project.setSessionProperty(buildInfoProperty, buildInfo);
IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
- // Send an event to each configuration and if they exist, its resource configurations
+ // Send an event to each configuration and if they exist, its resource configurations
for (int i=0; i < configs.length; ++i) {
ManagedBuildManager.performValueHandlerEvent(configs[i], IManagedOptionValueHandler.EVENT_OPEN);
}
@@ -2503,5 +2415,104 @@
}
}
}
+
+ private static boolean checkForMigrationSupport(ManagedBuildInfo buildInfo,
+ boolean forCurrentMbsVersion) {
+
+ IProjectType projectType = null;
+ IConfigurationElement element = null;
+
+ // Get the projectType from buildInfo
+ IManagedProject managedProject = buildInfo.getManagedProject();
+ projectType = managedProject.getProjectType();
+
+ // walk through the hierarchy of the projectType and
+ // call the converters if available for each configuration
+ IConfiguration[] configs = projectType.getConfigurations();
+ for (int i = 0; i < configs.length; i++) {
+ IConfiguration configuration = configs[i];
+ IToolChain toolChain = configuration.getToolChain();
+
+ if (forCurrentMbsVersion) {
+ element = ((ToolChain)toolChain).getCurrentMbsVersionConversionElement();
+ } else {
+ element = ((ToolChain)toolChain).getPreviousMbsVersionConversionElement();
+ }
+
+ if (element != null) {
+ // If there is a converter element for toolChain, invoke it
+ // toolChain converter should take care of invoking converters of it's children
+ if ( invokeConverter(toolChain, buildInfo, element) != true ) {
+ buildInfo.getManagedProject().setValid(false);
+ return false;
+ }
+ } else {
+ // If there are no converters for toolChain, walk through it's children
+ ITool[] tools = toolChain.getTools();
+ for (int j = 0; j < tools.length; j++) {
+ ITool tool = tools[j];
+ if (forCurrentMbsVersion) {
+ element = ((Tool)tool).getCurrentMbsVersionConversionElement();
+ } else {
+ element = ((Tool)tool).getPreviousMbsVersionConversionElement();
+ }
+ if (element != null) {
+ if ( invokeConverter(tool, buildInfo, element) != true ) {
+ buildInfo.getManagedProject().setValid(false);
+ return false;
+ }
+ }
+ }
+ IBuilder builder = toolChain.getBuilder();
+ if (forCurrentMbsVersion) {
+ element = ((Builder)builder).getCurrentMbsVersionConversionElement();
+ } else {
+ element = ((Builder)builder).getPreviousMbsVersionConversionElement();
+ }
+
+ if (element != null) {
+ if ( invokeConverter(builder, buildInfo, element) != true ) {
+ buildInfo.getManagedProject().setValid(false);
+ return false;
+ }
+ }
+ }
+ }
+ // If control comes here, it means either there is no converter element
+ // or converters are invoked successfully
+ return true;
+ }
+
+ private static boolean invokeConverter(IBuildObject buildObject,
+ IManagedBuildInfo buildInfo, IConfigurationElement element) {
+ String toId = null;
+ String fromId = null;
+ IConvertManagedBuildObject convertBuildObject = null;
+
+ if (element != null) {
+ toId = element.getAttribute("toId"); //$NON-NLS-1$
+ fromId = element.getAttribute("fromId"); //$NON-NLS-1$
+
+ try {
+ convertBuildObject = (IConvertManagedBuildObject) element
+ .createExecutableExtension("class"); //$NON-NLS-1$
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (convertBuildObject != null) {
+ // invoke the converter
+ if (convertBuildObject
+ .convert(buildObject, fromId, toId, false) != null) {
+ // If it is successful, return 'true'
+ return true;
+ }
+ }
+ }
+ // if control comes here, it means that either 'convertBuildObject' is null or
+ // converter did not convert the object successfully
+ return false;
+ }
}
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java,v
retrieving revision 1.8
diff -u -r1.8 Builder.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java 27 May 2005 11:54:51 -0000 1.8
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java 9 Jun 2005 20:44:14 -0000
@@ -12,11 +12,14 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.SortedMap;
import java.util.StringTokenizer;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@@ -28,6 +31,10 @@
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
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.Platform;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -61,10 +68,13 @@
private boolean isDirty = false;
private boolean resolved = true;
+ private IConfigurationElement previousMbsVersionConversionElement = null;
+ private IConfigurationElement currentMbsVersionConversionElement = null;
/*
* C O N S T R U C T O R S
*/
+
/**
* This constructor is called to create a builder defined by an extension point in
* a plugin manifest file, or returned by a dynamic element provider
@@ -308,9 +318,8 @@
superClassId = element.getAttribute(IProjectType.SUPERCLASS);
if (superClassId != null && superClassId.length() > 0) {
superClass = ManagedBuildManager.getExtensionBuilder(superClassId);
- if (superClass == null) {
- // TODO: Report error
- }
+ // Check for migration support
+ checkForMigrationSupport();
}
// Get the 'versionSupported' attribute
@@ -776,4 +785,200 @@
return superClass.getReservedMacroNameSupplier();
return reservedMacroNameSupplier;
}
+
+ /*
+ * This function checks for migration support for the builder, while
+ * loading. If migration support is needed, looks for the available
+ * converters and stores them.
+ */
+
+ private void checkForMigrationSupport() {
+
+ String tmpId = null;
+ boolean isExists = false;
+
+ if (getSuperClass() == null) {
+ // If 'superClass' is null, then there is no builder available in
+ // plugin manifest file with the same 'id' & version.
+ // Look for the 'versionsSupported' attribute
+ String high = (String) ManagedBuildManager
+ .getExtensionBuilderMap().lastKey();
+
+ SortedMap subMap = null;
+ if (superClassId.compareTo(high) <= 0) {
+ subMap = ManagedBuildManager.getExtensionBuilderMap().subMap(
+ superClassId, high + "\0"); //$NON-NLS-1$
+ } else {
+ // It means there are no entries in the map for the given id.
+ // make the project is invalid
+
+ IToolChain parent = getParent();
+ IConfiguration parentConfig = parent.getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ return;
+ }
+
+ // for each element in the 'subMap',
+ // check the 'versionsSupported' attribute whether the given
+ // builder version is supported
+
+ String baseId = ManagedBuildManager
+ .getIdFromIdAndVersion(superClassId);
+ String version = ManagedBuildManager
+ .getVersionFromIdAndVersion(superClassId);
+
+ IBuilder[] builderElements = (IBuilder[]) subMap.values()
+ .toArray();
+
+ for (int i = 0; i < builderElements.length; i++) {
+ IBuilder builderElement = builderElements[i];
+
+ if (ManagedBuildManager.getIdFromIdAndVersion(
+ builderElement.getId()).compareTo(baseId) > 0)
+ break;
+ // First check if both base ids are equal
+ if (ManagedBuildManager.getIdFromIdAndVersion(
+ builderElement.getId()).equals(baseId)) {
+
+ // Check if 'versionsSupported' attribute is available'
+ String versionsSupported = builderElement
+ .getVersionsSupported();
+
+ if ((versionsSupported != null)
+ && (!versionsSupported.equals(""))) { //$NON-NLS-1$
+ String[] tmpVersions = versionsSupported.split(","); //$NON-NLS-1$
+
+ for (int j = 0; j < tmpVersions.length; j++) {
+ if (new PluginVersionIdentifier(version)
+ .equals(new PluginVersionIdentifier(
+ tmpVersions[j]))) {
+ // version is supported.
+ // Do the automatic conversion without
+ // prompting the user.
+ // Get the supported version
+ String supportedVersion = ManagedBuildManager
+ .getVersionFromIdAndVersion(builderElement
+ .getId());
+ setId(ManagedBuildManager
+ .getIdFromIdAndVersion(getId())
+ + "_" + supportedVersion); //$NON-NLS-1$
+
+ // If control comes here means that 'superClass' is null
+ // So, set the superClass to this builder element
+ superClass = builderElement;
+ superClassId = superClass.getId();
+ isExists = true;
+ break;
+ }
+ }
+ if(isExists)
+ break; // break the outer for loop if 'isExists' is true
+ }
+ }
+ }
+ }
+ if (getSuperClass() != null) {
+ // If 'getSuperClass()' is not null, look for 'convertToId' attribute in plugin
+ // manifest file for this builder.
+ String convertToId = getSuperClass().getConvertToId();
+ if ((convertToId == null) || (convertToId.equals(""))) { //$NON-NLS-1$
+ // It means there is no 'convertToId' attribute available and
+ // the version is still actively
+ // supported by the tool integrator. So do nothing, just return
+ return;
+ } else {
+ // Incase the 'convertToId' attribute is available,
+ // it means that Tool integrator currently does not support this
+ // version of builder.
+ // Look for the converters available for this builder version.
+
+ getConverter(convertToId);
+ }
+
+ } else {
+ // make the project is invalid
+ //
+ IToolChain parent = getParent();
+ IConfiguration parentConfig = parent.getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ }
+ return;
+ }
+
+ private void getConverter(String convertToId) {
+
+ String fromId = null;
+ String toId = null;
+
+ // Get the Converter Extension Point
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
+ "projectConverter"); //$NON-NLS-1$
+ if (extensionPoint != null) {
+ // Get the extensions
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ // Get the configuration elements of each extension
+ IConfigurationElement[] configElements = extensions[i]
+ .getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+
+ IConfigurationElement element = configElements[j];
+
+ if (element.getName().equals("converter")) { //$NON-NLS-1$
+
+ fromId = element.getAttribute("fromId"); //$NON-NLS-1$
+ toId = element.getAttribute("toId"); //$NON-NLS-1$
+ // Check whether the current converter can be used for
+ // the selected builder
+
+ if (fromId.equals(getSuperClass().getId())
+ && toId.equals(convertToId)) {
+ // If it matches
+ String mbsVersion = element
+ .getAttribute("mbsVersion"); //$NON-NLS-1$
+ PluginVersionIdentifier currentMbsVersion = ManagedBuildManager
+ .getBuildInfoVersion();
+
+ // set the converter element based on the MbsVersion
+ if (currentMbsVersion
+ .isGreaterThan(new PluginVersionIdentifier(
+ mbsVersion))) {
+ previousMbsVersionConversionElement = element;
+ } else {
+ currentMbsVersionConversionElement = element;
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ // If control comes here, it means 'Tool Integrator' specified
+ // 'convertToId' attribute in toolchain definition file, but
+ // has not provided any converter.
+ // So, make the project is invalid
+
+ IToolChain parent = getParent();
+ IConfiguration parentConfig = parent.getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ }
+
+ public IConfigurationElement getPreviousMbsVersionConversionElement() {
+ return previousMbsVersionConversionElement;
+ }
+
+ public IConfigurationElement getCurrentMbsVersionConversionElement() {
+ return currentMbsVersionConversionElement;
+ }
}
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java,v
retrieving revision 1.34
diff -u -r1.34 Tool.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java 6 Jun 2005 15:51:49 -0000 1.34
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java 9 Jun 2005 20:44:29 -0000
@@ -17,6 +17,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.SortedMap;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -25,6 +26,7 @@
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
@@ -46,8 +48,12 @@
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -111,6 +117,8 @@
private boolean isExtensionTool = false;
private boolean isDirty = false;
private boolean resolved = resolvedDefault;
+ private IConfigurationElement previousMbsVersionConversionElement = null;
+ private IConfigurationElement currentMbsVersionConversionElement = null;
/*
* C O N S T R U C T O R S
@@ -558,9 +566,8 @@
setSuperClass( resConfig.getParent().getTool(superClassId) );
} else {
setSuperClass( ManagedBuildManager.getExtensionTool(superClassId) );
- }
- if (getSuperClass() == null) {
- // TODO: Report error
+ // Check for migration support
+ checkForMigrationSupport();
}
}
@@ -2408,5 +2415,214 @@
envVarBuildPathList.add(path);
}
-
+
+ /*
+ * This function checks for migration support for the tool, while
+ * loading. If migration support is needed, looks for the available
+ * converters and stores them.
+ *
+ * This function should be called only if the parent is 'IToolChain'
+ * and not 'IResourceConfiguration'
+ */
+
+ private void checkForMigrationSupport() {
+
+ String tmpId = null;
+ boolean isExists = false;
+
+ if (getSuperClass() == null) {
+ // If 'superClass' is null, then there is no tool available in
+ // plugin manifest file with the same 'id' & version.
+ // Look for the 'versionsSupported' attribute
+ String high = (String) ManagedBuildManager.getExtensionToolMap()
+ .lastKey();
+
+ SortedMap subMap = null;
+ if (superClassId.compareTo(high) <= 0) {
+ subMap = ManagedBuildManager.getExtensionToolMap().subMap(
+ superClassId, high + "\0"); //$NON-NLS-1$
+ } else {
+ // It means there are no entries in the map for the given id.
+ // make the project is invalid
+
+ // It means there are no entries in the map for the given id.
+ // make the project is invalid
+
+ IToolChain parent = (IToolChain) getParent();
+ IConfiguration parentConfig = parent.getParent();
+ IManagedProject managedProject = parentConfig
+ .getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ return;
+ }
+
+ // for each element in the 'subMap',
+ // check the 'versionsSupported' attribute whether the given
+ // builder version is supported
+
+ String baseId = ManagedBuildManager
+ .getIdFromIdAndVersion(superClassId);
+ String version = ManagedBuildManager
+ .getVersionFromIdAndVersion(superClassId);
+
+ ITool[] toolElements = (ITool[]) subMap.values().toArray();
+
+ for (int i = 0; i < toolElements.length; i++) {
+ ITool toolElement = toolElements[i];
+
+ if (ManagedBuildManager.getIdFromIdAndVersion(
+ toolElement.getId()).compareTo(baseId) > 0)
+ break;
+
+ // First check if both base ids are equal
+ if (ManagedBuildManager.getIdFromIdAndVersion(
+ toolElement.getId()).equals(baseId)) {
+
+ // Check if 'versionsSupported' attribute is available'
+ String versionsSupported = toolElement
+ .getVersionsSupported();
+
+ if ((versionsSupported != null)
+ && (!versionsSupported.equals(""))) { //$NON-NLS-1$
+ String[] tmpVersions = versionsSupported.split(","); //$NON-NLS-1$
+
+ for (int j = 0; j < tmpVersions.length; j++) {
+ if (new PluginVersionIdentifier(version)
+ .equals(new PluginVersionIdentifier(
+ tmpVersions[j]))) {
+ // version is supported.
+ // Do the automatic conversion without
+ // prompting the user.
+ // Get the supported version
+ String supportedVersion = ManagedBuildManager
+ .getVersionFromIdAndVersion(toolElement
+ .getId());
+ setId(ManagedBuildManager
+ .getIdFromIdAndVersion(getId())
+ + "_" + supportedVersion); //$NON-NLS-1$
+
+ // If control comes here means that superClass
+ // is null.
+ // So, set the superClass to this tool element
+ setSuperClass(toolElement);
+ isExists = true;
+ break;
+ }
+ }
+ if (isExists)
+ break; // break the outer for loop if 'isExists' is
+ // true
+ }
+ }
+ }
+ }
+
+ if (getSuperClass() != null) {
+ // If 'tmpSuperClass' is not null, look for 'convertToId' attribute in plugin
+ // manifest file for this tool.
+ String convertToId = getSuperClass().getConvertToId();
+ if ((convertToId == null) || (convertToId.equals(""))) { //$NON-NLS-1$
+ // It means there is no 'convertToId' attribute available and
+ // the version is still actively
+ // supported by the tool integrator. So do nothing, just return
+ return;
+ } else {
+ // Incase the 'convertToId' attribute is available,
+ // it means that Tool integrator currently does not support this
+ // version of tool.
+ // Look for the converters available for this tool version.
+
+ getConverter(convertToId);
+ }
+
+ } else {
+ // make the project is invalid
+ //
+ // It means there are no entries in the map for the given id.
+ // make the project is invalid
+ IToolChain parent = (IToolChain) getParent();
+ IConfiguration parentConfig = parent.getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ }
+ return;
+ }
+
+ private void getConverter(String convertToId) {
+
+ String fromId = null;
+ String toId = null;
+
+ // Get the Converter Extension Point
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
+ "projectConverter"); //$NON-NLS-1$
+ if (extensionPoint != null) {
+ // Get the extensions
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ // Get the configuration elements of each extension
+ IConfigurationElement[] configElements = extensions[i]
+ .getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+
+ IConfigurationElement element = configElements[j];
+
+ if (element.getName().equals("converter")) { //$NON-NLS-1$
+
+ fromId = element.getAttribute("fromId"); //$NON-NLS-1$
+ toId = element.getAttribute("toId"); //$NON-NLS-1$
+ // Check whether the current converter can be used for
+ // the selected tool
+
+ if (fromId.equals(getSuperClass().getId())
+ && toId.equals(convertToId)) {
+ // If it matches
+ String mbsVersion = element
+ .getAttribute("mbsVersion"); //$NON-NLS-1$
+ PluginVersionIdentifier currentMbsVersion = ManagedBuildManager
+ .getBuildInfoVersion();
+
+ // set the converter element based on the MbsVersion
+ if (currentMbsVersion
+ .isGreaterThan(new PluginVersionIdentifier(
+ mbsVersion))) {
+ previousMbsVersionConversionElement = element;
+ } else {
+ currentMbsVersionConversionElement = element;
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ // If control comes here, it means 'Tool Integrator' specified
+ // 'convertToId' attribute in toolchain definition file, but
+ // has not provided any converter.
+ // So, make the project is invalid
+
+ // It means there are no entries in the map for the given id.
+ // make the project is invalid
+ IToolChain parent = (IToolChain) getParent();
+ IConfiguration parentConfig = parent.getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ return;
+ }
+
+ public IConfigurationElement getPreviousMbsVersionConversionElement() {
+ return previousMbsVersionConversionElement;
+ }
+
+ public IConfigurationElement getCurrentMbsVersionConversionElement() {
+ return currentMbsVersionConversionElement;
+ }
}
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java,v
retrieving revision 1.12
diff -u -r1.12 ToolChain.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java 6 Jun 2005 15:51:49 -0000 1.12
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java 9 Jun 2005 20:44:38 -0000
@@ -15,6 +15,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.SortedMap;
import java.util.StringTokenizer;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
@@ -22,6 +23,7 @@
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
@@ -33,6 +35,10 @@
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
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.Platform;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -80,6 +86,9 @@
//holds the user-defined macros
private StorableMacros userDefinedMacros;
+ private IConfigurationElement previousMbsVersionConversionElement = null;
+ private IConfigurationElement currentMbsVersionConversionElement = null;
+
/*
* C O N S T R U C T O R S
*/
@@ -473,9 +482,8 @@
superClassId = element.getAttribute(IProjectType.SUPERCLASS);
if (superClassId != null && superClassId.length() > 0) {
setSuperClass( ManagedBuildManager.getExtensionToolChain(superClassId) );
- if (getSuperClass() == null) {
- // TODO: Report error
- }
+ // Check for migration support
+ checkForMigrationSupport();
}
// Get the unused children, if any
@@ -1460,4 +1468,191 @@
}
return null;
}
+
+ /*
+ * This function checks for migration support for the toolchain, while
+ * loading. If migration support is needed, looks for the available
+ * converters and adds them to the list.
+ */
+
+ private void checkForMigrationSupport() {
+
+ String tmpId = null;
+ boolean isExists = false;
+
+ if (getSuperClass() == null) {
+ // If 'getSuperClass()' is null, then there is no toolchain available in
+ // plugin manifest file with the 'id' & version.
+ // Look for the 'versionsSupported' attribute
+ String high = (String) ManagedBuildManager
+ .getExtensionToolChainMap().lastKey();
+
+ SortedMap subMap = null;
+ if (superClassId.compareTo(high) <= 0) {
+ subMap = ManagedBuildManager.getExtensionToolChainMap().subMap(
+ superClassId, high + "\0"); //$NON-NLS-1$
+ } else {
+ // It means there are no entries in the map for the given id.
+ // make the project is invalid
+ IConfiguration parentConfig = getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ return;
+ }
+
+ // for each element in the 'subMap',
+ // check the 'versionsSupported' attribute whether the given
+ // toolChain version is supported
+
+ String baseId = ManagedBuildManager.getIdFromIdAndVersion(superClassId);
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(superClassId);
+
+ IToolChain[] toolChainElements = (IToolChain[]) subMap.values().toArray();
+
+ for (int i = 0; i < toolChainElements.length; i++) {
+ IToolChain toolChainElement = toolChainElements[i];
+
+ if (ManagedBuildManager.getIdFromIdAndVersion(
+ toolChainElement.getId()).compareTo(baseId) > 0)
+ break;
+
+ // First check if both base ids are equal
+ if (ManagedBuildManager.getIdFromIdAndVersion(
+ toolChainElement.getId()).equals(baseId)) {
+
+ // Check if 'versionsSupported' attribute is available'
+ String versionsSupported = toolChainElement.getVersionsSupported();
+
+ if ((versionsSupported != null)
+ && (!versionsSupported.equals(""))) { //$NON-NLS-1$
+ String[] tmpVersions = versionsSupported.split(","); //$NON-NLS-1$
+
+ for (int j = 0; j < tmpVersions.length; j++) {
+ if (new PluginVersionIdentifier(version).equals(new PluginVersionIdentifier(tmpVersions[j]))) {
+ // version is supported.
+ // Do the automatic conversion without
+ // prompting the user.
+ // Get the supported version
+ String supportedVersion = ManagedBuildManager.getVersionFromIdAndVersion(
+ toolChainElement.getId());
+ setId(ManagedBuildManager.getIdFromIdAndVersion(getId())
+ + "_" + supportedVersion); //$NON-NLS-1$
+
+ // If control comes here means that 'superClass' is null
+ // So, set the superClass to this toolChain element
+ setSuperClass(toolChainElement);
+ superClassId = getSuperClass().getId();
+ isExists = true;
+ break;
+ }
+ }
+ if(isExists)
+ break; // break the outer for loop if 'isExists' is true
+ }
+ }
+ }
+ }
+
+ if (getSuperClass() != null) {
+ // If 'getSuperClass()' is not null, look for 'convertToId' attribute in plugin
+ // manifest file for this toolchain.
+ String convertToId = getSuperClass().getConvertToId();
+ if ((convertToId == null) || (convertToId.equals(""))) { //$NON-NLS-1$
+ // It means there is no 'convertToId' attribute available and
+ // the version is still actively
+ // supported by the tool integrator. So do nothing, just return
+ return;
+ } else {
+ // In case the 'convertToId' attribute is available,
+ // it means that Tool integrator currently does not support this
+ // version of toolchain.
+ // Look for the converters available for this toolchain version.
+
+ getConverter(convertToId);
+ }
+
+ } else {
+ // make the project is invalid
+ //
+ IConfiguration parentConfig = getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ }
+ return;
+ }
+
+ private void getConverter(String convertToId) {
+
+ String fromId = null;
+ String toId = null;
+
+ // Get the Converter Extension Point
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
+ "projectConverter"); //$NON-NLS-1$
+ if (extensionPoint != null) {
+ // Get the extensions
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ // Get the configuration elements of each extension
+ IConfigurationElement[] configElements = extensions[i]
+ .getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+
+ IConfigurationElement element = configElements[j];
+
+ if (element.getName().equals("converter")) { //$NON-NLS-1$
+
+ fromId = element.getAttribute("fromId"); //$NON-NLS-1$
+ toId = element.getAttribute("toId"); //$NON-NLS-1$
+ // Check whether the current converter can be used for
+ // the selected toolchain
+
+ if (fromId.equals(getSuperClass().getId())
+ && toId.equals(convertToId)) {
+ // If it matches
+ String mbsVersion = element
+ .getAttribute("mbsVersion"); //$NON-NLS-1$
+ PluginVersionIdentifier currentMbsVersion = ManagedBuildManager
+ .getBuildInfoVersion();
+
+ // set the converter element based on the MbsVersion
+ if (currentMbsVersion
+ .isGreaterThan(new PluginVersionIdentifier(
+ mbsVersion))) {
+ previousMbsVersionConversionElement = element;
+ } else {
+ currentMbsVersionConversionElement = element;
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ // If control comes here, it means 'Tool Integrator' specified
+ // 'convertToId' attribute in toolchain definition file, but
+ // has not provided any converter.
+ // So, make the project is invalid
+
+ IConfiguration parentConfig = getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ }
+
+
+ public IConfigurationElement getPreviousMbsVersionConversionElement() {
+ return previousMbsVersionConversionElement;
+ }
+
+ public IConfigurationElement getCurrentMbsVersionConversionElement() {
+ return currentMbsVersionConversionElement;
+ }
}
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java,v
retrieving revision 1.33
diff -u -r1.33 ToolReference.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java 6 Jun 2005 15:51:49 -0000 1.33
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java 9 Jun 2005 20:44:44 -0000
@@ -1222,4 +1222,14 @@
public String getManagedBuildRevision() {
return null;
}
+
+ public IConfigurationElement getPreviousMbsVersionConversionElement() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IConfigurationElement getCurrentMbsVersionConversionElement() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Index: schema/Converter.exsd
===================================================================
RCS file: schema/Converter.exsd
diff -N schema/Converter.exsd
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ schema/Converter.exsd 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,163 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.core" id="Converter" name="Converter"/>
+ </appInfo>
+ <documentation>
+ This extension point allows a tool integrator to contribute a project-type/tool-chain/tool/builder converter to MBS.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="converter" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="converter">
+ <annotation>
+ <documentation>
+ This extension point allows a tool integrator to contribute a project-type/tool-chain/tool/builder converter to MBS. Converters can be used to upgrade to newer versions, change the project-type, or to perform conversions between different tool chains/tools/buiders.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="fromId" type="string" use="required">
+ <annotation>
+ <documentation>
+ The 'fromId' is project-type/tool-chain/tool/builder id - a regular expression.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="toId" type="string" use="required">
+ <annotation>
+ <documentation>
+ The 'toId' is project-type/tool-chain/tool/builder id - a regular expression.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="mbsVersion" type="string" use="required">
+ <annotation>
+ <documentation>
+ The MBS version the converter was written for.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The class that implements the IConvertManagedBuildObject interface
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The id of the converter
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ The name of the converter that is used in User Interface to display to the user
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ CDT version 3.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ <p>
+ <pre>
+ <extension point="org.eclipse.cdt.managedbuilder.core.converter">
+ <converter
+ fromId="project-type/tool-chain/tool/builder id"
+ toId="project-type/tool-chain/tool/builder id"
+ mbsVersion="The MBS version the converter was written for"
+ class="org.eclipse.cdt.managedbuilder.core.GccConverter">
+ </converter>
+ </extension>
+ </pre>
+ </p>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ Plugins that want to extend this extension point must implement
+"org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject" interface
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ "Example plugin" has default implementation of the converter
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ /**********************************************************************
+ * Copyright (c) 2005 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
Index: src/org/eclipse/cdt/managedbuilder/core/IConvertManagedBuildObject.java
===================================================================
RCS file: src/org/eclipse/cdt/managedbuilder/core/IConvertManagedBuildObject.java
diff -N src/org/eclipse/cdt/managedbuilder/core/IConvertManagedBuildObject.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/managedbuilder/core/IConvertManagedBuildObject.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+
+public interface IConvertManagedBuildObject {
+ public IBuildObject convert(IBuildObject buildObj, String fromId, String toId, boolean isConfirmed);
+}
Index: src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java,v
retrieving revision 1.16
diff -u -r1.16 ManageConfigDialog.java
--- src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java 3 May 2005 13:49:50 -0000 1.16
+++ src/org/eclipse/cdt/managedbuilder/ui/properties/ManageConfigDialog.java 9 Jun 2005 20:56:20 -0000
@@ -14,14 +14,21 @@
import java.util.SortedMap;
import java.util.TreeMap;
+import org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
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.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -83,6 +90,11 @@
private Combo conversionTargetSelector;
private Button convertTargetBtn;
+ private Composite conversionGroup;
+
+ // The list of conversion targets for the selected configuration
+ private SortedMap conversionTargets;
+
// Widgets
protected List currentConfigList;
@@ -173,13 +185,15 @@
});
// Create a composite for the conversion target combo
- final Composite conversionGroup = new Composite(configListGroup, SWT.NULL);
+// final Composite conversionGroup = new Composite(configListGroup, SWT.NULL);
+ conversionGroup = new Composite(configListGroup, SWT.NULL);
conversionGroup.setFont(configListGroup.getFont());
conversionGroup.setLayout(new GridLayout(2, true));
conversionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Create the Tool chain conversion target list
Label conversionTargetLabel = ControlFactory.createLabel(conversionGroup, ManagedBuilderUIMessages.getResourceString(CONVERSION_TARGET_LABEL));
+
conversionTargetSelector = new Combo(conversionGroup, SWT.READ_ONLY|SWT.DROP_DOWN);
conversionTargetSelector.addListener(SWT.Selection, new Listener () {
public void handleEvent(Event e) {
@@ -187,6 +201,7 @@
}
});
conversionTargetSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONVERSION_TARGET_TIP));
+ conversionTargetSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Create a composite for the buttons
final Composite buttonBar = new Composite(configListGroup, SWT.NULL);
@@ -250,9 +265,38 @@
}
private void handleConversionTargetSelection() {
- return;
+ IConfigurationElement element = null;
+ String selectedConversionTargetName = null;
+
+ // Determine which conversion target was selected
+ int selectionIndex = conversionTargetSelector.getSelectionIndex();
+ if (selectionIndex != -1) {
+ // Get the converter based on selection
+ selectedConversionTargetName = conversionTargetSelector.getItem(selectionIndex);
+ element = (IConfigurationElement) getConversionTargets().get(selectedConversionTargetName);
+
+ // Get the confirmation from the user
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldConvert = MessageDialog.openQuestion(shell,
+ ManagedBuilderUIMessages.getResourceString("ConfigurationConvert.confirmdialog.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getFormattedString("ConfigurationConvert.confirmdialog.message", //$NON-NLS-1$
+ new String[] {getSelectedConfiguration().getName(), getSelectedConfiguration().getToolChain().getName(), element.getAttribute("name")})); //$NON-NLS-1$
+ if (shouldConvert) {
+ IConvertManagedBuildObject convertBuildObject = null;
+ try {
+ convertBuildObject = (IConvertManagedBuildObject) element.createExecutableExtension("class"); //$NON-NLS-1$
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ String fromId = element.getAttribute("fromId"); //$NON-NLS-1$
+ String toId = element.getAttribute("toId"); //$NON-NLS-1$
+
+ if(convertBuildObject != null )
+ convertBuildObject.convert( getSelectedConfiguration().getToolChain(), fromId, toId, true);
+ }
+ }
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@@ -289,17 +333,71 @@
}
private String [] getConversionTargetList(IConfiguration config) {
- // This is temporary, once I implement backend & converter extension point,
- // this will be replaced with original code.
- String [] conversionTargetNames = { "GNU Toolchain version 4.0"}; //$NON-NLS-1$
- return conversionTargetNames;
+
+ String []emptyList = new String[0];
+
+ String fromId = null;
+
+ // Get the id of the toolchain used in the given configuration.
+ String id = config.getToolChain().getId();
+
+ // Clear the conversionTargets list.
+ getConversionTargets().clear();
+
+ // Get the Converter Extension Point
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
+ "projectConverter"); //$NON-NLS-1$
+ if (extensionPoint != null) {
+ // Get the extensions
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ // Get the configuration elements of each extension
+ IConfigurationElement[] configElements = extensions[i]
+ .getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+
+ IConfigurationElement element = configElements[j];
+ if (element.getName().equals("converter")) { //$NON-NLS-1$
+
+ fromId = element.getAttribute("fromId"); //$NON-NLS-1$
+ // Check whether the current converter can be used for the selected configuration(toolchain)
+ if (hasToolChainConverters(config.getToolChain(), fromId)) {
+ // Add this converter to the display list
+ getConversionTargets().put( element.getAttribute("name"), element); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ if ( getConversionTargets().isEmpty())
+ return (String []) emptyList;
+ else
+ return (String []) getConversionTargets().keySet().toArray(new String[getConversionTargets().size()]);
+ }
+
+ private boolean hasToolChainConverters(IToolChain toolChain, String fromId) {
+
+// Check whether the converter's 'fromId' and the given toolChain 'id' are equal
+ if(fromId == null)
+ return false;
+
+ while( toolChain != null) {
+ String id = toolChain.getId();
+
+ if (fromId.equals(id))
+ return true;
+ else
+ toolChain = toolChain.getSuperClass();
+ }
+ return false;
}
private void updateConversionTargets(IConfiguration config) {
conversionTargetSelector.setItems( getConversionTargetList(config));
conversionTargetSelector.select(0);
- conversionTargetSelector.setEnabled(conversionTargetSelector.getItemCount() > 1);
- convertTargetBtn.setEnabled( conversionTargetSelector.getItemCount() > 1);
+ conversionGroup.setEnabled(conversionTargetSelector.getItemCount() > 0);
+ convertTargetBtn.setEnabled( conversionTargetSelector.getItemCount() > 0);
}
private String [] getConfigurationNamesAndDescriptions() {
@@ -337,6 +435,13 @@
}
+ protected SortedMap getConversionTargets() {
+ if (conversionTargets == null) {
+ conversionTargets = new TreeMap();
+ }
+ return conversionTargets;
+ }
+
/*
* @return the <code>IProject</code> associated with the managed project
*/
@@ -525,7 +630,7 @@
private void updateButtons() {
// Disable the remove button if there is only 1 configuration
removeBtn.setEnabled(currentConfigList.getItemCount() > 1);
- convertTargetBtn.setEnabled( conversionTargetSelector.getItemCount() > 1);
+ convertTargetBtn.setEnabled( conversionTargetSelector.getItemCount() > 0);
}
private void handleConfigSelection() {
Index: src/org/eclipse/cdt/managedbuilder/internal/ui/ConvertStartup.java
===================================================================
RCS file: src/org/eclipse/cdt/managedbuilder/internal/ui/ConvertStartup.java
diff -N src/org/eclipse/cdt/managedbuilder/internal/ui/ConvertStartup.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/managedbuilder/internal/ui/ConvertStartup.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.managedbuilder.internal.ui;
+
+import org.eclipse.cdt.managedbuilder.ui.actions.ConvertTargetAction;
+import org.eclipse.ui.IStartup;
+
+
+public class ConvertStartup implements IStartup {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IStartup#earlyStartup()
+ */
+ /*
+ * This code is needed incase we want to add cascading menu for project converters in UI.
+ */
+ public void earlyStartup() {
+ ConvertTargetAction.initStartup();
+ }
+}
Index: src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java
===================================================================
RCS file: src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java
diff -N src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/managedbuilder/ui/actions/ConvertTargetAction.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Intel Corporation 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:
+ * Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+
+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.Platform;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionDelegate;
+
+public class ConvertTargetAction
+ extends ActionDelegate
+ implements IObjectActionDelegate {
+
+ private String converterId = null;
+ private String fromId = null;
+ private String toId = null;
+ private IConvertManagedBuildObject convertBuildObject = null;
+ private IProject selectedProject = null;
+
+ public static void initStartup() {
+ return;
+ }
+
+ public void initConvertAction(IAction action) {
+ convertBuildObject = null;
+ String id = action.getId();
+ try {
+
+ // Get the Converter Extension Point
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
+ "projectConverter"); //$NON-NLS-1$
+ if (extensionPoint != null) {
+ // Get the Converter Extensions
+ IExtension[] extensions = extensionPoint.getExtensions();
+ List list = new ArrayList(extensions.length);
+ for (int i = 0; i < extensions.length; i++) {
+
+ // Get the configuration elements for each extension
+ IConfigurationElement[] configElements = extensions[i]
+ .getConfigurationElements();
+
+ for (int j = 0; j < configElements.length; j++) {
+ IConfigurationElement element = configElements[j];
+
+ if (element.getName().equals("converter")) { //$NON-NLS-1$
+ // Get the converter 'id'
+ String tmpConverterID = element.getAttribute("id"); //$NON-NLS-1$
+ // If the converter 'id' and action 'id' are same.
+ if (id.equals(tmpConverterID)) {
+
+ convertBuildObject = (IConvertManagedBuildObject) element
+ .createExecutableExtension("class"); //$NON-NLS-1$
+ fromId = element.getAttribute("fromId"); //$NON-NLS-1$
+ toId = element.getAttribute("toId"); //$NON-NLS-1$
+ return;
+ }
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ initConvertAction(action);
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection sel = (IStructuredSelection) selection;
+ Object obj = sel.getFirstElement();
+ if (obj instanceof IProject) {
+ IProject project = (IProject)obj;
+
+ // Save the selected project.
+ setSelectedProject(project);
+
+ // If the project does not have managed build nature then disable the action.
+ try {
+ if(!project.hasNature("org.eclipse.cdt.managedbuilder.core.managedBuildNature")) { //$NON-NLS-1$
+ action.setEnabled(false);
+ return;
+ }
+ } catch (CoreException e) {
+// e.printStackTrace();
+ }
+
+ // Get the projectType of the project.
+ IProjectType projectType = getProjectType(project);
+
+ // Check whether the Converter can convert the selected project.
+ if( isProjectConvertable(projectType))
+ action.setEnabled(true);
+ else
+ action.setEnabled(false);
+ } else {
+ action.setEnabled(false);
+ }
+ }
+ }
+
+ private IProjectType getProjectType(IProject project) {
+ IProjectType projectType = null;
+
+ // Get the projectType from project.
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ if (info != null) {
+ IManagedProject managedProject = info.getManagedProject();
+ projectType = managedProject.getProjectType();
+ }
+ return projectType;
+ }
+
+
+ private boolean isProjectConvertable(IProjectType projectType) {
+
+ IProjectType tmpProjectType = projectType;
+
+// Check whether the converter can convert the given projectType
+ if(fromId == null)
+ return false;
+
+ while( tmpProjectType != null) {
+ String id = tmpProjectType.getId();
+
+ if (fromId.equals(id))
+ return true;
+ else
+ tmpProjectType = tmpProjectType.getSuperClass();
+ }
+ return false;
+ }
+
+
+
+ public void run(IAction action) {
+ if( convertBuildObject != null) {
+// Get the confirmation from user before converting the selected project
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldConvert = MessageDialog.openQuestion(shell,
+ ManagedBuilderUIMessages.getResourceString("ProjectConvert.confirmdialog.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getFormattedString("ProjectConvert.confirmdialog.message", //$NON-NLS-1$
+ new String[] {getSelectedProject().getName()}));
+
+ if (shouldConvert) {
+ convertBuildObject.convert( getProjectType(getSelectedProject()), getFromId(), getToId(), true);
+ }
+ }
+
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private IConvertManagedBuildObject getConvertBuildObject() {
+ return convertBuildObject;
+ }
+
+ private void setConvertBuildObject(IConvertManagedBuildObject convertBuildObject) {
+ this.convertBuildObject = convertBuildObject;
+ }
+
+ private String getConverterId() {
+ return converterId;
+ }
+
+ private void setConverterId(String converterId) {
+ this.converterId = converterId;
+ }
+
+ private String getFromId() {
+ return fromId;
+ }
+
+ private void setFromId(String fromId) {
+ this.fromId = fromId;
+ }
+
+ /**
+ * @return Returns the selectedProject.
+ */
+ private IProject getSelectedProject() {
+ return selectedProject;
+ }
+
+ /**
+ * @param selectedProject The selectedProject to set.
+ */
+ private void setSelectedProject(IProject selectedProject) {
+ this.selectedProject = selectedProject;
+ }
+
+ /**
+ * @return Returns the toId.
+ */
+ private String getToId() {
+ return toId;
+ }
+
+ /**
+ * @param toId The toId to set.
+ */
+ private void setToId(String toId) {
+ this.toId = toId;
+ }
+}