mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
bug 272432: tidied up a bit
This commit is contained in:
parent
5f088e7a74
commit
4b6bf63742
1 changed files with 23 additions and 33 deletions
|
@ -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;
|
||||||
|
@ -35,12 +35,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
/**
|
/**
|
||||||
* This class sets the Managed Build System Option Values. Note that this class
|
* This class sets the Managed Build System Option Values. Note that this class
|
||||||
* handles both string options and enumerated options.
|
* handles both string options and enumerated options.
|
||||||
*
|
*
|
||||||
* @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 SetMBSStringOptionValue extends ProcessRunner {
|
public class SetMBSStringOptionValue 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();
|
||||||
|
@ -53,11 +53,10 @@ public class SetMBSStringOptionValue 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();
|
||||||
|
@ -77,15 +76,14 @@ public class SetMBSStringOptionValue 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);
|
||||||
|
@ -97,35 +95,31 @@ public class SetMBSStringOptionValue 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();
|
||||||
int optionType;
|
for (IOption option : options) {
|
||||||
for (int i = 0; i < options.length; i++) {
|
if (option.getBaseId().toLowerCase().matches(lowerId)) {
|
||||||
if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
|
int optionType = option.getValueType();
|
||||||
optionType = options[i].getValueType();
|
|
||||||
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
|
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
|
||||||
IOption setOption = ManagedBuildManager.setOption(resourceConfig, optionHolder, options[i], value);
|
ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value);
|
||||||
if (setOption == null) {
|
|
||||||
setOption = options[i];
|
|
||||||
}
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,15 +130,11 @@ public class SetMBSStringOptionValue 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();
|
||||||
int optionType;
|
for (IOption option : options) {
|
||||||
for (int i = 0; i < options.length; i++) {
|
if (option.getBaseId().toLowerCase().matches(lowerId)) {
|
||||||
if (options[i].getBaseId().toLowerCase().matches(lowerId)) {
|
int optionType = option.getValueType();
|
||||||
optionType = options[i].getValueType();
|
|
||||||
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
|
if ((optionType == IOption.STRING) || (optionType == IOption.ENUMERATED)) {
|
||||||
IOption setOption = ManagedBuildManager.setOption(config, optionHolder, options[i], value);
|
ManagedBuildManager.setOption(config, optionHolder, option, value);
|
||||||
if (setOption == null) {
|
|
||||||
setOption = options[i];
|
|
||||||
}
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue