diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index 3d4ea53d48c..2d145e30ce0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -4944,21 +4944,23 @@ - + isSystem="true" + name="Tools" + targetTool="cdt.test.customOptionCommand.Tool2"> + owner="cdt.test.customOptionCommand.Tool1"/> + + + + 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(); + IOptionApplicability applicabilityCalculator = 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); - } + 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) {