1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

bug 272432: tidied up + getBaseId()

This commit is contained in:
Andrew Gvozdev 2010-11-04 20:29:29 +00:00
parent 0f4a1ee55d
commit 8fd82b9735
2 changed files with 40 additions and 51 deletions

View file

@ -60,8 +60,7 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue(); ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
boolean modified = false; boolean modified = false;
for(int i=0; i<resourcePathObjects.length; i++) { for (ProcessArgument[] resourcePathObject : resourcePathObjects) {
ProcessArgument[] resourcePathObject = resourcePathObjects[i];
String id = resourcePathObject[0].getSimpleValue(); String id = resourcePathObject[0].getSimpleValue();
String[] values = resourcePathObject[1].getSimpleArrayValue(); String[] values = resourcePathObject[1].getSimpleArrayValue();
String path = resourcePathObject[2].getSimpleValue(); String path = resourcePathObject[2].getSimpleValue();
@ -88,8 +87,7 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
boolean resource = !(path == null || path.equals("") || path.equals("/")); //$NON-NLS-1$ //$NON-NLS-2$ boolean resource = !(path == null || path.equals("") || path.equals("/")); //$NON-NLS-1$ //$NON-NLS-2$
boolean modified = false; boolean modified = false;
for(int i=0; i<projectConfigs.length; i++) { for (IConfiguration config : projectConfigs) {
IConfiguration config = projectConfigs[i];
IResourceConfiguration resourceConfig = null; IResourceConfiguration resourceConfig = null;
if (resource) { if (resource) {
resourceConfig = config.getResourceConfiguration(path); resourceConfig = config.getResourceConfiguration(path);
@ -101,16 +99,16 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
resourceConfig = config.createResourceConfiguration(file); resourceConfig = config.createResourceConfiguration(file);
} }
ITool[] tools = resourceConfig.getTools(); ITool[] tools = resourceConfig.getTools();
for(int j=0; j<tools.length; j++) { for (ITool tool : tools) {
modified |= setOptionForResourceConfig(id, value, resourceConfig, tools[j].getOptions(), tools[j]); modified |= setOptionForResourceConfig(id, value, resourceConfig, tool.getOptions(), tool);
} }
} else { } else {
IToolChain toolChain = config.getToolChain(); IToolChain toolChain = config.getToolChain();
modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain); modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain);
ITool[] tools = config.getTools(); ITool[] tools = config.getTools();
for(int j=0; j<tools.length; j++) { for (ITool tool : tools) {
modified |= setOptionForConfig(id, value, config, tools[j].getOptions(), tools[j]); modified |= setOptionForConfig(id, value, config, tool.getOptions(), tool);
} }
} }
} }
@ -121,10 +119,9 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
private boolean setOptionForResourceConfig(String id, String[] value, IResourceConfiguration resourceConfig, IOption[] options, IHoldsOptions optionHolder) throws BuildException { private boolean setOptionForResourceConfig(String id, String[] value, IResourceConfiguration resourceConfig, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
boolean modified = false; boolean modified = false;
String lowerId = id.toLowerCase(); String lowerId = id.toLowerCase();
for (int i = 0; i < options.length; i++) { for (IOption option : options) {
IOption option = options[i]; if (option.getBaseId().toLowerCase().matches(lowerId)) {
if (option.getId().toLowerCase().matches(lowerId)) { switch(option.getValueType()) {
switch(options[i].getValueType()) {
case IOption.STRING_LIST: case IOption.STRING_LIST:
case IOption.INCLUDE_PATH: case IOption.INCLUDE_PATH:
case IOption.PREPROCESSOR_SYMBOLS: case IOption.PREPROCESSOR_SYMBOLS:
@ -148,10 +145,9 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
private boolean setOptionForConfig(String id, String[] value, IConfiguration config, IOption[] options, IHoldsOptions optionHolder) throws BuildException { private boolean setOptionForConfig(String id, String[] value, IConfiguration config, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
boolean modified = false; boolean modified = false;
String lowerId = id.toLowerCase(); String lowerId = id.toLowerCase();
for (int i = 0; i < options.length; i++) { for (IOption option : options) {
IOption option = options[i]; if (option.getBaseId().toLowerCase().matches(lowerId)) {
if (option.getId().toLowerCase().matches(lowerId)) { switch(option.getValueType()) {
switch(options[i].getValueType()) {
case IOption.STRING_LIST: case IOption.STRING_LIST:
case IOption.INCLUDE_PATH: case IOption.INCLUDE_PATH:
case IOption.PREPROCESSOR_SYMBOLS: case IOption.PREPROCESSOR_SYMBOLS:

View file

@ -10,11 +10,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.templateengine.processes; package org.eclipse.cdt.managedbuilder.templateengine.processes;
import org.eclipse.cdt.core.templateengine.process.processes.Messages;
import org.eclipse.cdt.core.templateengine.TemplateCore; import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.process.ProcessArgument; import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException; import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
import org.eclipse.cdt.core.templateengine.process.ProcessRunner; import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
import org.eclipse.cdt.core.templateengine.process.processes.Messages;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
@ -53,13 +53,13 @@ public class AppendToMBSStringOptionValue extends ProcessRunner {
workspaceDesc.setAutoBuilding(false); workspaceDesc.setAutoBuilding(false);
try { try {
workspace.setDescription(workspaceDesc); workspace.setDescription(workspaceDesc);
} catch (CoreException e) {//ignore } catch (CoreException e) {
//ignore
} }
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue(); ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
boolean modified = false; boolean modified = false;
for(int i=0; i<resourcePathObjects.length; i++) { for (ProcessArgument[] resourcePathObject : resourcePathObjects) {
ProcessArgument[] resourcePathObject = resourcePathObjects[i];
String id = resourcePathObject[0].getSimpleValue(); String id = resourcePathObject[0].getSimpleValue();
String value = resourcePathObject[1].getSimpleValue(); String value = resourcePathObject[1].getSimpleValue();
String path = resourcePathObject[2].getSimpleValue(); String path = resourcePathObject[2].getSimpleValue();
@ -86,8 +86,7 @@ public class AppendToMBSStringOptionValue extends ProcessRunner {
boolean resource = !(path == null || path.equals("") || path.equals("/")); //$NON-NLS-1$ //$NON-NLS-2$ boolean resource = !(path == null || path.equals("") || path.equals("/")); //$NON-NLS-1$ //$NON-NLS-2$
boolean modified = false; boolean modified = false;
for(int i=0; i<projectConfigs.length; i++) { for (IConfiguration config : projectConfigs) {
IConfiguration config = projectConfigs[i];
IResourceConfiguration resourceConfig = null; IResourceConfiguration resourceConfig = null;
if (resource) { if (resource) {
resourceConfig = config.getResourceConfiguration(path); resourceConfig = config.getResourceConfiguration(path);
@ -99,16 +98,16 @@ public class AppendToMBSStringOptionValue extends ProcessRunner {
resourceConfig = config.createResourceConfiguration(file); resourceConfig = config.createResourceConfiguration(file);
} }
ITool[] tools = resourceConfig.getTools(); ITool[] tools = resourceConfig.getTools();
for(int j=0; j<tools.length; j++) { for (ITool tool : tools) {
modified |= setOptionForResourceConfig(id, value, resourceConfig, tools[j].getOptions(), tools[j]); modified |= setOptionForResourceConfig(id, value, resourceConfig, tool.getOptions(), tool);
} }
} else { } else {
IToolChain toolChain = config.getToolChain(); IToolChain toolChain = config.getToolChain();
modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain); modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain);
ITool[] tools = config.getTools(); ITool[] tools = config.getTools();
for(int j=0; j<tools.length; j++) { for (ITool tool : tools) {
modified |= setOptionForConfig(id, value, config, tools[j].getOptions(), tools[j]); modified |= setOptionForConfig(id, value, config, tool.getOptions(), tool);
} }
} }
} }
@ -119,15 +118,12 @@ public class AppendToMBSStringOptionValue extends ProcessRunner {
private boolean setOptionForResourceConfig(String id, String value, IResourceConfiguration resourceConfig, IOption[] options, IHoldsOptions optionHolder) throws BuildException { private boolean setOptionForResourceConfig(String id, String value, IResourceConfiguration resourceConfig, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
boolean modified = false; boolean modified = false;
String lowerId = id.toLowerCase(); String lowerId = id.toLowerCase();
for (int i = 0; i < options.length; i++) { for (IOption option : options) {
if (options[i].getId().toLowerCase().matches(lowerId)) { if (option.getId().toLowerCase().matches(lowerId)) {
if (options[i].getValueType() == IOption.STRING) { if (option.getValueType() == IOption.STRING) {
String oldValue = options[i].getStringValue(); String oldValue = option.getStringValue();
String newValue = oldValue + value; String newValue = oldValue + value;
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], newValue); ManagedBuildManager.setOption(resourceConfig, optionHolder, option, newValue);
if (setOption == null) {
setOption = options[i];
}
modified = true; modified = true;
} }
} }
@ -138,15 +134,12 @@ public class AppendToMBSStringOptionValue extends ProcessRunner {
private boolean setOptionForConfig(String id, String value, IConfiguration config, IOption[] options, IHoldsOptions optionHolder) throws BuildException { private boolean setOptionForConfig(String id, String value, IConfiguration config, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
boolean modified = false; boolean modified = false;
String lowerId = id.toLowerCase(); String lowerId = id.toLowerCase();
for (int i = 0; i < options.length; i++) { for (IOption option : options) {
if (options[i].getId().toLowerCase().matches(lowerId)) { if (option.getId().toLowerCase().matches(lowerId)) {
if (options[i].getValueType() == IOption.STRING) { if (option.getValueType() == IOption.STRING) {
String oldValue = options[i].getStringValue(); String oldValue = option.getStringValue();
String newValue = oldValue + value; String newValue = oldValue + value;
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], newValue); ManagedBuildManager.setOption(config, optionHolder, option, newValue);
if (setOption == null) {
setOption = options[i];
}
modified = true; modified = true;
} }
} }