mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 564257: Respect commandGenerator and applicabilityCalculator
The method Configuration.getUserObjects() and Configuration.getLibs() should respect the commandGenerator and applicabilityCalculator defined for the option in the toolchain definition. The method Tool.getToolCommandFlags() should call the commandGenerator only if the value type would generate a default command. Change-Id: I4d6224627888e602682076ac929adbf808cff8d7 Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
This commit is contained in:
parent
4bd9fed83b
commit
ef2ee6df71
5 changed files with 453 additions and 52 deletions
|
@ -4944,21 +4944,23 @@
|
||||||
<configuration
|
<configuration
|
||||||
id="cdt.test.customOptionCommand.one"
|
id="cdt.test.customOptionCommand.one"
|
||||||
name="One">
|
name="One">
|
||||||
<toolChain isSystem="true"
|
<toolChain
|
||||||
id="cdt.test.customOptionCommand.Toolchain"
|
id="cdt.test.customOptionCommand.Toolchain"
|
||||||
isAbstract="false"
|
isAbstract="false"
|
||||||
name="Tools">
|
isSystem="true"
|
||||||
|
name="Tools"
|
||||||
|
targetTool="cdt.test.customOptionCommand.Tool2">
|
||||||
<tool
|
<tool
|
||||||
command="xxx"
|
command="xxx"
|
||||||
id="cdt.test.customOptionCommand.Tool"
|
id="cdt.test.customOptionCommand.Tool1"
|
||||||
isAbstract="false"
|
isAbstract="false"
|
||||||
name="Tool"
|
name="Tool1"
|
||||||
natureFilter="both"
|
natureFilter="both"
|
||||||
outputFlag="-o">
|
outputFlag="-o">
|
||||||
<optionCategory
|
<optionCategory
|
||||||
id="cdt.test.customOptionCommand.optionCategory1"
|
id="cdt.test.customOptionCommand.optionCategory1"
|
||||||
name="Test Options"
|
name="Test Options"
|
||||||
owner="cdt.test.customOptionCommand.Tool"/>
|
owner="cdt.test.customOptionCommand.Tool1"/>
|
||||||
<option
|
<option
|
||||||
category="cdt.test.customOptionCommand.optionCategory1"
|
category="cdt.test.customOptionCommand.optionCategory1"
|
||||||
command="-opt1="
|
command="-opt1="
|
||||||
|
@ -4986,6 +4988,178 @@
|
||||||
id="cdt.test.customOptionCommand.option4"
|
id="cdt.test.customOptionCommand.option4"
|
||||||
name="Option4"
|
name="Option4"
|
||||||
valueType="string"/>
|
valueType="string"/>
|
||||||
|
</tool>
|
||||||
|
<tool
|
||||||
|
command="xxx"
|
||||||
|
id="cdt.test.customOptionCommand.Tool2"
|
||||||
|
isAbstract="false"
|
||||||
|
name="Tool2"
|
||||||
|
natureFilter="both"
|
||||||
|
outputFlag="-o">
|
||||||
|
<optionCategory
|
||||||
|
id="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
name="Test Options"
|
||||||
|
owner="cdt.test.customOptionCommand.Tool2"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optString="
|
||||||
|
id="cdt.test.customOptionCommand.optionString"
|
||||||
|
name="OptionString"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="string"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optStringList="
|
||||||
|
id="cdt.test.customOptionCommand.optionStringList"
|
||||||
|
name="OptionStringList"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="stringList"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optBoolean=true"
|
||||||
|
commandFalse="-optBoolean=false"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
id="cdt.test.customOptionCommand.optionBoolean"
|
||||||
|
name="OptionBoolean"
|
||||||
|
valueType="boolean"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optEnumerated="
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
id="cdt.test.customOptionCommand.optionEnumerated"
|
||||||
|
name="OptionEnumerated"
|
||||||
|
valueType="enumerated">
|
||||||
|
<enumeratedOptionValue
|
||||||
|
command="-optEnumerated=value1"
|
||||||
|
id="org.eclipse.cdt.managedbuilder.core.tests.enumeratedOptionValue1"
|
||||||
|
name="EnumeratedOptionValue1">
|
||||||
|
</enumeratedOptionValue>
|
||||||
|
<enumeratedOptionValue
|
||||||
|
command="-optEnumerated=value2"
|
||||||
|
id="org.eclipse.cdt.managedbuilder.core.tests.enumeratedOptionValue2"
|
||||||
|
name="EnumeratedOptionValue2">
|
||||||
|
</enumeratedOptionValue>
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optIncludePath="
|
||||||
|
id="cdt.test.customOptionCommand.optionIncludePath"
|
||||||
|
name="OptionIncludePath"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="includePath"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optDefinedSymbols="
|
||||||
|
id="cdt.test.customOptionCommand.optionDefinedSymbols"
|
||||||
|
name="OptionDefinedSymbols"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="definedSymbols"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optLibs="
|
||||||
|
id="cdt.test.customOptionCommand.optionLibs"
|
||||||
|
name="OptionLibs"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="libs"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optUserObjs="
|
||||||
|
id="cdt.test.customOptionCommand.optionUserObjs"
|
||||||
|
name="OptionUserObjs"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="userObjs"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optSymbolFiles="
|
||||||
|
id="cdt.test.customOptionCommand.optionSymbolFiles"
|
||||||
|
name="OptionSymbolFiles"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="symbolFiles"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optIncludeFiles="
|
||||||
|
id="cdt.test.customOptionCommand.optionIncludeFiles"
|
||||||
|
name="OptionIncludeFiles"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="includeFiles"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optLibPaths="
|
||||||
|
id="cdt.test.customOptionCommand.optionLibPaths"
|
||||||
|
name="OptionLibPaths"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="libPaths"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optLibFiles="
|
||||||
|
id="cdt.test.customOptionCommand.optionLibFiles"
|
||||||
|
name="OptionLibFiles"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="libFiles"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optUndefIncludePath="
|
||||||
|
id="cdt.test.customOptionCommand.optionUndefIncludePath"
|
||||||
|
name="OptionUndefIncludePath"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="undefIncludePath"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optUndefDefinedSymbols="
|
||||||
|
id="cdt.test.customOptionCommand.optionUndefDefinedSymbols"
|
||||||
|
name="OptionUndefDefinedSymbols"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="undefDefinedSymbols"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optUndefLibPaths="
|
||||||
|
id="cdt.test.customOptionCommand.optionUndefLibPaths"
|
||||||
|
name="OptionUndefLibPaths"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="undefLibPaths"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optUndefLibFiles="
|
||||||
|
id="cdt.test.customOptionCommand.optionUndefLibFiles"
|
||||||
|
name="OptionUndefLibFiles"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="undefLibFiles"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optUndefIncludeFiles="
|
||||||
|
id="cdt.test.customOptionCommand.optionUndefIncludeFiles"
|
||||||
|
name="OptionUndefIncludeFiles"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="undefIncludeFiles"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optUndefSymbolFiles="
|
||||||
|
id="cdt.test.customOptionCommand.optionUndefSymbolFiles"
|
||||||
|
name="OptionUndefSymbolFiles"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
valueType="undefSymbolFiles"/>
|
||||||
|
<option
|
||||||
|
category="cdt.test.customOptionCommand.optionCategory2"
|
||||||
|
command="-optTree="
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.core.tests.CustomOptionCommandGenerator"
|
||||||
|
id="cdt.test.customOptionCommand.optionTree"
|
||||||
|
name="OptionTree"
|
||||||
|
valueType="tree">
|
||||||
|
<treeOptionRoot
|
||||||
|
id="org.eclipse.cdt.managedbuilder.core.tests.treeOptionRoot1"
|
||||||
|
name="org.eclipse.cdt.managedbuilder.core.tests.treeOptionRoot1">
|
||||||
|
<treeOption
|
||||||
|
command="-optTree=value1"
|
||||||
|
id="org.eclipse.cdt.managedbuilder.core.tests.treeOption1"
|
||||||
|
name="TreeOption1">
|
||||||
|
</treeOption>
|
||||||
|
<treeOption
|
||||||
|
command="-optTree=value2"
|
||||||
|
id="org.eclipse.cdt.managedbuilder.core.tests.treeOption2"
|
||||||
|
name="TreeOption2">
|
||||||
|
</treeOption>
|
||||||
|
</treeOptionRoot>
|
||||||
|
</option>
|
||||||
</tool>
|
</tool>
|
||||||
<builder
|
<builder
|
||||||
id="cdt.test.customOptionCommand.builder"
|
id="cdt.test.customOptionCommand.builder"
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
|
import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor;
|
||||||
|
|
||||||
|
public class CustomOptionCommandGenerator2 extends CustomOptionCommandGenerator {
|
||||||
|
|
||||||
|
public CustomOptionCommandGenerator2() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generateCommand(IOption option, IVariableSubstitutor macroSubstitutor) {
|
||||||
|
String command = super.generateCommand(option, macroSubstitutor);
|
||||||
|
if (command == null) {
|
||||||
|
try {
|
||||||
|
switch (option.getValueType()) {
|
||||||
|
case IOption.BOOLEAN:
|
||||||
|
return option.getBooleanValue() ? option.getCommand() : option.getCommandFalse();
|
||||||
|
case IOption.ENUMERATED:
|
||||||
|
return option.getEnumCommand(option.getSelectedEnum());
|
||||||
|
case IOption.TREE:
|
||||||
|
return option.getCommand(option.getStringValue());
|
||||||
|
default:
|
||||||
|
return option.getCommand() + option.getValue();
|
||||||
|
}
|
||||||
|
} catch (BuildException e) {
|
||||||
|
return "CustomOptionCommandGenerator2-error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
|
@ -194,8 +195,8 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
|
||||||
"cdt.test.customOptionCommand.ProjectType");
|
"cdt.test.customOptionCommand.ProjectType");
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||||
IConfiguration config = info.getDefaultConfiguration();
|
IConfiguration config = info.getDefaultConfiguration();
|
||||||
ITool[] tools = config.getToolsBySuperClassId("cdt.test.customOptionCommand.Tool");
|
ITool[] tools = config.getToolsBySuperClassId("cdt.test.customOptionCommand.Tool1");
|
||||||
assertEquals(tools.length, 1);
|
assertEquals(1, tools.length);
|
||||||
|
|
||||||
ITool tool = tools[0];
|
ITool tool = tools[0];
|
||||||
|
|
||||||
|
@ -229,6 +230,124 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void testCustomOptionCommandGenerator2() {
|
||||||
|
try {
|
||||||
|
IProject project = ManagedBuildTestHelper.createProject("COCG2", null, (IPath) null,
|
||||||
|
"cdt.test.customOptionCommand.ProjectType");
|
||||||
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||||
|
IConfiguration config = info.getDefaultConfiguration();
|
||||||
|
|
||||||
|
ITool[] tools = config.getToolsBySuperClassId("cdt.test.customOptionCommand.Tool2");
|
||||||
|
assertEquals(1, tools.length);
|
||||||
|
|
||||||
|
ITool tool = tools[0];
|
||||||
|
|
||||||
|
IOption optionString = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionString");
|
||||||
|
IOption optionStringList = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionStringList");
|
||||||
|
IOption optionBoolean = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionBoolean");
|
||||||
|
IOption optionEnumerated = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionEnumerated");
|
||||||
|
IOption optionIncludePath = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionIncludePath");
|
||||||
|
IOption optionDefinedSymbols = tool
|
||||||
|
.getOptionBySuperClassId("cdt.test.customOptionCommand.optionDefinedSymbols");
|
||||||
|
IOption optionLibs = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionLibs");
|
||||||
|
IOption optionUserObjs = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionUserObjs");
|
||||||
|
IOption optionSymbolFiles = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionSymbolFiles");
|
||||||
|
IOption optionIncludeFiles = tool
|
||||||
|
.getOptionBySuperClassId("cdt.test.customOptionCommand.optionIncludeFiles");
|
||||||
|
IOption optionLibPaths = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionLibPaths");
|
||||||
|
IOption optionLibFiles = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionLibFiles");
|
||||||
|
IOption optionUndefIncludePath = tool
|
||||||
|
.getOptionBySuperClassId("cdt.test.customOptionCommand.optionUndefIncludePath");
|
||||||
|
IOption optionUndefDefinedSymbols = tool
|
||||||
|
.getOptionBySuperClassId("cdt.test.customOptionCommand.optionUndefDefinedSymbols");
|
||||||
|
IOption optionUndefLibPaths = tool
|
||||||
|
.getOptionBySuperClassId("cdt.test.customOptionCommand.optionUndefLibPaths");
|
||||||
|
IOption optionUndefLibFiles = tool
|
||||||
|
.getOptionBySuperClassId("cdt.test.customOptionCommand.optionUndefLibFiles");
|
||||||
|
IOption optionUndefIncludeFiles = tool
|
||||||
|
.getOptionBySuperClassId("cdt.test.customOptionCommand.optionUndefIncludeFiles");
|
||||||
|
IOption optionUndefSymbolFiles = tool
|
||||||
|
.getOptionBySuperClassId("cdt.test.customOptionCommand.optionUndefSymbolFiles");
|
||||||
|
IOption optionTree = tool.getOptionBySuperClassId("cdt.test.customOptionCommand.optionTree");
|
||||||
|
|
||||||
|
assertTrue(optionString.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionStringList.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionBoolean.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionEnumerated.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionIncludePath.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionDefinedSymbols.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionLibs.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionUserObjs.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionSymbolFiles.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionIncludeFiles.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionLibPaths.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionLibFiles.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionUndefIncludePath.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionUndefDefinedSymbols.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionUndefLibPaths.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionUndefLibFiles.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionUndefIncludeFiles.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionUndefSymbolFiles.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
assertTrue(optionTree.getCommandGenerator() instanceof CustomOptionCommandGenerator);
|
||||||
|
|
||||||
|
optionString = config.setOption(tool, optionString, "${ProjName}");
|
||||||
|
optionStringList = config.setOption(tool, optionStringList, new String[] { "val1", "${ProjName}" });
|
||||||
|
optionBoolean = config.setOption(tool, optionBoolean, true);
|
||||||
|
optionEnumerated = config.setOption(tool, optionEnumerated,
|
||||||
|
"org.eclipse.cdt.managedbuilder.core.tests.enumeratedOptionValue2");
|
||||||
|
optionIncludePath = config.setOption(tool, optionIncludePath, new String[] { "val2", "${ProjName}" });
|
||||||
|
optionDefinedSymbols = config.setOption(tool, optionDefinedSymbols, new String[] { "val3", "${ProjName}" });
|
||||||
|
optionLibs = config.setOption(tool, optionLibs, new String[] { "val4", "${ProjName}" });
|
||||||
|
optionUserObjs = config.setOption(tool, optionUserObjs, new String[] { "val5", "${ProjName}" });
|
||||||
|
optionSymbolFiles = config.setOption(tool, optionSymbolFiles, new String[] { "val6", "${ProjName}" });
|
||||||
|
optionIncludeFiles = config.setOption(tool, optionIncludeFiles, new String[] { "val7", "${ProjName}" });
|
||||||
|
optionLibPaths = config.setOption(tool, optionLibPaths, new String[] { "val8", "${ProjName}" });
|
||||||
|
optionLibFiles = config.setOption(tool, optionLibFiles, new String[] { "val9", "${ProjName}" });
|
||||||
|
optionUndefIncludePath = config.setOption(tool, optionUndefIncludePath,
|
||||||
|
new String[] { "val10", "${ProjName}" });
|
||||||
|
optionUndefDefinedSymbols = config.setOption(tool, optionUndefDefinedSymbols,
|
||||||
|
new String[] { "val11", "${ProjName}" });
|
||||||
|
optionUndefLibPaths = config.setOption(tool, optionUndefLibPaths, new String[] { "val12", "${ProjName}" });
|
||||||
|
optionUndefLibFiles = config.setOption(tool, optionUndefLibFiles, new String[] { "val13", "${ProjName}" });
|
||||||
|
optionUndefIncludeFiles = config.setOption(tool, optionUndefIncludeFiles,
|
||||||
|
new String[] { "val14", "${ProjName}" });
|
||||||
|
optionUndefSymbolFiles = config.setOption(tool, optionUndefSymbolFiles,
|
||||||
|
new String[] { "val15", "${ProjName}" });
|
||||||
|
optionTree = config.setOption(tool, optionTree, "org.eclipse.cdt.managedbuilder.core.tests.treeOption2");
|
||||||
|
|
||||||
|
String command = tool.getToolCommandFlagsString(null, null);
|
||||||
|
assertEquals(String.join(" ", "-optString=COCG2", //
|
||||||
|
"-optStringList=\"val1;COCG2;\"", //
|
||||||
|
"-optBoolean=true", //
|
||||||
|
"-optEnumerated=value2", //
|
||||||
|
"-optIncludePath=\"val2;COCG2;\"", //
|
||||||
|
"-optDefinedSymbols=\"val3;COCG2;\"", //
|
||||||
|
"-optSymbolFiles=\"val6;COCG2;\"", //
|
||||||
|
"-optIncludeFiles=\"val7;COCG2;\"", //
|
||||||
|
"-optLibPaths=\"val8;COCG2;\"", //
|
||||||
|
"-optLibFiles=\"val9;COCG2;\"", //
|
||||||
|
"-optUndefIncludePath=\"val10;COCG2;\"", //
|
||||||
|
"-optUndefDefinedSymbols=\"val11;COCG2;\"", //
|
||||||
|
"-optUndefLibPaths=\"val12;COCG2;\"", //
|
||||||
|
"-optUndefLibFiles=\"val13;COCG2;\"", //
|
||||||
|
"-optUndefIncludeFiles=\"val14;COCG2;\"", //
|
||||||
|
"-optUndefSymbolFiles=\"val15;COCG2;\"", //
|
||||||
|
"-optTree=value2"), //
|
||||||
|
command);
|
||||||
|
|
||||||
|
String[] libs = config.getLibs(config.getArtifactExtension());
|
||||||
|
assertEquals(Arrays.asList("-optLibs=\"val4;COCG2;\"").toString(), Arrays.asList(libs).toString());
|
||||||
|
|
||||||
|
String[] userObjs = config.getUserObjects(config.getArtifactExtension());
|
||||||
|
assertEquals(Arrays.asList("-optUserObjs=\"val5;COCG2;\"").toString(), Arrays.asList(userObjs).toString());
|
||||||
|
|
||||||
|
ManagedBuildTestHelper.removeProject("COCG2");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
fail("Test failed on project creation: " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public final void testDollarValue() {
|
public final void testDollarValue() {
|
||||||
try {
|
try {
|
||||||
IProject project = ManagedBuildTestHelper.createProject("CDV", null, (IPath) null,
|
IProject project = ManagedBuildTestHelper.createProject("CDV", null, (IPath) null,
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Vector;
|
||||||
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
|
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
|
||||||
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
|
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
|
||||||
import org.eclipse.cdt.core.ErrorParserManager;
|
import org.eclipse.cdt.core.ErrorParserManager;
|
||||||
|
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
|
||||||
import org.eclipse.cdt.core.settings.model.CSourceEntry;
|
import org.eclipse.cdt.core.settings.model.CSourceEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
||||||
|
@ -65,6 +66,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
|
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOptionCommandGenerator;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
|
@ -77,11 +79,15 @@ import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSu
|
||||||
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
|
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
|
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildfileMacroSubstitutor;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfoProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
|
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
|
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
|
||||||
|
import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
|
@ -95,6 +101,7 @@ import org.osgi.framework.Version;
|
||||||
public class Configuration extends BuildObject implements IConfiguration, IBuildPropertiesRestriction,
|
public class Configuration extends BuildObject implements IConfiguration, IBuildPropertiesRestriction,
|
||||||
IBuildPropertyChangeListener, IRealBuildObjectAssociation {
|
IBuildPropertyChangeListener, IRealBuildObjectAssociation {
|
||||||
|
|
||||||
|
private static final String WHITE_SPACE = " "; //$NON-NLS-1$
|
||||||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
private static final String EMPTY_CFG_ID = "org.eclipse.cdt.build.core.emptycfg"; //$NON-NLS-1$
|
private static final String EMPTY_CFG_ID = "org.eclipse.cdt.build.core.emptycfg"; //$NON-NLS-1$
|
||||||
private static final String LANGUAGE_SETTINGS_PROVIDER_DELIMITER = ";"; //$NON-NLS-1$
|
private static final String LANGUAGE_SETTINGS_PROVIDER_DELIMITER = ";"; //$NON-NLS-1$
|
||||||
|
@ -2600,6 +2607,30 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
||||||
IOption option = opts[i];
|
IOption option = opts[i];
|
||||||
try {
|
try {
|
||||||
if (option.getValueType() == IOption.OBJECTS) {
|
if (option.getValueType() == IOption.OBJECTS) {
|
||||||
|
// check to see if the option has an applicability calculator
|
||||||
|
IOptionApplicability applicabilityCalculator = option.getApplicabilityCalculator();
|
||||||
|
|
||||||
|
if (applicabilityCalculator == null
|
||||||
|
|| applicabilityCalculator.isOptionUsedInCommandLine(this, tool, option)) {
|
||||||
|
boolean generateDefaultCommand = true;
|
||||||
|
IOptionCommandGenerator commandGenerator = option.getCommandGenerator();
|
||||||
|
if (commandGenerator != null) {
|
||||||
|
SupplierBasedCdtVariableSubstitutor macroSubstitutor = new BuildfileMacroSubstitutor(
|
||||||
|
null, EMPTY_STRING, WHITE_SPACE);
|
||||||
|
IMacroContextInfoProvider provider = BuildMacroProvider.getDefault();
|
||||||
|
IMacroContextInfo info = provider.getMacroContextInfo(BuildMacroProvider.CONTEXT_OPTION,
|
||||||
|
new OptionContextData(option, tool));
|
||||||
|
if (info != null) {
|
||||||
|
macroSubstitutor.setMacroContextInfo(info);
|
||||||
|
String command = commandGenerator.generateCommand(option, macroSubstitutor);
|
||||||
|
if (command != null) {
|
||||||
|
objs.add(command);
|
||||||
|
generateDefaultCommand = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (generateDefaultCommand) {
|
||||||
String unresolved[] = option.getUserObjects();
|
String unresolved[] = option.getUserObjects();
|
||||||
if (unresolved != null && unresolved.length > 0) {
|
if (unresolved != null && unresolved.length > 0) {
|
||||||
for (int k = 0; k < unresolved.length; k++) {
|
for (int k = 0; k < unresolved.length; k++) {
|
||||||
|
@ -2618,7 +2649,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (BuildException e) {
|
}
|
||||||
|
}
|
||||||
|
} catch (BuildException | CdtVariableException e) {
|
||||||
// TODO: report error
|
// TODO: report error
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2643,10 +2676,29 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
||||||
if (option.getValueType() == IOption.LIBRARIES) {
|
if (option.getValueType() == IOption.LIBRARIES) {
|
||||||
|
|
||||||
// check to see if the option has an applicability calculator
|
// check to see if the option has an applicability calculator
|
||||||
IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator();
|
IOptionApplicability applicabilityCalculator = option.getApplicabilityCalculator();
|
||||||
|
|
||||||
if (applicabilitytCalculator == null
|
if (applicabilityCalculator == null
|
||||||
|| applicabilitytCalculator.isOptionUsedInCommandLine(this, tool, option)) {
|
|| applicabilityCalculator.isOptionUsedInCommandLine(this, tool, option)) {
|
||||||
|
boolean generateDefaultCommand = true;
|
||||||
|
IOptionCommandGenerator commandGenerator = option.getCommandGenerator();
|
||||||
|
if (commandGenerator != null) {
|
||||||
|
SupplierBasedCdtVariableSubstitutor macroSubstitutor = new BuildfileMacroSubstitutor(
|
||||||
|
null, EMPTY_STRING, WHITE_SPACE);
|
||||||
|
IMacroContextInfoProvider provider = BuildMacroProvider.getDefault();
|
||||||
|
IMacroContextInfo info = provider.getMacroContextInfo(BuildMacroProvider.CONTEXT_OPTION,
|
||||||
|
new OptionContextData(option, tool));
|
||||||
|
if (info != null) {
|
||||||
|
macroSubstitutor.setMacroContextInfo(info);
|
||||||
|
String command = commandGenerator.generateCommand(option, macroSubstitutor);
|
||||||
|
if (command != null) {
|
||||||
|
libs.add(command);
|
||||||
|
generateDefaultCommand = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (generateDefaultCommand) {
|
||||||
String command = option.getCommand();
|
String command = option.getCommand();
|
||||||
String[] allLibs = option.getLibraries();
|
String[] allLibs = option.getLibraries();
|
||||||
for (int j = 0; j < allLibs.length; j++) {
|
for (int j = 0; j < allLibs.length; j++) {
|
||||||
|
@ -2667,11 +2719,11 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
||||||
// TODO: report error
|
// TODO: report error
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (BuildException e) {
|
}
|
||||||
|
} catch (BuildException | CdtVariableException e) {
|
||||||
// TODO: report error
|
// TODO: report error
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2655,6 +2655,24 @@ public class Tool extends HoldsOptions
|
||||||
boolean generateDefaultCommand = true;
|
boolean generateDefaultCommand = true;
|
||||||
IOptionCommandGenerator commandGenerator = option.getCommandGenerator();
|
IOptionCommandGenerator commandGenerator = option.getCommandGenerator();
|
||||||
if (commandGenerator != null) {
|
if (commandGenerator != null) {
|
||||||
|
switch (option.getValueType()) {
|
||||||
|
case IOption.BOOLEAN:
|
||||||
|
case IOption.ENUMERATED:
|
||||||
|
case IOption.TREE:
|
||||||
|
case IOption.STRING:
|
||||||
|
case IOption.STRING_LIST:
|
||||||
|
case IOption.INCLUDE_FILES:
|
||||||
|
case IOption.INCLUDE_PATH:
|
||||||
|
case IOption.LIBRARY_PATHS:
|
||||||
|
case IOption.LIBRARY_FILES:
|
||||||
|
case IOption.MACRO_FILES:
|
||||||
|
case IOption.UNDEF_INCLUDE_FILES:
|
||||||
|
case IOption.UNDEF_INCLUDE_PATH:
|
||||||
|
case IOption.UNDEF_LIBRARY_PATHS:
|
||||||
|
case IOption.UNDEF_LIBRARY_FILES:
|
||||||
|
case IOption.UNDEF_MACRO_FILES:
|
||||||
|
case IOption.PREPROCESSOR_SYMBOLS:
|
||||||
|
case IOption.UNDEF_PREPROCESSOR_SYMBOLS:
|
||||||
IMacroContextInfo info = provider.getMacroContextInfo(BuildMacroProvider.CONTEXT_FILE,
|
IMacroContextInfo info = provider.getMacroContextInfo(BuildMacroProvider.CONTEXT_FILE,
|
||||||
new FileContextData(inputFileLocation, outputFileLocation, option, this));
|
new FileContextData(inputFileLocation, outputFileLocation, option, this));
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
|
@ -2665,6 +2683,10 @@ public class Tool extends HoldsOptions
|
||||||
generateDefaultCommand = false;
|
generateDefaultCommand = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (generateDefaultCommand) {
|
if (generateDefaultCommand) {
|
||||||
switch (option.getValueType()) {
|
switch (option.getValueType()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue