mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Tool-chain modification fixes
This commit is contained in:
parent
1731b69f79
commit
0cb1316547
7 changed files with 153 additions and 25 deletions
|
@ -10,7 +10,15 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
|
||||
|
@ -20,11 +28,14 @@ public class ConverterInfo {
|
|||
private IBuildObject fToObject;
|
||||
private IConfigurationElement fConverterElement;
|
||||
private boolean fIsConversionPerformed;
|
||||
private IResourceInfo fRcInfo;
|
||||
// private IManagedProject fMProj;
|
||||
|
||||
public ConverterInfo(IBuildObject fromObject, IBuildObject toObject, IConfigurationElement el){
|
||||
public ConverterInfo(IResourceInfo rcInfo, IBuildObject fromObject, IBuildObject toObject, IConfigurationElement el){
|
||||
fFromObject = fromObject;
|
||||
fToObject = toObject;
|
||||
fConverterElement = el;
|
||||
fRcInfo = rcInfo;
|
||||
}
|
||||
|
||||
public IBuildObject getFromObject(){
|
||||
|
@ -41,9 +52,34 @@ public class ConverterInfo {
|
|||
|
||||
public IBuildObject getConvertedFromObject(){
|
||||
if(!fIsConversionPerformed){
|
||||
ManagedProject mProj = getManagedProject();
|
||||
IConfiguration[] cfgs = mProj.getConfigurations();
|
||||
fConvertedFromObject = ManagedBuildManager.convert(fFromObject, fToObject.getId(), true);
|
||||
IConfiguration[] updatedCfgs = mProj.getConfigurations();
|
||||
Set oldSet = new HashSet(Arrays.asList(cfgs));
|
||||
Set updatedSet = new HashSet(Arrays.asList(updatedCfgs));
|
||||
Set oldSetCopy = new HashSet(oldSet);
|
||||
oldSet.removeAll(updatedSet);
|
||||
updatedSet.removeAll(oldSetCopy);
|
||||
if(updatedSet.size() != 0){
|
||||
for(Iterator iter = updatedSet.iterator(); iter.hasNext();){
|
||||
Configuration cfg = (Configuration)iter.next();
|
||||
mProj.removeConfiguration(cfg.getId());
|
||||
}
|
||||
}
|
||||
if(oldSet.size() != 0){
|
||||
for(Iterator iter = oldSet.iterator(); iter.hasNext();){
|
||||
mProj.applyConfiguration((Configuration)iter.next());
|
||||
}
|
||||
}
|
||||
fIsConversionPerformed = true;
|
||||
}
|
||||
return fConvertedFromObject;
|
||||
}
|
||||
|
||||
private ManagedProject getManagedProject(){
|
||||
if(fRcInfo != null)
|
||||
return (ManagedProject)fRcInfo.getParent().getManagedProject();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
|||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
|
@ -730,6 +731,21 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
|
|||
|
||||
public boolean isToolChainCompatible(IToolChain tCh){
|
||||
boolean compatible = false;
|
||||
if(tCh == toolChain)
|
||||
return true;
|
||||
|
||||
if(tCh == null){
|
||||
tCh = ManagedBuildManager.getExtensionToolChain(ConfigurationDataProvider.PREF_TC_ID);
|
||||
}
|
||||
|
||||
if(tCh == null)
|
||||
return false;
|
||||
|
||||
IToolChain curReal = ManagedBuildManager.getRealToolChain(toolChain);
|
||||
IToolChain newReal = ManagedBuildManager.getRealToolChain(tCh);
|
||||
|
||||
if(curReal == newReal)
|
||||
return true;
|
||||
|
||||
if(tCh != null){
|
||||
if(getToolChainConverterInfo(tCh) != null)
|
||||
|
@ -843,11 +859,33 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
|
|||
|
||||
void updateToolChainWithConverter(ConverterInfo cInfo, String Id, String name) throws BuildException{
|
||||
IBuildObject bo = cInfo.getConvertedFromObject();
|
||||
if(!(bo instanceof ToolChain)){
|
||||
ToolChain updatedToolChain = null;
|
||||
if(bo instanceof Configuration){
|
||||
Configuration cfg = (Configuration)bo;
|
||||
if(cfg != getParent()){
|
||||
IResourceInfo rcInfo = cfg.getResourceInfo(getPath(), true);
|
||||
if(rcInfo instanceof FolderInfo){
|
||||
IToolChain tc = ((FolderInfo)rcInfo).getToolChain();
|
||||
IToolChain realToToolChain = ManagedBuildManager.getRealToolChain((IToolChain)cInfo.getToObject());
|
||||
if(ManagedBuildManager.getRealToolChain(tc) == realToToolChain){
|
||||
updatedToolChain = (ToolChain)tc;
|
||||
}
|
||||
}
|
||||
|
||||
if(updatedToolChain == null){
|
||||
updatedToolChain = (ToolChain)cfg.getRootFolderInfo().getToolChain();
|
||||
}
|
||||
} else {
|
||||
updatedToolChain = toolChain;
|
||||
}
|
||||
} else if(bo instanceof ToolChain){
|
||||
updatedToolChain = (ToolChain)bo;
|
||||
} else {
|
||||
throw new BuildException(ManagedMakeMessages.getResourceString("FolderInfo.4")); //$NON-NLS-1$
|
||||
}
|
||||
if(toolChain != bo){
|
||||
setUpdatedToolChain((ToolChain)bo);
|
||||
|
||||
if(updatedToolChain != null && toolChain != updatedToolChain){
|
||||
setUpdatedToolChain(updatedToolChain);
|
||||
}
|
||||
|
||||
toolChain.setName(name);
|
||||
|
@ -875,7 +913,7 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
|
|||
}
|
||||
|
||||
if(el != null)
|
||||
return new ConverterInfo(getToolChain(), foundToTc, el);
|
||||
return new ConverterInfo(this, getToolChain(), foundToTc, el);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1157,7 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
|
|||
|
||||
IConfigurationElement el = getToolConverterElement(r, a);
|
||||
if(el != null){
|
||||
resultMap.put(r, new ConverterInfo(r, a, el));
|
||||
resultMap.put(r, new ConverterInfo(this, r, a, el));
|
||||
rIter.remove();
|
||||
aIter.remove();
|
||||
break;
|
||||
|
@ -1374,7 +1412,10 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
|
|||
}
|
||||
|
||||
public boolean hasCustomSettings(){
|
||||
return toolChain.hasCustomSettings();
|
||||
IFolderInfo parentFo = getParentFolderInfo();
|
||||
if(parentFo == null)
|
||||
return true;
|
||||
return toolChain.hasCustomSettings((ToolChain)parentFo.getToolChain());
|
||||
}
|
||||
|
||||
public boolean containsDiscoveredScannerInfo(){
|
||||
|
|
|
@ -972,14 +972,34 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
|||
}
|
||||
|
||||
public boolean hasCustomSettings() {
|
||||
if(toolList != null && toolList.size() != 0){
|
||||
Tool tool;
|
||||
for(Iterator iter = toolList.iterator(); iter.hasNext();){
|
||||
tool = (Tool)iter.next();
|
||||
if(tool.hasCustomSettings())
|
||||
return true;
|
||||
}
|
||||
IResourceInfo parentRc = getParentResourceInfo();
|
||||
if(parentRc instanceof FolderInfo){
|
||||
IPath path = getPath();
|
||||
String ext = path.getFileExtension();
|
||||
if(ext == null)
|
||||
ext = "";
|
||||
ITool tool = ((FolderInfo)parentRc).getToolFromInputExtension(ext);
|
||||
if(tool == null)
|
||||
return true;
|
||||
|
||||
ITool[] tti = getToolsToInvoke();
|
||||
if(tti.length != 1)
|
||||
return true;
|
||||
|
||||
return ((Tool)tool).hasCustomSettings((Tool)tti[0]);
|
||||
}
|
||||
ITool[] tools = getTools();
|
||||
ITool[] otherTools = ((IFileInfo)parentRc).getTools();
|
||||
if(tools.length != otherTools.length)
|
||||
return true;
|
||||
|
||||
for(int i = 0; i < tools.length; i++){
|
||||
Tool tool = (Tool)tools[i];
|
||||
Tool otherTool = (Tool)otherTools[i];
|
||||
if(tool.hasCustomSettings(otherTool))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
|
|||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
|
@ -508,6 +509,22 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
|
|||
return path.makeRelative();
|
||||
}
|
||||
|
||||
protected ResourceInfo getParentResourceInfo(){
|
||||
if(isRoot())
|
||||
return null;
|
||||
|
||||
IPath path = getPath();
|
||||
path = path.removeLastSegments(1);
|
||||
return (ResourceInfo)getParent().getResourceInfo(path, false);
|
||||
}
|
||||
|
||||
protected IFolderInfo getParentFolderInfo(){
|
||||
ResourceInfo parentRc = getParentResourceInfo();
|
||||
for(; parentRc != null && !parentRc.isFolderInfo(); parentRc = parentRc.getParentResourceInfo());
|
||||
|
||||
return (IFolderInfo)parentRc;
|
||||
}
|
||||
|
||||
abstract void resolveProjectReferences(boolean onLoad);
|
||||
|
||||
abstract public boolean hasCustomSettings();
|
||||
|
|
|
@ -3966,11 +3966,16 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
|||
return id;
|
||||
}
|
||||
|
||||
public boolean hasCustomSettings(){
|
||||
public boolean hasCustomSettings(Tool tool){
|
||||
if(superClass == null)
|
||||
return true;
|
||||
|
||||
if(super.hasCustomSettings())
|
||||
ITool realTool = ManagedBuildManager.getRealTool(this);
|
||||
ITool otherRealTool = ManagedBuildManager.getRealTool(tool);
|
||||
if(realTool != otherRealTool)
|
||||
return true;
|
||||
|
||||
if(hasCustomSettings())
|
||||
return true;
|
||||
|
||||
if(inputTypeList != null && inputTypeList.size() != 0){
|
||||
|
|
|
@ -2669,20 +2669,28 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
|
|||
return tch != null && tch.getId().equals(ConfigurationDataProvider.PREF_TC_ID);
|
||||
}
|
||||
|
||||
public boolean hasCustomSettings(){
|
||||
public boolean hasCustomSettings(ToolChain tCh){
|
||||
if(superClass == null)
|
||||
return true;
|
||||
|
||||
if(super.hasCustomSettings())
|
||||
IToolChain realTc = ManagedBuildManager.getRealToolChain(this);
|
||||
IToolChain otherRealTc = ManagedBuildManager.getRealToolChain(tCh);
|
||||
if(realTc != otherRealTc)
|
||||
return true;
|
||||
|
||||
if(toolList != null && toolList.size() != 0){
|
||||
Tool tool;
|
||||
for(Iterator iter = toolList.iterator(); iter.hasNext();){
|
||||
tool = (Tool)iter.next();
|
||||
if(tool.hasCustomSettings())
|
||||
return true;
|
||||
}
|
||||
if(hasCustomSettings())
|
||||
return true;
|
||||
|
||||
ITool[] tools = getTools();
|
||||
ITool[] otherTools = tCh.getTools();
|
||||
if(tools.length != otherTools.length)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < tools.length; i++){
|
||||
Tool tool = (Tool)tools[i];
|
||||
Tool otherTool = (Tool)otherTools[i];
|
||||
if(tool.hasCustomSettings(otherTool))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
|||
super.createControls(parent);
|
||||
usercomp.setLayout(new GridLayout(2, false));
|
||||
b_dispCompatible = setupCheck(usercomp, Messages.getString("ToolChainEditTab.0"), 2, GridData.BEGINNING); //$NON-NLS-1$
|
||||
b_dispCompatible.setSelection(true);
|
||||
|
||||
setupLabel(usercomp, Messages.getString("ToolChainEditTab.1"), 2, GridData.BEGINNING); //$NON-NLS-1$
|
||||
c_toolchain = new Combo(usercomp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
|
||||
|
|
Loading…
Add table
Reference in a new issue