mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Commit for Leo Treggiari -- Bug 80820 Two problems for converting 1.2 projects using 3rd party tool integrations
If there is no match for an option in the project being converted, ignore the option and continue converting the configuration Patch tool lookup in converters to handle the case where the location of the definition fools the manifest reader and effectively hides the tool
This commit is contained in:
parent
e7908d52e2
commit
3abb569374
5 changed files with 98 additions and 109 deletions
Binary file not shown.
Binary file not shown.
|
@ -52,8 +52,10 @@ public class ManagedProjectUpdateTests extends TestCase {
|
|||
|
||||
private IProject[] createVersionProjects(String version){
|
||||
File file = getVersionProjectsDir(version);
|
||||
if(file == null)
|
||||
if(file == null) {
|
||||
fail("Test project directory " + file.getName() + " is missing.");
|
||||
return null;
|
||||
}
|
||||
|
||||
File projectZips[] = file.listFiles(new FileFilter(){
|
||||
public boolean accept(File pathname){
|
||||
|
@ -80,8 +82,10 @@ public class ManagedProjectUpdateTests extends TestCase {
|
|||
catch(Exception e){
|
||||
}
|
||||
}
|
||||
if(projectList.size() == 0)
|
||||
if(projectList.size() == 0) {
|
||||
fail("No projects found in test project directory " + file.getName() + ". The .zip file may be missing or corrupt.");
|
||||
return null;
|
||||
}
|
||||
return (IProject[])projectList.toArray(new IProject[projectList.size()]);
|
||||
}
|
||||
|
||||
|
|
|
@ -218,6 +218,7 @@ class UpdateManagedProject12 {
|
|||
convertToolRef(toolChain, (Element) toolRefNodes.item(refIndex), monitor);
|
||||
}
|
||||
catch(CoreException e){
|
||||
// TODO: Need error dialog!
|
||||
newProject.removeConfiguration(newConfigId);
|
||||
throw e;
|
||||
}
|
||||
|
@ -233,7 +234,7 @@ class UpdateManagedProject12 {
|
|||
String optId = null;
|
||||
String[] idTokens = oldId.split(REGEXP_SEPARATOR);
|
||||
Vector oldIdVector = new Vector(Arrays.asList(idTokens));
|
||||
if (isBuiltInOption(oldIdVector)) {
|
||||
if (isBuiltInOption(oldIdVector)) {
|
||||
|
||||
// New ID will be in form gnu.[c|c++|both].[compiler|link|lib].option.{1.2_component}
|
||||
Vector newIdVector = new Vector(idTokens.length + 2);
|
||||
|
@ -314,7 +315,6 @@ class UpdateManagedProject12 {
|
|||
// ignore this exception too
|
||||
}
|
||||
|
||||
|
||||
// Construct the new ID
|
||||
optId = new String();
|
||||
for (int rebuildIndex = 0; rebuildIndex < newIdVector.size(); ++ rebuildIndex) {
|
||||
|
@ -350,8 +350,7 @@ class UpdateManagedProject12 {
|
|||
|
||||
return curOption.getId();
|
||||
}
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
|
||||
ConverterMessages.getFormattedString("UpdateManagedProject12.3",optId), null)); //$NON-NLS-1$
|
||||
return optId;
|
||||
}
|
||||
|
||||
protected static void convertOptionRef(IToolChain toolChain, ITool tool, Element optRef)
|
||||
|
@ -362,51 +361,47 @@ class UpdateManagedProject12 {
|
|||
optId = getNewOptionId(toolChain, tool, optId);
|
||||
// Get the option from the new tool
|
||||
IOption newOpt = tool.getOptionById(optId);
|
||||
if (newOpt == null) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
|
||||
ConverterMessages.getFormattedString("UpdateManagedProject12.4",optId), null)); //$NON-NLS-1$
|
||||
}
|
||||
if (newOpt != null) { // Ignore options that don't have a match
|
||||
IConfiguration configuration = toolChain.getParent();
|
||||
|
||||
IConfiguration configuration = toolChain.getParent();
|
||||
|
||||
try {
|
||||
switch (newOpt.getValueType()) {
|
||||
case IOption.BOOLEAN:
|
||||
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
|
||||
configuration.setOption(tool, newOpt, bool.booleanValue());
|
||||
break;
|
||||
case IOption.STRING:
|
||||
case IOption.ENUMERATED:
|
||||
// This is going to be the human readable form of the enumerated value
|
||||
String name = (String) optRef.getAttribute(IOption.DEFAULT_VALUE);
|
||||
// Convert it to the ID
|
||||
String idValue = newOpt.getEnumeratedId(name);
|
||||
configuration.setOption(tool, newOpt, idValue != null ? idValue : name);
|
||||
break;
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.INCLUDE_PATH:
|
||||
case IOption.PREPROCESSOR_SYMBOLS:
|
||||
case IOption.LIBRARIES:
|
||||
case IOption.OBJECTS:
|
||||
Vector values = new Vector();
|
||||
NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
|
||||
for (int i = 0; i < nodes.getLength(); ++i) {
|
||||
Node node = nodes.item(i);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
|
||||
if (!isBuiltIn.booleanValue()) {
|
||||
values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
|
||||
try {
|
||||
switch (newOpt.getValueType()) {
|
||||
case IOption.BOOLEAN:
|
||||
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
|
||||
configuration.setOption(tool, newOpt, bool.booleanValue());
|
||||
break;
|
||||
case IOption.STRING:
|
||||
case IOption.ENUMERATED:
|
||||
// This is going to be the human readable form of the enumerated value
|
||||
String name = (String) optRef.getAttribute(IOption.DEFAULT_VALUE);
|
||||
// Convert it to the ID
|
||||
String idValue = newOpt.getEnumeratedId(name);
|
||||
configuration.setOption(tool, newOpt, idValue != null ? idValue : name);
|
||||
break;
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.INCLUDE_PATH:
|
||||
case IOption.PREPROCESSOR_SYMBOLS:
|
||||
case IOption.LIBRARIES:
|
||||
case IOption.OBJECTS:
|
||||
Vector values = new Vector();
|
||||
NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
|
||||
for (int i = 0; i < nodes.getLength(); ++i) {
|
||||
Node node = nodes.item(i);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
|
||||
if (!isBuiltIn.booleanValue()) {
|
||||
values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
configuration.setOption(tool, newOpt, (String[])values.toArray(new String[values.size()]));
|
||||
break;
|
||||
configuration.setOption(tool, newOpt, (String[])values.toArray(new String[values.size()]));
|
||||
break;
|
||||
}
|
||||
} catch (BuildException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
|
||||
ConverterMessages.getFormattedString("UpdateManagedProject12.5",e.getMessage()), e)); //$NON-NLS-1$
|
||||
}
|
||||
} catch (BuildException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
|
||||
ConverterMessages.getFormattedString("UpdateManagedProject12.5",e.getMessage()), e)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -582,17 +577,15 @@ class UpdateManagedProject12 {
|
|||
ITool parent = curTool.getSuperClass();
|
||||
String curToolId = curTool.getId();
|
||||
|
||||
while (parent != null) {
|
||||
String parentId = parent.getId();
|
||||
if(parentId.equals(toolId))
|
||||
break;
|
||||
parent = parent.getSuperClass();
|
||||
}
|
||||
if(parent == null)
|
||||
continue;
|
||||
|
||||
parent = parent.getSuperClass();
|
||||
if(parent == null)
|
||||
continue;
|
||||
|
||||
String parentId = parent.getId();
|
||||
if(!parentId.equals(toolId))
|
||||
continue;
|
||||
|
||||
try{
|
||||
Integer.decode(curToolId.substring(curToolId.lastIndexOf('.')+1)); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -611,9 +604,7 @@ class UpdateManagedProject12 {
|
|||
protected static void convertToolRef(IToolChain toolChain, Element oldToolRef, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
String toolId = oldToolRef.getAttribute(IToolReference.ID);
|
||||
|
||||
toolId = getNewToolId(toolChain, toolId);
|
||||
|
||||
IConfiguration configuration = toolChain.getParent();
|
||||
|
||||
// Get the new tool out of the configuration
|
||||
|
|
|
@ -286,17 +286,15 @@ class UpdateManagedProject20 {
|
|||
ITool parent = curTool.getSuperClass();
|
||||
String curToolId = curTool.getId();
|
||||
|
||||
while (parent != null) {
|
||||
String parentId = parent.getId();
|
||||
if(parentId.equals(toolId))
|
||||
break;
|
||||
parent = parent.getSuperClass();
|
||||
}
|
||||
if(parent == null)
|
||||
continue;
|
||||
|
||||
parent = parent.getSuperClass();
|
||||
if(parent == null)
|
||||
continue;
|
||||
|
||||
String parentId = parent.getId();
|
||||
if(!parentId.equals(toolId))
|
||||
continue;
|
||||
|
||||
try{
|
||||
Integer.decode(curToolId.substring(curToolId.lastIndexOf('.')+1)); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -374,56 +372,52 @@ class UpdateManagedProject20 {
|
|||
if(option == null)
|
||||
option = tool.getOptionById(optId);
|
||||
|
||||
if(option == null){
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
|
||||
ConverterMessages.getFormattedString("UpdateManagedProject20.7",optId), null)); //$NON-NLS-1$
|
||||
}
|
||||
if (option != null) { // Ignore options that don't have a match
|
||||
try{
|
||||
int type = option.getValueType();
|
||||
|
||||
try{
|
||||
int type = option.getValueType();
|
||||
|
||||
switch(type){
|
||||
case IOption.BOOLEAN:{
|
||||
if(optRef.hasAttribute(IOption.DEFAULT_VALUE)){
|
||||
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
|
||||
configuration.setOption(tool,option,bool.booleanValue());
|
||||
switch(type){
|
||||
case IOption.BOOLEAN:{
|
||||
if(optRef.hasAttribute(IOption.DEFAULT_VALUE)){
|
||||
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
|
||||
configuration.setOption(tool,option,bool.booleanValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IOption.ENUMERATED:
|
||||
case IOption.STRING:{
|
||||
if(optRef.hasAttribute(IOption.DEFAULT_VALUE))
|
||||
configuration.setOption(tool,option,optRef.getAttribute(IOption.DEFAULT_VALUE));
|
||||
break;
|
||||
}
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.INCLUDE_PATH:
|
||||
case IOption.PREPROCESSOR_SYMBOLS:
|
||||
case IOption.LIBRARIES:
|
||||
case IOption.OBJECTS:{
|
||||
Vector values = new Vector();
|
||||
NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
|
||||
for (int j = 0; j < nodes.getLength(); ++j) {
|
||||
Node node = nodes.item(j);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
|
||||
if (!isBuiltIn.booleanValue()) {
|
||||
values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
|
||||
case IOption.ENUMERATED:
|
||||
case IOption.STRING:{
|
||||
if(optRef.hasAttribute(IOption.DEFAULT_VALUE))
|
||||
configuration.setOption(tool,option,optRef.getAttribute(IOption.DEFAULT_VALUE));
|
||||
break;
|
||||
}
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.INCLUDE_PATH:
|
||||
case IOption.PREPROCESSOR_SYMBOLS:
|
||||
case IOption.LIBRARIES:
|
||||
case IOption.OBJECTS:{
|
||||
Vector values = new Vector();
|
||||
NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
|
||||
for (int j = 0; j < nodes.getLength(); ++j) {
|
||||
Node node = nodes.item(j);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
|
||||
if (!isBuiltIn.booleanValue()) {
|
||||
values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
|
||||
}
|
||||
}
|
||||
}
|
||||
configuration.setOption(tool,option,(String[])values.toArray(new String[values.size()]));
|
||||
break;
|
||||
}
|
||||
configuration.setOption(tool,option,(String[])values.toArray(new String[values.size()]));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
catch(BuildException e){
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
|
||||
ConverterMessages.getFormattedString("UpdateManagedProject20.8",e.getMessage()), e)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
catch(BuildException e){
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
|
||||
ConverterMessages.getFormattedString("UpdateManagedProject20.8",e.getMessage()), e)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue