mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Changed the toolchain specification for Gnu tools to add a generic set of target definitions for POSIX targets. There is also a redefined set of tools and options. There is also a conversion routine that runs on workspace startup to convert older projects into the newer format.
This commit is contained in:
parent
43e38ae75c
commit
f971a5046c
28 changed files with 2534 additions and 3518 deletions
|
@ -60,7 +60,7 @@
|
|||
defaultExtension="toor"
|
||||
isAbstract="false"
|
||||
makeCommand="make"
|
||||
makeFlags="-k"
|
||||
makeArguments="-k"
|
||||
binaryParser="org.eclipse.cdt.core.PE"
|
||||
osList="win32">
|
||||
<tool
|
||||
|
@ -182,7 +182,7 @@
|
|||
id="boolean.false.option">
|
||||
</optionReference>
|
||||
<optionReference
|
||||
defaultValue="-e2"
|
||||
defaultValue="another.enum.option"
|
||||
id="enumerated.option">
|
||||
</optionReference>
|
||||
<optionReference
|
||||
|
@ -208,7 +208,7 @@
|
|||
defaultExtension="bus"
|
||||
isAbstract="false"
|
||||
binaryParser="org.eclipse.cdt.core.PE"
|
||||
makeFlags="-d"
|
||||
makeArguments="-d"
|
||||
parent="test.root"
|
||||
osList="win32,linux,solaris">
|
||||
<configuration
|
||||
|
@ -294,6 +294,7 @@
|
|||
</toolReference>
|
||||
</target>
|
||||
<dynamicElementProvider
|
||||
name="Test Target Provider"
|
||||
class="org.eclipse.cdt.managedbuild.core.tests.TestManagedConfigProvider">
|
||||
</dynamicElementProvider>
|
||||
<target
|
||||
|
@ -364,6 +365,8 @@
|
|||
id="error.parsers.tool">
|
||||
</tool>
|
||||
</target>
|
||||
<!-- The old tool definitions exercised the model differently, so keep an example around for testing -->
|
||||
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -844,11 +844,15 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
// Next option is an enumerated
|
||||
assertEquals("Enumerated Option in Category", options[4].getName());
|
||||
assertEquals(IOption.ENUMERATED, options[4].getValueType());
|
||||
assertEquals("Default Enum", options[4].getSelectedEnum());
|
||||
// Post-2.0 enums store the ID, not the string value
|
||||
assertEquals("default.enum.option", options[4].getSelectedEnum());
|
||||
assertEquals("-e1", options[4].getEnumCommand("default.enum.option"));
|
||||
// Need this methof to populate the UI selection widget
|
||||
valueList = options[4].getApplicableValues();
|
||||
assertEquals(2, valueList.length);
|
||||
assertEquals("Default Enum", valueList[0]);
|
||||
assertEquals("Another Enum", valueList[1]);
|
||||
// Test compatability with 1.2 scheme of getting the command from the name
|
||||
assertEquals("-e1", options[4].getEnumCommand(valueList[0]));
|
||||
assertEquals("-e2", options[4].getEnumCommand(valueList[1]));
|
||||
// Final option is another boolean
|
||||
|
@ -986,13 +990,13 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
assertTrue(options[2] instanceof OptionReference);
|
||||
assertEquals("Enumerated Option in Category", options[2].getName());
|
||||
assertEquals(IOption.ENUMERATED, options[2].getValueType());
|
||||
assertEquals("-e2", options[2].getSelectedEnum());
|
||||
assertEquals("another.enum.option", options[2].getSelectedEnum());
|
||||
assertTrue(options[3] instanceof OptionReference);
|
||||
assertEquals("Boolean Option in Category", options[3].getName());
|
||||
assertEquals(IOption.BOOLEAN, options[3].getValueType());
|
||||
assertEquals(true, options[3].getBooleanValue());
|
||||
tool = tools[0];
|
||||
assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden", tool.getToolFlags());
|
||||
assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1186,7 +1190,7 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
assertNotNull(parentTool);
|
||||
|
||||
// check option categories
|
||||
IOption option = parentTool.getOption("test.forward.option");
|
||||
IOption option = parentTool.getOptionById("test.forward.option");
|
||||
assertNotNull(option);
|
||||
IOptionCategory[] firstLevel = parentTool.getTopOptionCategory()
|
||||
.getChildCategories();
|
||||
|
@ -1206,7 +1210,7 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
|
||||
// get and check the option reference
|
||||
OptionReference optRef = (OptionReference)
|
||||
childToolRef.getOption("test.forward.option");
|
||||
childToolRef.getOptionById("test.forward.option");
|
||||
assertEquals(option, optRef.getOption());
|
||||
|
||||
// get the tool reference from the grandchild
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
<attribute name="outputPrefix" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Some tools produce files with a special prefix that must be specified. For example, a librarian on POSIX systems expects the output to be lib<target>.a so 'lib' would be the prefix.
|
||||
Some tools produce files with a special prefix that must be specified. For example, a librarian on POSIX systems expects the output to be lib<target>.a, so 'lib' would be the prefix.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
|
@ -327,7 +327,28 @@ Additional special types exist to flag options of special relevance to the build
|
|||
<attribute name="command" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
The overridden command for the tool the reference is for.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="outputs" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A comma-separated list of extensions that this tool reference will create. This completely overrides the the output extension in the tool the reference is for.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="outputPrefix" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The prefix that will be applied to the output of the tool. This completely overrides the output defined in the referenced tool.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="outputFlag" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Overrides the output flag of the referenced tool.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
|
@ -388,7 +409,7 @@ Additional special types exist to flag options of special relevance to the build
|
|||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string" use="required">
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A human-readable target name, such as 'Linux Executable'. This will be the name the user sees displayed in the UI.
|
||||
|
@ -444,14 +465,14 @@ Additional special types exist to flag options of special relevance to the build
|
|||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="makeFlags" type="string">
|
||||
<attribute name="makeArguments" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="binaryParser" type="string" use="required">
|
||||
<attribute name="binaryParser" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Set this to the ID of the binary parser for the output format of your target. Currently there are only 2 choices: org.eclipse.cdt.core.ELF for *nix targets, and "org.eclipse.cdt.core.PE" for targets that build for Windows, like Cygwin.
|
||||
|
@ -461,7 +482,7 @@ Additional special types exist to flag options of special relevance to the build
|
|||
<attribute name="osList" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
This field is used by the managed build system to decide when to show the user the target. The value should be a comma-separated list. Current values are "win32", "linux", and "solaris".
|
||||
This field is used by the managed build system to decide when to show the user the target. The value should be a comma-separated list. Current values are "win32", "linux", "solaris", "hpux", "aix" or "any".
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
|
@ -547,6 +568,13 @@ Additional special types exist to flag options of special relevance to the build
|
|||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A meaningful name for the type of element being provided.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ public interface IConfiguration extends IBuildObject {
|
|||
*/
|
||||
public IConfiguration getParent();
|
||||
|
||||
public ITool getToolById(String id);
|
||||
|
||||
/**
|
||||
* Returns the tools that are used in this configuration.
|
||||
*
|
||||
|
|
|
@ -201,6 +201,13 @@ public interface IManagedBuildInfo {
|
|||
*/
|
||||
public String[] getUserObjectsForTarget(String extension);
|
||||
|
||||
|
||||
/**
|
||||
* Answers the version of the build information in the format
|
||||
* @return
|
||||
*/
|
||||
public String getVersion();
|
||||
|
||||
/**
|
||||
* Answers true if the build model has been changed by the user.
|
||||
*
|
||||
|
@ -217,6 +224,8 @@ public interface IManagedBuildInfo {
|
|||
*/
|
||||
public boolean isHeaderFile(String ext);
|
||||
|
||||
public void removeTarget(String id);
|
||||
|
||||
/**
|
||||
* Set the dirty flag for the build model to the value of the argument.
|
||||
*
|
||||
|
|
|
@ -119,14 +119,21 @@ public interface IOption extends IBuildObject {
|
|||
public String[] getDefinedSymbols() throws BuildException;
|
||||
|
||||
/**
|
||||
* Answers the command associated with the enumeration name. For
|
||||
* example, if the enumeration name was 'Default' for the debug
|
||||
* level option of the Gnu compiler, and the plugin manifest defined
|
||||
* that as -g, then the return value would be a String containing "-g"
|
||||
* Answers the command associated with the enumeration id. For
|
||||
* example, if the enumeration id was <code>gnu.debug.level.default</code>
|
||||
* for the debug level option of the Gnu compiler, and the plugin
|
||||
* manifest defined that as -g, then the return value would be the
|
||||
* String "-g"
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getEnumCommand (String name);
|
||||
public String getEnumCommand (String id);
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public String getEnumeratedId(String name);
|
||||
|
||||
/**
|
||||
* Answers an array of <code>String</code> containing the includes paths
|
||||
|
@ -148,14 +155,14 @@ public interface IOption extends IBuildObject {
|
|||
public String[] getLibraries() throws BuildException ;
|
||||
|
||||
/**
|
||||
* Answers a <code>String</code> containing the selected enumeration in an
|
||||
* enumerated option. For an option that has not been changed by the user,
|
||||
* the receiver will answer with the default defined in the plugin manifest.
|
||||
* If the user has modified the selection, the receiver will answer with the
|
||||
* overridden selection.
|
||||
* Answers a <code>String</code> containing the unique ID of the selected
|
||||
* enumeration in an enumerated option. For an option that has not been
|
||||
* changed by the user, the receiver will answer with the default defined
|
||||
* in the plugin manifest. If the user has modified the selection, the
|
||||
* receiver will answer with the overridden selection.
|
||||
*
|
||||
* @return String
|
||||
* @throws BuildException
|
||||
* @throws BuildException if the option type is not an enumeration
|
||||
*/
|
||||
public String getSelectedEnum () throws BuildException;
|
||||
|
||||
|
|
|
@ -61,12 +61,28 @@ public interface ITool extends IBuildObject {
|
|||
public int getNatureFilter();
|
||||
|
||||
/**
|
||||
* Get a particular option.
|
||||
*
|
||||
* This is a deprecated method for retrieving an <code>IOption</code> from
|
||||
* the receiver based on an ID. It is preferred that you use the newer method
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
||||
*
|
||||
* @param id unique identifier of the option to search for
|
||||
* @return IOption
|
||||
* @return <code>IOption</code>
|
||||
*/
|
||||
public IOption getOption(String id);
|
||||
|
||||
/**
|
||||
* Get the <code>IOption</code> in the receiver with the specified
|
||||
* ID. This is an efficient search in the receiver.
|
||||
*
|
||||
* <p>If the receiver does not have an option with that ID, the method
|
||||
* returns <code>null</code>. It is the responsibility of the caller to
|
||||
* verify the return value.
|
||||
*
|
||||
* @param id unique identifier of the option to search for
|
||||
* @return <code>IOption</code>
|
||||
* @since 2.0
|
||||
*/
|
||||
public IOption getOptionById(String id);
|
||||
|
||||
/**
|
||||
* Answers the options that may be customized for this tool.
|
||||
|
|
|
@ -56,7 +56,11 @@ public interface IToolReference extends ITool {
|
|||
*/
|
||||
public boolean references(ITool tool);
|
||||
|
||||
|
||||
/**
|
||||
* @param isDirty The value to set the dirty flag to in the receiver
|
||||
*/
|
||||
public void setDirty(boolean isDirty);
|
||||
|
||||
/**
|
||||
* Set the tool command in the receiver to be the argument.
|
||||
*
|
||||
|
|
|
@ -35,6 +35,12 @@ import javax.xml.transform.dom.DOMSource;
|
|||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.eclipse.cdt.core.AbstractCExtension;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IContainerEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
|
@ -43,6 +49,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
|
|||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Target;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
||||
import org.eclipse.cdt.managedbuilder.scannerconfig.ManagedBuildCPathEntryContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -51,6 +58,8 @@ import org.eclipse.core.runtime.IConfigurationElement;
|
|||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.w3c.dom.Document;
|
||||
|
@ -67,7 +76,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
|
||||
private static final QualifiedName buildInfoProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "managedBuildInfo"); //$NON-NLS-1$
|
||||
private static final String ROOT_NODE_NAME = "ManagedProjectBuildInfo"; //$NON-NLS-1$
|
||||
private static final String FILE_NAME = ".cdtbuild"; //$NON-NLS-1$
|
||||
public static final String SETTINGS_FILE_NAME = ".cdtbuild"; //$NON-NLS-1$
|
||||
private static final ITarget[] emptyTargets = new ITarget[0];
|
||||
public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.getUniqueIdentifier() + "." + "ManagedBuildManager"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final String EXTENSION_POINT_ID = "ManagedBuildInfo"; //$NON-NLS-1$
|
||||
|
@ -278,6 +287,15 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newProject
|
||||
*/
|
||||
public static void setNewProjectVersion(IProject newProject) {
|
||||
// Get the build info for the argument
|
||||
ManagedBuildInfo info = findBuildInfo(newProject, false);
|
||||
info.setVersion(buildInfoVersion.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the string value for an option for a given config.
|
||||
*
|
||||
|
@ -380,7 +398,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
transformer.transform(source, result);
|
||||
|
||||
// Save the document
|
||||
IFile projectFile = project.getFile(FILE_NAME);
|
||||
IFile projectFile = project.getFile(SETTINGS_FILE_NAME);
|
||||
String utfString = stream.toString("UTF8");
|
||||
if (projectFile.exists()) {
|
||||
projectFile.setContents(new ByteArrayInputStream(utfString.getBytes()), IResource.FORCE, null);
|
||||
|
@ -470,7 +488,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
public static void addExtensionTool(Tool tool) {
|
||||
getExtensionToolMap().put(tool.getId(), tool);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new target for the resource based on the parentTarget.
|
||||
*
|
||||
|
@ -534,7 +552,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
*/
|
||||
private static ManagedBuildInfo loadBuildInfo(IProject project) {
|
||||
ManagedBuildInfo buildInfo = null;
|
||||
IFile file = project.getFile(FILE_NAME);
|
||||
IFile file = project.getFile(SETTINGS_FILE_NAME);
|
||||
if (!file.exists())
|
||||
return null;
|
||||
|
||||
|
@ -679,7 +697,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
IFile file = project.getFile(FILE_NAME);
|
||||
IFile file = project.getFile(SETTINGS_FILE_NAME);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
InputStream stream = file.getContents();
|
||||
|
@ -700,11 +718,16 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
// Make sure the extension information is loaded first
|
||||
try {
|
||||
loadExtensions();
|
||||
} catch (BuildException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (BuildException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
// Flag to deteremine if a PathEntryContainer is needed for project
|
||||
boolean needsContainer = false;
|
||||
ManagedBuildInfo buildInfo = null;
|
||||
|
||||
// Check if there is any build info associated with this project for this session
|
||||
try {
|
||||
buildInfo = (ManagedBuildInfo)resource.getSessionProperty(buildInfoProperty);
|
||||
// Make sure that if a project has build info, that the info is not corrupted
|
||||
|
@ -712,11 +735,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
buildInfo.updateOwner(resource);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
return buildInfo;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (buildInfo == null && resource instanceof IProject) {
|
||||
// Nothing in session store, so see if we can load it from cdtbuild
|
||||
buildInfo = loadBuildInfo((IProject)resource);
|
||||
needsContainer = (buildInfo != null);
|
||||
}
|
||||
|
||||
if (buildInfo == null && create) {
|
||||
|
@ -725,8 +750,24 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
buildInfo = new ManagedBuildInfo(resource);
|
||||
// Associate the build info with the project for the duration of the session
|
||||
resource.setSessionProperty(buildInfoProperty, buildInfo);
|
||||
needsContainer = true;
|
||||
} catch (CoreException e) {
|
||||
buildInfo = null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Assocaite a container with the project
|
||||
if (buildInfo != null && needsContainer) {
|
||||
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(buildInfo);
|
||||
try {
|
||||
ICProject project = CoreModel.getDefault().create((IProject)resource);
|
||||
IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$
|
||||
CoreModel.getDefault().setRawPathEntries(project, new IPathEntry[]{containerEntry}, new NullProgressMonitor());
|
||||
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{project}, container, new NullProgressMonitor());
|
||||
} catch (CModelException e) {
|
||||
e.printStackTrace();
|
||||
// The build info is valid even if there's no container
|
||||
return buildInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -216,19 +216,31 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
* @return
|
||||
*/
|
||||
private OptionReference createOptionReference(IOption option) {
|
||||
// The option may already be a reference created to hold user settings
|
||||
if (option instanceof OptionReference) {
|
||||
// The option reference belongs to an existing tool reference
|
||||
OptionReference optionRef = (OptionReference)option;
|
||||
ToolReference toolRef = optionRef.getToolReference();
|
||||
// That tool reference may belong to a target or to the configuration
|
||||
if (toolRef.ownedByConfiguration(this))
|
||||
return optionRef;
|
||||
else {
|
||||
// Make a copy so the settings can be saved
|
||||
toolRef = new ToolReference(this, toolRef);
|
||||
return toolRef.createOptionReference(option);
|
||||
}
|
||||
} else {
|
||||
IToolReference toolRef = getToolReference(option.getTool());
|
||||
if (toolRef == null)
|
||||
// Find out if a tool reference already exists
|
||||
ToolReference toolRef = (ToolReference) getToolReference(option.getTool());
|
||||
if (toolRef == null) {
|
||||
toolRef = new ToolReference(this, option.getTool());
|
||||
} else {
|
||||
// The reference may belong to the target
|
||||
if (!toolRef.ownedByConfiguration(this)) {
|
||||
toolRef = new ToolReference(this, toolRef);
|
||||
}
|
||||
}
|
||||
|
||||
return toolRef.createOptionReference(option);
|
||||
}
|
||||
}
|
||||
|
@ -362,6 +374,31 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
return references;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolById(java.lang.String)
|
||||
*/
|
||||
public ITool getToolById(String id) {
|
||||
ITool[] tools = parent != null
|
||||
? parent.getTools()
|
||||
: target.getTools();
|
||||
|
||||
// Replace tools with local overrides
|
||||
for (int i = 0; i < tools.length; ++i) {
|
||||
IToolReference ref = getToolReference(tools[i]);
|
||||
if (ref != null)
|
||||
tools[i] = ref;
|
||||
}
|
||||
|
||||
// Search the result for the ID
|
||||
for (int index = tools.length - 1; index >= 0; --index) {
|
||||
if (tools[index].getId().equals(id)) {
|
||||
return tools[index];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTarget()
|
||||
*/
|
||||
|
@ -384,18 +421,29 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
* @return ToolReference
|
||||
*/
|
||||
private IToolReference getToolReference(ITool tool) {
|
||||
// Sanity
|
||||
if (tool == null) return null;
|
||||
|
||||
// See if the receiver has a reference to the tool
|
||||
ToolReference ref = null;
|
||||
if (tool == null) return ref;
|
||||
Iterator iter = getLocalToolReferences().listIterator();
|
||||
while (iter.hasNext()) {
|
||||
ToolReference temp = (ToolReference)iter.next();
|
||||
if (temp.references(tool)) {
|
||||
ref = temp;
|
||||
break;
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
return ref;
|
||||
|
||||
// See if the target that the receiver belongs to has a reference to the tool
|
||||
ITool[] targetTools = target.getTools();
|
||||
for (int index = targetTools.length - 1; index >= 0; --index) {
|
||||
ITool targetTool = targetTools[index];
|
||||
if (targetTool instanceof ToolReference) {
|
||||
if (((ToolReference)targetTool).references(tool)) {
|
||||
return (ToolReference)targetTool;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -447,7 +495,13 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
|
||||
*/
|
||||
public void setDirty(boolean isDirty) {
|
||||
// Override the dirty flag
|
||||
this.isDirty = isDirty;
|
||||
// And do the same for the tool references
|
||||
Iterator iter = getLocalToolReferences().listIterator();
|
||||
while (iter.hasNext()) {
|
||||
((ToolReference)iter.next()).setDirty(isDirty);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -669,7 +669,11 @@ public class MakefileGenerator {
|
|||
|
||||
// Always add a clean target
|
||||
buffer.append("clean:" + NEWLINE); //$NON-NLS-1$
|
||||
buffer.append(TAB + "-$(RM)" + WHITESPACE + "$(OBJS)" + WHITESPACE + outputPrefix + target + NEWLINE + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
buffer.append(TAB + "-$(RM)" + WHITESPACE + "$(OBJS)" + WHITESPACE + outputPrefix + target); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (extension.length() > 0) {
|
||||
buffer.append(DOT + extension);
|
||||
}
|
||||
buffer.append(NEWLINE + NEWLINE);
|
||||
|
||||
buffer.append(".PHONY: all clean deps" + NEWLINE + NEWLINE); //$NON-NLS-1$
|
||||
|
||||
|
@ -765,6 +769,16 @@ public class MakefileGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @param message
|
||||
*/
|
||||
protected void cancel(String message) {
|
||||
if (monitor != null && !monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the build has been cancelled. Cancellation requests
|
||||
* propagated to the caller by throwing <code>OperationCanceledException</code>.
|
||||
|
@ -777,7 +791,6 @@ public class MakefileGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clients call this method when an incremental rebuild is required. The argument
|
||||
* contains a set of resource deltas that will be used to determine which
|
||||
|
@ -1076,7 +1089,11 @@ public class MakefileGenerator {
|
|||
// Now populate the module makefiles
|
||||
ListIterator iter = getSubdirList().listIterator();
|
||||
while (iter.hasNext()) {
|
||||
populateFragmentMakefile((IContainer)iter.next());
|
||||
try {
|
||||
populateFragmentMakefile((IContainer)iter.next());
|
||||
} catch (CoreException e) {
|
||||
|
||||
}
|
||||
checkCancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,11 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
|
@ -54,7 +59,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
private IResource owner;
|
||||
private Map targetMap;
|
||||
private List targetList;
|
||||
private String version; //$NON-NLS-1$
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* Create a new managed build information for the IResource specified in the argument
|
||||
|
@ -172,6 +177,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
|
||||
*/
|
||||
|
@ -338,7 +345,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
}
|
||||
return symbols;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForSource(java.lang.String)
|
||||
*/
|
||||
|
@ -463,7 +470,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
if (option.getValueType() == IOption.INCLUDE_PATH) {
|
||||
try {
|
||||
// Get all the built-in paths from the option
|
||||
paths.addAll(Arrays.asList(option.getBuiltIns()));
|
||||
paths.addAll(getCompilerPaths(option));
|
||||
// Get all the user-defined paths from the option as absolute paths
|
||||
String[] userPaths = option.getIncludePaths();
|
||||
for (int index = 0; index < userPaths.length; ++index) {
|
||||
|
@ -486,6 +493,39 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return (String[])paths.toArray(new String[paths.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param owner2
|
||||
* @return
|
||||
*/
|
||||
private List getCompilerPaths(IOption option) {
|
||||
// Extract the resolved paths from the project (if any)
|
||||
ArrayList paths = new ArrayList();
|
||||
ICProject project = CoreModel.getDefault().create(owner.getProject());
|
||||
if (project != null) {
|
||||
try {
|
||||
IPathEntry[] entries = project.getResolvedPathEntries();
|
||||
for (int index = entries.length - 1; index >=0; --index) {
|
||||
int kind = entries[index].getEntryKind();
|
||||
if (kind == IPathEntry.CDT_INCLUDE) {
|
||||
IIncludeEntry include = (IIncludeEntry) entries[index];
|
||||
if (include.isSystemInclude()) {
|
||||
IPath entryPath = include.getPath();
|
||||
paths.add(entryPath.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
// See if there are any built-ins from the tool definition
|
||||
return Arrays.asList(option.getBuiltIns());
|
||||
}
|
||||
}
|
||||
// if (paths.size() == 0) {
|
||||
return Arrays.asList(option.getBuiltIns());
|
||||
// } else {
|
||||
// return paths;
|
||||
// }
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForTarget(java.lang.String)
|
||||
*/
|
||||
|
@ -830,8 +870,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return (String[])objs.toArray(new String[objs.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getVersion()
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
|
@ -935,6 +975,16 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#removeTarget(java.lang.String)
|
||||
*/
|
||||
public void removeTarget(String id) {
|
||||
getTargets().remove(getTarget(id));
|
||||
getTargetMap().remove(id);
|
||||
setDirty(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the contents of the build model to the persistent store
|
||||
* specified in the argument.
|
||||
|
|
|
@ -12,8 +12,11 @@ package org.eclipse.cdt.managedbuilder.internal.core;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
|
@ -35,8 +38,9 @@ public class Option extends BuildObject implements IOption {
|
|||
private IOptionCategory category;
|
||||
private String command;
|
||||
private String commandFalse;
|
||||
private String defaultEnumName;
|
||||
private String defaultEnumId;
|
||||
private Map enumCommands;
|
||||
private Map enumNames;
|
||||
private ITool tool;
|
||||
private Object value;
|
||||
private int valueType;
|
||||
|
@ -89,7 +93,6 @@ public class Option extends BuildObject implements IOption {
|
|||
valueType = PREPROCESSOR_SYMBOLS;
|
||||
|
||||
// Now get the actual value
|
||||
enumCommands = new HashMap();
|
||||
switch (valueType) {
|
||||
case BOOLEAN:
|
||||
// Convert the string to a boolean
|
||||
|
@ -103,13 +106,13 @@ public class Option extends BuildObject implements IOption {
|
|||
List enumList = new ArrayList();
|
||||
IManagedConfigElement[] enumElements = element.getChildren(ENUM_VALUE);
|
||||
for (int i = 0; i < enumElements.length; ++i) {
|
||||
String optName = enumElements[i].getAttribute(NAME);
|
||||
String optCommand = enumElements[i].getAttribute(COMMAND);
|
||||
enumList.add(optName);
|
||||
enumCommands.put(optName, optCommand);
|
||||
String optId = enumElements[i].getAttribute(ID);
|
||||
enumList.add(optId);
|
||||
getEnumCommandMap().put(optId, enumElements[i].getAttribute(COMMAND));
|
||||
getEnumNameMap().put(optId, enumElements[i].getAttribute(NAME));
|
||||
Boolean isDefault = new Boolean(enumElements[i].getAttribute(IS_DEFAULT));
|
||||
if (isDefault.booleanValue()) {
|
||||
defaultEnumName = optName;
|
||||
defaultEnumId = optId;
|
||||
}
|
||||
}
|
||||
value = enumList;
|
||||
|
@ -165,10 +168,18 @@ public class Option extends BuildObject implements IOption {
|
|||
* @see org.eclipse.cdt.core.build.managed.IOption#getApplicableValues()
|
||||
*/
|
||||
public String[] getApplicableValues() {
|
||||
List enumValues = (List)value;
|
||||
return enumValues != null
|
||||
? (String[])enumValues.toArray(new String[enumValues.size()])
|
||||
: EMPTY_STRING_ARRAY;
|
||||
// Get all of the enumerated names from the option
|
||||
List ids = (List) value;
|
||||
if (ids == null || ids.size() == 0) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
} else {
|
||||
// Return the elements in the order they are specified in the manifest
|
||||
String[] enumNames = new String[ids.size()];
|
||||
for (int index = 0; index < ids.size(); ++ index) {
|
||||
enumNames[index] = (String) getEnumNameMap().get(ids.get(index));
|
||||
}
|
||||
return enumNames;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getBooleanValue() {
|
||||
|
@ -233,11 +244,72 @@ public class Option extends BuildObject implements IOption {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
|
||||
*/
|
||||
public String getEnumCommand(String name) {
|
||||
String cmd = (String) enumCommands.get(name);
|
||||
public String getEnumCommand(String id) {
|
||||
// Sanity
|
||||
if (id == null) return EMPTY_STRING;
|
||||
|
||||
// First check for the command in ID->command map
|
||||
String cmd = (String) getEnumCommandMap().get(id);
|
||||
if (cmd == null) {
|
||||
// This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
|
||||
// name of the enumeration. Search for the ID that maps to the name and use that to find the
|
||||
// command.
|
||||
List ids = (List) value;
|
||||
ListIterator iter = ids.listIterator();
|
||||
while (iter.hasNext()) {
|
||||
String realID = (String) iter.next();
|
||||
String name = (String) getEnumNameMap().get(realID);
|
||||
if (id.equals(name)) {
|
||||
cmd = (String) getEnumCommandMap().get(realID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmd == null ? EMPTY_STRING : cmd;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* A memory-safe accessor to the map of enumerated option value IDs to the commands
|
||||
* that a tool understands.
|
||||
*
|
||||
* @return a Map of enumerated option value IDs to actual commands that are passed
|
||||
* to a tool on the command line.
|
||||
*/
|
||||
private Map getEnumCommandMap() {
|
||||
if (enumCommands == null) {
|
||||
enumCommands = new HashMap();
|
||||
}
|
||||
return enumCommands;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumeratedId(java.lang.String)
|
||||
*/
|
||||
public String getEnumeratedId(String name) {
|
||||
if (name == null) return null;
|
||||
Set idSet = getEnumNameMap().keySet();
|
||||
Iterator iter = idSet.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String id = (String) iter.next();
|
||||
String enumName = (String) getEnumNameMap().get(id);
|
||||
if (name.equals(enumName)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @return a Map of enumerated option value IDs to the selection displayed to the user.
|
||||
*/
|
||||
private Map getEnumNameMap() {
|
||||
if (enumNames == null) {
|
||||
enumNames = new HashMap();
|
||||
}
|
||||
return enumNames;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IOption#getIncludePaths()
|
||||
*/
|
||||
|
@ -277,7 +349,7 @@ public class Option extends BuildObject implements IOption {
|
|||
if (valueType != ENUMERATED) {
|
||||
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
|
||||
}
|
||||
return defaultEnumName == null ? EMPTY_STRING : defaultEnumName;
|
||||
return defaultEnumId == null ? EMPTY_STRING : defaultEnumId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -87,8 +87,13 @@ public class OptionReference implements IOption {
|
|||
* @param element
|
||||
*/
|
||||
public OptionReference(ToolReference owner, Element element) {
|
||||
this.owner = owner;
|
||||
option = owner.getTool().getOption(element.getAttribute(ID));
|
||||
this.owner = owner;
|
||||
try {
|
||||
option = owner.getTool().getOptionById(element.getAttribute(ID));
|
||||
} catch (NullPointerException e) {
|
||||
// Something bad happened
|
||||
option = null;
|
||||
}
|
||||
|
||||
// Bail now if there's no option for the reference
|
||||
if (option == null) {
|
||||
|
@ -105,7 +110,9 @@ public class OptionReference implements IOption {
|
|||
break;
|
||||
case STRING:
|
||||
case ENUMERATED:
|
||||
value = (String) element.getAttribute(DEFAULT_VALUE);
|
||||
// Pre-2.0 the value was the string for the UI
|
||||
// Post-2.0 it is the ID of the enumerated option
|
||||
value = (String) element.getAttribute(DEFAULT_VALUE);
|
||||
break;
|
||||
case STRING_LIST:
|
||||
case INCLUDE_PATH:
|
||||
|
@ -137,7 +144,12 @@ public class OptionReference implements IOption {
|
|||
IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
|
||||
|
||||
// resolve parent (recursively) before calling methods on it.
|
||||
option = owner.getTool().getOption(element.getAttribute(ID));
|
||||
option = owner.getTool().getOptionById(element.getAttribute(ID));
|
||||
if (option == null) {
|
||||
// error condition probably the result of a misidentified option ID
|
||||
resolved = false;
|
||||
return;
|
||||
}
|
||||
if (option instanceof Option) {
|
||||
((Option)option).resolveReferences();
|
||||
} else if (option instanceof OptionReference) {
|
||||
|
@ -276,9 +288,31 @@ public class OptionReference implements IOption {
|
|||
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
|
||||
*/
|
||||
public String getEnumCommand(String name) {
|
||||
return option.getEnumCommand(name);
|
||||
if (!resolved) {
|
||||
resolveReferences();
|
||||
}
|
||||
if (option != null) {
|
||||
return option.getEnumCommand(name);
|
||||
} else {
|
||||
return new String();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumeratedId(java.lang.String)
|
||||
*/
|
||||
public String getEnumeratedId(String name) {
|
||||
if (!resolved) {
|
||||
resolveReferences();
|
||||
}
|
||||
if (option != null) {
|
||||
return option.getEnumeratedId(name);
|
||||
} else {
|
||||
return new String();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
|
||||
*/
|
||||
|
@ -373,19 +407,27 @@ public class OptionReference implements IOption {
|
|||
return (String[]) answer.toArray(new String[answer.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the <code>IOption the reference is for</code>
|
||||
*/
|
||||
public IOption getOption() {
|
||||
// This is an operation that requires the reference to be resolved
|
||||
if (!resolved) {
|
||||
resolveReferences();
|
||||
}
|
||||
return option;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IOption#getSelectedEnum()
|
||||
*/
|
||||
public String getSelectedEnum() throws BuildException {
|
||||
// A reference to an enumerated option stores the ID of the selected enum in its value
|
||||
if (value == null) {
|
||||
// Return the default defined for the enumeration in the manifest.
|
||||
return option.getSelectedEnum();
|
||||
} else if (getValueType() == ENUMERATED) {
|
||||
// Value will contain the human-readable name of the enum
|
||||
// This is a valid ID
|
||||
return (String) value;
|
||||
} else {
|
||||
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
|
||||
|
@ -495,10 +537,12 @@ public class OptionReference implements IOption {
|
|||
* @throws BuildException
|
||||
*/
|
||||
public void setValue(String value) throws BuildException {
|
||||
if (getValueType() == STRING || getValueType() == ENUMERATED)
|
||||
// Note that we can still set the human-readable value here
|
||||
if (getValueType() == STRING || getValueType() == ENUMERATED) {
|
||||
this.value = value;
|
||||
else
|
||||
} else {
|
||||
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -535,4 +579,5 @@ public class OptionReference implements IOption {
|
|||
return super.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -146,6 +146,9 @@ public class Target extends BuildObject implements ITarget {
|
|||
// Get the make command
|
||||
makeCommand = element.getAttribute(MAKE_COMMAND);
|
||||
|
||||
// Get the make arguments
|
||||
makeArguments = element.getAttribute(MAKE_ARGS);
|
||||
|
||||
// Get the comma-separated list of valid OS
|
||||
String os = element.getAttribute(OS_LIST);
|
||||
if (os != null) {
|
||||
|
@ -213,7 +216,9 @@ public class Target extends BuildObject implements ITarget {
|
|||
isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
|
||||
|
||||
// Get the clean command
|
||||
cleanCommand = element.getAttribute(CLEAN_COMMAND);
|
||||
if (element.hasAttribute(CLEAN_COMMAND)) {
|
||||
cleanCommand = element.getAttribute(CLEAN_COMMAND);
|
||||
}
|
||||
|
||||
// Get the semicolon separated list of IDs of the error parsers
|
||||
if (element.hasAttribute(ERROR_PARSERS)) {
|
||||
|
@ -321,7 +326,7 @@ public class Target extends BuildObject implements ITarget {
|
|||
element.setAttribute(EXTENSION, extension);
|
||||
}
|
||||
element.setAttribute(IS_TEST, isTest ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
element.setAttribute(CLEAN_COMMAND, getCleanCommand());
|
||||
|
||||
if (makeCommand != null) {
|
||||
element.setAttribute(MAKE_COMMAND, makeCommand);
|
||||
}
|
||||
|
@ -426,7 +431,16 @@ public class Target extends BuildObject implements ITarget {
|
|||
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return (name == null && parent != null) ? parent.getName() : name;
|
||||
// If I am unnamed, see if I can inherit one from my parent
|
||||
if (name == null) {
|
||||
if (parent != null) {
|
||||
return parent.getName();
|
||||
} else {
|
||||
return new String(""); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -445,8 +459,8 @@ public class Target extends BuildObject implements ITarget {
|
|||
if (parent != null) {
|
||||
return parent.getTargetOSList();
|
||||
} else {
|
||||
// I have no parent and no defined list but never return null
|
||||
return new String[0];
|
||||
// I have no parent and no defined filter list
|
||||
return new String[] {"all"};
|
||||
}
|
||||
}
|
||||
return (String[]) targetOSList.toArray(new String[targetOSList.size()]);
|
||||
|
@ -736,7 +750,7 @@ public class Target extends BuildObject implements ITarget {
|
|||
while (tok.hasMoreElements()) {
|
||||
list.add(tok.nextToken());
|
||||
}
|
||||
String[] strArr = {""};
|
||||
String[] strArr = {""}; //$NON-NLS-1$
|
||||
errorParsers = (String[]) list.toArray(strArr);
|
||||
}
|
||||
} else {
|
||||
|
@ -894,4 +908,6 @@ public class Target extends BuildObject implements ITarget {
|
|||
owner = resource;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -91,7 +91,10 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
|||
return getInputExtensions().contains(extension);
|
||||
}
|
||||
|
||||
void addChildCategory(IOptionCategory category) {
|
||||
/**
|
||||
* @param category
|
||||
*/
|
||||
public void addChildCategory(IOptionCategory category) {
|
||||
if (childOptionCategories == null)
|
||||
childOptionCategories = new ArrayList();
|
||||
childOptionCategories.add(category);
|
||||
|
@ -147,19 +150,6 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
|||
return interfaceExtensions;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#createChildCategory()
|
||||
*/
|
||||
public IOptionCategory createChildCategory() {
|
||||
IOptionCategory category = new OptionCategory(this);
|
||||
|
||||
if (childOptionCategories == null)
|
||||
childOptionCategories = new ArrayList();
|
||||
childOptionCategories.add(category);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOutputFlag()
|
||||
*/
|
||||
|
@ -310,9 +300,16 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOption(java.lang.String)
|
||||
*/
|
||||
public IOption getOption(String id) {
|
||||
return getOptionById(id);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
||||
*/
|
||||
public IOption getOptionById(String id) {
|
||||
return (IOption)optionMap.get(id);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,15 @@ import org.w3c.dom.Node;
|
|||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class ToolReference implements IToolReference {
|
||||
private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
|
||||
|
||||
private String command;
|
||||
private boolean isDirty = false;
|
||||
private List optionReferences;
|
||||
private IBuildObject owner;
|
||||
private List outputExtensions;
|
||||
private String outputFlag;
|
||||
private String outputPrefix;
|
||||
protected ITool parent;
|
||||
private boolean resolved = true;
|
||||
|
||||
|
@ -50,12 +55,20 @@ public class ToolReference implements IToolReference {
|
|||
if (owner instanceof Configuration) {
|
||||
if (parent == null) {
|
||||
Target parentTarget = (Target) ((Configuration)owner).getTarget();
|
||||
parent = ((Target)parentTarget.getParent()).getTool(element.getAttribute(ID));
|
||||
try {
|
||||
parent = ((Target)parentTarget.getParent()).getTool(element.getAttribute(ID));
|
||||
} catch (NullPointerException e) {
|
||||
parent = null;
|
||||
}
|
||||
}
|
||||
((Configuration)owner).addToolReference(this);
|
||||
} else if (owner instanceof Target) {
|
||||
if (parent == null) {
|
||||
parent = ((Target)((Target)owner).getParent()).getTool(element.getAttribute(ID));
|
||||
try {
|
||||
parent = ((Target)((Target)owner).getParent()).getTool(element.getAttribute(ID));
|
||||
} catch (NullPointerException e) {
|
||||
parent = null;
|
||||
}
|
||||
}
|
||||
((Target)owner).addToolReference(this);
|
||||
}
|
||||
|
@ -65,6 +78,23 @@ public class ToolReference implements IToolReference {
|
|||
command = element.getAttribute(ITool.COMMAND);
|
||||
}
|
||||
|
||||
// Get the overridden output prefix (if any)
|
||||
if (element.hasAttribute(ITool.OUTPUT_PREFIX)) {
|
||||
outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
|
||||
}
|
||||
|
||||
// Get the output extensions the reference produces
|
||||
if (element.hasAttribute(ITool.OUTPUTS)) {
|
||||
String output = element.getAttribute(ITool.OUTPUTS);
|
||||
String[] outputs = output.split(DEFAULT_SEPARATOR);
|
||||
for (int index = outputs.length - 1; index >= 0; --index) {
|
||||
getOutputsList().add(outputs[index].trim());
|
||||
}
|
||||
}
|
||||
// Get the flag to control output
|
||||
if (element.hasAttribute(ITool.OUTPUT_FLAG))
|
||||
outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
|
||||
|
||||
NodeList configElements = element.getChildNodes();
|
||||
for (int i = 0; i < configElements.getLength(); ++i) {
|
||||
Node configElement = configElements.item(i);
|
||||
|
@ -96,7 +126,22 @@ public class ToolReference implements IToolReference {
|
|||
|
||||
// Get the overridden tool command (if any)
|
||||
command = element.getAttribute(ITool.COMMAND);
|
||||
|
||||
// Get the overridden output prefix, if any
|
||||
outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
|
||||
|
||||
// Get the overridden output extensions (if any)
|
||||
String output = element.getAttribute(ITool.OUTPUTS);
|
||||
if (output != null) {
|
||||
String[] outputs = output.split(DEFAULT_SEPARATOR);
|
||||
for (int index = outputs.length - 1; index >= 0; --index) {
|
||||
getOutputsList().add(outputs[index].trim());
|
||||
}
|
||||
}
|
||||
|
||||
// Get the flag to control output
|
||||
outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
|
||||
|
||||
IManagedConfigElement[] toolElements = element.getChildren();
|
||||
for (int m = 0; m < toolElements.length; ++m) {
|
||||
IManagedConfigElement toolElement = toolElements[m];
|
||||
|
@ -107,7 +152,7 @@ public class ToolReference implements IToolReference {
|
|||
}
|
||||
|
||||
/**
|
||||
* Created a tool reference on the fly based on an existing tool.
|
||||
* Created a tool reference on the fly based on an existing tool or tool reference.
|
||||
*
|
||||
* @param owner The <code>BuildObject</code> the receiver will be added to.
|
||||
* @param parent The <code>ITool</code>tool the reference will be based on.
|
||||
|
@ -115,6 +160,9 @@ public class ToolReference implements IToolReference {
|
|||
public ToolReference(BuildObject owner, ITool parent) {
|
||||
this.parent = parent;
|
||||
this.owner = owner;
|
||||
command = parent.getToolCommand();
|
||||
outputFlag = parent.getOutputFlag();
|
||||
outputPrefix = parent.getOutputPrefix();
|
||||
|
||||
if (owner instanceof Configuration) {
|
||||
((Configuration)owner).addToolReference(this);
|
||||
|
@ -177,6 +225,7 @@ public class ToolReference implements IToolReference {
|
|||
*/
|
||||
public void addOptionReference(OptionReference optionRef) {
|
||||
getOptionReferenceList().add(optionRef);
|
||||
isDirty = true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -193,7 +242,7 @@ public class ToolReference implements IToolReference {
|
|||
// Check if the option reference already exists
|
||||
OptionReference ref = getOptionReference(option);
|
||||
if (ref == null) {
|
||||
ref = new OptionReference(this, option);
|
||||
ref = new OptionReference(this, option);
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
@ -235,9 +284,16 @@ public class ToolReference implements IToolReference {
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOption(java.lang.String)
|
||||
*/
|
||||
public IOption getOption(String id) {
|
||||
return getOptionById(id);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
||||
*/
|
||||
public IOption getOptionById(String id) {
|
||||
IOption[] options = getOptions();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
IOption current = options[i];
|
||||
|
@ -252,7 +308,13 @@ public class ToolReference implements IToolReference {
|
|||
* @see org.eclipse.cdt.managedbuilder.core.ITool#producesFileType(java.lang.String)
|
||||
*/
|
||||
public boolean producesFileType(String outputExtension) {
|
||||
return parent.producesFileType(outputExtension);
|
||||
// Check if the reference produces this type of file
|
||||
if (!getOutputsList().contains(outputExtension)) {
|
||||
return parent.producesFileType(outputExtension);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -419,19 +481,35 @@ public class ToolReference implements IToolReference {
|
|||
public String getOutputExtension(String inputExtension) {
|
||||
return parent.getOutputExtension(inputExtension);
|
||||
}
|
||||
|
||||
private List getOutputsList() {
|
||||
if (outputExtensions == null) {
|
||||
outputExtensions = new ArrayList();
|
||||
}
|
||||
return outputExtensions;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputFlag()
|
||||
*/
|
||||
public String getOutputFlag() {
|
||||
return parent.getOutputFlag();
|
||||
if (outputFlag == null) {
|
||||
if (parent != null) {
|
||||
return parent.getOutputFlag();
|
||||
} else {
|
||||
// We never should be here
|
||||
return new String();
|
||||
}
|
||||
} else {
|
||||
return outputFlag;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputPrefix()
|
||||
*/
|
||||
public String getOutputPrefix() {
|
||||
return parent.getOutputPrefix();
|
||||
return (outputPrefix == null) ? parent.getOutputPrefix() : outputPrefix;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -472,11 +550,23 @@ public class ToolReference implements IToolReference {
|
|||
public void serialize(Document doc, Element element) {
|
||||
element.setAttribute(ITool.ID, parent.getId());
|
||||
|
||||
// Output the command if overridden
|
||||
// Output the command
|
||||
if (command != null) {
|
||||
element.setAttribute(ITool.COMMAND, command);
|
||||
element.setAttribute(ITool.COMMAND, getToolCommand());
|
||||
}
|
||||
|
||||
// Save output prefix
|
||||
if (outputPrefix != null) {
|
||||
element.setAttribute(ITool.OUTPUT_PREFIX, getOutputPrefix());
|
||||
}
|
||||
|
||||
// Save the output flag
|
||||
if (outputPrefix != null) {
|
||||
element.setAttribute(ITool.OUTPUT_FLAG, getOutputFlag());
|
||||
}
|
||||
|
||||
// Save the outputs
|
||||
|
||||
// Output the option references
|
||||
Iterator iter = getOptionReferenceList().listIterator();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -490,6 +580,14 @@ public class ToolReference implements IToolReference {
|
|||
isDirty = false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolReference#setDirty(boolean)
|
||||
*/
|
||||
public void setDirty(boolean isDirty) {
|
||||
// Override the local flag
|
||||
this.isDirty = isDirty;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolReference#setToolCommand(java.lang.String)
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) Apr 21, 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.managedbuilder.scannerconfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||
|
||||
private ManagedBuildInfo info;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ManagedBuildCPathEntryContainer(ManagedBuildInfo info) {
|
||||
super();
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
|
||||
*/
|
||||
public IPathEntry[] getPathEntries() {
|
||||
// Resolve the symbols and paths for the project
|
||||
IPath resourcePath = info.getOwner().getProjectRelativePath();
|
||||
|
||||
ArrayList entries = new ArrayList();
|
||||
entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include/c++"), true));
|
||||
entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include/c++/i686-pc-cygwin"), true));
|
||||
entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include/c++/backward"), true));
|
||||
entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include"), true));
|
||||
entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include"), true));
|
||||
entries.add(CoreModel.newIncludeEntry(resourcePath, null, new Path("/usr/include/api"), true));
|
||||
|
||||
entries.add(CoreModel.newMacroEntry(resourcePath, "__GNUC__", "3"));
|
||||
entries.add(CoreModel.newMacroEntry(resourcePath, "__GNUC_MINOR__", "3"));
|
||||
entries.add(CoreModel.newMacroEntry(resourcePath, "__GNUC_PATCHLEVEL__", "1"));
|
||||
entries.add(CoreModel.newMacroEntry(resourcePath, "__CYGWIN32__", ""));
|
||||
entries.add(CoreModel.newMacroEntry(resourcePath, "__CYGWIN__", ""));
|
||||
entries.add(CoreModel.newMacroEntry(resourcePath, "unix", ""));
|
||||
entries.add(CoreModel.newMacroEntry(resourcePath, "__unix__", ""));
|
||||
entries.add(CoreModel.newMacroEntry(resourcePath, "unix__", ""));
|
||||
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription()
|
||||
*/
|
||||
public String getDescription() {
|
||||
return "CDT Managed Build Project"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath()
|
||||
*/
|
||||
public IPath getPath() {
|
||||
return new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
|
@ -12,10 +12,19 @@ MngBuildProp.name=C/C++ Build
|
|||
MngOtherProp.name= Error Parsers
|
||||
|
||||
# Build Model Names
|
||||
TargetName.gnu=GNU
|
||||
TargetName.gnu.exe=Executable (Gnu)
|
||||
TargetName.gnu.so=Shared Library (Gnu)
|
||||
TargetName.gnu.lib=Static Library (Gnu)
|
||||
TargetName.cygw.exe=Executable (Cygwin)
|
||||
TargetName.cygw.so=Shared Library (Cygwin)
|
||||
TargetName.cygw.lib=Static Library (Cygwin)
|
||||
TargetName.mingw.exe=Executable (MinGW)
|
||||
TargetName.mingw.so=Shared Library (MinGW)
|
||||
TargetName.mingw.lib=Static Library (MinGW)
|
||||
|
||||
# No longer needed post-2.0
|
||||
TargetName.cygw=Cygwin
|
||||
TargetName.cygw.exe=Cygwin Executable
|
||||
TargetName.cygw.so=Cygwin Shared Library
|
||||
TargetName.cygw.lib=Cygwin Static Library
|
||||
TargetName.cygw.dll=Cygwin Export Library (DLL)
|
||||
TargetName.linux=Linux
|
||||
TargetName.linux.exe=Linux Executable
|
||||
|
@ -26,9 +35,11 @@ TargetName.solaris.exe=Solaris Executable
|
|||
TargetName.solaris.so=Solaris Shared Library
|
||||
TargetName.solaris.lib=Solaris Static Library
|
||||
|
||||
# Default Configuration Names
|
||||
ConfigName.Rel=Release
|
||||
ConfigName.Dbg=Debug
|
||||
|
||||
# Generic tool names
|
||||
ToolName.preprocessor = Preprocessor
|
||||
ToolName.compiler.c = C Compiler
|
||||
ToolName.compiler.cpp = C++ Compiler
|
||||
|
@ -36,6 +47,15 @@ ToolName.archiver = Archiver
|
|||
ToolName.linker.c = C Linker
|
||||
ToolName.linker.cpp = C++ Linker
|
||||
|
||||
# GNU tool names
|
||||
ToolName.compiler.gnu.c = GCC C Compiler
|
||||
ToolName.compiler.gnu.cpp = GCC C++ Compiler
|
||||
ToolName.linker.gnu.c = GCC C Linker
|
||||
ToolName.linker.gnu.cpp = GCC C++ Linker
|
||||
ToolName.archiver.gnu = GCC Archiver
|
||||
ToolName.assembler.gnu = GCC Assembler
|
||||
|
||||
# Generic Category Names
|
||||
OptionCategory.Symbols = Symbols
|
||||
OptionCategory.Preproc = Preprocessor
|
||||
OptionCategory.Dirs = Directories
|
||||
|
@ -45,7 +65,9 @@ OptionCategory.Debug=Debugging
|
|||
OptionCategory.Warn=Warnings
|
||||
OptionCategory.Misc=Miscellaneous
|
||||
OptionCategory.Libs=Libraries
|
||||
OptionCategory.Shared.Settings=Shared Library Settings
|
||||
|
||||
# Generic Option Names
|
||||
Option.Posix.PreprocOnly=Preprocess only (-E)
|
||||
Option.Posix.Nostdinc=Do not search system directories (-nostdinc)
|
||||
|
||||
|
@ -91,5 +113,9 @@ Option.Posix.Linker.Flags=Linker flags
|
|||
Option.Posix.Libs=Libraries (-l)
|
||||
Option.Posix.Libsearch=Library search path (-L)
|
||||
Option.Posix.UserObjs=Other objects
|
||||
Option.Posix.Linker.Shared=Shared (-shared)
|
||||
Option.Posix.Linker.SOName=Shared object name (-Wl,-soname,)
|
||||
Option.Posix.Linker.Implib=Import Library name (-Wl,--out-implib)
|
||||
Option.Posix.Linker.Defname=DEF file name (-Wl,--output-def,)
|
||||
|
||||
Option.Posix.Archiver.Flags=Archiver flags
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,22 +11,25 @@ package org.eclipse.cdt.managedbuilder.internal.ui;
|
|||
* IBM Rational Software - Initial API and implementation
|
||||
* **********************************************************************/
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
|
||||
|
||||
public class ManagedBuilderUIPlugin extends Plugin {
|
||||
public class ManagedBuilderUIPlugin extends AbstractUIPlugin {
|
||||
//The shared instance.
|
||||
private static ManagedBuilderUIPlugin plugin;
|
||||
//Resource bundle.
|
||||
|
@ -45,6 +48,21 @@ public class ManagedBuilderUIPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static Shell getActiveWorkbenchShell() {
|
||||
IWorkbenchWindow window = getActiveWorkbenchWindow();
|
||||
if (window != null) {
|
||||
return window.getShell();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the active workbench window or <code>null</code> if none
|
||||
*/
|
||||
public static IWorkbenchWindow getActiveWorkbenchWindow() {
|
||||
return getDefault().getWorkbench().getActiveWorkbenchWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance.
|
||||
*/
|
||||
|
@ -62,6 +80,20 @@ public class ManagedBuilderUIPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers the <code>Shell</code> associated with the active workbench, or
|
||||
* one of the windows associated with the workbench.
|
||||
* @return
|
||||
*/
|
||||
public Shell getShell() {
|
||||
if (getActiveWorkbenchShell() != null) {
|
||||
return getActiveWorkbenchShell();
|
||||
} else {
|
||||
IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
|
||||
return windows[0].getShell();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFormattedString(String key, String arg) {
|
||||
return MessageFormat.format(getResourceString(key), new String[] { arg });
|
||||
}
|
||||
|
@ -117,4 +149,52 @@ public class ManagedBuilderUIPlugin extends Plugin {
|
|||
ErrorDialog.openError(shell, title, message, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to log an exception without displaying a
|
||||
* message dialog
|
||||
* @param e
|
||||
*/
|
||||
public static void logException(Throwable e) {
|
||||
logException(e, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param exception
|
||||
* @param string
|
||||
* @param string2
|
||||
*/
|
||||
public static void logException(Throwable exception, final String title, String message) {
|
||||
if (exception instanceof InvocationTargetException) {
|
||||
exception = ((InvocationTargetException) exception).getTargetException();
|
||||
}
|
||||
IStatus status = null;
|
||||
if (exception instanceof CoreException)
|
||||
status = ((CoreException) exception).getStatus();
|
||||
else {
|
||||
if (message == null)
|
||||
message = exception.getMessage();
|
||||
if (message == null)
|
||||
message = exception.toString();
|
||||
status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, message, exception);
|
||||
}
|
||||
ResourcesPlugin.getPlugin().getLog().log(status);
|
||||
Display display;
|
||||
display = Display.getCurrent();
|
||||
if (display == null)
|
||||
display = Display.getDefault();
|
||||
final IStatus fstatus = status;
|
||||
display.asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
ErrorDialog.openError(null, title, null, fstatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static IWorkspace getWorkspace() {
|
||||
return ResourcesPlugin.getWorkspace();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.ui;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.ui.actions.UpdateManagedProjectAction;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IStartup;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ManagedMakeStartup implements IStartup {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IStartup#earlyStartup()
|
||||
*/
|
||||
public void earlyStartup() {
|
||||
// Get any 1.2 projects from the workspace
|
||||
final IProject[] projects = UpdateManagedProjectAction.getVersion12Projects();
|
||||
if (projects.length > 0) {
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
// Start the process that will update the 1.2 projects
|
||||
public void run() {
|
||||
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
|
||||
for (int index = projects.length - 1; index >= 0; --index) {
|
||||
IProject project = projects[index];
|
||||
boolean shouldUpdate = MessageDialog.openQuestion(shell,
|
||||
ManagedBuilderUIPlugin.getResourceString("ManagedBuilderStartup.update.12x.title"), //$NON-NLS-1$
|
||||
ManagedBuilderUIPlugin.getFormattedString("ManagedBuilderStartup.update.12x.message", new String[]{project.getName()})); //$NON-NLS-1$
|
||||
// Go for it
|
||||
if (shouldUpdate) {
|
||||
ProgressMonitorDialog pd = new ProgressMonitorDialog(shell);
|
||||
UpdateManagedProjectAction.run(false, pd, project);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,8 +3,18 @@
|
|||
# All Rights Reserved.
|
||||
#########################################
|
||||
|
||||
# ------- NewProjectCreationPluginPage-------
|
||||
# ------- 1.2 Project Update Messages -------
|
||||
ManagedBuilderStartup.update.12x.title=Update Managed Builder Project
|
||||
ManagedBuilderStartup.update.12x.message=The project {0} has been detected in your workspace.\n Its build settings are stored in a format that is no longer supported.\n Would you like to convert them now?
|
||||
ManagedBuilderStartup.update.exception.error=Error
|
||||
ManagedBuilderStartup.update.exception.message=Error updating project {0}
|
||||
ManagedBuildConvert.12x.monitor.message.project=Updating build settings for project {0}
|
||||
ManagedBuildConvert.12x.monitor.message.backup=Backing up the settings file for {0}
|
||||
ManagedBuildConvert.12x.warning.title=Backup File Already Exists
|
||||
ManagedBuildConvert.12x.warning.message=A backup file already exists for the project {0}.\n Shall I try to convert the project anyway?
|
||||
ManagedBuildConvert.12x.cancelled.message=The update operation has been cancelled.\n The build system will not be able to read the project settings until you update the project.
|
||||
|
||||
# ------- NewProjectCreationPluginPage-------
|
||||
MngMakeProjectWizard.op_error=Managed Make Error
|
||||
MngMakeProjectWizard.title=Managed Make Project
|
||||
MngMakeProjectWizard.description=Create a new Managed Make project.
|
||||
|
@ -28,8 +38,10 @@ MngCCWizardSettings.description=Define the Managed Make C++ build settings.
|
|||
# -- Strings for the platform selection page --
|
||||
MngMakeProjectWizard.config.title=Select a Target
|
||||
MngMakeProjectWizard.config.desc=Select the platform and configurations you wish to deploy on
|
||||
PlatformBlock.label.platform=Platform:
|
||||
PlatformBlock.tip.platform=Select the target of the build goal
|
||||
PlatformBlock.label.platform=Build Target:
|
||||
PlatformBlock.label.configs=Configurations:
|
||||
PlatformBlock.label.showall=Show All Targets
|
||||
|
||||
# -- Strings for the additional options tab
|
||||
MngMakeProjectWizard.options.title=Additional Project Settings
|
||||
|
@ -50,6 +62,7 @@ BuildPropertyPage.tip.addconf=Add configurations for the platform
|
|||
BuildPropertyPage.tip.remconf=Remove configurations for the platform
|
||||
BuildPropertyPage.manage.title=Manage
|
||||
BuildPropertyPage.error.Unknown_tree_element=Unknown type of element in tree of type {0}
|
||||
BuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be upgraded.
|
||||
|
||||
# ----------- Entry Dialog -----------
|
||||
BrowseEntryDialog.error.Folder_name_invalid = Folder name invalid
|
||||
|
|
|
@ -0,0 +1,577 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.actions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Random;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.FactoryConfigurationError;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolReference;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegate {
|
||||
|
||||
|
||||
private static final String ID_CYGWIN = "cygwin"; //$NON-NLS-1$
|
||||
private static final String ID_DEBUG = "debug"; //$NON-NLS-1$
|
||||
private static final String ID_DIRS = "dirs"; //$NON-NLS-1$
|
||||
private static final String ID_EXE = "exe"; //$NON-NLS-1$
|
||||
private static final String ID_EXEC = "exec"; //$NON-NLS-1$
|
||||
private static final String ID_GENERAL = "general"; //$NON-NLS-1$
|
||||
private static final String ID_GNU = "gnu"; //$NON-NLS-1$
|
||||
private static final String ID_INCPATHS = "incpaths"; //$NON-NLS-1$
|
||||
private static final String ID_INCLUDE = "include"; //$NON-NLS-1$
|
||||
private static final String ID_LINUX = "linux"; //$NON-NLS-1$
|
||||
private static final String ID_OPTION = "option"; //$NON-NLS-1$
|
||||
private static final String ID_OPTIONS = "options"; //$NON-NLS-1$
|
||||
private static final String ID_PATHS = "paths"; //$NON-NLS-1$
|
||||
private static final String ID_PREPROC = "preprocessor"; //$NON-NLS-1$
|
||||
private static final String ID_RELEASE = "release"; //$NON-NLS-1$
|
||||
private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
|
||||
private static final String ID_SHARED = "so"; //$NON-NLS-1$
|
||||
private static final String ID_SOLARIS = "solaris"; //$NON-NLS-1$
|
||||
private static final String ID_STATIC = "lib"; //$NON-NLS-1$
|
||||
private static final String NEW_CONFIG_ROOT = "cdt.managedbuild.config.gnu"; //$NON-NLS-1$
|
||||
private static final String NEW_CYGWIN_TARGET_ROOT = "cdt.managedbuild.target.gnu.cygwin"; //$NON-NLS-1$
|
||||
private static final String NEW_POSIX_TARGET_ROOT = "cdt.managedbuild.target.gnu"; //$NON-NLS-1$
|
||||
private static final String NEW_TOOL_ROOT = "cdt.managedbuild.tool.gnu"; //$NON-NLS-1$
|
||||
private static final String TOOL_LANG_BOTH = "both"; //$NON-NLS-1$
|
||||
private static final String TOOL_LANG_C = "c"; //$NON-NLS-1$
|
||||
private static final String TOOL_LANG_CPP = "cpp"; //$NON-NLS-1$
|
||||
private static final String TOOL_NAME_AR = "ar"; //$NON-NLS-1$
|
||||
private static final String TOOL_NAME_ARCHIVER = "archiver"; //$NON-NLS-1$
|
||||
private static final String TOOL_NAME_COMPILER = "compiler"; //$NON-NLS-1$
|
||||
private static final String TOOL_NAME_LIB = "lib"; //$NON-NLS-1$
|
||||
private static final String TOOL_NAME_LINK = "link"; //$NON-NLS-1$
|
||||
private static final String TOOL_NAME_LINKER = "linker"; //$NON-NLS-1$
|
||||
private static final String TOOL_NAME_SOLINK = "solink"; //$NON-NLS-1$
|
||||
private static final int TOOL_TYPE_COMPILER = 0;
|
||||
private static final int TOOL_TYPE_LINKER = 1;
|
||||
private static final int TOOL_TYPE_ARCHIVER = 2;
|
||||
private static final int TYPE_EXE = 0;
|
||||
private static final int TYPE_SHARED = 1;
|
||||
private static final int TYPE_STATIC = 2;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Create a back-up file containing the pre-2.0 project settings.
|
||||
*
|
||||
* @param settingsFile
|
||||
* @param monitor
|
||||
* @param project
|
||||
* @throws CoreException
|
||||
*/
|
||||
protected static void backupFile(IFile settingsFile, IProgressMonitor monitor, IProject project) throws CoreException {
|
||||
// Make a back-up of the settings file
|
||||
String newName = settingsFile.getName() + "_12backup"; //$NON-NLS-1$
|
||||
IContainer destFolder = (IContainer)project;
|
||||
IFile backupFile = destFolder.getFile(new Path(newName));
|
||||
if (backupFile.exists()) {
|
||||
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
|
||||
boolean shouldUpdate = MessageDialog.openQuestion(shell,
|
||||
ManagedBuilderUIPlugin.getResourceString("ManagedBuildConvert.12x.warning.title"), //$NON-NLS-1$
|
||||
ManagedBuilderUIPlugin.getFormattedString("ManagedBuildConvert.12x.warning.message", new String[]{project.getName()})); //$NON-NLS-1$
|
||||
if (shouldUpdate) {
|
||||
backupFile.delete(true, monitor);
|
||||
} else {
|
||||
monitor.setCanceled(true);
|
||||
throw new OperationCanceledException(ManagedBuilderUIPlugin.getFormattedString("ManagedBuildConvert.12x.cancelled.message", new String[]{project.getName()}));
|
||||
}
|
||||
}
|
||||
settingsFile.copy(backupFile.getFullPath(), true, monitor); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected static void convertConfiguration(ITarget newTarget, ITarget newParent, Element oldConfig, IProgressMonitor monitor) {
|
||||
IConfiguration newParentConfig = null;
|
||||
IConfiguration newConfig = null;
|
||||
boolean cygwin = false;
|
||||
boolean debug = false;
|
||||
int type = -1;
|
||||
|
||||
// Figure out what the original parent of the config is
|
||||
String parentId = oldConfig.getAttribute(IConfiguration.PARENT);
|
||||
StringTokenizer idTokens = new StringTokenizer(parentId, ID_SEPARATOR);
|
||||
while (idTokens.hasMoreTokens()) {
|
||||
String id = idTokens.nextToken();
|
||||
if (id.equalsIgnoreCase(ID_CYGWIN)) {
|
||||
cygwin = true;
|
||||
} else if(id.equalsIgnoreCase(ID_EXEC)) {
|
||||
type = TYPE_EXE;
|
||||
} else if(id.equalsIgnoreCase(ID_SHARED)) {
|
||||
type = TYPE_SHARED;
|
||||
} else if (id.equalsIgnoreCase(ID_STATIC)) {
|
||||
type = TYPE_STATIC;
|
||||
} else if (id.equalsIgnoreCase(ID_DEBUG)) {
|
||||
debug = true;
|
||||
}
|
||||
}
|
||||
String defId = NEW_CONFIG_ROOT + ID_SEPARATOR;
|
||||
if (cygwin) defId += ID_CYGWIN + ID_SEPARATOR;
|
||||
switch (type) {
|
||||
case TYPE_EXE:
|
||||
defId += ID_EXE;
|
||||
break;
|
||||
case TYPE_SHARED :
|
||||
defId += ID_SHARED;
|
||||
break;
|
||||
case TYPE_STATIC :
|
||||
defId += ID_STATIC;
|
||||
break;
|
||||
}
|
||||
defId += ID_SEPARATOR + (debug ? "debug" : "release");
|
||||
newParentConfig = newParent.getConfiguration(defId);
|
||||
if (newParentConfig == null) {
|
||||
// Create a default gnu exe release or debug
|
||||
}
|
||||
// Generate a random number for the new config id
|
||||
Random rand = new Random();
|
||||
rand.setSeed(System.currentTimeMillis());
|
||||
int randomElement = rand.nextInt();
|
||||
if (randomElement < 0) {
|
||||
randomElement *= -1;
|
||||
}
|
||||
// Create the new configuration
|
||||
newConfig = newTarget.createConfiguration(newParentConfig, defId + ID_SEPARATOR + randomElement);
|
||||
|
||||
// Convert the tool references
|
||||
NodeList toolRefNodes = oldConfig.getElementsByTagName(IConfiguration.TOOLREF_ELEMENT_NAME);
|
||||
for (int refIndex = 0; refIndex < toolRefNodes.getLength(); ++refIndex) {
|
||||
convertToolRef(newConfig, (Element) toolRefNodes.item(refIndex), monitor);
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
protected static void convertOptionRef(IConfiguration newConfig, ITool newTool, Element optRef) {
|
||||
String optId = optRef.getAttribute(IOption.ID);
|
||||
if (optId == null) return;
|
||||
String[] idTokens = optId.split("\\."); //$NON-NLS-1$
|
||||
|
||||
// New ID will be in for gnu.[compiler|link|lib].[c|c++|both].option.{1.2_component}
|
||||
Vector newIdVector = new Vector(idTokens.length + 2);
|
||||
|
||||
// We can ignore the first element of the old IDs since it is just [cygwin|linux|solaris]
|
||||
for (int index = 1; index < idTokens.length; ++index) {
|
||||
newIdVector.add(idTokens[index]);
|
||||
}
|
||||
|
||||
// In the case of some Cygwin C++ tools, the old ID will be missing gnu
|
||||
if (!((String)newIdVector.firstElement()).equals(ID_GNU)) {
|
||||
newIdVector.add(0, ID_GNU);
|
||||
}
|
||||
|
||||
// In some old IDs the language specifier is missing for librarian and C++ options
|
||||
String langToken = (String)newIdVector.get(1);
|
||||
if(!langToken.equals(TOOL_LANG_C)) {
|
||||
// In the case of the librarian the language must b set to both
|
||||
if (langToken.equals(TOOL_NAME_LIB) || langToken.equals(TOOL_NAME_AR)) {
|
||||
newIdVector.add(1, TOOL_LANG_BOTH);
|
||||
} else {
|
||||
newIdVector.add(1, TOOL_LANG_CPP);
|
||||
}
|
||||
}
|
||||
|
||||
// Standardize the next token to compiler, link, or lib
|
||||
String toolToken = (String)newIdVector.get(2);
|
||||
if (toolToken.equals(ID_PREPROC)) {
|
||||
// Some compiler preprocessor options are missing this
|
||||
newIdVector.add(2, TOOL_NAME_COMPILER);
|
||||
} else if (toolToken.equals(TOOL_NAME_LINKER) || toolToken.equals(TOOL_NAME_SOLINK)) {
|
||||
// Some linker options have linker or solink as the toolname
|
||||
newIdVector.remove(2);
|
||||
newIdVector.add(2, TOOL_NAME_LINK);
|
||||
} else if (toolToken.equals(TOOL_NAME_AR)) {
|
||||
// The cygwin librarian uses ar
|
||||
newIdVector.remove(2);
|
||||
newIdVector.add(2, TOOL_NAME_LIB);
|
||||
}
|
||||
|
||||
// Add in the option tag
|
||||
String optionToken = (String)newIdVector.get(3);
|
||||
if (optionToken.equals(ID_OPTIONS)) {
|
||||
// Some old-style options had "options" in the id
|
||||
newIdVector.remove(3);
|
||||
}
|
||||
newIdVector.add(3, ID_OPTION);
|
||||
|
||||
// Convert any lingering "incpaths" to "include.paths"
|
||||
String badToken = (String) newIdVector.lastElement();
|
||||
if (badToken.equals(ID_INCPATHS)) {
|
||||
newIdVector.addElement(ID_INCLUDE);
|
||||
newIdVector.addElement(ID_PATHS);
|
||||
}
|
||||
|
||||
// Edit out the "general" or "dirs" categories that may be in some older IDs
|
||||
int generalIndex = newIdVector.indexOf(ID_GENERAL);
|
||||
if (generalIndex != -1) {
|
||||
newIdVector.remove(generalIndex);
|
||||
}
|
||||
int dirIndex = newIdVector.indexOf(ID_DIRS);
|
||||
if (dirIndex != -1) {
|
||||
newIdVector.remove(dirIndex);
|
||||
}
|
||||
|
||||
// Construct the new ID
|
||||
String newOptionId = new String();
|
||||
for (int rebuildIndex = 0; rebuildIndex < newIdVector.size(); ++ rebuildIndex) {
|
||||
String token = (String) newIdVector.get(rebuildIndex);
|
||||
newOptionId += token;
|
||||
if (rebuildIndex < newIdVector.size() - 1) {
|
||||
newOptionId += ID_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the option from the new tool
|
||||
IOption newOpt = newTool.getOptionById(newOptionId);
|
||||
if (newOpt == null) {
|
||||
// TODO flag warning condition to user
|
||||
return;
|
||||
}
|
||||
try {
|
||||
switch (newOpt.getValueType()) {
|
||||
case IOption.BOOLEAN:
|
||||
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
|
||||
newConfig.setOption(newOpt, bool.booleanValue());
|
||||
break;
|
||||
case IOption.STRING:
|
||||
case IOption.ENUMERATED:
|
||||
// This is going to be the human readable form of the enumerated value
|
||||
String name = (String) optRef.getAttribute(IOption.DEFAULT_VALUE);
|
||||
// Convert it to the ID
|
||||
String idValue = newOpt.getEnumeratedId(name);
|
||||
newConfig.setOption(newOpt, idValue != null ? idValue : name);
|
||||
break;
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.INCLUDE_PATH:
|
||||
case IOption.PREPROCESSOR_SYMBOLS:
|
||||
case IOption.LIBRARIES:
|
||||
case IOption.OBJECTS:
|
||||
Vector values = new Vector();
|
||||
NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
|
||||
for (int i = 0; i < nodes.getLength(); ++i) {
|
||||
Node node = nodes.item(i);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
|
||||
if (!isBuiltIn.booleanValue()) {
|
||||
values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
|
||||
}
|
||||
}
|
||||
}
|
||||
newConfig.setOption(newOpt, (String[])values.toArray(new String[values.size()]));
|
||||
break;
|
||||
}
|
||||
} catch (BuildException e) {
|
||||
// TODO flag error to user
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
protected static ITarget convertTarget(IProject project, Element oldTarget, IProgressMonitor monitor) {
|
||||
// What we want to create
|
||||
ITarget newTarget = null;
|
||||
ITarget newParent = null;
|
||||
// The type of target we are converting from/to
|
||||
int type = -1;
|
||||
// Use the Cygwin or generic target form
|
||||
boolean posix = false;
|
||||
|
||||
// Get the parent
|
||||
String id = oldTarget.getAttribute(ITarget.PARENT);
|
||||
|
||||
// Figure out the new target definition to use for that type
|
||||
StringTokenizer idTokens = new StringTokenizer(id, ID_SEPARATOR);
|
||||
while (idTokens.hasMoreTokens()) {
|
||||
String token = idTokens.nextToken();
|
||||
if (token.equals(ID_LINUX) || token.equals(ID_SOLARIS)) {
|
||||
posix = true;
|
||||
} else if (token.equalsIgnoreCase(ID_EXEC)){
|
||||
type = TYPE_EXE;
|
||||
} else if (token.equalsIgnoreCase(ID_SHARED)){
|
||||
type = TYPE_SHARED;
|
||||
} else if (token.equalsIgnoreCase(ID_SHARED)){
|
||||
type = TYPE_SHARED;
|
||||
}
|
||||
}
|
||||
// Create a target based on the new target type
|
||||
String defID = (posix ? NEW_POSIX_TARGET_ROOT : NEW_CYGWIN_TARGET_ROOT) + ID_SEPARATOR;
|
||||
switch (type) {
|
||||
case TYPE_EXE :
|
||||
defID += ID_EXE;
|
||||
break;
|
||||
case TYPE_SHARED :
|
||||
defID += ID_SHARED;
|
||||
break;
|
||||
case TYPE_STATIC :
|
||||
defID += ID_STATIC;
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the new target definitions we need for the conversion
|
||||
newParent = ManagedBuildManager.getTarget(project, defID);
|
||||
if (newParent == null) {
|
||||
// Return null and let the caller deal with the error reporting
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// Create a new target based on the new parent
|
||||
newTarget = ManagedBuildManager.createTarget(project, newParent);
|
||||
|
||||
// Create new configurations
|
||||
NodeList configNodes = oldTarget.getElementsByTagName(IConfiguration.CONFIGURATION_ELEMENT_NAME);
|
||||
for (int configIndex = 0; configIndex < configNodes.getLength(); ++configIndex) {
|
||||
convertConfiguration(newTarget, newParent, (Element) configNodes.item(configIndex), monitor);
|
||||
}
|
||||
} catch (BuildException e) {
|
||||
ManagedBuilderUIPlugin.logException(e);
|
||||
}
|
||||
|
||||
monitor.worked(1);
|
||||
return newTarget;
|
||||
}
|
||||
|
||||
protected static void convertToolRef(IConfiguration newConfig, Element oldToolRef, IProgressMonitor monitor) {
|
||||
String oldToolId = oldToolRef.getAttribute(IToolReference.ID);
|
||||
// All known tools have id NEW_TOOL_ROOT.[c|cpp].[compiler|linker|archiver]
|
||||
String newToolId = NEW_TOOL_ROOT;
|
||||
boolean cppFlag = true;
|
||||
int toolType = -1;
|
||||
|
||||
// Figure out what kind of tool the ref pointed to
|
||||
StringTokenizer idTokens = new StringTokenizer(oldToolId, ID_SEPARATOR);
|
||||
while (idTokens.hasMoreTokens()) {
|
||||
String token = idTokens.nextToken();
|
||||
if(token.equals(TOOL_LANG_C)) {
|
||||
cppFlag = false;
|
||||
} else if (token.equalsIgnoreCase(TOOL_NAME_COMPILER)) {
|
||||
toolType = TOOL_TYPE_COMPILER;
|
||||
} else if (token.equalsIgnoreCase(TOOL_NAME_AR)) {
|
||||
toolType = TOOL_TYPE_ARCHIVER;
|
||||
} else if (token.equalsIgnoreCase(TOOL_NAME_LIB)) {
|
||||
toolType = TOOL_TYPE_ARCHIVER;
|
||||
} else if (token.equalsIgnoreCase(TOOL_NAME_LINK)) {
|
||||
toolType = TOOL_TYPE_LINKER;
|
||||
} else if (token.equalsIgnoreCase(TOOL_NAME_SOLINK)) {
|
||||
toolType = TOOL_TYPE_LINKER;
|
||||
}
|
||||
}
|
||||
|
||||
// Now complete the new tool id
|
||||
newToolId += ID_SEPARATOR + (cppFlag ? "cpp" : "c") + ID_SEPARATOR;
|
||||
switch (toolType) {
|
||||
case TOOL_TYPE_COMPILER:
|
||||
newToolId += TOOL_NAME_COMPILER;
|
||||
break;
|
||||
case TOOL_TYPE_LINKER:
|
||||
newToolId += TOOL_NAME_LINKER;
|
||||
break;
|
||||
case TOOL_TYPE_ARCHIVER:
|
||||
newToolId += TOOL_NAME_ARCHIVER;
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the new tool out of the configuration
|
||||
ITool newTool = newConfig.getToolById(newToolId);
|
||||
// Check that this is not null
|
||||
|
||||
// The ref may or may not contain overridden options
|
||||
NodeList optRefs = oldToolRef.getElementsByTagName(ITool.OPTION_REF);
|
||||
for (int refIndex = optRefs.getLength() - 1; refIndex >= 0; --refIndex) {
|
||||
convertOptionRef(newConfig, newTool, (Element) optRefs.item(refIndex));
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param monitor the monitor to allow users to cancel the long-running operation
|
||||
* @param project the <code>IProject</code> that needs to be upgraded
|
||||
* @throws CoreException
|
||||
*/
|
||||
protected static void doProjectUpdate(IProgressMonitor monitor, IProject project) throws CoreException {
|
||||
String[] projectName = new String[]{project.getName()};
|
||||
IFile settingsFile = project.getFile(ManagedBuildManager.SETTINGS_FILE_NAME);
|
||||
if (!settingsFile.exists()) {
|
||||
monitor.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Backup the file
|
||||
monitor.beginTask(ManagedBuilderUIPlugin.getFormattedString("ManagedBuildConvert.12x.monitor.message.backup", projectName), 1); //$NON-NLS-1$
|
||||
backupFile(settingsFile, monitor, project);
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
|
||||
//Now convert each target to the new format
|
||||
try {
|
||||
// Load the old build file
|
||||
InputStream stream = settingsFile.getContents();
|
||||
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document document = parser.parse(stream);
|
||||
|
||||
// Clone the target based on the proper target definition
|
||||
NodeList targetNodes = document.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME);
|
||||
// This is a guess, but typically the project has 1 target, 2 configs, and 6 tool defs
|
||||
int listSize = targetNodes.getLength();
|
||||
monitor.beginTask(ManagedBuilderUIPlugin.getFormattedString("ManagedBuildConvert.12x.monitor.message.project", projectName), listSize * 9); //$NON-NLS-1$
|
||||
for (int targIndex = 0; targIndex < listSize; ++targIndex) {
|
||||
Element oldTarget = (Element) targetNodes.item(targIndex);
|
||||
String oldTargetId = oldTarget.getAttribute(ITarget.ID);
|
||||
ITarget newTarget = convertTarget(project, oldTarget, monitor);
|
||||
|
||||
// Remove the old target
|
||||
if (newTarget != null) {
|
||||
info.removeTarget(oldTargetId);
|
||||
monitor.worked(9);
|
||||
}
|
||||
}
|
||||
// Upgrade the version
|
||||
((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString());
|
||||
} catch (ParserConfigurationException e) {
|
||||
ManagedBuilderUIPlugin.log(e);
|
||||
} catch (FactoryConfigurationError e) {
|
||||
ManagedBuilderUIPlugin.log(e);
|
||||
} catch (SAXException e) {
|
||||
ManagedBuilderUIPlugin.log(e);
|
||||
} catch (IOException e) {
|
||||
ManagedBuilderUIPlugin.log(e);
|
||||
} finally {
|
||||
ManagedBuildManager.saveBuildInfo(project, false);
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which projects in the workspace are still using
|
||||
* the settings format defined in CDT 1.2.x.
|
||||
*
|
||||
* @return an array of <code>IProject</code> that need to have their
|
||||
* project settings updated to the CDT 2.0 format
|
||||
*/
|
||||
public static IProject[] getVersion12Projects() {
|
||||
IProject[] projects = ManagedBuilderUIPlugin.getWorkspace().getRoot().getProjects();
|
||||
Vector result = new Vector();
|
||||
for (int index = projects.length - 1; index >=0 ; --index) {
|
||||
IProjectDescription description;
|
||||
try {
|
||||
description = projects[index].getDescription();
|
||||
} catch (CoreException e) {
|
||||
ManagedBuilderUIPlugin.log(e);
|
||||
continue;
|
||||
}
|
||||
// Make sure it has a managed nature
|
||||
if (description == null || !description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
|
||||
continue;
|
||||
}
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[index]);
|
||||
if (info != null && info.getVersion()== null) {
|
||||
// This is a pre-2.0 file (no version info)
|
||||
result.add(projects[index]);
|
||||
}
|
||||
}
|
||||
|
||||
return (IProject[]) result.toArray(new IProject[result.size()]);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
public void init(IWorkbenchWindow window) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void run(IAction action) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
static public void run(boolean fork, IRunnableContext context, final IProject project) {
|
||||
try {
|
||||
context.run(fork, true, new IRunnableWithProgress() {
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
try {
|
||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
doProjectUpdate(monitor, project);
|
||||
}
|
||||
};
|
||||
ManagedBuilderUIPlugin.getWorkspace().run(runnable, monitor);
|
||||
} catch (CoreException e) {
|
||||
throw new InvocationTargetException(e);
|
||||
} catch (OperationCanceledException e) {
|
||||
throw new InterruptedException(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException e) {
|
||||
return;
|
||||
} catch (InvocationTargetException e) {
|
||||
ManagedBuilderUIPlugin.logException(e,
|
||||
ManagedBuilderUIPlugin.getResourceString("ManagedBuilderStartup.update.exception.error"), //$NON-NLS-1$
|
||||
ManagedBuilderUIPlugin.getFormattedString("ManagedBuilderStartup.update.exception.message", new String[]{project.getName()})); //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
||||
*/
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -169,14 +169,25 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
}
|
||||
|
||||
protected Control createContents(Composite parent) {
|
||||
// Create the container we return to the property page editor
|
||||
Composite composite = new Composite(parent, SWT.NULL);
|
||||
composite.setFont(parent.getFont());
|
||||
composite.setLayout(new GridLayout(1, true));
|
||||
GridData gd;
|
||||
|
||||
// Initialize the key data
|
||||
targets = ManagedBuildManager.getTargets(getProject());
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject(), true);
|
||||
if (info.getVersion() == null) {
|
||||
// Display a message page instead of the properties control
|
||||
final Label invalidInfo = new Label(composite, SWT.LEFT);
|
||||
invalidInfo.setFont(composite.getFont());
|
||||
invalidInfo.setText(ManagedBuilderUIPlugin.getResourceString("BuildPropertyPage.error.version_low")); //$NON-NLS-1$
|
||||
invalidInfo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_CENTER, true, true));
|
||||
return composite;
|
||||
}
|
||||
targets = ManagedBuildManager.getTargets(getProject());
|
||||
ITarget defaultTarget = info.getDefaultTarget();
|
||||
|
||||
// Create the container we return to the property page editor
|
||||
Composite composite = ControlFactory.createComposite(parent, 1);
|
||||
GridData gd;
|
||||
|
||||
// Add a config selection area
|
||||
Group configGroup = ControlFactory.createGroup(composite, ManagedBuilderUIPlugin.getResourceString(ACTIVE_LABEL), 1);
|
||||
|
@ -456,6 +467,10 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
* @return
|
||||
*/
|
||||
private List getPagesForConfig() {
|
||||
// Make sure that something was selected
|
||||
if (selectedConfiguration == null) {
|
||||
return null;
|
||||
}
|
||||
List pages = (List) configToPageListMap.get(selectedConfiguration.getId());
|
||||
if (pages == null) {
|
||||
pages = new ArrayList();
|
||||
|
@ -858,6 +873,11 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
public boolean performOk() {
|
||||
// Force each settings page to update
|
||||
List pages = getPagesForConfig();
|
||||
// Make sure we have something to work on
|
||||
if (pages == null) {
|
||||
// Nothing to do
|
||||
return true;
|
||||
}
|
||||
ListIterator iter = pages.listIterator();
|
||||
while (iter.hasNext()) {
|
||||
BuildSettingsPage page = (BuildSettingsPage) iter.next();
|
||||
|
|
|
@ -75,6 +75,7 @@ public class FileListControl {
|
|||
super.createButtonsForButtonBar(parent);
|
||||
if (type != IOption.BROWSE_NONE) {
|
||||
final Button browse = createButton(parent, 3, ManagedBuilderUIPlugin.getResourceString(BROWSE), true);
|
||||
getOkButton().setFocus();
|
||||
browse.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent ev) {
|
||||
String currentName;
|
||||
|
@ -89,6 +90,8 @@ public class FileListControl {
|
|||
result = dialog.open();
|
||||
if(result != null) {
|
||||
getText().setText(result);
|
||||
// Give the OK button focus
|
||||
getOkButton().setFocus();
|
||||
}
|
||||
break;
|
||||
case IOption.BROWSE_FILE:
|
||||
|
@ -100,6 +103,8 @@ public class FileListControl {
|
|||
result = browseDialog.open();
|
||||
if (result != null) {
|
||||
getText().setText(result);
|
||||
// Give the OK button focus
|
||||
getOkButton().setFocus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -21,16 +21,21 @@ import org.eclipse.cdt.managedbuilder.core.ITarget;
|
|||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
|
||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
|
||||
import org.eclipse.core.boot.BootLoader;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.TableLayout;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
|
@ -38,7 +43,6 @@ import org.eclipse.swt.widgets.Label;
|
|||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
|
||||
|
||||
public class CProjectPlatformPage extends WizardPage {
|
||||
/*
|
||||
|
@ -55,12 +59,14 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
*/
|
||||
protected Combo platformSelection;
|
||||
protected CheckboxTableViewer tableViewer;
|
||||
protected Button showAll;
|
||||
private static final String PREFIX = "PlatformBlock"; //$NON-NLS-1$
|
||||
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
||||
private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
|
||||
private static final String PLATFORM_TIP = TIP + ".platform"; //$NON-NLS-1$
|
||||
private static final String PLATFORM_LABEL = LABEL + ".platform"; //$NON-NLS-1$
|
||||
private static final String TARGET_TIP = TIP + ".platform"; //$NON-NLS-1$
|
||||
private static final String TARGET_LABEL = LABEL + ".platform"; //$NON-NLS-1$
|
||||
private static final String CONFIG_LABEL = LABEL + ".configs"; //$NON-NLS-1$
|
||||
private static final String SHOWALL_LABEL = LABEL + ".showall"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -70,7 +76,6 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
public CProjectPlatformPage(String pageName, NewManagedProjectWizard parentWizard) {
|
||||
super(pageName);
|
||||
setPageComplete(false);
|
||||
populateTargets();
|
||||
selectedTarget = null;
|
||||
selectedConfigurations = new ArrayList(0);
|
||||
this.parentWizard = parentWizard;
|
||||
|
@ -83,36 +88,21 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
return validatePage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
// Create the composite control for the tab
|
||||
Composite composite = ControlFactory.createComposite(parent, 6);
|
||||
|
||||
// Create the platform selection label and combo widgets
|
||||
Label platformLabel = ControlFactory.createLabel(composite, ManagedBuilderUIPlugin.getResourceString(PLATFORM_LABEL));
|
||||
platformLabel.setLayoutData(new GridData());
|
||||
|
||||
platformSelection = ControlFactory.createSelectCombo(composite, targetNames, null);
|
||||
// platformSelection.setToolTipText(ManagedBuilderUIPlugin.getResourceString(PLATFORM_TIP));
|
||||
platformSelection.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
handleTargetSelection();
|
||||
}
|
||||
});
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalSpan = 5;
|
||||
platformSelection.setLayoutData(gd);
|
||||
private void createConfigSelectionGroup (Composite parent) {
|
||||
// Create the group composite
|
||||
Composite composite = new Composite(parent, SWT.NULL);
|
||||
composite.setFont(parent.getFont());
|
||||
composite.setLayout(new GridLayout());
|
||||
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
// Create a check box table of valid configurations
|
||||
Label configLabel = ControlFactory.createLabel(composite, ManagedBuilderUIPlugin.getResourceString(CONFIG_LABEL));
|
||||
configLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
final Label configLabel = new Label(composite, SWT.LEFT);
|
||||
configLabel.setFont(composite.getFont());
|
||||
configLabel.setText(ManagedBuilderUIPlugin.getResourceString(CONFIG_LABEL));
|
||||
|
||||
Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.MULTI
|
||||
| SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
gd = new GridData(GridData.FILL_BOTH);
|
||||
gd.horizontalSpan = 6;
|
||||
table.setLayoutData(gd);
|
||||
table.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
table.setHeaderVisible(true);
|
||||
table.setLinesVisible(false);
|
||||
|
||||
|
@ -131,12 +121,31 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
handleConfigurationSelectionChange();
|
||||
}
|
||||
});
|
||||
|
||||
// Select the first target in the list
|
||||
handleTargetSelection();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
// Create the composite control for the tab
|
||||
Composite composite = new Composite(parent, SWT.NULL);
|
||||
composite.setFont(parent.getFont());
|
||||
composite.setLayout(new GridLayout());
|
||||
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
// Setup the help information
|
||||
WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_PLATFORM_HELP);
|
||||
|
||||
// Create the widgets
|
||||
createTargetSelectGroup(composite);
|
||||
createConfigSelectionGroup(composite);
|
||||
createShowAllGroup(composite);
|
||||
|
||||
// Select the first target in the list
|
||||
populateTargets();
|
||||
platformSelection.select(0);
|
||||
handleTargetSelection();
|
||||
|
||||
// Do the nasty
|
||||
setErrorMessage(null);
|
||||
|
@ -144,6 +153,65 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
setControl(composite);
|
||||
}
|
||||
|
||||
private void createShowAllGroup(Composite parent) {
|
||||
// Create the group composite
|
||||
Composite composite = new Composite(parent, SWT.NULL);
|
||||
composite.setFont(parent.getFont());
|
||||
composite.setLayout(new GridLayout());
|
||||
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
showAll = new Button(composite, SWT.CHECK | SWT.LEFT);
|
||||
showAll.setFont(composite.getFont());
|
||||
showAll.setText(ManagedBuilderUIPlugin.getResourceString(SHOWALL_LABEL));
|
||||
showAll.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
populateTargets();
|
||||
platformSelection.select(0);
|
||||
handleTargetSelection();
|
||||
}
|
||||
});
|
||||
showAll.addDisposeListener(new DisposeListener() {
|
||||
public void widgetDisposed(DisposeEvent event) {
|
||||
showAll = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createTargetSelectGroup(Composite parent) {
|
||||
// Create the group composite
|
||||
Composite composite = new Composite(parent, SWT.NULL);
|
||||
composite.setFont(parent.getFont());
|
||||
composite.setLayout(new GridLayout(2, false));
|
||||
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
// Create the platform selection label and combo widgets
|
||||
final Label platformLabel = new Label(composite, SWT.LEFT);
|
||||
platformLabel.setFont(composite.getFont());
|
||||
platformLabel.setText(ManagedBuilderUIPlugin.getResourceString(TARGET_LABEL));
|
||||
|
||||
platformSelection = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
|
||||
platformSelection.setFont(composite.getFont());
|
||||
platformSelection.setToolTipText(ManagedBuilderUIPlugin.getResourceString(TARGET_TIP));
|
||||
platformSelection.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
handleTargetSelection();
|
||||
}
|
||||
});
|
||||
platformSelection.addDisposeListener(new DisposeListener() {
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
platformSelection = null;
|
||||
}
|
||||
});
|
||||
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
// Make this the same as NewCProjectWizardPage.SIZING_TEXT_FIELD_WIDTH
|
||||
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 50;
|
||||
platformSelection.setLayoutData(gd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public IConfiguration[] getSelectedConfigurations() {
|
||||
return (IConfiguration[]) selectedConfigurations.toArray(new IConfiguration[selectedConfigurations.size()]);
|
||||
}
|
||||
|
@ -198,6 +266,10 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
handleConfigurationSelectionChange();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Extracts the names from the targets that are valid for the wizard
|
||||
* session and populates the combo widget with them.
|
||||
*/
|
||||
private void populateTargetNames() {
|
||||
targetNames = new String[targets.size()];
|
||||
ListIterator iter = targets.listIterator();
|
||||
|
@ -205,8 +277,15 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
while (iter.hasNext()) {
|
||||
targetNames[index++] = ((ITarget) iter.next()).getName();
|
||||
}
|
||||
|
||||
// Now setup the combo
|
||||
platformSelection.removeAll();
|
||||
platformSelection.setItems(targetNames);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Collects all the valid targets for the platform Eclipse is running on
|
||||
*/
|
||||
private void populateTargets() {
|
||||
// Get a list of platforms defined by plugins
|
||||
ITarget[] allTargets = ManagedBuildManager.getDefinedTargets(null);
|
||||
|
@ -216,9 +295,14 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
for (int index = 0; index < allTargets.length; ++index) {
|
||||
ITarget target = allTargets[index];
|
||||
if (!target.isAbstract() && !target.isTestTarget()) {
|
||||
List targetOSList = Arrays.asList(target.getTargetOSList());
|
||||
if (targetOSList.contains(os)) {
|
||||
// If the check box is selected show all the targets
|
||||
if (showAll != null && showAll.getSelection() == true) {
|
||||
targets.add(target);
|
||||
} else {
|
||||
List targetOSList = Arrays.asList(target.getTargetOSList());
|
||||
if (targetOSList.contains("all") || targetOSList.contains(os)) { //$NON-NLS-1$
|
||||
targets.add(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +314,7 @@ public class CProjectPlatformPage extends WizardPage {
|
|||
* @return
|
||||
*/
|
||||
private boolean validatePage() {
|
||||
// TODO Auto-generated method stub
|
||||
// TODO some validation ... maybe
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
|
|||
ManagedBuildManager.setDefaultConfiguration(newProject, newConfigs[0]);
|
||||
}
|
||||
ManagedBuildManager.setSelectedTarget(newProject, newTarget);
|
||||
ManagedBuildManager.setNewProjectVersion(newProject);
|
||||
}
|
||||
} catch (BuildException e) {
|
||||
// TODO Flag the error to the user
|
||||
|
@ -141,7 +142,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
|
|||
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
|
||||
|
||||
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||
// org.eclipse.cdt.core.ELF or "org.eclipse.cdt.core.PE"
|
||||
// org.eclipse.cdt.core.ELF or org.eclipse.cdt.core.PE
|
||||
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, newTarget.getBinaryParserId());
|
||||
} catch (CoreException e) {
|
||||
// TODO Flag the error to the user
|
||||
|
|
Loading…
Add table
Reference in a new issue