mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Partial fix for bugzilla 57860 - Last fundamental change to enable compilation of .s (or any other file) extension with proper dependencies.
This commit is contained in:
parent
b2719be9c5
commit
5c9fe1859c
13 changed files with 1654 additions and 1401 deletions
File diff suppressed because it is too large
Load diff
|
@ -13,9 +13,11 @@ package org.eclipse.cdt.managedbuilder.core;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
|
||||
public interface IManagedBuildInfo {
|
||||
public static final String DEFAULT_TARGET = "defaultTarget"; //$NON-NLS-1$
|
||||
public static final String DEFAULT_CONFIGURATION = "defaultConfig"; //$NON-NLS-1$
|
||||
public static final String DEFAULT_TARGET = "defaultTarget"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Add a new target to the build information for the receiver
|
||||
|
@ -87,49 +89,10 @@ public interface IManagedBuildInfo {
|
|||
public ITarget getDefaultTarget();
|
||||
|
||||
/**
|
||||
* Answers the extension that will be built by the current configuration
|
||||
* for the extension passed in the argument or <code>null</code>.
|
||||
*
|
||||
* @param resourceName
|
||||
* @param sourceExtension
|
||||
* @return
|
||||
*/
|
||||
public String getOutputExtension(String resourceExtension);
|
||||
|
||||
/**
|
||||
* Answers the flag to be passed to the build tool to produce a specific output
|
||||
* or an empty <code>String</code> if there is no special flag. For example, the
|
||||
* GCC tools use the '-o' flag to produce a named output, for example
|
||||
* gcc -c foo.c -o foo.o
|
||||
*
|
||||
* @param outputExt
|
||||
* @return
|
||||
*/
|
||||
public String getOutputFlag(String outputExt);
|
||||
|
||||
/**
|
||||
* Get the target specified in the argument.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public ITarget getTarget(String id);
|
||||
|
||||
/**
|
||||
* Answers the prefix that should be prepended to the name of the build
|
||||
* artifact. For example, a library foo, should have the prefix 'lib' and
|
||||
* the extension '.a', so the final goal would be 'libfoo.a'
|
||||
*
|
||||
* @param extension
|
||||
* @return
|
||||
*/
|
||||
public String getOutputPrefix(String outputExtension);
|
||||
|
||||
/**
|
||||
* Get all of the targets associated with the receiver.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List getTargets();
|
||||
public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension);
|
||||
|
||||
/**
|
||||
* Returns a <code>String</code> containing the flags, including
|
||||
|
@ -173,22 +136,75 @@ public interface IManagedBuildInfo {
|
|||
* for the default target/configuration.
|
||||
*/
|
||||
public String getMakeCommand();
|
||||
|
||||
/**
|
||||
* Answers the extension that will be built by the current configuration
|
||||
* for the extension passed in the argument or <code>null</code>.
|
||||
*
|
||||
* @param resourceName
|
||||
* @return
|
||||
*/
|
||||
public String getOutputExtension(String resourceExtension);
|
||||
|
||||
/**
|
||||
* Answers the flag to be passed to the build tool to produce a specific output
|
||||
* or an empty <code>String</code> if there is no special flag. For example, the
|
||||
* GCC tools use the '-o' flag to produce a named output, for example
|
||||
* gcc -c foo.c -o foo.o
|
||||
*
|
||||
* @param outputExt
|
||||
* @return
|
||||
*/
|
||||
public String getOutputFlag(String outputExt);
|
||||
|
||||
/**
|
||||
* Answers the prefix that should be prepended to the name of the build
|
||||
* artifact. For example, a library foo, should have the prefix 'lib' and
|
||||
* the extension '.a', so the final goal would be 'libfoo.a'
|
||||
*
|
||||
* @param extension
|
||||
* @return
|
||||
*/
|
||||
public String getOutputPrefix(String outputExtension);
|
||||
|
||||
/**
|
||||
* Get the currently selected target. This is used while the project
|
||||
* property pages are displayed
|
||||
*
|
||||
* @return target
|
||||
*/
|
||||
public ITarget getSelectedTarget();
|
||||
|
||||
/**
|
||||
* Get the target specified in the argument.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public ITarget getTarget(String id);
|
||||
|
||||
/**
|
||||
* Get all of the targets associated with the receiver.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List getTargets();
|
||||
|
||||
/**
|
||||
* Returns a <code>String</code> containing the command-line invocation
|
||||
* for the tool associated with the source extension.
|
||||
*
|
||||
* @param extension the file extension of the file to be built
|
||||
* @return String
|
||||
* @param sourceExtension the file extension of the file to be built
|
||||
* @return a String containing the command line invocation for the tool
|
||||
*/
|
||||
public String getToolForSource(String extension);
|
||||
public String getToolForSource(String sourceExtension);
|
||||
|
||||
/**
|
||||
* Returns a <code>String</code> containing the command-line invocation
|
||||
* for the tool associated with the target extension.
|
||||
*
|
||||
* @param extension
|
||||
* @return
|
||||
* @param extension the file extension of the build goal
|
||||
* @return a String containing the command line invocation for the tool
|
||||
*/
|
||||
public String getToolForTarget(String extension);
|
||||
|
||||
|
@ -204,26 +220,10 @@ public interface IManagedBuildInfo {
|
|||
|
||||
/**
|
||||
* Answers the version of the build information in the format
|
||||
* @return
|
||||
* @return a <code>String</code> containing the build information
|
||||
* version
|
||||
*/
|
||||
public String getVersion();
|
||||
|
||||
|
||||
/**
|
||||
* Answers whether the receiver has been changed and requires the
|
||||
* project to be rebuilt. When a project is first created, it is
|
||||
* assumed that the user will need it to be fully rebuilt. However
|
||||
* only option and tool command changes will trigger the build
|
||||
* information for an existing project to require a rebuild.
|
||||
* <p>
|
||||
* Clients can reset the state to force or clear the rebuild status
|
||||
* using <code>setRebuildState()</code>
|
||||
* @see ManagedBuildInfo#setRebuildState(boolean)
|
||||
*
|
||||
* @return <code>true</code> if the resource managed by the
|
||||
* receiver needs to be rebuilt
|
||||
*/
|
||||
public boolean needsRebuild();
|
||||
|
||||
/**
|
||||
* Answers true if the build model has been changed by the user.
|
||||
|
@ -241,14 +241,24 @@ 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.
|
||||
* Answers whether the receiver has been changed and requires the
|
||||
* project to be rebuilt. When a project is first created, it is
|
||||
* assumed that the user will need it to be fully rebuilt. However
|
||||
* only option and tool command changes will trigger the build
|
||||
* information for an existing project to require a rebuild.
|
||||
* <p>
|
||||
* Clients can reset the state to force or clear the rebuild status
|
||||
* using <code>setRebuildState()</code>
|
||||
* @see ManagedBuildInfo#setRebuildState(boolean)
|
||||
*
|
||||
* @param isDirty
|
||||
* @return <code>true</code> if the resource managed by the
|
||||
* receiver needs to be rebuilt
|
||||
*/
|
||||
public void setDirty(boolean isDirty);
|
||||
public boolean needsRebuild();
|
||||
|
||||
public void removeTarget(String id);
|
||||
|
||||
/**
|
||||
* Set the primary configuration for the receiver.
|
||||
|
@ -259,6 +269,7 @@ public interface IManagedBuildInfo {
|
|||
public void setDefaultConfiguration(IConfiguration configuration);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param configuration
|
||||
* @return
|
||||
*/
|
||||
|
@ -271,6 +282,13 @@ public interface IManagedBuildInfo {
|
|||
*/
|
||||
public void setDefaultTarget(ITarget target);
|
||||
|
||||
/**
|
||||
* Set the dirty flag for the build model to the value of the argument.
|
||||
*
|
||||
* @param isDirty
|
||||
*/
|
||||
public void setDirty(boolean isDirty);
|
||||
|
||||
/**
|
||||
* Sets the rebuild state in the receiver to the value of the argument.
|
||||
* This is a potentially expensive option, so setting it to true should
|
||||
|
@ -282,18 +300,10 @@ public interface IManagedBuildInfo {
|
|||
public void setRebuildState(boolean rebuild);
|
||||
|
||||
/**
|
||||
* Set the currently selected target. This is used while the project
|
||||
* Set the currently selected target. This is used while the project
|
||||
* property pages are displayed
|
||||
*
|
||||
* @param target
|
||||
* @param target the user selection
|
||||
*/
|
||||
public void setSelectedTarget(ITarget target);
|
||||
|
||||
/**
|
||||
* Get the currently selected target. This is used while the project
|
||||
* property pages are displayed
|
||||
*
|
||||
* @return target
|
||||
*/
|
||||
public ITarget getSelectedTarget();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.core;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
|
@ -117,6 +118,17 @@ public interface ITarget extends IBuildObject {
|
|||
*/
|
||||
public String getDefaultExtension();
|
||||
|
||||
/**
|
||||
* Answers a class instance that implements an interface to generate
|
||||
* source-level dependencies for the tool specified in the argument.
|
||||
* This method may return <code>null</code> in which case, the receiver
|
||||
* should assume that the tool does not require dependency information
|
||||
* when the project is built.
|
||||
*
|
||||
* @param toolId
|
||||
* @return
|
||||
*/
|
||||
public IManagedDependencyGenerator getDependencyGenerator(String toolId);
|
||||
|
||||
/**
|
||||
* Answers the command line arguments to pass to the make utility used
|
||||
|
@ -162,12 +174,12 @@ public interface ITarget extends IBuildObject {
|
|||
*/
|
||||
public String[] getTargetOSList();
|
||||
|
||||
/**
|
||||
* Answers an array of architectures the target can be created on.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getTargetArchList();
|
||||
/**
|
||||
* Answers an array of architectures the target can be created on.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getTargetArchList();
|
||||
|
||||
/**
|
||||
* Returns the list of platform specific tools associated with this
|
||||
|
@ -229,7 +241,7 @@ public interface ITarget extends IBuildObject {
|
|||
/**
|
||||
* Removes the configuration with the ID specified in the argument.
|
||||
*
|
||||
* @param id
|
||||
* @param id
|
||||
*/
|
||||
public void removeConfiguration(String id);
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ 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.Tool;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -88,6 +89,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
|
||||
// This is the version of the manifest and project files that
|
||||
private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(2, 0, 0);
|
||||
private static Map depCalculatorsMap;
|
||||
private static boolean extensionTargetsLoaded = false;
|
||||
private static Map extensionTargetMap;
|
||||
private static List extensionTargets;
|
||||
|
@ -136,6 +138,69 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
return targets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers an instance of a class that implements the
|
||||
* <code>IManagedDependencyGenerator</code> interface to generate
|
||||
* the source-level dependencies that make utilities rely on to
|
||||
* properly rebuild projects
|
||||
*
|
||||
* @param toolId the unique <code>ID</code> of the tool to look for
|
||||
* @return the dependency generator for the tool specified in the argument or <code>null</code>
|
||||
*/
|
||||
public static IManagedDependencyGenerator getDependencyGenerator(String toolId) {
|
||||
return (IManagedDependencyGenerator) getExtensionDepCalcMap().get(toolId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param toolId
|
||||
* @return
|
||||
*/
|
||||
public static IManagedDependencyGenerator createDependencyGenerator(String toolId) {
|
||||
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(ITool.TOOL_ELEMENT_NAME)) {
|
||||
if (element.getAttribute(ITool.ID).equals(toolId)) {
|
||||
if (element.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
|
||||
return (IManagedDependencyGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
|
||||
}
|
||||
}
|
||||
} else if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME)) {
|
||||
IConfigurationElement[] children = element.getChildren(ITool.TOOL_ELEMENT_NAME);
|
||||
for (int k = 0; k < children.length; ++k) {
|
||||
IConfigurationElement child = children[k];
|
||||
if (child.getAttribute(ITool.ID).equals(toolId)) {
|
||||
if (child.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
|
||||
return (IManagedDependencyGenerator) child.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CoreException e) {
|
||||
// Probably not defined
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static Map getExtensionDepCalcMap() {
|
||||
if (depCalculatorsMap == null) {
|
||||
depCalculatorsMap = new HashMap();
|
||||
}
|
||||
return depCalculatorsMap;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Safe accessor for the map of IDs to Targets
|
||||
*
|
||||
|
@ -247,6 +312,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetId
|
||||
* @return
|
||||
*/
|
||||
public static IManagedBuilderMakefileGenerator getMakefileGenerator(String targetId) {
|
||||
try {
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
|
@ -555,10 +624,17 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a tool that is is specified in the manifest to the
|
||||
* build system. This tool is available to any target that
|
||||
* has a reference to it as part of its description. This
|
||||
* permits a tool that is common to many targets to be defined
|
||||
* only once.
|
||||
*
|
||||
* @param tool
|
||||
*/
|
||||
public static void addExtensionTool(Tool tool) {
|
||||
getExtensionToolMap().put(tool.getId(), tool);
|
||||
getExtensionDepCalcMap().put(tool.getId(), createDependencyGenerator(tool.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -609,7 +685,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
ManagedBuilderCorePlugin.log(e);
|
||||
return new Status(IStatus.ERROR,
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
-1,
|
||||
IStatus.ERROR,
|
||||
e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
|
@ -628,6 +704,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
* @throws CoreException
|
||||
*/
|
||||
private static void initBuildInfoContainer(ManagedBuildInfo info) throws CoreException {
|
||||
if (info == null) {
|
||||
throw new CoreException(new Status(IStatus.ERROR,
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
IStatus.ERROR,
|
||||
new String(),
|
||||
null));
|
||||
}
|
||||
// Now associate the path entry container with the project
|
||||
ICProject cProject = info.getCProject();
|
||||
// This does not block the workspace or trigger delta events
|
||||
|
@ -901,6 +984,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
// Nothing in session store, so see if we can load it from cdtbuild
|
||||
if (buildInfo == null && resource instanceof IProject) {
|
||||
buildInfo = loadBuildInfo((IProject)resource);
|
||||
// Make sure there was no error
|
||||
|
||||
try {
|
||||
// Check if the project needs its container initialized
|
||||
initBuildInfoContainer(buildInfo);
|
||||
|
|
|
@ -31,7 +31,7 @@ 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.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
|
@ -326,7 +326,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
* @param toolId
|
||||
* @return
|
||||
*/
|
||||
public IManagedBuilderDependencyCalculator getDependencyCalculator(String toolId) {
|
||||
public IManagedDependencyGenerator getDependencyCalculator(String toolId) {
|
||||
try {
|
||||
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ManagedBuilderCorePlugin.DEP_CALC_ID);
|
||||
if (extension != null) {
|
||||
|
@ -339,7 +339,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
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);
|
||||
return (IManagedDependencyGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
/**********************************************************************
|
||||
* Copyright (c) 2002,2004 Rational Software Corporation and others.
|
||||
* Copyright (c) 2002,2004 IBM Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.internal.core;
|
|||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* **********************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -38,6 +37,7 @@ import org.eclipse.cdt.managedbuilder.core.ITarget;
|
|||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -49,15 +49,17 @@ import org.w3c.dom.Document;
|
|||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||
|
||||
// Local variables
|
||||
public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
|
||||
public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
|
||||
private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultConfig"); //$NON-NLS-1$
|
||||
private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultTarget"); //$NON-NLS-1$
|
||||
// The path container used for all managed projects
|
||||
public static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$
|
||||
private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultConfig"); //$NON-NLS-1$
|
||||
private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultTarget"); //$NON-NLS-1$
|
||||
public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
|
||||
public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
|
||||
|
||||
private boolean containerCreated;
|
||||
private ICProject cProject;
|
||||
|
@ -69,8 +71,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
private IResource owner;
|
||||
private boolean rebuildNeeded;
|
||||
private ITarget selectedTarget;
|
||||
private Map targetMap;
|
||||
private List targetList;
|
||||
private Map targetMap;
|
||||
private String version;
|
||||
|
||||
|
||||
|
@ -91,7 +93,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
rebuildNeeded = true;
|
||||
|
||||
// The id of the default target from the project persistent settings store
|
||||
IProject project = (IProject)owner;
|
||||
IProject project = owner.getProject();
|
||||
defaultTargetId = null;
|
||||
try {
|
||||
defaultTargetId = project.getPersistentProperty(defaultTargetProperty);
|
||||
|
@ -119,6 +121,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
*/
|
||||
public ManagedBuildInfo(IResource owner, Element element) {
|
||||
this(owner);
|
||||
|
||||
// Container has already been created for this project
|
||||
containerCreated = true;
|
||||
|
||||
|
@ -159,17 +162,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
|
||||
*/
|
||||
public void setRebuildState(boolean rebuild) {
|
||||
Iterator iter = getTargets().listIterator();
|
||||
while (iter.hasNext()) {
|
||||
((ITarget)iter.next()).setRebuildState(rebuild);
|
||||
}
|
||||
rebuildNeeded = rebuild;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getBuildArtifactExtension()
|
||||
|
@ -196,10 +188,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return name;
|
||||
}
|
||||
|
||||
public ICProject getCProject() {
|
||||
return cProject;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
|
||||
*/
|
||||
|
@ -236,6 +224,10 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return (String[])configNames.toArray(new String[configNames.size()]);
|
||||
}
|
||||
|
||||
public ICProject getCProject() {
|
||||
return cProject;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @return Returns the map of ITarget ids to IConfigurations.
|
||||
|
@ -343,15 +335,46 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return symbols;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getDependencyGenerator(java.lang.String)
|
||||
*/
|
||||
public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension) {
|
||||
// Find the tool and ask the target for its dep generator
|
||||
try {
|
||||
ITarget target = getDefaultTarget();
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; ++index) {
|
||||
if(tools[index].buildsFileType(sourceExtension)) {
|
||||
return target.getDependencyGenerator(tools[index].getId());
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Helper method to extract a list of valid tools that are filtered by the
|
||||
* project nature.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ITool[] getFilteredTools() {
|
||||
// Get all the tools for the current config filtered by the project nature
|
||||
IProject project = owner.getProject();
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
return config.getFilteredTools(project);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForSource(java.lang.String)
|
||||
*/
|
||||
public String getFlagsForSource(String extension) {
|
||||
IProject project = (IProject)owner;
|
||||
|
||||
// Get all the tools for the current config
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
if (tool != null && tool.buildsFileType(extension)) {
|
||||
|
@ -369,13 +392,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFlags(java.lang.String)
|
||||
*/
|
||||
public String getFlagsForTarget(String extension) {
|
||||
IProject project = (IProject)owner;
|
||||
// Treat null extensions as an empty string
|
||||
String ext = extension == null ? new String() : extension;
|
||||
|
||||
// Get all the tools for the current config
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
if (tool.producesFileType(ext)) {
|
||||
|
@ -459,37 +480,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return (String[])paths.toArray(new String[paths.size()]);
|
||||
}
|
||||
|
||||
private HashMap getMacroPathEntries() {
|
||||
HashMap macros = new HashMap();
|
||||
if (cProject != null) {
|
||||
try {
|
||||
IPathEntry[] entries = cProject.getResolvedPathEntries();
|
||||
for (int index = 0; index < entries.length; ++index) {
|
||||
if (entries[index].getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||
IMacroEntry macro = (IMacroEntry) entries[index];
|
||||
macros.put(macro.getMacroName(), macro.getMacroValue());
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
// return an empty map
|
||||
macros.clear();
|
||||
return macros;
|
||||
}
|
||||
|
||||
}
|
||||
return macros;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForTarget(java.lang.String)
|
||||
*/
|
||||
public String[] getLibsForTarget(String extension) {
|
||||
IProject project = (IProject)owner;
|
||||
|
||||
Vector libs = new Vector();
|
||||
// Get all the tools for the current config
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
if (tool.producesFileType(extension)) {
|
||||
|
@ -515,6 +511,27 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return (String[])libs.toArray(new String[libs.size()]);
|
||||
}
|
||||
|
||||
private HashMap getMacroPathEntries() {
|
||||
HashMap macros = new HashMap();
|
||||
if (cProject != null) {
|
||||
try {
|
||||
IPathEntry[] entries = cProject.getResolvedPathEntries();
|
||||
for (int index = 0; index < entries.length; ++index) {
|
||||
if (entries[index].getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||
IMacroEntry macro = (IMacroEntry) entries[index];
|
||||
macros.put(macro.getMacroName(), macro.getMacroValue());
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
// return an empty map
|
||||
macros.clear();
|
||||
return macros;
|
||||
}
|
||||
|
||||
}
|
||||
return macros;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
|
||||
*/
|
||||
|
@ -533,12 +550,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputExtension(java.lang.String)
|
||||
*/
|
||||
public String getOutputExtension(String resourceExtension) {
|
||||
IProject project = (IProject)owner;
|
||||
String outputExtension = null;
|
||||
|
||||
// Get all the tools for the current config
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
outputExtension = tool.getOutputExtension(resourceExtension);
|
||||
|
@ -553,14 +566,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputFlag()
|
||||
*/
|
||||
public String getOutputFlag(String outputExt) {
|
||||
IProject project = (IProject)owner;
|
||||
// Treat null extension as an empty string
|
||||
String ext = outputExt == null ? new String() : outputExt;
|
||||
|
||||
// Get all the tools for the current config
|
||||
String flags = new String();
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
// It's OK
|
||||
|
@ -575,14 +586,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputPrefix(java.lang.String)
|
||||
*/
|
||||
public String getOutputPrefix(String outputExtension) {
|
||||
IProject project = (IProject)owner;
|
||||
// Treat null extensions as empty string
|
||||
String ext = outputExtension == null ? new String() : outputExtension;
|
||||
|
||||
// Get all the tools for the current config
|
||||
String flags = new String();
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
if (tool.producesFileType(ext)) {
|
||||
|
@ -599,6 +608,13 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
return owner;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedTarget()
|
||||
*/
|
||||
public ITarget getSelectedTarget() {
|
||||
return selectedTarget;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
|
||||
*/
|
||||
|
@ -631,15 +647,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForSource(java.lang.String)
|
||||
*/
|
||||
public String getToolForSource(String extension) {
|
||||
IProject project = (IProject)owner;
|
||||
|
||||
public String getToolForSource(String sourceExtension) {
|
||||
// Get all the tools for the current config
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
if (tool.buildsFileType(extension)) {
|
||||
if (tool.buildsFileType(sourceExtension)) {
|
||||
return tool.getToolCommand();
|
||||
}
|
||||
}
|
||||
|
@ -650,13 +663,10 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolInvocation(java.lang.String)
|
||||
*/
|
||||
public String getToolForTarget(String extension) {
|
||||
IProject project = (IProject)owner;
|
||||
|
||||
// Treat a null argument as an empty string
|
||||
String ext = extension == null ? new String() : extension;
|
||||
// Get all the tools for the current config
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
if (tool.producesFileType(ext)) {
|
||||
|
@ -670,11 +680,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getUserObjectsForTarget(java.lang.String)
|
||||
*/
|
||||
public String[] getUserObjectsForTarget(String extension) {
|
||||
IProject project = (IProject)owner;
|
||||
Vector objs = new Vector();
|
||||
// Get all the tools for the current config
|
||||
IConfiguration config = getDefaultConfiguration(getDefaultTarget());
|
||||
ITool[] tools = config.getFilteredTools(project);
|
||||
ITool[] tools = getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tool = tools[index];
|
||||
// The tool is OK for this project nature
|
||||
|
@ -702,6 +710,18 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
*/
|
||||
private void initializePathEntries() {
|
||||
try {
|
||||
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
|
||||
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
|
||||
} catch (CModelException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isDirty()
|
||||
|
@ -792,7 +812,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
}
|
||||
}
|
||||
// Persist the default configurations
|
||||
IProject project = (IProject) getOwner();
|
||||
IProject project = owner.getProject();
|
||||
try {
|
||||
project.setPersistentProperty(defaultConfigProperty, defaultConfigs.toString().trim());
|
||||
} catch (CoreException e) {
|
||||
|
@ -805,7 +825,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
*/
|
||||
private void persistDefaultTarget() {
|
||||
// Persist the default target as a project setting
|
||||
IProject project = (IProject) getOwner();
|
||||
IProject project = owner.getProject();
|
||||
ITarget defTarget = getDefaultTarget();
|
||||
if (defTarget != null){
|
||||
try {
|
||||
|
@ -815,18 +835,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
*/
|
||||
private void initializePathEntries() {
|
||||
try {
|
||||
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
|
||||
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
|
||||
} catch (CModelException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#removeTarget(java.lang.String)
|
||||
|
@ -925,20 +933,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedTarget(org.eclipse.cdt.core.build.managed.ITarget)
|
||||
*/
|
||||
public void setSelectedTarget(ITarget target) {
|
||||
selectedTarget = target;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedTarget()
|
||||
*/
|
||||
public ITarget getSelectedTarget() {
|
||||
return selectedTarget;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setDirty(boolean)
|
||||
|
@ -954,6 +948,24 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
|
||||
*/
|
||||
public void setRebuildState(boolean rebuild) {
|
||||
Iterator iter = getTargets().listIterator();
|
||||
while (iter.hasNext()) {
|
||||
((ITarget)iter.next()).setRebuildState(rebuild);
|
||||
}
|
||||
rebuildNeeded = rebuild;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedTarget(org.eclipse.cdt.core.build.managed.ITarget)
|
||||
*/
|
||||
public void setSelectedTarget(ITarget target) {
|
||||
selectedTarget = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,13 +10,14 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IManagedBuilderDependencyCalculator {
|
||||
public interface IManagedDependencyGenerator {
|
||||
public int TYPE_NODEPS = 0;
|
||||
public int TYPE_COMMAND = 1;
|
||||
public int TYPE_INDEXER = 2;
|
||||
|
@ -24,5 +25,5 @@ public interface IManagedBuilderDependencyCalculator {
|
|||
|
||||
public IResource[] findDependencies(IResource resource, IProject project);
|
||||
public int getCalculatorType();
|
||||
public String getDependencyCommand();
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
|
||||
}
|
|
@ -10,14 +10,18 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultGCCDependencyCalculator implements IManagedBuilderDependencyCalculator {
|
||||
public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
|
@ -35,9 +39,75 @@ public class DefaultGCCDependencyCalculator implements IManagedBuilderDependency
|
|||
/* (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$
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
/*
|
||||
* For a given input, <path>/<resource_name>.<ext>, return a string containing
|
||||
* echo -n $(@:%.<out_ext>=%.d) '<path>/' >> $(@:%.<out_ext>=%.d) && \
|
||||
* <tool_command> -P -MM -MG <tool_flags> $< >> $(@:%.<out_ext>=%.d)
|
||||
*
|
||||
*/
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
// Get what we need to create the dependency generation command
|
||||
String inputExtension = resource.getFileExtension();
|
||||
String cmd = info.getToolForSource(inputExtension);
|
||||
String outputExtension = info.getOutputExtension(inputExtension);
|
||||
String buildFlags = info.getFlagsForSource(inputExtension);
|
||||
|
||||
// Work out the build-relative path
|
||||
IContainer resourceLocation = resource.getParent();
|
||||
String relativePath = new String();
|
||||
if (resourceLocation != null) {
|
||||
relativePath += resourceLocation.getProjectRelativePath().toString();
|
||||
}
|
||||
if (relativePath.length() > 0) {
|
||||
relativePath += IManagedBuilderMakefileGenerator.SEPARATOR;
|
||||
}
|
||||
|
||||
// Calculate the dependency rule
|
||||
// <path>/$(@:%.<out_ext>=%.d)
|
||||
String depRule = "$(@:%." + //$NON-NLS-1$
|
||||
outputExtension +
|
||||
"=%." + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.DEP_EXT +
|
||||
")"; //$NON-NLS-1$
|
||||
|
||||
// Add the rule that will actually create the right format for the dep
|
||||
buffer.append(IManagedBuilderMakefileGenerator.TAB +
|
||||
IManagedBuilderMakefileGenerator.ECHO +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-n" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.SINGLE_QUOTE +
|
||||
relativePath +
|
||||
IManagedBuilderMakefileGenerator.SINGLE_QUOTE +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.LOGICAL_AND +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.LINEBREAK);
|
||||
|
||||
// Add the line that will do the work
|
||||
buffer.append(IManagedBuilderMakefileGenerator.TAB +
|
||||
cmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-MM -MG -P -w" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
buildFlags +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.IN_MACRO +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">>" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
depRule);
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ import java.util.Vector;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.internal.core.model.Util;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
|
@ -205,7 +205,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
|
||||
// Local variables needed by generator
|
||||
private String buildTargetName;
|
||||
private ITarget defaultTarget;
|
||||
private Vector buildTools;
|
||||
private Vector deletedFileList;
|
||||
private Vector dependencyMakefiles;
|
||||
private String extension;
|
||||
|
@ -319,9 +319,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
String outputExtension = info.getOutputExtension(inputExtension);
|
||||
String outflag = null;
|
||||
String outputPrefix = null;
|
||||
IManagedDependencyGenerator depGen = info.getDependencyGenerator(inputExtension);
|
||||
boolean doDepGen = (depGen != null && depGen.getCalculatorType() == IManagedDependencyGenerator.TYPE_COMMAND);
|
||||
|
||||
// If the tool creates a dependency file, add it to the list
|
||||
if (true) {
|
||||
if (doDepGen) {
|
||||
String depFile = relativePath + resourceName + DOT + DEP_EXT;
|
||||
getDependencyMakefiles().add(depFile);
|
||||
}
|
||||
|
@ -345,14 +347,12 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE);
|
||||
buffer.append(TAB + AT + buildCmd);
|
||||
|
||||
// TODO determine if there are any deps to calculate
|
||||
if (true) {
|
||||
// determine if there are any deps to calculate
|
||||
if (doDepGen && depGen.getCalculatorType() == IManagedDependencyGenerator.TYPE_COMMAND) {
|
||||
buffer.append(WHITESPACE + LOGICAL_AND + WHITESPACE + LINEBREAK);
|
||||
// TODO get the dep rule out of the tool
|
||||
String depRule = "$(@:%." + outputExtension + "=%." + DEP_EXT + ")";
|
||||
buffer.append(TAB + ECHO + WHITESPACE + "-n" + WHITESPACE + depRule + WHITESPACE + SINGLE_QUOTE + relativePath + SINGLE_QUOTE + WHITESPACE + ">" + WHITESPACE + depRule + WHITESPACE + LOGICAL_AND + WHITESPACE + LINEBREAK); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
buffer.append(TAB + cmd + WHITESPACE + "-MM -MG -P -w" + WHITESPACE + buildFlags + WHITESPACE + IN_MACRO + WHITESPACE + ">>" + WHITESPACE + depRule); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// get the dep rule out of the generator
|
||||
String depCmd = depGen.getDependencyCommand(resource, info);
|
||||
buffer.append(depCmd);
|
||||
}
|
||||
|
||||
// Say goodbye to the nice user
|
||||
|
@ -375,9 +375,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
String relativePath = moduleRelativePath.toString();
|
||||
relativePath += relativePath.length() == 0 ? "" : SEPARATOR; //$NON-NLS-1$
|
||||
|
||||
// get the list of tools associated with our target
|
||||
ITool toolArray[] = defaultTarget.getTools();
|
||||
|
||||
// For each tool for the target, lookup the kinds of sources it can handle and
|
||||
// create a map which will map its extension to a string which holds its list of sources.
|
||||
HashMap extensionToRuleStringMap = new HashMap();
|
||||
|
@ -386,8 +383,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
Set outputExtensionsSet = getOutputExtentions();
|
||||
|
||||
// put in rules if the file type is not a generated file
|
||||
for(int k = 0; k < toolArray.length; k++) {
|
||||
List extensionsList = toolArray[k].getInputExtensions();
|
||||
Iterator iter = buildTools.iterator();
|
||||
while(iter.hasNext()) {
|
||||
List extensionsList = ((ITool)iter.next()).getInputExtensions();
|
||||
// iterate over all extensions that the tool knows how to handle
|
||||
Iterator exListIterator = extensionsList.iterator();
|
||||
while(exListIterator.hasNext()) {
|
||||
|
@ -935,7 +933,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
/* (non-Javadoc)
|
||||
* @return
|
||||
*/
|
||||
private Vector getDeletedFileList() {
|
||||
|
@ -945,7 +943,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
return deletedFileList;
|
||||
}
|
||||
|
||||
/**
|
||||
/* (non-Javadoc)
|
||||
* @return
|
||||
*/
|
||||
private Vector getDependencyMakefiles() {
|
||||
|
@ -955,7 +953,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
return dependencyMakefiles;
|
||||
}
|
||||
|
||||
/**
|
||||
/* (non-Javadoc)
|
||||
* Strips off the file extension from the argument and returns
|
||||
* the name component in a <code>String</code>
|
||||
*
|
||||
|
@ -1017,9 +1015,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
*/
|
||||
protected Set getOutputExtentions() {
|
||||
if (outputExtensionsSet == null) {
|
||||
// Get the list of tools associated with our target
|
||||
ITool toolArray[] = defaultTarget.getTools();
|
||||
|
||||
// The set of output extensions which will be produced by this tool.
|
||||
// It is presumed that this set is not very large (likely < 10) so
|
||||
// a HashSet should provide good performance.
|
||||
|
@ -1027,8 +1022,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
|
||||
// For each tool for the target, lookup the kinds of sources it outputs
|
||||
// and add that to our list of output extensions.
|
||||
for(int k = 0; k < toolArray.length; k++) {
|
||||
String[] outputs = toolArray[k].getOutputExtensions();
|
||||
Iterator iter = buildTools.iterator();
|
||||
while(iter.hasNext()) {
|
||||
String[] outputs = ((ITool)iter.next()) .getOutputExtensions();
|
||||
outputExtensionsSet.addAll(Arrays.asList(outputs));
|
||||
}
|
||||
}
|
||||
|
@ -1079,10 +1075,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
if (extension == null) {
|
||||
extension = new String();
|
||||
}
|
||||
defaultTarget = info.getDefaultTarget();
|
||||
// Cache the build tools
|
||||
buildTools = new Vector(Arrays.asList(info.getDefaultTarget().getTools()));
|
||||
}
|
||||
|
||||
/**
|
||||
/* (non-Javadoc)
|
||||
* Answers <code>true</code> if the argument is found in a generated container
|
||||
* @param resource
|
||||
* @return boolean
|
||||
|
@ -1274,7 +1271,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
Util.save(makeBuf, modMakefile);
|
||||
}
|
||||
|
||||
/**
|
||||
/* (non-Javadoc)
|
||||
* The makefile generator "knows" about source files participating in the
|
||||
* the build. It does not keep track of the targets that the build produces.
|
||||
* Instead, it keeps a set of transformation macros that it supplies to the
|
||||
|
@ -1316,17 +1313,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
// which says that B depends on A.
|
||||
// TODO Handle dependencies for complex chains of the form A->B->C
|
||||
|
||||
// get the list of tools associated with our target
|
||||
ITool toolArray[] = defaultTarget.getTools();
|
||||
|
||||
// set of input extensions for which rules have been created so far
|
||||
HashSet handledInputExtensions = new HashSet();
|
||||
|
||||
// Look at each input extension and generate an appropriate macro for that extension
|
||||
// based on whether the file is generated or not. We do not want to create rules for
|
||||
// generated files due to the current way the makefile is structured.
|
||||
for(int k = 0; k < toolArray.length; k++) {
|
||||
List extensionsList = toolArray[k].getInputExtensions();
|
||||
Iterator iter = buildTools.iterator();
|
||||
while(iter.hasNext()) {
|
||||
ITool tool = (ITool)iter.next();
|
||||
List extensionsList = tool.getInputExtensions();
|
||||
|
||||
// iterate over all extensions that the tool knows how to handle
|
||||
Iterator exListIterator = extensionsList.iterator();
|
||||
|
@ -1348,7 +1344,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
// OBJS = $(macroName1: $(ROOT)/%.input1=%.output1) ... $(macroNameN: $(ROOT)/%.inputN=%.outputN)
|
||||
objectsBuffer.append(WHITESPACE + "$(" + macroName + COLON + "$(ROOT)" + SEPARATOR + WILDCARD //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ DOT + extensionName + "=" + WILDCARD + DOT + //$NON-NLS-1$
|
||||
toolArray[k].getOutputExtension(extensionName) + ")" ); //$NON-NLS-1$
|
||||
tool.getOutputExtension(extensionName) + ")" ); //$NON-NLS-1$
|
||||
|
||||
// And another for the deps makefiles
|
||||
// DEPS = $(macroName1: $(ROOT)/%.input1=%.DEP_EXT) ... $(macroNameN: $(ROOT)/%.inputN=%.DEP_EXT)
|
||||
|
@ -1367,7 +1363,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
Util.save(macroBuffer, fileHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
/* (non-Javadoc)
|
||||
* @param fileHandle
|
||||
* @throws CoreException
|
||||
*/
|
||||
|
@ -1376,10 +1372,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
StringBuffer buffer = addDefaultHeader();
|
||||
|
||||
// Add the known macros
|
||||
ITool toolArray[] = defaultTarget.getTools();
|
||||
HashSet handledInputExtensions = new HashSet();
|
||||
for(int k = 0; k < toolArray.length; k++) {
|
||||
List extensionsList = toolArray[k].getInputExtensions();
|
||||
Iterator iter = buildTools.iterator();
|
||||
while(iter.hasNext()) {
|
||||
List extensionsList = ((ITool)iter.next()).getInputExtensions();
|
||||
Iterator exListIterator = extensionsList.iterator();
|
||||
while(exListIterator.hasNext()) {
|
||||
// create a macro of the form "EXTENSION_SRCS :="
|
||||
|
@ -1399,7 +1395,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
Util.save(buffer, fileHandle);
|
||||
}
|
||||
|
||||
/* (non-javadoc)
|
||||
/* (non-Javadoc)
|
||||
* Create the entire contents of the makefile.
|
||||
*
|
||||
* @param fileHandle The file to place the contents in.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
package org.eclipse.cdt.managedbuilder.makegen.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -21,7 +21,8 @@ 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.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
|
@ -29,7 +30,7 @@ import org.eclipse.core.resources.IWorkspaceRoot;
|
|||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultIndexerDependencyCalculator implements IManagedBuilderDependencyCalculator {
|
||||
public class DefaultIndexerDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
|
@ -79,7 +80,7 @@ public class DefaultIndexerDependencyCalculator implements IManagedBuilderDepend
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand() {
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
// There is no command
|
||||
return null;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/**********************************************************************
|
||||
* 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.internal;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
* This is the dependency calculator used by the makefile generation system when
|
||||
* nothing is defined for a tool.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultNoDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource, org.eclipse.core.resources.IProject)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
// Never answers any dependencies
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_NODEPS;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
// Never answers this call with an actual value
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -99,6 +99,7 @@
|
|||
name="%ToolName.linker.gnu.c"
|
||||
outputFlag="-o"
|
||||
command="gcc"
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
||||
id="cdt.managedbuild.tool.gnu.c.linker">
|
||||
<optionCategory
|
||||
owner="cdt.managedbuild.tool.gnu.c.linker"
|
||||
|
@ -232,6 +233,7 @@
|
|||
name="%ToolName.linker.gnu.cpp"
|
||||
outputFlag="-o"
|
||||
command="g++"
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
||||
id="cdt.managedbuild.tool.gnu.cpp.linker">
|
||||
<optionCategory
|
||||
owner="cdt.managedbuild.tool.gnu.cpp.linker"
|
||||
|
@ -358,6 +360,7 @@
|
|||
outputs="a"
|
||||
command="ar"
|
||||
outputPrefix="lib"
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
||||
id="cdt.managedbuild.tool.gnu.archiver">
|
||||
<optionCategory
|
||||
owner="cdt.managedbuild.tool.gnu.archiver"
|
||||
|
@ -372,8 +375,7 @@
|
|||
id="gnu.both.lib.option.flags">
|
||||
</option>
|
||||
</tool>
|
||||
<!-- Experimental
|
||||
<tool
|
||||
<!--tool
|
||||
command="windres"
|
||||
sources="rc"
|
||||
outputs="res"
|
||||
|
@ -435,8 +437,7 @@
|
|||
browseType="none"
|
||||
name="%Option.Posix.UndefSym"
|
||||
id="gnu.windres.option.preprocessor.undefined.symbols"/>
|
||||
</tool>
|
||||
-->
|
||||
</tool-->
|
||||
<target
|
||||
name="%TargetName.gnu"
|
||||
id="cdt.managedbuild.target.gnu"
|
||||
|
@ -1192,6 +1193,7 @@
|
|||
outputs="exe"
|
||||
id="cdt.managedbuild.tool.gnu.cpp.linker">
|
||||
</toolReference>
|
||||
<toolReference id="cdt.managedbuild.tool.gnu.windres"/>
|
||||
</target>
|
||||
<target
|
||||
name="%TargetName.cygw.so"
|
||||
|
|
Loading…
Add table
Reference in a new issue