mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
bug 272432: tidied up + getBaseId()
This commit is contained in:
parent
0f4a1ee55d
commit
8fd82b9735
2 changed files with 40 additions and 51 deletions
|
@ -36,7 +36,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
|
||||
/**
|
||||
* This class Appends contents to Managed Build System StringList Option Values.
|
||||
*
|
||||
*
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||
*/
|
||||
|
@ -60,8 +60,7 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
|||
|
||||
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
|
||||
boolean modified = false;
|
||||
for(int i=0; i<resourcePathObjects.length; i++) {
|
||||
ProcessArgument[] resourcePathObject = resourcePathObjects[i];
|
||||
for (ProcessArgument[] resourcePathObject : resourcePathObjects) {
|
||||
String id = resourcePathObject[0].getSimpleValue();
|
||||
String[] values = resourcePathObject[1].getSimpleArrayValue();
|
||||
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 modified = false;
|
||||
|
||||
for(int i=0; i<projectConfigs.length; i++) {
|
||||
IConfiguration config = projectConfigs[i];
|
||||
for (IConfiguration config : projectConfigs) {
|
||||
IResourceConfiguration resourceConfig = null;
|
||||
if (resource) {
|
||||
resourceConfig = config.getResourceConfiguration(path);
|
||||
|
@ -101,16 +99,16 @@ public class AppendToMBSStringListOptionValues extends ProcessRunner {
|
|||
resourceConfig = config.createResourceConfiguration(file);
|
||||
}
|
||||
ITool[] tools = resourceConfig.getTools();
|
||||
for(int j=0; j<tools.length; j++) {
|
||||
modified |= setOptionForResourceConfig(id, value, resourceConfig, tools[j].getOptions(), tools[j]);
|
||||
for (ITool tool : tools) {
|
||||
modified |= setOptionForResourceConfig(id, value, resourceConfig, tool.getOptions(), tool);
|
||||
}
|
||||
} else {
|
||||
IToolChain toolChain = config.getToolChain();
|
||||
modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain);
|
||||
|
||||
ITool[] tools = config.getTools();
|
||||
for(int j=0; j<tools.length; j++) {
|
||||
modified |= setOptionForConfig(id, value, config, tools[j].getOptions(), tools[j]);
|
||||
for (ITool tool : tools) {
|
||||
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 {
|
||||
boolean modified = false;
|
||||
String lowerId = id.toLowerCase();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
IOption option = options[i];
|
||||
if (option.getId().toLowerCase().matches(lowerId)) {
|
||||
switch(options[i].getValueType()) {
|
||||
for (IOption option : options) {
|
||||
if (option.getBaseId().toLowerCase().matches(lowerId)) {
|
||||
switch(option.getValueType()) {
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.INCLUDE_PATH:
|
||||
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 {
|
||||
boolean modified = false;
|
||||
String lowerId = id.toLowerCase();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
IOption option = options[i];
|
||||
if (option.getId().toLowerCase().matches(lowerId)) {
|
||||
switch(options[i].getValueType()) {
|
||||
for (IOption option : options) {
|
||||
if (option.getBaseId().toLowerCase().matches(lowerId)) {
|
||||
switch(option.getValueType()) {
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.INCLUDE_PATH:
|
||||
case IOption.PREPROCESSOR_SYMBOLS:
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
*******************************************************************************/
|
||||
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.process.ProcessArgument;
|
||||
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
||||
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.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||
|
@ -34,12 +34,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
|
||||
/**
|
||||
* This class Appends contents to Managed Build System String Option Value.
|
||||
*
|
||||
*
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||
*/
|
||||
public class AppendToMBSStringOptionValue extends ProcessRunner {
|
||||
|
||||
|
||||
/**
|
||||
* This method Appends contents to Managed Build System StringList Option Values.
|
||||
*/
|
||||
|
@ -53,13 +53,13 @@ public class AppendToMBSStringOptionValue extends ProcessRunner {
|
|||
workspaceDesc.setAutoBuilding(false);
|
||||
try {
|
||||
workspace.setDescription(workspaceDesc);
|
||||
} catch (CoreException e) {//ignore
|
||||
} catch (CoreException e) {
|
||||
//ignore
|
||||
}
|
||||
|
||||
|
||||
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
|
||||
boolean modified = false;
|
||||
for(int i=0; i<resourcePathObjects.length; i++) {
|
||||
ProcessArgument[] resourcePathObject = resourcePathObjects[i];
|
||||
for (ProcessArgument[] resourcePathObject : resourcePathObjects) {
|
||||
String id = resourcePathObject[0].getSimpleValue();
|
||||
String value = resourcePathObject[1].getSimpleValue();
|
||||
String path = resourcePathObject[2].getSimpleValue();
|
||||
|
@ -79,15 +79,14 @@ public class AppendToMBSStringOptionValue extends ProcessRunner {
|
|||
} catch (CoreException e) {//ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean setOptionValue(IProject projectHandle, String id, String value, String path) throws BuildException, ProcessFailureException {
|
||||
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
|
||||
|
||||
|
||||
boolean resource = !(path == null || path.equals("") || path.equals("/")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
boolean modified = false;
|
||||
|
||||
for(int i=0; i<projectConfigs.length; i++) {
|
||||
IConfiguration config = projectConfigs[i];
|
||||
|
||||
for (IConfiguration config : projectConfigs) {
|
||||
IResourceConfiguration resourceConfig = null;
|
||||
if (resource) {
|
||||
resourceConfig = config.getResourceConfiguration(path);
|
||||
|
@ -99,35 +98,32 @@ public class AppendToMBSStringOptionValue extends ProcessRunner {
|
|||
resourceConfig = config.createResourceConfiguration(file);
|
||||
}
|
||||
ITool[] tools = resourceConfig.getTools();
|
||||
for(int j=0; j<tools.length; j++) {
|
||||
modified |= setOptionForResourceConfig(id, value, resourceConfig, tools[j].getOptions(), tools[j]);
|
||||
for (ITool tool : tools) {
|
||||
modified |= setOptionForResourceConfig(id, value, resourceConfig, tool.getOptions(), tool);
|
||||
}
|
||||
} else {
|
||||
IToolChain toolChain = config.getToolChain();
|
||||
modified |= setOptionForConfig(id, value, config, toolChain.getOptions(), toolChain);
|
||||
|
||||
|
||||
ITool[] tools = config.getTools();
|
||||
for(int j=0; j<tools.length; j++) {
|
||||
modified |= setOptionForConfig(id, value, config, tools[j].getOptions(), tools[j]);
|
||||
for (ITool tool : tools) {
|
||||
modified |= setOptionForConfig(id, value, config, tool.getOptions(), tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean setOptionForResourceConfig(String id, String value, IResourceConfiguration resourceConfig, IOption[] options, IHoldsOptions optionHolder) throws BuildException {
|
||||
boolean modified = false;
|
||||
String lowerId = id.toLowerCase();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
if (options[i].getId().toLowerCase().matches(lowerId)) {
|
||||
if (options[i].getValueType() == IOption.STRING) {
|
||||
String oldValue = options[i].getStringValue();
|
||||
for (IOption option : options) {
|
||||
if (option.getId().toLowerCase().matches(lowerId)) {
|
||||
if (option.getValueType() == IOption.STRING) {
|
||||
String oldValue = option.getStringValue();
|
||||
String newValue = oldValue + value;
|
||||
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], newValue);
|
||||
if (setOption == null) {
|
||||
setOption = options[i];
|
||||
}
|
||||
ManagedBuildManager.setOption(resourceConfig, optionHolder, option, newValue);
|
||||
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 {
|
||||
boolean modified = false;
|
||||
String lowerId = id.toLowerCase();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
if (options[i].getId().toLowerCase().matches(lowerId)) {
|
||||
if (options[i].getValueType() == IOption.STRING) {
|
||||
String oldValue = options[i].getStringValue();
|
||||
for (IOption option : options) {
|
||||
if (option.getId().toLowerCase().matches(lowerId)) {
|
||||
if (option.getValueType() == IOption.STRING) {
|
||||
String oldValue = option.getStringValue();
|
||||
String newValue = oldValue + value;
|
||||
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], newValue);
|
||||
if (setOption == null) {
|
||||
setOption = options[i];
|
||||
}
|
||||
ManagedBuildManager.setOption(config, optionHolder, option, newValue);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue