1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 17:25:38 +02:00

Large commit. Two components. The first is to switch all the managed build components over to the new plugin loading scheme. The second is to remove the dependency between the indexer and the build system for dependency calculation. Currently, to make this work, there is a flag that is only available on the 3.x GCC compilers, but I will be addressing that shortly.

This commit is contained in:
Sean Evoy 2004-05-24 23:23:36 +00:00
parent 5b75216401
commit d03b0f48a0
25 changed files with 1939 additions and 1485 deletions

View file

@ -6,12 +6,11 @@
version="1.0.0"> version="1.0.0">
<requires> <requires>
<import plugin="org.eclipse.core.runtime.compatibility"/> <import plugin="org.eclipse.core.runtime"/>
<import plugin="org.junit"/> <import plugin="org.junit"/>
<import plugin="org.eclipse.cdt.managedbuilder.core"/> <import plugin="org.eclipse.cdt.managedbuilder.core"/>
<import plugin="org.eclipse.cdt.core"/> <import plugin="org.eclipse.cdt.core"/>
<import plugin="org.eclipse.cdt.make.core"/> <import plugin="org.eclipse.cdt.make.core"/>
<import plugin="org.eclipse.cdt.core.tests"/>
<import plugin="org.eclipse.core.resources"/> <import plugin="org.eclipse.core.resources"/>
</requires> </requires>

View file

@ -46,7 +46,6 @@ import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.core.OptionReference; import org.eclipse.cdt.managedbuilder.internal.core.OptionReference;
import org.eclipse.cdt.testplugin.FileManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -1435,8 +1434,6 @@ public class ManagedBuildCoreTests extends TestCase {
public void testBug43450 () throws Exception{ public void testBug43450 () throws Exception{
IProject project = createProject( projectName ); IProject project = createProject( projectName );
FileManager fileManager = new FileManager();
IFolder folder = project.getProject().getFolder( "includes" ); IFolder folder = project.getProject().getFolder( "includes" );
if( !folder.exists() ){ if( !folder.exists() ){
folder.create( false, true, null ); folder.create( false, true, null );

View file

@ -15,7 +15,7 @@
<requires> <requires>
<import plugin="org.eclipse.cdt.core"/> <import plugin="org.eclipse.cdt.core"/>
<import plugin="org.eclipse.core.resources"/> <import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.core.runtime.compatibility"/> <import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.cdt.make.core"/> <import plugin="org.eclipse.cdt.make.core"/>
</requires> </requires>

View file

@ -109,7 +109,7 @@
This is an optional field that specifies the class that provides the dependency calculation for a given tool. This field is unused in CDT 1.2. This is an optional field that specifies the class that provides the dependency calculation for a given tool. This field is unused in CDT 1.2.
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.cdt.internal.core.sourcedependency.ISourceDependency"/> <meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator"/>
</appInfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
@ -239,6 +239,16 @@ Additional special types exist to flag options of special relevance to the build
</restriction> </restriction>
</simpleType> </simpleType>
</attribute> </attribute>
<attribute name="helpSupplier" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java"/>
</appInfo>
</annotation>
</attribute>
</complexType> </complexType>
</element> </element>
@ -393,7 +403,7 @@ Additional special types exist to flag options of special relevance to the build
<element name="target"> <element name="target">
<annotation> <annotation>
<documentation> <documentation>
Represents a type of resource that is the target of the build process, for example, a Linux Library. A target contains a sequence of tool definitions and configurations. Targets are arranged in an inheritance hierarchy where a target inherits the list of tools from it&apos;s parent and can add to or override tools in this list. Represents a type of resource that is the target of the build process, for example, a Linux static library. A target contains a sequence of tool definitions and configurations. Targets are arranged in an inheritance hierarchy where a target inherits the list of tools from it&apos;s parent and can add to or override tools in this list.
</documentation> </documentation>
</annotation> </annotation>
<complexType> <complexType>
@ -510,6 +520,16 @@ Additional special types exist to flag options of special relevance to the build
</appInfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="makefileGenerator" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator"/>
</appInfo>
</annotation>
</attribute>
</complexType> </complexType>
</element> </element>

View file

@ -10,6 +10,8 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.managedbuilder.core; package org.eclipse.cdt.managedbuilder.core;
import java.util.List;
/** /**
* *
*/ */
@ -41,6 +43,14 @@ public interface ITool extends IBuildObject {
*/ */
public boolean buildsFileType(String extension); public boolean buildsFileType(String extension);
/**
* Answers the list of valid source extensions the receiver know how to build.
* The list may be empty but will never be <code>null</code>.
*
* @return List
*/
public List getInputExtensions();
/** /**
* Answers a constant corresponding to the project nature the tool should be used * Answers a constant corresponding to the project nature the tool should be used
* for. Possible answers are: * for. Possible answers are:

View file

@ -41,8 +41,11 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration; import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement; import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.Target; import org.eclipse.cdt.managedbuilder.internal.core.Target;
import org.eclipse.cdt.managedbuilder.internal.core.Tool; import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -50,7 +53,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier; import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -69,8 +73,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
private static final String ROOT_NODE_NAME = "ManagedProjectBuildInfo"; //$NON-NLS-1$ private static final String ROOT_NODE_NAME = "ManagedProjectBuildInfo"; //$NON-NLS-1$
public static final String SETTINGS_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]; private static final ITarget[] emptyTargets = new ITarget[0];
public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.getUniqueIdentifier() + "." + "ManagedBuildManager"; //$NON-NLS-1$ //$NON-NLS-2$ public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ManagedBuildManager"; //$NON-NLS-1$
public static final String EXTENSION_POINT_ID = "ManagedBuildInfo"; //$NON-NLS-1$ public static final String EXTENSION_POINT_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ManagedBuildInfo"; //$NON-NLS-1$
private static final String REVISION_ELEMENT_NAME = "managedBuildRevision"; //$NON-NLS-1$ private static final String REVISION_ELEMENT_NAME = "managedBuildRevision"; //$NON-NLS-1$
private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$ private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$
private static final String MANIFEST_VERSION_ERROR ="ManagedBuildManager.error.manifest.version.error"; //$NON-NLS-1$ private static final String MANIFEST_VERSION_ERROR ="ManagedBuildManager.error.manifest.version.error"; //$NON-NLS-1$
@ -236,7 +240,73 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
info.setSelectedTarget(target); info.setSelectedTarget(target);
} }
} }
public static IManagedBuilderMakefileGenerator getMakefileGenerator(String targetId) {
try {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(EXTENSION_POINT_ID);
if (extension != null) {
// There could be many of these
IExtension[] extensions = extension.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
IConfigurationElement element = configElements[j];
if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME)) {
if (element.getAttribute(ITarget.ID).equals(targetId)) {
if (element.getAttribute(ManagedBuilderCorePlugin.MAKEGEN_ID) != null) {
return (IManagedBuilderMakefileGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.MAKEGEN_ID);
}
}
}
}
}
}
}
catch (CoreException e) {
// Probably not defined
ManagedBuilderCorePlugin.log(e);
}
return null;
}
/**
* Targets may have a scanner collector defined that knows how to discover
* built-in compiler defines and includes search paths. Find the scanner
* collector implentation for the target specified.
*
* @param string the unique id of the target to search for
* @return an implementation of <code>IManagedScannerInfoCollector</code>
*/
public static IManagedScannerInfoCollector getScannerInfoCollector(String targetId) {
try {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(EXTENSION_POINT_ID);
if (extension != null) {
// There could be many of these
IExtension[] extensions = extension.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
IConfigurationElement element = configElements[j];
if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME)) {
if (element.getAttribute(ITarget.ID).equals(targetId)) {
if (element.getAttribute(ManagedBuilderCorePlugin.SCANNER_INFO_ID) != null) {
return (IManagedScannerInfoCollector) element.createExecutableExtension(ManagedBuilderCorePlugin.SCANNER_INFO_ID);
}
}
}
}
}
}
}
catch (CoreException e) {
// Probably not defined
ManagedBuilderCorePlugin.log(e);
}
return null;
}
/** /**
* Gets the currently selected target. This is used while the project * Gets the currently selected target. This is used while the project
* property pages are displayed * property pages are displayed
@ -352,6 +422,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} }
} }
/** /**
* Saves the build information associated with a project and all resources * Saves the build information associated with a project and all resources
* in the project to the build info file. * in the project to the build info file.
@ -501,13 +572,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
if (resource instanceof IProject) { if (resource instanceof IProject) {
// Must be an extension target (why?) // Must be an extension target (why?)
if (owner != null) if (owner != null)
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("ManagedBuildManager.error.owner_not_null")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("ManagedBuildManager.error.owner_not_null")); //$NON-NLS-1$
} else { } else {
// Owner must be owned by the project containing this resource // Owner must be owned by the project containing this resource
if (owner == null) if (owner == null)
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("ManagedBuildManager.error.null_owner")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("ManagedBuildManager.error.null_owner")); //$NON-NLS-1$
if (!owner.equals(resource.getProject())) if (!owner.equals(resource.getProject()))
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("ManagedBuildManager.error.owner_not_project")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("ManagedBuildManager.error.owner_not_project")); //$NON-NLS-1$
} }
// Passed validation so create the target. // Passed validation so create the target.
@ -566,7 +637,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
fileVersion = rootElement.getNodeValue(); fileVersion = rootElement.getNodeValue();
PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion); PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion);
if (!buildInfoVersion.isCompatibleWith(version)) { if (!buildInfoVersion.isCompatibleWith(version)) {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString(PROJECT_VERSION_ERROR)); throw new BuildException(ManagedMakeMessages.getResourceString(PROJECT_VERSION_ERROR));
} }
if (buildInfoVersion.isGreaterThan(version)) { if (buildInfoVersion.isGreaterThan(version)) {
// TODO Upgrade the project // TODO Upgrade the project
@ -599,8 +670,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return; return;
// Get those extensions // Get those extensions
IPluginDescriptor descriptor = ManagedBuilderCorePlugin.getDefault().getDescriptor(); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
IExtensionPoint extensionPoint = descriptor.getExtensionPoint(EXTENSION_POINT_ID);
IExtension[] extensions = extensionPoint.getExtensions(); IExtension[] extensions = extensionPoint.getExtensions();
// First call the constructors // First call the constructors
@ -609,7 +679,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Can we read this manifest // Can we read this manifest
if (!isVersionCompatible(extension)) { if (!isVersionCompatible(extension)) {
//The version of the Plug-in is greater than what the manager thinks it understands //The version of the Plug-in is greater than what the manager thinks it understands
throw new BuildException(ManagedBuilderCorePlugin.getResourceString(MANIFEST_VERSION_ERROR)); throw new BuildException(ManagedMakeMessages.getResourceString(MANIFEST_VERSION_ERROR));
} }
IConfigurationElement[] elements = extension.getConfigurationElements(); IConfigurationElement[] elements = extension.getConfigurationElements();
loadConfigElements(DefaultManagedConfigElement.convertArray(elements)); loadConfigElements(DefaultManagedConfigElement.convertArray(elements));

View file

@ -11,38 +11,44 @@ package org.eclipse.cdt.managedbuilder.core;
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
* **********************************************************************/ * **********************************************************************/
import java.text.MessageFormat; import java.lang.reflect.InvocationTargetException;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
public class ManagedBuilderCorePlugin extends Plugin { public class ManagedBuilderCorePlugin extends Plugin {
private static final String PLUGIN_ID = "org.eclipse.cdt.managedbuilder.core"; //$NON-NLS-1$
// The attribute name for the dependency calculator
public static final String DEP_CALC_ID ="dependencyCalculator"; //$NON-NLS-1$
//The shared instance. //The shared instance.
private static ManagedBuilderCorePlugin plugin; private static ManagedBuilderCorePlugin plugin;
//Resource bundle. // The attribute name for the scanner info collector
private static ResourceBundle resourceBundle; public static final String SCANNER_INFO_ID = "scannerInfoCollector"; //$NON-NLS-1$
// The attribute name for the makefile generator
public static final String MAKEGEN_ID ="makefileGenerator"; //$NON-NLS-1$
/** /**
* @param descriptor * @param descriptor
*/ */
public ManagedBuilderCorePlugin(IPluginDescriptor descriptor) { public ManagedBuilderCorePlugin() {
super(descriptor); super();
plugin = this; plugin = this;
try {
resourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.managedbuilder.internal.core.PluginResources"); //$NON-NLS-1$
} catch (MissingResourceException x) {
resourceBundle = null;
}
} }
public static String getUniqueIdentifier() {
if (getDefault() == null) {
// If the default instance is not yet initialized,
// return a static identifier. This identifier must
// match the plugin id defined in plugin.xml
return PLUGIN_ID;
}
return getDefault().getBundle().getSymbolicName();
}
/** /**
* Returns the shared instance. * Returns the shared instance.
*/ */
@ -50,69 +56,19 @@ public class ManagedBuilderCorePlugin extends Plugin {
return plugin; return plugin;
} }
public static void log(Throwable e) {
public static String getResourceString(String key) { if (e instanceof InvocationTargetException)
try { e = ((InvocationTargetException) e).getTargetException();
return resourceBundle.getString(key); IStatus status = null;
} catch (MissingResourceException e) { if (e instanceof CoreException)
return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ status = ((CoreException) e).getStatus();
} catch (NullPointerException e) { else
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e);
} log(status);
} }
public static String getFormattedString(String key, String arg) { public static void log(IStatus status) {
return MessageFormat.format(getResourceString(key), new String[] { arg }); ResourcesPlugin.getPlugin().getLog().log(status);
}
public static String getFormattedString(String key, String[] args) {
return MessageFormat.format(getResourceString(key), args);
}
/**
* Convenience method which returns the unique identifier of this plugin.
*/
public static String getUniqueIdentifier() {
if (getDefault() == null) {
// If the default instance is not yet initialized,
// return a static identifier. This identifier must
// match the plugin id defined in plugin.xml
return "org.eclipse.cdt.managedbuilder.core"; //$NON-NLS-1$
}
return getDefault().getDescriptor().getUniqueIdentifier();
}
/**
* Targets may have a scanner collector defined that knows how to discover
* built-in compiler defines and includes search paths. Find the scanner
* collector implentation for the target specified.
*
* @param string the unique id of the target to search for
* @return an implementation of <code>IManagedScannerInfoCollector</code>
*/
public IManagedScannerInfoCollector getScannerInfoCollector(String targetId) {
try {
IExtensionPoint extension = getDescriptor().getExtensionPoint(ManagedBuildManager.EXTENSION_POINT_ID);
if (extension != null) {
// There could be many of these
IExtension[] extensions = extension.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
IConfigurationElement element = configElements[j];
if (element.getName().equals("target")) { //$NON-NLS-1$
if (element.getAttribute(ITarget.ID).equals(targetId)) {
return (IManagedScannerInfoCollector) element.createExecutableExtension("scannerInfoCollector"); //$NON-NLS-1$
}
}
}
}
}
}
catch (CoreException e) {
// Probably not defined
}
return null;
} }
} }

