mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +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:
parent
373ff106c3
commit
c7f73a4051
31 changed files with 22682 additions and 20994 deletions
|
@ -1,391 +1,391 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 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.core;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
|
||||
/**
|
||||
* This interface represents an inputType instance in the managed build system.
|
||||
* It describes one category of input files to a Tool. A tool can have
|
||||
* multiple inputType children.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IInputType extends IBuildObject {
|
||||
public static final String INPUT_TYPE_ELEMENT_NAME = "inputType"; //$NON-NLS-1$
|
||||
public static final String SOURCE_CONTENT_TYPE = "sourceContentType"; //$NON-NLS-1$
|
||||
public static final String SOURCES = "sources"; //$NON-NLS-1$
|
||||
public static final String DEPENDENCY_CONTENT_TYPE = "dependencyContentType"; //$NON-NLS-1$
|
||||
public static final String DEPENDENCY_EXTENSIONS = "dependencyExtensions"; //$NON-NLS-1$
|
||||
public static final String OPTION = "option"; //$NON-NLS-1$
|
||||
public static final String ASSIGN_TO_OPTION = "assignToOption"; //$NON-NLS-1$
|
||||
public static final String MULTIPLE_OF_TYPE = "multipleOfType"; //$NON-NLS-1$
|
||||
public static final String PRIMARY_INPUT = "primaryInput"; //$NON-NLS-1$
|
||||
public static final String BUILD_VARIABLE = "buildVariable"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Creates an inputOrder child for this InputType.
|
||||
*
|
||||
* @param path The path associated with the InputOrder element
|
||||
* @return IInputOrder of the new element
|
||||
*/
|
||||
public IInputOrder createInputOrder(String path);
|
||||
|
||||
/**
|
||||
* Removes the InputOrder element with the path specified in the argument.
|
||||
*
|
||||
* @param path The path associated with the InputOrder element
|
||||
*/
|
||||
public void removeInputOrder(String path);
|
||||
|
||||
/**
|
||||
* Removes the InputOrder element specified in the argument.
|
||||
*
|
||||
* @param path The InputOrder element
|
||||
*/
|
||||
public void removeInputOrder(IInputOrder element);
|
||||
|
||||
/**
|
||||
* Returns all of the InputOrder children of this InputType
|
||||
*
|
||||
* @return IInputOrder[]
|
||||
*/
|
||||
public IInputOrder[] getInputOrders();
|
||||
|
||||
/**
|
||||
* Returns the InputOrder element with the path specified in the argument.
|
||||
*
|
||||
* @param path The path associated with the InputOrder element
|
||||
* @return IInputOrder
|
||||
*/
|
||||
public IInputOrder getInputOrder(String path);
|
||||
|
||||
/**
|
||||
* Creates an additionalInput child for this InputType.
|
||||
*
|
||||
* @param path The path associated with the AdditionalInput element
|
||||
* @return IAdditionalInput of the new element
|
||||
*/
|
||||
public IAdditionalInput createAdditionalInput(String path);
|
||||
|
||||
/**
|
||||
* Removes the AdditionalInput element with the path specified in the argument.
|
||||
*
|
||||
* @param path The path associated with the AdditionalInput element
|
||||
*/
|
||||
public void removeAdditionalInput(String path);
|
||||
|
||||
/**
|
||||
* Removes the AdditionalInput element specified in the argument.
|
||||
*
|
||||
* @param element The AdditionalInput element
|
||||
*/
|
||||
public void removeAdditionalInput(IAdditionalInput element);
|
||||
|
||||
/**
|
||||
* Returns all of the AdditionalInput children of this InputType
|
||||
*
|
||||
* @return IAdditionalInput[]
|
||||
*/
|
||||
public IAdditionalInput[] getAdditionalInputs();
|
||||
|
||||
/**
|
||||
* Returns the AdditionalInput element with the path specified in the argument.
|
||||
*
|
||||
* @param path The path associated with the AdditionalInput element
|
||||
* @return IAdditionalInput
|
||||
*/
|
||||
public IAdditionalInput getAdditionalInput(String path);
|
||||
|
||||
/**
|
||||
* Returns all of the additional input resources of this InputType.
|
||||
* Note: This does not include additional dependencies.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getAdditionalResources();
|
||||
|
||||
/**
|
||||
* Returns all of the additional dependency resources of this InputType.
|
||||
* Note: This does not include additional inputs.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getAdditionalDependencies();
|
||||
|
||||
/**
|
||||
* Returns the tool parent of this InputType.
|
||||
*
|
||||
* @return ITool
|
||||
*/
|
||||
public ITool getParent();
|
||||
|
||||
/**
|
||||
* Returns the <code>IInputType</code> that is the superclass of this
|
||||
* InputType, or <code>null</code> if the attribute was not specified.
|
||||
*
|
||||
* @return IInputType
|
||||
*/
|
||||
public IInputType getSuperClass();
|
||||
|
||||
/**
|
||||
* Returns the Eclipse <code>IContentType</code> that describes this
|
||||
* input type. If both the sources attribute and the sourceContentType
|
||||
* attribute are specified, the sourceContentType will be used if it
|
||||
* is registered in Eclipse.
|
||||
*
|
||||
* @return IContentType
|
||||
*/
|
||||
public IContentType getSourceContentType();
|
||||
|
||||
/**
|
||||
* Sets the Eclipse <code>IContentType</code> that describes this
|
||||
* input type.
|
||||
*
|
||||
* @param contentType The Eclipse content type
|
||||
*/
|
||||
public void setSourceContentType(IContentType contentType);
|
||||
|
||||
/**
|
||||
* Returns the list of valid source extensions from the
|
||||
* sourceExtensions attribute. Note that this value is not used
|
||||
* if source content type is specified and registered with Eclipse.
|
||||
* Also, the user will not be able to modify the set of file
|
||||
* extensions as they can when sourceContentType is specified.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getSourceExtensionsAttribute();
|
||||
|
||||
/**
|
||||
* Sets the list of valid source extensions for this input type.
|
||||
* NOTE: The value of this attribute will NOT be used if a
|
||||
* source content type is specified and is registered with
|
||||
* Eclipse.
|
||||
*
|
||||
* @param extensions The comma-separated list of valid file extensions
|
||||
* - not including the separator period.
|
||||
*/
|
||||
public void setSourceExtensionsAttribute(String extensions);
|
||||
|
||||
/**
|
||||
* Returns the list of valid source extensions for this input type.
|
||||
* Note that the list will come from the sourceContentType if it
|
||||
* is specified and registered with Eclipse. Otherwise the
|
||||
* sourceExtensions attribute will be used.
|
||||
*
|
||||
* @param tool the tool that contains the input-type
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getSourceExtensions(ITool tool);
|
||||
|
||||
/**
|
||||
* Answers <code>true</code> if the input type considers the file extension to be
|
||||
* one associated with a source file.
|
||||
*
|
||||
* @param tool the tool that contains the input-type
|
||||
* @param ext file extension of the source
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isSourceExtension(ITool tool, String ext);
|
||||
|
||||
/**
|
||||
* Returns the Eclipse <code>IContentType</code> that describes the
|
||||
* dependency files of this input type. If both the dependencyExtensions
|
||||
* attribute and the dependencyContentType attribute are specified,
|
||||
* the dependencyContentType will be used if it is defined in Eclipse.
|
||||
*
|
||||
* @return IContentType
|
||||
*/
|
||||
public IContentType getDependencyContentType();
|
||||
|
||||
/**
|
||||
* Sets the Eclipse <code>IContentType</code> that describes the
|
||||
* dependency files of this input type.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public void setDependencyContentType(IContentType type);
|
||||
|
||||
/**
|
||||
* Returns the list of valid dependency extensions from the
|
||||
* dependencyExtensions attribute. Note that this value is not used
|
||||
* if dependency content type is specified and registered with Eclipse.
|
||||
* Also, the user will not be able to modify the set of file
|
||||
* extensions as they can when dependencyContentType is specified.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getDependencyExtensionsAttribute();
|
||||
|
||||
/**
|
||||
* Sets the list of valid dependency extensions for this input type.
|
||||
* NOTE: The value of this attribute will NOT be used if a
|
||||
* dependency content type is specified and is registered with
|
||||
* Eclipse.
|
||||
*
|
||||
* @param extensions The comma-separated list of valid dependency extensions
|
||||
* - not including the separator period.
|
||||
*/
|
||||
public void setDependencyExtensionsAttribute(String extensions);
|
||||
|
||||
/**
|
||||
* Returns the list of valid dependency extensions for this input type.
|
||||
* Note that the list will come from the dependencyContentType if it
|
||||
* is specified and registered with Eclipse. Otherwise the
|
||||
* dependencyExtensions attribute will be used.
|
||||
*
|
||||
* @param tool the tool that contains the input-type
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getDependencyExtensions(ITool tool);
|
||||
|
||||
/**
|
||||
* Answers <code>true</code> if the input type considers the file extension to be
|
||||
* one associated with a dependency file.
|
||||
*
|
||||
* @param tool the tool that contains the input-type
|
||||
* @param ext file extension of the source
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isDependencyExtension(ITool tool, String ext);
|
||||
|
||||
/**
|
||||
* Returns the id of the option that is associated with this input
|
||||
* type on the command line. If specified, the name(s) of the input
|
||||
* files for this input type are taken from the value specified
|
||||
* for the option.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getOptionId();
|
||||
|
||||
/**
|
||||
* Sets the id of the option that is associated with this input type on
|
||||
* the command line. If specified, the name(s) of the input files for
|
||||
* this input type are taken from the value specified for the option.
|
||||
*
|
||||
* @param optionId
|
||||
*/
|
||||
public void setOptionId(String optionId);
|
||||
|
||||
/**
|
||||
* Returns the id of the option whose value is to be assigned to the
|
||||
* file(s) calculated for this input type. The default is not to
|
||||
* assign the input file(s) to a command line option but to assign the
|
||||
* files to the ${Inputs} part of the command line. Note that the
|
||||
* option value is only updated during build file generation and therefore
|
||||
* could be out of sync with the project until build file generation
|
||||
* occurs.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getAssignToOptionId();
|
||||
|
||||
/**
|
||||
* Sets the id of the option whose value is to be assigned to the
|
||||
* file(s) calculated for this input type. The default is not to
|
||||
* assign the input file(s) to a command line option but to assign the
|
||||
* files to the ${Inputs} part of the command line. Note that the
|
||||
* option value is only updated during build file generation and therefore
|
||||
* could be out of sync with the project until build file generation
|
||||
* occurs.
|
||||
*
|
||||
* @param optionId
|
||||
*/
|
||||
public void setAssignToOptionId(String optionId);
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this inputType can contain multiple input
|
||||
* resources, else <code>false</code>. The inputs can be project resources,
|
||||
* or the outputs of other tools in the tool-chain.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getMultipleOfType();
|
||||
|
||||
/**
|
||||
* Sets whether this inputType can contain multiple input resources
|
||||
*
|
||||
* @param multiple
|
||||
*/
|
||||
public void setMultipleOfType(boolean multiple);
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this inputType is considered the primary input
|
||||
* of the tool, else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getPrimaryInput();
|
||||
|
||||
/**
|
||||
* Sets whether this inputType is considered the primary input of the tool
|
||||
*
|
||||
* @param primary
|
||||
*/
|
||||
public void setPrimaryInput(boolean primary);
|
||||
|
||||
/**
|
||||
* Returns a class instance that implements an interface to generate
|
||||
* source-level dependencies for this input type.
|
||||
* This method may return <code>null</code> in which case, the receiver
|
||||
* should assume that the input type does not require dependency information
|
||||
* when the project is built.
|
||||
*
|
||||
* @return IManagedDependencyGenerator
|
||||
*/
|
||||
public IManagedDependencyGenerator getDependencyGenerator();
|
||||
|
||||
/**
|
||||
* Returns the name of the build variable associated this this input type's resources
|
||||
* The build variable used in the build file to represent the list of input files when
|
||||
* multipleOfType is True. The same variable name can be used by an outputType to
|
||||
* identify a set of output files that contribute to this tool’s input
|
||||
* (i.e., those using the same buildVariable name). The default name is chosen by MBS.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getBuildVariable();
|
||||
|
||||
/**
|
||||
* Sets the name of the build variable associated this this input type's resources
|
||||
*
|
||||
* @return variableName
|
||||
*/
|
||||
public void setBuildVariable(String variableName);
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this element has changes that need to
|
||||
* be saved in the project file, else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isDirty();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this InputType was loaded from a manifest file,
|
||||
* and <code>false</code> if it was loaded from a project (.cdtbuild) file.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isExtensionElement();
|
||||
|
||||
/**
|
||||
* Sets the element's "dirty" (have I been modified?) flag.
|
||||
*
|
||||
* @param isDirty
|
||||
*/
|
||||
public void setDirty(boolean isDirty);
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.core;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
|
||||
/**
|
||||
* This interface represents an inputType instance in the managed build system.
|
||||
* It describes one category of input files to a Tool. A tool can have
|
||||
* multiple inputType children.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IInputType extends IBuildObject {
|
||||
public static final String INPUT_TYPE_ELEMENT_NAME = "inputType"; //$NON-NLS-1$
|
||||
public static final String SOURCE_CONTENT_TYPE = "sourceContentType"; //$NON-NLS-1$
|
||||
public static final String SOURCES = "sources"; //$NON-NLS-1$
|
||||
public static final String DEPENDENCY_CONTENT_TYPE = "dependencyContentType"; //$NON-NLS-1$
|
||||
public static final String DEPENDENCY_EXTENSIONS = "dependencyExtensions"; //$NON-NLS-1$
|
||||
public static final String OPTION = "option"; //$NON-NLS-1$
|
||||
public static final String ASSIGN_TO_OPTION = "assignToOption"; //$NON-NLS-1$
|
||||
public static final String MULTIPLE_OF_TYPE = "multipleOfType"; //$NON-NLS-1$
|
||||
public static final String PRIMARY_INPUT = "primaryInput"; //$NON-NLS-1$
|
||||
public static final String BUILD_VARIABLE = "buildVariable"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Creates an inputOrder child for this InputType.
|
||||
*
|
||||
* @param path The path associated with the InputOrder element
|
||||
* @return IInputOrder of the new element
|
||||
*/
|
||||
public IInputOrder createInputOrder(String path);
|
||||
|
||||
/**
|
||||
* Removes the InputOrder element with the path specified in the argument.
|
||||
*
|
||||
* @param path The path associated with the InputOrder element
|
||||
*/
|
||||
public void removeInputOrder(String path);
|
||||
|
||||
/**
|
||||
* Removes the InputOrder element specified in the argument.
|
||||
*
|
||||
* @param path The InputOrder element
|
||||
*/
|
||||
public void removeInputOrder(IInputOrder element);
|
||||
|
||||
/**
|
||||
* Returns all of the InputOrder children of this InputType
|
||||
*
|
||||
* @return IInputOrder[]
|
||||
*/
|
||||
public IInputOrder[] getInputOrders();
|
||||
|
||||
/**
|
||||
* Returns the InputOrder element with the path specified in the argument.
|
||||
*
|
||||
* @param path The path associated with the InputOrder element
|
||||
* @return IInputOrder
|
||||
*/
|
||||
public IInputOrder getInputOrder(String path);
|
||||
|
||||
/**
|
||||
* Creates an additionalInput child for this InputType.
|
||||
*
|
||||
* @param path The path associated with the AdditionalInput element
|
||||
* @return IAdditionalInput of the new element
|
||||
*/
|
||||
public IAdditionalInput createAdditionalInput(String path);
|
||||
|
||||
/**
|
||||
* Removes the AdditionalInput element with the path specified in the argument.
|
||||
*
|
||||
* @param path The path associated with the AdditionalInput element
|
||||
*/
|
||||
public void removeAdditionalInput(String path);
|
||||
|
||||
/**
|
||||
* Removes the AdditionalInput element specified in the argument.
|
||||
*
|
||||
* @param element The AdditionalInput element
|
||||
*/
|
||||
public void removeAdditionalInput(IAdditionalInput element);
|
||||
|
||||
/**
|
||||
* Returns all of the AdditionalInput children of this InputType
|
||||
*
|
||||
* @return IAdditionalInput[]
|
||||
*/
|
||||
public IAdditionalInput[] getAdditionalInputs();
|
||||
|
||||
/**
|
||||
* Returns the AdditionalInput element with the path specified in the argument.
|
||||
*
|
||||
* @param path The path associated with the AdditionalInput element
|
||||
* @return IAdditionalInput
|
||||
*/
|
||||
public IAdditionalInput getAdditionalInput(String path);
|
||||
|
||||
/**
|
||||
* Returns all of the additional input resources of this InputType.
|
||||
* Note: This does not include additional dependencies.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getAdditionalResources();
|
||||
|
||||
/**
|
||||
* Returns all of the additional dependency resources of this InputType.
|
||||
* Note: This does not include additional inputs.
|
||||
*
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] getAdditionalDependencies();
|
||||
|
||||
/**
|
||||
* Returns the tool parent of this InputType.
|
||||
*
|
||||
* @return ITool
|
||||
*/
|
||||
public ITool getParent();
|
||||
|
||||
/**
|
||||
* Returns the <code>IInputType</code> that is the superclass of this
|
||||
* InputType, or <code>null</code> if the attribute was not specified.
|
||||
*
|
||||
* @return IInputType
|
||||
*/
|
||||
public IInputType getSuperClass();
|
||||
|
||||
/**
|
||||
* Returns the Eclipse <code>IContentType</code> that describes this
|
||||
* input type. If both the sources attribute and the sourceContentType
|
||||
* attribute are specified, the sourceContentType will be used if it
|
||||
* is registered in Eclipse.
|
||||
*
|
||||
* @return IContentType
|
||||
*/
|
||||
public IContentType getSourceContentType();
|
||||
|
||||
/**
|
||||
* Sets the Eclipse <code>IContentType</code> that describes this
|
||||
* input type.
|
||||
*
|
||||
* @param contentType The Eclipse content type
|
||||
*/
|
||||
public void setSourceContentType(IContentType contentType);
|
||||
|
||||
/**
|
||||
* Returns the list of valid source extensions from the
|
||||
* sourceExtensions attribute. Note that this value is not used
|
||||
* if source content type is specified and registered with Eclipse.
|
||||
* Also, the user will not be able to modify the set of file
|
||||
* extensions as they can when sourceContentType is specified.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getSourceExtensionsAttribute();
|
||||
|
||||
/**
|
||||
* Sets the list of valid source extensions for this input type.
|
||||
* NOTE: The value of this attribute will NOT be used if a
|
||||
* source content type is specified and is registered with
|
||||
* Eclipse.
|
||||
*
|
||||
* @param extensions The comma-separated list of valid file extensions
|
||||
* - not including the separator period.
|
||||
*/
|
||||
public void setSourceExtensionsAttribute(String extensions);
|
||||
|
||||
/**
|
||||
* Returns the list of valid source extensions for this input type.
|
||||
* Note that the list will come from the sourceContentType if it
|
||||
* is specified and registered with Eclipse. Otherwise the
|
||||
* sourceExtensions attribute will be used.
|
||||
*
|
||||
* @param tool the tool that contains the input-type
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getSourceExtensions(ITool tool);
|
||||
|
||||
/**
|
||||
* Answers <code>true</code> if the input type considers the file extension to be
|
||||
* one associated with a source file.
|
||||
*
|
||||
* @param tool the tool that contains the input-type
|
||||
* @param ext file extension of the source
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isSourceExtension(ITool tool, String ext);
|
||||
|
||||
/**
|
||||
* Returns the Eclipse <code>IContentType</code> that describes the
|
||||
* dependency files of this input type. If both the dependencyExtensions
|
||||
* attribute and the dependencyContentType attribute are specified,
|
||||
* the dependencyContentType will be used if it is defined in Eclipse.
|
||||
*
|
||||
* @return IContentType
|
||||
*/
|
||||
public IContentType getDependencyContentType();
|
||||
|
||||
/**
|
||||
* Sets the Eclipse <code>IContentType</code> that describes the
|
||||
* dependency files of this input type.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public void setDependencyContentType(IContentType type);
|
||||
|
||||
/**
|
||||
* Returns the list of valid dependency extensions from the
|
||||
* dependencyExtensions attribute. Note that this value is not used
|
||||
* if dependency content type is specified and registered with Eclipse.
|
||||
* Also, the user will not be able to modify the set of file
|
||||
* extensions as they can when dependencyContentType is specified.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getDependencyExtensionsAttribute();
|
||||
|
||||
/**
|
||||
* Sets the list of valid dependency extensions for this input type.
|
||||
* NOTE: The value of this attribute will NOT be used if a
|
||||
* dependency content type is specified and is registered with
|
||||
* Eclipse.
|
||||
*
|
||||
* @param extensions The comma-separated list of valid dependency extensions
|
||||
* - not including the separator period.
|
||||
*/
|
||||
public void setDependencyExtensionsAttribute(String extensions);
|
||||
|
||||
/**
|
||||
* Returns the list of valid dependency extensions for this input type.
|
||||
* Note that the list will come from the dependencyContentType if it
|
||||
* is specified and registered with Eclipse. Otherwise the
|
||||
* dependencyExtensions attribute will be used.
|
||||
*
|
||||
* @param tool the tool that contains the input-type
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getDependencyExtensions(ITool tool);
|
||||
|
||||
/**
|
||||
* Answers <code>true</code> if the input type considers the file extension to be
|
||||
* one associated with a dependency file.
|
||||
*
|
||||
* @param tool the tool that contains the input-type
|
||||
* @param ext file extension of the source
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isDependencyExtension(ITool tool, String ext);
|
||||
|
||||
/**
|
||||
* Returns the id of the option that is associated with this input
|
||||
* type on the command line. If specified, the name(s) of the input
|
||||
* files for this input type are taken from the value specified
|
||||
* for the option.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getOptionId();
|
||||
|
||||
/**
|
||||
* Sets the id of the option that is associated with this input type on
|
||||
* the command line. If specified, the name(s) of the input files for
|
||||
* this input type are taken from the value specified for the option.
|
||||
*
|
||||
* @param optionId
|
||||
*/
|
||||
public void setOptionId(String optionId);
|
||||
|
||||
/**
|
||||
* Returns the id of the option whose value is to be assigned to the
|
||||
* file(s) calculated for this input type. The default is not to
|
||||
* assign the input file(s) to a command line option but to assign the
|
||||
* files to the ${Inputs} part of the command line. Note that the
|
||||
* option value is only updated during build file generation and therefore
|
||||
* could be out of sync with the project until build file generation
|
||||
* occurs.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getAssignToOptionId();
|
||||
|
||||
/**
|
||||
* Sets the id of the option whose value is to be assigned to the
|
||||
* file(s) calculated for this input type. The default is not to
|
||||
* assign the input file(s) to a command line option but to assign the
|
||||
* files to the ${Inputs} part of the command line. Note that the
|
||||
* option value is only updated during build file generation and therefore
|
||||
* could be out of sync with the project until build file generation
|
||||
* occurs.
|
||||
*
|
||||
* @param optionId
|
||||
*/
|
||||
public void setAssignToOptionId(String optionId);
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this inputType can contain multiple input
|
||||
* resources, else <code>false</code>. The inputs can be project resources,
|
||||
* or the outputs of other tools in the tool-chain.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getMultipleOfType();
|
||||
|
||||
/**
|
||||
* Sets whether this inputType can contain multiple input resources
|
||||
*
|
||||
* @param multiple
|
||||
*/
|
||||
public void setMultipleOfType(boolean multiple);
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this inputType is considered the primary input
|
||||
* of the tool, else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getPrimaryInput();
|
||||
|
||||
/**
|
||||
* Sets whether this inputType is considered the primary input of the tool
|
||||
*
|
||||
* @param primary
|
||||
*/
|
||||
public void setPrimaryInput(boolean primary);
|
||||
|
||||
/**
|
||||
* Returns a class instance that implements an interface to generate
|
||||
* source-level dependencies for this input type.
|
||||
* This method may return <code>null</code> in which case, the receiver
|
||||
* should assume that the input type does not require dependency information
|
||||
* when the project is built.
|
||||
*
|
||||
* @return IManagedDependencyGeneratorType
|
||||
*/
|
||||
public IManagedDependencyGeneratorType getDependencyGenerator();
|
||||
|
||||
/**
|
||||
* Returns the name of the build variable associated this this input type's resources
|
||||
* The build variable used in the build file to represent the list of input files when
|
||||
* multipleOfType is True. The same variable name can be used by an outputType to
|
||||
* identify a set of output files that contribute to this tool’s input
|
||||
* (i.e., those using the same buildVariable name). The default name is chosen by MBS.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getBuildVariable();
|
||||
|
||||
/**
|
||||
* Sets the name of the build variable associated this this input type's resources
|
||||
*
|
||||
* @return variableName
|
||||
*/
|
||||
public void setBuildVariable(String variableName);
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this element has changes that need to
|
||||
* be saved in the project file, else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isDirty();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this InputType was loaded from a manifest file,
|
||||
* and <code>false</code> if it was loaded from a project (.cdtbuild) file.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isExtensionElement();
|
||||
|
||||
/**
|
||||
* Sets the element's "dirty" (have I been modified?) flag.
|
||||
*
|
||||
* @param isDirty
|
||||
*/
|
||||
public void setDirty(boolean isDirty);
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,110 +1,111 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2002, 2005 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
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# IBM Rational Software - Initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
# Generated makefile builder messages
|
||||
ManagedMakeBuilder.message.starting = Starting the build for project {0}
|
||||
ManagedMakeBuilder.message.rebuild.makefiles = Regenerating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.updating = Updating project files...
|
||||
ManagedMakeBuilder.message.make = Calling {0} for project {1}
|
||||
ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
|
||||
ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
|
||||
ManagedMakeBuilder.message.creating.markers = Generating markers...
|
||||
ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
|
||||
ManagedMakeBuilder.message.no.build = Nothing to build for {0}
|
||||
ManagedMakeBuilder.message.error = Build error
|
||||
ManagedMakeBuilder.message.error.refresh = Error refreshing project
|
||||
ManagedMakeBuilder.message.finished = Build complete for project {0}
|
||||
ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
|
||||
ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
|
||||
ManagedMakeBuilder.type.clean = Clean-only build
|
||||
ManagedMakeBuider.type.incremental = Build
|
||||
ManagedMakeBuilder.warning.unsupported.configuration=**** WARNING: The "{0}" Configuration may not build ****\n**** because it uses the "{1}" ****\n**** tool-chain that is unsupported on this system. ****\n\n**** Attempting to build... ****
|
||||
|
||||
# Option exception messages
|
||||
Option.error.bad_value_type=Bad value for type
|
||||
|
||||
# Managed build manager exception messages
|
||||
ManagedBuildManager.error.owner_not_null=addTarget: owner not null
|
||||
ManagedBuildManager.error.null_owner=addTarget: null owner
|
||||
ManagedBuildManager.error.owner_not_project=addTarget: owner not project
|
||||
ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error
|
||||
ManagedBuildManager.error.manifest.version.error=The version number defined in the plugin manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded.
|
||||
ManagedBuildManager.error.manifest.header=Managed Build system manifest file error:
|
||||
ManagedBuildManager.error.manifest.resolving=Unable to resolve the {0} identifier {1} in the {2} {3}.
|
||||
ManagedBuildManager.error.manifest.duplicate=Duplicate identifier {1} for element type {0}.
|
||||
ManagedBuildManager.error.manifest.icon=Could not load icon "{0}".
|
||||
ManagedBuildManager.error.manifest.option.category=Option {0} uses a null category that is invalid in its context. The option was ignored.
|
||||
ManagedBuildManager.error.manifest.option.filter=Option {0} uses an unsupported resourceFilter attribute value. The option was ignored.
|
||||
ManagedBuildManager.error.manifest.option.valuehandler=Could not load value handler {0} in option {1}.
|
||||
ManagedBuildManager.error.open_failed_title=Managed Make Project File Error
|
||||
ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error:\n\n{0}\n\nManaged Make functionality will not be available for this project.
|
||||
ManagedBuildManager.error.write_failed_title=Managed Make Project File Write Error
|
||||
ManagedBuildManager.error.write_failed=The Managed Make project file could not be written because of the following error:\n\n{0}\n
|
||||
ManagedBuildManager.error.read_only=File {0} is read-only.
|
||||
ManagedBuildManager.error.project.version.error=The version number of the project {0} is greater than the Managed Build System version number.
|
||||
ManagedBuildManager.error.id.nomatch=Error loading Managed Make project information for project {0}. The tool definitions used to create the project are not available.
|
||||
ManagedBuildManager.error.project.file.missing=The Managed Make project file for project {0} is missing.
|
||||
# Makefile Generator Messages
|
||||
MakefileGenerator.message.start.file=Building file:
|
||||
MakefileGenerator.message.finish.file=Finished building:
|
||||
MakefileGenerator.message.start.build=Building target:
|
||||
MakefileGenerator.message.finish.build=Finished building target:
|
||||
MakefileGenerator.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}
|
||||
MakefileGenerator.message.calc.delta=Calculating the delta for project {0}
|
||||
MakefileGenerator.message.finding.sources=Finding source files in project {0}
|
||||
MakefileGenerator.comment.module.list = Every subdirectory with source files must be described here
|
||||
MakefileGenerator.comment.module.variables = Add inputs and outputs from these tool invocations to the build variables
|
||||
MakefileGenerator.comment.source.list = All of the sources participating in the build are defined here
|
||||
MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
|
||||
MakefileGenerator.comment.build.toprules = Tool invocations
|
||||
MakefileGenerator.comment.build.alltarget = All Target
|
||||
MakefileGenerator.comment.build.mainbuildtarget = Main-build Target
|
||||
MakefileGenerator.comment.build.toptargets = Other Targets
|
||||
MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory
|
||||
MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list:
|
||||
MakefileGenerator.comment.autodeps=Automatically-generated dependency list:
|
||||
MakefileGenerator.comment.header=Automatically-generated file. Do not edit!
|
||||
MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces in name
|
||||
MakefileGenerator.warning.no.source=Nothing to build for project {0}
|
||||
MakefileGenerator.error.no.nameprovider=A nameProvider or outputNames must be specified with multipleType == true
|
||||
|
||||
ManagedBuildInfo.message.job.init = Initializing path container for {0}
|
||||
ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
|
||||
|
||||
# Default GNU Makefile Generator messages
|
||||
GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0}
|
||||
|
||||
# Tool strings
|
||||
Tool.default.announcement=Invoking:
|
||||
#Environment loader messages
|
||||
StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments
|
||||
|
||||
#User Defined Macro Supplier
|
||||
UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist macros: Wrong arguments
|
||||
|
||||
# BuildMacroStatus messages
|
||||
BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
|
||||
BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
|
||||
BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect
|
||||
BuildMacroStatus.status.macro.not.string=Macro {0} is not of String type
|
||||
BuildMacroStatus.status.macro.not.stringlist=Macro {0} is not of String-list type
|
||||
BuildMacroStatus.status.error=Error occured
|
||||
BuildMacroStatus.value.undefined=
|
||||
|
||||
#ResourceChangeHandler messages
|
||||
ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
|
||||
|
||||
#ManagedBuilderCorePlugin messages
|
||||
###############################################################################
|
||||
# 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
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# IBM Rational Software - Initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
# Generated makefile builder messages
|
||||
ManagedMakeBuilder.message.starting = Starting the build for project {0}
|
||||
ManagedMakeBuilder.message.rebuild.makefiles = Regenerating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
|
||||
ManagedMakeBuilder.message.updating = Updating project files...
|
||||
ManagedMakeBuilder.message.make = Calling {0} for project {1}
|
||||
ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
|
||||
ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
|
||||
ManagedMakeBuilder.message.creating.markers = Generating markers...
|
||||
ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
|
||||
ManagedMakeBuilder.message.no.build = Nothing to build for {0}
|
||||
ManagedMakeBuilder.message.error = Build error
|
||||
ManagedMakeBuilder.message.error.refresh = Error refreshing project
|
||||
ManagedMakeBuilder.message.finished = Build complete for project {0}
|
||||
ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
|
||||
ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
|
||||
ManagedMakeBuilder.type.clean = Clean-only build
|
||||
ManagedMakeBuider.type.incremental = Build
|
||||
ManagedMakeBuilder.warning.unsupported.configuration=**** WARNING: The "{0}" Configuration may not build ****\n**** because it uses the "{1}" ****\n**** tool-chain that is unsupported on this system. ****\n\n**** Attempting to build... ****
|
||||
|
||||
# Option exception messages
|
||||
Option.error.bad_value_type=Bad value for type
|
||||
|
||||
# Managed build manager exception messages
|
||||
ManagedBuildManager.error.owner_not_null=addTarget: owner not null
|
||||
ManagedBuildManager.error.null_owner=addTarget: null owner
|
||||
ManagedBuildManager.error.owner_not_project=addTarget: owner not project
|
||||
ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error
|
||||
ManagedBuildManager.error.manifest.version.error=The version number defined in the plugin manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded.
|
||||
ManagedBuildManager.error.manifest.header=Managed Build system manifest file error:
|
||||
ManagedBuildManager.error.manifest.resolving=Unable to resolve the {0} identifier {1} in the {2} {3}.
|
||||
ManagedBuildManager.error.manifest.duplicate=Duplicate identifier {1} for element type {0}.
|
||||
ManagedBuildManager.error.manifest.icon=Could not load icon "{0}".
|
||||
ManagedBuildManager.error.manifest.option.category=Option {0} uses a null category that is invalid in its context. The option was ignored.
|
||||
ManagedBuildManager.error.manifest.option.filter=Option {0} uses an unsupported resourceFilter attribute value. The option was ignored.
|
||||
ManagedBuildManager.error.manifest.option.valuehandler=Could not load value handler {0} in option {1}.
|
||||
ManagedBuildManager.error.open_failed_title=Managed Make Project File Error
|
||||
ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error:\n\n{0}\n\nManaged Make functionality will not be available for this project.
|
||||
ManagedBuildManager.error.write_failed_title=Managed Make Project File Write Error
|
||||
ManagedBuildManager.error.write_failed=The Managed Make project file could not be written because of the following error:\n\n{0}\n
|
||||
ManagedBuildManager.error.read_only=File {0} is read-only.
|
||||
ManagedBuildManager.error.project.version.error=The version number of the project {0} is greater than the Managed Build System version number.
|
||||
ManagedBuildManager.error.id.nomatch=Error loading Managed Make project information for project {0}. The tool definitions used to create the project are not available.
|
||||
ManagedBuildManager.error.project.file.missing=The Managed Make project file for project {0} is missing.
|
||||
# Makefile Generator Messages
|
||||
MakefileGenerator.message.start.file=Building file:
|
||||
MakefileGenerator.message.finish.file=Finished building:
|
||||
MakefileGenerator.message.start.build=Building target:
|
||||
MakefileGenerator.message.finish.build=Finished building target:
|
||||
MakefileGenerator.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}
|
||||
MakefileGenerator.message.calc.delta=Calculating the delta for project {0}
|
||||
MakefileGenerator.message.finding.sources=Finding source files in project {0}
|
||||
MakefileGenerator.comment.module.list = Every subdirectory with source files must be described here
|
||||
MakefileGenerator.comment.module.variables = Add inputs and outputs from these tool invocations to the build variables
|
||||
MakefileGenerator.comment.source.list = All of the sources participating in the build are defined here
|
||||
MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
|
||||
MakefileGenerator.comment.build.toprules = Tool invocations
|
||||
MakefileGenerator.comment.build.alltarget = All Target
|
||||
MakefileGenerator.comment.build.mainbuildtarget = Main-build Target
|
||||
MakefileGenerator.comment.build.toptargets = Other Targets
|
||||
MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory
|
||||
MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list:
|
||||
MakefileGenerator.comment.autodeps=Automatically-generated dependency list:
|
||||
MakefileGenerator.comment.header=Automatically-generated file. Do not edit!
|
||||
MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces in name
|
||||
MakefileGenerator.warning.no.source=Nothing to build for project {0}
|
||||
MakefileGenerator.error.no.nameprovider=A nameProvider or outputNames must be specified with multipleType == true
|
||||
|
||||
ManagedBuildInfo.message.job.init = Initializing path container for {0}
|
||||
ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
|
||||
|
||||
# Default GNU Makefile Generator messages
|
||||
GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0}
|
||||
|
||||
# Tool strings
|
||||
Tool.default.announcement=Invoking:
|
||||
#Environment loader messages
|
||||
StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments
|
||||
|
||||
#User Defined Macro Supplier
|
||||
UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist macros: Wrong arguments
|
||||
|
||||
# BuildMacroStatus messages
|
||||
BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
|
||||
BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
|
||||
BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect
|
||||
BuildMacroStatus.status.macro.not.string=Macro {0} is not of String type
|
||||
BuildMacroStatus.status.macro.not.stringlist=Macro {0} is not of String-list type
|
||||
BuildMacroStatus.status.error=Error occured
|
||||
BuildMacroStatus.value.undefined=
|
||||
|
||||
#ResourceChangeHandler messages
|
||||
ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
|
||||
|
||||
#ManagedBuilderCorePlugin messages
|
||||
ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Resource Change Handling
|
|
@ -1,455 +1,458 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 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.internal.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.IResourceChangeListener;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||
import org.eclipse.core.resources.IResourceRuleFactory;
|
||||
import org.eclipse.core.resources.ISaveContext;
|
||||
import org.eclipse.core.resources.ISaveParticipant;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||
|
||||
public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
|
||||
|
||||
private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
|
||||
private IResourceDelta fRootDelta;
|
||||
private HashMap fBuildFileGeneratorMap = new HashMap();
|
||||
private HashSet fValidatedFilesSet = new HashSet();
|
||||
private HashSet fModifiedProjects = new HashSet();
|
||||
|
||||
public ResourceConfigurationChecker(IResourceDelta rootDelta){
|
||||
fRootDelta = rootDelta;
|
||||
}
|
||||
|
||||
public IProject[] getModifiedProjects(){
|
||||
return (IProject[])fModifiedProjects.toArray(new IProject[fModifiedProjects.size()]);
|
||||
}
|
||||
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
int rcType = dResource.getType();
|
||||
|
||||
if(rcType == IResource.PROJECT || rcType == IResource.FOLDER){
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject project = null;
|
||||
IResource rcToCheck = null;
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
|
||||
sendClose((IProject)dResource);
|
||||
break;
|
||||
}
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = delta.getMovedToPath();
|
||||
if(path != null){
|
||||
project = root.findMember(path.segment(0)).getProject();
|
||||
if(project != null && rcType == IResource.FOLDER)
|
||||
rcToCheck = root.getFolder(substituteProject(dResource.getFullPath(),project.getName()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
project = dResource.getProject();
|
||||
if(rcType == IResource.FOLDER)
|
||||
rcToCheck = dResource;
|
||||
break;
|
||||
}
|
||||
|
||||
if(project != null) {
|
||||
IManagedBuilderMakefileGenerator makeGen = getInitializedGenerator(project);
|
||||
if(makeGen != null){
|
||||
if(rcToCheck == null || !makeGen.isGeneratedResource(rcToCheck))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (rcType == IResource.FILE && !dResource.isDerived()) {
|
||||
int flags = delta.getFlags();
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((flags & IResourceDelta.MOVED_TO) == 0) {
|
||||
handleDeleteFile(dResource.getFullPath());
|
||||
break;
|
||||
}
|
||||
case IResourceDelta.ADDED :
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((flags & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = delta.getMovedToPath();
|
||||
if (path != null) {
|
||||
handleRenamedFile(
|
||||
dResource.getFullPath(),
|
||||
path);
|
||||
}
|
||||
} else if ((flags & IResourceDelta.MOVED_FROM) != 0) {
|
||||
IPath path = delta.getMovedFromPath();
|
||||
if (path != null) {
|
||||
handleRenamedFile(
|
||||
path,
|
||||
dResource.getFullPath());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true; // visit the children
|
||||
}
|
||||
|
||||
private IPath substituteProject(IPath path, String projectName){
|
||||
return new Path(projectName).makeAbsolute().append(path.removeFirstSegments(1));
|
||||
}
|
||||
|
||||
private void handleRenamedFile(IPath fromPath, IPath toPath){
|
||||
if(!fValidatedFilesSet.add(fromPath))
|
||||
return;
|
||||
|
||||
IProject fromProject = findModifiedProject(fromPath.segment(0));
|
||||
if(fromProject == null)
|
||||
return;
|
||||
IManagedBuilderMakefileGenerator fromMakeGen = getInitializedGenerator(fromProject);
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
if(fromMakeGen == null || fromMakeGen.isGeneratedResource(root.getFile(substituteProject(fromPath,fromProject.getName()))))
|
||||
return;
|
||||
|
||||
IManagedBuildInfo fromInfo = fromProject != null ?
|
||||
ManagedBuildManager.getBuildInfo(fromProject) :
|
||||
null;
|
||||
|
||||
IProject toProject = root.findMember(toPath.uptoSegment(1)).getProject();
|
||||
IManagedBuildInfo toInfo = toProject != null ?
|
||||
ManagedBuildManager.getBuildInfo(toProject) :
|
||||
null;
|
||||
IManagedBuilderMakefileGenerator toMakeGen = toProject != null ?
|
||||
getInitializedGenerator(toProject) :
|
||||
null;
|
||||
if(toMakeGen != null && toMakeGen.isGeneratedResource(root.getFile(toPath)))
|
||||
toInfo = null;
|
||||
|
||||
if(fromInfo == toInfo){
|
||||
//the resource was moved whithing the project scope
|
||||
if(updateResourceConfigurations(fromInfo,fromPath,toPath) && toProject != null)
|
||||
fModifiedProjects.add(toProject);
|
||||
} else {
|
||||
if(fromInfo != null && toInfo != null){
|
||||
//TODO: this is the case when the resource
|
||||
//is moved from one managed project to another
|
||||
//should we handle this?
|
||||
//e.g. add resource configurations to the destination project?
|
||||
}
|
||||
if(fromInfo != null && removeResourceConfigurations(fromInfo,fromPath) && fromProject != null)
|
||||
fModifiedProjects.add(fromProject);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteFile(IPath path){
|
||||
IProject project = findModifiedProject(path.segment(0));
|
||||
if(project != null){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
if(info != null
|
||||
&& removeResourceConfigurations(info,path))
|
||||
fModifiedProjects.add(project);
|
||||
}
|
||||
}
|
||||
|
||||
//finds the project geven the initial project name
|
||||
//That is:
|
||||
// if the project of a given name was renamed returns the renamed project
|
||||
// if the project of a given name was removed returns null
|
||||
// if the project of a given name was neither renamed or removed
|
||||
// returns the project of that name or null if the project does not exist
|
||||
//
|
||||
private IProject findModifiedProject(final String oldProjectName){
|
||||
IResourceDelta projectDelta = fRootDelta.findMember(new Path(oldProjectName));
|
||||
boolean replaced = false;
|
||||
if(projectDelta != null) {
|
||||
switch(projectDelta.getKind()){
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
|
||||
return null;
|
||||
}
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = projectDelta.getMovedToPath();
|
||||
if(path != null)
|
||||
return ResourcesPlugin.getWorkspace().getRoot().findMember(path).getProject();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final IProject project[] = new IProject[1];
|
||||
try {
|
||||
fRootDelta.accept(new IResourceDeltaVisitor() {
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
int rcType = dResource.getType();
|
||||
if(rcType == IResource.ROOT) {
|
||||
return true;
|
||||
} else if(rcType == IResource.PROJECT){
|
||||
switch(delta.getKind()){
|
||||
case IResourceDelta.ADDED :
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
|
||||
IPath path = delta.getMovedFromPath();
|
||||
if (path != null && path.segment(0).equals(oldProjectName)) {
|
||||
project[0] = dResource.getProject();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
if(project[0] == null && !replaced)
|
||||
project[0] = ResourcesPlugin.getWorkspace().getRoot().findMember(oldProjectName).getProject();
|
||||
return project[0];
|
||||
}
|
||||
|
||||
private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){
|
||||
IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project);
|
||||
if (makeGen == null) {
|
||||
try {
|
||||
if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
|
||||
// Determine if we can access the build info before actually trying
|
||||
// If not, don't try, to avoid putting up a dialog box warning the user
|
||||
if (!ManagedBuildManager.canGetBuildInfo(project)) return null;
|
||||
|
||||
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
|
||||
if (buildInfo != null){
|
||||
IConfiguration defaultCfg = buildInfo.getDefaultConfiguration();
|
||||
if (defaultCfg != null) {
|
||||
makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg);
|
||||
makeGen.initialize(project,buildInfo,new NullProgressMonitor());
|
||||
fBuildFileGeneratorMap.put(project,makeGen);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return makeGen;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendClose(IProject project){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
|
||||
if(info != null){
|
||||
IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
|
||||
|
||||
for(int i = 0; i < cfgs.length; i++)
|
||||
ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* I R e s o u r c e C h a n g e L i s t e n e r
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* Handle the renaming and deletion of project resources
|
||||
* This is necessary in order to update ResourceConfigurations and AdditionalInputs
|
||||
*
|
||||
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
|
||||
*/
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
if (event.getSource() instanceof IWorkspace) {
|
||||
|
||||
switch (event.getType()) {
|
||||
case IResourceChangeEvent.PRE_CLOSE:
|
||||
IResource proj = event.getResource();
|
||||
if(proj instanceof IProject)
|
||||
sendClose((IProject)proj);
|
||||
break;
|
||||
case IResourceChangeEvent.POST_CHANGE :
|
||||
case IResourceChangeEvent.POST_BUILD :
|
||||
case IResourceChangeEvent.PRE_DELETE :
|
||||
IResourceDelta resDelta = event.getDelta();
|
||||
if (resDelta == null) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
ResourceConfigurationChecker rcChecker = new ResourceConfigurationChecker(resDelta);
|
||||
resDelta.accept(rcChecker);
|
||||
|
||||
//saving info for the modified projects
|
||||
initInfoSerialization(rcChecker.getModifiedProjects());
|
||||
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initInfoSerialization(final IProject projects[]){
|
||||
if(projects.length == 0)
|
||||
return;
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
|
||||
ISchedulingRule buildInfoSaveRule;
|
||||
if(projects.length == 1){
|
||||
buildInfoSaveRule = ruleFactory.modifyRule(projects[0]);
|
||||
} else {
|
||||
ISchedulingRule rules[] = new ISchedulingRule[projects.length];
|
||||
for(int i = 0; i < rules.length; i++)
|
||||
rules[i] = ruleFactory.modifyRule(projects[i]);
|
||||
buildInfoSaveRule = MultiRule.combine(rules);
|
||||
}
|
||||
|
||||
Job savingJob = new Job(ManagedMakeMessages.getResourceString("ResourceChangeHandler.buildInfoSerializationJob")){ //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
ManagedBuildManager.saveBuildInfo(projects[i],true);
|
||||
}
|
||||
return new Status(
|
||||
IStatus.OK,
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
IStatus.OK,
|
||||
new String(),
|
||||
null);
|
||||
}
|
||||
};
|
||||
savingJob.setRule(buildInfoSaveRule);
|
||||
|
||||
savingJob.schedule();
|
||||
}
|
||||
|
||||
private boolean updateResourceConfigurations(IManagedBuildInfo info, IPath oldPath, IPath newPath){
|
||||
boolean changed = false;
|
||||
if(!oldPath.equals(newPath)){
|
||||
IManagedProject mngProj = info.getManagedProject();
|
||||
if(mngProj != null){
|
||||
IConfiguration configs[] = mngProj.getConfigurations();
|
||||
if(configs != null && configs.length > 0){
|
||||
for(int i = 0; i < configs.length; i++){
|
||||
if(updateResourceConfiguration(configs[i],oldPath,newPath))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean removeResourceConfigurations(IManagedBuildInfo info, IPath path){
|
||||
boolean changed = false;
|
||||
IManagedProject mngProj = info.getManagedProject();
|
||||
if(mngProj != null){
|
||||
IConfiguration configs[] = mngProj.getConfigurations();
|
||||
if(configs != null && configs.length > 0){
|
||||
for(int i = 0; i < configs.length; i++){
|
||||
if(removeResourceConfiguration(configs[i],path))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){
|
||||
IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString());
|
||||
if(rcCfg != null && !oldPath.equals(newPath)){
|
||||
config.removeResourceConfiguration(rcCfg);
|
||||
rcCfg.setResourcePath(newPath.toString());
|
||||
((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
|
||||
config.setRebuildState(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean removeResourceConfiguration(IConfiguration config, IPath path){
|
||||
IResourceConfiguration rcCfg = config.getResourceConfiguration(path.toString());
|
||||
if(rcCfg != null){
|
||||
config.removeResourceConfiguration(rcCfg);
|
||||
config.setRebuildState(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* I S a v e P a r t i c i p a n t
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void saving(ISaveContext context) throws CoreException {
|
||||
// No state to be saved by the plug-in, but request a
|
||||
// resource delta to be used on next activation.
|
||||
context.needDelta();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void doneSaving(ISaveContext context) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void prepareToSave(ISaveContext context) throws CoreException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void rollback(ISaveContext context) {
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2005 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.internal.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.IResourceChangeListener;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||
import org.eclipse.core.resources.IResourceRuleFactory;
|
||||
import org.eclipse.core.resources.ISaveContext;
|
||||
import org.eclipse.core.resources.ISaveParticipant;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||
|
||||
public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
|
||||
|
||||
private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
|
||||
private IResourceDelta fRootDelta;
|
||||
private HashMap fBuildFileGeneratorMap = new HashMap();
|
||||
private HashSet fValidatedFilesSet = new HashSet();
|
||||
private HashSet fModifiedProjects = new HashSet();
|
||||
|
||||
public ResourceConfigurationChecker(IResourceDelta rootDelta){
|
||||
fRootDelta = rootDelta;
|
||||
}
|
||||
|
||||
public IProject[] getModifiedProjects(){
|
||||
return (IProject[])fModifiedProjects.toArray(new IProject[fModifiedProjects.size()]);
|
||||
}
|
||||
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
int rcType = dResource.getType();
|
||||
|
||||
if(rcType == IResource.PROJECT || rcType == IResource.FOLDER){
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject project = null;
|
||||
IResource rcToCheck = null;
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
|
||||
sendClose((IProject)dResource);
|
||||
break;
|
||||
}
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = delta.getMovedToPath();
|
||||
if(path != null){
|
||||
project = root.findMember(path.segment(0)).getProject();
|
||||
if(project != null && rcType == IResource.FOLDER)
|
||||
rcToCheck = root.getFolder(substituteProject(dResource.getFullPath(),project.getName()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
project = dResource.getProject();
|
||||
if(rcType == IResource.FOLDER)
|
||||
rcToCheck = dResource;
|
||||
break;
|
||||
}
|
||||
|
||||
if(project != null) {
|
||||
IManagedBuilderMakefileGenerator makeGen = getInitializedGenerator(project);
|
||||
if(makeGen != null){
|
||||
if(rcToCheck == null || !makeGen.isGeneratedResource(rcToCheck))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (rcType == IResource.FILE && !dResource.isDerived()) {
|
||||
int flags = delta.getFlags();
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((flags & IResourceDelta.MOVED_TO) == 0) {
|
||||
handleDeleteFile(dResource.getFullPath());
|
||||
break;
|
||||
}
|
||||
case IResourceDelta.ADDED :
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((flags & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = delta.getMovedToPath();
|
||||
if (path != null) {
|
||||
handleRenamedFile(
|
||||
dResource.getFullPath(),
|
||||
path);
|
||||
}
|
||||
} else if ((flags & IResourceDelta.MOVED_FROM) != 0) {
|
||||
IPath path = delta.getMovedFromPath();
|
||||
if (path != null) {
|
||||
handleRenamedFile(
|
||||
path,
|
||||
dResource.getFullPath());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true; // visit the children
|
||||
}
|
||||
|
||||
private IPath substituteProject(IPath path, String projectName){
|
||||
return new Path(projectName).makeAbsolute().append(path.removeFirstSegments(1));
|
||||
}
|
||||
|
||||
private void handleRenamedFile(IPath fromPath, IPath toPath){
|
||||
if(!fValidatedFilesSet.add(fromPath))
|
||||
return;
|
||||
|
||||
IProject fromProject = findModifiedProject(fromPath.segment(0));
|
||||
if(fromProject == null)
|
||||
return;
|
||||
IManagedBuilderMakefileGenerator fromMakeGen = getInitializedGenerator(fromProject);
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
if(fromMakeGen == null || fromMakeGen.isGeneratedResource(root.getFile(substituteProject(fromPath,fromProject.getName()))))
|
||||
return;
|
||||
|
||||
IManagedBuildInfo fromInfo = fromProject != null ?
|
||||
ManagedBuildManager.getBuildInfo(fromProject) :
|
||||
null;
|
||||
|
||||
IProject toProject = root.findMember(toPath.uptoSegment(1)).getProject();
|
||||
IManagedBuildInfo toInfo = toProject != null ?
|
||||
ManagedBuildManager.getBuildInfo(toProject) :
|
||||
null;
|
||||
IManagedBuilderMakefileGenerator toMakeGen = toProject != null ?
|
||||
getInitializedGenerator(toProject) :
|
||||
null;
|
||||
if(toMakeGen != null && toMakeGen.isGeneratedResource(root.getFile(toPath)))
|
||||
toInfo = null;
|
||||
|
||||
if(fromInfo == toInfo){
|
||||
//the resource was moved whithing the project scope
|
||||
if(updateResourceConfigurations(fromInfo,fromPath,toPath) && toProject != null)
|
||||
fModifiedProjects.add(toProject);
|
||||
} else {
|
||||
if(fromInfo != null && toInfo != null){
|
||||
//TODO: this is the case when the resource
|
||||
//is moved from one managed project to another
|
||||
//should we handle this?
|
||||
//e.g. add resource configurations to the destination project?
|
||||
}
|
||||
if(fromInfo != null && removeResourceConfigurations(fromInfo,fromPath) && fromProject != null)
|
||||
fModifiedProjects.add(fromProject);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteFile(IPath path){
|
||||
IProject project = findModifiedProject(path.segment(0));
|
||||
if(project != null){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
if(info != null
|
||||
&& removeResourceConfigurations(info,path))
|
||||
fModifiedProjects.add(project);
|
||||
}
|
||||
}
|
||||
|
||||
//finds the project geven the initial project name
|
||||
//That is:
|
||||
// if the project of a given name was renamed returns the renamed project
|
||||
// if the project of a given name was removed returns null
|
||||
// if the project of a given name was neither renamed or removed
|
||||
// returns the project of that name or null if the project does not exist
|
||||
//
|
||||
private IProject findModifiedProject(final String oldProjectName){
|
||||
IResourceDelta projectDelta = fRootDelta.findMember(new Path(oldProjectName));
|
||||
boolean replaced = false;
|
||||
if(projectDelta != null) {
|
||||
switch(projectDelta.getKind()){
|
||||
case IResourceDelta.REMOVED :
|
||||
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
|
||||
return null;
|
||||
}
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
IPath path = projectDelta.getMovedToPath();
|
||||
if(path != null)
|
||||
return ResourcesPlugin.getWorkspace().getRoot().findMember(path).getProject();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final IProject project[] = new IProject[1];
|
||||
try {
|
||||
fRootDelta.accept(new IResourceDeltaVisitor() {
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
int rcType = dResource.getType();
|
||||
if(rcType == IResource.ROOT) {
|
||||
return true;
|
||||
} else if(rcType == IResource.PROJECT){
|
||||
switch(delta.getKind()){
|
||||
case IResourceDelta.ADDED :
|
||||
case IResourceDelta.CHANGED :
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
|
||||
IPath path = delta.getMovedFromPath();
|
||||
if (path != null && path.segment(0).equals(oldProjectName)) {
|
||||
project[0] = dResource.getProject();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
if(project[0] == null && !replaced)
|
||||
project[0] = ResourcesPlugin.getWorkspace().getRoot().findMember(oldProjectName).getProject();
|
||||
return project[0];
|
||||
}
|
||||
|
||||
private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){
|
||||
IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project);
|
||||
if (makeGen == null) {
|
||||
try {
|
||||
if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
|
||||
// Determine if we can access the build info before actually trying
|
||||
// If not, don't try, to avoid putting up a dialog box warning the user
|
||||
if (!ManagedBuildManager.canGetBuildInfo(project)) return null;
|
||||
|
||||
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
|
||||
if (buildInfo != null){
|
||||
IConfiguration defaultCfg = buildInfo.getDefaultConfiguration();
|
||||
if (defaultCfg != null) {
|
||||
makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg);
|
||||
makeGen.initialize(project,buildInfo,new NullProgressMonitor());
|
||||
fBuildFileGeneratorMap.put(project,makeGen);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return makeGen;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendClose(IProject project){
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
|
||||
if(info != null){
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* I R e s o u r c e C h a n g e L i s t e n e r
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* Handle the renaming and deletion of project resources
|
||||
* This is necessary in order to update ResourceConfigurations and AdditionalInputs
|
||||
*
|
||||
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
|
||||
*/
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
if (event.getSource() instanceof IWorkspace) {
|
||||
|
||||
switch (event.getType()) {
|
||||
case IResourceChangeEvent.PRE_CLOSE:
|
||||
IResource proj = event.getResource();
|
||||
if(proj instanceof IProject)
|
||||
sendClose((IProject)proj);
|
||||
break;
|
||||
case IResourceChangeEvent.POST_CHANGE :
|
||||
case IResourceChangeEvent.POST_BUILD :
|
||||
case IResourceChangeEvent.PRE_DELETE :
|
||||
IResourceDelta resDelta = event.getDelta();
|
||||
if (resDelta == null) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
ResourceConfigurationChecker rcChecker = new ResourceConfigurationChecker(resDelta);
|
||||
resDelta.accept(rcChecker);
|
||||
|
||||
//saving info for the modified projects
|
||||
initInfoSerialization(rcChecker.getModifiedProjects());
|
||||
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initInfoSerialization(final IProject projects[]){
|
||||
if(projects.length == 0)
|
||||
return;
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
|
||||
ISchedulingRule buildInfoSaveRule;
|
||||
if(projects.length == 1){
|
||||
buildInfoSaveRule = ruleFactory.modifyRule(projects[0]);
|
||||
} else {
|
||||
ISchedulingRule rules[] = new ISchedulingRule[projects.length];
|
||||
for(int i = 0; i < rules.length; i++)
|
||||
rules[i] = ruleFactory.modifyRule(projects[i]);
|
||||
buildInfoSaveRule = MultiRule.combine(rules);
|
||||
}
|
||||
|
||||
Job savingJob = new Job(ManagedMakeMessages.getResourceString("ResourceChangeHandler.buildInfoSerializationJob")){ //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
for(int i = 0; i < projects.length; i++){
|
||||
ManagedBuildManager.saveBuildInfo(projects[i],true);
|
||||
}
|
||||
return new Status(
|
||||
IStatus.OK,
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
IStatus.OK,
|
||||
new String(),
|
||||
null);
|
||||
}
|
||||
};
|
||||
savingJob.setRule(buildInfoSaveRule);
|
||||
|
||||
savingJob.schedule();
|
||||
}
|
||||
|
||||
private boolean updateResourceConfigurations(IManagedBuildInfo info, IPath oldPath, IPath newPath){
|
||||
boolean changed = false;
|
||||
if(!oldPath.equals(newPath)){
|
||||
IManagedProject mngProj = info.getManagedProject();
|
||||
if(mngProj != null){
|
||||
IConfiguration configs[] = mngProj.getConfigurations();
|
||||
if(configs != null && configs.length > 0){
|
||||
for(int i = 0; i < configs.length; i++){
|
||||
if(updateResourceConfiguration(configs[i],oldPath,newPath))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean removeResourceConfigurations(IManagedBuildInfo info, IPath path){
|
||||
boolean changed = false;
|
||||
IManagedProject mngProj = info.getManagedProject();
|
||||
if(mngProj != null){
|
||||
IConfiguration configs[] = mngProj.getConfigurations();
|
||||
if(configs != null && configs.length > 0){
|
||||
for(int i = 0; i < configs.length; i++){
|
||||
if(removeResourceConfiguration(configs[i],path))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){
|
||||
IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString());
|
||||
if(rcCfg != null && !oldPath.equals(newPath)){
|
||||
config.removeResourceConfiguration(rcCfg);
|
||||
rcCfg.setResourcePath(newPath.toString());
|
||||
((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
|
||||
config.setRebuildState(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean removeResourceConfiguration(IConfiguration config, IPath path){
|
||||
IResourceConfiguration rcCfg = config.getResourceConfiguration(path.toString());
|
||||
if(rcCfg != null){
|
||||
config.removeResourceConfiguration(rcCfg);
|
||||
config.setRebuildState(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* I S a v e P a r t i c i p a n t
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void saving(ISaveContext context) throws CoreException {
|
||||
// No state to be saved by the plug-in, but request a
|
||||
// resource delta to be used on next activation.
|
||||
context.needDelta();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void doneSaving(ISaveContext context) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void prepareToSave(ISaveContext context) throws CoreException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
|
||||
*/
|
||||
public void rollback(ISaveContext context) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -1,35 +1,27 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
public interface IManagedDependencyGenerator {
|
||||
public int TYPE_NODEPS = 0;
|
||||
public int TYPE_COMMAND = 1;
|
||||
public int TYPE_INDEXER = 2;
|
||||
public int TYPE_EXTERNAL = 3;
|
||||
|
||||
public IResource[] findDependencies(IResource resource, IProject project);
|
||||
public int getCalculatorType();
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
* @deprecated 3.1
|
||||
*
|
||||
* Use IManagedDependencyGenerator2 instead.
|
||||
*/
|
||||
public interface IManagedDependencyGenerator extends IManagedDependencyGeneratorType {
|
||||
|
||||
public IResource[] findDependencies(IResource resource, IProject project);
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
|
||||
}
|
||||
|
|
|
@ -1,89 +1,114 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation of IManagedDependencyGenerator
|
||||
* Intel - Initial API and implementation of IManagedDependencyGenerator2
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
|
||||
/**
|
||||
* @since NOT YET
|
||||
* This interface is PROPOSED and not yet used.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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.
|
||||
* @return IPath[]
|
||||
*/
|
||||
public IPath[] findDependencies(
|
||||
IPath source,
|
||||
IManagedBuildInfo info,
|
||||
ITool tool,
|
||||
IPath topBuildDirectory);
|
||||
|
||||
/**
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getDependencyCommand(
|
||||
IPath source,
|
||||
IManagedBuildInfo info,
|
||||
ITool tool,
|
||||
IPath topBuildDirectory);
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation of IManagedDependencyGenerator
|
||||
* Intel - Initial API and implementation of IManagedDependencyGenerator2
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen;
|
||||
|
||||
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 3.1
|
||||
*
|
||||
* A Tool dependency calculator must implement this interface. This interface
|
||||
* replaces IManagedDependencyGenerator which is deprecated.
|
||||
*
|
||||
* 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 extends IManagedDependencyGeneratorType {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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.
|
||||
* @return IManagedDependencyInfo
|
||||
*/
|
||||
public IManagedDependencyInfo getDependencySourceInfo(
|
||||
IPath source,
|
||||
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.
|
||||
*
|
||||
* @param buildContext The IConfiguration that contains the context of the build
|
||||
* @param tool The tool associated with the dependency generator.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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 don’t 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();
|
||||
}
|
|
@ -1,300 +1,300 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.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.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
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;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
public final String WHITESPACE = " "; //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_COMMAND;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand(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
|
||||
IConfiguration config = info.getDefaultConfiguration();
|
||||
|
||||
// We need to check whether we have any resource specific build information.
|
||||
IResourceConfiguration resConfig = null;
|
||||
if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
|
||||
|
||||
String inputExtension = resource.getFileExtension();
|
||||
String outputExtension = info.getOutputExtension(inputExtension);
|
||||
|
||||
// Work out the build-relative path for the output files
|
||||
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 +
|
||||
"$(dir $@)" + //$NON-NLS-1$
|
||||
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 to calculate dependencies
|
||||
IManagedCommandLineInfo cmdLInfo = null;
|
||||
String buildCmd = null;
|
||||
String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
String outflag = ""; //$NON-NLS-1$
|
||||
String outputPrefix = ""; //$NON-NLS-1$
|
||||
String outputFile = ""; //$NON-NLS-1$
|
||||
ITool[] tools;
|
||||
if( resConfig != null && (tools = resConfig.getToolsToInvoke()) != null && tools.length > 0) {
|
||||
ITool tool = tools[0];
|
||||
String cmd = tool.getToolCommand();
|
||||
//try to resolve the build macros in the tool command
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String[] toolFlags = null;
|
||||
try {
|
||||
toolFlags = tool.getToolCommandFlags(resource.getLocation(),null);
|
||||
} catch( BuildException ex ) {
|
||||
// TODO add some routines to catch this
|
||||
toolFlags = EMPTY_STRING_ARRAY;
|
||||
}
|
||||
String[] flags = new String[toolFlags.length + 4];
|
||||
flags[0] = "-MM"; //$NON-NLS-1$
|
||||
flags[1] = "-MG"; //$NON-NLS-1$
|
||||
flags[2] = "-P"; //$NON-NLS-1$
|
||||
flags[3] = "-w"; //$NON-NLS-1$
|
||||
for (int i=0; i<toolFlags.length; i++) {
|
||||
flags[4+i] = toolFlags[i];
|
||||
}
|
||||
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
|
||||
cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, tool.getCommandLinePattern() );
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
|
||||
// resolve any remaining macros in the command after it has been generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
ITool tool = null;
|
||||
tools = config.getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tmp = tools[index];
|
||||
if (tmp.buildsFileType(inputExtension)) {
|
||||
tool = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String cmd = tool != null ? tool.getToolCommand() : null;
|
||||
|
||||
//try to resolve the build macros in the tool command
|
||||
try{
|
||||
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),null,null,tool));
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String buildFlags = "-MM -MG -P -w " + info.getToolFlagsForSource(inputExtension, resource.getLocation(), null); //$NON-NLS-1$
|
||||
String[] flags = buildFlags.split( "\\s" ); //$NON-NLS-1$
|
||||
cmdLInfo = info.generateToolCommandLineInfo( inputExtension, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, resource.getLocation(), null);
|
||||
// The command to build
|
||||
if( cmdLInfo == null ) buildCmd =
|
||||
cmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-MM -MG -P -w " + //$NON-NLS-1$
|
||||
buildFlags +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
else {
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
}
|
||||
|
||||
// resolve any remaining macros in the command after it has been
|
||||
// generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append(IManagedBuilderMakefileGenerator.TAB +
|
||||
buildCmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">>" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE + depRule );
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.gnu;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.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.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||
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;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
private static final String EMPTY_STRING = new String();
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
public final String WHITESPACE = " "; //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
return TYPE_COMMAND;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand(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
|
||||
IConfiguration config = info.getDefaultConfiguration();
|
||||
|
||||
// We need to check whether we have any resource specific build information.
|
||||
IResourceConfiguration resConfig = null;
|
||||
if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
|
||||
|
||||
String inputExtension = resource.getFileExtension();
|
||||
String outputExtension = info.getOutputExtension(inputExtension);
|
||||
|
||||
// Work out the build-relative path for the output files
|
||||
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 +
|
||||
"$(dir $@)" + //$NON-NLS-1$
|
||||
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 to calculate dependencies
|
||||
IManagedCommandLineInfo cmdLInfo = null;
|
||||
String buildCmd = null;
|
||||
String[] inputs= new String[1]; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
String outflag = ""; //$NON-NLS-1$
|
||||
String outputPrefix = ""; //$NON-NLS-1$
|
||||
String outputFile = ""; //$NON-NLS-1$
|
||||
ITool[] tools;
|
||||
if( resConfig != null && (tools = resConfig.getToolsToInvoke()) != null && tools.length > 0) {
|
||||
ITool tool = tools[0];
|
||||
String cmd = tool.getToolCommand();
|
||||
//try to resolve the build macros in the tool command
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String[] toolFlags = null;
|
||||
try {
|
||||
toolFlags = tool.getToolCommandFlags(resource.getLocation(),null);
|
||||
} catch( BuildException ex ) {
|
||||
// TODO add some routines to catch this
|
||||
toolFlags = EMPTY_STRING_ARRAY;
|
||||
}
|
||||
String[] flags = new String[toolFlags.length + 4];
|
||||
flags[0] = "-MM"; //$NON-NLS-1$
|
||||
flags[1] = "-MG"; //$NON-NLS-1$
|
||||
flags[2] = "-P"; //$NON-NLS-1$
|
||||
flags[3] = "-w"; //$NON-NLS-1$
|
||||
for (int i=0; i<toolFlags.length; i++) {
|
||||
flags[4+i] = toolFlags[i];
|
||||
}
|
||||
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
|
||||
cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, tool.getCommandLinePattern() );
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
|
||||
// resolve any remaining macros in the command after it has been generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
ITool tool = null;
|
||||
tools = config.getFilteredTools();
|
||||
for (int index = 0; index < tools.length; index++) {
|
||||
ITool tmp = tools[index];
|
||||
if (tmp.buildsFileType(inputExtension)) {
|
||||
tool = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String cmd = tool != null ? tool.getToolCommand() : null;
|
||||
|
||||
//try to resolve the build macros in the tool command
|
||||
try{
|
||||
String resolvedCommand = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(cmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),null,null,tool));
|
||||
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
cmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e){
|
||||
}
|
||||
|
||||
String buildFlags = "-MM -MG -P -w " + info.getToolFlagsForSource(inputExtension, resource.getLocation(), null); //$NON-NLS-1$
|
||||
String[] flags = buildFlags.split( "\\s" ); //$NON-NLS-1$
|
||||
cmdLInfo = info.generateToolCommandLineInfo( inputExtension, flags, outflag, outputPrefix,
|
||||
outputFile, inputs, resource.getLocation(), null);
|
||||
// The command to build
|
||||
if( cmdLInfo == null ) buildCmd =
|
||||
cmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
"-MM -MG -P -w " + //$NON-NLS-1$
|
||||
buildFlags +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
IManagedBuilderMakefileGenerator.IN_MACRO;
|
||||
else {
|
||||
buildCmd = cmdLInfo.getCommandLine();
|
||||
}
|
||||
|
||||
// resolve any remaining macros in the command after it has been
|
||||
// generated
|
||||
try {
|
||||
String resolvedCommand = null;
|
||||
|
||||
// does the resource have spaces in its name?
|
||||
if (resource.getProjectRelativePath().toString().indexOf(" ") != -1) {
|
||||
// use fully qualified strings
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
} else {
|
||||
// use builder variables
|
||||
resolvedCommand = ManagedBuildManager
|
||||
.getBuildMacroProvider()
|
||||
.resolveValueToMakefileFormat(
|
||||
buildCmd,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_FILE,
|
||||
new FileContextData(resource.getLocation(),
|
||||
null, null, tool));
|
||||
}
|
||||
if ((resolvedCommand = resolvedCommand.trim()).length() > 0)
|
||||
buildCmd = resolvedCommand;
|
||||
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append(IManagedBuilderMakefileGenerator.TAB +
|
||||
buildCmd +
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE +
|
||||
">>" + //$NON-NLS-1$
|
||||
IManagedBuilderMakefileGenerator.WHITESPACE + depRule );
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,112 +1,122 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 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.Vector;
|
||||
|
||||
/**
|
||||
* This interface returns information about a Tool's inputs
|
||||
* and outputs while a Gnu makefile is being generated.
|
||||
*/
|
||||
public interface IManagedBuildGnuToolInfo {
|
||||
public final String DOT = "."; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's inputs have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areInputsCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's inputs in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandInputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's input file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedInputs();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's outputs have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areOutputsCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's outputs in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's primary output file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedPrimaryOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's secondary output file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedSecondaryOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's output variable names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getOutputVariables();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's dependencies have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areDependenciesCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's dependencies in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandDependencies();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's input dependencies.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
//public Vector getEnumeratedDependencies();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this is the target tool
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isTargetTool();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
* 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.Vector;
|
||||
|
||||
/**
|
||||
* This interface returns information about a Tool's inputs
|
||||
* and outputs while a Gnu makefile is being generated.
|
||||
*/
|
||||
public interface IManagedBuildGnuToolInfo {
|
||||
public final String DOT = "."; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's inputs have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areInputsCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's inputs in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandInputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's input file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedInputs();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's outputs have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areOutputsCalculated();
|
||||
|
||||
/**
|
||||
* Returns the tool's outputs in command line format. This will use
|
||||
* variables rather than actual file names as appropriate.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getCommandOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's primary output file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedPrimaryOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's secondary output file names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getEnumeratedSecondaryOutputs();
|
||||
|
||||
/**
|
||||
* Returns the raw list of tool's output variable names.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
public Vector getOutputVariables();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the tool's dependencies have been calculated,
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean areDependenciesCalculated();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return Vector
|
||||
*/
|
||||
//public Vector getEnumeratedDependencies();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this is the target tool
|
||||
* else <code>false</code>.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isTargetTool();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,87 +1,87 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.search.PathCollector;
|
||||
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.cdt.managedbuilder.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;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultIndexerDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
PathCollector pathCollector = new PathCollector();
|
||||
ICSearchScope scope = SearchEngine.createWorkspaceScope();
|
||||
CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(), ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES, ICSearchConstants.EXACT_MATCH, true);
|
||||
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.performConcurrentJob(
|
||||
new PatternSearchJob(
|
||||
(CSearchPattern) pattern,
|
||||
scope,
|
||||
pathCollector,
|
||||
indexManager),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
null, null);
|
||||
|
||||
// We will get back an array of resource names relative to the workspace
|
||||
String[] deps = pathCollector.getPaths();
|
||||
|
||||
// Convert them to something useful
|
||||
List depList = new ArrayList();
|
||||
IResource res = null;
|
||||
IWorkspaceRoot root = null;
|
||||
if (project != null) {
|
||||
root = project.getWorkspace().getRoot();
|
||||
}
|
||||
for (int index = 0; index < deps.length; ++index) {
|
||||
res = root.findMember(deps[index]);
|
||||
if (res != null) {
|
||||
depList.add(res);
|
||||
}
|
||||
}
|
||||
|
||||
return (IResource[]) depList.toArray(new IResource[depList.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
// Tell the
|
||||
return TYPE_INDEXER;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
// There is no command
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.makegen.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.search.PathCollector;
|
||||
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.cdt.managedbuilder.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;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DefaultIndexerDependencyCalculator implements IManagedDependencyGenerator {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
public IResource[] findDependencies(IResource resource, IProject project) {
|
||||
PathCollector pathCollector = new PathCollector();
|
||||
ICSearchScope scope = SearchEngine.createWorkspaceScope();
|
||||
CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(), ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES, ICSearchConstants.EXACT_MATCH, true);
|
||||
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.performConcurrentJob(
|
||||
new PatternSearchJob(
|
||||
(CSearchPattern) pattern,
|
||||
scope,
|
||||
pathCollector,
|
||||
indexManager),
|
||||
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||
null, null);
|
||||
|
||||
// We will get back an array of resource names relative to the workspace
|
||||
String[] deps = pathCollector.getPaths();
|
||||
|
||||
// Convert them to something useful
|
||||
List depList = new ArrayList();
|
||||
IResource res = null;
|
||||
IWorkspaceRoot root = null;
|
||||
if (project != null) {
|
||||
root = project.getWorkspace().getRoot();
|
||||
}
|
||||
for (int index = 0; index < deps.length; ++index) {
|
||||
res = root.findMember(deps[index]);
|
||||
if (res != null) {
|
||||
depList.add(res);
|
||||
}
|
||||
}
|
||||
|
||||
return (IResource[]) depList.toArray(new IResource[depList.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
|
||||
*/
|
||||
public int getCalculatorType() {
|
||||
// Tell the
|
||||
return TYPE_EXTERNAL;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
|
||||
*/
|
||||
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
|
||||
// There is no command
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue