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

Add new dependency calculator interfaces

Apply patch from bugzilla 127077 (Echo loses quotes)
Apply patch from bugzilla 128333 (Limitations for project converter support)
Fix problem in ResourceChangeHandler.sendClose when MBS project cannot be loaded
This commit is contained in:
Leo Treggiari 2006-02-23 18:04:02 +00:00
parent 373ff106c3
commit c7f73a4051
31 changed files with 22682 additions and 20994 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 Intel Corporation and others.
* Copyright (c) 2005, 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.content.IContentType;
@ -343,9 +343,9 @@ public interface IInputType extends IBuildObject {
* should assume that the input type does not require dependency information
* when the project is built.
*
* @return IManagedDependencyGenerator
* @return IManagedDependencyGeneratorType
*/
public IManagedDependencyGenerator getDependencyGenerator();
public IManagedDependencyGeneratorType getDependencyGenerator();
/**
* Returns the name of the build variable associated this this input type's resources

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2005 Rational Software Corporation and others.
* Copyright (c) 2003, 2006 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -12,7 +12,7 @@ package org.eclipse.cdt.managedbuilder.core;
import java.util.List;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.runtime.IPath;
/*
@ -192,7 +192,7 @@ public interface IManagedBuildInfo {
* @param sourceExtension
* @return
*/
public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension);
public IManagedDependencyGeneratorType getDependencyGenerator(String sourceExtension);
/**
* Returns a <code>String</code> containing the flags, including

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2005 IBM Corporation and others.
* Copyright (c) 2003, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -16,6 +16,7 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
/**
* This interface represents a utility of some sort that is used in the build process.
@ -547,9 +548,9 @@ public interface ITool extends IBuildObject, IHoldsOptions {
* when the project is built.
*
* @param sourceExt source file extension
* @return IManagedDependencyGenerator
* @return IManagedDependencyGeneratorType
*/
public IManagedDependencyGenerator getDependencyGeneratorForExtension(String sourceExt);
public IManagedDependencyGeneratorType getDependencyGeneratorForExtension(String sourceExt);
/**
* Returns an array of command line arguments that have been specified for

View file

@ -1438,4 +1438,13 @@ public class Configuration extends BuildObject implements IConfiguration {
((ResourceConfiguration)iter.next()).updateManagedBuildRevision(revision);
}
}
public void setParent(IConfiguration parent) {
if ( this.parent != parent) {
this.parent = parent;
if (!isExtensionElement())
setDirty(true);
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 Intel Corporation and others.
* Copyright (c) 2005, 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -25,7 +25,7 @@ import org.eclipse.cdt.managedbuilder.core.IInputOrder;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
@ -62,7 +62,7 @@ public class InputType extends BuildObject implements IInputType {
private Boolean multipleOfType;
private Boolean primaryInput;
private IConfigurationElement dependencyGeneratorElement = null;
private IManagedDependencyGenerator dependencyGenerator = null;
private IManagedDependencyGeneratorType dependencyGenerator = null;
// Miscellaneous
private boolean isExtensionInputType = false;
private boolean isDirty = false;
@ -874,7 +874,7 @@ public class InputType extends BuildObject implements IInputType {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyGenerator()
*/
public IManagedDependencyGenerator getDependencyGenerator() {
public IManagedDependencyGeneratorType getDependencyGenerator() {
if (dependencyGenerator != null) {
return dependencyGenerator;
}
@ -882,7 +882,7 @@ public class InputType extends BuildObject implements IInputType {
if (element != null) {
try {
if (element.getAttribute(ITool.DEP_CALC_ID) != null) {
dependencyGenerator = (IManagedDependencyGenerator) element.createExecutableExtension(ITool.DEP_CALC_ID);
dependencyGenerator = (IManagedDependencyGeneratorType) element.createExecutableExtension(ITool.DEP_CALC_ID);
return dependencyGenerator;
}
} catch (CoreException e) {}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2005 IBM Software Corporation and others.
* Copyright (c) 2002, 2006 IBM Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -53,7 +53,7 @@ import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@ -283,7 +283,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getDependencyGenerator(java.lang.String)
*/
public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension) {
public IManagedDependencyGeneratorType getDependencyGenerator(String sourceExtension) {
// Find the tool and ask the Managed Build Manager for its dep generator
try {
if (getDefaultConfiguration() != null) {

View file

@ -368,7 +368,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
*
* @return
*/
private Map getConfigurationMap() {
public Map getConfigurationMap() {
if (configMap == null) {
configMap = new HashMap();
}
@ -521,4 +521,15 @@ public class ManagedProject extends BuildObject implements IManagedProject {
cfg.updateManagedBuildRevision(revision);
}
}
public void setProjectType(IProjectType projectType) {
if ( this.projectType != projectType ) {
this.projectType = projectType;
if ( this.projectType == null) {
projectTypeId = null;
} else {
projectTypeId = this.projectType.getId();
}
}
}
}

View file

@ -1850,4 +1850,18 @@ public class Option extends BuildObject implements IOption {
isUdjusted = adjusted;
}
public void setSuperClass(IOption superClass) {
if ( this.superClass != superClass ) {
this.superClass = superClass;
if ( this.superClass == null) {
superClassId = null;
} else {
superClassId = this.superClass.getId();
}
if(!isExtensionElement())
setDirty(true);
}
}
}

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2002, 2005 Rational Software Corporation and others.
# Copyright (c) 2002, 2006 Rational Software Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@ -59,6 +59,7 @@ 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.message.start.dependency=Regenerating dependency file:
MakefileGenerator.message.no.target=No tool found that can build the extension specified with the build arrtifact name
MakefileGenerator.message.adding.source.folder=Adding folder {0} to sources
MakefileGenerator.message.gen.source.makefile=Generating makefile for source folder {0}

View file

@ -283,10 +283,13 @@ public class ResourceChangeHandler implements IResourceChangeListener, ISavePart
public void sendClose(IProject project){
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
if(info != null){
IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
IManagedProject managedProj = info.getManagedProject();
if (managedProj != null) {
IConfiguration cfgs[] = managedProj.getConfigurations();
for(int i = 0; i < cfgs.length; i++)
ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true);
for(int i = 0; i < cfgs.length; i++)
ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true);
}
}
}

View file

@ -46,6 +46,7 @@ import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IConfigurationElement;
@ -86,7 +87,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
// Superclass
// Note that superClass itself is defined in the base and that the methods
// getSuperClass() and setSuperClass(), defined in Tool must be used to
// getSuperClass() and setSuperClassInternal(), defined in Tool must be used to
// access it. This avoids widespread casts from IHoldsOptions to ITool.
private String superClassId;
// Parent and children
@ -116,7 +117,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
private IConfigurationElement commandLineGeneratorElement = null;
private IManagedCommandLineGenerator commandLineGenerator = null;
private IConfigurationElement dependencyGeneratorElement = null;
private IManagedDependencyGenerator dependencyGenerator = null;
private IManagedDependencyGeneratorType dependencyGenerator = null;
private URL iconPathURL;
// Miscellaneous
private boolean isExtensionTool = false;
@ -199,7 +200,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
public Tool(ToolChain parent, ITool superClass, String Id, String name, boolean isExtensionElement) {
super(resolvedDefault);
this.parent = parent;
setSuperClass(superClass);
setSuperClassInternal(superClass);
setManagedBuildRevision(parent.getManagedBuildRevision());
if (getSuperClass() != null) {
superClassId = getSuperClass().getId();
@ -232,7 +233,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
public Tool(ResourceConfiguration parent, ITool superClass, String Id, String name, boolean isExtensionElement) {
super(resolvedDefault);
this.parent = parent;
setSuperClass( superClass );
setSuperClassInternal( superClass );
setManagedBuildRevision(parent.getManagedBuildRevision());
if (getSuperClass() != null) {
superClassId = getSuperClass().getId();
@ -300,9 +301,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
super(resolvedDefault);
this.parent = parent;
if (toolSuperClass != null) {
setSuperClass( toolSuperClass );
setSuperClassInternal( toolSuperClass );
} else {
setSuperClass( tool.getSuperClass() );
setSuperClassInternal( tool.getSuperClass() );
}
if (getSuperClass() != null) {
superClassId = getSuperClass().getId();
@ -571,9 +572,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (superClassId != null && superClassId.length() > 0) {
if( getParent() instanceof IResourceConfiguration ) {
IResourceConfiguration resConfig = (IResourceConfiguration) getParent();
setSuperClass( resConfig.getParent().getTool(superClassId) );
setSuperClassInternal( resConfig.getParent().getTool(superClassId) );
} else {
setSuperClass( ManagedBuildManager.getExtensionTool(superClassId) );
setSuperClassInternal( ManagedBuildManager.getExtensionTool(superClassId) );
}
// Check for migration support
@ -1251,10 +1252,24 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
* Access function to set the superclass element that is defined in
* the base class.
*/
private void setSuperClass(ITool superClass) {
private void setSuperClassInternal(ITool superClass) {
this.superClass = superClass;
}
public void setSuperClass(ITool superClass) {
if ( this.superClass != superClass ) {
this.superClass = superClass;
if ( this.superClass == null) {
superClassId = null;
} else {
superClassId = this.superClass.getId();
}
if(!isExtensionElement())
setDirty(true);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getName()
*/
@ -1802,14 +1817,22 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
*/
public IManagedDependencyGenerator getDependencyGenerator() {
if (dependencyGenerator != null) {
return dependencyGenerator;
if (dependencyGenerator instanceof IManagedDependencyGenerator)
return (IManagedDependencyGenerator)dependencyGenerator;
else
return null;
}
IConfigurationElement element = getDependencyGeneratorElement();
if (element != null) {
try {
if (element.getAttribute(DEP_CALC_ID) != null) {
dependencyGenerator = (IManagedDependencyGenerator) element.createExecutableExtension(DEP_CALC_ID);
return dependencyGenerator;
dependencyGenerator = (IManagedDependencyGeneratorType) element.createExecutableExtension(DEP_CALC_ID);
if (dependencyGenerator != null) {
if (dependencyGenerator instanceof IManagedDependencyGenerator)
return (IManagedDependencyGenerator)dependencyGenerator;
else
return null;
}
}
} catch (CoreException e) {}
}
@ -1819,7 +1842,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getDependencyGeneratorForExtension()
*/
public IManagedDependencyGenerator getDependencyGeneratorForExtension(String sourceExt) {
public IManagedDependencyGeneratorType getDependencyGeneratorForExtension(String sourceExt) {
if (dependencyGenerator != null) {
return dependencyGenerator;
}
@ -1827,7 +1850,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
if (element != null) {
try {
if (element.getAttribute(DEP_CALC_ID) != null) {
dependencyGenerator = (IManagedDependencyGenerator) element.createExecutableExtension(DEP_CALC_ID);
dependencyGenerator = (IManagedDependencyGeneratorType) element.createExecutableExtension(DEP_CALC_ID);
return dependencyGenerator;
}
} catch (CoreException e) {}
@ -2381,7 +2404,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
resolved = true;
// Resolve superClass
if (superClassId != null && superClassId.length() > 0) {
setSuperClass( ManagedBuildManager.getExtensionTool(superClassId) );
setSuperClassInternal( ManagedBuildManager.getExtensionTool(superClassId) );
if (getSuperClass() == null) {
// Report error
ManagedBuildManager.OutputResolveError(
@ -2632,7 +2655,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory {
// If control comes here means that superClass
// is null.
// So, set the superClass to this tool element
setSuperClass(toolElement);
setSuperClassInternal(toolElement);
superClassId = getSuperClass().getId();
isExists = true;
break;

View file

@ -54,7 +54,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
// Superclass
// Note that superClass itself is defined in the base and that the methods
// getSuperClass() and setSuperClass(), defined in ToolChain must be used
// getSuperClass() and setSuperClassInternal(), defined in ToolChain must be used
// to access it. This avoids widespread casts from IHoldsOptions to IToolChain.
private String superClassId;
// Parent and children
@ -169,7 +169,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
public ToolChain(Configuration parent, IToolChain superClass, String Id, String name, boolean isExtensionElement) {
super(resolvedDefault);
this.parent = parent;
setSuperClass(superClass);
setSuperClassInternal(superClass);
setManagedBuildRevision(parent.getManagedBuildRevision());
if (getSuperClass() != null) {
@ -243,7 +243,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
public ToolChain(IConfiguration parent, String Id, String name, ToolChain toolChain) {
super(resolvedDefault);
this.parent = parent;
setSuperClass(toolChain.getSuperClass());
setSuperClassInternal(toolChain.getSuperClass());
if (getSuperClass() != null) {
if (toolChain.superClassId != null) {
superClassId = new String(toolChain.superClassId);
@ -480,7 +480,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
// superClass
superClassId = element.getAttribute(IProjectType.SUPERCLASS);
if (superClassId != null && superClassId.length() > 0) {
setSuperClass( ManagedBuildManager.getExtensionToolChain(superClassId) );
setSuperClassInternal( ManagedBuildManager.getExtensionToolChain(superClassId) );
// Check for migration support
checkForMigrationSupport();
}
@ -893,10 +893,24 @@ public class ToolChain extends HoldsOptions implements IToolChain {
* Access function to set the superclass element that is defined in
* the base class.
*/
private void setSuperClass(IToolChain superClass) {
private void setSuperClassInternal(IToolChain superClass) {
this.superClass = superClass;
}
public void setSuperClass(IToolChain superClass) {
if ( this.superClass != superClass ) {
this.superClass = superClass;
if ( this.superClass == null) {
superClassId = null;
} else {
superClassId = this.superClass.getId();
}
if(!isExtensionElement())
setDirty(true);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IToolChain#getName()
*/
@ -1285,7 +1299,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
resolved = true;
// Resolve superClass
if (superClassId != null && superClassId.length() > 0) {
setSuperClass(ManagedBuildManager.getExtensionToolChain(superClassId));
setSuperClassInternal(ManagedBuildManager.getExtensionToolChain(superClassId));
if (getSuperClass() == null) {
// Report error
ManagedBuildManager.OutputResolveError(
@ -1585,7 +1599,7 @@ public class ToolChain extends HoldsOptions implements IToolChain {
// If control comes here means that 'superClass' is null
// So, set the superClass to this toolChain element
setSuperClass(toolChainElement);
setSuperClassInternal(toolChainElement);
superClassId = getSuperClass().getId();
isExists = true;
break;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2005 IBM Corporation and others.
* Copyright (c) 2003, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -33,6 +33,7 @@ import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.PluginVersionIdentifier;
@ -585,6 +586,7 @@ public class ToolReference implements IToolReference {
* @param id
* @return
*/
/*
private OptionReference getOptionReference(String id) {
Iterator it = getOptionReferenceList().iterator();
while (it.hasNext()) {
@ -595,6 +597,7 @@ public class ToolReference implements IToolReference {
}
return null;
}
*/
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolReference#getOptionReferenceList()
@ -1115,7 +1118,7 @@ public class ToolReference implements IToolReference {
return null;
}
public IManagedDependencyGenerator getDependencyGeneratorForExtension(String sourceExt) {
public IManagedDependencyGeneratorType getDependencyGeneratorForExtension(String sourceExt) {
return null;
}

View file

@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.core.runtime.IPath;
/**
* @since 3.1
*
* A Tool dependency calculator may implement this interface or
* IManagedDependencyCommands or IManagedDependencyPreBuild.
* An object implementing the interface is returned from a call to
* IManagedDependencyGenerator2.getDependencySourceInfo.
*
* Discussion of Dependency Calculation:
*
* There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are:
*
* 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax.
* This type of dependency calculator implements the
* IManagedDependencyCalculator interface defined in this module.
*
* One minor mode of this mode is to use a dependency calculator provided
* by a language integration (e.g. C, C++ or Fortran) that uses the
* language's parsing support to return information regarding source file
* dependencies. An example of this is using the C/C++ Indexer to
* compute dependencies.
*
* 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. In this case, dependency calculation
* is done at "build time", rather than at "build file generation time" as
* in mode #1. This currently supports the GNU concept of using .d files
* in GNU make. See the IManagedDependencyCommands and
* IManagedDependencyPreBuild interfaces for more information.
*
*/
public interface IManagedDependencyCalculator extends IManagedDependencyInfo {
/**
* Returns the list of source file specific dependencies.
*
* The paths can be either relative to the project directory, or absolute
* in the file system.
*
* @return IPath[]
*/
public IPath[] getDependencies();
/**
* Returns the list of source file specific additional targets that the
* source file creates. Most source files will return null. An example
* of where additional targets should be returned is for a Fortran 90
* source file that creates one or more Fortran Modules.
*
* Note that these output files that are dependencies to other invocations
* of the same tool can be specified here, or as another output type
* of the tool. If the output file can be used as the input of a different
* tool, then use the output type mechanism.
*
* The paths can be either relative to the top build directory, or absolute
* in the file system.
*
* @return IPath[]
*/
public IPath[] getAdditionalTargets();
}

View file

@ -0,0 +1,168 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.core.runtime.IPath;
/**
* @since 3.1
*
* A Tool dependency calculator may implement this interface or
* IManagedDependencyCalculator or IManagedDependencyPreBuild.
* An object implementing the interface is returned from a call to
* IManagedDependencyGenerator2.getDependencySourceInfo.
*
* Discussion of Dependency Calculation:
*
* There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are:
*
* 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax.
* See the IManagedDependencyCalculator interface for more information.
*
* 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. The build file generator calls
* the dependency calculator to get the dependency file names and to get
* commands that need to be added to the build file. In this case,
* dependency calculation is done at "build time", rather than at
* "build file generation time" as in mode #1. This currently
* supports the GNU concept of using .d files in GNU make.
*
* There are multiple ways that these separate dependency files can
* be created by the tool-chain and used by the builder.
*
* a. In some cases (e.g., Fortran 90 using modules) the dependency files
* must be created/updated prior to invoking the build of the project
* artifact (e.g., an application). In this case, the dependency
* generation step must occur separately before the main build.
* See the IManagedDependencyPreBuild interface for more information.
*
* b. In other cases (e.g., C/C++) the dependency files can be created as
* a side effect of the main build. This implies that the up to date
* dependency files are not required for the current build, but for
* the next build. C/C++ builds can be treated in this manner as is
* described in the following link:
* http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
*
* Use the IManagedDependencyCommands interface defined in this file
* for this mode.
*
* Two sub-scenarios of this mode are to:
*
* Create dependency files in the same invocation of the tool that
* creates the tool's build artifact - by adding additional options
* to the tool invocation command line.
*
* Create dependency files in a separate invocation of the tool, or
* by the invocation of another tool.
*
* MBS can also help in the generation of the dependency files. Prior to
* CDT 3.1, MBS and gcc cooperated in generating dependency files using the
* following steps:
*
* 1. Gcc is invoked to perform the compilation that generates the object
* file.
*
* 2. An "echo" command creates the .d file, adding the name of the .d
* file to the beginning of the newly created .d file. Note that this
* causes problems with some implementations of "echo" that don't
* work exactly the way that we want (e.g., it doesn't support the -n
* switch).
* 3. Gcc is invoked again with the appropriate additional command line
* options to append its dependency file information to the .d file
* that was created by "echo".
*
* 4. Steps 1 - 3 are invoked in the make file. Step 4 occurs after the
* make invocation has finished. In step 4, MBS code post-processes
* the .d files to add a dummy dependency for each header file, for
* the reason explained in the link above.
*
* This mode is no longer used by the default gcc implementation, but can
* still be used by selecting the DefaultGCCDependencyCalculator.
*
*
* Note for GNU make: these separate dependency files are "include"d by
* a main makefile. Therefore, if the dependency files are required to
* be up to date before the main build begins, they must be updated by
* a separate invocation of make. Also, the configuration "clean" step
* must be invoked by a separate invocation of make. This is so that
* we can exclude the dependency files for a "make clean" invocation
* using syntax like:
*
* ifneq ($(MAKECMDGOALS), clean)
* -include $(DEPS)
* endif
*
* Otherwise, because GNU make attempts to re-make make files, we
* can end up with out of date or missing dependency files being
* re-generated and then immediately "clean"ed.
*/
public interface IManagedDependencyCommands extends IManagedDependencyInfo {
/**
* Returns the list of generated dependency files.
*
* The paths can be either relative to the top build directory, or absolute
* in the file system.
*
* @return IPath[]
*/
public IPath[] getDependencyFiles();
/**
* Returns the command lines to be invoked before the normal tool invocation
* to calculate dependencies.
*
* @return String[] This can be null or an empty array if no dependency
* generation command needs to be invoked before the normal
* tool invocation.
*/
public String[] getPreToolDependencyCommands();
/**
* Returns the command line options to be used to calculate dependencies.
* The options are added to the normal tool invocation.
*
* @return String[] This can be null or an empty array if no additional
* arguments need to be added to the tool invocation.
* SHOULD THIS RETURN AN IOption[]?
*/
public String[] getDependencyCommandOptions();
// IMPLEMENTATION NOTE: This should be called from addRuleFromSource for both resconfig & non-resconfig
/**
* Returns the command lines to be invoked after the normal tool invocation
* to calculate dependencies.
*
* @return String[] This can be null or an empty array if no dependency
* generation commands needs to be invoked after the normal
* tool invocation
*/
public String[] getPostToolDependencyCommands();
/**
* Returns true if the command lines and/or options returned by this interface
* are not specific to the particular source file, but are only specific to,
* at most, the configuration and tool. If the build context is a resource
* configuration, this method should return false if any of the command lines
* and/or options are different than if the build context were the parent
* configuration. This can be used by the build file generator in helping
* to determine if a "pattern" (generic) rule can be used.
*
* @return boolean
*/
public boolean areCommandsGeneric();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -16,20 +16,12 @@ import org.eclipse.core.resources.IResource;
/**
* @since 2.0
* @deprecated 3.1
*
* TODO: These methods should take IPath's rather than IResource's,
* because an output file from one tool can be used as an
* input file to another, and it can be generated outside of the
* project directory.
* This will require a new interface.
* Use IManagedDependencyGenerator2 instead.
*/
public interface IManagedDependencyGenerator {
public int TYPE_NODEPS = 0;
public int TYPE_COMMAND = 1;
public int TYPE_INDEXER = 2;
public int TYPE_EXTERNAL = 3;
public interface IManagedDependencyGenerator extends IManagedDependencyGeneratorType {
public IResource[] findDependencies(IResource resource, IProject project);
public int getCalculatorType();
public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -11,79 +11,104 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.core.runtime.IPath;
import org.eclipse.cdt.managedbuilder.core.ITool;
/**
* @since NOT YET
* This interface is PROPOSED and not yet used.
* @since 3.1
*
* A Tool dependency calculator must implement this interface. This interface
* replaces IManagedDependencyGenerator which is deprecated.
*
* Note: The IPath arguments to the methods below can be either relative to
* the project directory, or absolute in the file system.
* Discussion of Dependency Calculation:
*
* There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are:
*
* 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax.
* This is a TYPE_CUSTOM dependency calculator as defined below.
* See the IManagedDependencyCalculator interface for more information.
*
* 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. In this case, dependency calculation
* is done at "build time", rather than at "build file generation time" as
* in mode #1. This currently supports the GNU concept of using .d files
* in GNU make.
* This is either a TYPE_BUILD_COMMANDS dependency calculator or a
* TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
* See the IManagedDependencyCommands and IManagedDependencyPreBuild
* interfaces for more information.
*
*/
public interface IManagedDependencyGenerator2 {
/**
* Constants returned by getCalculatorType
*/
public int TYPE_NODEPS = 0;
public int TYPE_COMMAND = 1;
public int TYPE_INDEXER = 2;
public int TYPE_EXTERNAL = 3;
public interface IManagedDependencyGenerator2 extends IManagedDependencyGeneratorType {
/**
* Returns the type of dependency generator that is implemented.
*
* TYPE_NODEPS indicates a NULL dependency generator
* TYPE_COMMAND indicates that a command line will be returned to be
* used to calculate dependencies. This currently supports compilers
* that generate .d files.
* TYPE_INDEXER indicates that the CDT indexer should be used to
* calculate the dependencies.
* TYPE_EXTERNAL indicates that a custom dependency calculator is
* implemented.
*
* @return int
*/
public int getCalculatorType();
/**
* Returns the list of dependencies for this source file.
* The paths can be either relative to the project directory, or absolute
* in the file system.
* Returns an instance of IManagedDependencyInfo for this source file.
* IManagedDependencyCalculator, IManagedDependencyCommands
* and IManagedDependencyPreBuild are all derived from
* IManagedDependencyInfo, and any one of the three can be returned.
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS,
* TYPE_CUSTOM or TYPE_PREBUILD_COMMANDS.
*
* @param source The source file for which dependencies should be calculated
* @param info The IManagedBuildInfo of the project
* The IPath can be either relative to the project directory, or absolute in the file system.
* @param buildContext The IConfiguration or IResourceConfiguration that
* contains the context in which the source file will be built
* @param tool The tool associated with the source file
* @param topBuildDirectory The top build directory of the project. This is
* the working directory for the tool.
* @return IPath[]
* @param topBuildDirectory The top build directory of the configuration. This is
* the working directory for the tool. This IPath is relative to the project directory.
* @return IManagedDependencyInfo
*/
public IPath[] findDependencies(
public IManagedDependencyInfo getDependencySourceInfo(
IPath source,
IManagedBuildInfo info,
IBuildObject buildContext,
ITool tool,
IPath topBuildDirectory);
/**
* Returns the file extension used by dependency files created
* by this dependency generator.
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
* TYPE_PREBUILD_COMMANDS.
*
* Returns the command line to be used to calculate dependencies.
* This currently supports compilers that generate .d files
*
* @param source The source file for which dependencies should be calculated
* @param info The IManagedBuildInfo of the project
* @param tool The tool associated with the source file
* @param topBuildDirectory The top build directory of the project. This is
* the working directory for the tool.
* @param buildContext The IConfiguration that contains the context of the build
* @param tool The tool associated with the dependency generator.
*
* @return String
*/
public String getDependencyCommand(
IPath source,
IManagedBuildInfo info,
public String getDependencyFileExtension(
IConfiguration buildContext,
ITool tool);
/**
* Called to allow the dependency calculator to post-process dependency files.
* This method is called after the build has completed for at least every
* dependency file that has changed, and possibly for those that have not
* changed as well. It may also be called with dependency files created by
* another tool. This method should be able to recognize dependency files
* that don't belong to it, or that it has already post-processed.
* This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
* TYPE_PREBUILD_COMMANDS.
*
* @param dependencyFile The dependency file
* The IPath can be either relative to the top build directory, or absolute in the file system.
* @param buildContext The IConfiguration that contains the context of the build
* @param tool The tool associated with the dependency generator. Note that this is
* not necessarily the tool that created the dependency file
* @param topBuildDirectory The top build directory of the project. This is
* the working directory for the tool.
*
* @return boolean True if the method modified the dependency (e.g., .d) file
*/
public boolean postProcessDependencyFile(
IPath dependencyFile,
IConfiguration buildContext,
ITool tool,
IPath topBuildDirectory);
}

View file

@ -0,0 +1,87 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen;
/**
* @since 3.1
*
* IManagedDependencyGenerator (deprecated) and IManagedDependencyGenerator2
* extend this interface.
*
* Discussion of Dependency Calculation:
*
* There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are:
*
* 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax.
* This is a TYPE_CUSTOM dependency calculator as defined below.
* See the IManagedDependencyCalculator interface for more information.
*
* 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. In this case, dependency calculation
* is done at "build time", rather than at "build file generation time" as
* in mode #1. This currently supports the GNU concept of using .d files
* in GNU make.
* This is either a TYPE_BUILD_COMMANDS dependency calculator or a
* TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
* See the IManagedDependencyCommands and IManagedDependencyPreBuild
* interfaces for more information.
*
*/
public interface IManagedDependencyGeneratorType {
/**
* Constants returned by getCalculatorType
*/
public int TYPE_NODEPS = 0; // Deprecated - use TYPE_NODEPENDENCIES
public int TYPE_COMMAND = 1; // Deprecated - use TYPE_BUILD_COMMANDS
public int TYPE_INDEXER = 2; // Deprecated - use TYPE_CUSTOM
public int TYPE_EXTERNAL = 3; // Deprecated - use TYPE_CUSTOM
public int TYPE_OLD_TYPE_LIMIT = 3;
// Use these types
public int TYPE_NODEPENDENCIES = 4;
public int TYPE_BUILD_COMMANDS = 5;
public int TYPE_PREBUILD_COMMANDS = 6;
public int TYPE_CUSTOM = 7;
/**
* Returns the type of dependency generator that is implemented.
*
* TYPE_NODEPENDENCIES indicates that no dependency generator is
* supplied or needed.
* TYPE_CUSTOM indicates that a custom, "build file generation time"
* dependency calculator is implemented. Note that the dependency
* calculator will be called when the makefile is generated, and
* for every source file that is built by this tool in the build
* file, not just for those that have changed since the last build
* file generation.
* TYPE_BUILD_COMMANDS indicates that command lines or options will
* be returned to be used to calculate dependencies. These
* commands/options are added to the build file to perform dependency
* calculation at "build time". This currently supports
* compilers/tools that generate .d files either as a
* side-effect of tool invocation, or as a separate step that is
* invoked immediately before or after the tool invocation.
* TYPE_PREBUILD_COMMANDS indicates that a separate build step is
* invoked, prior to the the normal build steps, to update the
* dependency information. These commands are added to the build
* file to perform dependency calculation at "build time". Note
* that this step will be invoked every time a build is done in
* order to determine if dependency files need to be re-generated.
*
* @return int
*/
public int getCalculatorType();
}

View file

@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.core.runtime.IPath;
/**
* @since 3.1
*
* This interface is the base interface for IManagedDependencyCalculator,
* IManagedDependencyCommands and IManagedDependencyPreBuild. See these
* interfaces and IManagedDependencyGenerator2 for more information on
* writing a dependency calculator.
*
* The methods below simply return the arguments passed to the
* IManagedDependencyGenerator2.getDependency*Info call that created the
* IManagedDependencyInfo instance.
*
*/
public interface IManagedDependencyInfo {
public IPath getSource();
public IBuildObject getBuildContext();
public ITool getTool();
public IPath getTopBuildDirectory();
}

View file

@ -0,0 +1,136 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen;
import org.eclipse.core.runtime.IPath;
/**
* @since 3.1
*
* A Tool dependency calculator may implement this interface or
* IManagedDependencyCalculator or IManagedDependencyCommands.
* An object implementing the interface is returned from a call to
* IManagedDependencyGenerator2.getDependencySourceInfo.
*
* Discussion of Dependency Calculation:
*
* There are two major, and multiple minor, modes of dependency calculation
* supported by the MBS. The major modes are:
*
* 1. The build file generator invokes tool integrator provided methods
* that calculate all dependencies using whatever method the tool
* integrator wants. The build file generator then adds the dependencies
* to the build file using the appropriate build file syntax.
* See the IManagedDependencyCalculator interface for more information.
*
* 2. The build file generator and the tool-chain cooperate in creating and
* using separate "dependency" files. The build file generator calls
* the dependency calculator to get the dependency file names and to get
* commands that need to be added to the build file. In this case,
* dependency calculation is done at "build time", rather than at
* "build file generation time" as in mode #1. This currently
* supports the GNU concept of using .d files in GNU make.
*
* There are multiple ways that these separate dependency files can
* be created by the tool-chain and used by the builder.
*
* a. In some cases (e.g., Fortran 90 using modules) the dependency files
* must be created/updated prior to invoking the build of the project
* artifact (e.g., an application). In this case, the dependency
* generation step must occur separately before the main build.
* Use the IManagedDependencyPreBuild interface defined in this file
* for this mode.
*
* b. In other cases (e.g., C/C++) the dependency files can be created as
* a side effect of the main build. This implies that the up to date
* dependency files are not required for the current build, but for
* the next build. C/C++ builds can be treated in this manner as is
* described in the following link:
* http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
*
* See the IManagedDependencyCommands interface for more information.
*
*
* Note for GNU make: these separate dependency files are "include"d by
* a main makefile. Make performs special processing on make files:
*
* "To this end, after reading in all makefiles, make will consider
* each as a goal target and attempt to update it. If a makefile has a
* rule which says how to update it (found either in that very
* makefile or in another one)..., it will be updated if necessary.
* After all makefiles have been checked, if any have actually been
* changed, make starts with a clean slate and reads all the makefiles
* over again."
*
* We can use this to ensure that the dependency files are up to date
* by adding rules to the make file for generating the dependency files.
* These rules are returned by the call to getDependencyCommands.
* However, this has a significant problem when we dont want to build
* the build target, but only want to clean the configuration,
* for example. If we invoke make just to clean the configuration,
* make will still update the dependency files if necessary, thereby
* re-generating the dependency files only to immediately delete them.
* The workaround suggested by the make documentation is to check for
* an invocation using the clean target, and to not include the
* dependency files it that case. For example,
*
* ifneq ($(MAKECMDGOALS),clean)
* include $(DEPS)
* endif
*
* The restriction with this is that it only works if clean is the only
* target specified on the make command line. Therefore, the build
* "clean" step must be invoked separately.
*/
public interface IManagedDependencyPreBuild extends IManagedDependencyInfo {
/**
* Returns the list of generated dependency files.
*
* The paths can be either relative to the top build directory, or absolute
* in the file system.
*
* @return IPath[]
*/
public IPath[] getDependencyFiles();
/**
* Returns the name to be used in the build file to identify the separate
* build step. Note that this name should be unique to the tool since
* multiple tools in a tool-chain may be using this method of
* dependency calculation.
*
* @return String
*/
public String getBuildStepName();
/**
* Returns the command line(s) to be invoked in the separate
* dependencies pre-build step.
*
* @return String[]
*/
public String[] getDependencyCommands();
/**
* Returns true if the command lines returned by this interface
* are not specific to the particular source file, but are only specific to,
* at most, the configuration and tool. If the build context is a resource
* configuration, this method should return false if any of the command lines
* are different than if the build context were the parent configuration.
* This can be used by the build file generator in helping to determine if
* a "pattern" (generic) rule can be used.
*
* @return boolean
*/
public boolean areCommandsGeneric();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -0,0 +1,71 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild;
import org.eclipse.core.runtime.IPath;
/**
* This dependency calculator uses the GCC -MMD -MF -MP -MQ options in order to
* generate .d files as a side effect of compilation.
* See bugzilla 108715 for the discussion of dependency management that led to
* the creation of this dependency calculator. Note also that this technique
* exhibits the failure modes discussed in comment #5.
*
* This dependency calculator uses the class DefaultGCCDependencyCalculator2Commands
* which implements the per-source command information
*
* @since 3.1
*/
public class DefaultGCCDependencyCalculator2 implements
IManagedDependencyGenerator2 {
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
*/
public int getCalculatorType() {
return TYPE_BUILD_COMMANDS;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool)
*/
public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
return IManagedBuilderMakefileGenerator.DEP_EXT;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencySourceInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
*/
public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
return new DefaultGCCDependencyCalculator2Commands(source, buildContext, tool, topBuildDirectory);
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#postProcessDependencyFile(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
*/
public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
// Nothing
return false;
}
}

View file

@ -0,0 +1,203 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IProject;;
/**
* This dependency calculator uses the GCC -MMD -MF -MP -MQ options in order to
* generate .d files as a side effect of compilation.
* See bugzilla 108715 for the discussion of dependency management that led to
* the creation of this dependency calculator. Note also that this technique
* exhibits the failure modes discussed in comment #5.
*
* This class is used with DefaultGCCDependencyCalculator2.
*
* @since 3.1
*/
public class DefaultGCCDependencyCalculator2Commands implements
IManagedDependencyCommands {
// Member variables set by the constructor
IPath source;
IBuildObject buildContext;
ITool tool;
IPath topBuildDirectory;
// Other Member variables
IProject project;
IPath sourceLocation;
IPath outputLocation;
boolean needExplicitRuleForFile;
Boolean genericCommands = null;
/**
* Constructor
*
* @param source The source file for which dependencies should be calculated
* The IPath can be either relative to the project directory, or absolute in the file system.
* @param buildContext The IConfiguration or IResourceConfiguration that
* contains the context in which the source file will be built
* @param tool The tool associated with the source file
* @param topBuildDirectory The top build directory of the configuration. This is
* the working directory for the tool. This IPath is relative to the project directory.
*/
public DefaultGCCDependencyCalculator2Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
this.source = source;
this.buildContext = buildContext;
this.tool = tool;
this.topBuildDirectory = topBuildDirectory;
// Compute the project
if (buildContext instanceof IConfiguration) {
IConfiguration config = (IConfiguration)buildContext;
project = (IProject)config.getOwner();
} else if (buildContext instanceof IResourceConfiguration) {
IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
project = (IProject)resConfig.getOwner();
}
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
// A separate rule is needed for the resource in the case where explicit file-specific macros
// are referenced, or if the resource contains special characters in its path (e.g., whitespace)
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|| MacroResolver.getReferencedExplitFileMacros(
tool.getToolCommand(),
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation,
null, tool)).length > 0;
if (needExplicitRuleForFile) genericCommands = new Boolean(false);
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric()
*/
public boolean areCommandsGeneric() {
if (genericCommands == null) genericCommands = new Boolean(true);
return genericCommands.booleanValue();
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions()
*/
public String[] getDependencyCommandOptions() {
String[] options = new String[4];
// -MMD
options[0] = "-MMD"; //$NON-NLS-1$
// -MP
options[1] = "-MP"; //$NON-NLS-1$
// -MF$(@:%.o=%.d)
options[2] = "-MF\"$(@:%.o=%.d)\""; //$NON-NLS-1$
//options[2] = "-MF\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$
if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) {
IPath outPath = getDependencyFiles()[0];
// -MT"dependecy-file-name"
String optTxt = "-MT\""; //$NON-NLS-1$
optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$
options[3] = optTxt;
} else {
// -MT"$(@:%.o=%.d) %.o"
options[3] = "-MT\"$(@:%.o=%.d)\""; //$NON-NLS-1$
//options[3] = "-MT\"${OutputDirRelPath}${OutputFileBaseName}.d\""; //$NON-NLS-1$
}
return options;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles()
*/
public IPath[] getDependencyFiles() {
// The source file is project relative and the dependency file is top build directory relative
// Remove the source extension and add the dependency extension
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
// Remember that the source folder hierarchy and the build output folder hierarchy are the same
// but if this is a generated resource, then it may already be under the top build directory
if (!depFilePath.isAbsolute()) {
if (topBuildDirectory.isPrefixOf(depFilePath)) {
depFilePath = depFilePath.removeFirstSegments(1);
}
}
IPath[] paths = new IPath[1];
paths[0] = depFilePath;
return paths;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands()
*/
public String[] getPostToolDependencyCommands() {
// Nothing
return null;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands()
*/
public String[] getPreToolDependencyCommands() {
// Nothing
return null;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
*/
public IBuildObject getBuildContext() {
return buildContext;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
*/
public IPath getSource() {
return source;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
*/
public ITool getTool() {
return tool;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
*/
public IPath getTopBuildDirectory() {
return topBuildDirectory;
}
}

View file

@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild;
import org.eclipse.core.runtime.IPath;
/**
* This dependency calculator uses the GCC -MM -MF -MP -MQ options in order to
* generate .d files as separate step prior to the source compilations.
*
* This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands
* which implements the per-source command information
*
* @since 3.1
*/
public class DefaultGCCDependencyCalculatorPreBuild implements
IManagedDependencyGenerator2 {
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType#getCalculatorType()
*/
public int getCalculatorType() {
return TYPE_PREBUILD_COMMANDS;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencyFileExtension(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool)
*/
public String getDependencyFileExtension(IConfiguration buildContext, ITool tool) {
return IManagedBuilderMakefileGenerator.DEP_EXT;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#getDependencySourceInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
*/
public IManagedDependencyInfo getDependencySourceInfo(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
return new DefaultGCCDependencyCalculatorPreBuildCommands(source, buildContext, tool, topBuildDirectory);
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2#postProcessDependencyFile(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.core.ITool, org.eclipse.core.runtime.IPath)
*/
public boolean postProcessDependencyFile(IPath dependencyFile, IConfiguration buildContext, ITool tool, IPath topBuildDirectory) {
// Nothing
return false;
}
}

View file

@ -0,0 +1,308 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyPreBuild;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IProject;
import java.util.Vector;
/**
* This dependency calculator uses the GCC -MM -MF -MP -MT options in order to
* generate .d files as separate step prior to the source compilations.
*
* This dependency calculator uses the class DefaultGCCDependencyCalculatorPreBuildCommands
* which implements the per-source command information
*
* This class is used with DefaultGCCDependencyCalculatorPreBuild.
*
* @since 3.1
*/
public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedDependencyPreBuild {
private static final String EMPTY_STRING = new String();
// Member variables set by the constructor
IPath source;
IBuildObject buildContext;
ITool tool;
IPath topBuildDirectory;
// Other Member variables
IProject project;
IPath sourceLocation;
IPath outputLocation;
boolean needExplicitRuleForFile;
Boolean genericCommands = null;
/**
* Constructor
*
* @param source The source file for which dependencies should be calculated
* The IPath can be either relative to the project directory, or absolute in the file system.
* @param buildContext The IConfiguration or IResourceConfiguration that
* contains the context in which the source file will be built
* @param tool The tool associated with the source file
* @param topBuildDirectory The top build directory of the configuration. This is
* the working directory for the tool. This IPath is relative to the project directory.
*/
public DefaultGCCDependencyCalculatorPreBuildCommands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) {
this.source = source;
this.buildContext = buildContext;
this.tool = tool;
this.topBuildDirectory = topBuildDirectory;
// Compute the project
if (buildContext instanceof IConfiguration) {
IConfiguration config = (IConfiguration)buildContext;
project = (IProject)config.getOwner();
} else if (buildContext instanceof IResourceConfiguration) {
IResourceConfiguration resConfig = (IResourceConfiguration)buildContext;
project = (IProject)resConfig.getOwner();
}
sourceLocation = (source.isAbsolute() ? source : project.getLocation().append(source));
outputLocation = project.getLocation().append(topBuildDirectory).append(getDependencyFiles()[0]);
// A separate rule is needed for the resource in the case where explicit file-specific macros
// are referenced, or if the resource contains special characters in its path (e.g., whitespace)
needExplicitRuleForFile = GnuMakefileGenerator.containsSpecialCharacters(sourceLocation.toString()) ||
MacroResolver.getReferencedExplitFileMacros(tool).length > 0
|| MacroResolver.getReferencedExplitFileMacros(
tool.getToolCommand(),
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation, outputLocation,
null, tool)).length > 0;
if (needExplicitRuleForFile) genericCommands = new Boolean(false);
}
public boolean areCommandsGeneric() {
if (genericCommands != null) return genericCommands.booleanValue();
// If the context is a Configuration, yes
if (buildContext instanceof IConfiguration) {
genericCommands = new Boolean(true);
return true;
}
// If the context is a Resource Configuration, determine if it overrides any
// of its parent configuration's options that would affect dependency file
// generation.
// TODO
genericCommands = new Boolean(false);
return false;
}
public String getBuildStepName() {
return new String("GCC_DEPENDS"); //$NON-NLS-1$
}
public String[] getDependencyCommands() {
String[] commands = new String[1];
String depCmd = EMPTY_STRING;
// Get and resolve the command
String cmd = tool.getToolCommand();
try {
String resolvedCommand = null;
if (!needExplicitRuleForFile) {
resolvedCommand = ManagedBuildManager.getBuildMacroProvider()
.resolveValueToMakefileFormat(
cmd,
EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation,
outputLocation, null, tool));
} else {
// if we need an explicit rule then don't use any builder
// variables, resolve everything
// to explicit strings
resolvedCommand = ManagedBuildManager.getBuildMacroProvider()
.resolveValue(
cmd,
EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation,
outputLocation, null, tool));
}
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand;
} catch (BuildMacroException e) {
}
IManagedCommandLineInfo cmdLInfo = null;
// Set up the command line options that will generate the dependency file
Vector options = new Vector();
// -w
options.add("-w"); //$NON-NLS-1$
// -MM
options.add("-MM"); //$NON-NLS-1$
// -MP
options.add("-MP"); //$NON-NLS-1$
String optTxt;
if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) {
IPath outPath = getDependencyFiles()[0];
// -MT"dependecy-file-name"
optTxt = "-MT\""; //$NON-NLS-1$
optTxt += GnuMakefileGenerator.escapeWhitespaces(outPath.toString()) + "\""; //$NON-NLS-1$
options.add(optTxt);
// -MT"object-file-filename"
optTxt = "-MT\""; //$NON-NLS-1$
GnuMakefileGenerator.escapeWhitespaces((outPath.removeFileExtension()).toString());
String outExt = tool.getOutputExtension(source.getFileExtension());
if (outExt != null) optTxt += "." + outExt; //$NON-NLS-1$
optTxt += "\""; //$NON-NLS-1$
options.add(optTxt);
} else {
// -MT"$@"
options.add("-MT\"$@\""); //$NON-NLS-1$
// -MT'$(@:%.d=%.o)'
optTxt = "-MT\"$(@:%.d=%.o)\""; //$NON-NLS-1$
//optTxt = "-MT\"${OutputDirRelPath}${OutputFileBaseName}";
//if (outExt != null) optTxt += "." + outExt;
//optTxt += "\""; //$NON-NLS-1$
options.add(optTxt);
}
// Save the -I, -D, -U options and discard the rest
try {
String[] allFlags = tool.getToolCommandFlags(sourceLocation, outputLocation);
for (int i=0; i<allFlags.length; i++) {
if (allFlags[i].startsWith("-I") || //$NON-NLS-1$
allFlags[i].startsWith("-D") || //$NON-NLS-1$
allFlags[i].startsWith("-U")) { //$NON-NLS-1$
options.add(allFlags[i]);
}
}
} catch( BuildException ex ) {
}
// Call the command line generator
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
String[] flags = (String[])options.toArray(new String[options.size()]);
String[] inputs = new String[1];
inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
cmdLInfo = cmdLGen.generateCommandLineInfo(
tool, cmd, flags, "-MF", EMPTY_STRING, //$NON-NLS-1$
IManagedBuilderMakefileGenerator.OUT_MACRO,
inputs,
tool.getCommandLinePattern() );
// The command to build
if (cmdLInfo != null) {
depCmd = cmdLInfo.getCommandLine();
// resolve any remaining macros in the command after it has been
// generated
try {
String resolvedCommand;
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
if (!needExplicitRuleForFile) {
resolvedCommand = provider.resolveValueToMakefileFormat(
depCmd,
EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation,
outputLocation, null, tool));
} else {
// if we need an explicit rule then don't use any builder
// variables, resolve everything to explicit strings
resolvedCommand = provider.resolveValue(
depCmd,
EMPTY_STRING,
IManagedBuilderMakefileGenerator.WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
new FileContextData(sourceLocation,
outputLocation, null, tool));
}
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
depCmd = resolvedCommand;
} catch (BuildMacroException e) {
}
}
commands[0] = depCmd;
return commands;
}
public IPath[] getDependencyFiles() {
// The source file is project relative and the dependency file is top build directory relative
// Remove the source extension and add the dependency extension
IPath depFilePath = source.removeFileExtension().addFileExtension(IManagedBuilderMakefileGenerator.DEP_EXT);
// Remember that the source folder hierarchy and the build output folder hierarchy are the same
// but if this is a generated resource, then it may already be under the top build directory
if (!depFilePath.isAbsolute()) {
if (topBuildDirectory.isPrefixOf(depFilePath)) {
depFilePath = depFilePath.removeFirstSegments(1);
}
}
IPath[] paths = new IPath[1];
paths[0] = depFilePath;
return paths;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext()
*/
public IBuildObject getBuildContext() {
return buildContext;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource()
*/
public IPath getSource() {
return source;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool()
*/
public ITool getTool() {
return tool;
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory()
*/
public IPath getTopBuildDirectory() {
return topBuildDirectory;
}
}

View file

@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu;
import java.util.ArrayList;
/**
*
* This class contains the desciption of a group of generated dependency files,
* e.g., .d files created by compilations
*
*/
public class GnuDependencyGroupInfo {
// Member Variables
String groupBuildVar;
boolean conditionallyInclude;
ArrayList groupFiles;
// Constructor
public GnuDependencyGroupInfo(String groupName, boolean bConditionallyInclude) {
groupBuildVar = groupName;
conditionallyInclude = bConditionallyInclude;
// Note: not yet needed
groupFiles = null;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 Intel Corporation and others.
* Copyright (c) 2005, 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -90,11 +90,21 @@ public interface IManagedBuildGnuToolInfo {
/**
* Returns the tool's dependencies in command line format. This will use
* variables rather than actual file names as appropriate.
* Dependencies are top build directory relative.
*
* @return Vector
*/
public Vector getCommandDependencies();
/**
* Returns the tool's additional targets as determined by the
* dependency calculator.
* Additional targets are top build directory relative
*
* @return Vector
*/
public Vector getAdditionalTargets();
/**
* Returns the raw list of tool's input dependencies.
*

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 Intel Corporation and others.
* Copyright (c) 2005, 2006 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -20,7 +20,6 @@ import java.util.HashMap;
import java.util.HashSet;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
@ -28,12 +27,15 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCalculator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
@ -49,10 +51,6 @@ import org.eclipse.core.runtime.Path;
*/
public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
//private static final String EMPTY_STRING = new String();
//private static final String OBJS_MACRO = "OBJS"; //$NON-NLS-1$
private static final String DEPS_MACRO = "DEPS"; //$NON-NLS-1$
/*
* Members
*/
@ -72,6 +70,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
private Vector enumeratedSecondaryOutputs = new Vector();
private Vector outputVariables = new Vector();
private Vector commandDependencies = new Vector();
private Vector additionalTargets = new Vector();
//private Vector enumeratedDependencies = new Vector();
// Map of macro names (String) to values (List)
@ -134,10 +133,16 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
return dependenciesCalculated;
}
// Command dependencies are top build directory relative
public Vector getCommandDependencies() {
return commandDependencies;
}
// Additional targets are top build directory relative
public Vector getAdditionalTargets() {
return additionalTargets;
}
//public Vector getEnumeratedDependencies() {
// return enumeratedDependencies;
//}
@ -336,8 +341,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
for (int k = 0; k < paths.length; k++) {
String path = paths[k];
itEnumeratedInputs.add(path);
// Translate the path from project relative to
// build directory relative
// Translate the path from project relative to build directory relative
if (!(path.startsWith("$("))) { //$NON-NLS-1$
IResource addlResource = project.getFile(path);
if (addlResource != null) {
@ -764,10 +768,108 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
return false;
}
public boolean calculateDependencies(GnuMakefileGenerator makeGen, HashSet handledInputExtensions, boolean lastChance) {
private boolean callDependencyCalculator (GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions,
IManagedDependencyGeneratorType depGen, String[] extensionsList, Vector myCommandDependencies, HashMap myOutputMacros,
Vector myAdditionalTargets, boolean done) {
int calcType = depGen.getCalculatorType();
switch (calcType) {
case IManagedDependencyGeneratorType.TYPE_COMMAND:
case IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS:
// iterate over all extensions that the tool knows how to handle
for (int i=0; i<extensionsList.length; i++) {
String extensionName = extensionsList[i];
// Generated files should not appear in the list.
if(!makeGen.getOutputExtensions().contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
handledInputExtensions.add(extensionName);
String depExt = IManagedBuilderMakefileGenerator.DEP_EXT;
if (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS) {
IManagedDependencyGenerator2 depGen2 = (IManagedDependencyGenerator2)depGen;
String xt = depGen2.getDependencyFileExtension(config, tool);
if (xt != null && xt.length() > 0) depExt = xt;
}
String depsMacroEntry = calculateSourceMacro(makeGen, extensionName, depExt,
IManagedBuilderMakefileGenerator.WILDCARD);
List depsList = new ArrayList();
depsList.add(Path.fromOSString(depsMacroEntry));
String depsMacro = makeGen.getDepMacroName(extensionName).toString();
if (myOutputMacros.containsKey(depsMacro)) {
List currList = (List)myOutputMacros.get(depsMacro);
currList.addAll(depsList);
myOutputMacros.put(depsMacro, currList);
} else {
myOutputMacros.put(depsMacro, depsList);
}
}
}
break;
case IManagedDependencyGeneratorType.TYPE_INDEXER:
case IManagedDependencyGeneratorType.TYPE_EXTERNAL:
case IManagedDependencyGeneratorType.TYPE_CUSTOM:
// The inputs must have been calculated before we can do this
if (!inputsCalculated) {
done = false;
} else {
Vector inputs = getEnumeratedInputs();
if (calcType == IManagedDependencyGeneratorType.TYPE_CUSTOM) {
IManagedDependencyGenerator2 depGen2 = (IManagedDependencyGenerator2)depGen;
IManagedDependencyInfo depInfo = null;
for (int i=0; i<inputs.size(); i++) {
depInfo = depGen2.getDependencySourceInfo(
Path.fromOSString((String)inputs.get(i)), config, tool, makeGen.getBuildWorkingDir());
if (depInfo instanceof IManagedDependencyCalculator) {
IManagedDependencyCalculator depCalc = (IManagedDependencyCalculator)depInfo;
IPath[] depPaths = depCalc.getDependencies();
if (depPaths != null) {
for (int j=0; j<depPaths.length; j++) {
if (!depPaths[j].isAbsolute()) {
// Convert from project relative to build directory relative
IPath absolutePath = project.getLocation().append((IPath)depPaths[j]);
depPaths[j] = ManagedBuildManager.calculateRelativePath(
makeGen.getTopBuildDir(), absolutePath);
}
myCommandDependencies.add(depPaths[j].toString());
}
}
IPath[] targetPaths = depCalc.getAdditionalTargets();
if (targetPaths != null) {
for (int j=0; j<targetPaths.length; j++) {
myAdditionalTargets.add(targetPaths[j].toString());
}
}
}
}
} else {
IManagedDependencyGenerator oldDepGen = (IManagedDependencyGenerator)depGen;
for (int i=0; i<inputs.size(); i++) {
IResource[] outNames = oldDepGen.findDependencies(
project.getFile((String)inputs.get(i)), project);
if (outNames != null) {
for (int j=0; j<outNames.length; j++) {
myCommandDependencies.add(outNames[j].toString());
}
}
}
}
}
break;
default:
break;
}
return done;
}
public boolean calculateDependencies(GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions, boolean lastChance) {
// Get the dependencies for this tool invocation
boolean done = true;
Vector myCommandDependencies = new Vector();
Vector myAdditionalTargets = new Vector();
//Vector myEnumeratedDependencies = new Vector();
HashMap myOutputMacros = new HashMap();
@ -776,56 +878,13 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
for (int i=0; i<inTypes.length; i++) {
IInputType type = inTypes[i];
IManagedDependencyGenerator depGen = type.getDependencyGenerator();
// Handle dependencies from the dependencyCalculator
IManagedDependencyGeneratorType depGen = type.getDependencyGenerator();
String[] extensionsList = type.getSourceExtensions(tool);
if (depGen != null) {
int calcType = depGen.getCalculatorType();
switch (calcType) {
case IManagedDependencyGenerator.TYPE_COMMAND:
// iterate over all extensions that the tool knows how to handle
String[] extensionsList = type.getSourceExtensions(tool);
for (int j=0; j<extensionsList.length; j++) {
String extensionName = extensionsList[j];
// Generated files should not appear in the list.
if(!makeGen.getOutputExtensions().contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
handledInputExtensions.add(extensionName);
String depsMacro = calculateSourceMacro(makeGen, extensionName, IManagedBuilderMakefileGenerator.DEP_EXT,
IManagedBuilderMakefileGenerator.WILDCARD);
List depsList = new ArrayList();
depsList.add(Path.fromOSString(depsMacro));
if (myOutputMacros.containsKey(DEPS_MACRO)) {
List currList = (List)myOutputMacros.get(DEPS_MACRO);
currList.addAll(depsList);
myOutputMacros.put(DEPS_MACRO, currList);
} else {
myOutputMacros.put(DEPS_MACRO, depsList);
}
}
}
break;
case IManagedDependencyGenerator.TYPE_INDEXER:
case IManagedDependencyGenerator.TYPE_EXTERNAL:
// The inputs must have been calculated before we can do this
if (!inputsCalculated) {
done = false;
} else {
Vector inputs = getEnumeratedInputs();
for (int j=0; j<inputs.size(); j++) {
IResource[] outNames = depGen.findDependencies(project.getFile((String)inputs.get(j)), project);
if (outNames != null) {
for (int k=0; k<outNames.length; k++) {
myCommandDependencies.add(outNames[k].toString());
}
}
}
}
break;
default:
break;
}
done = callDependencyCalculator (makeGen, config, handledInputExtensions,
depGen, extensionsList, myCommandDependencies, myOutputMacros,
myAdditionalTargets, done);
}
// Add additional dependencies specified in AdditionalInput elements
@ -872,59 +931,15 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
myCommandDependencies.add("$(OBJS)"); //$NON-NLS-1$
myCommandDependencies.add("$(USER_OBJS)"); //$NON-NLS-1$
} else {
String[] extensionsList = tool.getAllInputExtensions();
// Handle dependencies from the dependencyCalculator
IManagedDependencyGenerator depGen = tool.getDependencyGenerator();
IManagedDependencyGeneratorType depGen = tool.getDependencyGenerator();
String[] extensionsList = tool.getAllInputExtensions();
if (depGen != null) {
int calcType = depGen.getCalculatorType();
switch (calcType) {
case IManagedDependencyGenerator.TYPE_COMMAND:
// iterate over all extensions that the tool knows how to handle
for (int i=0; i<extensionsList.length; i++) {
String extensionName = extensionsList[i];
// Generated files should not appear in the list.
if(!makeGen.getOutputExtensions().contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
handledInputExtensions.add(extensionName);
String depsMacro = calculateSourceMacro(makeGen, extensionName, IManagedBuilderMakefileGenerator.DEP_EXT,
IManagedBuilderMakefileGenerator.WILDCARD);
List depsList = new ArrayList();
depsList.add(Path.fromOSString(depsMacro));
if (myOutputMacros.containsKey(DEPS_MACRO)) {
List currList = (List)myOutputMacros.get(DEPS_MACRO);
currList.addAll(depsList);
myOutputMacros.put(DEPS_MACRO, currList);
} else {
myOutputMacros.put(DEPS_MACRO, depsList);
}
}
}
break;
case IManagedDependencyGenerator.TYPE_INDEXER:
case IManagedDependencyGenerator.TYPE_EXTERNAL:
// The inputs must have been calculated before we can do this
if (!inputsCalculated) {
done = false;
} else {
Vector inputs = getEnumeratedInputs();
for (int j=0; j<inputs.size(); j++) {
IResource[] outNames = depGen.findDependencies(project.getFile((String)inputs.get(j)), project);
if (outNames != null) {
for (int k=0; k<outNames.length; k++) {
myCommandDependencies.add(outNames[k].toString());
}
}
}
}
break;
default:
break;
}
done = callDependencyCalculator (makeGen, config, handledInputExtensions,
depGen, extensionsList, myCommandDependencies, myOutputMacros,
myAdditionalTargets, done);
}
}
}
@ -946,6 +961,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
if (done) {
commandDependencies.addAll(myCommandDependencies);
additionalTargets.addAll(myAdditionalTargets);
//enumeratedDependencies.addAll(myEnumeratedDependencies);
dependenciesCalculated = true;
return true;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004 IBM Corporation and others.
* Copyright (c) 2004, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -74,7 +74,7 @@ public class DefaultIndexerDependencyCalculator implements IManagedDependencyGen
*/
public int getCalculatorType() {
// Tell the
return TYPE_INDEXER;
return TYPE_EXTERNAL;
}
/* (non-Javadoc)