1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-05 14:43:36 +02:00

Added a field to the option schema that allows a browse type to be encoded and a new sequence to the option reference with list values

This commit is contained in:
Sean Evoy 2004-04-05 15:28:23 +00:00
parent a0aed1c95c
commit 66c786380a
9 changed files with 137 additions and 36 deletions

View file

@ -221,6 +221,23 @@ Additional special types exist to flag options of special relevance to the build
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="browseType">
<annotation>
<documentation>
This value is used for list (and related) options only. If you need a list option to prompt the user to browse for a file or directory when adding a new value, set the value of the attribute accordingly. By default the value is treated as no browsing needed.
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="none">
</enumeration>
<enumeration value="file">
</enumeration>
<enumeration value="directory">
</enumeration>
</restriction>
</simpleType>
</attribute>
</complexType> </complexType>
</element> </element>
@ -323,6 +340,10 @@ Additional special types exist to flag options of special relevance to the build
</documentation> </documentation>
</annotation> </annotation>
<complexType> <complexType>
<sequence>
<element ref="listOptionValue"/>
<element ref="enumeratedOptionValue"/>
</sequence>
<attribute name="id" type="string" use="required"> <attribute name="id" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>

View file

@ -23,8 +23,17 @@ public interface IOption extends IBuildObject {
public static final int PREPROCESSOR_SYMBOLS = 5; public static final int PREPROCESSOR_SYMBOLS = 5;
public static final int LIBRARIES = 6; public static final int LIBRARIES = 6;
public static final int OBJECTS = 7; public static final int OBJECTS = 7;
// Browse type
public static final int BROWSE_NONE = 0;
public static final String NONE = "none"; //$NON-NLS-1$
public static final int BROWSE_FILE = 1;
public static final String FILE = "file"; //$NON-NLS-1$
public static final int BROWSE_DIR = 2;
public static final String DIR = "directory"; //$NON-NLS-1$
// Schema attribute names for option elements // Schema attribute names for option elements
public static final String BROSWE_TYPE = "browseType"; //$NON-NLS-1$
public static final String CATEGORY = "category"; //$NON-NLS-1$ public static final String CATEGORY = "category"; //$NON-NLS-1$
public static final String COMMAND = "command"; //$NON-NLS-1$ public static final String COMMAND = "command"; //$NON-NLS-1$
public static final String COMMAND_FALSE = "commandFalse"; //$NON-NLS-1$ public static final String COMMAND_FALSE = "commandFalse"; //$NON-NLS-1$
@ -64,6 +73,11 @@ public interface IOption extends IBuildObject {
*/ */
public boolean getBooleanValue() throws BuildException; public boolean getBooleanValue() throws BuildException;
/**
* @return
*/
public int getBrowseType();
/** /**
* Answers an array of strings containing the built-in values * Answers an array of strings containing the built-in values
* defined for a stringList, includePaths, definedSymbols, or libs * defined for a stringList, includePaths, definedSymbols, or libs

View file

@ -12,8 +12,8 @@ package org.eclipse.cdt.managedbuilder.core;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -23,12 +23,17 @@ import java.util.Map;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.xerces.dom.DocumentImpl;
import org.apache.xml.serialize.Method;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.Serializer;
import org.apache.xml.serialize.SerializerFactory;
import org.eclipse.cdt.core.AbstractCExtension; import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
@ -297,37 +302,61 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*/ */
public static void saveBuildInfo(IProject project, boolean force) { public static void saveBuildInfo(IProject project, boolean force) {
// Create document // Create document
Document doc = new DocumentImpl(); try {
Element rootElement = doc.createElement(ROOT_ELEM_NAME); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc.appendChild(rootElement); Document doc = builder.newDocument();
Element rootElement = doc.createElement(ROOT_ELEM_NAME);
doc.appendChild(rootElement);
// Save the build info // Save the build info
ManagedBuildInfo buildInfo = (ManagedBuildInfo) getBuildInfo(project); ManagedBuildInfo buildInfo = (ManagedBuildInfo) getBuildInfo(project);
if (buildInfo != null && (force == true || buildInfo.isDirty())) { if (buildInfo != null && (force == true || buildInfo.isDirty())) {
buildInfo.serialize(doc, rootElement); buildInfo.serialize(doc, rootElement);
// Save the document // Transform the document to something we can save in a file
ByteArrayOutputStream s = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
OutputFormat format = new OutputFormat(); Transformer transformer = TransformerFactory.newInstance().newTransformer();
format.setIndenting(true); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
String xml = null; transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
try { DOMSource source = new DOMSource(doc);
Serializer serializer StreamResult result = new StreamResult(stream);
= SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(new OutputStreamWriter(s, "UTF8"), format); //$NON-NLS-1$ transformer.transform(source, result);
serializer.asDOMSerializer().serialize(doc);
xml = s.toString("UTF8"); //$NON-NLS-1$ // Save the document
IFile rscFile = project.getFile(FILE_NAME); IFile projectFile = project.getFile(FILE_NAME);
InputStream inputStream = new ByteArrayInputStream(xml.getBytes()); InputStream inputStream = new ByteArrayInputStream(stream.toByteArray());
// update the resource content if (projectFile.exists()) {
if (rscFile.exists()) { projectFile.setContents(inputStream, IResource.FORCE, null);
rscFile.setContents(inputStream, IResource.FORCE, null);
} else { } else {
rscFile.create(inputStream, IResource.FORCE, null); projectFile.create(inputStream, IResource.FORCE, null);
} }
} catch (Exception e) {
return; // Close the streams
stream.close();
inputStream.close();
} }
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerConfigurationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (TransformerFactoryConfigurationError e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// The save failed
e.printStackTrace();
} catch (CoreException e) {
// Save to IFile failed
e.printStackTrace();
} }
} }
@ -411,7 +440,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("ManagedBuildManager.error.owner_not_project")); //$NON-NLS-1$ throw new BuildException(ManagedBuilderCorePlugin.getResourceString("ManagedBuildManager.error.owner_not_project")); //$NON-NLS-1$
} }
// Passed validation // Passed validation so create the target.
return new Target(resource, parentTarget); return new Target(resource, parentTarget);
} }

View file

@ -28,7 +28,7 @@ import org.eclipse.core.runtime.Plugin;
public class ManagedCProjectNature implements IProjectNature { public class ManagedCProjectNature implements IProjectNature {
public static final String BUILDER_NAME = "genmakebuilder"; //$NON-NLS-1$ public static final String BUILDER_NAME = "genmakebuilder"; //$NON-NLS-1$
public static final String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + "." + BUILDER_NAME; //$NON-NLS-1$ public static final String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + "." + BUILDER_NAME; //$NON-NLS-1$
private static final String MNG_NATURE_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".managedBuildNature"; //$NON-NLS-1$ public static final String MNG_NATURE_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".managedBuildNature"; //$NON-NLS-1$
private IProject project; private IProject project;
/** /**

View file

@ -94,12 +94,16 @@ public class GeneratedMakefileBuilder extends ACBuilder {
*/ */
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
String statusMsg = ManagedBuilderCorePlugin.getFormattedString(START, getProject().getName()); String statusMsg = ManagedBuilderCorePlugin.getFormattedString(START, getProject().getName());
IProject[] deps = getProject().getReferencedProjects();
if (statusMsg != null) { if (statusMsg != null) {
monitor.subTask(statusMsg); monitor.subTask(statusMsg);
} }
// Get the build information // Get the build information
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject()); IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
if (info == null) {
return deps;
}
if (kind == IncrementalProjectBuilder.FULL_BUILD || info.isDirty()) { if (kind == IncrementalProjectBuilder.FULL_BUILD || info.isDirty()) {
fullBuild(monitor, info); fullBuild(monitor, info);
@ -124,7 +128,6 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Scrub the build info of all the projects participating in the build // Scrub the build info of all the projects participating in the build
info.setDirty(false); info.setDirty(false);
IProject[] deps = getProject().getReferencedProjects();
for (int i = 0; i < deps.length; i++) { for (int i = 0; i < deps.length; i++) {
IProject project = deps[i]; IProject project = deps[i];
IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(project); IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(project);

View file

@ -110,6 +110,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public void addTarget(ITarget target) { public void addTarget(ITarget target) {
getTargetMap().put(target.getId(), target); getTargetMap().put(target.getId(), target);
getTargets().add(target); getTargets().add(target);
setDirty(true);
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -30,6 +30,7 @@ public class Option extends BuildObject implements IOption {
private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final String[] EMPTY_STRING_ARRAY = new String[0];
// Private bookeeping attributes // Private bookeeping attributes
private int browseType;
private List builtIns; private List builtIns;
private IOptionCategory category; private IOptionCategory category;
private String command; private String command;
@ -136,6 +137,17 @@ public class Option extends BuildObject implements IOption {
default : default :
break; break;
} }
// Determine if there needs to be a browse button
String browseTypeStr = element.getAttribute(BROSWE_TYPE);
if (browseTypeStr == null || browseTypeStr.equals(NONE)) {
browseType = BROWSE_NONE;
} else if (browseTypeStr.equals(FILE)) {
browseType = BROWSE_FILE;
} else if (browseTypeStr.equals(DIR)) {
browseType = BROWSE_DIR;
}
} }
public void resolveReferences() { public void resolveReferences() {
@ -164,6 +176,13 @@ public class Option extends BuildObject implements IOption {
return bool.booleanValue(); return bool.booleanValue();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseType()
*/
public int getBrowseType() {
return browseType;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getBuiltIns() * @see org.eclipse.cdt.core.build.managed.IOption#getBuiltIns()
*/ */

View file

@ -335,6 +335,13 @@ public class OptionReference implements IOption {
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseType()
*/
public int getBrowseType() {
return option.getBrowseType();
}
private List getBuiltInList() { private List getBuiltInList() {
if (builtIns == null) { if (builtIns == null) {
builtIns = new ArrayList(); builtIns = new ArrayList();

View file

@ -87,7 +87,7 @@ public class Target extends BuildObject implements ITarget {
} }
setId(owner.getName() + "." + parent.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$ setId(owner.getName() + "." + parent.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
setName(parent.getName()); setName(parent.getName());
this.artifactName = parent.getArtifactName(); setArtifactName(parent.getArtifactName());
this.binaryParserId = parent.getBinaryParserId(); this.binaryParserId = parent.getBinaryParserId();
this.defaultExtension = parent.getArtifactExtension(); this.defaultExtension = parent.getArtifactExtension();
this.isTest = parent.isTestTarget(); this.isTest = parent.isTestTarget();
@ -226,6 +226,9 @@ public class Target extends BuildObject implements ITarget {
} }
} }
/**
*
*/
public void resolveReferences() { public void resolveReferences() {
if (!resolved) { if (!resolved) {
resolved = true; resolved = true;
@ -282,6 +285,10 @@ public class Target extends BuildObject implements ITarget {
* @see org.eclipse.cdt.managedbuilder.core.ITarget#resetMakeCommand() * @see org.eclipse.cdt.managedbuilder.core.ITarget#resetMakeCommand()
*/ */
public void resetMakeCommand() { public void resetMakeCommand() {
// Flag target as dirty if the reset actually changes something
if (makeCommand != null) {
setDirty(true);
}
makeCommand = null; makeCommand = null;
makeArguments = null; makeArguments = null;
} }