Skip to main content
summaryrefslogtreecommitdiffstats
path: root/xlc
diff options
context:
space:
mode:
authorChris Recoskie2012-05-02 14:49:05 -0400
committerChris Recoskie2012-05-02 14:49:40 -0400
commit53306d93e97e6942660d6e9f865fdb543eb1a3ba (patch)
tree6ebb07d5430a707b3b73fca92537e784d0fa0ccc /xlc
parentfcaa09aaf84acdfa298e4f4e9e3759954bd506c0 (diff)
downloadorg.eclipse.cdt-53306d93e97e6942660d6e9f865fdb543eb1a3ba.tar.gz
org.eclipse.cdt-53306d93e97e6942660d6e9f865fdb543eb1a3ba.tar.xz
org.eclipse.cdt-53306d93e97e6942660d6e9f865fdb543eb1a3ba.zip
Bug 378270 - xlc macro supplier doesn't overwrite old values for
compiler root location
Diffstat (limited to 'xlc')
-rw-r--r--xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java
index 4f614e44c6..f8d62f3460 100644
--- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java
+++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/src/org/eclipse/cdt/managedbuilder/xlc/ui/XLCProjectMacroSupplier.java
@@ -101,14 +101,34 @@ public class XLCProjectMacroSupplier implements IProjectBuildMacroSupplier {
// our array consists of our macro, plus all the macros from our parent
IBuildMacro[] parentMacros = provider.getMacros(IBuildMacroProvider.CONTEXT_PROJECT, project, true);
- int numMacros = parentMacros.length + 1; // +1 for our macro
-
+
+ // look for an existing macro definition
+ int foundIndex = -1;
+ for(int k = 0; k < parentMacros.length; k++) {
+
+ if(parentMacros[k].getName().equals(macro.getName())) {
+ foundIndex = k;
+ break;
+ }
+ }
+
+ int numMacros = (foundIndex == -1) ? parentMacros.length + 1 : parentMacros.length;
+
IBuildMacro[] macros = new IBuildMacro[numMacros];
- macros[0] = macro;
+ // if there was no existing value then add it to the front
+ if(foundIndex == -1) {
+ macros[0] = macro;
+ for(int k = 1; k < macros.length; k++) {
+ macros[k] = parentMacros[k-1];
+ }
+ }
- for(int k = 1; k < macros.length; k++) {
- macros[k] = parentMacros[k-1];
+ else { // replace the old value
+ for(int k = 0; k < macros.length; k++) {
+ macros[k] = parentMacros[k];
+ }
+ macros[foundIndex] = macro;
}
return macros;

Back to the top