Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2013-07-24 12:50:12 -0400
committerAndrew Gvozdev2013-07-24 14:05:13 -0400
commit12c5f1299086244119b44fb9aad877f9fb49a430 (patch)
tree782ef26d425a162547b453f7d89eb3af6bc52f46
parentaf57f95d75d7c26ab80ba7de1dc1bfa5391aa3fc (diff)
downloadorg.eclipse.cdt-12c5f1299086244119b44fb9aad877f9fb49a430.tar.gz
org.eclipse.cdt-12c5f1299086244119b44fb9aad877f9fb49a430.tar.xz
org.eclipse.cdt-12c5f1299086244119b44fb9aad877f9fb49a430.zip
bug 404913: Built-In Settings Provider should recognize extra gcc
parameters from build settings
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml53
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java22
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java64
5 files changed, 154 insertions, 4 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
index 565b947e54..455c53885e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
@@ -9392,6 +9392,15 @@
valueType="string">
</option>
<option
+ command="-bool-option"
+ defaultValue="true"
+ id="cdt.managedbuilder.lsp.tests.option.bool"
+ isAbstract="false"
+ resourceFilter="all"
+ useByScannerDiscovery="true"
+ valueType="boolean">
+ </option>
+ <option
command="-str-option="
id="cdt.managedbuilder.lsp.tests.option.string"
isAbstract="false"
@@ -9400,6 +9409,50 @@
value="str-value"
valueType="string">
</option>
+ <option
+ id="cdt.managedbuilder.lsp.tests.option.enum"
+ isAbstract="false"
+ resourceFilter="all"
+ useByScannerDiscovery="true"
+ valueType="enumerated">
+ <enumeratedOptionValue
+ command="-enum-option"
+ id="cdt.managedbuilder.lsp.tests.enum.value"
+ isDefault="true"
+ name="cdt.managedbuilder.lsp.tests.enum.value">
+ </enumeratedOptionValue>
+ </option>
+ <option
+ command="-list-option"
+ id="cdt.managedbuilder.lsp.tests.option.stringlist"
+ isAbstract="false"
+ resourceFilter="all"
+ useByScannerDiscovery="true"
+ valueType="stringList">
+ <listOptionValue
+ value="1">
+ </listOptionValue>
+ <listOptionValue
+ value="2">
+ </listOptionValue>
+ </option>
+ <option
+ defaultValue="cdt.managedbuilder.lsp.tests.tree-option"
+ id="cdt.managedbuilder.lsp.tests.option.tree"
+ isAbstract="false"
+ resourceFilter="all"
+ useByScannerDiscovery="true"
+ valueType="tree">
+ <treeOptionRoot
+ id="cdt.managedbuilder.lsp.tests.option.tree.root"
+ name="cdt.managedbuilder.lsp.tests.option.tree.root">
+ <treeOption
+ command="-tree-option"
+ id="cdt.managedbuilder.lsp.tests.tree-option"
+ name="cdt.managedbuilder.lsp.tests.tree-option">
+ </treeOption>
+ </treeOptionRoot>
+ </option>
</tool>
</toolChain>
</extension>
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java
index 3d6bfe896f..c10b4405be 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java
@@ -84,6 +84,15 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
}
}
+ class MockLspToolchainBuiltinSpecsDetectorCommandResolver extends MockGCCBuiltinSpecsDetectorCommandResolver {
+ // ID must match the tool-chain definition in org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point
+ private static final String MOCK_TOOLCHAIN_ID = "cdt.managedbuilder.lsp.tests.toolchain";
+ @Override
+ public String getToolchainId() {
+ return MOCK_TOOLCHAIN_ID;
+ }
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -164,6 +173,19 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
}
/**
+ * Test expansion of relevant tool options in build command.
+ */
+ public void testGCCBuiltinSpecsDetector_ResolvedCommand_Flags() throws Exception {
+ // check ${FLAGS}
+ MockLspToolchainBuiltinSpecsDetectorCommandResolver detector = new MockLspToolchainBuiltinSpecsDetectorCommandResolver();
+ detector.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID_C);}});
+ detector.setCommand("gcc ${FLAGS}");
+
+ String resolvedCommand = detector.resolveCommand(LANGUAGE_ID_C);
+ assertEquals("gcc -bool-option -str-option=str-value -enum-option -list-option1 -list-option2 -tree-option", resolvedCommand);
+ }
+
+ /**
* Test parsing of macro without value.
*/
public void testGCCBuiltinSpecsDetector_Macro_NoValue() throws Exception {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
index 20bc65cd8d..7cbc02775a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
@@ -42,7 +42,7 @@ ManagedMakeBuilder.warning.unsupported.configuration=**** WARNING: The "{0}" Co
ManagedMakeBuilder.error.prefix=Error:
# Option exception messages
-Option.error.bad_value_type=Bad value for type
+Option.error.bad_value_type=Type of option value is inconsistent with option type
# Managed build manager exception messages
ManagedBuildManager.error.owner_not_null=addTarget: owner not null
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
index 2287de07a3..4ab8d3246a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
@@ -93,6 +93,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
public static final String JOB_FAMILY_BUILTIN_SPECS_DETECTOR = "org.eclipse.cdt.managedbuilder.AbstractBuiltinSpecsDetector"; //$NON-NLS-1$
protected static final String COMPILER_MACRO = "${COMMAND}"; //$NON-NLS-1$
+ protected static final String FLAGS_MACRO = "${FLAGS}"; //$NON-NLS-1$
protected static final String SPEC_FILE_MACRO = "${INPUTS}"; //$NON-NLS-1$
protected static final String SPEC_EXT_MACRO = "${EXT}"; //$NON-NLS-1$
protected static final String SPEC_FILE_BASE = "spec"; //$NON-NLS-1$
@@ -305,6 +306,11 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
if (compiler != null)
cmd = cmd.replace(COMPILER_MACRO, compiler);
}
+ if (cmd.contains(FLAGS_MACRO)) {
+ String flags = getToolOptions(languageId);
+ if (flags != null)
+ cmd = cmd.replace(FLAGS_MACRO, flags);
+ }
if (cmd.contains(SPEC_FILE_MACRO)) {
String specFileName = getSpecFile(languageId);
if (specFileName != null)
@@ -814,6 +820,17 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
return ext;
}
+ /**
+ * Determine additional options to pass to scanner discovery command.
+ * These options are intended to come from the tool-chain.
+ *
+ * @param languageId - language ID.
+ * @return additional options to pass to scanner discovery command.
+ */
+ protected String getToolOptions(String languageId) {
+ return ""; //$NON-NLS-1$
+ }
+
@Override
public Element serializeAttributes(Element parentElement) {
Element elementProvider = super.serializeAttributes(parentElement);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java
index cb4ccc7639..0fbb79a93c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/ToolchainBuiltinSpecsDetector.java
@@ -16,8 +16,10 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@@ -39,6 +41,7 @@ import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableManager
* @since 8.1
*/
public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector {
+ private static final String EMPTY_QUOTED_STRING = "\"\""; //$NON-NLS-1$
private Map<String, ITool> toolMap = new HashMap<String, ITool>();
/**
@@ -55,13 +58,16 @@ public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecs
* This returns the first tool found.
*/
private ITool getTool(String languageId) {
- ITool tool = toolMap.get(languageId);
- if (tool != null) {
- return tool;
+ if (currentCfgDescription == null) {
+ ITool tool = toolMap.get(languageId);
+ if (tool != null) {
+ return tool;
+ }
}
String toolchainId = null;
IToolChain toolchain = null;
+ ITool tool = null;
if (currentCfgDescription != null) {
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(currentCfgDescription);
toolchain = cfg != null ? cfg.getToolChain() : null;
@@ -131,6 +137,58 @@ public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecs
}
@Override
+ protected String getToolOptions(String languageId) {
+ String flags = ""; //$NON-NLS-1$
+ ITool tool = getTool(languageId);
+ if (tool != null) {
+ IOption[] options = tool.getOptions();
+ for (IOption option : options) {
+ if (option.isForScannerDiscovery()) {
+ try {
+ String optionValue = null;
+ switch (option.getBasicValueType()) {
+ case IOption.BOOLEAN:
+ if (option.getBooleanValue()) {
+ optionValue = option.getCommand();
+ } else {
+ optionValue = option.getCommandFalse();
+ }
+ break;
+ case IOption.ENUMERATED:
+ optionValue = option.getEnumCommand(option.getSelectedEnum());
+ break;
+ case IOption.STRING:
+ optionValue = option.getCommand() + option.getStringValue();
+ break;
+ case IOption.STRING_LIST:
+ String[] values = option.getBasicStringListValue();
+ if(values != null) {
+ optionValue = ""; //$NON-NLS-1$
+ String cmd = option.getCommand();
+ for (String value : values) {
+ if(!value.isEmpty() && !value.equals(EMPTY_QUOTED_STRING))
+ optionValue = optionValue + cmd + value + ' ';
+ }
+ }
+ break;
+ case IOption.TREE:
+ optionValue = option.getCommand(option.getStringValue());
+ break;
+ default:
+ }
+ if (optionValue != null) {
+ flags = flags + ' ' + optionValue.trim();
+ }
+ } catch (BuildException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+ }
+ }
+ return flags.trim();
+ }
+
+ @Override
protected List<IEnvironmentVariable> getEnvironmentVariables() {
if (envMngr == null && currentCfgDescription == null) {
// For global provider need to include toolchain in the equation

Back to the top