1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-02 05:45:58 +02:00

bug 272432: tidied up + setBaseId()

This commit is contained in:
Andrew Gvozdev 2010-11-04 20:24:20 +00:00
parent 4b6bf63742
commit 0f4a1ee55d
2 changed files with 44 additions and 64 deletions

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;
@ -34,12 +34,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
/** /**
* This class sets the Managed Build System Option boolean Values. * This class sets the Managed Build System Option boolean Values.
* *
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class SetMBSBooleanOptionValue extends ProcessRunner { public class SetMBSBooleanOptionValue extends ProcessRunner {
@Override @Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException { public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
String projectName = args[0].getSimpleValue(); String projectName = args[0].getSimpleValue();
@ -52,11 +52,10 @@ public class SetMBSBooleanOptionValue extends ProcessRunner {
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();
@ -76,15 +75,14 @@ public class SetMBSBooleanOptionValue extends ProcessRunner {
} catch (CoreException e) {//ignore } catch (CoreException e) {//ignore
} }
} }
private boolean setOptionValue(IProject projectHandle, String id, String value, String path) throws BuildException, ProcessFailureException { private boolean setOptionValue(IProject projectHandle, String id, String value, String path) throws BuildException, ProcessFailureException {
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations(); IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
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);
@ -96,33 +94,30 @@ public class SetMBSBooleanOptionValue 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);
} }
} }
} }
return modified; return modified;
} }
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.getBaseId().toLowerCase().matches(lowerId)) {
if (options[i].getValueType() == IOption.BOOLEAN) { if (option.getValueType() == IOption.BOOLEAN) {
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], Boolean.valueOf(value).booleanValue()); ManagedBuildManager.setOption(resourceConfig, optionHolder, option, Boolean.valueOf(value).booleanValue());
if (setOption == null) {
setOption = options[i];
}
modified = true; modified = true;
} }
} }
@ -133,13 +128,10 @@ public class SetMBSBooleanOptionValue 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.getBaseId().toLowerCase().matches(lowerId)) {
if (options[i].getValueType() == IOption.BOOLEAN) { if (option.getValueType() == IOption.BOOLEAN) {
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], Boolean.valueOf(value).booleanValue()); ManagedBuildManager.setOption(config, optionHolder, option, Boolean.valueOf(value).booleanValue());
if (setOption == null) {
setOption = options[i];
}
modified = true; modified = true;
} }
} }

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;
@ -34,12 +34,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
/** /**
* This class Sets (overwrites) contents of Managed Build System StringList Option Values. * This class Sets (overwrites) contents of Managed Build System StringList Option Values.
* *
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class SetMBSStringListOptionValues extends ProcessRunner { public class SetMBSStringListOptionValues extends ProcessRunner {
@Override @Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException { public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
String projectName = args[0].getSimpleValue(); String projectName = args[0].getSimpleValue();
@ -52,11 +52,10 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
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[] values = resourcePathObject[1].getSimpleArrayValue(); String[] values = resourcePathObject[1].getSimpleArrayValue();
String path = resourcePathObject[2].getSimpleValue(); String path = resourcePathObject[2].getSimpleValue();
@ -76,15 +75,14 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
} catch (CoreException e) {//ignore } catch (CoreException e) {//ignore
} }
} }
private boolean setOptionValue(IProject projectHandle, String id, String[] value, String path) throws BuildException, ProcessFailureException { private boolean setOptionValue(IProject projectHandle, String id, String[] value, String path) throws BuildException, ProcessFailureException {
IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations(); IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
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);
@ -96,30 +94,28 @@ public class SetMBSStringListOptionValues 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);
} }
} }
} }
return modified; return modified;
} }
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)) {
IOption setOption = null;
switch (option.getValueType()) { switch (option.getValueType()) {
case IOption.STRING_LIST: case IOption.STRING_LIST:
case IOption.INCLUDE_PATH: case IOption.INCLUDE_PATH:
@ -130,14 +126,11 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
case IOption.LIBRARY_PATHS: case IOption.LIBRARY_PATHS:
case IOption.LIBRARY_FILES: case IOption.LIBRARY_FILES:
case IOption.MACRO_FILES: case IOption.MACRO_FILES:
setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value); ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value);
break; break;
default: default:
continue; continue;
} }
if (setOption == null) {
setOption = option;
}
modified = true; modified = true;
} }
} }
@ -147,10 +140,8 @@ public class SetMBSStringListOptionValues 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)) {
IOption setOption = null;
switch (option.getValueType()) { switch (option.getValueType()) {
case IOption.STRING_LIST: case IOption.STRING_LIST:
case IOption.INCLUDE_PATH: case IOption.INCLUDE_PATH:
@ -161,14 +152,11 @@ public class SetMBSStringListOptionValues extends ProcessRunner {
case IOption.LIBRARY_PATHS: case IOption.LIBRARY_PATHS:
case IOption.LIBRARY_FILES: case IOption.LIBRARY_FILES:
case IOption.MACRO_FILES: case IOption.MACRO_FILES:
setOption = ManagedBuildManager.setOption(config, optionHolder, option, value); ManagedBuildManager.setOption(config, optionHolder, option, value);
break; break;
default: default:
continue; continue;
} }
if (setOption == null) {
setOption = option;
}
modified = true; modified = true;
} }
} }