mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Tool-chain modification fixes: preserving includes/symbols/libs settings
This commit is contained in:
parent
6b053aa52a
commit
0a32923da7
2 changed files with 94 additions and 1 deletions
|
@ -11,13 +11,30 @@
|
|||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
|
||||
|
||||
public class BuildSettingsUtil {
|
||||
private static final int[] COMMON_SETTINGS_IDS = new int[]{
|
||||
IOption.INCLUDE_PATH,
|
||||
IOption.PREPROCESSOR_SYMBOLS,
|
||||
IOption.LIBRARIES,
|
||||
IOption.OBJECTS,
|
||||
IOption.INCLUDE_FILES,
|
||||
IOption.LIBRARY_PATHS,
|
||||
IOption.LIBRARY_FILES,
|
||||
IOption.MACRO_FILES,
|
||||
};
|
||||
|
||||
public static void disconnectDepentents(IConfiguration cfg, ITool[] tools){
|
||||
for(int i = 0; i < tools.length; i++){
|
||||
disconnectDepentents(cfg, tools[i]);
|
||||
|
@ -74,5 +91,46 @@ public class BuildSettingsUtil {
|
|||
return list;
|
||||
}
|
||||
|
||||
public static void copyCommonSettings(ITool fromTool, ITool toTool){
|
||||
Tool fromT = (Tool)fromTool;
|
||||
Tool toT = (Tool)toTool;
|
||||
List values = new ArrayList();
|
||||
for(int i = 0; i < COMMON_SETTINGS_IDS.length; i++){
|
||||
int type = COMMON_SETTINGS_IDS[i];
|
||||
IOption[] toOptions = toT.getOptionsOfType(type);
|
||||
if(toOptions.length == 0)
|
||||
continue;
|
||||
|
||||
IOption[] fromOptions = fromT.getOptionsOfType(type);
|
||||
values.clear();
|
||||
for(int k = 0; k < fromOptions.length; k++){
|
||||
Option fromOption = (Option)fromOptions[k];
|
||||
if(fromOption.getParent() != fromTool)
|
||||
continue;
|
||||
|
||||
List v = (List)fromOption.getExactValue();
|
||||
values.addAll(v);
|
||||
}
|
||||
|
||||
if(values.size() == 0)
|
||||
continue;
|
||||
|
||||
IOption toOption = toOptions[0];
|
||||
|
||||
try {
|
||||
OptionStringValue[] v = toOption.getBasicStringListValueElements();
|
||||
if(v.length != 0)
|
||||
values.addAll(Arrays.asList(v));
|
||||
} catch (BuildException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
|
||||
OptionStringValue[] v = (OptionStringValue[])values.toArray(new OptionStringValue[values.size()]);
|
||||
IResourceInfo rcInfo = toTool.getParentResourceInfo();
|
||||
|
||||
ManagedBuildManager.setOption(rcInfo, toTool, toOption, v);
|
||||
|
||||
values.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -894,11 +894,46 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
|
|||
newBuilder.copySettings(oldBuilder, false);
|
||||
}
|
||||
|
||||
//TODO: copy includes, symbols, etc.
|
||||
IManagedProject mProj = getParent().getManagedProject();
|
||||
ITool[] filteredTools = getFilteredTools();
|
||||
ITool[] oldFilteredTools = filterTools(oldTc.getTools(), mProj);
|
||||
|
||||
copySettings(oldFilteredTools, filteredTools);
|
||||
|
||||
toolChain.propertiesChanged();
|
||||
}
|
||||
|
||||
private void copySettings(ITool[] fromTools, ITool[] toTools){
|
||||
ITool[][] matches = getBestMatches(fromTools, toTools);
|
||||
for(int i = 0; i < matches.length; i++){
|
||||
BuildSettingsUtil.copyCommonSettings(matches[i][0], matches[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
private ITool[][] getBestMatches(ITool[] tools1, ITool[] tools2){
|
||||
HashSet set = new HashSet(Arrays.asList(tools2));
|
||||
List list = new ArrayList(tools1.length);
|
||||
for(int i = 0; i < tools1.length; i++){
|
||||
ITool tool1 = tools1[i];
|
||||
ITool bestMatchTool = null;
|
||||
int num = 0;
|
||||
for(Iterator iter = set.iterator(); iter.hasNext();){
|
||||
ITool tool2 = (ITool)iter.next();
|
||||
int extsNum = getConflictingInputExts(tool1, tool2).length;
|
||||
if(extsNum > num){
|
||||
bestMatchTool = tool2;
|
||||
num = extsNum;
|
||||
}
|
||||
}
|
||||
|
||||
if(bestMatchTool != null){
|
||||
list.add(new ITool[]{tool1, bestMatchTool});
|
||||
set.remove(bestMatchTool);
|
||||
}
|
||||
}
|
||||
return (ITool[][])list.toArray(new ITool[list.size()][]);
|
||||
}
|
||||
|
||||
void updateToolChainWithConverter(ConverterInfo cInfo, String Id, String name) throws BuildException{
|
||||
IBuildObject bo = cInfo.getConvertedFromObject();
|
||||
ToolChain updatedToolChain = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue