1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 00:45:28 +02:00

Bug 315187 Unknown tool option silently breaks ManagedBuild tool command line generation

This commit is contained in:
James Blackburn 2010-06-01 13:48:09 +00:00
parent 587eb8061f
commit e09733c754
5 changed files with 23 additions and 14 deletions

View file

@ -211,7 +211,7 @@ public class ManagedBuilderCorePlugin extends Plugin {
e = ((InvocationTargetException) e).getTargetException();
IStatus status = null;
if (e instanceof CoreException)
status = ((CoreException) e).getStatus();
status = new Status(((CoreException) e).getStatus().getSeverity(), getUniqueIdentifier(), e.getMessage(), e);
else
status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e);
log(status);

View file

@ -168,9 +168,10 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
public Option(IHoldsOptions parent, String Id, String name, Option option){
this.holder = parent;
superClass = option.superClass;
if (superClass != null) {
if (superClass != null)
superClassId = option.superClass.getId();
}
else if (option.superClassId != null)
superClassId = option.superClassId;
setId(Id);
setName(name);
isExtensionOption = false;
@ -708,7 +709,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
public void serialize(ICStorageElement element) throws BuildException {
if (superClass != null)
element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
else if (superClassId != null)
element.setAttribute(IProjectType.SUPERCLASS, superClassId);
element.setAttribute(IBuildObject.ID, id);
if (name != null) {

View file

@ -100,6 +100,7 @@ GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency
# Tool strings
Tool.default.announcement=Invoking:
Tool_Problem_Discovering_Args_For_Option=Problem discovering arguments for Tool option: {0} ({1})
#Environment loader messages
StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.internal.core;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -75,9 +76,11 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeSettings;
import org.eclipse.core.runtime.preferences.IScopeContext;
@ -2502,16 +2505,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
* @param outputFileLocation
* @param macroSubstitutor
* @return the command flags with the build macros resolved
* @throws BuildException
*/
public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation,
SupplierBasedCdtVariableSubstitutor macroSubstitutor,
IMacroContextInfoProvider provider) throws BuildException {
IMacroContextInfoProvider provider) {
IOption[] opts = getOptions();
ArrayList<String> flags = new ArrayList<String>();
StringBuilder sb = new StringBuilder();
for (IOption op : opts) {
IOption option = op;
for (IOption option : opts) {
if (option == null)
continue;
sb.setLength( 0 );
@ -2626,8 +2627,16 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (sb.toString().trim().length() > 0)
flags.add(sb.toString().trim());
} catch (BuildException e) {
// Bug 315187 one broken option shouldn't cascade to all other options breaking the build...
Status s = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), MessageFormat.format(ManagedMakeMessages.getString("Tool_Problem_Discovering_Args_For_Option"), option, //$NON-NLS-1$
option.getId()), e);
ManagedBuilderCorePlugin.log(new CoreException(s));
} catch (CdtVariableException e) {
Status s = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), MessageFormat.format(ManagedMakeMessages.getString("Tool_Problem_Discovering_Args_For_Option"), option, //$NON-NLS-1$
option.getId()), e);
ManagedBuilderCorePlugin.log(new CoreException(s));
}
}
}

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@ -473,10 +472,7 @@ public class BuildMacroProvider implements IBuildMacroProvider, IMacroContextInf
if(tool instanceof Tool){
Tool t = (Tool)tool;
ExplicitFileMacroCollector collector = new ExplicitFileMacroCollector(null);
try {
t.getToolCommandFlags(null,null,collector, getDefault());
} catch (BuildException e){
}
t.getToolCommandFlags(null,null,collector, getDefault());
return collector.getExplicisFileMacros();
}
return new IBuildMacro[0];