mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
1.File context macro support implemented
2.New MBS pre-defined macros added that represent tool/tool-chain/builder version 3.Some fixes for the option specific macros functionslity
This commit is contained in:
parent
4fa15e42ed
commit
fcddfaecbf
12 changed files with 195 additions and 162 deletions
|
@ -206,7 +206,7 @@ public class ManagedBuildMacrosTests extends TestCase {
|
|||
assertNotNull(opt);
|
||||
|
||||
// standard check of suppliers # and attempt to add macro (should fail)
|
||||
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,tc));
|
||||
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
|
||||
assertNotNull(ms);
|
||||
assertEquals(ms.length, 1);
|
||||
assertFalse(addMacro(TEST, IBuildMacro.VALUE_TEXT, TST[IBuildMacroProvider.CONTEXT_OPTION], IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t)));
|
||||
|
@ -214,7 +214,7 @@ public class ManagedBuildMacrosTests extends TestCase {
|
|||
// modify value and check that macros is resolved
|
||||
try {
|
||||
opt = cfgs[0].setOption(t, opt, "222 " + INC_DEF); //$NON-NLS-1$
|
||||
String a = mp.resolveValue(opt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,tc));
|
||||
String a = mp.resolveValue(opt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
|
||||
assertEquals(a, "222 111"); //$NON-NLS-1$
|
||||
} catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
||||
catch (BuildException e) { fail(e.getLocalizedMessage()); }
|
||||
|
@ -225,7 +225,7 @@ public class ManagedBuildMacrosTests extends TestCase {
|
|||
IOption ropt = rc.getTools()[0].getOptionById(OPT_IDS);
|
||||
try {
|
||||
ropt = rc.setOption(rc.getTools()[0], ropt, "333 " + INC_DEF); //$NON-NLS-1$
|
||||
String a = mp.resolveValue(ropt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,tc));
|
||||
String a = mp.resolveValue(ropt.getStringValue(), UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
|
||||
assertEquals(a, "333 111"); //$NON-NLS-1$
|
||||
} catch (Exception e) { fail(e.getLocalizedMessage()); }
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class ManagedBuildMacrosTests extends TestCase {
|
|||
IToolChain tc = cfgs[0].getToolChain();
|
||||
ITool t = cfgs[0].getTools()[0];
|
||||
IOption opt = t.getOptionById(OPT_IDL);
|
||||
OptionContextData ocd = new OptionContextData(opt,tc);
|
||||
OptionContextData ocd = new OptionContextData(opt,t);
|
||||
assertNotNull(opt);
|
||||
ms = mp.getSuppliers(IBuildMacroProvider.CONTEXT_OPTION, ocd);
|
||||
assertNotNull(ms);
|
||||
|
@ -259,7 +259,7 @@ public class ManagedBuildMacrosTests extends TestCase {
|
|||
ArrayList ar = new ArrayList(1);
|
||||
for (int i=0; i<set1.length; i++) {
|
||||
try {
|
||||
String[] aus = mp.resolveStringListValue(set1[i], UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,tc));
|
||||
String[] aus = mp.resolveStringListValue(set1[i], UNKNOWN, LISTSEP, IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(opt,t));
|
||||
if (aus == null) continue;
|
||||
for (int j=0; j<aus.length; j++) ar.add(aus[j]);
|
||||
} catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
||||
|
@ -326,14 +326,14 @@ public class ManagedBuildMacrosTests extends TestCase {
|
|||
values0wAbs[8] = dev1 + values0wAbs[8];
|
||||
values0wAbs[9] = dev1 + values0wAbs[9];
|
||||
|
||||
fd = new FileContextData(new Path(values0wAbs[3]), new Path(values0wAbs[8]),opt,cfgs[0].getToolChain());
|
||||
fd = new FileContextData(new Path(values0wAbs[3]), new Path(values0wAbs[8]),opt,t);
|
||||
for (int i=0; i<names.length; i++)
|
||||
try {
|
||||
assertEquals(values0wAbs[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
||||
} catch (BuildMacroException e) { fail(e.getLocalizedMessage()); }
|
||||
|
||||
// check that relative path are reported OK
|
||||
fd = new FileContextData(p.append(EIN), p.append(AUS),opt,cfgs[0].getToolChain());
|
||||
fd = new FileContextData(p.append(EIN), p.append(AUS),opt,t);
|
||||
for (int i=0; i<names.length; i++)
|
||||
try {
|
||||
assertEquals(values0wRel[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
||||
|
@ -368,7 +368,7 @@ public class ManagedBuildMacrosTests extends TestCase {
|
|||
|
||||
} else {
|
||||
// check relative path only
|
||||
fd = new FileContextData(p.append(EIN), p.append(AUS),opt,cfgs[0].getToolChain());
|
||||
fd = new FileContextData(p.append(EIN), p.append(AUS),opt,t);
|
||||
for (int i=0; i<names.length; i++)
|
||||
try {
|
||||
assertEquals(values0u[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
||||
|
@ -384,8 +384,8 @@ public class ManagedBuildMacrosTests extends TestCase {
|
|||
TST[IBuildMacroProvider.CONTEXT_FILE], IBuildMacroProvider.CONTEXT_FILE, fd));
|
||||
|
||||
// For config #3, macros should contain lines specified in plugin.xml
|
||||
opt = cfgs[3].getTools()[0].getOptions()[0];
|
||||
fd = new FileContextData(p.append(EIN), p.append(AUS),opt,cfgs[1].getToolChain());
|
||||
opt = cfgs[1].getTools()[0].getOptions()[0];
|
||||
fd = new FileContextData(p.append(EIN), p.append(AUS),opt,cfgs[1].getTools()[0]);
|
||||
for (int i=0; i<names.length; i++)
|
||||
try {
|
||||
assertEquals(values1[i], mp.getMacro(names[i], IBuildMacroProvider.CONTEXT_FILE, fd, flag).getStringValue());
|
||||
|
|
|
@ -434,7 +434,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(option, getDefaultConfiguration().getToolChain()));
|
||||
new OptionContextData(option, tool));
|
||||
if(resolved != null && resolved.length > 0){
|
||||
for(int k = 0; k < resolved.length; k++){
|
||||
String string = resolved[k];
|
||||
|
@ -733,8 +733,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(inputLocation,
|
||||
outputLocation, null,
|
||||
getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
tool));
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -747,8 +746,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(inputLocation,
|
||||
outputLocation, null,
|
||||
getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
tool));
|
||||
}
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
@ -790,7 +788,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(option, getDefaultConfiguration().getToolChain()));
|
||||
new OptionContextData(option, tool));
|
||||
if(resolved != null && resolved.length > 0)
|
||||
objs.addAll(Arrays.asList(resolved));
|
||||
} catch (BuildMacroException e) {
|
||||
|
@ -1342,12 +1340,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
if (entryType == IPathEntry.CDT_INCLUDE_FILE &&
|
||||
op[j].getValueType() == IOption.INCLUDE_PATH)
|
||||
{
|
||||
OptionContextData ocd = new OptionContextData(op[j], obj);
|
||||
OptionContextData ocd = new OptionContextData(op[j], t[i]);
|
||||
addIncludes(entries, builtIns ? op[j].getBuiltIns() : op[j].getIncludePaths(), resPath, ocd);
|
||||
} else if (entryType == IPathEntry.CDT_LIBRARY &&
|
||||
op[j].getValueType() == IOption.LIBRARIES)
|
||||
{
|
||||
OptionContextData ocd = new OptionContextData(op[j], obj);
|
||||
OptionContextData ocd = new OptionContextData(op[j], t[i]);
|
||||
addLibraries(entries, builtIns ? op[j].getBuiltIns() : op[j].getLibraries(), resPath, ocd);
|
||||
} else if (entryType == IPathEntry.CDT_MACRO &&
|
||||
op[j].getValueType() == IOption.PREPROCESSOR_SYMBOLS)
|
||||
|
|
|
@ -2107,7 +2107,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
|
|||
String strCmd = option.getCommand();
|
||||
String val = option.getStringValue();
|
||||
macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(inputFileLocation, outputFileLocation, option, getParent()));
|
||||
new FileContextData(inputFileLocation, outputFileLocation, option, this));
|
||||
if (val.length() > 0
|
||||
&& (val = MacroResolver.resolveToString(val, macroSubstitutor)).length() > 0) {
|
||||
sb.append( evaluateCommand( strCmd, val ) );
|
||||
|
@ -2117,7 +2117,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
|
|||
case IOption.STRING_LIST :
|
||||
String listCmd = option.getCommand();
|
||||
macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(inputFileLocation, outputFileLocation, option, getParent()));
|
||||
new FileContextData(inputFileLocation, outputFileLocation, option, this));
|
||||
String[] list = MacroResolver.resolveStringListValues(option.getStringListValue(), macroSubstitutor, true);
|
||||
if(list != null){
|
||||
for (int j = 0; j < list.length; j++) {
|
||||
|
@ -2131,7 +2131,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
|
|||
case IOption.INCLUDE_PATH :
|
||||
String incCmd = option.getCommand();
|
||||
macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(inputFileLocation, outputFileLocation, option, getParent()));
|
||||
new FileContextData(inputFileLocation, outputFileLocation, option, this));
|
||||
String[] paths = MacroResolver.resolveStringListValues(option.getIncludePaths(), macroSubstitutor, true);
|
||||
if(paths != null){
|
||||
for (int j = 0; j < paths.length; j++) {
|
||||
|
@ -2145,7 +2145,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
|
|||
case IOption.PREPROCESSOR_SYMBOLS :
|
||||
String defCmd = option.getCommand();
|
||||
macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(inputFileLocation, outputFileLocation, option, getParent()));
|
||||
new FileContextData(inputFileLocation, outputFileLocation, option, this));
|
||||
String[] symbols = MacroResolver.resolveStringListValues(option.getDefinedSymbols(), macroSubstitutor, true);
|
||||
if(symbols != null){
|
||||
for (int j = 0; j < symbols.length; j++) {
|
||||
|
|
|
@ -69,14 +69,14 @@ public class CheckStringExpression implements IBooleanExpression {
|
|||
" ", //$NON-NLS-1$
|
||||
delimiter,
|
||||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(option,configuration)
|
||||
new OptionContextData(option,holder)
|
||||
);
|
||||
|
||||
String resolvedValue = provider.resolveValue(fValue,
|
||||
" ", //$NON-NLS-1$
|
||||
delimiter,
|
||||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(option,configuration)
|
||||
new OptionContextData(option,holder)
|
||||
);
|
||||
|
||||
if(fIsRegex){
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.internal.macros;
|
|||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
|
@ -60,6 +61,13 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
|
|||
};
|
||||
}
|
||||
break;
|
||||
case IBuildMacroProvider.CONTEXT_TOOL:
|
||||
if(data instanceof ITool){
|
||||
return new IBuildMacroSupplier[]{
|
||||
BuildMacroProvider.fMbsMacroSupplier
|
||||
};
|
||||
}
|
||||
break;
|
||||
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
|
||||
if(data instanceof IConfiguration){
|
||||
return new IBuildMacroSupplier[]{
|
||||
|
@ -150,23 +158,31 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
|
|||
case IBuildMacroProvider.CONTEXT_OPTION:
|
||||
if(fData instanceof IOptionContextData){
|
||||
IOptionContextData optionContext = (IOptionContextData)fData;
|
||||
IBuildObject buildObj = optionContext.getParent();
|
||||
IHoldsOptions ho = OptionContextData.getHolder(optionContext);
|
||||
if(ho instanceof ITool)
|
||||
return new DefaultMacroContextInfo(
|
||||
IBuildMacroProvider.CONTEXT_TOOL,
|
||||
ho);
|
||||
else if(ho instanceof IToolChain)
|
||||
return new DefaultMacroContextInfo(
|
||||
IBuildMacroProvider.CONTEXT_CONFIGURATION,
|
||||
((IToolChain)ho).getParent());
|
||||
}
|
||||
break;
|
||||
case IBuildMacroProvider.CONTEXT_TOOL:
|
||||
if(fData instanceof ITool){
|
||||
IBuildObject parent = ((ITool)fData).getParent();
|
||||
IConfiguration cfg = null;
|
||||
if(buildObj instanceof ITool)
|
||||
buildObj = ((ITool)buildObj).getParent();
|
||||
if(buildObj instanceof IToolChain)
|
||||
cfg = ((IToolChain)buildObj).getParent();
|
||||
else if(buildObj instanceof IResourceConfiguration)
|
||||
cfg = ((IResourceConfiguration)buildObj).getParent();
|
||||
else if(buildObj instanceof IConfiguration)
|
||||
cfg = (IConfiguration)buildObj;
|
||||
if(parent instanceof IToolChain)
|
||||
cfg = ((IToolChain)parent).getParent();
|
||||
else if(parent instanceof IResourceConfiguration)
|
||||
cfg = ((IResourceConfiguration)parent).getParent();
|
||||
|
||||
if(cfg != null){
|
||||
if(cfg != null)
|
||||
return new DefaultMacroContextInfo(
|
||||
IBuildMacroProvider.CONTEXT_CONFIGURATION,
|
||||
cfg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
|
||||
if(fData instanceof IConfiguration){
|
||||
|
@ -209,5 +225,4 @@ public class DefaultMacroContextInfo implements IMacroContextInfo {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
|
|||
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.IHoldsOptions;
|
||||
import org.eclipse.cdt.managedbuilder.core.IInputType;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
|
@ -38,6 +39,7 @@ import org.eclipse.core.resources.IWorkspace;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
/**
|
||||
|
@ -66,6 +68,11 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
|
||||
private static final String fOptionMacros[] = new String[]{
|
||||
"IncludeDefaults", //$NON-NLS-1$
|
||||
"ParentVersion", //$NON-NLS-1$
|
||||
};
|
||||
|
||||
private static final String fToolMacros[] = new String[]{
|
||||
"ToolVersion", //$NON-NLS-1$
|
||||
};
|
||||
|
||||
private static final String fConfigurationMacros[] = new String[]{
|
||||
|
@ -77,6 +84,8 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
"BuildArtifactFilePrefix", //$NON-NLS-1$
|
||||
"TargetOsList", //$NON-NLS-1$
|
||||
"TargetArchList", //$NON-NLS-1$
|
||||
"ToolChainVersion", //$NON-NLS-1$
|
||||
"BuilderVersion", //$NON-NLS-1$
|
||||
};
|
||||
|
||||
private static final String fProjectMacros[] = new String[]{
|
||||
|
@ -271,6 +280,9 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
case IBuildMacroProvider.CONTEXT_OPTION:
|
||||
names = fOptionMacros;
|
||||
break;
|
||||
case IBuildMacroProvider.CONTEXT_TOOL:
|
||||
names = fToolMacros;
|
||||
break;
|
||||
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
|
||||
names = fConfigurationMacros;
|
||||
break;
|
||||
|
@ -311,8 +323,10 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
case IBuildMacroProvider.CONTEXT_FILE:
|
||||
if(contextData instanceof IFileContextData){
|
||||
for(int i = 0; i < fFileMacros.length; i++){
|
||||
if(macroName.equals(fFileMacros[i]))
|
||||
if(macroName.equals(fFileMacros[i])){
|
||||
macro = new FileContextMacro(macroName,(IFileContextData)contextData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -321,6 +335,11 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
macro = getMacro(macroName, (IOptionContextData)contextData);
|
||||
}
|
||||
break;
|
||||
case IBuildMacroProvider.CONTEXT_TOOL:
|
||||
if(contextData instanceof ITool){
|
||||
macro = getMacro(macroName, (ITool)contextData);
|
||||
}
|
||||
break;
|
||||
case IBuildMacroProvider.CONTEXT_CONFIGURATION:
|
||||
if(contextData instanceof IConfiguration){
|
||||
macro = getMacro(macroName, (IConfiguration)contextData);
|
||||
|
@ -354,6 +373,18 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
if(!canHandle(optionContext))
|
||||
optionContext = null;
|
||||
macro = new OptionMacro(macroName,optionContext);
|
||||
} else if("ParentVersion".equals(macroName)){
|
||||
IHoldsOptions holder = OptionContextData.getHolder(optionContext);
|
||||
if(holder != null && holder.getVersion() != null)
|
||||
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,holder.getVersion().toString());
|
||||
}
|
||||
return macro;
|
||||
}
|
||||
|
||||
public IBuildMacro getMacro(String macroName, ITool tool){
|
||||
IBuildMacro macro = null;
|
||||
if("ToolVersion".equals(macroName) && tool.getVersion() != null){ //$NON-NLS-1$
|
||||
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,tool.getVersion().toString());
|
||||
}
|
||||
return macro;
|
||||
}
|
||||
|
@ -513,6 +544,15 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT_LIST,archList);
|
||||
|
||||
}
|
||||
else if("ToolChainVersion".equals(macroName)){ //$NON-NLS-1$
|
||||
if(cfg.getToolChain().getVersion() != null)
|
||||
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,cfg.getToolChain().getVersion().toString());
|
||||
}
|
||||
else if("BuilderVersion".equals(macroName)){ //$NON-NLS-1$
|
||||
PluginVersionIdentifier version = cfg.getToolChain().getBuilder().getVersion();
|
||||
if(version != null)
|
||||
macro = new BuildMacro(macroName,IBuildMacro.VALUE_TEXT,version.toString());
|
||||
}
|
||||
return macro;
|
||||
}
|
||||
|
||||
|
@ -897,83 +937,30 @@ public class MbsMacroSupplier implements IBuildMacroSupplier {
|
|||
if (parent instanceof ITool) {
|
||||
tool = (ITool)parent;
|
||||
}
|
||||
IBuildObject bo = (optionContext instanceof OptionData) ?
|
||||
IBuildObject bObj = (optionContext instanceof OptionData) ?
|
||||
((OptionData)optionContext).getOptionContainer() : optionContext.getParent();
|
||||
IBuildObject parentObject = null;
|
||||
if(bo instanceof ITool)
|
||||
bo = ((ITool)bo).getParent();
|
||||
else if(bo instanceof IConfiguration)
|
||||
bo = ((IConfiguration)bo).getToolChain();
|
||||
|
||||
if(tool != null && bo instanceof IResourceConfiguration){
|
||||
IResourceConfiguration rcCfg = null;
|
||||
ITool holderTool = null;
|
||||
if(bObj instanceof ITool){
|
||||
holderTool = (ITool)bObj;
|
||||
IBuildObject p = holderTool.getParent();
|
||||
if(p instanceof IResourceConfiguration)
|
||||
rcCfg = (IResourceConfiguration)p;
|
||||
} else if(bObj instanceof IResourceConfiguration)
|
||||
rcCfg = (IResourceConfiguration)bObj;
|
||||
|
||||
IToolChain toolChain = null;
|
||||
IConfiguration cfg = null;
|
||||
IBuildObject parentObject = rcCfg == null ? bObj : rcCfg.getParent();
|
||||
|
||||
IResourceConfiguration rc = (IResourceConfiguration)bo;
|
||||
cfg = rc.getParent();
|
||||
toolChain = cfg.getToolChain();
|
||||
parentObject = toolChain;
|
||||
if(rc.getTool(tool.getId()) != null){
|
||||
//get the configuration tool
|
||||
if(rcCfg != null && rcCfg.getTool(tool.getId()) != null){
|
||||
tool = tool.getSuperClass();
|
||||
IOption opts[] = tool.getOptions();
|
||||
IOption superClass = option;
|
||||
do{
|
||||
for(int i = 0; i < opts.length; i++){
|
||||
if(superClass.equals(opts[i]) || superClass.equals(opts[i].getSuperClass())){
|
||||
parentOption = opts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(parentOption != null)
|
||||
break;
|
||||
}while((superClass = superClass.getSuperClass()) != null);
|
||||
} else if(toolChain.getTool(tool.getId()) != null){
|
||||
parentOption = option.getSuperClass();
|
||||
} else {
|
||||
ITool tools[] = toolChain.getTools();
|
||||
ITool superClasses[] = new ITool[tools.length];
|
||||
int i = 0;
|
||||
for(i = 0; i < tools.length; i++){
|
||||
superClasses[i] = tools[i];
|
||||
}
|
||||
for(i = 0; i < tools.length; i++){
|
||||
if(tool.equals(superClasses[i]))
|
||||
break;
|
||||
superClasses[i] = tools[i].getSuperClass();
|
||||
}
|
||||
if(i < tools.length){
|
||||
tool = tools[i];
|
||||
IOption opts[] = tool.getOptions();
|
||||
IOption superClassOpts[] = new IOption[opts.length];
|
||||
for(i = 0; i < opts.length; i++){
|
||||
superClassOpts[i] = opts[i];
|
||||
}
|
||||
for(i = 0; i < opts.length; i++){
|
||||
if(superClassOpts[i] != null){
|
||||
if(option.equals(superClassOpts[i]))
|
||||
break;
|
||||
superClassOpts[i] = superClassOpts[i].getSuperClass();
|
||||
}
|
||||
}
|
||||
if(i < opts.length)
|
||||
parentOption = opts[i];
|
||||
}
|
||||
}
|
||||
parentOption = tool.getOptionBySuperClassId(option.getSuperClass().getId());
|
||||
} else {
|
||||
parentOption = option.getSuperClass();
|
||||
if(parentOption != null){
|
||||
IBuildObject parentParent = parentOption.getParent();
|
||||
if (parentParent instanceof ITool)
|
||||
parentObject = ((ITool)parentParent).getParent();
|
||||
else if (parentParent instanceof IToolChain)
|
||||
parentObject = parentParent;
|
||||
}
|
||||
}
|
||||
|
||||
if(parentOption != null)
|
||||
return new OptionData(parentOption,bo,parentObject);
|
||||
return new OptionData(parentOption,bObj,parentObject);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,12 @@
|
|||
package org.eclipse.cdt.managedbuilder.internal.macros;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IOptionContextData;
|
||||
|
||||
/**
|
||||
|
@ -41,4 +46,46 @@ public class OptionContextData implements IOptionContextData {
|
|||
return fParent;
|
||||
}
|
||||
|
||||
public static IHoldsOptions getHolder(IOptionContextData data){
|
||||
IOption option = data.getOption();
|
||||
if(option == null)
|
||||
return null;
|
||||
|
||||
IBuildObject buildObj = data.getParent();
|
||||
IToolChain tCh = null;
|
||||
IHoldsOptions ho = null;
|
||||
IResourceConfiguration rcCfg = null;
|
||||
if(buildObj instanceof ITool)
|
||||
ho = (ITool)buildObj;
|
||||
if(buildObj instanceof IToolChain)
|
||||
tCh = (IToolChain)buildObj;
|
||||
else if(buildObj instanceof IResourceConfiguration)
|
||||
rcCfg = (IResourceConfiguration)buildObj;
|
||||
else if(buildObj instanceof IConfiguration)
|
||||
tCh = ((IConfiguration)buildObj).getToolChain();
|
||||
|
||||
if(ho == null){
|
||||
ho = option.getOptionHolder();
|
||||
ITool tools[] = null;
|
||||
if(tCh != null){
|
||||
for(IToolChain cur = tCh; cur != null; cur = cur.getSuperClass()){
|
||||
if(cur == ho)
|
||||
return tCh;
|
||||
}
|
||||
tools = tCh.getTools();
|
||||
} else if(rcCfg != null){
|
||||
tools = rcCfg.getTools();
|
||||
}
|
||||
|
||||
if(tools != null){
|
||||
for(int i = 0; i < tools.length; i++){
|
||||
for(ITool cur = tools[i]; cur != null; cur = cur.getSuperClass()){
|
||||
if(cur == ho)
|
||||
return tools[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ho;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public interface IBuildMacroProvider{
|
|||
public final static int CONTEXT_WORKSPACE = 5;
|
||||
public final static int CONTEXT_INSTALLATIONS = 6;
|
||||
public final static int CONTEXT_ECLIPSEENV = 7;
|
||||
public final static int CONTEXT_TOOL = 8;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -27,7 +27,12 @@ public interface IOptionContextData {
|
|||
public IOption getOption();
|
||||
|
||||
/**
|
||||
* Returns IBuildObject that could be either an IToolChain or an IResourceConfiguration reference
|
||||
* Returns IBuildObject that represents the option holder.
|
||||
* For the backward compatibility MBS will also support the cases
|
||||
* when this method returns either an IToolChain or IResourceConfiguration.
|
||||
* In this case MBS will try to obtain the option holder automatically,
|
||||
* but it might fail in case the tool-chain/resource configuration contains
|
||||
* more than one tools with the same super-class
|
||||
*
|
||||
* @return IBuildObject
|
||||
*/
|
||||
|
|
|
@ -136,9 +136,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
|
|||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
|
@ -149,9 +147,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
|
|||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
null, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
|
@ -195,9 +191,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
|
|||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
|
@ -208,9 +202,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
|
|||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
null, null, tool));
|
||||
}
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
@ -220,14 +212,24 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
|
|||
|
||||
|
||||
} else {
|
||||
String cmd = info.getToolForSource(inputExtension);
|
||||
ITool tool = null;
|
||||
tools = config.getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tmp = tools[index];
|
||||
if (tmp.buildsFileType(inputExtension)) {
|
||||
tool = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String cmd = tool != null ? tool.getToolCommand() : null;
|
||||
|
||||
//try to resolve the build macros in the tool command
|
||||
try{
|
||||
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),null,null,info.getDefaultConfiguration().getToolChain()));
|
||||
new FileContextData(resource.getLocation(),null,null,tool));
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
|
@ -266,9 +268,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
|
|||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
|
@ -279,9 +279,7 @@ public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerat
|
|||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
null, null, tool));
|
||||
}
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
|
|
@ -1547,7 +1547,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
EMPTY_STRING,
|
||||
WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(null,null,null,info.getDefaultConfiguration().getToolChain()));
|
||||
new FileContextData(null,null,null,tool));
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
command = resolvedCommand;
|
||||
|
||||
|
@ -1581,9 +1581,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
EMPTY_STRING,
|
||||
WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(null, null, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
new FileContextData(null, null, null, tool));
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
|
@ -2149,7 +2147,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
|| MacroResolver.getReferencedExplitFileMacros(tool
|
||||
.getToolCommand(), IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation, outputLocation,
|
||||
null, config.getToolChain())).length > 0;
|
||||
null, tool)).length > 0;
|
||||
//get and resolve command
|
||||
String cmd = tool.getToolCommand();
|
||||
|
||||
|
@ -2163,9 +2161,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything
|
||||
|
@ -2177,9 +2173,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
|
@ -2346,9 +2340,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything
|
||||
|
@ -2360,9 +2352,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
|
@ -2423,9 +2413,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
outputLocation, null, tool));
|
||||
} else {
|
||||
// if we need an explicit rule then don't use any builder
|
||||
// variables, resolve everything
|
||||
|
@ -2437,9 +2425,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
WHITESPACE,
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null, info
|
||||
.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
outputLocation, null, tool));
|
||||
}
|
||||
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
|
@ -2474,8 +2460,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null,
|
||||
info.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
tool));
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -2487,8 +2472,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(sourceLocation,
|
||||
outputLocation, null,
|
||||
info.getDefaultConfiguration()
|
||||
.getToolChain()));
|
||||
tool));
|
||||
}
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
|
|
|
@ -215,8 +215,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
|
|||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(
|
||||
option,
|
||||
config
|
||||
.getToolChain()));
|
||||
tool));
|
||||
} else {
|
||||
|
||||
// resolve to makefile variable format
|
||||
|
@ -229,8 +228,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
|
|||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(
|
||||
option,
|
||||
config
|
||||
.getToolChain()));
|
||||
tool));
|
||||
}
|
||||
|
||||
if ((resolved = resolved.trim()).length() > 0)
|
||||
|
@ -539,7 +537,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
|
|||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(option, config.getToolChain()));
|
||||
new OptionContextData(option, tool));
|
||||
if((resolved = resolved.trim()).length() > 0)
|
||||
outputs.set(j, resolved);
|
||||
} catch (BuildMacroException e){
|
||||
|
@ -624,7 +622,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
|
|||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(option, config.getToolChain()));
|
||||
new OptionContextData(option, tool));
|
||||
if((resolved = resolved.trim()).length() > 0)
|
||||
outputNames[j] = resolved;
|
||||
} catch (BuildMacroException e){
|
||||
|
|
Loading…
Add table
Reference in a new issue