View file

@ -21,8 +21,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Plugin;
public class ManagedCProjectNature implements IProjectNature { public class ManagedCProjectNature implements IProjectNature {
@ -110,9 +110,8 @@ public class ManagedCProjectNature implements IProjectNature {
*/ */
public static String getBuilderID() { public static String getBuilderID() {
Plugin plugin = (Plugin)ManagedBuilderCorePlugin.getDefault(); Plugin plugin = (Plugin)ManagedBuilderCorePlugin.getDefault();
IPluginDescriptor descriptor = plugin.getDescriptor(); if (Platform.getExtensionRegistry().getExtension(BUILDER_NAME) != null) {
if (descriptor.getExtension(BUILDER_NAME) != null) { return ManagedBuilderCorePlugin.getUniqueIdentifier() + "." + BUILDER_NAME; //$NON-NLS-1$
return descriptor.getUniqueIdentifier() + "." + BUILDER_NAME; //$NON-NLS-1$
} }
return BUILDER_ID; return BUILDER_ID;
} }

View file

@ -28,8 +28,11 @@ import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.ACBuilder; import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -39,11 +42,15 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
public class GeneratedMakefileBuilder extends ACBuilder { public class GeneratedMakefileBuilder extends ACBuilder {
@ -65,7 +72,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Local variables // Local variables
protected List resourcesToBuild; protected List resourcesToBuild;
protected List ruleList; protected List ruleList;
protected IManagedBuilderMakefileGenerator generator;
public class ResourceDeltaVisitor implements IResourceDeltaVisitor { public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
private boolean buildNeeded = false; private boolean buildNeeded = false;
@ -96,7 +103,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
* @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/ */
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
String statusMsg = ManagedBuilderCorePlugin.getFormattedString(START, getProject().getName()); String statusMsg = ManagedMakeMessages.getFormattedString(START, getProject().getName());
IProject[] deps = getProject().getReferencedProjects(); IProject[] deps = getProject().getReferencedProjects();
if (statusMsg != null) { if (statusMsg != null) {
monitor.subTask(statusMsg); monitor.subTask(statusMsg);
@ -171,7 +178,9 @@ public class GeneratedMakefileBuilder extends ACBuilder {
IProject depProject = deps[i]; IProject depProject = deps[i];
if (ManagedBuildManager.manages(depProject)) { if (ManagedBuildManager.manages(depProject)) {
IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(depProject); IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(depProject);
MakefileGenerator generator = new MakefileGenerator(depProject, depInfo, monitor); String targetID = depInfo.getDefaultTarget().getParent().getId();
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getMakefileGenerator(targetID);
generator.initialize(depProject, depInfo, monitor);
try { try {
generator.regenerateMakefiles(); generator.regenerateMakefiles();
} catch (CoreException e) { } catch (CoreException e) {
@ -182,11 +191,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
} }
// Need to report status to the user // Need to report status to the user
String statusMsg = ManagedBuilderCorePlugin.getFormattedString(REBUILD, getProject().getName()); String statusMsg = ManagedMakeMessages.getFormattedString(REBUILD, getProject().getName());
monitor.subTask(statusMsg); monitor.subTask(statusMsg);
// Regenerate the makefiles for this project // Regenerate the makefiles for this project
MakefileGenerator generator = new MakefileGenerator(getProject(), info, monitor); String targetID = info.getDefaultTarget().getParent().getId();
generator = ManagedBuildManager.getMakefileGenerator(targetID);
generator.initialize(getProject(), info, monitor);
try { try {
generator.regenerateMakefiles(); generator.regenerateMakefiles();
} catch (CoreException e) { } catch (CoreException e) {
@ -195,14 +206,53 @@ public class GeneratedMakefileBuilder extends ACBuilder {
} }
// Now call make // Now call make
IPath topBuildDir = generator.getTopBuildDir(); IPath topBuildDir = generator.getBuildWorkingDir();
if (topBuildDir != null) { if (topBuildDir != null) {
invokeMake(true, topBuildDir.removeFirstSegments(1), info, monitor); invokeMake(true, topBuildDir, info, monitor);
} else { } else {
monitor.done(); monitor.done();
} }
// Now regenerate the dependencies
try {
generator.regenerateDependencies(false);
} catch (CoreException e) {
// Throw the exception back to the builder
throw e;
}
} }
/**
* @param toolId
* @return
*/
public IManagedBuilderDependencyCalculator getDependencyCalculator(String toolId) {
try {
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ManagedBuilderCorePlugin.DEP_CALC_ID);
if (extension != null) {
// There could be many of these
IExtension[] extensions = extension.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
IConfigurationElement element = configElements[j];
if (element.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
if (element.getAttribute(ITool.ID).equals(toolId)) {
if (element.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
return (IManagedBuilderDependencyCalculator) element.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
}
}
}
}
}
}
}
catch (CoreException e) {
// Probably not defined
}
return null;
}
/* (non-javadoc) /* (non-javadoc)
* Answers an array of strings with the proper make targets * Answers an array of strings with the proper make targets
* *
@ -262,7 +312,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
statusMsg = ManagedBuilderCorePlugin.getFormattedString(INCREMENTAL, getProject().getName()); statusMsg = ManagedMakeMessages.getFormattedString(INCREMENTAL, getProject().getName());
monitor.subTask(statusMsg); monitor.subTask(statusMsg);
// Regenerate the makefiles for any managed projects this project depends on // Regenerate the makefiles for any managed projects this project depends on
@ -271,7 +321,9 @@ public class GeneratedMakefileBuilder extends ACBuilder {
IProject depProject = deps[i]; IProject depProject = deps[i];
if (ManagedBuildManager.manages(depProject)) { if (ManagedBuildManager.manages(depProject)) {
IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(depProject); IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(depProject);
MakefileGenerator generator = new MakefileGenerator(depProject, depInfo, monitor); String targetID = depInfo.getDefaultTarget().getParent().getId();
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getMakefileGenerator(targetID);
generator.initialize(depProject, depInfo, monitor);
try { try {
generator.regenerateMakefiles(); generator.regenerateMakefiles();
} catch (CoreException e) { } catch (CoreException e) {
@ -282,7 +334,9 @@ public class GeneratedMakefileBuilder extends ACBuilder {
} }
// Ask the makefile generator to generate any makefiles needed to build delta // Ask the makefile generator to generate any makefiles needed to build delta
MakefileGenerator generator = new MakefileGenerator(getProject(), info, monitor); String targetID = info.getDefaultTarget().getParent().getId();
generator = ManagedBuildManager.getMakefileGenerator(targetID);
generator.initialize(getProject(), info, monitor);
try { try {
generator.generateMakefiles(delta); generator.generateMakefiles(delta);
} catch (CoreException e) { } catch (CoreException e) {
@ -319,7 +373,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
if (root == null) { if (root == null) {
return; return;
} }
IPath makefile = workingDirectory.addTrailingSeparator().append(MakefileGenerator.MAKEFILE_NAME); IPath makefile = workingDirectory.addTrailingSeparator().append(generator.getMakefileName());
if (root.getFileForLocation(makefile) == null) { if (root.getFileForLocation(makefile) == null) {
return; return;
} }
@ -330,7 +384,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
String[] msgs = new String[2]; String[] msgs = new String[2];
msgs[0] = makeCommand.toString(); msgs[0] = makeCommand.toString();
msgs[1] = currentProject.getName(); msgs[1] = currentProject.getName();
monitor.beginTask(ManagedBuilderCorePlugin.getFormattedString(MAKE, msgs), IProgressMonitor.UNKNOWN); monitor.beginTask(ManagedMakeMessages.getFormattedString(MAKE, msgs), IProgressMonitor.UNKNOWN);
// Get a build console for the project // Get a build console for the project
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
@ -339,14 +393,14 @@ public class GeneratedMakefileBuilder extends ACBuilder {
ConsoleOutputStream consoleOutStream = console.getOutputStream(); ConsoleOutputStream consoleOutStream = console.getOutputStream();
String[] consoleHeader = new String[3]; String[] consoleHeader = new String[3];
consoleHeader[0] = fullBuild ? consoleHeader[0] = fullBuild ?
ManagedBuilderCorePlugin.getResourceString(TYPE_FULL) : ManagedMakeMessages.getResourceString(TYPE_FULL) :
ManagedBuilderCorePlugin.getResourceString(TYPE_INC); ManagedMakeMessages.getResourceString(TYPE_INC);
consoleHeader[1] = info.getConfigurationName(); consoleHeader[1] = info.getConfigurationName();
consoleHeader[2] = currentProject.getName(); consoleHeader[2] = currentProject.getName();
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
buf.append(ManagedBuilderCorePlugin.getFormattedString(CONSOLE_HEADER, consoleHeader)); buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush(); consoleOutStream.flush();
@ -392,7 +446,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Hook up an error parser manager // Hook up an error parser manager
String[] errorParsers = info.getDefaultTarget().getErrorParserList(); String[] errorParsers = info.getDefaultTarget().getErrorParserList();
ErrorParserManager epm = new ErrorParserManager(getProject(), this, errorParsers); ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectory, this, errorParsers);
epm.setOutputStream(consoleOutStream); epm.setOutputStream(consoleOutStream);
OutputStream stdout = epm.getOutputStream(); OutputStream stdout = epm.getOutputStream();
OutputStream stderr = epm.getOutputStream(); OutputStream stderr = epm.getOutputStream();
@ -413,7 +467,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Force a resync of the projects without allowing the user to cancel. // Force a resync of the projects without allowing the user to cancel.
// This is probably unkind, but short of this there is no way to insure // This is probably unkind, but short of this there is no way to insure
// the UI is up-to-date with the build results // the UI is up-to-date with the build results
monitor.subTask(ManagedBuilderCorePlugin.getResourceString(REFRESH)); monitor.subTask(ManagedMakeMessages.getResourceString(REFRESH));
try { try {
currentProject.refreshLocal(IResource.DEPTH_INFINITE, null); currentProject.refreshLocal(IResource.DEPTH_INFINITE, null);
for (int j = 0; j < deps.length; ++j) { for (int j = 0; j < deps.length; ++j) {
@ -421,7 +475,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
project.refreshLocal(IResource.DEPTH_INFINITE, null); project.refreshLocal(IResource.DEPTH_INFINITE, null);
} }
} catch (CoreException e) { } catch (CoreException e) {
monitor.subTask(ManagedBuilderCorePlugin.getResourceString(REFRESH_ERROR)); monitor.subTask(ManagedMakeMessages.getResourceString(REFRESH_ERROR));
} }
} else { } else {
errMsg = launcher.getErrorMessage(); errMsg = launcher.getErrorMessage();
@ -430,13 +484,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Report either the success or failure of our mission // Report either the success or failure of our mission
buf = new StringBuffer(); buf = new StringBuffer();
if (errMsg != null && errMsg.length() > 0) { if (errMsg != null && errMsg.length() > 0) {
String errorDesc = ManagedBuilderCorePlugin.getResourceString(BUILD_ERROR); String errorDesc = ManagedMakeMessages.getResourceString(BUILD_ERROR);
buf.append(errorDesc); buf.append(errorDesc);
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
} else { } else {
// Report a successful build // Report a successful build
String successMsg = ManagedBuilderCorePlugin.getFormattedString(BUILD_FINISHED, currentProject.getName()); String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, currentProject.getName());
buf.append(successMsg); buf.append(successMsg);
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
} }
@ -447,7 +501,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
stdout.close(); stdout.close();
stderr.close(); stderr.close();
monitor.subTask(ManagedBuilderCorePlugin.getResourceString(MARKERS)); monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
epm.reportProblems(); epm.reportProblems();
} }
} catch (Exception e) { } catch (Exception e) {

View file

@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Vector;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.CProjectNature;
@ -41,9 +42,12 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.jobs.Job;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@ -92,10 +96,26 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
cModelElement = CoreModel.getDefault().create(owner.getProject()); cModelElement = CoreModel.getDefault().create(owner.getProject());
try { try {
CoreModel.getDefault().setRawPathEntries(cModelElement, new IPathEntry[]{containerEntry}, new NullProgressMonitor()); IPathEntry[] entries = cModelElement.getRawPathEntries();
} catch (CModelException e1) { if (entries.length > 0 && entries[0].equals(containerEntry)) {
// TODO Auto-generated catch block
e1.printStackTrace(); } else {
Job initJob = new Job("Initializing path container") {
protected IStatus run(IProgressMonitor monitor) {
try {
// Set the raw path entries
cModelElement.setRawPathEntries(new IPathEntry[]{containerEntry}, new NullProgressMonitor());
} catch (CModelException e) {
ManagedBuilderCorePlugin.log(e);
}
return null;
}
};
initJob.schedule();
}
} catch (CModelException e) {
ManagedBuilderCorePlugin.log(e);
} }
isDirty = false; isDirty = false;
@ -161,27 +181,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Check to see if there is a rule to build a file with this extension // Check to see if there is a rule to build a file with this extension
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
try { if (tool != null && tool.buildsFileType(srcExt)) {
// Make sure the tool is right for the project return true;
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.buildsFileType(srcExt);
}
break;
case ITool.FILTER_CC:
if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.buildsFileType(srcExt);
}
break;
case ITool.FILTER_BOTH:
return tool.buildsFileType(srcExt);
}
} catch (CoreException e) {
continue;
} }
} }
return false; return false;
@ -365,31 +369,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Get all the tools for the current config // Get all the tools for the current config
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
if (tool.buildsFileType(extension)) { if (tool != null && tool.buildsFileType(extension)) {
try { try {
// Make sure the tool is right for the project return tool.getToolFlags();
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getToolFlags();
}
break;
case ITool.FILTER_CC:
if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getToolFlags();
}
break;
case ITool.FILTER_BOTH:
return tool.getToolFlags();
}
} catch (CoreException e) {
continue;
} catch (BuildException e) { } catch (BuildException e) {
// Give it your best shot with the next tool return null;
continue;
} }
} }
} }
@ -406,31 +393,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Get all the tools for the current config // Get all the tools for the current config
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
if (tool.producesFileType(ext)) { if (tool.producesFileType(ext)) {
try { try {
// Make sure the tool is right for the project return tool.getToolFlags();
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getToolFlags();
}
break;
case ITool.FILTER_CC:
if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getToolFlags();
}
break;
case ITool.FILTER_BOTH:
return tool.getToolFlags();
}
} catch (CoreException e) {
continue;
} catch (BuildException e) { } catch (BuildException e) {
// Give it your best shot with the next tool return null;
continue;
} }
} }
} }
@ -534,32 +504,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public String[] getLibsForTarget(String extension) { public String[] getLibsForTarget(String extension) {
IProject project = (IProject)owner; IProject project = (IProject)owner;
ArrayList libs = new ArrayList(); Vector libs = new Vector();
// Get all the tools for the current config // Get all the tools for the current config
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
try {
// Make sure the tool is right for the project
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (!project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
continue;
}
break;
case ITool.FILTER_CC:
if (!project.hasNature(CCProjectNature.CC_NATURE_ID)) {
continue;
}
break;
case ITool.FILTER_BOTH:
break;
}
} catch (CoreException e) {
continue;
}
// The tool is OK for this project nature
if (tool.producesFileType(extension)) { if (tool.producesFileType(extension)) {
IOption[] opts = tool.getOptions(); IOption[] opts = tool.getOptions();
// Look for the lib option type // Look for the lib option type
@ -580,7 +530,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
} }
} }
} }
libs.trimToSize();
return (String[])libs.toArray(new String[libs.size()]); return (String[])libs.toArray(new String[libs.size()]);
} }
@ -603,29 +552,16 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/ */
public String getOutputExtension(String resourceExtension) { public String getOutputExtension(String resourceExtension) {
IProject project = (IProject)owner; IProject project = (IProject)owner;
String outputExtension = null;
// Get all the tools for the current config // Get all the tools for the current config
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
try { outputExtension = tool.getOutputExtension(resourceExtension);
// Make sure the tool is right for the project if (outputExtension != null) {
switch (tool.getNatureFilter()) { return outputExtension;
case ITool.FILTER_C:
if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getOutputExtension(resourceExtension);
}
break;
case ITool.FILTER_CC:
if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getOutputExtension(resourceExtension);
}
break;
case ITool.FILTER_BOTH:
return tool.getOutputExtension(resourceExtension);
}
} catch (CoreException e) {
continue;
} }
} }
return null; return null;
@ -642,28 +578,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Get all the tools for the current config // Get all the tools for the current config
String flags = new String(); String flags = new String();
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
try {
// Make sure the tool is right for the project
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (!project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
continue;
}
break;
case ITool.FILTER_CC:
if (!project.hasNature(CCProjectNature.CC_NATURE_ID)) {
continue;
}
break;
case ITool.FILTER_BOTH:
break;
}
} catch (CoreException e) {
continue;
}
// It's OK // It's OK
if (tool.producesFileType(ext)) { if (tool.producesFileType(ext)) {
flags = tool.getOutputFlag(); flags = tool.getOutputFlag();
@ -683,28 +600,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Get all the tools for the current config // Get all the tools for the current config
String flags = new String(); String flags = new String();
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
try {
// Make sure the tool is right for the project
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (!project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
continue;
}
break;
case ITool.FILTER_CC:
if (!project.hasNature(CCProjectNature.CC_NATURE_ID)) {
continue;
}
break;
case ITool.FILTER_BOTH:
break;
}
} catch (CoreException e) {
continue;
}
if (tool.producesFileType(ext)) { if (tool.producesFileType(ext)) {
flags = tool.getOutputPrefix(); flags = tool.getOutputPrefix();
} }
@ -756,29 +654,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Get all the tools for the current config // Get all the tools for the current config
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
if (tool.buildsFileType(extension)) { if (tool.buildsFileType(extension)) {
try { return tool.getToolCommand();
// Make sure the tool is right for the project
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getToolCommand();
}
break;
case ITool.FILTER_CC:
if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getToolCommand();
}
break;
case ITool.FILTER_BOTH:
return tool.getToolCommand();
}
} catch (CoreException e) {
continue;
}
} }
} }
return null; return null;
@ -794,29 +674,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
String ext = extension == null ? new String() : extension; String ext = extension == null ? new String() : extension;
// Get all the tools for the current config // Get all the tools for the current config
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
if (tool.producesFileType(ext)) { if (tool.producesFileType(ext)) {
try { return tool.getToolCommand();
// Make sure the tool is right for the project
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getToolCommand();
}
break;
case ITool.FILTER_CC:
if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
return tool.getToolCommand();
}
break;
case ITool.FILTER_BOTH:
return tool.getToolCommand();
}
} catch (CoreException e) {
continue;
}
} }
} }
return null; return null;
@ -827,31 +689,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/ */
public String[] getUserObjectsForTarget(String extension) { public String[] getUserObjectsForTarget(String extension) {
IProject project = (IProject)owner; IProject project = (IProject)owner;
ArrayList objs = new ArrayList(); Vector objs = new Vector();
// Get all the tools for the current config // Get all the tools for the current config
IConfiguration config = getDefaultConfiguration(getDefaultTarget()); IConfiguration config = getDefaultConfiguration(getDefaultTarget());
ITool[] tools = config.getTools(); ITool[] tools = config.getFilteredTools(project);
for (int index = 0; index < tools.length; index++) { for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index]; ITool tool = tools[index];
try {
// Make sure the tool is right for the project
switch (tool.getNatureFilter()) {
case ITool.FILTER_C:
if (!project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
continue;
}
break;
case ITool.FILTER_CC:
if (!project.hasNature(CCProjectNature.CC_NATURE_ID)) {
continue;
}
break;
case ITool.FILTER_BOTH:
break;
}
} catch (CoreException e) {
continue;
}
// The tool is OK for this project nature // The tool is OK for this project nature
if (tool.producesFileType(extension)) { if (tool.producesFileType(extension)) {
IOption[] opts = tool.getOptions(); IOption[] opts = tool.getOptions();
@ -868,7 +711,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
} }
} }
} }
objs.trimToSize();
return (String[])objs.toArray(new String[objs.size()]); return (String[])objs.toArray(new String[objs.size()]);
} }
@ -985,8 +827,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(this); IPathEntryContainer container = new ManagedBuildCPathEntryContainer(this);
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cModelElement}, container, new NullProgressMonitor()); CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cModelElement}, container, new NullProgressMonitor());
} catch (CModelException e) { } catch (CModelException e) {
// TODO Auto-generated catch block ManagedBuilderCorePlugin.log(e);
e.printStackTrace();
} }
} }
@ -1122,7 +963,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// And finally update the cModelElement // And finally update the cModelElement
cModelElement = CoreModel.getDefault().create(owner.getProject()); cModelElement = CoreModel.getDefault().create(owner.getProject());
try { try {
CoreModel.getDefault().setRawPathEntries(cModelElement, new IPathEntry[]{containerEntry}, new NullProgressMonitor()); CoreModel.setRawPathEntries(cModelElement, new IPathEntry[]{containerEntry}, new NullProgressMonitor());
} catch (CModelException e) { } catch (CModelException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

View file

@ -0,0 +1,58 @@
/**********************************************************************
* 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.core;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* @since 2.0
*/
public class ManagedMakeMessages {
// Bundle ID
private static final String BUNDLE_ID = "org.eclipse.cdt.managedbuilder.internal.core.PluginResources"; //$NON-NLS-1$
//Resource bundle.
private static ResourceBundle resourceBundle;
static {
try {
resourceBundle = ResourceBundle.getBundle(BUNDLE_ID);
} catch (MissingResourceException x) {
resourceBundle = null;
}
}
public static String getResourceString(String key) {
try {
return resourceBundle.getString(key);
} catch (MissingResourceException e) {
return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
} catch (NullPointerException e) {
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
public static String getFormattedString(String key, String arg) {
return MessageFormat.format(getResourceString(key), new String[] { arg });
}
public static String getFormattedString(String key, String[] args) {
return MessageFormat.format(getResourceString(key), args);
}
/**
*
*/
private ManagedMakeMessages() {
// No constructor
}
}

View file

@ -25,7 +25,6 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
public class Option extends BuildObject implements IOption { public class Option extends BuildObject implements IOption {
// Static default return values // Static default return values
@ -230,7 +229,7 @@ public class Option extends BuildObject implements IOption {
*/ */
public String[] getDefinedSymbols() throws BuildException { public String[] getDefinedSymbols() throws BuildException {
if (valueType != PREPROCESSOR_SYMBOLS) { if (valueType != PREPROCESSOR_SYMBOLS) {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
ArrayList v = (ArrayList)value; ArrayList v = (ArrayList)value;
if (v == null) { if (v == null) {
@ -315,7 +314,7 @@ public class Option extends BuildObject implements IOption {
*/ */
public String[] getIncludePaths() throws BuildException { public String[] getIncludePaths() throws BuildException {
if (valueType != INCLUDE_PATH) { if (valueType != INCLUDE_PATH) {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
ArrayList v = (ArrayList)value; ArrayList v = (ArrayList)value;
if (v == null) { if (v == null) {
@ -331,7 +330,7 @@ public class Option extends BuildObject implements IOption {
*/ */
public String[] getLibraries() throws BuildException { public String[] getLibraries() throws BuildException {
if (valueType != LIBRARIES) { if (valueType != LIBRARIES) {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
ArrayList v = (ArrayList)value; ArrayList v = (ArrayList)value;
if (v == null) { if (v == null) {
@ -347,7 +346,7 @@ public class Option extends BuildObject implements IOption {
*/ */
public String getSelectedEnum() throws BuildException { public String getSelectedEnum() throws BuildException {
if (valueType != ENUMERATED) { if (valueType != ENUMERATED) {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
return defaultEnumId == null ? EMPTY_STRING : defaultEnumId; return defaultEnumId == null ? EMPTY_STRING : defaultEnumId;
} }
@ -357,7 +356,7 @@ public class Option extends BuildObject implements IOption {
*/ */
public String[] getStringListValue() throws BuildException { public String[] getStringListValue() throws BuildException {
if (valueType != STRING_LIST) { if (valueType != STRING_LIST) {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
ArrayList v = (ArrayList)value; ArrayList v = (ArrayList)value;
if (v == null) { if (v == null) {
@ -373,7 +372,7 @@ public class Option extends BuildObject implements IOption {
*/ */
public String getStringValue() throws BuildException { public String getStringValue() throws BuildException {
if (valueType != STRING) { if (valueType != STRING) {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
return value == null ? EMPTY_STRING : (String)value; return value == null ? EMPTY_STRING : (String)value;
} }
@ -390,7 +389,7 @@ public class Option extends BuildObject implements IOption {
*/ */
public String[] getUserObjects() throws BuildException { public String[] getUserObjects() throws BuildException {
if (valueType != OBJECTS) { if (valueType != OBJECTS) {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
// This is the right puppy, so return its list value // This is the right puppy, so return its list value
ArrayList v = (ArrayList)value; ArrayList v = (ArrayList)value;
@ -424,7 +423,7 @@ public class Option extends BuildObject implements IOption {
{ {
if (valueType != IOption.STRING if (valueType != IOption.STRING
|| valueType != ENUMERATED) || valueType != ENUMERATED)
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
if (config == null) { if (config == null) {
this.value = value; this.value = value;
@ -446,7 +445,7 @@ public class Option extends BuildObject implements IOption {
|| valueType != PREPROCESSOR_SYMBOLS || valueType != PREPROCESSOR_SYMBOLS
|| valueType != LIBRARIES || valueType != LIBRARIES
|| valueType != OBJECTS) || valueType != OBJECTS)
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
if (config == null) { if (config == null) {
this.value = value; this.value = value;

View file

@ -21,7 +21,6 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@ -281,7 +280,7 @@ public class OptionReference implements IOption {
return (String[]) list.toArray(new String[list.size()]); return (String[]) list.toArray(new String[list.size()]);
} }
else else
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -332,7 +331,7 @@ public class OptionReference implements IOption {
return (String[]) list.toArray(new String[list.size()]); return (String[]) list.toArray(new String[list.size()]);
} }
else else
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -346,7 +345,7 @@ public class OptionReference implements IOption {
return (String[]) list.toArray(new String[list.size()]); return (String[]) list.toArray(new String[list.size()]);
} }
else else
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -368,7 +367,7 @@ public class OptionReference implements IOption {
Boolean bool = (Boolean) value; Boolean bool = (Boolean) value;
return bool.booleanValue(); return bool.booleanValue();
} else { } else {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
} }
@ -430,7 +429,7 @@ public class OptionReference implements IOption {
// This is a valid ID // This is a valid ID
return (String) value; return (String) value;
} else { } else {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
} }
@ -445,7 +444,7 @@ public class OptionReference implements IOption {
return (String[]) list.toArray(new String[list.size()]); return (String[]) list.toArray(new String[list.size()]);
} }
else else
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -457,7 +456,7 @@ public class OptionReference implements IOption {
else if (getValueType() == STRING) else if (getValueType() == STRING)
return (String)value; return (String)value;
else else
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -487,7 +486,7 @@ public class OptionReference implements IOption {
return (String[]) list.toArray(new String[list.size()]); return (String[]) list.toArray(new String[list.size()]);
} }
else else
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -529,7 +528,7 @@ public class OptionReference implements IOption {
if (getValueType() == BOOLEAN) if (getValueType() == BOOLEAN)
this.value = new Boolean(value); this.value = new Boolean(value);
else else
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
/** /**
@ -541,7 +540,7 @@ public class OptionReference implements IOption {
if (getValueType() == STRING || getValueType() == ENUMERATED) { if (getValueType() == STRING || getValueType() == ENUMERATED) {
this.value = value; this.value = value;
} else { } else {
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
} }
@ -561,7 +560,7 @@ public class OptionReference implements IOption {
this.value = new ArrayList(Arrays.asList(value)); this.value = new ArrayList(Arrays.asList(value));
} }
else else
throw new BuildException(ManagedBuilderCorePlugin.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -20,13 +20,6 @@ ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for pr
ManagedMakeBuilder.message.error = Build error ManagedMakeBuilder.message.error = Build error
ManagedMakeBuilder.message.error.refresh = Error refreshing project ManagedMakeBuilder.message.error.refresh = Error refreshing project
ManagedMakeBuilder.message.finished = Build complete for project {0} ManagedMakeBuilder.message.finished = Build complete for project {0}
ManagedMakeBuilder.comment.module.list = Every subdirectory with source files must be described here
ManagedMakeBuilder.comment.source.list = Each subdirectory must contribute its source files here
ManagedMakeBuilder.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
ManagedMakeBuilder.comment.module.make.includes = Include the makefiles for each source subdirectory
ManagedMakeBuilder.comment.module.dep.includes = Include automatically-generated dependency list:
ManagedMakeBuilder.comment.autodeps = Automatically-generated dependency list:
ManagedMakeBuilder.comment.header = Automatically-generated file. Do not edit!
ManagedMakeBuilder.type.full = Full rebuild ManagedMakeBuilder.type.full = Full rebuild
ManagedMakeBuider.type.incremental = Incremental build ManagedMakeBuider.type.incremental = Incremental build
@ -39,3 +32,16 @@ ManagedBuildManager.error.null_owner=addTarget: null owner
ManagedBuildManager.error.owner_not_project=addTarget: owner not project ManagedBuildManager.error.owner_not_project=addTarget: owner not project
ManagedBuildManager.error.manifest.version.error=The version of plugin file is higher than version of the build system ManagedBuildManager.error.manifest.version.error=The version of plugin file is higher than version of the build system
ManagedBuildManager.error.project.version.error=The version of the project is higher than the build system ManagedBuildManager.error.project.version.error=The version of the project is higher than the build system
# Makefile Generator Messages
MakefileGenerator.message.start.file=Building file:
MakefileGenerator.message.finish.file=Finished building:
MakefileGenerator.message.start.build=Building target:
MakefileGenerator.message.finish.build=Finished building target:
MakefileGenerator.comment.module.list = Every subdirectory with source files must be described here
MakefileGenerator.comment.source.list = All of the sources participating in the build are defined here
MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory
MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list:
MakefileGenerator.comment.autodeps = Automatically-generated dependency list:
MakefileGenerator.comment.header = Automatically-generated file. Do not edit!

View file

@ -330,7 +330,10 @@ public class Target extends BuildObject implements ITarget {
if (makeCommand != null) { if (makeCommand != null) {
element.setAttribute(MAKE_COMMAND, makeCommand); element.setAttribute(MAKE_COMMAND, makeCommand);
} else {
// Make sure we use the default
} }
if (makeArguments != null) { if (makeArguments != null) {
element.setAttribute(MAKE_ARGS, makeArguments); element.setAttribute(MAKE_ARGS, makeArguments);
} }
@ -420,7 +423,7 @@ public class Target extends BuildObject implements ITarget {
if (parent != null) { if (parent != null) {
return parent.getMakeCommand(); return parent.getMakeCommand();
} else { } else {
// The user has forgotten to specify a command in the plugin manifets. // The user has forgotten to specify a command in the plugin manifest
return new String("make"); //$NON-NLS-1$ return new String("make"); //$NON-NLS-1$
} }
} else { } else {
@ -721,7 +724,7 @@ public class Target extends BuildObject implements ITarget {
return defaultExtension; return defaultExtension;
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getBinaryParserId() * @see org.eclipse.cdt.managedbuilder.core.ITarget#getBinaryParserId()
*/ */

View file

@ -180,12 +180,9 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
} }
/* (non-Javadoc) /* (non-Javadoc)
* Safe accessor method to retrieve the list of valid source extensions * @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions()
* the receiver know how to build.
*
* @return List
*/ */
private List getInputExtensions() { public List getInputExtensions() {
if (inputExtensions == null) { if (inputExtensions == null) {
inputExtensions = new ArrayList(); inputExtensions = new ArrayList();
} }

View file

@ -273,8 +273,15 @@ public class ToolReference implements IToolReference {
public String getId() { public String getId() {
return parent.getId(); return parent.getId();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions()
*/
public List getInputExtensions() {
return getTool().getInputExtensions();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName() * @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
*/ */
public String getName() { public String getName() {

View file

@ -16,7 +16,6 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Vector; import java.util.Vector;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
@ -32,7 +31,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITarget; import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector; import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -73,8 +72,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
protected void addDefinedSymbols(Map definedSymbols) { protected void addDefinedSymbols(Map definedSymbols) {
// Add a new macro entry for each defined symbol // Add a new macro entry for each defined symbol
Set macros = definedSymbols.keySet(); Iterator keyIter = definedSymbols.keySet().iterator();
Iterator keyIter = macros.iterator();
while (keyIter.hasNext()) { while (keyIter.hasNext()) {
boolean add = true; boolean add = true;
String macro = (String) keyIter.next(); String macro = (String) keyIter.next();
@ -191,7 +189,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries() * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
*/ */
public synchronized IPathEntry[] getPathEntries() { public IPathEntry[] getPathEntries() {
// TODO figure out when I can skip this step // TODO figure out when I can skip this step
if (entries.isEmpty()) { if (entries.isEmpty()) {
// Load the toolchain-spec'd collector // Load the toolchain-spec'd collector
@ -207,7 +205,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
} }
// See if we can load a dynamic resolver // See if we can load a dynamic resolver
String baseTargetId = parent.getId(); String baseTargetId = parent.getId();
IManagedScannerInfoCollector collector = ManagedBuilderCorePlugin.getDefault().getScannerInfoCollector(baseTargetId); IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
if (collector != null) { if (collector != null) {
collector.setProject(info.getOwner().getProject()); collector.setProject(info.getOwner().getProject());
calculateEntriesDynamically((IProject)info.getOwner(), collector); calculateEntriesDynamically((IProject)info.getOwner(), collector);
@ -239,4 +237,5 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
public IPath getPath() { public IPath getPath() {
return new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"); //$NON-NLS-1$ return new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"); //$NON-NLS-1$
} }
} }

View file

@ -0,0 +1,28 @@
/**********************************************************************
* 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.makegen;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
/**
* @since 2.0
*/
public interface IManagedBuilderDependencyCalculator {
public int TYPE_NODEPS = 0;
public int TYPE_COMMAND = 1;
public int TYPE_INDEXER = 2;
public int TYPE_EXTERNAL = 3;
public IResource[] findDependencies(IResource resource, IProject project);
public int getCalculatorType();
public String getDependencyCommand();
}

View file

@ -0,0 +1,72 @@
/**********************************************************************
* 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.makegen;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* @since 2.0
*/
public interface IManagedBuilderMakefileGenerator {
/**
* @throws CoreException
*/
public void generateDependencies() throws CoreException;
/**
* 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
* subdirectories need a new makefile and dependency list (if any).
*
* @param delta
* @throws CoreException
*/
public void generateMakefiles(IResourceDelta delta) throws CoreException ;
/**
* Answers the path of the top directory generated for the build
* output, or <code>null</code> if none has been generated.
*
* @return <code>IPath</code> to the working directory of the build
*/
public IPath getBuildWorkingDir();
/**
* Answers the name of the top-level makefile generated by the receiver.
*
* @return name of the makefile.
*/
public String getMakefileName();
/**
* @param project
* @param info
* @param monitor
*/
public void initialize(IProject project, IManagedBuildInfo info, IProgressMonitor monitor);
/**
* @param force
* @throws CoreException
*/
public void regenerateDependencies(boolean force) throws CoreException;
/**
* @throws CoreException
*/
public void regenerateMakefiles() throws CoreException;
}

View file

@ -0,0 +1,43 @@
/**********************************************************************
* 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.makegen.gnu;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
/**
* @since 2.0
*/
public class DefaultGCCDependencyCalculator implements IManagedBuilderDependencyCalculator {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
*/
public IResource[] findDependencies(IResource resource, IProject project) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
*/
public int getCalculatorType() {
return TYPE_COMMAND;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
*/
public String getDependencyCommand() {
// TODO Auto-generated method stub
return "$(CC) -M $(CC_FLAGS) $< > makefile.dep"; //$NON-NLS-1$
}
}

View file

@ -0,0 +1,86 @@
/**********************************************************************
* 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.makegen.gnu;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.search.PathCollector;
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
/**
* @since 2.0
*/
public class DefaultIndexerDependencyCalculator implements IManagedBuilderDependencyCalculator {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
*/
public IResource[] findDependencies(IResource resource, IProject project) {
PathCollector pathCollector = new PathCollector();
ICSearchScope scope = SearchEngine.createWorkspaceScope();
CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(), ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES, ICSearchConstants.EXACT_MATCH, true);
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.performConcurrentJob(
new PatternSearchJob(
(CSearchPattern) pattern,
scope,
pathCollector,
indexManager),
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null, null);
// We will get back an array of resource names relative to the workspace
String[] deps = pathCollector.getPaths();
// Convert them to something useful
List depList = new ArrayList();
IResource res = null;
IWorkspaceRoot root = null;
if (project != null) {
root = project.getWorkspace().getRoot();
}
for (int index = 0; index < deps.length; ++index) {
res = root.findMember(deps[index]);
if (res != null) {
depList.add(res);
}
}
return (IResource[]) depList.toArray(new IResource[depList.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
*/
public int getCalculatorType() {
// Tell the
return TYPE_INDEXER;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
*/
public String getDependencyCommand() {
// There is no command
return null;
}
}

View file

@ -848,13 +848,14 @@
</tool> </tool>
</target> </target>
<target <target
isTest="false" isAbstract="false"
osList="solaris,linux,hpux,aix,macosx,qnx" osList="solaris,linux,hpux,aix,macosx,qnx"
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
isTest="false"
makefileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
name="%TargetName.gnu.exe" name="%TargetName.gnu.exe"
parent="cdt.managedbuild.target.gnu" id="cdt.managedbuild.target.gnu.exe"
isAbstract="false" parent="cdt.managedbuild.target.gnu">
id="cdt.managedbuild.target.gnu.exe">
<configuration <configuration
name="%ConfigName.Dbg" name="%ConfigName.Dbg"
id="cdt.managedbuild.config.gnu.exe.debug"> id="cdt.managedbuild.config.gnu.exe.debug">
@ -918,6 +919,7 @@
isTest="false" isTest="false"
osList="solaris,linux,hpux,aix,macosx,qnx" osList="solaris,linux,hpux,aix,macosx,qnx"
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
makefileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
name="%TargetName.gnu.so" name="%TargetName.gnu.so"
parent="cdt.managedbuild.target.gnu" parent="cdt.managedbuild.target.gnu"
defaultExtension="so" defaultExtension="so"
@ -990,6 +992,7 @@
isTest="false" isTest="false"
osList="solaris,linux,hpux,aix,macosx,qnx" osList="solaris,linux,hpux,aix,macosx,qnx"
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
makefileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
name="%TargetName.gnu.lib" name="%TargetName.gnu.lib"
parent="cdt.managedbuild.target.gnu" parent="cdt.managedbuild.target.gnu"
defaultExtension="a" defaultExtension="a"
@ -1059,6 +1062,7 @@
isTest="false" isTest="false"
defaultExtension="exe" defaultExtension="exe"
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultCygwinScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultCygwinScannerInfoCollector"
makefileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
isAbstract="false" isAbstract="false"
binaryParser="org.eclipse.cdt.core.PE" binaryParser="org.eclipse.cdt.core.PE"
parent="cdt.managedbuild.target.gnu" parent="cdt.managedbuild.target.gnu"
@ -1130,6 +1134,7 @@
isTest="false" isTest="false"
defaultExtension="a.dll" defaultExtension="a.dll"
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultCygwinScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultCygwinScannerInfoCollector"
makefileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
isAbstract="false" isAbstract="false"
binaryParser="org.eclipse.cdt.core.PE" binaryParser="org.eclipse.cdt.core.PE"
parent="cdt.managedbuild.target.gnu" parent="cdt.managedbuild.target.gnu"
@ -1199,6 +1204,7 @@
name="%TargetName.cygw.lib" name="%TargetName.cygw.lib"
id="cdt.managedbuild.target.gnu.cygwin.lib" id="cdt.managedbuild.target.gnu.cygwin.lib"
isTest="false" isTest="false"
makefileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
defaultExtension="a" defaultExtension="a"
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultCygwinScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultCygwinScannerInfoCollector"
isAbstract="false" isAbstract="false"
@ -1269,6 +1275,7 @@
osList="win32" osList="win32"
makeCommand="mingw32-make" makeCommand="mingw32-make"
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector"
makefileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
isTest="false" isTest="false"
binaryParser="org.eclipse.cdt.core.PE" binaryParser="org.eclipse.cdt.core.PE"
name="%TargetName.mingw.exe" name="%TargetName.mingw.exe"
@ -1344,6 +1351,7 @@
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector"
isTest="false" isTest="false"
binaryParser="org.eclipse.cdt.core.PE" binaryParser="org.eclipse.cdt.core.PE"
makefileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"
name="%TargetName.mingw.so" name="%TargetName.mingw.so"
parent="cdt.managedbuild.target.gnu" parent="cdt.managedbuild.target.gnu"
id="cdt.managedbuild.target.gnu.mingw.so" id="cdt.managedbuild.target.gnu.mingw.so"
@ -1414,6 +1422,7 @@
defaultExtension="lib" defaultExtension="lib"
osList="win32" osList="win32"
makeCommand="mingw32-make" makeCommand="mingw32-make"
makefileGenerator="org.eclipse.cdt.managedbuilder.ui.properties.BrowseEntryDialog"
scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector" scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultMinGWScannerInfoCollector"
isTest="false" isTest="false"
binaryParser="org.eclipse.cdt.core.PE" binaryParser="org.eclipse.cdt.core.PE"