Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTorbjörn Svensson2020-06-12 13:28:51 -0400
committerTorbjörn Svensson2020-06-12 14:02:31 -0400
commitef2ee6df714b508233543c38dbfce13f6b76f153 (patch)
treead553e120622faf6fb89cfdf5e33e74f3f0ad058 /build/org.eclipse.cdt.managedbuilder.core/src/org
parent4bd9fed83b96dfc66d33ccdeb4d9fcddc9cac349 (diff)
downloadorg.eclipse.cdt-ef2ee6df714b508233543c38dbfce13f6b76f153.tar.gz
org.eclipse.cdt-ef2ee6df714b508233543c38dbfce13f6b76f153.tar.xz
org.eclipse.cdt-ef2ee6df714b508233543c38dbfce13f6b76f153.zip
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>
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core/src/org')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java128
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java38
2 files changed, 120 insertions, 46 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index 81d6821d0eb..bf4b762ffab 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -30,6 +30,7 @@ import java.util.Vector;
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
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.ICConfigurationDescription;
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.IOption;
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.IResourceConfiguration;
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.enablement.OptionEnablementExpression;
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.IMacroContextInfo;
+import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfoProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
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.IResource;
import org.eclipse.core.resources.IResourceDelta;
@@ -95,6 +101,7 @@ import org.osgi.framework.Version;
public class Configuration extends BuildObject implements IConfiguration, IBuildPropertiesRestriction,
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_CFG_ID = "org.eclipse.cdt.build.core.emptycfg"; //$NON-NLS-1$
private static final String LANGUAGE_SETTINGS_PROVIDER_DELIMITER = ";"; //$NON-NLS-1$
@@ -2600,25 +2607,51 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
IOption option = opts[i];
try {
if (option.getValueType() == IOption.OBJECTS) {
- String unresolved[] = option.getUserObjects();
- if (unresolved != null && unresolved.length > 0) {
- for (int k = 0; k < unresolved.length; k++) {
- try {
- String resolved[] = ManagedBuildManager.getBuildMacroProvider()
- .resolveStringListValueToMakefileFormat(unresolved[k], "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_OPTION,
- new OptionContextData(option, tool));
- if (resolved != null && resolved.length > 0)
- objs.addAll(Arrays.asList(resolved));
- } catch (BuildMacroException e) {
- // TODO: report error
- continue;
+ // 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();
+ if (unresolved != null && unresolved.length > 0) {
+ for (int k = 0; k < unresolved.length; k++) {
+ try {
+ String resolved[] = ManagedBuildManager.getBuildMacroProvider()
+ .resolveStringListValueToMakefileFormat(unresolved[k], "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_OPTION,
+ new OptionContextData(option, tool));
+ if (resolved != null && resolved.length > 0)
+ objs.addAll(Arrays.asList(resolved));
+ } catch (BuildMacroException e) {
+ // TODO: report error
+ continue;
+ }
+ }
}
}
}
}
- } catch (BuildException e) {
+ } catch (BuildException | CdtVariableException e) {
// TODO: report error
continue;
}
@@ -2643,35 +2676,54 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
if (option.getValueType() == IOption.LIBRARIES) {
// check to see if the option has an applicability calculator
- IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator();
-
- if (applicabilitytCalculator == null
- || applicabilitytCalculator.isOptionUsedInCommandLine(this, tool, option)) {
- String command = option.getCommand();
- String[] allLibs = option.getLibraries();
- for (int j = 0; j < allLibs.length; j++) {
- try {
- String resolved[] = ManagedBuildManager.getBuildMacroProvider()
- .resolveStringListValueToMakefileFormat(allLibs[j], "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_OPTION,
- new OptionContextData(option, tool));
- if (resolved != null && resolved.length > 0) {
- for (int k = 0; k < resolved.length; k++) {
- String string = resolved[k];
- if (string.length() > 0)
- libs.add(command + string);
- }
+ 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) {
+ libs.add(command);
+ generateDefaultCommand = false;
}
- } catch (BuildMacroException e) {
- // TODO: report error
- continue;
}
+ }
+ if (generateDefaultCommand) {
+ String command = option.getCommand();
+ String[] allLibs = option.getLibraries();
+ for (int j = 0; j < allLibs.length; j++) {
+ try {
+ String resolved[] = ManagedBuildManager.getBuildMacroProvider()
+ .resolveStringListValueToMakefileFormat(allLibs[j], " ", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_OPTION,
+ new OptionContextData(option, tool));
+ if (resolved != null && resolved.length > 0) {
+ for (int k = 0; k < resolved.length; k++) {
+ String string = resolved[k];
+ if (string.length() > 0)
+ libs.add(command + string);
+ }
+ }
+ } catch (BuildMacroException e) {
+ // TODO: report error
+ continue;
+ }
+ }
}
}
}
- } catch (BuildException e) {
+ } catch (BuildException | CdtVariableException e) {
// TODO: report error
continue;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
index 894a6c9eea6..0fd5e1076c4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
@@ -2655,15 +2655,37 @@ public class Tool extends HoldsOptions
boolean generateDefaultCommand = true;
IOptionCommandGenerator commandGenerator = option.getCommandGenerator();
if (commandGenerator != null) {
- IMacroContextInfo info = provider.getMacroContextInfo(BuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputFileLocation, outputFileLocation, option, this));
- if (info != null) {
- macroSubstitutor.setMacroContextInfo(info);
- String command = commandGenerator.generateCommand(option, macroSubstitutor);
- if (command != null) {
- sb.append(command);
- generateDefaultCommand = false;
+ 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,
+ new FileContextData(inputFileLocation, outputFileLocation, option, this));
+ if (info != null) {
+ macroSubstitutor.setMacroContextInfo(info);
+ String command = commandGenerator.generateCommand(option, macroSubstitutor);
+ if (command != null) {
+ sb.append(command);
+ generateDefaultCommand = false;
+ }
}
+ break;
+ default:
+ break;
}
}
if (generateDefaultCommand) {

Back to the top