diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java index 9d29f2962b6..fe2bf1bcda8 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildObject.java @@ -23,7 +23,12 @@ public interface IBuildObject { public String getId(); public String getName(); + + /** + * @return id of the object this class was based on during creation or id of the object itself. + */ public String getBaseId(); + /** @since 8.0 */ public Version getVersion(); /** @since 8.0 */ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index 8c99ce19e3d..487f5e2b95b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -3697,6 +3697,32 @@ public class ManagedBuildManager extends AbstractCExtension { return superId + "." + suffix; //$NON-NLS-1$ } + + private static int isInt(String s) { + try { + return Integer.parseInt(s); + } catch (NumberFormatException e) { + return 0; + } + } + + /** + * @return base id when the given id was generated by {@link #calculateChildId(String, String)}. + * @since 8.0 + */ + public static String calculateBaseId(String id) { + int index = id.lastIndexOf('.'); + if (index<0) + return id; + + String lastSeg = id.substring(index+1,id.length()); + if (isInt(lastSeg)>0) { + String baseId = id.substring(0,index); + return baseId; + } + return getIdFromIdAndVersion(id); + } + /** * @return calculated relative path given the full path to a folder and a file */ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java index 47389dc2aee..40de8e7fc85 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java @@ -19,6 +19,7 @@ public class BuildObject implements IBuildObject { protected String id; protected String name; + private String baseId=null; protected Version version = null; protected String managedBuildRevision = null; @@ -81,10 +82,13 @@ public class BuildObject implements IBuildObject { } /** - * @return Returns the Id without the version (if any). + * @return id of the object this class was based on. Note that this function + * assumes that id was generated by {@link ManagedBuildManager#calculateChildId(String, String)}. */ public String getBaseId() { - return ManagedBuildManager.getIdFromIdAndVersion(id); + if (baseId==null) + baseId = ManagedBuildManager.calculateBaseId(id); + return baseId; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java index 624caeb7a53..964fdc46e08 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/SetMBSStringOptionValue.java @@ -33,7 +33,8 @@ import org.eclipse.core.runtime.IProgressMonitor; /** - * This class sets the Managed Build System Option Values. + * This class sets the Managed Build System Option Values. Note that this class + * handles both string options and enumerated options. * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. @@ -118,7 +119,7 @@ public class SetMBSStringOptionValue extends ProcessRunner { String lowerId = id.toLowerCase(); int optionType; for (int i = 0; i < options.length; i++) { - if (options[i].getId().toLowerCase().matches(lowerId)) { + if (options[i].getBaseId().toLowerCase().matches(lowerId)) { optionType = options[i].getValueType(); if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) { IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], value); @@ -137,7 +138,7 @@ public class SetMBSStringOptionValue extends ProcessRunner { String lowerId = id.toLowerCase(); int optionType; for (int i = 0; i < options.length; i++) { - if (options[i].getId().toLowerCase().matches(lowerId)) { + if (options[i].getBaseId().toLowerCase().matches(lowerId)) { optionType = options[i].getValueType(); if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) { IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], value);