Skip to main content
summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorLeo Treggiari2006-02-23 13:04:02 -0500
committerLeo Treggiari2006-02-23 13:04:02 -0500
commitc7f73a40517ebbe266d35bf3a3c441c1f33003b8 (patch)
treed73fb312c922b8a29287a34bc7e57e4adbe27c29 /build
parent373ff106c39360e7dfa8a07b02e6c88e0852118e (diff)
downloadorg.eclipse.cdt-c7f73a40517ebbe266d35bf3a3c441c1f33003b8.tar.gz
org.eclipse.cdt-c7f73a40517ebbe266d35bf3a3c441c1f33003b8.tar.xz
org.eclipse.cdt-c7f73a40517ebbe266d35bf3a3c441c1f33003b8.zip
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
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java782
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java1002
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java1451
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java2891
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java2004
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java2442
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java2946
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java1059
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java3720
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties219
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java913
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java5627
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java3446
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java2505
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCalculator.java79
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCommands.java168
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java62
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator2.java203
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGeneratorType.java87
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyInfo.java35
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java136
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java600
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2.java71
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java203
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuild.java70
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuildCommands.java308
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuDependencyGroupInfo.java37
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java8226
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/IManagedBuildGnuToolInfo.java234
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java1976
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/internal/DefaultIndexerDependencyCalculator.java174
31 files changed, 22682 insertions, 20994 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
index 9db563dff8..91dc116939 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
@@ -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);
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
index f50edcf6f3..58a95cdf21 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
@@ -1,501 +1,501 @@
-/*******************************************************************************
- * Copyright (c) 2003, 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
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.core;
-
-import java.util.List;
-
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
-import org.eclipse.core.runtime.IPath;
-
-/*
- * There is a ManagedBuildInfo per CDT managed build project. Here are
- * some notes on their usage:
- * o You can look up the managed build info associated with a CDT
- * project by using ManagedBuildManager.getBuildInfo(IProject).
- * o Given a ManagedBuildInfo, you can retrieve the associated CDT
- * managed build system project by using getManagedProject.
- * o The usage model of a ManagedBuildInfo is:
- * 1. Call setDefaultConfiguration to set the context
- * 2. Call other methods (e.g. getBuildArtifactName) which get
- * information from the default configuration, and the other managed
- * build system model elements that can be reached from the
- * configuration.
- */
-public interface IManagedBuildInfo {
- public static final String DEFAULT_CONFIGURATION = "defaultConfig"; //$NON-NLS-1$
- public static final String DEFAULT_TARGET = "defaultTarget"; //$NON-NLS-1$
-
- /*
- * Note: "Target" routines are only currently applicable when loading a CDT 2.0
- * or earlier managed build project file (.cdtbuild)
- */
-
- /**
- * Add a new target to the build information for the receiver
- *
- * @param target
- */
- public void addTarget(ITarget target);
-
- /**
- * Answers <code>true</code> if the build system knows how to
- * build a file with the extension passed in the argument.
- *
- * @param srcExt
- * @return
- */
- public boolean buildsFileType(String srcExt);
-
- /**
- * Returns <code>IManagedCommandLineInfo</code> for source with extension
- * The command line info contains values with
- * build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * command line info contains values contain all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the command line info contains values contain
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @param sourceExtension - source extension
- * @param flags - build flags
- * @param outputFlag - output flag for build tool
- * @param outputPrefix
- * @param outputName
- * @param inputResources
- * @return IManagedCommandLineInfo
- *
- * @deprecated - use generateToolCommandLineInfo instead
- */
- public IManagedCommandLineInfo generateCommandLineInfo( String sourceExtension, String[] flags,
- String outputFlag, String outputPrefix, String outputName, String[] inputResources );
-
- /**
- * Returns <code>IManagedCommandLineInfo</code> for source with extension
- * The command line info contains values with
- * build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * command line info contains values contain all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the command line info contains values contain
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @param sourceExtension
- * @param flags
- * @param outputFlag
- * @param outputPrefix
- * @param outputName
- * @param inputResources
- * @param inputLocation
- * @param outputLocation
- * @return
- */
- public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
- String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation );
-
- /**
- * Answers a <code>String</code> containing the arguments to be passed to make.
- * For example, if the user has selected a build that keeps going on error, the
- * answer would contain {"-k"}.
- *
- * @return String
- */
- public String getBuildArguments();
-
-
- /**
- * Answers the file extension for the receivers build goal without a separator.
- *
- * @return the extension or an empty string if none is defined
- */
- public String getBuildArtifactExtension();
-
- /**
- * Returns the name of the artifact to build for the receiver.
- *
- * @return
- */
- public String getBuildArtifactName();
-
- /**
- * Answers a <code>String</code> containing the make command invocation
- * for the default configuration.
- */
- public String getBuildCommand();
-
- /**
- * Answers the prebuild step for the default configuration
- *
- * @return String
- */
- public String getPrebuildStep();
-
- /**
- * Answers the postbuild step for the default configuration
- *
- * @return String
- */
- public String getPostbuildStep();
-
- /**
- * Answers the display string associated with the prebuild step for the default configuration
- *
- * @return String
- */
- public String getPreannouncebuildStep();
-
- /**
- * Answers the display string associated with the postbuild step for the default configuration
- *
- * @return String
- */
- public String getPostannouncebuildStep();
-
- /**
- * Answers the command needed to remove files on the build machine
- *
- * @return
- */
- public String getCleanCommand();
-
- /**
- * Answers the name of the default configuration, for example <code>Debug</code>
- * or <code>Release</code>.
- *
- * @return
- */
- public String getConfigurationName();
-
- /**
- * Answers a <code>String</code> array containing the names of all the configurations
- * defined for the project.
- *
- * @return
- */
- public String[] getConfigurationNames();
-
- /**
- * Get the default configuration associated with the receiver
- *
- * @return
- */
- public IConfiguration getDefaultConfiguration();
-
- /**
- * @param sourceExtension
- * @return
- */
- public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension);
-
- /**
- * Returns a <code>String</code> containing the flags, including
- * those overridden by the user, for the tool in the configuration
- * defined by the argument.
- * The string contains build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * the string contains all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the string contains
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @param extension
- * @return
- *
- * @deprecated - use getToolFlagsForConfiguration
- */
- public String getFlagsForConfiguration(String extension);
-
- /**
- * Returns a <code>String</code> containing the flags, including
- * those overridden by the user, for the tool in the configuration
- * defined by the argument.
- * The string contains build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * the string contains all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the string contains
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @param extension
- * @param inputLocation
- * @param outputLocation
- * @return
- */
- public String getToolFlagsForConfiguration(String extension, IPath inputLocation, IPath outputLocation);
-
- /**
- * Returns a <code>String</code> containing the flags, including
- * those overridden by the user, for the tool that handles the
- * type of source file defined by the argument.
- * The string contains build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * the string contains all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the string contains
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @param extension
- * @return
- *
- * @deprecated - use getToolFlagsForSource
- */
- public String getFlagsForSource(String extension);
-
- /**
- * Returns a <code>String</code> containing the flags, including
- * those overridden by the user, for the tool that handles the
- * type of source file defined by the argument.
- * The string contains build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * the string contains all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the string contains
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @param extension
- * @param inputLocation
- * @param outputLocation
- * @return
- */
- public String getToolFlagsForSource(String extension, IPath inputLocation, IPath outputLocation);
-
- /**
- * Answers the libraries the project links in.
- *
- * @param extension
- * @return
- */
- public String[] getLibsForConfiguration(String extension);
-
- /**
- * Returns the ManagedProject associated with this build info
- *
- * @return IManagedProject
- */
- public IManagedProject getManagedProject( );
-
- /**
- * Answers the extension that will be built by the current configuration
- * for the extension passed in the argument or <code>null</code>.
- *
- * @param resourceName
- * @return
- */
- public String getOutputExtension(String resourceExtension);
-
- /**
- * Answers the flag to be passed to the build tool to produce a specific output
- * or an empty <code>String</code> if there is no special flag. For example, the
- * GCC tools use the '-o' flag to produce a named output, for example
- * gcc -c foo.c -o foo.o
- *
- * @param outputExt
- * @return
- */
- public String getOutputFlag(String outputExt);
-
- /**
- * Answers the prefix that should be prepended to the name of the build
- * artifact. For example, a library foo, should have the prefix 'lib' and
- * the extension '.a', so the final goal would be 'libfoo.a'
- *
- * @param extension
- * @return the prefix or an empty string
- */
- public String getOutputPrefix(String outputExtension);
-
- /**
- * Returns the currently selected configuration. This is used while the project
- * property pages are displayed
- *
- * @return IConfiguration
- */
- public IConfiguration getSelectedConfiguration();
-
- /**
- * Get the target specified in the argument.
- *
- * @param id
- * @return
- */
- public ITarget getTarget(String id);
-
- /**
- * Get all of the targets associated with the receiver.
- *
- * @return
- */
- public List getTargets();
-
- /**
- * Returns a <code>String</code> containing the command-line invocation
- * for the tool associated with the output extension.
- *
- * @param extension the file extension of the output file
- * @return a String containing the command line invocation for the tool
- */
- public String getToolForConfiguration(String extension);
-
- /**
- * Returns a <code>String</code> containing the command-line invocation
- * for the tool associated with the source extension.
- *
- * @param sourceExtension the file extension of the file to be built
- * @return a String containing the command line invocation for the tool
- */
- public String getToolForSource(String sourceExtension);
-
- /**
- * Returns a <code>ITool</code> for the tool associated with the
- * input extension.
- *
- * @param extension the file extension of the input file
- * @return ITool
- */
- public ITool getToolFromInputExtension(String extension);
-
- /**
- * Returns a <code>ITool</code> for the tool associated with the
- * output extension.
- *
- * @param extension the file extension of the output file
- * @return ITool
- */
- public ITool getToolFromOutputExtension(String extension);
-
- /**
- * Answers a <code>String</code> array containing the contents of the
- * user objects option, if one is defined for the target.
- *
- * @param extension the file ecxtension of the build target
- * @return
- */
- public String[] getUserObjectsForConfiguration(String extension);
-
-
- /**
- * Answers the version of the build information in the format
- * @return a <code>String</code> containing the build information
- * version
- */
- public String getVersion();
-
- /**
- * Answers true if the build model has been changed by the user.
- *
- * @return boolean
- */
- public boolean isDirty();
-
- /**
- * Answers <code>true</code> if the extension matches one of the special
- * file extensions the tools for the configuration consider to be a header file.
- *
- * @param ext the file extension of the resource
- * @return boolean
- */
- public boolean isHeaderFile(String ext);
-
- /**
- * Gets the read only status of Managed Build Info
- *
- * @return <code>true</code> if Managed Build Info is read only
- * otherwise returns <code>false</code>
- */
- public boolean isReadOnly();
-
- /**
- * Gets the "valid" status of Managed Build Info. Managed Build Info is invalid
- * if the loading of, or conversion to, the Managed Build Info failed.
- *
- * @return <code>true</code> if Managed Build Info is valid,
- * otherwise returns <code>false</code>
- */
- public boolean isValid();
-
- /**
- * Answers whether the receiver has been changed and requires the
- * project to be rebuilt. When a project is first created, it is
- * assumed that the user will need it to be fully rebuilt. However
- * only option and tool command changes will trigger the build
- * information for an existing project to require a rebuild.
- * <p>
- * Clients can reset the state to force or clear the rebuild status
- * using <code>setRebuildState()</code>
- * @see ManagedBuildInfo#setRebuildState(boolean)
- *
- * @return <code>true</code> if the resource managed by the
- * receiver needs to be rebuilt
- */
- public boolean needsRebuild();
-
- public void removeTarget(String id);
-
- /**
- * Set the primary configuration for the receiver.
- *
- * @param configuration The <code>IConfiguration</code> that will be used as the default
- * for all building.
- */
- public void setDefaultConfiguration(IConfiguration configuration);
-
- /**
- *
- * @param configuration
- * @return
- */
- public boolean setDefaultConfiguration(String configName);
-
- /**
- * Sets the dirty flag for the build model to the value of the argument.
- *
- * @param isDirty
- */
- public void setDirty(boolean isDirty);
-
- /**
- * Sets the valid flag for the build model to the value of the argument.
- *
- * @param isValid
- */
- public void setValid(boolean isValid);
-
- /**
- * Sets the ManagedProject associated with this build info
- *
- * @param project
- */
- public void setManagedProject(IManagedProject project);
-
- /**
- * sets the read only status of Managed Build Info
- *
- * @param readOnly
- */
- public void setReadOnly(boolean readOnly);
-
- /**
- * Sets the rebuild state in the receiver to the value of the argument.
- * This is a potentially expensive option, so setting it to true should
- * only be done if a project resource or setting has been modified in a
- * way that would invalidate the previous build.
- *
- * @param <code>true</code> will force a rebuild the next time the project builds
- */
- public void setRebuildState(boolean rebuild);
-
- /**
- * Sets the currently selected configuration. This is used while the project
- * property pages are displayed
- *
- * @param configuration the user selection
- */
- public void setSelectedConfiguration(IConfiguration configuration);
-}
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
+import org.eclipse.core.runtime.IPath;
+
+/*
+ * There is a ManagedBuildInfo per CDT managed build project. Here are
+ * some notes on their usage:
+ * o You can look up the managed build info associated with a CDT
+ * project by using ManagedBuildManager.getBuildInfo(IProject).
+ * o Given a ManagedBuildInfo, you can retrieve the associated CDT
+ * managed build system project by using getManagedProject.
+ * o The usage model of a ManagedBuildInfo is:
+ * 1. Call setDefaultConfiguration to set the context
+ * 2. Call other methods (e.g. getBuildArtifactName) which get
+ * information from the default configuration, and the other managed
+ * build system model elements that can be reached from the
+ * configuration.
+ */
+public interface IManagedBuildInfo {
+ public static final String DEFAULT_CONFIGURATION = "defaultConfig"; //$NON-NLS-1$
+ public static final String DEFAULT_TARGET = "defaultTarget"; //$NON-NLS-1$
+
+ /*
+ * Note: "Target" routines are only currently applicable when loading a CDT 2.0
+ * or earlier managed build project file (.cdtbuild)
+ */
+
+ /**
+ * Add a new target to the build information for the receiver
+ *
+ * @param target
+ */
+ public void addTarget(ITarget target);
+
+ /**
+ * Answers <code>true</code> if the build system knows how to
+ * build a file with the extension passed in the argument.
+ *
+ * @param srcExt
+ * @return
+ */
+ public boolean buildsFileType(String srcExt);
+
+ /**
+ * Returns <code>IManagedCommandLineInfo</code> for source with extension
+ * The command line info contains values with
+ * build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * command line info contains values contain all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the command line info contains values contain
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @param sourceExtension - source extension
+ * @param flags - build flags
+ * @param outputFlag - output flag for build tool
+ * @param outputPrefix
+ * @param outputName
+ * @param inputResources
+ * @return IManagedCommandLineInfo
+ *
+ * @deprecated - use generateToolCommandLineInfo instead
+ */
+ public IManagedCommandLineInfo generateCommandLineInfo( String sourceExtension, String[] flags,
+ String outputFlag, String outputPrefix, String outputName, String[] inputResources );
+
+ /**
+ * Returns <code>IManagedCommandLineInfo</code> for source with extension
+ * The command line info contains values with
+ * build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * command line info contains values contain all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the command line info contains values contain
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @param sourceExtension
+ * @param flags
+ * @param outputFlag
+ * @param outputPrefix
+ * @param outputName
+ * @param inputResources
+ * @param inputLocation
+ * @param outputLocation
+ * @return
+ */
+ public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
+ String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation );
+
+ /**
+ * Answers a <code>String</code> containing the arguments to be passed to make.
+ * For example, if the user has selected a build that keeps going on error, the
+ * answer would contain {"-k"}.
+ *
+ * @return String
+ */
+ public String getBuildArguments();
+
+
+ /**
+ * Answers the file extension for the receivers build goal without a separator.
+ *
+ * @return the extension or an empty string if none is defined
+ */
+ public String getBuildArtifactExtension();
+
+ /**
+ * Returns the name of the artifact to build for the receiver.
+ *
+ * @return
+ */
+ public String getBuildArtifactName();
+
+ /**
+ * Answers a <code>String</code> containing the make command invocation
+ * for the default configuration.
+ */
+ public String getBuildCommand();
+
+ /**
+ * Answers the prebuild step for the default configuration
+ *
+ * @return String
+ */
+ public String getPrebuildStep();
+
+ /**
+ * Answers the postbuild step for the default configuration
+ *
+ * @return String
+ */
+ public String getPostbuildStep();
+
+ /**
+ * Answers the display string associated with the prebuild step for the default configuration
+ *
+ * @return String
+ */
+ public String getPreannouncebuildStep();
+
+ /**
+ * Answers the display string associated with the postbuild step for the default configuration
+ *
+ * @return String
+ */
+ public String getPostannouncebuildStep();
+
+ /**
+ * Answers the command needed to remove files on the build machine
+ *
+ * @return
+ */
+ public String getCleanCommand();
+
+ /**
+ * Answers the name of the default configuration, for example <code>Debug</code>
+ * or <code>Release</code>.
+ *
+ * @return
+ */
+ public String getConfigurationName();
+
+ /**
+ * Answers a <code>String</code> array containing the names of all the configurations
+ * defined for the project.
+ *
+ * @return
+ */
+ public String[] getConfigurationNames();
+
+ /**
+ * Get the default configuration associated with the receiver
+ *
+ * @return
+ */
+ public IConfiguration getDefaultConfiguration();
+
+ /**
+ * @param sourceExtension
+ * @return
+ */
+ public IManagedDependencyGeneratorType getDependencyGenerator(String sourceExtension);
+
+ /**
+ * Returns a <code>String</code> containing the flags, including
+ * those overridden by the user, for the tool in the configuration
+ * defined by the argument.
+ * The string contains build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * the string contains all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the string contains
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @param extension
+ * @return
+ *
+ * @deprecated - use getToolFlagsForConfiguration
+ */
+ public String getFlagsForConfiguration(String extension);
+
+ /**
+ * Returns a <code>String</code> containing the flags, including
+ * those overridden by the user, for the tool in the configuration
+ * defined by the argument.
+ * The string contains build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * the string contains all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the string contains
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @param extension
+ * @param inputLocation
+ * @param outputLocation
+ * @return
+ */
+ public String getToolFlagsForConfiguration(String extension, IPath inputLocation, IPath outputLocation);
+
+ /**
+ * Returns a <code>String</code> containing the flags, including
+ * those overridden by the user, for the tool that handles the
+ * type of source file defined by the argument.
+ * The string contains build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * the string contains all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the string contains
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @param extension
+ * @return
+ *
+ * @deprecated - use getToolFlagsForSource
+ */
+ public String getFlagsForSource(String extension);
+
+ /**
+ * Returns a <code>String</code> containing the flags, including
+ * those overridden by the user, for the tool that handles the
+ * type of source file defined by the argument.
+ * The string contains build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * the string contains all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the string contains
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @param extension
+ * @param inputLocation
+ * @param outputLocation
+ * @return
+ */
+ public String getToolFlagsForSource(String extension, IPath inputLocation, IPath outputLocation);
+
+ /**
+ * Answers the libraries the project links in.
+ *
+ * @param extension
+ * @return
+ */
+ public String[] getLibsForConfiguration(String extension);
+
+ /**
+ * Returns the ManagedProject associated with this build info
+ *
+ * @return IManagedProject
+ */
+ public IManagedProject getManagedProject( );
+
+ /**
+ * Answers the extension that will be built by the current configuration
+ * for the extension passed in the argument or <code>null</code>.
+ *
+ * @param resourceName
+ * @return
+ */
+ public String getOutputExtension(String resourceExtension);
+
+ /**
+ * Answers the flag to be passed to the build tool to produce a specific output
+ * or an empty <code>String</code> if there is no special flag. For example, the
+ * GCC tools use the '-o' flag to produce a named output, for example
+ * gcc -c foo.c -o foo.o
+ *
+ * @param outputExt
+ * @return
+ */
+ public String getOutputFlag(String outputExt);
+
+ /**
+ * Answers the prefix that should be prepended to the name of the build
+ * artifact. For example, a library foo, should have the prefix 'lib' and
+ * the extension '.a', so the final goal would be 'libfoo.a'
+ *
+ * @param extension
+ * @return the prefix or an empty string
+ */
+ public String getOutputPrefix(String outputExtension);
+
+ /**
+ * Returns the currently selected configuration. This is used while the project
+ * property pages are displayed
+ *
+ * @return IConfiguration
+ */
+ public IConfiguration getSelectedConfiguration();
+
+ /**
+ * Get the target specified in the argument.
+ *
+ * @param id
+ * @return
+ */
+ public ITarget getTarget(String id);
+
+ /**
+ * Get all of the targets associated with the receiver.
+ *
+ * @return
+ */
+ public List getTargets();
+
+ /**
+ * Returns a <code>String</code> containing the command-line invocation
+ * for the tool associated with the output extension.
+ *
+ * @param extension the file extension of the output file
+ * @return a String containing the command line invocation for the tool
+ */
+ public String getToolForConfiguration(String extension);
+
+ /**
+ * Returns a <code>String</code> containing the command-line invocation
+ * for the tool associated with the source extension.
+ *
+ * @param sourceExtension the file extension of the file to be built
+ * @return a String containing the command line invocation for the tool
+ */
+ public String getToolForSource(String sourceExtension);
+
+ /**
+ * Returns a <code>ITool</code> for the tool associated with the
+ * input extension.
+ *
+ * @param extension the file extension of the input file
+ * @return ITool
+ */
+ public ITool getToolFromInputExtension(String extension);
+
+ /**
+ * Returns a <code>ITool</code> for the tool associated with the
+ * output extension.
+ *
+ * @param extension the file extension of the output file
+ * @return ITool
+ */
+ public ITool getToolFromOutputExtension(String extension);
+
+ /**
+ * Answers a <code>String</code> array containing the contents of the
+ * user objects option, if one is defined for the target.
+ *
+ * @param extension the file ecxtension of the build target
+ * @return
+ */
+ public String[] getUserObjectsForConfiguration(String extension);
+
+
+ /**
+ * Answers the version of the build information in the format
+ * @return a <code>String</code> containing the build information
+ * version
+ */
+ public String getVersion();
+
+ /**
+ * Answers true if the build model has been changed by the user.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Answers <code>true</code> if the extension matches one of the special
+ * file extensions the tools for the configuration consider to be a header file.
+ *
+ * @param ext the file extension of the resource
+ * @return boolean
+ */
+ public boolean isHeaderFile(String ext);
+
+ /**
+ * Gets the read only status of Managed Build Info
+ *
+ * @return <code>true</code> if Managed Build Info is read only
+ * otherwise returns <code>false</code>
+ */
+ public boolean isReadOnly();
+
+ /**
+ * Gets the "valid" status of Managed Build Info. Managed Build Info is invalid
+ * if the loading of, or conversion to, the Managed Build Info failed.
+ *
+ * @return <code>true</code> if Managed Build Info is valid,
+ * otherwise returns <code>false</code>
+ */
+ public boolean isValid();
+
+ /**
+ * Answers whether the receiver has been changed and requires the
+ * project to be rebuilt. When a project is first created, it is
+ * assumed that the user will need it to be fully rebuilt. However
+ * only option and tool command changes will trigger the build
+ * information for an existing project to require a rebuild.
+ * <p>
+ * Clients can reset the state to force or clear the rebuild status
+ * using <code>setRebuildState()</code>
+ * @see ManagedBuildInfo#setRebuildState(boolean)
+ *
+ * @return <code>true</code> if the resource managed by the
+ * receiver needs to be rebuilt
+ */
+ public boolean needsRebuild();
+
+ public void removeTarget(String id);
+
+ /**
+ * Set the primary configuration for the receiver.
+ *
+ * @param configuration The <code>IConfiguration</code> that will be used as the default
+ * for all building.
+ */
+ public void setDefaultConfiguration(IConfiguration configuration);
+
+ /**
+ *
+ * @param configuration
+ * @return
+ */
+ public boolean setDefaultConfiguration(String configName);
+
+ /**
+ * Sets the dirty flag for the build model to the value of the argument.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Sets the valid flag for the build model to the value of the argument.
+ *
+ * @param isValid
+ */
+ public void setValid(boolean isValid);
+
+ /**
+ * Sets the ManagedProject associated with this build info
+ *
+ * @param project
+ */
+ public void setManagedProject(IManagedProject project);
+
+ /**
+ * sets the read only status of Managed Build Info
+ *
+ * @param readOnly
+ */
+ public void setReadOnly(boolean readOnly);
+
+ /**
+ * Sets the rebuild state in the receiver to the value of the argument.
+ * This is a potentially expensive option, so setting it to true should
+ * only be done if a project resource or setting has been modified in a
+ * way that would invalidate the previous build.
+ *
+ * @param <code>true</code> will force a rebuild the next time the project builds
+ */
+ public void setRebuildState(boolean rebuild);
+
+ /**
+ * Sets the currently selected configuration. This is used while the project
+ * property pages are displayed
+ *
+ * @param configuration the user selection
+ */
+ public void setSelectedConfiguration(IConfiguration configuration);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
index 35648ee55f..3d04cd8d69 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
@@ -1,725 +1,726 @@
-/*******************************************************************************
- * Copyright (c) 2003, 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.core;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
-
-/**
- * This interface represents a utility of some sort that is used in the build process.
- * A tool will generally process one or more resources to produce output resources.
- * Most tools have a set of options that can be used to modify the behavior of the tool.
- */
-public interface ITool extends IBuildObject, IHoldsOptions {
- // Schema element names
- public static final String COMMAND = "command"; //$NON-NLS-1$
- public static final String COMMAND_LINE_PATTERN = "commandLinePattern"; //$NON-NLS-1$
- public static final String COMMAND_LINE_GENERATOR = "commandLineGenerator"; //$NON-NLS-1$
- public static final String DEP_CALC_ID ="dependencyCalculator"; //$NON-NLS-1$
- public static final String INTERFACE_EXTS = "headerExtensions"; //$NON-NLS-1$
- public static final String NATURE = "natureFilter"; //$NON-NLS-1$
- public static final String OUTPUT_FLAG = "outputFlag"; //$NON-NLS-1$
- public static final String INPUT_TYPE = "inputType"; //$NON-NLS-1$
- public static final String OUTPUT_TYPE = "outputType"; //$NON-NLS-1$
- public static final String OUTPUT_PREFIX = "outputPrefix"; //$NON-NLS-1$
- public static final String OUTPUTS = "outputs"; //$NON-NLS-1$
- public static final String SOURCES = "sources"; //$NON-NLS-1$
- public static final String ADVANCED_INPUT_CATEGORY = "advancedInputCategory"; //$NON-NLS-1$
- public static final String CUSTOM_BUILD_STEP = "customBuildStep"; //$NON-NLS-1$
- public static final String ANNOUNCEMENT = "announcement"; //$NON-NLS-1$
- public static final String TOOL_ELEMENT_NAME = "tool"; //$NON-NLS-1$
- public static final String WHITE_SPACE = " "; //$NON-NLS-1$
- public static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- public static final String VERSIONS_SUPPORTED = "versionsSupported"; //$NON-NLS-1$
- public static final String CONVERT_TO_ID = "convertToId"; //$NON-NLS-1$
-
- public static final int FILTER_C = 0;
- public static final int FILTER_CC = 1;
- public static final int FILTER_BOTH = 2;
-
- /**
- * Returns the tool-chain or resource configuration that is the parent of this tool.
- *
- * @return IBuildObject
- */
- public IBuildObject getParent();
-
- /**
- * Creates a child InputType for this tool.
- *
- * @param InputType The superClass, if any
- * @param String The id for the new InputType
- * @param String The name for the new InputType
- * @param boolean Indicates whether this is an extension element or a managed project element
- *
- * @return IInputType
- * @since 3.0
- */
- public IInputType createInputType(IInputType superClass, String Id, String name, boolean isExtensionElement);
-
- /**
- * Removes an InputType from the tool's list.
- *
- * @param type
- * @since 3.0
- */
- public void removeInputType(IInputType type);
-
- /**
- * Returns the complete list of input types that are available for this tool.
- * The list is a merging of the input types specified for this tool with the
- * input types of its superclasses. The lowest input type instance in the hierarchy
- * takes precedence.
- *
- * @return IInputType[]
- * @since 3.0
- */
- public IInputType[] getInputTypes();
-
- /**
- * Returns the <code>IInputType</code> in the tool with the specified
- * ID. This is an efficient search in the receiver.
- *
- * <p>If the receiver does not have an InputType with that ID, the method
- * returns <code>null</code>. It is the responsibility of the caller to
- * verify the return value.
- *
- * @param id unique identifier of the InputType to search for
- * @return <code>IInputType</code>
- * @since 3.0
- */
- public IInputType getInputTypeById(String id);
-
- /**
- * Returns the <code>IInputType</code> in the tool that uses the
- * specified extension.
- *
- * <p>If the receiver does not have an InputType that uses the extension,
- * the method returns <code>null</code>. It is the responsibility of the
- * caller to verify the return value.
- *
- * @param inputExtension File extension
- * @return <code>IInputType</code>
- * @since 3.0
- */
- public IInputType getInputType(String inputExtension);
-
- /**
- * Returns the primary <code>IInputType</code> in this tool
- *
- * <p>If the receiver has no InputTypes,
- * the method returns <code>null</code>. It is the responsibility of the
- * caller to verify the return value.
- *
- * @return <code>IInputType</code>
- * @since 3.0
- */
- public IInputType getPrimaryInputType();
-
- /**
- * Returns all of the additional input resources of all InputType children.
- * Note: This does not include the primary InputType and does not include
- * additional dependencies.
- *
- * @return IPath[]
- */
- public IPath[] getAdditionalResources();
-
- /**
- * Returns all of the additional dependency resources of all InputType children.
- * Note: This does not include the primary InputType and does not include
- * additional inputs.
- *
- * @return IPath[]
- */
- public IPath[] getAdditionalDependencies();
-
- /**
- * Creates a child OutputType for this tool.
- *
- * @param OutputType The superClass, if any
- * @param String The id for the new OutputType
- * @param String The name for the new OutputType
- * @param boolean Indicates whether this is an extension element or a managed project element
- *
- * @return IOutputType
- * @since 3.0
- */
- public IOutputType createOutputType(IOutputType superClass, String Id, String name, boolean isExtensionElement);
-
- /**
- * Removes an OutputType from the tool's list.
- *
- * @param type
- * @since 3.0
- */
- public void removeOutputType(IOutputType type);
-
- /**
- * Returns the complete list of output types that are available for this tool.
- * The list is a merging of the output types specified for this tool with the
- * output types of its superclasses. The lowest output type instance in the hierarchy
- * takes precedence.
- *
- * @return IOutputType[]
- * @since 3.0
- */
- public IOutputType[] getOutputTypes();
- /**
- * Get the <code>IOutputType</code> in the receiver with the specified
- * ID. This is an efficient search in the receiver.
- *
- * <p>If the receiver does not have an OutputType with that ID, the method
- * returns <code>null</code>. It is the responsibility of the caller to
- * verify the return value.
- *
- * @param id unique identifier of the OutputType to search for
- * @return <code>IOutputType</code>
- * @since 3.0
- */
- public IOutputType getOutputTypeById(String id);
-
- /**
- * Returns the <code>IOutputType</code> in the tool that creates the
- * specified extension.
- *
- * <p>If the receiver does not have an OutputType that creates the extension,
- * the method returns <code>null</code>. It is the responsibility of the
- * caller to verify the return value.
- *
- * @param outputExtension File extension
- * @return <code>IOutputType</code>
- * @since 3.0
- */
- public IOutputType getOutputType(String outputExtension);
-
- /**
- * Returns the primary <code>IOutputType</code> in this tool
- *
- * <p>If the receiver has no OutputTypes,
- * the method returns <code>null</code>. It is the responsibility of the
- * caller to verify the return value.
- *
- * @return <code>IOutputType</code>
- * @since 3.0
- */
- public IOutputType getPrimaryOutputType();
-
- /**
- * Returns the <code>ITool</code> that is the superclass of this
- * tool, or <code>null</code> if the attribute was not specified.
- *
- * @return ITool
- */
- public ITool getSuperClass();
-
- /**
- * Returns whether this element is abstract. Returns <code>false</code>
- * if the attribute was not specified.
- * @return boolean
- */
- public boolean isAbstract();
-
- /**
- * Sets the isAbstract attribute of the tool-chain.
- *
- * @param b
- */
- public void setIsAbstract(boolean b);
-
- /**
- * Returns a semi-colon delimited list of child Ids of the superclass'
- * children that should not be automatically inherited by this element.
- * Returns an empty string if the attribute was not specified.
- * @return String
- */
- public String getUnusedChildren();
-
- /**
- * Returns the semicolon separated list of unique IDs of the error parsers associated
- * with the tool.
- *
- * @return String
- */
- public String getErrorParserIds();
-
- /**
- * Returns the ordered list of unique IDs of the error parsers associated with the
- * tool.
- *
- * @return String[]
- */
- public String[] getErrorParserList();
-
- /**
- * Sets the semicolon separated list of error parser ids
- *
- * @param ids
- */
- public void setErrorParserIds(String ids);
-
- /**
- * Returns the list of valid source extensions this tool knows how to build.
- * The list may be empty but will never be <code>null</code>.
- *
- * @return List
- * @deprecated - use getPrimaryInputExtensions or getAllInputExtensions
- */
- public List getInputExtensions();
-
- /**
- * Returns the array of valid primary source extensions this tool knows how to build.
- * The array may be empty but will never be <code>null</code>.
- *
- * @return String[]
- */
- public String[] getPrimaryInputExtensions();
-
- /**
- * Returns the array of all valid source extensions this tool knows how to build.
- * The array may be empty but will never be <code>null</code>.
- *
- * @return String[]
- */
- public String[] getAllInputExtensions();
-
- /**
- * Returns the default input extension for the primary input of the tool
- *
- * @return String
- */
- public String getDefaultInputExtension();
-
- /**
- * Returns the array of all valid dependency extensions for this tool's inputs.
- * The array may be empty but will never be <code>null</code>.
- *
- * @return String[]
- */
- public String[] getAllDependencyExtensions();
-
- /**
- * Returns the list of valid header extensions for this tool.
- * Returns the value of the headerExtensions attribute
- * The list may be empty but will never be <code>null</code>.
- *
- * @return List
- * @deprecated - use getDependency* methods
- */
- public List getInterfaceExtensions();
-
- /**
- * Answers a constant corresponding to the project nature the tool should be used
- * for. Possible answers are:
- *
- * <dl>
- * <dt>ITool.FILTER_C
- * <dd>The tool should only be displayed for C projects. <i>Notes:</i> even
- * though a C++ project has a C nature, this flag will mask the tool for C++
- * projects.
- * <dt>ITool.FILTER_CC
- * <dd>The tool should only be displayed for C++ projects.
- * <dt>ITool.FILTER_BOTH
- * <dd>The tool should be displayed for projects with both natures.
- * </dl>
- *
- * @return int
- */
- public int getNatureFilter();
-
- /**
- * Returns the array of all valid output extensions this tool can create.
- * The array may be empty but will never be <code>null</code>.
- *
- * @return String[]
- */
- public String[] getAllOutputExtensions();
-
- /**
- * Answers all of the output extensions that the receiver can build.
- * This routine returns the value if the outputs attribute.
- *
- * @return <code>String[]</code> of extensions
- * @deprecated - use getAllOutputExtensions
- */
- public String[] getOutputExtensions();
-
- /**
- * Answers all of the output extensions that the receiver can build,
- * from the value of the outputs attribute
- *
- * @return <code>String[]</code> of extensions
- */
- public String[] getOutputsAttribute();
-
- /**
- * Answer the output extension the receiver will create from the input,
- * or <code>null</code> if the tool does not understand that extension.
- *
- * @param inputExtension The extension of the source file.
- * @return String
- */
- public String getOutputExtension(String inputExtension);
-
- /**
- * Sets all of the output extensions that the receiver can build,
- * into the outputs attribute. Note that the outputs attribute is
- * ignored when one or more outputTypes are specified.
- *
- * @param String
- */
- public void setOutputsAttribute(String extensions);
-
- /**
- * Answers the argument that must be passed to a specific tool in order to
- * control the name of the output artifact. For example, the GCC compile and
- * linker use '-o', while the archiver does not.
- *
- * @return String
- */
- public String getOutputFlag();
-
- /**
- * Sets the argument that must be passed to a specific tool in order to
- * control the name of the output artifact. For example, the GCC compile and
- * linker use '-o', while the archiver does not.
- *
- * @param String
- */
- public void setOutputFlag(String flag);
-
- /**
- * Answers the prefix that the tool should prepend to the name of the build artifact.
- * For example, a librarian usually prepends 'lib' to the target.a
- * @return String
- */
- public String getOutputPrefix();
-
- /**
- * Sets the prefix that the tool should prepend to the name of the build artifact.
- * For example, a librarian usually prepends 'lib' to the target.a
- * @param String
- */
- public void setOutputPrefix(String prefix);
-
- /**
- * Returns <code>true</code> if the Tool wants the MBS to display the Advanced
- * Input category that allows the user to specify additional input resources and
- * dependencies, else <code>false</code>.
- *
- * @return boolean
- */
- public boolean getAdvancedInputCategory();
-
- /**
- * Sets whether the Tool wants the MBS to display the Advanced
- * Input category that allows the user to specify additional input resources and
- * dependencies.
- *
- * @param display
- */
- public void setAdvancedInputCategory(boolean display);
-
- /**
- * Returns <code>true</code> if the Tool represents a user-define custom build
- * step, else <code>false</code>.
- *
- * @return boolean
- */
- public boolean getCustomBuildStep();
-
- /**
- * Sets whether the Tool represents a user-define custom build step.
- *
- * @param customBuildStep
- */
- public void setCustomBuildStep(boolean customBuildStep);
-
- /**
- * Returns the announcement string for this tool
- * @return String
- */
- public String getAnnouncement();
-
- /**
- * Sets the announcement string for this tool
- * @param announcement
- */
- public void setAnnouncement(String announcement);
-
- /**
- * Answers the command-line invocation defined for the receiver.
- *
- * @return String
- */
- public String getToolCommand();
-
- /**
- * Sets the command-line invocation command defined for this tool.
- *
- * @param String
- *
- * @return boolean if <code>true</code>, then the tool command was modified
- */
- public boolean setToolCommand(String command);
-
- /**
- * Returns command line pattern for this tool
- * @return String
- */
- public String getCommandLinePattern();
-
- /**
- * Sets the command line pattern for this tool
- * @param String
- */
- public void setCommandLinePattern(String pattern);
-
- /**
- * Returns the plugin.xml element of the commandLineGenerator extension or <code>null</code> if none.
- *
- * @return IConfigurationElement
- *
- * @deprecated - use getCommandLineGenerator
- */
- public IConfigurationElement getCommandLineGeneratorElement();
-
- /**
- * Sets the CommandLineGenerator plugin.xml element
- *
- * @param element
- * @deprecated
- */
- public void setCommandLineGeneratorElement(IConfigurationElement element);
-
- /**
- * Returns the command line generator specified for this tool
- * @return IManagedCommandLineGenerator
- */
- public IManagedCommandLineGenerator getCommandLineGenerator();
-
- /**
- * Returns the plugin.xml element of the dependencyGenerator extension or <code>null</code> if none.
- *
- * @return IConfigurationElement
- * @deprecated - use getDependencyGeneratorForExtension or IInputType#getDependencyGenerator method
- */
- public IConfigurationElement getDependencyGeneratorElement();
-
- /**
- * Sets the DependencyGenerator plugin.xml element
- *
- * @param element
- * @deprecated
- */
- public void setDependencyGeneratorElement(IConfigurationElement element);
-
- /**
- * Returns a class instance that implements an interface to generate
- * source-level dependencies for the tool specified in the argument.
- * This method may return <code>null</code> in which case, the receiver
- * should assume that the tool does not require dependency information
- * when the project is built.
- *
- * @return IManagedDependencyGenerator
- * @deprecated - use getDependencyGeneratorForExtension or IInputType method
- */
- public IManagedDependencyGenerator getDependencyGenerator();
-
- /**
- * Returns a class instance that implements an interface to generate
- * source-level dependencies for the tool specified in the argument.
- * This method may return <code>null</code> in which case, the receiver
- * should assume that the tool does not require dependency information
- * when the project is built.
- *
- * @param sourceExt source file extension
- * @return IManagedDependencyGenerator
- */
- public IManagedDependencyGenerator getDependencyGeneratorForExtension(String sourceExt);
-
- /**
- * Returns an array of command line arguments that have been specified for
- * the tool.
- * The flags contain build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * the flags contain all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the flags contain
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @return String[]
- * @throws BuildException
- *
- * @deprecated - use getToolCommandFlags instead
- */
- public String[] getCommandFlags() throws BuildException;
-
- /**
- * Returns the command line arguments that have been specified for
- * the tool.
- * The string contains build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * the string contains all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the string contains
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @return String
- *
- * @deprecated - use getToolCommandFlagsString instead
- */
- public String getToolFlags() throws BuildException ;
-
- /**
- * Returns an array of command line arguments that have been specified for
- * the tool.
- * The flags contain build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * the flags contain all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the flags contain
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @param inputFileLocation
- * @param outputFileLocation
- * @return
- * @throws BuildException
- */
- public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation) throws BuildException;
-
- /**
- * Returns the command line arguments that have been specified for
- * the tool.
- * The string contains build macros resolved to the makefile format.
- * That is if a user has chosen to expand all macros in the buildfile,
- * the string contains all macro references resolved, otherwise, if a user has
- * chosen to keep the environment build macros unresolved, the string contains
- * the environment macro references converted to the buildfile variable format,
- * all other macro references are resolved
- *
- * @param inputFileLocation
- * @param outputFileLocation
- * @return
- * @throws BuildException
- */
- public String getToolCommandFlagsString(IPath inputFileLocation, IPath outputFileLocation) throws BuildException;
-
- /**
- * Options are organized into categories for UI purposes.
- * These categories are organized into a tree. This is the root
- * of that tree.
- *
- * @return IOptionCategory
- */
- public IOptionCategory getTopOptionCategory();
-
- /**
- * Return <code>true</code> if the receiver builds files with the
- * specified extension, else <code>false</code>.
- *
- * @param extension file extension of the source
- * @return boolean
- */
- public boolean buildsFileType(String extension);
-
- /**
- * Return <code>true</code> if the receiver uses files with the
- * specified extension as input, else <code>false</code>. This
- * returns true for a superset of the extensions that buildFileType
- * returns true for - it includes secondary inputs.
- *
- * @param extension file extension of the source
- * @return boolean
- */
- public boolean isInputFileType(String extension);
-
- /**
- * Answers <code>true</code> if the tool considers the file extension to be
- * one associated with a header file.
- *
- * @param ext file extension of the source
- * @return boolean
- */
- public boolean isHeaderFile(String ext);
-
- /**
- * Answers <code>true</code> if the receiver builds a file with the extension specified
- * in the argument, else <code>false</code>.
- *
- * @param outputExtension extension of the file being produced by a tool
- * @return boolean
- */
- public boolean producesFileType(String outputExtension);
-
- /**
- * Returns <code>true</code> if this tool has changes that need to
- * be saved in the project file, else <code>false</code>.
- *
- * @return boolean
- */
- public boolean isDirty();
-
- /**
- * Sets the element's "dirty" (have I been modified?) flag.
- *
- * @param isDirty
- */
- public void setDirty(boolean isDirty);
-
- /**
- * Returns <code>true</code> if this tool was loaded from a manifest file,
- * and <code>false</code> if it was loaded from a project (.cdtbuild) file.
- *
- * @return boolean
- */
- public boolean isExtensionElement();
-
- /**
- * Returns the 'versionsSupported' of this tool
- *
- * @return String
- */
- public String getVersionsSupported();
-
- /**
- * Returns the 'convertToId' of this tool
- *
- * @return String
- */
- public String getConvertToId();
-
- /**
- * Sets the 'versionsSupported' attribute of the tool.
- *
- * @param versionsSupported
- */
- public void setVersionsSupported(String versionsSupported);
-
- /**
- * Sets the 'convertToId' attribute of the tool.
- *
- * @param convertToId
- */
- public void setConvertToId(String convertToId);
-
- /**
- * Returns an array of the Environment Build Path variable descriptors
- *
- * @return IEnvVarBuildPath[]
- */
- public IEnvVarBuildPath[] getEnvVarBuildPaths();
-}
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
+
+/**
+ * This interface represents a utility of some sort that is used in the build process.
+ * A tool will generally process one or more resources to produce output resources.
+ * Most tools have a set of options that can be used to modify the behavior of the tool.
+ */
+public interface ITool extends IBuildObject, IHoldsOptions {
+ // Schema element names
+ public static final String COMMAND = "command"; //$NON-NLS-1$
+ public static final String COMMAND_LINE_PATTERN = "commandLinePattern"; //$NON-NLS-1$
+ public static final String COMMAND_LINE_GENERATOR = "commandLineGenerator"; //$NON-NLS-1$
+ public static final String DEP_CALC_ID ="dependencyCalculator"; //$NON-NLS-1$
+ public static final String INTERFACE_EXTS = "headerExtensions"; //$NON-NLS-1$
+ public static final String NATURE = "natureFilter"; //$NON-NLS-1$
+ public static final String OUTPUT_FLAG = "outputFlag"; //$NON-NLS-1$
+ public static final String INPUT_TYPE = "inputType"; //$NON-NLS-1$
+ public static final String OUTPUT_TYPE = "outputType"; //$NON-NLS-1$
+ public static final String OUTPUT_PREFIX = "outputPrefix"; //$NON-NLS-1$
+ public static final String OUTPUTS = "outputs"; //$NON-NLS-1$
+ public static final String SOURCES = "sources"; //$NON-NLS-1$
+ public static final String ADVANCED_INPUT_CATEGORY = "advancedInputCategory"; //$NON-NLS-1$
+ public static final String CUSTOM_BUILD_STEP = "customBuildStep"; //$NON-NLS-1$
+ public static final String ANNOUNCEMENT = "announcement"; //$NON-NLS-1$
+ public static final String TOOL_ELEMENT_NAME = "tool"; //$NON-NLS-1$
+ public static final String WHITE_SPACE = " "; //$NON-NLS-1$
+ public static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ public static final String VERSIONS_SUPPORTED = "versionsSupported"; //$NON-NLS-1$
+ public static final String CONVERT_TO_ID = "convertToId"; //$NON-NLS-1$
+
+ public static final int FILTER_C = 0;
+ public static final int FILTER_CC = 1;
+ public static final int FILTER_BOTH = 2;
+
+ /**
+ * Returns the tool-chain or resource configuration that is the parent of this tool.
+ *
+ * @return IBuildObject
+ */
+ public IBuildObject getParent();
+
+ /**
+ * Creates a child InputType for this tool.
+ *
+ * @param InputType The superClass, if any
+ * @param String The id for the new InputType
+ * @param String The name for the new InputType
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ *
+ * @return IInputType
+ * @since 3.0
+ */
+ public IInputType createInputType(IInputType superClass, String Id, String name, boolean isExtensionElement);
+
+ /**
+ * Removes an InputType from the tool's list.
+ *
+ * @param type
+ * @since 3.0
+ */
+ public void removeInputType(IInputType type);
+
+ /**
+ * Returns the complete list of input types that are available for this tool.
+ * The list is a merging of the input types specified for this tool with the
+ * input types of its superclasses. The lowest input type instance in the hierarchy
+ * takes precedence.
+ *
+ * @return IInputType[]
+ * @since 3.0
+ */
+ public IInputType[] getInputTypes();
+
+ /**
+ * Returns the <code>IInputType</code> in the tool with the specified
+ * ID. This is an efficient search in the receiver.
+ *
+ * <p>If the receiver does not have an InputType with that ID, the method
+ * returns <code>null</code>. It is the responsibility of the caller to
+ * verify the return value.
+ *
+ * @param id unique identifier of the InputType to search for
+ * @return <code>IInputType</code>
+ * @since 3.0
+ */
+ public IInputType getInputTypeById(String id);
+
+ /**
+ * Returns the <code>IInputType</code> in the tool that uses the
+ * specified extension.
+ *
+ * <p>If the receiver does not have an InputType that uses the extension,
+ * the method returns <code>null</code>. It is the responsibility of the
+ * caller to verify the return value.
+ *
+ * @param inputExtension File extension
+ * @return <code>IInputType</code>
+ * @since 3.0
+ */
+ public IInputType getInputType(String inputExtension);
+
+ /**
+ * Returns the primary <code>IInputType</code> in this tool
+ *
+ * <p>If the receiver has no InputTypes,
+ * the method returns <code>null</code>. It is the responsibility of the
+ * caller to verify the return value.
+ *
+ * @return <code>IInputType</code>
+ * @since 3.0
+ */
+ public IInputType getPrimaryInputType();
+
+ /**
+ * Returns all of the additional input resources of all InputType children.
+ * Note: This does not include the primary InputType and does not include
+ * additional dependencies.
+ *
+ * @return IPath[]
+ */
+ public IPath[] getAdditionalResources();
+
+ /**
+ * Returns all of the additional dependency resources of all InputType children.
+ * Note: This does not include the primary InputType and does not include
+ * additional inputs.
+ *
+ * @return IPath[]
+ */
+ public IPath[] getAdditionalDependencies();
+
+ /**
+ * Creates a child OutputType for this tool.
+ *
+ * @param OutputType The superClass, if any
+ * @param String The id for the new OutputType
+ * @param String The name for the new OutputType
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ *
+ * @return IOutputType
+ * @since 3.0
+ */
+ public IOutputType createOutputType(IOutputType superClass, String Id, String name, boolean isExtensionElement);
+
+ /**
+ * Removes an OutputType from the tool's list.
+ *
+ * @param type
+ * @since 3.0
+ */
+ public void removeOutputType(IOutputType type);
+
+ /**
+ * Returns the complete list of output types that are available for this tool.
+ * The list is a merging of the output types specified for this tool with the
+ * output types of its superclasses. The lowest output type instance in the hierarchy
+ * takes precedence.
+ *
+ * @return IOutputType[]
+ * @since 3.0
+ */
+ public IOutputType[] getOutputTypes();
+ /**
+ * Get the <code>IOutputType</code> in the receiver with the specified
+ * ID. This is an efficient search in the receiver.
+ *
+ * <p>If the receiver does not have an OutputType with that ID, the method
+ * returns <code>null</code>. It is the responsibility of the caller to
+ * verify the return value.
+ *
+ * @param id unique identifier of the OutputType to search for
+ * @return <code>IOutputType</code>
+ * @since 3.0
+ */
+ public IOutputType getOutputTypeById(String id);
+
+ /**
+ * Returns the <code>IOutputType</code> in the tool that creates the
+ * specified extension.
+ *
+ * <p>If the receiver does not have an OutputType that creates the extension,
+ * the method returns <code>null</code>. It is the responsibility of the
+ * caller to verify the return value.
+ *
+ * @param outputExtension File extension
+ * @return <code>IOutputType</code>
+ * @since 3.0
+ */
+ public IOutputType getOutputType(String outputExtension);
+
+ /**
+ * Returns the primary <code>IOutputType</code> in this tool
+ *
+ * <p>If the receiver has no OutputTypes,
+ * the method returns <code>null</code>. It is the responsibility of the
+ * caller to verify the return value.
+ *
+ * @return <code>IOutputType</code>
+ * @since 3.0
+ */
+ public IOutputType getPrimaryOutputType();
+
+ /**
+ * Returns the <code>ITool</code> that is the superclass of this
+ * tool, or <code>null</code> if the attribute was not specified.
+ *
+ * @return ITool
+ */
+ public ITool getSuperClass();
+
+ /**
+ * Returns whether this element is abstract. Returns <code>false</code>
+ * if the attribute was not specified.
+ * @return boolean
+ */
+ public boolean isAbstract();
+
+ /**
+ * Sets the isAbstract attribute of the tool-chain.
+ *
+ * @param b
+ */
+ public void setIsAbstract(boolean b);
+
+ /**
+ * Returns a semi-colon delimited list of child Ids of the superclass'
+ * children that should not be automatically inherited by this element.
+ * Returns an empty string if the attribute was not specified.
+ * @return String
+ */
+ public String getUnusedChildren();
+
+ /**
+ * Returns the semicolon separated list of unique IDs of the error parsers associated
+ * with the tool.
+ *
+ * @return String
+ */
+ public String getErrorParserIds();
+
+ /**
+ * Returns the ordered list of unique IDs of the error parsers associated with the
+ * tool.
+ *
+ * @return String[]
+ */
+ public String[] getErrorParserList();
+
+ /**
+ * Sets the semicolon separated list of error parser ids
+ *
+ * @param ids
+ */
+ public void setErrorParserIds(String ids);
+
+ /**
+ * Returns the list of valid source extensions this tool knows how to build.
+ * The list may be empty but will never be <code>null</code>.
+ *
+ * @return List
+ * @deprecated - use getPrimaryInputExtensions or getAllInputExtensions
+ */
+ public List getInputExtensions();
+
+ /**
+ * Returns the array of valid primary source extensions this tool knows how to build.
+ * The array may be empty but will never be <code>null</code>.
+ *
+ * @return String[]
+ */
+ public String[] getPrimaryInputExtensions();
+
+ /**
+ * Returns the array of all valid source extensions this tool knows how to build.
+ * The array may be empty but will never be <code>null</code>.
+ *
+ * @return String[]
+ */
+ public String[] getAllInputExtensions();
+
+ /**
+ * Returns the default input extension for the primary input of the tool
+ *
+ * @return String
+ */
+ public String getDefaultInputExtension();
+
+ /**
+ * Returns the array of all valid dependency extensions for this tool's inputs.
+ * The array may be empty but will never be <code>null</code>.
+ *
+ * @return String[]
+ */
+ public String[] getAllDependencyExtensions();
+
+ /**
+ * Returns the list of valid header extensions for this tool.
+ * Returns the value of the headerExtensions attribute
+ * The list may be empty but will never be <code>null</code>.
+ *
+ * @return List
+ * @deprecated - use getDependency* methods
+ */
+ public List getInterfaceExtensions();
+
+ /**
+ * Answers a constant corresponding to the project nature the tool should be used
+ * for. Possible answers are:
+ *
+ * <dl>
+ * <dt>ITool.FILTER_C
+ * <dd>The tool should only be displayed for C projects. <i>Notes:</i> even
+ * though a C++ project has a C nature, this flag will mask the tool for C++
+ * projects.
+ * <dt>ITool.FILTER_CC
+ * <dd>The tool should only be displayed for C++ projects.
+ * <dt>ITool.FILTER_BOTH
+ * <dd>The tool should be displayed for projects with both natures.
+ * </dl>
+ *
+ * @return int
+ */
+ public int getNatureFilter();
+
+ /**
+ * Returns the array of all valid output extensions this tool can create.
+ * The array may be empty but will never be <code>null</code>.
+ *
+ * @return String[]
+ */
+ public String[] getAllOutputExtensions();
+
+ /**
+ * Answers all of the output extensions that the receiver can build.
+ * This routine returns the value if the outputs attribute.
+ *
+ * @return <code>String[]</code> of extensions
+ * @deprecated - use getAllOutputExtensions
+ */
+ public String[] getOutputExtensions();
+
+ /**
+ * Answers all of the output extensions that the receiver can build,
+ * from the value of the outputs attribute
+ *
+ * @return <code>String[]</code> of extensions
+ */
+ public String[] getOutputsAttribute();
+
+ /**
+ * Answer the output extension the receiver will create from the input,
+ * or <code>null</code> if the tool does not understand that extension.
+ *
+ * @param inputExtension The extension of the source file.
+ * @return String
+ */
+ public String getOutputExtension(String inputExtension);
+
+ /**
+ * Sets all of the output extensions that the receiver can build,
+ * into the outputs attribute. Note that the outputs attribute is
+ * ignored when one or more outputTypes are specified.
+ *
+ * @param String
+ */
+ public void setOutputsAttribute(String extensions);
+
+ /**
+ * Answers the argument that must be passed to a specific tool in order to
+ * control the name of the output artifact. For example, the GCC compile and
+ * linker use '-o', while the archiver does not.
+ *
+ * @return String
+ */
+ public String getOutputFlag();
+
+ /**
+ * Sets the argument that must be passed to a specific tool in order to
+ * control the name of the output artifact. For example, the GCC compile and
+ * linker use '-o', while the archiver does not.
+ *
+ * @param String
+ */
+ public void setOutputFlag(String flag);
+
+ /**
+ * Answers the prefix that the tool should prepend to the name of the build artifact.
+ * For example, a librarian usually prepends 'lib' to the target.a
+ * @return String
+ */
+ public String getOutputPrefix();
+
+ /**
+ * Sets the prefix that the tool should prepend to the name of the build artifact.
+ * For example, a librarian usually prepends 'lib' to the target.a
+ * @param String
+ */
+ public void setOutputPrefix(String prefix);
+
+ /**
+ * Returns <code>true</code> if the Tool wants the MBS to display the Advanced
+ * Input category that allows the user to specify additional input resources and
+ * dependencies, else <code>false</code>.
+ *
+ * @return boolean
+ */
+ public boolean getAdvancedInputCategory();
+
+ /**
+ * Sets whether the Tool wants the MBS to display the Advanced
+ * Input category that allows the user to specify additional input resources and
+ * dependencies.
+ *
+ * @param display
+ */
+ public void setAdvancedInputCategory(boolean display);
+
+ /**
+ * Returns <code>true</code> if the Tool represents a user-define custom build
+ * step, else <code>false</code>.
+ *
+ * @return boolean
+ */
+ public boolean getCustomBuildStep();
+
+ /**
+ * Sets whether the Tool represents a user-define custom build step.
+ *
+ * @param customBuildStep
+ */
+ public void setCustomBuildStep(boolean customBuildStep);
+
+ /**
+ * Returns the announcement string for this tool
+ * @return String
+ */
+ public String getAnnouncement();
+
+ /**
+ * Sets the announcement string for this tool
+ * @param announcement
+ */
+ public void setAnnouncement(String announcement);
+
+ /**
+ * Answers the command-line invocation defined for the receiver.
+ *
+ * @return String
+ */
+ public String getToolCommand();
+
+ /**
+ * Sets the command-line invocation command defined for this tool.
+ *
+ * @param String
+ *
+ * @return boolean if <code>true</code>, then the tool command was modified
+ */
+ public boolean setToolCommand(String command);
+
+ /**
+ * Returns command line pattern for this tool
+ * @return String
+ */
+ public String getCommandLinePattern();
+
+ /**
+ * Sets the command line pattern for this tool
+ * @param String
+ */
+ public void setCommandLinePattern(String pattern);
+
+ /**
+ * Returns the plugin.xml element of the commandLineGenerator extension or <code>null</code> if none.
+ *
+ * @return IConfigurationElement
+ *
+ * @deprecated - use getCommandLineGenerator
+ */
+ public IConfigurationElement getCommandLineGeneratorElement();
+
+ /**
+ * Sets the CommandLineGenerator plugin.xml element
+ *
+ * @param element
+ * @deprecated
+ */
+ public void setCommandLineGeneratorElement(IConfigurationElement element);
+
+ /**
+ * Returns the command line generator specified for this tool
+ * @return IManagedCommandLineGenerator
+ */
+ public IManagedCommandLineGenerator getCommandLineGenerator();
+
+ /**
+ * Returns the plugin.xml element of the dependencyGenerator extension or <code>null</code> if none.
+ *
+ * @return IConfigurationElement
+ * @deprecated - use getDependencyGeneratorForExtension or IInputType#getDependencyGenerator method
+ */
+ public IConfigurationElement getDependencyGeneratorElement();
+
+ /**
+ * Sets the DependencyGenerator plugin.xml element
+ *
+ * @param element
+ * @deprecated
+ */
+ public void setDependencyGeneratorElement(IConfigurationElement element);
+
+ /**
+ * Returns a class instance that implements an interface to generate
+ * source-level dependencies for the tool specified in the argument.
+ * This method may return <code>null</code> in which case, the receiver
+ * should assume that the tool does not require dependency information
+ * when the project is built.
+ *
+ * @return IManagedDependencyGenerator
+ * @deprecated - use getDependencyGeneratorForExtension or IInputType method
+ */
+ public IManagedDependencyGenerator getDependencyGenerator();
+
+ /**
+ * Returns a class instance that implements an interface to generate
+ * source-level dependencies for the tool specified in the argument.
+ * This method may return <code>null</code> in which case, the receiver
+ * should assume that the tool does not require dependency information
+ * when the project is built.
+ *
+ * @param sourceExt source file extension
+ * @return IManagedDependencyGeneratorType
+ */
+ public IManagedDependencyGeneratorType getDependencyGeneratorForExtension(String sourceExt);
+
+ /**
+ * Returns an array of command line arguments that have been specified for
+ * the tool.
+ * The flags contain build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * the flags contain all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the flags contain
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @return String[]
+ * @throws BuildException
+ *
+ * @deprecated - use getToolCommandFlags instead
+ */
+ public String[] getCommandFlags() throws BuildException;
+
+ /**
+ * Returns the command line arguments that have been specified for
+ * the tool.
+ * The string contains build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * the string contains all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the string contains
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @return String
+ *
+ * @deprecated - use getToolCommandFlagsString instead
+ */
+ public String getToolFlags() throws BuildException ;
+
+ /**
+ * Returns an array of command line arguments that have been specified for
+ * the tool.
+ * The flags contain build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * the flags contain all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the flags contain
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @param inputFileLocation
+ * @param outputFileLocation
+ * @return
+ * @throws BuildException
+ */
+ public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation) throws BuildException;
+
+ /**
+ * Returns the command line arguments that have been specified for
+ * the tool.
+ * The string contains build macros resolved to the makefile format.
+ * That is if a user has chosen to expand all macros in the buildfile,
+ * the string contains all macro references resolved, otherwise, if a user has
+ * chosen to keep the environment build macros unresolved, the string contains
+ * the environment macro references converted to the buildfile variable format,
+ * all other macro references are resolved
+ *
+ * @param inputFileLocation
+ * @param outputFileLocation
+ * @return
+ * @throws BuildException
+ */
+ public String getToolCommandFlagsString(IPath inputFileLocation, IPath outputFileLocation) throws BuildException;
+
+ /**
+ * Options are organized into categories for UI purposes.
+ * These categories are organized into a tree. This is the root
+ * of that tree.
+ *
+ * @return IOptionCategory
+ */
+ public IOptionCategory getTopOptionCategory();
+
+ /**
+ * Return <code>true</code> if the receiver builds files with the
+ * specified extension, else <code>false</code>.
+ *
+ * @param extension file extension of the source
+ * @return boolean
+ */
+ public boolean buildsFileType(String extension);
+
+ /**
+ * Return <code>true</code> if the receiver uses files with the
+ * specified extension as input, else <code>false</code>. This
+ * returns true for a superset of the extensions that buildFileType
+ * returns true for - it includes secondary inputs.
+ *
+ * @param extension file extension of the source
+ * @return boolean
+ */
+ public boolean isInputFileType(String extension);
+
+ /**
+ * Answers <code>true</code> if the tool considers the file extension to be
+ * one associated with a header file.
+ *
+ * @param ext file extension of the source
+ * @return boolean
+ */
+ public boolean isHeaderFile(String ext);
+
+ /**
+ * Answers <code>true</code> if the receiver builds a file with the extension specified
+ * in the argument, else <code>false</code>.
+ *
+ * @param outputExtension extension of the file being produced by a tool
+ * @return boolean
+ */
+ public boolean producesFileType(String outputExtension);
+
+ /**
+ * Returns <code>true</code> if this tool has changes that need to
+ * be saved in the project file, else <code>false</code>.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Returns <code>true</code> if this tool was loaded from a manifest file,
+ * and <code>false</code> if it was loaded from a project (.cdtbuild) file.
+ *
+ * @return boolean
+ */
+ public boolean isExtensionElement();
+
+ /**
+ * Returns the 'versionsSupported' of this tool
+ *
+ * @return String
+ */
+ public String getVersionsSupported();
+
+ /**
+ * Returns the 'convertToId' of this tool
+ *
+ * @return String
+ */
+ public String getConvertToId();
+
+ /**
+ * Sets the 'versionsSupported' attribute of the tool.
+ *
+ * @param versionsSupported
+ */
+ public void setVersionsSupported(String versionsSupported);
+
+ /**
+ * Sets the 'convertToId' attribute of the tool.
+ *
+ * @param convertToId
+ */
+ public void setConvertToId(String convertToId);
+
+ /**
+ * Returns an array of the Environment Build Path variable descriptors
+ *
+ * @return IEnvVarBuildPath[]
+ */
+ public IEnvVarBuildPath[] getEnvVarBuildPaths();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index cbf9e1d0be..164b5639fe 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -1,1441 +1,1450 @@
-/*******************************************************************************
- * Copyright (c) 2003, 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.internal.core;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.UserDefinedMacroSupplier;
-import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class Configuration extends BuildObject implements IConfiguration {
-
- private static final String EMPTY_STRING = new String();
-
- // Parent and children
- private IConfiguration parent;
- private ProjectType projectType;
- private ManagedProject managedProject;
- private ToolChain toolChain;
- private List resourceConfigurationList;
- private Map resourceConfigurationMap;
- // Managed Build model attributes
- private String artifactName;
- private String cleanCommand;
- private String artifactExtension;
- private String errorParserIds;
- private String prebuildStep;
- private String postbuildStep;
- private String preannouncebuildStep;
- private String postannouncebuildStep;
- private String description;
- // Miscellaneous
- private boolean isExtensionConfig = false;
- private boolean isDirty = false;
- private boolean rebuildNeeded = false;
- private boolean resolved = true;
- private boolean isTemporary = false;
-
-
- /*
- * C O N S T R U C T O R S
- */
-
- /**
- * Create an extension configuration from the project manifest file element.
- *
- * @param projectType The <code>ProjectType</code> the configuration will be added to.
- * @param element The element from the manifest that contains the configuration information.
- * @param managedBuildRevision
- */
- public Configuration(ProjectType projectType, IManagedConfigElement element, String managedBuildRevision) {
- this.projectType = projectType;
- isExtensionConfig = true;
-
- // setup for resolving
- resolved = false;
-
- setManagedBuildRevision(managedBuildRevision);
-
- // Initialize from the XML attributes
- loadFromManifest(element);
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionConfiguration(this);
-
- // Hook me up to the ProjectType
- if (projectType != null) {
- projectType.addConfiguration(this);
- }
-
- // Load the children
- IManagedConfigElement[] configElements = element.getChildren();
- for (int l = 0; l < configElements.length; ++l) {
- IManagedConfigElement configElement = configElements[l];
- if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
- toolChain = new ToolChain(this, configElement, managedBuildRevision);
- }else if (configElement.getName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
- ResourceConfiguration resConfig = new ResourceConfiguration(this, configElement, managedBuildRevision);
- addResourceConfiguration(resConfig);
- }
- }
- }
-
- /**
- * Create a new extension configuration based on one already defined.
- *
- * @param projectType The <code>ProjectType</code> the configuration will be added to.
- * @param parentConfig The <code>IConfiguration</code> that is the parent configuration of this configuration
- * @param id A unique ID for the new configuration.
- */
- public Configuration(ProjectType projectType, IConfiguration parentConfig, String id) {
- setId(id);
- this.projectType = projectType;
- isExtensionConfig = true;
-
- // setup for resolving
- resolved = false;
-
- if (parentConfig != null) {
- name = parentConfig.getName();
- // If this contructor is called to clone an existing
- // configuration, the parent of the parent should be stored.
- // As of 2.1, there is still one single level of inheritence to
- // worry about
- parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent();
- }
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionConfiguration(this);
-
- // Hook me up to the ProjectType
- if (projectType != null) {
- projectType.addConfiguration(this);
- // set managedBuildRevision
- setManagedBuildRevision(projectType.getManagedBuildRevision());
- }
- }
-
- /**
- * Create a new extension configuration and fill in the attributes and childen later.
- *
- * @param projectType The <code>ProjectType</code> the configuration will be added to.
- * @param parentConfig The <code>IConfiguration</code> that is the parent configuration of this configuration
- * @param id A unique ID for the new configuration.
- * @param name A name for the new configuration.
- */
- public Configuration(ProjectType projectType, IConfiguration parentConfig, String id, String name) {
- setId(id);
- setName(name);
- this.projectType = projectType;
- parent = parentConfig;
- isExtensionConfig = true;
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionConfiguration(this);
-
- // Hook me up to the ProjectType
- if (projectType != null) {
- projectType.addConfiguration(this);
- setManagedBuildRevision(projectType.getManagedBuildRevision());
- }
- }
-
- /**
- * Create a <code>Configuration</code> based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param managedProject The <code>ManagedProject</code> the configuration will be added to.
- * @param element The XML element that contains the configuration settings.
- *
- */
- public Configuration(ManagedProject managedProject, Element element, String managedBuildRevision) {
- this.managedProject = managedProject;
- isExtensionConfig = false;
-
- setManagedBuildRevision(managedBuildRevision);
-
- // Initialize from the XML attributes
- loadFromProject(element);
-
- // Hook me up
- managedProject.addConfiguration(this);
-
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
- toolChain = new ToolChain(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
- ResourceConfiguration resConfig = new ResourceConfiguration(this, (Element)configElement, managedBuildRevision);
- addResourceConfiguration(resConfig);
- }
- }
- }
-
- /**
- * Create a new project, non-extension, configuration based on one already defined.
- *
- * @param managedProject The <code>ManagedProject</code> the configuration will be added to.
- * @param cloneConfig The <code>IConfiguration</code> to copy the settings from.
- * @param id A unique ID for the new configuration.
- * @param cloneChildren If <code>true</code>, the configuration's tools are cloned
- */
- public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) {
- setId(id);
- setName(cloneConfig.getName());
- this.description = cloneConfig.getDescription();
- this.managedProject = managedProject;
- isExtensionConfig = false;
- this.isTemporary = temporary;
-
- // set managedBuildRevision
- setManagedBuildRevision(cloneConfig.getManagedBuildRevision());
-
- // If this contructor is called to clone an existing
- // configuration, the parent of the cloning config should be stored.
- parent = cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent();
-
- // Copy the remaining attributes
- projectType = cloneConfig.projectType;
- if (cloneConfig.artifactName != null) {
- artifactName = new String(cloneConfig.artifactName);
- }
- if (cloneConfig.cleanCommand != null) {
- cleanCommand = new String(cloneConfig.cleanCommand);
- }
- if (cloneConfig.artifactExtension != null) {
- artifactExtension = new String(cloneConfig.artifactExtension);
- }
- if (cloneConfig.errorParserIds != null) {
- errorParserIds = new String(cloneConfig.errorParserIds);
- }
- if (cloneConfig.prebuildStep != null) {
- prebuildStep = new String(cloneConfig.prebuildStep);
- }
- if (cloneConfig.postbuildStep != null) {
- postbuildStep = new String(cloneConfig.postbuildStep);
- }
- if (cloneConfig.preannouncebuildStep != null) {
- preannouncebuildStep = new String(cloneConfig.preannouncebuildStep);
- }
- if (cloneConfig.postannouncebuildStep != null) {
- postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
- }
-
- // Clone the configuration's children
- // Tool Chain
- String subId;
- String subName;
- if (cloneConfig.parent != null) {
- subId = ManagedBuildManager.calculateChildId(
- cloneConfig.parent.getToolChain().getId(),
- null);
- subName = cloneConfig.parent.getToolChain().getName();
-
- } else {
- subId = ManagedBuildManager.calculateChildId(
- cloneConfig.getToolChain().getId(),
- null);
- subName = cloneConfig.getToolChain().getName();
- }
-
- if (cloneChildren) {
- toolChain = new ToolChain(this, subId, subName, (ToolChain)cloneConfig.getToolChain());
-
- //copy expand build macros setting
- BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
- macroProvider.expandMacrosInBuildfile(this,
- macroProvider.areMacrosExpandedInBuildfile(cloneConfig));
-
- //copy user-defined build macros
- UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
- userMacros.setMacros(
- userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
- BuildMacroProvider.CONTEXT_CONFIGURATION,
- this);
-
- //copy user-defined environment
- UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
- userEnv.setVariables(
- userEnv.getVariables(cloneConfig), this);
-
- } else {
- // Add a tool-chain element that specifies as its superClass the
- // tool-chain that is the child of the configuration.
- ToolChain superChain = (ToolChain)cloneConfig.getToolChain();
- subId = ManagedBuildManager.calculateChildId(
- superChain.getId(),
- null);
- IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false);
-
- // For each option/option category child of the tool-chain that is
- // the child of the selected configuration element, create an option/
- // option category child of the cloned configuration's tool-chain element
- // that specifies the original tool element as its superClass.
- newChain.createOptions(superChain);
-
- // For each tool element child of the tool-chain that is the child of
- // the selected configuration element, create a tool element child of
- // the cloned configuration's tool-chain element that specifies the
- // original tool element as its superClass.
- ITool[] tools = superChain.getTools();
- for (int i=0; i<tools.length; i++) {
- Tool toolChild = (Tool)tools[i];
- subId = ManagedBuildManager.calculateChildId(toolChild.getId(),null);
- newChain.createTool(toolChild, subId, toolChild.getName(), false);
- }
- }
-
- // Resource Configurations
- if (cloneConfig.resourceConfigurationList != null) {
- List resElements = cloneConfig.getResourceConfigurationList();
- Iterator iter = resElements.listIterator();
- while (iter.hasNext()) {
- ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
- subId = getId() + "." + ManagedBuildManager.getRandomNumber(); //$NON-NLS-1$
- ResourceConfiguration newResConfig = new ResourceConfiguration(this, resConfig, subId);
- addResourceConfiguration(newResConfig);
- }
- }
-
- // Hook me up
- managedProject.addConfiguration(this);
- setDirty(true);
- rebuildNeeded = true;
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /* (non-Javadoc)
- * Initialize the configuration information from an element in the
- * manifest file or provided by a dynamicElementProvider
- *
- * @param element An obejct implementing IManagedConfigElement
- */
- protected void loadFromManifest(IManagedConfigElement element) {
- ManagedBuildManager.putConfigElement(this, element);
-
- // id
- setId(element.getAttribute(IConfiguration.ID));
-
- // name
- name = element.getAttribute(IConfiguration.NAME);
-
- // description
- description = element.getAttribute(IConfiguration.DESCRIPTION);
-
- // parent
- String parentID = element.getAttribute(IConfiguration.PARENT);
- if (parentID != null) {
- // Lookup the parent configuration by ID
- parent = ManagedBuildManager.getExtensionConfiguration(parentID);
- }
-
- // Get the name of the build artifact associated with configuration
- artifactName = element.getAttribute(ARTIFACT_NAME);
-
- // Get the semicolon separated list of IDs of the error parsers
- errorParserIds = element.getAttribute(ERROR_PARSERS);
-
- // Get the artifact extension
- artifactExtension = element.getAttribute(EXTENSION);
-
- // Get the clean command
- cleanCommand = element.getAttribute(CLEAN_COMMAND);
-
- // Get the pre-build and post-build commands
- prebuildStep = element.getAttribute(PREBUILD_STEP);
- postbuildStep = element.getAttribute(POSTBUILD_STEP);
-
- // Get the pre-build and post-build announcements
- preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
- postannouncebuildStep = element.getAttribute(POSTANNOUNCEBUILD_STEP);
- }
-
- /* (non-Javadoc)
- * Initialize the configuration information from the XML element
- * specified in the argument
- *
- * @param element An XML element containing the configuration information
- */
- protected void loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IConfiguration.ID));
-
- // name
- if (element.hasAttribute(IConfiguration.NAME))
- setName(element.getAttribute(IConfiguration.NAME));
-
- // description
- if (element.hasAttribute(IConfiguration.DESCRIPTION))
- this.description = element.getAttribute(IConfiguration.DESCRIPTION);
-
- if (element.hasAttribute(IConfiguration.PARENT)) {
- // See if the parent belongs to the same project
- parent = managedProject.getConfiguration(element.getAttribute(IConfiguration.PARENT));
- // If not, then try the extension configurations
- if (parent == null) {
- parent = ManagedBuildManager.getExtensionConfiguration(element.getAttribute(IConfiguration.PARENT));
- }
- }
-
- // Get the name of the build artifact associated with target (usually
- // in the plugin specification).
- if (element.hasAttribute(ARTIFACT_NAME)) {
- artifactName = element.getAttribute(ARTIFACT_NAME);
- }
-
- // Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(ERROR_PARSERS)) {
- errorParserIds = element.getAttribute(ERROR_PARSERS);
- }
-
- // Get the artifact extension
- if (element.hasAttribute(EXTENSION)) {
- artifactExtension = element.getAttribute(EXTENSION);
- }
-
- // Get the clean command
- if (element.hasAttribute(CLEAN_COMMAND)) {
- cleanCommand = element.getAttribute(CLEAN_COMMAND);
- }
-
- // Get the pre-build and post-build commands
- if (element.hasAttribute(PREBUILD_STEP)) {
- prebuildStep = element.getAttribute(PREBUILD_STEP);
- }
-
- if (element.hasAttribute(POSTBUILD_STEP)) {
- postbuildStep = element.getAttribute(POSTBUILD_STEP);
- }
-
- // Get the pre-build and post-build announcements
- if (element.hasAttribute(PREANNOUNCEBUILD_STEP)) {
- preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
- }
-
- if (element.hasAttribute(POSTANNOUNCEBUILD_STEP)) {
- postannouncebuildStep = element
- .getAttribute(POSTANNOUNCEBUILD_STEP);
- }
- }
-
- /**
- * Persist this configuration to project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- element.setAttribute(IConfiguration.ID, id);
-
- if (name != null)
- element.setAttribute(IConfiguration.NAME, name);
-
- if (description != null)
- element.setAttribute(IConfiguration.DESCRIPTION, description);
-
- if (parent != null)
- element.setAttribute(IConfiguration.PARENT, parent.getId());
-
- if (artifactName != null)
- element.setAttribute(ARTIFACT_NAME, artifactName);
-
- if (errorParserIds != null)
- element.setAttribute(ERROR_PARSERS, errorParserIds);
-
- if (artifactExtension != null)
- element.setAttribute(EXTENSION, artifactExtension);
-
- if (cleanCommand != null)
- element.setAttribute(CLEAN_COMMAND, cleanCommand);
-
- if (prebuildStep != null)
- element.setAttribute(PREBUILD_STEP, prebuildStep);
-
- if (postbuildStep != null)
- element.setAttribute(POSTBUILD_STEP, postbuildStep);
-
- if (preannouncebuildStep != null)
- element.setAttribute(PREANNOUNCEBUILD_STEP, preannouncebuildStep);
-
- if (postannouncebuildStep != null)
- element.setAttribute(POSTANNOUNCEBUILD_STEP, postannouncebuildStep);
-
- // Serialize my children
- Element toolChainElement = doc.createElement(IToolChain.TOOL_CHAIN_ELEMENT_NAME);
- element.appendChild(toolChainElement);
- toolChain.serialize(doc, toolChainElement);
- List resElements = getResourceConfigurationList();
- Iterator iter = resElements.listIterator();
- while (iter.hasNext()) {
- ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
- Element resElement = doc.createElement(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME);
- element.appendChild(resElement);
- resConfig.serialize(doc, resElement);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /*
- * P A R E N T A N D C H I L D H A N D L I N G
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
- */
- public IConfiguration getParent() {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getOwner()
- */
- public IResource getOwner() {
- if (managedProject != null)
- return managedProject.getOwner();
- else {
- return null; // Extension configurations don't have an "owner"
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getProjectType()
- */
- public IProjectType getProjectType() {
- return (IProjectType)projectType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getManagedProject()
- */
- public IManagedProject getManagedProject() {
- return (IManagedProject)managedProject;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain(IToolChain, String, String, boolean)
- */
- public IToolChain createToolChain(IToolChain superClass, String Id, String name, boolean isExtensionElement) {
- toolChain = new ToolChain(this, superClass, Id, name, isExtensionElement);
- setDirty(true);
- return (IToolChain)toolChain;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain()
- */
- public IToolChain getToolChain() {
- return (IToolChain)toolChain;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getResourceConfigurations()
- */
- public IResourceConfiguration[] getResourceConfigurations() {
- IResourceConfiguration[] resConfigs = new IResourceConfiguration[getResourceConfigurationList().size()];
- Iterator iter = getResourceConfigurationList().listIterator();
- int i = 0;
- while (iter.hasNext()) {
- ResourceConfiguration resConfig = (ResourceConfiguration)iter.next();
- resConfigs[i++] = (IResourceConfiguration)resConfig;
- }
- return resConfigs;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceConfiguration(java.lang.String)
- */
- public IResourceConfiguration getResourceConfiguration(String resPath) {
- ResourceConfiguration resConfig = (ResourceConfiguration)getResourceConfigurationMap().get(resPath);
- return (IResourceConfiguration)resConfig;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools()
- */
- public ITool[] getFilteredTools() {
- if (toolChain == null) {
- return new ITool[0];
- }
- ITool[] localTools = toolChain.getTools();
- IManagedProject manProj = getManagedProject();
- if (manProj == null) {
- // If this is not associated with a project, then there is nothing to filter with
- return localTools;
- }
- IProject project = (IProject)manProj.getOwner();
- Vector tools = new Vector(localTools.length);
- for (int i = 0; i < localTools.length; i++) {
- ITool tool = localTools[i];
- try {
- // Make sure the tool is right for the project
- switch (tool.getNatureFilter()) {
- case ITool.FILTER_C:
- if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- tools.add(tool);
- }
- break;
- case ITool.FILTER_CC:
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- tools.add(tool);
- }
- break;
- case ITool.FILTER_BOTH:
- tools.add(tool);
- break;
- default:
- break;
- }
- } catch (CoreException e) {
- continue;
- }
- }
-
- // Answer the filtered tools as an array
- return (ITool[])tools.toArray(new ITool[tools.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
- */
- public ITool[] getTools() {
- return toolChain.getTools();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTool(java.lang.String)
- */
- public ITool getTool(String id) {
- return toolChain.getTool(id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolsBySuperClassId(java.lang.String)
- */
- public ITool[] getToolsBySuperClassId(String id) {
- return toolChain.getToolsBySuperClassId(id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool()
- */
- public ITool getTargetTool() {
- String[] targetToolIds = toolChain.getTargetToolList();
- if (targetToolIds == null || targetToolIds.length == 0) return null;
-
- // For each target tool id, in list order,
- // look for a tool with this ID, or a tool with a superclass with this id.
- // Stop when we find a match
- ITool[] tools = getFilteredTools();
- for (int i=0; i<targetToolIds.length; i++) {
- String targetToolId = targetToolIds[i];
- for (int j=0; j<tools.length; j++) {
- ITool targetTool = tools[j];
- ITool tool = targetTool;
- do {
- if (targetToolId.equals(tool.getId())) {
- return targetTool;
- }
- tool = tool.getSuperClass();
- } while (tool != null);
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
- */
- public String getToolCommand(ITool tool) {
- // TODO: Do we need to verify that the tool is part of the configuration?
- return tool.getToolCommand();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
- */
- public void setToolCommand(ITool tool, String command) {
- // TODO: Do we need to verify that the tool is part of the configuration?
- tool.setToolCommand(command);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
- */
- public IOption setOption(IHoldsOptions holder, IOption option, boolean value) throws BuildException {
- // Is there a change?
- IOption retOpt = option;
- if (option.getBooleanValue() != value) {
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
- rebuildNeeded = true;
- }
- return retOpt;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
- */
- public IOption setOption(IHoldsOptions holder, IOption option, String value) throws BuildException {
- IOption retOpt = option;
- String oldValue;
- oldValue = option.getStringValue();
- if (oldValue != null && !oldValue.equals(value)) {
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
- rebuildNeeded = true;
- }
- return retOpt;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
- */
- public IOption setOption(IHoldsOptions holder, IOption option, String[] value) throws BuildException {
- IOption retOpt = option;
- // Is there a change?
- String[] oldValue;
- switch (option.getValueType()) {
- case IOption.STRING_LIST :
- oldValue = option.getStringListValue();
- break;
- case IOption.INCLUDE_PATH :
- oldValue = option.getIncludePaths();
- break;
- case IOption.PREPROCESSOR_SYMBOLS :
- oldValue = option.getDefinedSymbols();
- break;
- case IOption.LIBRARIES :
- oldValue = option.getLibraries();
- break;
- case IOption.OBJECTS :
- oldValue = option.getUserObjects();
- break;
- default :
- oldValue = new String[0];
- break;
- }
- if(!Arrays.equals(value, oldValue)) {
- retOpt = holder.getOptionToSet(option, false);
- retOpt.setValue(value);
- rebuildNeeded = true;
- }
- return retOpt;
- }
-
- /* (non-Javadoc)
- * Safe accessor for the list of resource configs.
- *
- * @return List containing the tools
- */
- private List getResourceConfigurationList() {
- if (resourceConfigurationList == null) {
- resourceConfigurationList = new ArrayList();
- }
- return resourceConfigurationList;
- }
-
- /* (non-Javadoc)
- * Safe accessor for the map of resource paths to resource configs
- *
- * @return
- */
- private Map getResourceConfigurationMap() {
- if (resourceConfigurationMap == null) {
- resourceConfigurationMap = new HashMap();
- }
- return resourceConfigurationMap;
- }
-
- /* (non-Javadoc)
- * Adds the Resource Configuration to the Resource Configuration list and map
- *
- * @param resConfig
- */
- public void addResourceConfiguration(ResourceConfiguration resConfig) {
- getResourceConfigurationList().add(resConfig);
- getResourceConfigurationMap().put(resConfig.getResourcePath(), resConfig);
- isDirty = true;
- rebuildNeeded = true;
- }
-
- public void removeResourceConfiguration(IResourceConfiguration resConfig) {
- ManagedBuildManager.performValueHandlerEvent(resConfig,
- IManagedOptionValueHandler.EVENT_CLOSE);
- getResourceConfigurationList().remove(resConfig);
- getResourceConfigurationMap().remove(resConfig.getResourcePath());
- isDirty = true;
- rebuildNeeded = true;
- }
- /*
- * M O D E L A T T R I B U T E A C C E S S O R S
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
- */
- public String getName() {
- return (name == null && parent != null) ? parent.getName() : name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getArtifactExtension()
- */
- public String getArtifactExtension() {
- if (artifactExtension == null) {
- // Ask my parent first
- if (parent != null) {
- return parent.getArtifactExtension();
- } else {
- return EMPTY_STRING;
- }
- } else {
- return artifactExtension;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getArtifactName()
- */
- public String getArtifactName() {
- if (artifactName == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getArtifactName();
- } else {
- // I'm it and this is not good!
- return EMPTY_STRING;
- }
- } else {
- return artifactName;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildArguments()
- */
- public String getBuildArguments() {
- IToolChain tc = getToolChain();
- IBuilder builder = tc.getBuilder();
- if (builder != null) {
- return builder.getArguments();
- }
- return new String("-k"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildCommand()
- */
- public String getBuildCommand() {
- IToolChain tc = getToolChain();
- IBuilder builder = tc.getBuilder();
- if (builder != null) {
- return builder.getCommand();
- }
- return new String("make"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPrebuildStep()
- */
- public String getPrebuildStep() {
- if (prebuildStep == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getPrebuildStep();
- } else {
- // I'm it
- return EMPTY_STRING;
- }
- } else {
- return prebuildStep;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostbuildStep()
- */
- public String getPostbuildStep() {
- if (postbuildStep == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getPostbuildStep();
- } else {
- // I'm it
- return EMPTY_STRING;
- }
- } else {
- return postbuildStep;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPreannouncebuildStep()
- */
- public String getPreannouncebuildStep() {
- if (preannouncebuildStep == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getPreannouncebuildStep();
- } else {
- // I'm it
- return EMPTY_STRING;
- }
- } else {
- return preannouncebuildStep;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostannouncebuildStep()
- */
- public String getPostannouncebuildStep() {
- if (postannouncebuildStep == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getPostannouncebuildStep();
- } else {
- // I'm it
- return EMPTY_STRING;
- }
- } else {
- return postannouncebuildStep;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getCleanCommand()
- */
- public String getCleanCommand() {
- // Return the command used to remove files
- if (cleanCommand == null) {
- if (parent != null) {
- return parent.getCleanCommand();
- } else {
- // User forgot to specify it. Guess based on OS.
- if (Platform.getOS().equals("OS_WIN32")) { //$NON-NLS-1$
- return new String("del"); //$NON-NLS-1$
- } else {
- return new String("rm"); //$NON-NLS-1$
- }
- }
- } else {
- // This was spec'd in the manifest
- return cleanCommand;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getDescription()
- */
- public String getDescription() {
- if (description == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getDescription();
- } else {
- // I'm it
- return EMPTY_STRING;
- }
- } else {
- return description;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserIds()
- */
- public String getErrorParserIds() {
- if (errorParserIds != null) {
- return errorParserIds;
- }
- // If I have a parent, ask it
- String errorParsers = null;
- if (parent != null) {
- errorParsers = parent.getErrorParserIds();
- }
- // If no error parsers are specified by the configuration, the default
- // is
- // the error parsers from the tool-chain
- if (errorParsers == null && toolChain != null) {
- errorParsers = toolChain.getErrorParserIds(this);
- }
- return errorParsers;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserList()
- */
- public String[] getErrorParserList() {
- String parserIDs = getErrorParserIds();
- String[] errorParsers;
- if (parserIDs != null) {
- // Check for an empty string
- if (parserIDs.length() == 0) {
- errorParsers = new String[0];
- } else {
- StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
- List list = new ArrayList(tok.countTokens());
- while (tok.hasMoreElements()) {
- list.add(tok.nextToken());
- }
- String[] strArr = {""}; //$NON-NLS-1$
- errorParsers = (String[]) list.toArray(strArr);
- }
- } else {
- // If no error parsers are specified, the default is
- // all error parsers
- errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
- }
- return errorParsers;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String)
- */
- public void setArtifactExtension(String extension) {
- if (extension == null && artifactExtension == null) return;
- if (artifactExtension == null || extension == null || !artifactExtension.equals(extension)) {
- artifactExtension = extension;
- rebuildNeeded = true;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setArtifactName(java.lang.String)
- */
- public void setArtifactName(String name) {
- if (name == null && artifactName == null) return;
- if (artifactName == null || name == null || !artifactName.equals(name)) {
- artifactName = name;
- rebuildNeeded = true;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setErrorParserIds()
- */
- public void setErrorParserIds(String ids) {
- String currentIds = getErrorParserIds();
- if (ids == null && currentIds == null) return;
- if (currentIds == null || ids == null || !(currentIds.equals(ids))) {
- errorParserIds = ids;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setCleanCommand()
- */
- public void setCleanCommand(String command) {
- if (command == null && cleanCommand == null) return;
- if (cleanCommand == null || command == null || !cleanCommand.equals(command)) {
- cleanCommand = command;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setDescription(java.lang.String)
- */
- public void setDescription(String description) {
- if (description == null && this.description == null) return;
- if (this.description == null || description == null || !description.equals(this.description)) {
- this.description = description;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildArguments()
- */
- public void setBuildArguments(String makeArgs) {
- IToolChain tc = getToolChain();
- IBuilder builder = tc.getBuilder();
- if(makeArgs == null){ //resetting the build arguments
- if(!builder.isExtensionElement()){
- builder.setArguments(makeArgs);
- rebuildNeeded = true;
- }
- }else if(!makeArgs.equals(builder.getArguments())){
- if (builder.isExtensionElement()) {
- String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
- String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
- builder = toolChain.createBuilder(builder, subId, builderName, false);
- }
- builder.setArguments(makeArgs);
- rebuildNeeded = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildCommand()
- */
- public void setBuildCommand(String command) {
- IToolChain tc = getToolChain();
- IBuilder builder = tc.getBuilder();
- if(command == null){ //resetting the build command
- if(!builder.isExtensionElement()){
- builder.setCommand(command);
- rebuildNeeded = true;
- }
- } else if(!command.equals(builder.getCommand())){
- if (builder.isExtensionElement()) {
- String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
- String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
- builder = toolChain.createBuilder(builder, subId, builderName, false);
- }
- builder.setCommand(command);
- rebuildNeeded = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPrebuildStep(java.lang.String)
- */
- public void setPrebuildStep(String step) {
- if (step == null && prebuildStep == null) return;
- if (prebuildStep == null || step == null || !prebuildStep.equals(step)) {
- prebuildStep = step;
- rebuildNeeded = true;
- isDirty = true;
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostbuildStep(java.lang.String)
- */
- public void setPostbuildStep(String step) {
- if (step == null && postbuildStep == null) return;
- if (postbuildStep == null || step == null || !postbuildStep.equals(step)) {
- postbuildStep = step;
- rebuildNeeded = true;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPreannouncebuildStep(java.lang.String)
- */
- public void setPreannouncebuildStep(String announceStep) {
- if (announceStep == null && preannouncebuildStep == null) return;
- if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) {
- preannouncebuildStep = announceStep;
- rebuildNeeded = true;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostannouncebuildStep(java.lang.String)
- */
- public void setPostannouncebuildStep(String announceStep) {
- if (announceStep == null && postannouncebuildStep == null) return;
- if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) {
- postannouncebuildStep = announceStep;
- rebuildNeeded = true;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isSupported()
- */
- public boolean isSupported(){
- IToolChain toolChain = getToolChain();
- if(toolChain != null)
- return toolChain.isSupported();
- return false;
- }
-
- /*
- * O B J E C T S T A T E M A I N T E N A N C E
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isExtensionElement()
- */
- public boolean isExtensionElement() {
- return isExtensionConfig;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isDirty()
- */
- public boolean isDirty() {
- // This shouldn't be called for an extension configuration
- if (isExtensionConfig) return false;
-
- // If I need saving, just say yes
- if (isDirty) return true;
-
- // Otherwise see if any children need saving
- if (toolChain.isDirty()) return true;
- Iterator iter = getResourceConfigurationList().listIterator();
- while (iter.hasNext()) {
- ResourceConfiguration current = (ResourceConfiguration) iter.next();
- if (current.isDirty()) return true;
- }
-
- return isDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#needsRebuild()
- */
- public boolean needsRebuild() {
- return rebuildNeeded;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- // Override the dirty flag
- this.isDirty = isDirty;
- // Propagate "false" to the children
- if (!isDirty) {
- toolChain.setDirty(false);
- Iterator iter = getResourceConfigurationList().listIterator();
- while (iter.hasNext()) {
- ResourceConfiguration current = (ResourceConfiguration) iter.next();
- current.setDirty(false);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setRebuildState(boolean)
- */
- public void setRebuildState(boolean rebuild) {
- rebuildNeeded = rebuild;
- if(rebuild && !isTemporary())
- ((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider()).checkBuildPathVariables(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#hasOverriddenBuildCommand()
- */
- public boolean hasOverriddenBuildCommand() {
- IBuilder builder = getToolChain().getBuilder();
- if (builder != null) {
- IBuilder superB = builder.getSuperClass();
- if (superB != null) {
- String command = builder.getCommand();
- if (command != null) {
- String superC = superB.getCommand();
- if (superC != null) {
- if (!command.equals(superC)) {
- return true;
- }
- }
- }
- String args = builder.getArguments();
- if (args != null) {
- String superA = superB.getArguments();
- if (superA != null) {
- if (!args.equals(superA)) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
-
- // call resolve references on any children
- toolChain.resolveReferences();
- Iterator resConfigIter = getResourceConfigurationList().iterator();
- while (resConfigIter.hasNext()) {
- ResourceConfiguration current = (ResourceConfiguration)resConfigIter.next();
- current.resolveReferences();
- }
- }
- }
-
- /**
- * Reset the configuration's, tools', options
- */
- public void reset() {
- // We just need to remove all Options
- ITool[] tools = getTools();
- IToolChain toolChain = getToolChain();
- IOption[] opts;
-
- // Send out the event to notify the options that they are about to be removed.
- // Do not do this for the child resource configurations as they are handled when
- // the configuration itself is destroyed.
-// ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE, false);
- // Remove the configurations
- for (int i = 0; i < tools.length; i++) {
- ITool tool = tools[i];
- opts = tool.getOptions();
- for (int j = 0; j < opts.length; j++) {
- tool.removeOption(opts[j]);
- }
- }
- opts = toolChain.getOptions();
- for (int j = 0; j < opts.length; j++) {
- toolChain.removeOption(opts[j]);
- }
-
- rebuildNeeded = true;
- }
-
- /*
- * Create a resource configuration object for the passed-in file
- */
- public IResourceConfiguration createResourceConfiguration(IFile file)
- {
- String path = file.getFullPath().toString();
- String resourceName = file.getName();
- String id = getId() + "." + ManagedBuildManager.getRandomNumber(); //$NON-NLS-1$
- ResourceConfiguration resConfig = new ResourceConfiguration( (IConfiguration) this, id, resourceName, path);
-
- // Get file extension.
- String extString = file.getFileExtension();
-
- // Add the resource specific tools to this resource.
- ITool tools[] = getFilteredTools();
- String subId = new String();
- for (int i = 0; i < tools.length; i++) {
- if( tools[i].buildsFileType(extString) ) {
- subId = tools[i].getId() + "." + path; //$NON-NLS-1$
- resConfig.createTool(tools[i], subId, tools[i].getName(), false);
- }
- }
-
- // Add this resource to the list.
- addResourceConfiguration(resConfig);
- ManagedBuildManager.performValueHandlerEvent(resConfig, IManagedOptionValueHandler.EVENT_OPEN);
-
- return resConfig;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getEnvironmentVariableSupplier()
- */
- public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
- IToolChain toolChain = getToolChain();
- if(toolChain != null)
- return toolChain.getEnvironmentVariableSupplier();
- return null;
- }
-
- /**
- * @return Returns the version.
- */
- public PluginVersionIdentifier getVersion() {
- if ( version == null) {
- if ( toolChain != null) {
- return toolChain.getVersion();
- }
- }
- return version;
- }
-
- public void setVersion(PluginVersionIdentifier version) {
- // Do nothing
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildMacroSupplier()
- */
- public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){
- IToolChain toolChain = getToolChain();
- if(toolChain != null)
- return toolChain.getBuildMacroSupplier();
- return null;
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isTemporary()
- */
- public boolean isTemporary(){
- return isTemporary;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
- */
- public void updateManagedBuildRevision(String revision){
- super.updateManagedBuildRevision(revision);
- toolChain.updateManagedBuildRevision(revision);
-
- for(Iterator iter = getResourceConfigurationList().iterator(); iter.hasNext();){
- ((ResourceConfiguration)iter.next()).updateManagedBuildRevision(revision);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2003, 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.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
+import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
+import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
+import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
+import org.eclipse.cdt.managedbuilder.internal.macros.UserDefinedMacroSupplier;
+import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class Configuration extends BuildObject implements IConfiguration {
+
+ private static final String EMPTY_STRING = new String();
+
+ // Parent and children
+ private IConfiguration parent;
+ private ProjectType projectType;
+ private ManagedProject managedProject;
+ private ToolChain toolChain;
+ private List resourceConfigurationList;
+ private Map resourceConfigurationMap;
+ // Managed Build model attributes
+ private String artifactName;
+ private String cleanCommand;
+ private String artifactExtension;
+ private String errorParserIds;
+ private String prebuildStep;
+ private String postbuildStep;
+ private String preannouncebuildStep;
+ private String postannouncebuildStep;
+ private String description;
+ // Miscellaneous
+ private boolean isExtensionConfig = false;
+ private boolean isDirty = false;
+ private boolean rebuildNeeded = false;
+ private boolean resolved = true;
+ private boolean isTemporary = false;
+
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * Create an extension configuration from the project manifest file element.
+ *
+ * @param projectType The <code>ProjectType</code> the configuration will be added to.
+ * @param element The element from the manifest that contains the configuration information.
+ * @param managedBuildRevision
+ */
+ public Configuration(ProjectType projectType, IManagedConfigElement element, String managedBuildRevision) {
+ this.projectType = projectType;
+ isExtensionConfig = true;
+
+ // setup for resolving
+ resolved = false;
+
+ setManagedBuildRevision(managedBuildRevision);
+
+ // Initialize from the XML attributes
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionConfiguration(this);
+
+ // Hook me up to the ProjectType
+ if (projectType != null) {
+ projectType.addConfiguration(this);
+ }
+
+ // Load the children
+ IManagedConfigElement[] configElements = element.getChildren();
+ for (int l = 0; l < configElements.length; ++l) {
+ IManagedConfigElement configElement = configElements[l];
+ if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
+ toolChain = new ToolChain(this, configElement, managedBuildRevision);
+ }else if (configElement.getName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
+ ResourceConfiguration resConfig = new ResourceConfiguration(this, configElement, managedBuildRevision);
+ addResourceConfiguration(resConfig);
+ }
+ }
+ }
+
+ /**
+ * Create a new extension configuration based on one already defined.
+ *
+ * @param projectType The <code>ProjectType</code> the configuration will be added to.
+ * @param parentConfig The <code>IConfiguration</code> that is the parent configuration of this configuration
+ * @param id A unique ID for the new configuration.
+ */
+ public Configuration(ProjectType projectType, IConfiguration parentConfig, String id) {
+ setId(id);
+ this.projectType = projectType;
+ isExtensionConfig = true;
+
+ // setup for resolving
+ resolved = false;
+
+ if (parentConfig != null) {
+ name = parentConfig.getName();
+ // If this contructor is called to clone an existing
+ // configuration, the parent of the parent should be stored.
+ // As of 2.1, there is still one single level of inheritence to
+ // worry about
+ parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent();
+ }
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionConfiguration(this);
+
+ // Hook me up to the ProjectType
+ if (projectType != null) {
+ projectType.addConfiguration(this);
+ // set managedBuildRevision
+ setManagedBuildRevision(projectType.getManagedBuildRevision());
+ }
+ }
+
+ /**
+ * Create a new extension configuration and fill in the attributes and childen later.
+ *
+ * @param projectType The <code>ProjectType</code> the configuration will be added to.
+ * @param parentConfig The <code>IConfiguration</code> that is the parent configuration of this configuration
+ * @param id A unique ID for the new configuration.
+ * @param name A name for the new configuration.
+ */
+ public Configuration(ProjectType projectType, IConfiguration parentConfig, String id, String name) {
+ setId(id);
+ setName(name);
+ this.projectType = projectType;
+ parent = parentConfig;
+ isExtensionConfig = true;
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionConfiguration(this);
+
+ // Hook me up to the ProjectType
+ if (projectType != null) {
+ projectType.addConfiguration(this);
+ setManagedBuildRevision(projectType.getManagedBuildRevision());
+ }
+ }
+
+ /**
+ * Create a <code>Configuration</code> based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param managedProject The <code>ManagedProject</code> the configuration will be added to.
+ * @param element The XML element that contains the configuration settings.
+ *
+ */
+ public Configuration(ManagedProject managedProject, Element element, String managedBuildRevision) {
+ this.managedProject = managedProject;
+ isExtensionConfig = false;
+
+ setManagedBuildRevision(managedBuildRevision);
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Hook me up
+ managedProject.addConfiguration(this);
+
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
+ toolChain = new ToolChain(this, (Element)configElement, managedBuildRevision);
+ }else if (configElement.getNodeName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
+ ResourceConfiguration resConfig = new ResourceConfiguration(this, (Element)configElement, managedBuildRevision);
+ addResourceConfiguration(resConfig);
+ }
+ }
+ }
+
+ /**
+ * Create a new project, non-extension, configuration based on one already defined.
+ *
+ * @param managedProject The <code>ManagedProject</code> the configuration will be added to.
+ * @param cloneConfig The <code>IConfiguration</code> to copy the settings from.
+ * @param id A unique ID for the new configuration.
+ * @param cloneChildren If <code>true</code>, the configuration's tools are cloned
+ */
+ public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) {
+ setId(id);
+ setName(cloneConfig.getName());
+ this.description = cloneConfig.getDescription();
+ this.managedProject = managedProject;
+ isExtensionConfig = false;
+ this.isTemporary = temporary;
+
+ // set managedBuildRevision
+ setManagedBuildRevision(cloneConfig.getManagedBuildRevision());
+
+ // If this contructor is called to clone an existing
+ // configuration, the parent of the cloning config should be stored.
+ parent = cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent();
+
+ // Copy the remaining attributes
+ projectType = cloneConfig.projectType;
+ if (cloneConfig.artifactName != null) {
+ artifactName = new String(cloneConfig.artifactName);
+ }
+ if (cloneConfig.cleanCommand != null) {
+ cleanCommand = new String(cloneConfig.cleanCommand);
+ }
+ if (cloneConfig.artifactExtension != null) {
+ artifactExtension = new String(cloneConfig.artifactExtension);
+ }
+ if (cloneConfig.errorParserIds != null) {
+ errorParserIds = new String(cloneConfig.errorParserIds);
+ }
+ if (cloneConfig.prebuildStep != null) {
+ prebuildStep = new String(cloneConfig.prebuildStep);
+ }
+ if (cloneConfig.postbuildStep != null) {
+ postbuildStep = new String(cloneConfig.postbuildStep);
+ }
+ if (cloneConfig.preannouncebuildStep != null) {
+ preannouncebuildStep = new String(cloneConfig.preannouncebuildStep);
+ }
+ if (cloneConfig.postannouncebuildStep != null) {
+ postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
+ }
+
+ // Clone the configuration's children
+ // Tool Chain
+ String subId;
+ String subName;
+ if (cloneConfig.parent != null) {
+ subId = ManagedBuildManager.calculateChildId(
+ cloneConfig.parent.getToolChain().getId(),
+ null);
+ subName = cloneConfig.parent.getToolChain().getName();
+
+ } else {
+ subId = ManagedBuildManager.calculateChildId(
+ cloneConfig.getToolChain().getId(),
+ null);
+ subName = cloneConfig.getToolChain().getName();
+ }
+
+ if (cloneChildren) {
+ toolChain = new ToolChain(this, subId, subName, (ToolChain)cloneConfig.getToolChain());
+
+ //copy expand build macros setting
+ BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
+ macroProvider.expandMacrosInBuildfile(this,
+ macroProvider.areMacrosExpandedInBuildfile(cloneConfig));
+
+ //copy user-defined build macros
+ UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
+ userMacros.setMacros(
+ userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
+ BuildMacroProvider.CONTEXT_CONFIGURATION,
+ this);
+
+ //copy user-defined environment
+ UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
+ userEnv.setVariables(
+ userEnv.getVariables(cloneConfig), this);
+
+ } else {
+ // Add a tool-chain element that specifies as its superClass the
+ // tool-chain that is the child of the configuration.
+ ToolChain superChain = (ToolChain)cloneConfig.getToolChain();
+ subId = ManagedBuildManager.calculateChildId(
+ superChain.getId(),
+ null);
+ IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false);
+
+ // For each option/option category child of the tool-chain that is
+ // the child of the selected configuration element, create an option/
+ // option category child of the cloned configuration's tool-chain element
+ // that specifies the original tool element as its superClass.
+ newChain.createOptions(superChain);
+
+ // For each tool element child of the tool-chain that is the child of
+ // the selected configuration element, create a tool element child of
+ // the cloned configuration's tool-chain element that specifies the
+ // original tool element as its superClass.
+ ITool[] tools = superChain.getTools();
+ for (int i=0; i<tools.length; i++) {
+ Tool toolChild = (Tool)tools[i];
+ subId = ManagedBuildManager.calculateChildId(toolChild.getId(),null);
+ newChain.createTool(toolChild, subId, toolChild.getName(), false);
+ }
+ }
+
+ // Resource Configurations
+ if (cloneConfig.resourceConfigurationList != null) {
+ List resElements = cloneConfig.getResourceConfigurationList();
+ Iterator iter = resElements.listIterator();
+ while (iter.hasNext()) {
+ ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
+ subId = getId() + "." + ManagedBuildManager.getRandomNumber(); //$NON-NLS-1$
+ ResourceConfiguration newResConfig = new ResourceConfiguration(this, resConfig, subId);
+ addResourceConfiguration(newResConfig);
+ }
+ }
+
+ // Hook me up
+ managedProject.addConfiguration(this);
+ setDirty(true);
+ rebuildNeeded = true;
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Initialize the configuration information from an element in the
+ * manifest file or provided by a dynamicElementProvider
+ *
+ * @param element An obejct implementing IManagedConfigElement
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IConfiguration.ID));
+
+ // name
+ name = element.getAttribute(IConfiguration.NAME);
+
+ // description
+ description = element.getAttribute(IConfiguration.DESCRIPTION);
+
+ // parent
+ String parentID = element.getAttribute(IConfiguration.PARENT);
+ if (parentID != null) {
+ // Lookup the parent configuration by ID
+ parent = ManagedBuildManager.getExtensionConfiguration(parentID);
+ }
+
+ // Get the name of the build artifact associated with configuration
+ artifactName = element.getAttribute(ARTIFACT_NAME);
+
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+
+ // Get the artifact extension
+ artifactExtension = element.getAttribute(EXTENSION);
+
+ // Get the clean command
+ cleanCommand = element.getAttribute(CLEAN_COMMAND);
+
+ // Get the pre-build and post-build commands
+ prebuildStep = element.getAttribute(PREBUILD_STEP);
+ postbuildStep = element.getAttribute(POSTBUILD_STEP);
+
+ // Get the pre-build and post-build announcements
+ preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
+ postannouncebuildStep = element.getAttribute(POSTANNOUNCEBUILD_STEP);
+ }
+
+ /* (non-Javadoc)
+ * Initialize the configuration information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the configuration information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IConfiguration.ID));
+
+ // name
+ if (element.hasAttribute(IConfiguration.NAME))
+ setName(element.getAttribute(IConfiguration.NAME));
+
+ // description
+ if (element.hasAttribute(IConfiguration.DESCRIPTION))
+ this.description = element.getAttribute(IConfiguration.DESCRIPTION);
+
+ if (element.hasAttribute(IConfiguration.PARENT)) {
+ // See if the parent belongs to the same project
+ parent = managedProject.getConfiguration(element.getAttribute(IConfiguration.PARENT));
+ // If not, then try the extension configurations
+ if (parent == null) {
+ parent = ManagedBuildManager.getExtensionConfiguration(element.getAttribute(IConfiguration.PARENT));
+ }
+ }
+
+ // Get the name of the build artifact associated with target (usually
+ // in the plugin specification).
+ if (element.hasAttribute(ARTIFACT_NAME)) {
+ artifactName = element.getAttribute(ARTIFACT_NAME);
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+ }
+
+ // Get the artifact extension
+ if (element.hasAttribute(EXTENSION)) {
+ artifactExtension = element.getAttribute(EXTENSION);
+ }
+
+ // Get the clean command
+ if (element.hasAttribute(CLEAN_COMMAND)) {
+ cleanCommand = element.getAttribute(CLEAN_COMMAND);
+ }
+
+ // Get the pre-build and post-build commands
+ if (element.hasAttribute(PREBUILD_STEP)) {
+ prebuildStep = element.getAttribute(PREBUILD_STEP);
+ }
+
+ if (element.hasAttribute(POSTBUILD_STEP)) {
+ postbuildStep = element.getAttribute(POSTBUILD_STEP);
+ }
+
+ // Get the pre-build and post-build announcements
+ if (element.hasAttribute(PREANNOUNCEBUILD_STEP)) {
+ preannouncebuildStep = element.getAttribute(PREANNOUNCEBUILD_STEP);
+ }
+
+ if (element.hasAttribute(POSTANNOUNCEBUILD_STEP)) {
+ postannouncebuildStep = element
+ .getAttribute(POSTANNOUNCEBUILD_STEP);
+ }
+ }
+
+ /**
+ * Persist this configuration to project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ element.setAttribute(IConfiguration.ID, id);
+
+ if (name != null)
+ element.setAttribute(IConfiguration.NAME, name);
+
+ if (description != null)
+ element.setAttribute(IConfiguration.DESCRIPTION, description);
+
+ if (parent != null)
+ element.setAttribute(IConfiguration.PARENT, parent.getId());
+
+ if (artifactName != null)
+ element.setAttribute(ARTIFACT_NAME, artifactName);
+
+ if (errorParserIds != null)
+ element.setAttribute(ERROR_PARSERS, errorParserIds);
+
+ if (artifactExtension != null)
+ element.setAttribute(EXTENSION, artifactExtension);
+
+ if (cleanCommand != null)
+ element.setAttribute(CLEAN_COMMAND, cleanCommand);
+
+ if (prebuildStep != null)
+ element.setAttribute(PREBUILD_STEP, prebuildStep);
+
+ if (postbuildStep != null)
+ element.setAttribute(POSTBUILD_STEP, postbuildStep);
+
+ if (preannouncebuildStep != null)
+ element.setAttribute(PREANNOUNCEBUILD_STEP, preannouncebuildStep);
+
+ if (postannouncebuildStep != null)
+ element.setAttribute(POSTANNOUNCEBUILD_STEP, postannouncebuildStep);
+
+ // Serialize my children
+ Element toolChainElement = doc.createElement(IToolChain.TOOL_CHAIN_ELEMENT_NAME);
+ element.appendChild(toolChainElement);
+ toolChain.serialize(doc, toolChainElement);
+ List resElements = getResourceConfigurationList();
+ Iterator iter = resElements.listIterator();
+ while (iter.hasNext()) {
+ ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
+ Element resElement = doc.createElement(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME);
+ element.appendChild(resElement);
+ resConfig.serialize(doc, resElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
+ */
+ public IConfiguration getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getOwner()
+ */
+ public IResource getOwner() {
+ if (managedProject != null)
+ return managedProject.getOwner();
+ else {
+ return null; // Extension configurations don't have an "owner"
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getProjectType()
+ */
+ public IProjectType getProjectType() {
+ return (IProjectType)projectType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getManagedProject()
+ */
+ public IManagedProject getManagedProject() {
+ return (IManagedProject)managedProject;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain(IToolChain, String, String, boolean)
+ */
+ public IToolChain createToolChain(IToolChain superClass, String Id, String name, boolean isExtensionElement) {
+ toolChain = new ToolChain(this, superClass, Id, name, isExtensionElement);
+ setDirty(true);
+ return (IToolChain)toolChain;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain()
+ */
+ public IToolChain getToolChain() {
+ return (IToolChain)toolChain;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getResourceConfigurations()
+ */
+ public IResourceConfiguration[] getResourceConfigurations() {
+ IResourceConfiguration[] resConfigs = new IResourceConfiguration[getResourceConfigurationList().size()];
+ Iterator iter = getResourceConfigurationList().listIterator();
+ int i = 0;
+ while (iter.hasNext()) {
+ ResourceConfiguration resConfig = (ResourceConfiguration)iter.next();
+ resConfigs[i++] = (IResourceConfiguration)resConfig;
+ }
+ return resConfigs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceConfiguration(java.lang.String)
+ */
+ public IResourceConfiguration getResourceConfiguration(String resPath) {
+ ResourceConfiguration resConfig = (ResourceConfiguration)getResourceConfigurationMap().get(resPath);
+ return (IResourceConfiguration)resConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools()
+ */
+ public ITool[] getFilteredTools() {
+ if (toolChain == null) {
+ return new ITool[0];
+ }
+ ITool[] localTools = toolChain.getTools();
+ IManagedProject manProj = getManagedProject();
+ if (manProj == null) {
+ // If this is not associated with a project, then there is nothing to filter with
+ return localTools;
+ }
+ IProject project = (IProject)manProj.getOwner();
+ Vector tools = new Vector(localTools.length);
+ for (int i = 0; i < localTools.length; i++) {
+ ITool tool = localTools[i];
+ try {
+ // Make sure the tool is right for the project
+ switch (tool.getNatureFilter()) {
+ case ITool.FILTER_C:
+ if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ tools.add(tool);
+ }
+ break;
+ case ITool.FILTER_CC:
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ tools.add(tool);
+ }
+ break;
+ case ITool.FILTER_BOTH:
+ tools.add(tool);
+ break;
+ default:
+ break;
+ }
+ } catch (CoreException e) {
+ continue;
+ }
+ }
+
+ // Answer the filtered tools as an array
+ return (ITool[])tools.toArray(new ITool[tools.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
+ */
+ public ITool[] getTools() {
+ return toolChain.getTools();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTool(java.lang.String)
+ */
+ public ITool getTool(String id) {
+ return toolChain.getTool(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolsBySuperClassId(java.lang.String)
+ */
+ public ITool[] getToolsBySuperClassId(String id) {
+ return toolChain.getToolsBySuperClassId(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool()
+ */
+ public ITool getTargetTool() {
+ String[] targetToolIds = toolChain.getTargetToolList();
+ if (targetToolIds == null || targetToolIds.length == 0) return null;
+
+ // For each target tool id, in list order,
+ // look for a tool with this ID, or a tool with a superclass with this id.
+ // Stop when we find a match
+ ITool[] tools = getFilteredTools();
+ for (int i=0; i<targetToolIds.length; i++) {
+ String targetToolId = targetToolIds[i];
+ for (int j=0; j<tools.length; j++) {
+ ITool targetTool = tools[j];
+ ITool tool = targetTool;
+ do {
+ if (targetToolId.equals(tool.getId())) {
+ return targetTool;
+ }
+ tool = tool.getSuperClass();
+ } while (tool != null);
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
+ */
+ public String getToolCommand(ITool tool) {
+ // TODO: Do we need to verify that the tool is part of the configuration?
+ return tool.getToolCommand();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
+ */
+ public void setToolCommand(ITool tool, String command) {
+ // TODO: Do we need to verify that the tool is part of the configuration?
+ tool.setToolCommand(command);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
+ */
+ public IOption setOption(IHoldsOptions holder, IOption option, boolean value) throws BuildException {
+ // Is there a change?
+ IOption retOpt = option;
+ if (option.getBooleanValue() != value) {
+ retOpt = holder.getOptionToSet(option, false);
+ retOpt.setValue(value);
+ rebuildNeeded = true;
+ }
+ return retOpt;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
+ */
+ public IOption setOption(IHoldsOptions holder, IOption option, String value) throws BuildException {
+ IOption retOpt = option;
+ String oldValue;
+ oldValue = option.getStringValue();
+ if (oldValue != null && !oldValue.equals(value)) {
+ retOpt = holder.getOptionToSet(option, false);
+ retOpt.setValue(value);
+ rebuildNeeded = true;
+ }
+ return retOpt;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
+ */
+ public IOption setOption(IHoldsOptions holder, IOption option, String[] value) throws BuildException {
+ IOption retOpt = option;
+ // Is there a change?
+ String[] oldValue;
+ switch (option.getValueType()) {
+ case IOption.STRING_LIST :
+ oldValue = option.getStringListValue();
+ break;
+ case IOption.INCLUDE_PATH :
+ oldValue = option.getIncludePaths();
+ break;
+ case IOption.PREPROCESSOR_SYMBOLS :
+ oldValue = option.getDefinedSymbols();
+ break;
+ case IOption.LIBRARIES :
+ oldValue = option.getLibraries();
+ break;
+ case IOption.OBJECTS :
+ oldValue = option.getUserObjects();
+ break;
+ default :
+ oldValue = new String[0];
+ break;
+ }
+ if(!Arrays.equals(value, oldValue)) {
+ retOpt = holder.getOptionToSet(option, false);
+ retOpt.setValue(value);
+ rebuildNeeded = true;
+ }
+ return retOpt;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the list of resource configs.
+ *
+ * @return List containing the tools
+ */
+ private List getResourceConfigurationList() {
+ if (resourceConfigurationList == null) {
+ resourceConfigurationList = new ArrayList();
+ }
+ return resourceConfigurationList;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of resource paths to resource configs
+ *
+ * @return
+ */
+ private Map getResourceConfigurationMap() {
+ if (resourceConfigurationMap == null) {
+ resourceConfigurationMap = new HashMap();
+ }
+ return resourceConfigurationMap;
+ }
+
+ /* (non-Javadoc)
+ * Adds the Resource Configuration to the Resource Configuration list and map
+ *
+ * @param resConfig
+ */
+ public void addResourceConfiguration(ResourceConfiguration resConfig) {
+ getResourceConfigurationList().add(resConfig);
+ getResourceConfigurationMap().put(resConfig.getResourcePath(), resConfig);
+ isDirty = true;
+ rebuildNeeded = true;
+ }
+
+ public void removeResourceConfiguration(IResourceConfiguration resConfig) {
+ ManagedBuildManager.performValueHandlerEvent(resConfig,
+ IManagedOptionValueHandler.EVENT_CLOSE);
+ getResourceConfigurationList().remove(resConfig);
+ getResourceConfigurationMap().remove(resConfig.getResourcePath());
+ isDirty = true;
+ rebuildNeeded = true;
+ }
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
+ */
+ public String getName() {
+ return (name == null && parent != null) ? parent.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getArtifactExtension()
+ */
+ public String getArtifactExtension() {
+ if (artifactExtension == null) {
+ // Ask my parent first
+ if (parent != null) {
+ return parent.getArtifactExtension();
+ } else {
+ return EMPTY_STRING;
+ }
+ } else {
+ return artifactExtension;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getArtifactName()
+ */
+ public String getArtifactName() {
+ if (artifactName == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getArtifactName();
+ } else {
+ // I'm it and this is not good!
+ return EMPTY_STRING;
+ }
+ } else {
+ return artifactName;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildArguments()
+ */
+ public String getBuildArguments() {
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if (builder != null) {
+ return builder.getArguments();
+ }
+ return new String("-k"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildCommand()
+ */
+ public String getBuildCommand() {
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if (builder != null) {
+ return builder.getCommand();
+ }
+ return new String("make"); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPrebuildStep()
+ */
+ public String getPrebuildStep() {
+ if (prebuildStep == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getPrebuildStep();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return prebuildStep;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostbuildStep()
+ */
+ public String getPostbuildStep() {
+ if (postbuildStep == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getPostbuildStep();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return postbuildStep;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPreannouncebuildStep()
+ */
+ public String getPreannouncebuildStep() {
+ if (preannouncebuildStep == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getPreannouncebuildStep();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return preannouncebuildStep;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostannouncebuildStep()
+ */
+ public String getPostannouncebuildStep() {
+ if (postannouncebuildStep == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getPostannouncebuildStep();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return postannouncebuildStep;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getCleanCommand()
+ */
+ public String getCleanCommand() {
+ // Return the command used to remove files
+ if (cleanCommand == null) {
+ if (parent != null) {
+ return parent.getCleanCommand();
+ } else {
+ // User forgot to specify it. Guess based on OS.
+ if (Platform.getOS().equals("OS_WIN32")) { //$NON-NLS-1$
+ return new String("del"); //$NON-NLS-1$
+ } else {
+ return new String("rm"); //$NON-NLS-1$
+ }
+ }
+ } else {
+ // This was spec'd in the manifest
+ return cleanCommand;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getDescription()
+ */
+ public String getDescription() {
+ if (description == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getDescription();
+ } else {
+ // I'm it
+ return EMPTY_STRING;
+ }
+ } else {
+ return description;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ if (errorParserIds != null) {
+ return errorParserIds;
+ }
+ // If I have a parent, ask it
+ String errorParsers = null;
+ if (parent != null) {
+ errorParsers = parent.getErrorParserIds();
+ }
+ // If no error parsers are specified by the configuration, the default
+ // is
+ // the error parsers from the tool-chain
+ if (errorParsers == null && toolChain != null) {
+ errorParsers = toolChain.getErrorParserIds(this);
+ }
+ return errorParsers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ String parserIDs = getErrorParserIds();
+ String[] errorParsers;
+ if (parserIDs != null) {
+ // Check for an empty string
+ if (parserIDs.length() == 0) {
+ errorParsers = new String[0];
+ } else {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ List list = new ArrayList(tok.countTokens());
+ while (tok.hasMoreElements()) {
+ list.add(tok.nextToken());
+ }
+ String[] strArr = {""}; //$NON-NLS-1$
+ errorParsers = (String[]) list.toArray(strArr);
+ }
+ } else {
+ // If no error parsers are specified, the default is
+ // all error parsers
+ errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
+ }
+ return errorParsers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String)
+ */
+ public void setArtifactExtension(String extension) {
+ if (extension == null && artifactExtension == null) return;
+ if (artifactExtension == null || extension == null || !artifactExtension.equals(extension)) {
+ artifactExtension = extension;
+ rebuildNeeded = true;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setArtifactName(java.lang.String)
+ */
+ public void setArtifactName(String name) {
+ if (name == null && artifactName == null) return;
+ if (artifactName == null || name == null || !artifactName.equals(name)) {
+ artifactName = name;
+ rebuildNeeded = true;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ String currentIds = getErrorParserIds();
+ if (ids == null && currentIds == null) return;
+ if (currentIds == null || ids == null || !(currentIds.equals(ids))) {
+ errorParserIds = ids;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setCleanCommand()
+ */
+ public void setCleanCommand(String command) {
+ if (command == null && cleanCommand == null) return;
+ if (cleanCommand == null || command == null || !cleanCommand.equals(command)) {
+ cleanCommand = command;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setDescription(java.lang.String)
+ */
+ public void setDescription(String description) {
+ if (description == null && this.description == null) return;
+ if (this.description == null || description == null || !description.equals(this.description)) {
+ this.description = description;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildArguments()
+ */
+ public void setBuildArguments(String makeArgs) {
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if(makeArgs == null){ //resetting the build arguments
+ if(!builder.isExtensionElement()){
+ builder.setArguments(makeArgs);
+ rebuildNeeded = true;
+ }
+ }else if(!makeArgs.equals(builder.getArguments())){
+ if (builder.isExtensionElement()) {
+ String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
+ String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
+ builder = toolChain.createBuilder(builder, subId, builderName, false);
+ }
+ builder.setArguments(makeArgs);
+ rebuildNeeded = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildCommand()
+ */
+ public void setBuildCommand(String command) {
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if(command == null){ //resetting the build command
+ if(!builder.isExtensionElement()){
+ builder.setCommand(command);
+ rebuildNeeded = true;
+ }
+ } else if(!command.equals(builder.getCommand())){
+ if (builder.isExtensionElement()) {
+ String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
+ String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
+ builder = toolChain.createBuilder(builder, subId, builderName, false);
+ }
+ builder.setCommand(command);
+ rebuildNeeded = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPrebuildStep(java.lang.String)
+ */
+ public void setPrebuildStep(String step) {
+ if (step == null && prebuildStep == null) return;
+ if (prebuildStep == null || step == null || !prebuildStep.equals(step)) {
+ prebuildStep = step;
+ rebuildNeeded = true;
+ isDirty = true;
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostbuildStep(java.lang.String)
+ */
+ public void setPostbuildStep(String step) {
+ if (step == null && postbuildStep == null) return;
+ if (postbuildStep == null || step == null || !postbuildStep.equals(step)) {
+ postbuildStep = step;
+ rebuildNeeded = true;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPreannouncebuildStep(java.lang.String)
+ */
+ public void setPreannouncebuildStep(String announceStep) {
+ if (announceStep == null && preannouncebuildStep == null) return;
+ if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) {
+ preannouncebuildStep = announceStep;
+ rebuildNeeded = true;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostannouncebuildStep(java.lang.String)
+ */
+ public void setPostannouncebuildStep(String announceStep) {
+ if (announceStep == null && postannouncebuildStep == null) return;
+ if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) {
+ postannouncebuildStep = announceStep;
+ rebuildNeeded = true;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isSupported()
+ */
+ public boolean isSupported(){
+ IToolChain toolChain = getToolChain();
+ if(toolChain != null)
+ return toolChain.isSupported();
+ return false;
+ }
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension configuration
+ if (isExtensionConfig) return false;
+
+ // If I need saving, just say yes
+ if (isDirty) return true;
+
+ // Otherwise see if any children need saving
+ if (toolChain.isDirty()) return true;
+ Iterator iter = getResourceConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ ResourceConfiguration current = (ResourceConfiguration) iter.next();
+ if (current.isDirty()) return true;
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#needsRebuild()
+ */
+ public boolean needsRebuild() {
+ return rebuildNeeded;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ // Override the dirty flag
+ this.isDirty = isDirty;
+ // Propagate "false" to the children
+ if (!isDirty) {
+ toolChain.setDirty(false);
+ Iterator iter = getResourceConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ ResourceConfiguration current = (ResourceConfiguration) iter.next();
+ current.setDirty(false);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setRebuildState(boolean)
+ */
+ public void setRebuildState(boolean rebuild) {
+ rebuildNeeded = rebuild;
+ if(rebuild && !isTemporary())
+ ((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider()).checkBuildPathVariables(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#hasOverriddenBuildCommand()
+ */
+ public boolean hasOverriddenBuildCommand() {
+ IBuilder builder = getToolChain().getBuilder();
+ if (builder != null) {
+ IBuilder superB = builder.getSuperClass();
+ if (superB != null) {
+ String command = builder.getCommand();
+ if (command != null) {
+ String superC = superB.getCommand();
+ if (superC != null) {
+ if (!command.equals(superC)) {
+ return true;
+ }
+ }
+ }
+ String args = builder.getArguments();
+ if (args != null) {
+ String superA = superB.getArguments();
+ if (superA != null) {
+ if (!args.equals(superA)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+
+ // call resolve references on any children
+ toolChain.resolveReferences();
+ Iterator resConfigIter = getResourceConfigurationList().iterator();
+ while (resConfigIter.hasNext()) {
+ ResourceConfiguration current = (ResourceConfiguration)resConfigIter.next();
+ current.resolveReferences();
+ }
+ }
+ }
+
+ /**
+ * Reset the configuration's, tools', options
+ */
+ public void reset() {
+ // We just need to remove all Options
+ ITool[] tools = getTools();
+ IToolChain toolChain = getToolChain();
+ IOption[] opts;
+
+ // Send out the event to notify the options that they are about to be removed.
+ // Do not do this for the child resource configurations as they are handled when
+ // the configuration itself is destroyed.
+// ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE, false);
+ // Remove the configurations
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ opts = tool.getOptions();
+ for (int j = 0; j < opts.length; j++) {
+ tool.removeOption(opts[j]);
+ }
+ }
+ opts = toolChain.getOptions();
+ for (int j = 0; j < opts.length; j++) {
+ toolChain.removeOption(opts[j]);
+ }
+
+ rebuildNeeded = true;
+ }
+
+ /*
+ * Create a resource configuration object for the passed-in file
+ */
+ public IResourceConfiguration createResourceConfiguration(IFile file)
+ {
+ String path = file.getFullPath().toString();
+ String resourceName = file.getName();
+ String id = getId() + "." + ManagedBuildManager.getRandomNumber(); //$NON-NLS-1$
+ ResourceConfiguration resConfig = new ResourceConfiguration( (IConfiguration) this, id, resourceName, path);
+
+ // Get file extension.
+ String extString = file.getFileExtension();
+
+ // Add the resource specific tools to this resource.
+ ITool tools[] = getFilteredTools();
+ String subId = new String();
+ for (int i = 0; i < tools.length; i++) {
+ if( tools[i].buildsFileType(extString) ) {
+ subId = tools[i].getId() + "." + path; //$NON-NLS-1$
+ resConfig.createTool(tools[i], subId, tools[i].getName(), false);
+ }
+ }
+
+ // Add this resource to the list.
+ addResourceConfiguration(resConfig);
+ ManagedBuildManager.performValueHandlerEvent(resConfig, IManagedOptionValueHandler.EVENT_OPEN);
+
+ return resConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getEnvironmentVariableSupplier()
+ */
+ public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
+ IToolChain toolChain = getToolChain();
+ if(toolChain != null)
+ return toolChain.getEnvironmentVariableSupplier();
+ return null;
+ }
+
+ /**
+ * @return Returns the version.
+ */
+ public PluginVersionIdentifier getVersion() {
+ if ( version == null) {
+ if ( toolChain != null) {
+ return toolChain.getVersion();
+ }
+ }
+ return version;
+ }
+
+ public void setVersion(PluginVersionIdentifier version) {
+ // Do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildMacroSupplier()
+ */
+ public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){
+ IToolChain toolChain = getToolChain();
+ if(toolChain != null)
+ return toolChain.getBuildMacroSupplier();
+ return null;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isTemporary()
+ */
+ public boolean isTemporary(){
+ return isTemporary;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
+ */
+ public void updateManagedBuildRevision(String revision){
+ super.updateManagedBuildRevision(revision);
+ toolChain.updateManagedBuildRevision(revision);
+
+ for(Iterator iter = getResourceConfigurationList().iterator(); iter.hasNext();){
+ ((ResourceConfiguration)iter.next()).updateManagedBuildRevision(revision);
+ }
+ }
+
+ public void setParent(IConfiguration parent) {
+ if ( this.parent != parent) {
+ this.parent = parent;
+ if (!isExtensionElement())
+ setDirty(true);
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
index 2eaf270710..7323793868 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
@@ -1,1002 +1,1002 @@
-/*******************************************************************************
- * Copyright (c) 2002, 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.core;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CommandLauncher;
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.core.ErrorParserManager;
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.core.model.ICModelMarker;
-import org.eclipse.cdt.core.resources.ACBuilder;
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-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.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-/**
- * This is the incremental builder associated with a managed build project. It dynamically
- * decides the makefile generator it wants to use for a specific target.
- *
- * @since 1.2
- */
-public class GeneratedMakefileBuilder extends ACBuilder {
-
- /**
- * @since 1.2
- */
- public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
- private String buildGoalName;
- private IManagedBuildInfo buildInfo;
- private boolean incrBuildNeeded = false;
- private boolean fullBuildNeeded = false;
- private List reservedNames;
-
- /**
- *
- */
- public ResourceDeltaVisitor(IManagedBuildInfo info) {
- buildInfo = info;
- String ext = buildInfo.getBuildArtifactExtension();
- //try to resolve build macros in the build artifact extension
- try{
- ext = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
- ext,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
- } catch (BuildMacroException e){
- }
-
- String name = buildInfo.getBuildArtifactName();
- //try to resolve build macros in the build artifact name
- try{
- String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
- name,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
- if((resolved = resolved.trim()).length() > 0)
- name = resolved;
- } catch (BuildMacroException e){
- }
-
- if (ext.length() > 0) {
- buildGoalName = buildInfo.getOutputPrefix(ext) + name + IManagedBuilderMakefileGenerator.DOT + ext;
- } else {
- buildGoalName = name;
- }
- reservedNames = Arrays.asList(new String[]{".cdtbuild", ".cdtproject", ".project"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- * @param changedResource
- * @return
- */
- private boolean isGeneratedResource(IResource resource) {
- // Is this a generated directory ...
- IPath path = resource.getProjectRelativePath();
- String[] configNames = buildInfo.getConfigurationNames();
- for (int i = 0; i < configNames.length; i++) {
- String name = configNames[i];
- IPath root = new Path(name);
- // It is if it is a root of the resource pathname
- if (root.isPrefixOf(path)) return true;
- }
- return false;
- }
-
- /**
- * @param resource
- * @return
- */
- private boolean isProjectFile(IResource resource) {
- return reservedNames.contains(resource.getName());
- }
-
- public boolean shouldBuildIncr() {
- return incrBuildNeeded;
- }
-
- public boolean shouldBuildFull() {
- return fullBuildNeeded;
- }
-
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
- // If the project has changed, then a build is needed and we can stop
- if (resource != null && resource.getProject() == getProject()) {
- IResourceDelta[] kids = delta.getAffectedChildren();
- for (int index = kids.length - 1; index >= 0; --index) {
- IResource changedResource = kids[index].getResource();
- if (changedResource instanceof IFolder) {
- return true;
- } else {
- String name = changedResource.getName();
- if ((!name.equals(buildGoalName) &&
- // TODO: Also need to check for secondary outputs
- (changedResource.isDerived() ||
- (isProjectFile(changedResource)) ||
- (isGeneratedResource(changedResource))))) {
- // The resource that changed has attributes which make it uninteresting,
- // so don't do anything
- ;
- }
- else {
- // TODO: Should we do extra checks here to determine if a build is really needed,
- // or do you just do exclusion checks like above?
- // We could check for:
- // o The build goal name
- // o A secondary output
- // o An input file to a tool:
- // o Has an extension of a source file used by a tool
- // o Has an extension of a header file used by a tool
- // o Has the name of an input file specified in an InputType via:
- // o An Option
- // o An AdditionalInput
- //
- //if (resourceName.equals(buildGoalName) ||
- // (buildInfo.buildsFileType(ext) || buildInfo.isHeaderFile(ext))) {
-
- // We need to do an incremental build, at least
- incrBuildNeeded = true;
- if (kids[index].getKind() == IResourceDelta.REMOVED) {
- // If a meaningful resource was removed, then force a full build
- // This is required because an incremental build will trigger make to
- // do nothing for a missing source, since the state after the file
- // removal is uptodate, as far as make is concerned
- // A full build will clean, and ultimately trigger a relink without
- // the object generated from the deleted source, which is what we want
- fullBuildNeeded = true;
- // There is no point in checking anything else since we have
- // decided to do a full build anyway
- break;
- }
-
- //}
- }
- }
- }
- return false;
- }
- return true;
- }
- }
-
- // String constants
- private static final String BUILD_ERROR = "ManagedMakeBuilder.message.error"; //$NON-NLS-1$
- private static final String BUILD_FINISHED = "ManagedMakeBuilder.message.finished"; //$NON-NLS-1$
- private static final String CONSOLE_HEADER = "ManagedMakeBuilder.message.console.header"; //$NON-NLS-1$
- private static final String ERROR_HEADER = "GeneratedmakefileBuilder error ["; //$NON-NLS-1$
- private static final String MAKE = "ManagedMakeBuilder.message.make"; //$NON-NLS-1$
- private static final String MARKERS = "ManagedMakeBuilder.message.creating.markers"; //$NON-NLS-1$
- private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
- private static final String NOTHING_BUILT = "ManagedMakeBuilder.message.no.build"; //$NON-NLS-1$
- private static final String REFRESH = "ManagedMakeBuilder.message.updating"; //$NON-NLS-1$
- private static final String REFRESH_ERROR = BUILD_ERROR + ".refresh"; //$NON-NLS-1$
- private static final String TRACE_FOOTER = "]: "; //$NON-NLS-1$
- private static final String TRACE_HEADER = "GeneratedmakefileBuilder trace ["; //$NON-NLS-1$
- private static final String TYPE_CLEAN = "ManagedMakeBuilder.type.clean"; //$NON-NLS-1$
- private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
- private static final String WARNING_UNSUPPORTED_CONFIGURATION = "ManagedMakeBuilder.warning.unsupported.configuration"; //$NON-NLS-1$
- public static boolean VERBOSE = false;
-
- // Local variables
- protected Vector generationProblems;
- protected IProject[] referencedProjects;
- protected List resourcesToBuild;
- public static void outputTrace(String resourceName, String message) {
- if (VERBOSE) {
- System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
- }
- }
-
- public static void outputError(String resourceName, String message) {
- if (VERBOSE) {
- System.err.println(ERROR_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
- }
- }
-
- /**
- * Zero-argument constructor needed to fulfill the contract of an
- * incremental builder.
- */
- public GeneratedMakefileBuilder() {
- }
-
- /**
- * @param epm
- */
- private void addBuilderMarkers(ErrorParserManager epm) {
- IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
- Iterator iter = getGenerationProblems().iterator();
- while (iter.hasNext()) {
- IStatus stat = (IStatus)iter.next();
- IResource location = root.findMember(stat.getMessage());
- if (stat.getCode() == IManagedBuilderMakefileGenerator.SPACES_IN_PATH) {
- epm.generateMarker(location, -1, ManagedMakeMessages.getResourceString("MakefileGenerator.error.spaces"), IMarkerGenerator.SEVERITY_WARNING, null); //$NON-NLS-1$
- }
- }
- }
-
- /* (non-javadoc)
- * Emits a message to the console indicating that there were no source files to build
- * @param buildType
- * @param status
- * @param configName
- */
- private void emitNoSourceMessage(int buildType, IStatus status, String configName) throws CoreException {
- try {
- StringBuffer buf = new StringBuffer();
- IConsole console = CCorePlugin.getDefault().getConsole();
- console.start(getProject());
- ConsoleOutputStream consoleOutStream = console.getOutputStream();
- // Report a successful clean
- String[] consoleHeader = new String[3];
- if (buildType == FULL_BUILD || buildType == INCREMENTAL_BUILD) {
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
- } else {
- consoleHeader[0] = new String();
- outputError(getProject().getName(), "The given build type is not supported in this context"); //$NON-NLS-1$
- }
- consoleHeader[1] = configName;
- consoleHeader[2] = getProject().getName();
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(status.getMessage());
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- consoleOutStream.close();
- } catch (CoreException e) {
- // Throw the exception back to the builder
- throw e;
- } catch (IOException io) { // Ignore console failures...
- }
- }
-
- /**
- *
- * This method has been created so that subclasses can override how the builder obtains its
- * build info. The default implementation retrieves the info from the build manager.
- *
- * @return An IManagedBuildInfo object representing the build info.
- */
- protected IManagedBuildInfo getBuildInfo() {
- return ManagedBuildManager.getBuildInfo(getProject());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
- // We should always tell the build system what projects we reference
- referencedProjects = getProject().getReferencedProjects();
-
- // Get the build information
- IManagedBuildInfo info = getBuildInfo();
- if (info == null) {
- outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
- return referencedProjects;
- }
- if (!info.isValid()) {
- outputError(getProject().getName(), "Build information is not valid"); //$NON-NLS-1$
- return referencedProjects;
- }
-
- // Create a makefile generator for the build
- IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
- generator.initialize(getProject(), info, monitor);
-
- // So let's figure out why we got called
- if (kind == FULL_BUILD || info.needsRebuild()) {
- outputTrace(getProject().getName(), "Full build needed/requested"); //$NON-NLS-1$
- fullBuild(info, generator, monitor);
- }
- else if (kind == AUTO_BUILD && info.needsRebuild()) {
- outputTrace(getProject().getName(), "Autobuild requested, full build needed"); //$NON-NLS-1$
- fullBuild(info, generator, monitor);
- }
- else {
- // Create a delta visitor to make sure we should be rebuilding
- ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(info);
- IResourceDelta delta = getDelta(getProject());
- if (delta == null) {
- outputTrace(getProject().getName(), "Incremental build requested, full build needed"); //$NON-NLS-1$
- fullBuild(info, generator, monitor);
- }
- else {
- delta.accept(visitor);
- if (visitor.shouldBuildFull()) {
- outputTrace(getProject().getName(), "Incremental build requested, full build needed"); //$NON-NLS-1$
- fullBuild(info, generator, monitor);
- } else if (visitor.shouldBuildIncr()) {
- outputTrace(getProject().getName(), "Incremental build requested"); //$NON-NLS-1$
- incrementalBuild(delta, info, generator, monitor);
- }
- else if (referencedProjects != null) {
- // Also check to see is any of the dependent projects changed
- for (int i=0; i<referencedProjects.length; i++) {
- IProject ref = referencedProjects[i];
- IResourceDelta refDelta = getDelta(ref);
- if (refDelta == null) {
- outputTrace(getProject().getName(), "Incremental build because of changed referenced project"); //$NON-NLS-1$
- incrementalBuild(delta, info, generator, monitor);
- // Should only build this project once, for this delta
- break;
- } else {
- int refKind = refDelta.getKind();
- if (refKind != IResourceDelta.NO_CHANGE) {
- int refFlags = refDelta.getFlags();
- if (!(refKind == IResourceDelta.CHANGED &&
- refFlags == IResourceDelta.OPEN)) {
- outputTrace(getProject().getName(), "Incremental build because of changed referenced project"); //$NON-NLS-1$
- incrementalBuild(delta, info, generator, monitor);
- // Should only build this project once, for this delta
- break;
- }
- }
- }
- }
- }
- }
- }
- // Scrub the build info the project
- info.setRebuildState(false);
- // Ask build mechanism to compute deltas for project dependencies next time
- return referencedProjects;
- }
-
- /**
- * Check whether the build has been canceled. Cancellation requests
- * propagated to the caller by throwing <code>OperationCanceledException</code>.
- *
- * @see org.eclipse.core.runtime.OperationCanceledException#OperationCanceledException()
- */
- public void checkCancel(IProgressMonitor monitor) {
- if (monitor != null && monitor.isCanceled()) {
- outputTrace(getProject().getName(), "Build cancelled"); //$NON-NLS-1$
- forgetLastBuiltState();
- throw new OperationCanceledException();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IncrementalProjectBuilder#clean(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void clean(IProgressMonitor monitor) throws CoreException {
- referencedProjects = getProject().getReferencedProjects();
- outputTrace(getProject().getName(), "Clean build requested"); //$NON-NLS-1$
- IManagedBuildInfo info = getBuildInfo();
- if (info == null) {
- outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
- return;
- }
- if (!info.isValid()) {
- outputError(getProject().getName(), "Build information is not valid"); //$NON-NLS-1$
- return;
- }
- IPath buildDirPath = getProject().getLocation().append(info.getConfigurationName());
- IWorkspace workspace = CCorePlugin.getWorkspace();
- IContainer buildDir = workspace.getRoot().getContainerForLocation(buildDirPath);
- if (buildDir == null || !buildDir.isAccessible()){
- outputError(buildDir.getName(), "Could not delete the build directory"); //$NON-NLS-1$
- return;
- }
- String status;
- try {
- // try the brute force approach first
- status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
- monitor.subTask(status);
- workspace.delete(new IResource[]{buildDir}, true, monitor);
- StringBuffer buf = new StringBuffer();
- // write to the console
- IConsole console = CCorePlugin.getDefault().getConsole();
- console.start(getProject());
- ConsoleOutputStream consoleOutStream = console.getOutputStream();
- String[] consoleHeader = new String[3];
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
- consoleHeader[1] = info.getConfigurationName();
- consoleHeader[2] = getProject().getName();
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- buf = new StringBuffer();
- // Report a successful clean
- String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName());
- buf.append(successMsg);
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- consoleOutStream.close();
- } catch (CoreException e) {
- // Create a makefile generator for the build
- status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.build.clean", buildDir.getName()); //$NON-NLS-1$
- monitor.subTask(status);
- IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
- generator.initialize(getProject(), info, monitor);
- cleanBuild(info, generator, monitor);
- } catch (IOException io) {} // Ignore console failures...
- }
-
- /* (non-Javadoc)
- * @param info
- * @param generator
- * @param monitor
- */
- protected void cleanBuild(IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) {
- // Make sure that there is a top level directory and a set of makefiles
- IPath buildDir = generator.getBuildWorkingDir();
- if (buildDir == null) {
- buildDir = new Path(info.getConfigurationName());
- }
- IPath makefilePath = getProject().getLocation().append(buildDir.append(generator.getMakefileName()));
- IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
- IFile makefile = root.getFileForLocation(makefilePath);
-
- if (buildDir != null && makefile != null && makefile.isAccessible()) {
- // invoke make with the clean argument
- String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- checkCancel(monitor);
- invokeMake(CLEAN_BUILD, buildDir, info, generator, monitor);
- }
- }
-
- /* (non-Javadoc)
- * @param info
- * @param generator
- * @param monitor
- */
- protected void fullBuild(IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) throws CoreException {
- // Always need one of these bad boys
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- checkCancel(monitor);
- //If the previous builder invocation was cancelled, generated files might be corrupted
- //in case one or more of the generated makefiles (e.g. dep files) are corrupted,
- //the builder invocation might fail because of the possible syntax errors, so e.g. "make clean" will not work
- //we need to explicitly clean the generated directories
- clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
-
- // Regenerate the makefiles for this project
- checkCancel(monitor);
- String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.rebuild.makefiles", getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- //generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
- generator.initialize(getProject(), info, monitor);
- MultiStatus result = generator.regenerateMakefiles();
- if (result.getCode() == IStatus.WARNING || result.getCode() == IStatus.INFO) {
- IStatus[] kids = result.getChildren();
- for (int index = 0; index < kids.length; ++index) {
- // One possibility is that there is nothing to build
- IStatus status = kids[index];
- if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) {
- // Inform the user, via the console, that there is nothing to build
- // either because there are no buildable sources files or all potentially
- // buildable files have been excluded from build
- try {
- emitNoSourceMessage(FULL_BUILD, status, info.getConfigurationName());
- } catch (CoreException e) {
- // Throw the exception back to the builder
- throw e;
- }
- // Dude, we're done
- return;
- } else {
- // Stick this in the list of stuff to warn the user about
- getGenerationProblems().add(status);
- }
- }
- }
-
- // Now call make
- checkCancel(monitor);
- statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- IPath topBuildDir = generator.getBuildWorkingDir();
- if (topBuildDir != null) {
- invokeMake(FULL_BUILD, topBuildDir, info, generator, monitor);
- } else {
- statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- return;
- }
-
- // Now regenerate the dependencies
- checkCancel(monitor);
- statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.regen.deps", getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- try {
- generator.regenerateDependencies(false);
- } catch (CoreException e) {
- // Throw the exception back to the builder
- throw e;
- }
-
- // Build finished message
- statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- }
-
- /* (non-Javadoc)
- *
- * @return
- */
- private Vector getGenerationProblems() {
- if (generationProblems == null) {
- generationProblems = new Vector();
- }
- return generationProblems;
- }
-
- /* (non-javadoc)
- * Answers an array of strings with the proper make targets
- * for a build with no custom prebuild/postbuild steps
- *
- * @param fullBuild
- * @return
- */
- protected String[] getMakeTargets(int buildType) {
- List args = new ArrayList();
- switch (buildType) {
- case CLEAN_BUILD:
- args.add("clean"); //$NON-NLS-1$
- break;
- case FULL_BUILD:
- case INCREMENTAL_BUILD:
- args.add("all"); //$NON-NLS-1$
- break;
- }
- return (String[])args.toArray(new String[args.size()]);
- }
-
- /**
- * @return
- */
- protected List getResourcesToBuild() {
- if (resourcesToBuild == null) {
- resourcesToBuild = new ArrayList();
- }
- return resourcesToBuild;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.resources.ACBuilder#getWorkingDirectory()
- */
- public IPath getWorkingDirectory() {
- return getProject().getLocation();
- }
-
- /* (non-Javadoc)
- * @param delta
- * @param info
- * @param monitor
- * @throws CoreException
- */
- protected void incrementalBuild(IResourceDelta delta, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) throws CoreException {
- // Need to report status to the user
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- // Ask the makefile generator to generate any makefiles needed to build delta
- checkCancel(monitor);
- String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.update.makefiles", getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- MultiStatus result = generator.generateMakefiles(delta);
- if (result.getCode() == IStatus.WARNING || result.getCode() == IStatus.INFO) {
- IStatus[] kids = result.getChildren();
- for (int index = 0; index < kids.length; ++index) {
- // One possibility is that there is nothing to build
- IStatus status = kids[index];
- if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) {
- // Inform the user, via the console, that there is nothing to build
- // either because there are no buildable sources files or all potentially
- // buildable files have been excluded from build
- try {
- emitNoSourceMessage(INCREMENTAL_BUILD, status, info.getConfigurationName());
- } catch (CoreException e) {
- // Throw the exception back to the builder
- throw e;
- }
- // Dude, we're done
- return;
- } else {
- // Stick this in the list of stuff to warn the user about
- getGenerationProblems().add(status);
- }
- }
- }
-
- // Run the build
- checkCancel(monitor);
- statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- IPath buildDir = generator.getBuildWorkingDir();
- if (buildDir != null) {
- invokeMake(INCREMENTAL_BUILD, buildDir, info, generator, monitor);
- } else {
- statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- return;
- }
-
- // Generate the dependencies for all changes
- checkCancel(monitor);
- statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.updating.deps", getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
- try {
- generator.generateDependencies();
- } catch (CoreException e) {
- throw e;
- }
-
- // Build finished message
- statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); //$NON-NLS-1$
- monitor.subTask(statusMsg);
-}
-
- /* (non-Javadoc)
- * @param buildType
- * @param buildDir
- * @param info
- * @param generator
- * @param monitor
- */
- protected void invokeMake(int buildType, IPath buildDir, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) {
- // Get the project and make sure there's a monitor to cancel the build
- IProject currentProject = getProject();
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- try {
- // Figure out the working directory for the build and make sure there is a makefile there
- IPath workingDirectory = getWorkingDirectory().append(buildDir);
- IWorkspace workspace = currentProject.getWorkspace();
- if (workspace == null) {
- return;
- }
- IWorkspaceRoot root = workspace.getRoot();
- if (root == null) {
- return;
- }
- IPath makefile = workingDirectory.append(generator.getMakefileName());
- if (root.getFileForLocation(makefile) == null) {
- return;
- }
-
- // Flag to the user that make is about to be called
- String makeCmd = info.getBuildCommand();
- //try to resolve the build macros in the builder command
- try{
- String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
- makeCmd,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
- if((resolved = resolved.trim()).length() > 0)
- makeCmd = resolved;
- } catch (BuildMacroException e){
- }
-
- IPath makeCommand = new Path(makeCmd);
- if (makeCommand != null) {
- String[] msgs = new String[2];
- msgs[0] = makeCommand.toString();
- msgs[1] = currentProject.getName();
- monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs));
-
- // Get a build console for the project
- StringBuffer buf = new StringBuffer();
- IConsole console = CCorePlugin.getDefault().getConsole();
- console.start(currentProject);
- ConsoleOutputStream consoleOutStream = console.getOutputStream();
- String[] consoleHeader = new String[3];
- switch (buildType) {
- case FULL_BUILD:
- case INCREMENTAL_BUILD:
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
- break;
- case CLEAN_BUILD:
- consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
- break;
- }
-
- consoleHeader[1] = info.getConfigurationName();
- consoleHeader[2] = currentProject.getName();
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
-
- IConfiguration cfg = info.getDefaultConfiguration();
- if(!cfg.isSupported()){
- buf.append(ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}));
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
-
- // Remove all markers for this project
- removeAllMarkers(currentProject);
-
- // Get a launcher for the make command
- String errMsg = null;
- CommandLauncher launcher = new CommandLauncher();
- launcher.showCommand(true);
-
- // Set the environmennt
- IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true);
- String[] env = null;
- ArrayList envList = new ArrayList();
- if (variables != null) {
- for(int i = 0; i < variables.length; i++){
- envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
- }
- env = (String[]) envList.toArray(new String[envList.size()]);
- }
-
- // Hook up an error parser manager
- String[] errorParsers = info.getDefaultConfiguration().getErrorParserList();
- ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectory, this, errorParsers);
- epm.setOutputStream(consoleOutStream);
- // This variable is necessary to ensure that the EPM stream stay open
- // until we explicitly close it. See bug#123302.
- OutputStream epmOutputStream = epm.getOutputStream();
-
- // Get the arguments to be passed to make from build model
- ArrayList makeArgs = new ArrayList();
- String arg = info.getBuildArguments();
- if (arg.length() > 0) {
- String[] args = arg.split("\\s"); //$NON-NLS-1$
- for (int i = 0; i < args.length; ++i) {
- makeArgs.add(args[i]);
- }
- }
-
- String[] makeTargets;
- String prebuildStep = info.getPrebuildStep();
- //try to resolve the build macros in the prebuildStep
- try{
- prebuildStep = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
- prebuildStep,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- cfg);
- } catch (BuildMacroException e){
- }
- boolean prebuildStepPresent = (prebuildStep.length() > 0);
- Process proc = null;
- boolean isuptodate = false;
-
- if (prebuildStepPresent) {
- ArrayList premakeArgs = (ArrayList) makeArgs.clone();
- String[] premakeTargets;
- switch (buildType) {
- case INCREMENTAL_BUILD: {
- // For an incremental build with a prebuild step:
- // Check the status of the main build with "make -q main-build"
- // If up to date:
- // then: don't invoke the prebuild step, which should be run only if
- // something needs to be built in the main build
- // else: invoke the prebuild step and the main build step
- premakeArgs.add("-q"); //$NON-NLS-1$
- premakeArgs.add("main-build"); //$NON-NLS-1$
- premakeTargets = (String[]) premakeArgs.toArray(new String[premakeArgs.size()]);
- proc = launcher.execute(makeCommand, premakeTargets, env, workingDirectory);
- if (proc != null) {
- try {
- // Close the input of the process since we will never write to it
- proc.getOutputStream().close();
- } catch (IOException e) {
- }
- if (launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(),
- new SubProgressMonitor(monitor,
- IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
- errMsg = launcher.getErrorMessage();
- }
- } else {
- errMsg = launcher.getErrorMessage();
- }
-
- if ((errMsg != null && errMsg.length() > 0) || proc == null) {
- // Can't tell if the build is needed, so assume it is, and let any errors be triggered
- // when the "real" build is invoked below
- makeArgs.add("pre-build"); //$NON-NLS-1$
- makeArgs.add("main-build"); //$NON-NLS-1$
- } else {
- // The "make -q" command launch was successful
- if (proc.exitValue() == 0) {
- // If the status value returned from "make -q" is 0, then the build state is up-to-date
- isuptodate = true;
- // Report that the build was up to date, and thus nothing needs to be built
- String uptodateMsg = ManagedMakeMessages
- .getFormattedString(NOTHING_BUILT, currentProject.getName());
- buf = new StringBuffer();
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- buf.append(uptodateMsg);
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- // Write message on the console
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- epmOutputStream.close();
- consoleOutStream.close();
- } else {
- // The status value was other than 0, so press on with the build process
- makeArgs.add("pre-build"); //$NON-NLS-1$
- makeArgs.add("main-build"); //$NON-NLS-1$
- }
- }
- break;
- }
- case FULL_BUILD: {
- makeArgs.add("clean"); //$NON-NLS-1$
- makeArgs.add("pre-build"); //$NON-NLS-1$
- makeArgs.add("main-build"); //$NON-NLS-1$
- break;
- }
- case CLEAN_BUILD: {
- makeArgs.add("clean"); //$NON-NLS-1$
- break;
- }
- }
-
- } else {
- // No prebuild step
- //
- makeArgs.addAll(Arrays.asList(getMakeTargets(buildType)));
- }
-
- makeTargets = (String[]) makeArgs.toArray(new String[makeArgs.size()]);
-
- // Launch make - main invocation
- if (!isuptodate) {
- proc = launcher.execute(makeCommand, makeTargets, env,
- workingDirectory);
- if (proc != null) {
- try {
- // Close the input of the process since we will never write to it
- proc.getOutputStream().close();
- } catch (IOException e) {
- }
-
- if (launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(),
- new SubProgressMonitor(monitor,
- IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
- errMsg = launcher.getErrorMessage();
- }
-
- // Force a resync of the projects without allowing the user to cancel.
- // This is probably unkind, but short of this there is no way to insure
- // the UI is up-to-date with the build results
- monitor.subTask(ManagedMakeMessages
- .getResourceString(REFRESH));
- try {
- currentProject.refreshLocal(
- IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- monitor.subTask(ManagedMakeMessages
- .getResourceString(REFRESH_ERROR));
- }
- } else {
- errMsg = launcher.getErrorMessage();
- }
-
- // Report either the success or failure of our mission
- buf = new StringBuffer();
- if (errMsg != null && errMsg.length() > 0) {
- String errorDesc = ManagedMakeMessages
- .getResourceString(BUILD_ERROR);
- buf.append(errorDesc);
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- // Report a successful build
- String successMsg = ManagedMakeMessages
- .getFormattedString(BUILD_FINISHED,
- currentProject.getName());
- buf.append(successMsg);
- buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
- }
-
- // Write message on the console
- consoleOutStream.write(buf.toString().getBytes());
- consoleOutStream.flush();
- epmOutputStream.close();
-
- // Generate any error markers that the build has discovered
- monitor.subTask(ManagedMakeMessages
- .getResourceString(MARKERS));
- addBuilderMarkers(epm);
- epm.reportProblems();
- consoleOutStream.close();
- }
- }
- } catch (Exception e) {
- forgetLastBuiltState();
- } finally {
- getGenerationProblems().clear();
- }
- }
-
- /* (non-Javadoc)
- * Removes the IMarkers for the project specified in the argument if the
- * project exists, and is open.
- *
- * @param project
- */
- private void removeAllMarkers(IProject project) {
- if (project == null || !project.isAccessible()) return;
-
- // Clear out the problem markers
- IWorkspace workspace = project.getWorkspace();
- IMarker[] markers;
- try {
- markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- // Handled just about every case in the sanity check
- return;
- }
- if (markers != null) {
- try {
- workspace.deleteMarkers(markers);
- } catch (CoreException e) {
- // The only situation that might cause this is some sort of resource change event
- return;
- }
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2002, 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 Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CommandLauncher;
+import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.IMarkerGenerator;
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.resources.ACBuilder;
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
+import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+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.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+/**
+ * This is the incremental builder associated with a managed build project. It dynamically
+ * decides the makefile generator it wants to use for a specific target.
+ *
+ * @since 1.2
+ */
+public class GeneratedMakefileBuilder extends ACBuilder {
+
+ /**
+ * @since 1.2
+ */
+ public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
+ private String buildGoalName;
+ private IManagedBuildInfo buildInfo;
+ private boolean incrBuildNeeded = false;
+ private boolean fullBuildNeeded = false;
+ private List reservedNames;
+
+ /**
+ *
+ */
+ public ResourceDeltaVisitor(IManagedBuildInfo info) {
+ buildInfo = info;
+ String ext = buildInfo.getBuildArtifactExtension();
+ //try to resolve build macros in the build artifact extension
+ try{
+ ext = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ ext,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ info.getDefaultConfiguration());
+ } catch (BuildMacroException e){
+ }
+
+ String name = buildInfo.getBuildArtifactName();
+ //try to resolve build macros in the build artifact name
+ try{
+ String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ name,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ info.getDefaultConfiguration());
+ if((resolved = resolved.trim()).length() > 0)
+ name = resolved;
+ } catch (BuildMacroException e){
+ }
+
+ if (ext.length() > 0) {
+ buildGoalName = buildInfo.getOutputPrefix(ext) + name + IManagedBuilderMakefileGenerator.DOT + ext;
+ } else {
+ buildGoalName = name;
+ }
+ reservedNames = Arrays.asList(new String[]{".cdtbuild", ".cdtproject", ".project"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ * @param changedResource
+ * @return
+ */
+ private boolean isGeneratedResource(IResource resource) {
+ // Is this a generated directory ...
+ IPath path = resource.getProjectRelativePath();
+ String[] configNames = buildInfo.getConfigurationNames();
+ for (int i = 0; i < configNames.length; i++) {
+ String name = configNames[i];
+ IPath root = new Path(name);
+ // It is if it is a root of the resource pathname
+ if (root.isPrefixOf(path)) return true;
+ }
+ return false;
+ }
+
+ /**
+ * @param resource
+ * @return
+ */
+ private boolean isProjectFile(IResource resource) {
+ return reservedNames.contains(resource.getName());
+ }
+
+ public boolean shouldBuildIncr() {
+ return incrBuildNeeded;
+ }
+
+ public boolean shouldBuildFull() {
+ return fullBuildNeeded;
+ }
+
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ IResource resource = delta.getResource();
+ // If the project has changed, then a build is needed and we can stop
+ if (resource != null && resource.getProject() == getProject()) {
+ IResourceDelta[] kids = delta.getAffectedChildren();
+ for (int index = kids.length - 1; index >= 0; --index) {
+ IResource changedResource = kids[index].getResource();
+ if (changedResource instanceof IFolder) {
+ return true;
+ } else {
+ String name = changedResource.getName();
+ if ((!name.equals(buildGoalName) &&
+ // TODO: Also need to check for secondary outputs
+ (changedResource.isDerived() ||
+ (isProjectFile(changedResource)) ||
+ (isGeneratedResource(changedResource))))) {
+ // The resource that changed has attributes which make it uninteresting,
+ // so don't do anything
+ ;
+ }
+ else {
+ // TODO: Should we do extra checks here to determine if a build is really needed,
+ // or do you just do exclusion checks like above?
+ // We could check for:
+ // o The build goal name
+ // o A secondary output
+ // o An input file to a tool:
+ // o Has an extension of a source file used by a tool
+ // o Has an extension of a header file used by a tool
+ // o Has the name of an input file specified in an InputType via:
+ // o An Option
+ // o An AdditionalInput
+ //
+ //if (resourceName.equals(buildGoalName) ||
+ // (buildInfo.buildsFileType(ext) || buildInfo.isHeaderFile(ext))) {
+
+ // We need to do an incremental build, at least
+ incrBuildNeeded = true;
+ if (kids[index].getKind() == IResourceDelta.REMOVED) {
+ // If a meaningful resource was removed, then force a full build
+ // This is required because an incremental build will trigger make to
+ // do nothing for a missing source, since the state after the file
+ // removal is uptodate, as far as make is concerned
+ // A full build will clean, and ultimately trigger a relink without
+ // the object generated from the deleted source, which is what we want
+ fullBuildNeeded = true;
+ // There is no point in checking anything else since we have
+ // decided to do a full build anyway
+ break;
+ }
+
+ //}
+ }
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+ }
+
+ // String constants
+ private static final String BUILD_ERROR = "ManagedMakeBuilder.message.error"; //$NON-NLS-1$
+ private static final String BUILD_FINISHED = "ManagedMakeBuilder.message.finished"; //$NON-NLS-1$
+ private static final String CONSOLE_HEADER = "ManagedMakeBuilder.message.console.header"; //$NON-NLS-1$
+ private static final String ERROR_HEADER = "GeneratedmakefileBuilder error ["; //$NON-NLS-1$
+ private static final String MAKE = "ManagedMakeBuilder.message.make"; //$NON-NLS-1$
+ private static final String MARKERS = "ManagedMakeBuilder.message.creating.markers"; //$NON-NLS-1$
+ private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
+ private static final String NOTHING_BUILT = "ManagedMakeBuilder.message.no.build"; //$NON-NLS-1$
+ private static final String REFRESH = "ManagedMakeBuilder.message.updating"; //$NON-NLS-1$
+ private static final String REFRESH_ERROR = BUILD_ERROR + ".refresh"; //$NON-NLS-1$
+ private static final String TRACE_FOOTER = "]: "; //$NON-NLS-1$
+ private static final String TRACE_HEADER = "GeneratedmakefileBuilder trace ["; //$NON-NLS-1$
+ private static final String TYPE_CLEAN = "ManagedMakeBuilder.type.clean"; //$NON-NLS-1$
+ private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
+ private static final String WARNING_UNSUPPORTED_CONFIGURATION = "ManagedMakeBuilder.warning.unsupported.configuration"; //$NON-NLS-1$
+ public static boolean VERBOSE = false;
+
+ // Local variables
+ protected Vector generationProblems;
+ protected IProject[] referencedProjects;
+ protected List resourcesToBuild;
+ public static void outputTrace(String resourceName, String message) {
+ if (VERBOSE) {
+ System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
+ }
+ }
+
+ public static void outputError(String resourceName, String message) {
+ if (VERBOSE) {
+ System.err.println(ERROR_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
+ }
+ }
+
+ /**
+ * Zero-argument constructor needed to fulfill the contract of an
+ * incremental builder.
+ */
+ public GeneratedMakefileBuilder() {
+ }
+
+ /**
+ * @param epm
+ */
+ private void addBuilderMarkers(ErrorParserManager epm) {
+ IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
+ Iterator iter = getGenerationProblems().iterator();
+ while (iter.hasNext()) {
+ IStatus stat = (IStatus)iter.next();
+ IResource location = root.findMember(stat.getMessage());
+ if (stat.getCode() == IManagedBuilderMakefileGenerator.SPACES_IN_PATH) {
+ epm.generateMarker(location, -1, ManagedMakeMessages.getResourceString("MakefileGenerator.error.spaces"), IMarkerGenerator.SEVERITY_WARNING, null); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /* (non-javadoc)
+ * Emits a message to the console indicating that there were no source files to build
+ * @param buildType
+ * @param status
+ * @param configName
+ */
+ private void emitNoSourceMessage(int buildType, IStatus status, String configName) throws CoreException {
+ try {
+ StringBuffer buf = new StringBuffer();
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ console.start(getProject());
+ ConsoleOutputStream consoleOutStream = console.getOutputStream();
+ // Report a successful clean
+ String[] consoleHeader = new String[3];
+ if (buildType == FULL_BUILD || buildType == INCREMENTAL_BUILD) {
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
+ } else {
+ consoleHeader[0] = new String();
+ outputError(getProject().getName(), "The given build type is not supported in this context"); //$NON-NLS-1$
+ }
+ consoleHeader[1] = configName;
+ consoleHeader[2] = getProject().getName();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(status.getMessage());
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ consoleOutStream.close();
+ } catch (CoreException e) {
+ // Throw the exception back to the builder
+ throw e;
+ } catch (IOException io) { // Ignore console failures...
+ }
+ }
+
+ /**
+ *
+ * This method has been created so that subclasses can override how the builder obtains its
+ * build info. The default implementation retrieves the info from the build manager.
+ *
+ * @return An IManagedBuildInfo object representing the build info.
+ */
+ protected IManagedBuildInfo getBuildInfo() {
+ return ManagedBuildManager.getBuildInfo(getProject());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
+ // We should always tell the build system what projects we reference
+ referencedProjects = getProject().getReferencedProjects();
+
+ // Get the build information
+ IManagedBuildInfo info = getBuildInfo();
+ if (info == null) {
+ outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
+ return referencedProjects;
+ }
+ if (!info.isValid()) {
+ outputError(getProject().getName(), "Build information is not valid"); //$NON-NLS-1$
+ return referencedProjects;
+ }
+
+ // Create a makefile generator for the build
+ IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
+ generator.initialize(getProject(), info, monitor);
+
+ // So let's figure out why we got called
+ if (kind == FULL_BUILD || info.needsRebuild()) {
+ outputTrace(getProject().getName(), "Full build needed/requested"); //$NON-NLS-1$
+ fullBuild(info, generator, monitor);
+ }
+ else if (kind == AUTO_BUILD && info.needsRebuild()) {
+ outputTrace(getProject().getName(), "Autobuild requested, full build needed"); //$NON-NLS-1$
+ fullBuild(info, generator, monitor);
+ }
+ else {
+ // Create a delta visitor to make sure we should be rebuilding
+ ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(info);
+ IResourceDelta delta = getDelta(getProject());
+ if (delta == null) {
+ outputTrace(getProject().getName(), "Incremental build requested, full build needed"); //$NON-NLS-1$
+ fullBuild(info, generator, monitor);
+ }
+ else {
+ delta.accept(visitor);
+ if (visitor.shouldBuildFull()) {
+ outputTrace(getProject().getName(), "Incremental build requested, full build needed"); //$NON-NLS-1$
+ fullBuild(info, generator, monitor);
+ } else if (visitor.shouldBuildIncr()) {
+ outputTrace(getProject().getName(), "Incremental build requested"); //$NON-NLS-1$
+ incrementalBuild(delta, info, generator, monitor);
+ }
+ else if (referencedProjects != null) {
+ // Also check to see is any of the dependent projects changed
+ for (int i=0; i<referencedProjects.length; i++) {
+ IProject ref = referencedProjects[i];
+ IResourceDelta refDelta = getDelta(ref);
+ if (refDelta == null) {
+ outputTrace(getProject().getName(), "Incremental build because of changed referenced project"); //$NON-NLS-1$
+ incrementalBuild(delta, info, generator, monitor);
+ // Should only build this project once, for this delta
+ break;
+ } else {
+ int refKind = refDelta.getKind();
+ if (refKind != IResourceDelta.NO_CHANGE) {
+ int refFlags = refDelta.getFlags();
+ if (!(refKind == IResourceDelta.CHANGED &&
+ refFlags == IResourceDelta.OPEN)) {
+ outputTrace(getProject().getName(), "Incremental build because of changed referenced project"); //$NON-NLS-1$
+ incrementalBuild(delta, info, generator, monitor);
+ // Should only build this project once, for this delta
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ // Scrub the build info the project
+ info.setRebuildState(false);
+ // Ask build mechanism to compute deltas for project dependencies next time
+ return referencedProjects;
+ }
+
+ /**
+ * Check whether the build has been canceled. Cancellation requests
+ * propagated to the caller by throwing <code>OperationCanceledException</code>.
+ *
+ * @see org.eclipse.core.runtime.OperationCanceledException#OperationCanceledException()
+ */
+ public void checkCancel(IProgressMonitor monitor) {
+ if (monitor != null && monitor.isCanceled()) {
+ outputTrace(getProject().getName(), "Build cancelled"); //$NON-NLS-1$
+ forgetLastBuiltState();
+ throw new OperationCanceledException();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IncrementalProjectBuilder#clean(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void clean(IProgressMonitor monitor) throws CoreException {
+ referencedProjects = getProject().getReferencedProjects();
+ outputTrace(getProject().getName(), "Clean build requested"); //$NON-NLS-1$
+ IManagedBuildInfo info = getBuildInfo();
+ if (info == null) {
+ outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
+ return;
+ }
+ if (!info.isValid()) {
+ outputError(getProject().getName(), "Build information is not valid"); //$NON-NLS-1$
+ return;
+ }
+ IPath buildDirPath = getProject().getLocation().append(info.getConfigurationName());
+ IWorkspace workspace = CCorePlugin.getWorkspace();
+ IContainer buildDir = workspace.getRoot().getContainerForLocation(buildDirPath);
+ if (buildDir == null || !buildDir.isAccessible()){
+ outputError(buildDir.getName(), "Could not delete the build directory"); //$NON-NLS-1$
+ return;
+ }
+ String status;
+ try {
+ // try the brute force approach first
+ status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
+ monitor.subTask(status);
+ workspace.delete(new IResource[]{buildDir}, true, monitor);
+ StringBuffer buf = new StringBuffer();
+ // write to the console
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ console.start(getProject());
+ ConsoleOutputStream consoleOutStream = console.getOutputStream();
+ String[] consoleHeader = new String[3];
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
+ consoleHeader[1] = info.getConfigurationName();
+ consoleHeader[2] = getProject().getName();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ buf = new StringBuffer();
+ // Report a successful clean
+ String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName());
+ buf.append(successMsg);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ consoleOutStream.close();
+ } catch (CoreException e) {
+ // Create a makefile generator for the build
+ status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.build.clean", buildDir.getName()); //$NON-NLS-1$
+ monitor.subTask(status);
+ IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
+ generator.initialize(getProject(), info, monitor);
+ cleanBuild(info, generator, monitor);
+ } catch (IOException io) {} // Ignore console failures...
+ }
+
+ /* (non-Javadoc)
+ * @param info
+ * @param generator
+ * @param monitor
+ */
+ protected void cleanBuild(IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) {
+ // Make sure that there is a top level directory and a set of makefiles
+ IPath buildDir = generator.getBuildWorkingDir();
+ if (buildDir == null) {
+ buildDir = new Path(info.getConfigurationName());
+ }
+ IPath makefilePath = getProject().getLocation().append(buildDir.append(generator.getMakefileName()));
+ IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
+ IFile makefile = root.getFileForLocation(makefilePath);
+
+ if (buildDir != null && makefile != null && makefile.isAccessible()) {
+ // invoke make with the clean argument
+ String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ checkCancel(monitor);
+ invokeMake(CLEAN_BUILD, buildDir, info, generator, monitor);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @param info
+ * @param generator
+ * @param monitor
+ */
+ protected void fullBuild(IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) throws CoreException {
+ // Always need one of these bad boys
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ checkCancel(monitor);
+ //If the previous builder invocation was cancelled, generated files might be corrupted
+ //in case one or more of the generated makefiles (e.g. dep files) are corrupted,
+ //the builder invocation might fail because of the possible syntax errors, so e.g. "make clean" will not work
+ //we need to explicitly clean the generated directories
+ clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
+
+ // Regenerate the makefiles for this project
+ checkCancel(monitor);
+ String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.rebuild.makefiles", getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ //generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
+ generator.initialize(getProject(), info, monitor);
+ MultiStatus result = generator.regenerateMakefiles();
+ if (result.getCode() == IStatus.WARNING || result.getCode() == IStatus.INFO) {
+ IStatus[] kids = result.getChildren();
+ for (int index = 0; index < kids.length; ++index) {
+ // One possibility is that there is nothing to build
+ IStatus status = kids[index];
+ if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) {
+ // Inform the user, via the console, that there is nothing to build
+ // either because there are no buildable sources files or all potentially
+ // buildable files have been excluded from build
+ try {
+ emitNoSourceMessage(FULL_BUILD, status, info.getConfigurationName());
+ } catch (CoreException e) {
+ // Throw the exception back to the builder
+ throw e;
+ }
+ // Dude, we're done
+ return;
+ } else {
+ // Stick this in the list of stuff to warn the user about
+ getGenerationProblems().add(status);
+ }
+ }
+ }
+
+ // Now call make
+ checkCancel(monitor);
+ statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ IPath topBuildDir = generator.getBuildWorkingDir();
+ if (topBuildDir != null) {
+ invokeMake(FULL_BUILD, topBuildDir, info, generator, monitor);
+ } else {
+ statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ return;
+ }
+
+ // Now regenerate the dependencies
+ checkCancel(monitor);
+ statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.regen.deps", getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ try {
+ generator.regenerateDependencies(false);
+ } catch (CoreException e) {
+ // Throw the exception back to the builder
+ throw e;
+ }
+
+ // Build finished message
+ statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ }
+
+ /* (non-Javadoc)
+ *
+ * @return
+ */
+ private Vector getGenerationProblems() {
+ if (generationProblems == null) {
+ generationProblems = new Vector();
+ }
+ return generationProblems;
+ }
+
+ /* (non-javadoc)
+ * Answers an array of strings with the proper make targets
+ * for a build with no custom prebuild/postbuild steps
+ *
+ * @param fullBuild
+ * @return
+ */
+ protected String[] getMakeTargets(int buildType) {
+ List args = new ArrayList();
+ switch (buildType) {
+ case CLEAN_BUILD:
+ args.add("clean"); //$NON-NLS-1$
+ break;
+ case FULL_BUILD:
+ case INCREMENTAL_BUILD:
+ args.add("all"); //$NON-NLS-1$
+ break;
+ }
+ return (String[])args.toArray(new String[args.size()]);
+ }
+
+ /**
+ * @return
+ */
+ protected List getResourcesToBuild() {
+ if (resourcesToBuild == null) {
+ resourcesToBuild = new ArrayList();
+ }
+ return resourcesToBuild;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.resources.ACBuilder#getWorkingDirectory()
+ */
+ public IPath getWorkingDirectory() {
+ return getProject().getLocation();
+ }
+
+ /* (non-Javadoc)
+ * @param delta
+ * @param info
+ * @param monitor
+ * @throws CoreException
+ */
+ protected void incrementalBuild(IResourceDelta delta, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) throws CoreException {
+ // Need to report status to the user
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ // Ask the makefile generator to generate any makefiles needed to build delta
+ checkCancel(monitor);
+ String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.update.makefiles", getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ MultiStatus result = generator.generateMakefiles(delta);
+ if (result.getCode() == IStatus.WARNING || result.getCode() == IStatus.INFO) {
+ IStatus[] kids = result.getChildren();
+ for (int index = 0; index < kids.length; ++index) {
+ // One possibility is that there is nothing to build
+ IStatus status = kids[index];
+ if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) {
+ // Inform the user, via the console, that there is nothing to build
+ // either because there are no buildable sources files or all potentially
+ // buildable files have been excluded from build
+ try {
+ emitNoSourceMessage(INCREMENTAL_BUILD, status, info.getConfigurationName());
+ } catch (CoreException e) {
+ // Throw the exception back to the builder
+ throw e;
+ }
+ // Dude, we're done
+ return;
+ } else {
+ // Stick this in the list of stuff to warn the user about
+ getGenerationProblems().add(status);
+ }
+ }
+ }
+
+ // Run the build
+ checkCancel(monitor);
+ statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ IPath buildDir = generator.getBuildWorkingDir();
+ if (buildDir != null) {
+ invokeMake(INCREMENTAL_BUILD, buildDir, info, generator, monitor);
+ } else {
+ statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ return;
+ }
+
+ // Generate the dependencies for all changes
+ checkCancel(monitor);
+ statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.updating.deps", getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+ try {
+ generator.generateDependencies();
+ } catch (CoreException e) {
+ throw e;
+ }
+
+ // Build finished message
+ statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); //$NON-NLS-1$
+ monitor.subTask(statusMsg);
+}
+
+ /* (non-Javadoc)
+ * @param buildType
+ * @param buildDir
+ * @param info
+ * @param generator
+ * @param monitor
+ */
+ protected void invokeMake(int buildType, IPath buildDir, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) {
+ // Get the project and make sure there's a monitor to cancel the build
+ IProject currentProject = getProject();
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ try {
+ // Figure out the working directory for the build and make sure there is a makefile there
+ IPath workingDirectory = getWorkingDirectory().append(buildDir);
+ IWorkspace workspace = currentProject.getWorkspace();
+ if (workspace == null) {
+ return;
+ }
+ IWorkspaceRoot root = workspace.getRoot();
+ if (root == null) {
+ return;
+ }
+ IPath makefile = workingDirectory.append(generator.getMakefileName());
+ if (root.getFileForLocation(makefile) == null) {
+ return;
+ }
+
+ // Flag to the user that make is about to be called
+ String makeCmd = info.getBuildCommand();
+ //try to resolve the build macros in the builder command
+ try{
+ String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ makeCmd,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ info.getDefaultConfiguration());
+ if((resolved = resolved.trim()).length() > 0)
+ makeCmd = resolved;
+ } catch (BuildMacroException e){
+ }
+
+ IPath makeCommand = new Path(makeCmd);
+ if (makeCommand != null) {
+ String[] msgs = new String[2];
+ msgs[0] = makeCommand.toString();
+ msgs[1] = currentProject.getName();
+ monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs));
+
+ // Get a build console for the project
+ StringBuffer buf = new StringBuffer();
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ console.start(currentProject);
+ ConsoleOutputStream consoleOutStream = console.getOutputStream();
+ String[] consoleHeader = new String[3];
+ switch (buildType) {
+ case FULL_BUILD:
+ case INCREMENTAL_BUILD:
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
+ break;
+ case CLEAN_BUILD:
+ consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
+ break;
+ }
+
+ consoleHeader[1] = info.getConfigurationName();
+ consoleHeader[2] = currentProject.getName();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ IConfiguration cfg = info.getDefaultConfiguration();
+ if(!cfg.isSupported()){
+ buf.append(ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}));
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+
+ // Remove all markers for this project
+ removeAllMarkers(currentProject);
+
+ // Get a launcher for the make command
+ String errMsg = null;
+ CommandLauncher launcher = new CommandLauncher();
+ launcher.showCommand(true);
+
+ // Set the environmennt
+ IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true);
+ String[] env = null;
+ ArrayList envList = new ArrayList();
+ if (variables != null) {
+ for(int i = 0; i < variables.length; i++){
+ envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
+ }
+ env = (String[]) envList.toArray(new String[envList.size()]);
+ }
+
+ // Hook up an error parser manager
+ String[] errorParsers = info.getDefaultConfiguration().getErrorParserList();
+ ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectory, this, errorParsers);
+ epm.setOutputStream(consoleOutStream);
+ // This variable is necessary to ensure that the EPM stream stay open
+ // until we explicitly close it. See bug#123302.
+ OutputStream epmOutputStream = epm.getOutputStream();
+
+ // Get the arguments to be passed to make from build model
+ ArrayList makeArgs = new ArrayList();
+ String arg = info.getBuildArguments();
+ if (arg.length() > 0) {
+ String[] args = arg.split("\\s"); //$NON-NLS-1$
+ for (int i = 0; i < args.length; ++i) {
+ makeArgs.add(args[i]);
+ }
+ }
+
+ String[] makeTargets;
+ String prebuildStep = info.getPrebuildStep();
+ //try to resolve the build macros in the prebuildStep
+ try{
+ prebuildStep = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ prebuildStep,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ cfg);
+ } catch (BuildMacroException e){
+ }
+ boolean prebuildStepPresent = (prebuildStep.length() > 0);
+ Process proc = null;
+ boolean isuptodate = false;
+
+ if (prebuildStepPresent) {
+ ArrayList premakeArgs = (ArrayList) makeArgs.clone();
+ String[] premakeTargets;
+ switch (buildType) {
+ case INCREMENTAL_BUILD: {
+ // For an incremental build with a prebuild step:
+ // Check the status of the main build with "make -q main-build"
+ // If up to date:
+ // then: don't invoke the prebuild step, which should be run only if
+ // something needs to be built in the main build
+ // else: invoke the prebuild step and the main build step
+ premakeArgs.add("-q"); //$NON-NLS-1$
+ premakeArgs.add("main-build"); //$NON-NLS-1$
+ premakeTargets = (String[]) premakeArgs.toArray(new String[premakeArgs.size()]);
+ proc = launcher.execute(makeCommand, premakeTargets, env, workingDirectory);
+ if (proc != null) {
+ try {
+ // Close the input of the process since we will never write to it
+ proc.getOutputStream().close();
+ } catch (IOException e) {
+ }
+ if (launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(),
+ new SubProgressMonitor(monitor,
+ IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
+ errMsg = launcher.getErrorMessage();
+ }
+ } else {
+ errMsg = launcher.getErrorMessage();
+ }
+
+ if ((errMsg != null && errMsg.length() > 0) || proc == null) {
+ // Can't tell if the build is needed, so assume it is, and let any errors be triggered
+ // when the "real" build is invoked below
+ makeArgs.add("pre-build"); //$NON-NLS-1$
+ makeArgs.add("main-build"); //$NON-NLS-1$
+ } else {
+ // The "make -q" command launch was successful
+ if (proc.exitValue() == 0) {
+ // If the status value returned from "make -q" is 0, then the build state is up-to-date
+ isuptodate = true;
+ // Report that the build was up to date, and thus nothing needs to be built
+ String uptodateMsg = ManagedMakeMessages
+ .getFormattedString(NOTHING_BUILT, currentProject.getName());
+ buf = new StringBuffer();
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ buf.append(uptodateMsg);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ // Write message on the console
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ epmOutputStream.close();
+ consoleOutStream.close();
+ } else {
+ // The status value was other than 0, so press on with the build process
+ makeArgs.add("pre-build"); //$NON-NLS-1$
+ makeArgs.add("main-build"); //$NON-NLS-1$
+ }
+ }
+ break;
+ }
+ case FULL_BUILD: {
+ makeArgs.add("clean"); //$NON-NLS-1$
+ makeArgs.add("pre-build"); //$NON-NLS-1$
+ makeArgs.add("main-build"); //$NON-NLS-1$
+ break;
+ }
+ case CLEAN_BUILD: {
+ makeArgs.add("clean"); //$NON-NLS-1$
+ break;
+ }
+ }
+
+ } else {
+ // No prebuild step
+ //
+ makeArgs.addAll(Arrays.asList(getMakeTargets(buildType)));
+ }
+
+ makeTargets = (String[]) makeArgs.toArray(new String[makeArgs.size()]);
+
+ // Launch make - main invocation
+ if (!isuptodate) {
+ proc = launcher.execute(makeCommand, makeTargets, env,
+ workingDirectory);
+ if (proc != null) {
+ try {
+ // Close the input of the process since we will never write to it
+ proc.getOutputStream().close();
+ } catch (IOException e) {
+ }
+
+ if (launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(),
+ new SubProgressMonitor(monitor,
+ IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
+ errMsg = launcher.getErrorMessage();
+ }
+
+ // Force a resync of the projects without allowing the user to cancel.
+ // This is probably unkind, but short of this there is no way to insure
+ // the UI is up-to-date with the build results
+ monitor.subTask(ManagedMakeMessages
+ .getResourceString(REFRESH));
+ try {
+ currentProject.refreshLocal(
+ IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ monitor.subTask(ManagedMakeMessages
+ .getResourceString(REFRESH_ERROR));
+ }
+ } else {
+ errMsg = launcher.getErrorMessage();
+ }
+
+ // Report either the success or failure of our mission
+ buf = new StringBuffer();
+ if (errMsg != null && errMsg.length() > 0) {
+ String errorDesc = ManagedMakeMessages
+ .getResourceString(BUILD_ERROR);
+ buf.append(errorDesc);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ // Report a successful build
+ String successMsg = ManagedMakeMessages
+ .getFormattedString(BUILD_FINISHED,
+ currentProject.getName());
+ buf.append(successMsg);
+ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ // Write message on the console
+ consoleOutStream.write(buf.toString().getBytes());
+ consoleOutStream.flush();
+ epmOutputStream.close();
+
+ // Generate any error markers that the build has discovered
+ monitor.subTask(ManagedMakeMessages
+ .getResourceString(MARKERS));
+ addBuilderMarkers(epm);
+ epm.reportProblems();
+ consoleOutStream.close();
+ }
+ }
+ } catch (Exception e) {
+ forgetLastBuiltState();
+ } finally {
+ getGenerationProblems().clear();
+ }
+ }
+
+ /* (non-Javadoc)
+ * Removes the IMarkers for the project specified in the argument if the
+ * project exists, and is open.
+ *
+ * @param project
+ */
+ private void removeAllMarkers(IProject project) {
+ if (project == null || !project.isAccessible()) return;
+
+ // Clear out the problem markers
+ IWorkspace workspace = project.getWorkspace();
+ IMarker[] markers;
+ try {
+ markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
+ } catch (CoreException e) {
+ // Handled just about every case in the sanity check
+ return;
+ }
+ if (markers != null) {
+ try {
+ workspace.deleteMarkers(markers);
+ } catch (CoreException e) {
+ // The only situation that might cause this is some sort of resource change event
+ return;
+ }
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
index 070dd4695d..6380d29895 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
@@ -1,1221 +1,1221 @@
-/*******************************************************************************
- * 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.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.content.*;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IInputOrder;
-import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class InputType extends BuildObject implements IInputType {
-
- private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
- private static final String EMPTY_STRING = new String();
-
- // Superclass
- private IInputType superClass;
- private String superClassId;
- // Parent and children
- private ITool parent;
- private Vector inputOrderList;
- private Vector additionalInputList;
- // Managed Build model attributes
- private String sourceContentTypeId;
- private IContentType sourceContentType;
- private List inputExtensions;
- private String dependencyContentTypeId;
- private IContentType dependencyContentType;
- private List dependencyExtensions;
- private String optionId;
- private String assignToOptionId;
- private String buildVariable;
- private Boolean multipleOfType;
- private Boolean primaryInput;
- private IConfigurationElement dependencyGeneratorElement = null;
- private IManagedDependencyGenerator dependencyGenerator = null;
- // Miscellaneous
- private boolean isExtensionInputType = false;
- private boolean isDirty = false;
- private boolean resolved = true;
-
- /*
- * C O N S T R U C T O R S
- */
-
- /**
- * This constructor is called to create an InputType defined by an extension point in
- * a plugin manifest file, or returned by a dynamic element provider
- *
- * @param parent The ITool parent of this InputType
- * @param element The InputType definition from the manifest file or a dynamic element
- * provider
- */
- public InputType(ITool parent, IManagedConfigElement element) {
- this.parent = parent;
- isExtensionInputType = true;
-
- // setup for resolving
- resolved = false;
-
- loadFromManifest(element);
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionInputType(this);
-
- // Load Children
- IManagedConfigElement[] iElements = element.getChildren();
- for (int l = 0; l < iElements.length; ++l) {
- IManagedConfigElement iElement = iElements[l];
- if (iElement.getName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
- InputOrder inputOrder = new InputOrder(this, iElement);
- getInputOrderList().add(inputOrder);
- } else if (iElement.getName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
- AdditionalInput addlInput = new AdditionalInput(this, iElement);
- getAdditionalInputList().add(addlInput);
- }
- }
- }
-
- /**
- * This constructor is called to create an InputType whose attributes and children will be
- * added by separate calls.
- *
- * @param Tool The parent of the an InputType
- * @param InputType The superClass, if any
- * @param String The id for the new InputType
- * @param String The name for the new InputType
- * @param boolean Indicates whether this is an extension element or a managed project element
- */
- public InputType(Tool parent, IInputType superClass, String Id, String name, boolean isExtensionElement) {
- this.parent = parent;
- this.superClass = superClass;
- if (this.superClass != null) {
- superClassId = this.superClass.getId();
- }
- setId(Id);
- setName(name);
-
- isExtensionInputType = isExtensionElement;
- if (isExtensionElement) {
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionInputType(this);
- } else {
- setDirty(true);
- }
- }
-
- /**
- * Create an <code>InputType</code> based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param parent The <code>ITool</code> the InputType will be added to.
- * @param element The XML element that contains the InputType settings.
- *
- */
- public InputType(ITool parent, Element element) {
- this.parent = parent;
- isExtensionInputType = false;
-
- // Initialize from the XML attributes
- loadFromProject(element);
-
- // Load children
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
- InputOrder inputOrder = new InputOrder(this, (Element)configElement);
- getInputOrderList().add(inputOrder);
- } else if (configElement.getNodeName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
- AdditionalInput addlInput = new AdditionalInput(this, (Element)configElement);
- getAdditionalInputList().add(addlInput);
- }
- }
- }
-
- /**
- * Create an <code>InputType</code> based upon an existing InputType.
- *
- * @param parent The <code>ITool</code> the InputType will be added to.
- * @param Id The identifier of the new InputType
- * @param name The name of the new InputType
- * @param inputType The existing InputType to clone.
- */
- public InputType(ITool parent, String Id, String name, InputType inputType) {
- this.parent = parent;
- superClass = inputType.superClass;
- if (superClass != null) {
- if (inputType.superClassId != null) {
- superClassId = new String(inputType.superClassId);
- }
- }
- setId(Id);
- setName(name);
-
- isExtensionInputType = false;
-
- // Copy the remaining attributes
-
- if (inputType.sourceContentTypeId != null) {
- sourceContentTypeId = new String(inputType.sourceContentTypeId);
- }
- sourceContentType = inputType.sourceContentType;
- if (inputType.inputExtensions != null) {
- inputExtensions = new ArrayList(inputType.inputExtensions);
- }
- if (inputType.dependencyContentTypeId != null) {
- dependencyContentTypeId = new String(inputType.dependencyContentTypeId);
- }
- dependencyContentType = inputType.dependencyContentType;
- if (inputType.dependencyExtensions != null) {
- dependencyExtensions = new ArrayList(inputType.dependencyExtensions);
- }
- if (inputType.optionId != null) {
- optionId = new String(inputType.optionId);
- }
- if (inputType.assignToOptionId != null) {
- assignToOptionId = new String(inputType.assignToOptionId);
- }
- if (inputType.buildVariable != null) {
- buildVariable = new String(inputType.buildVariable);
- }
- if (inputType.multipleOfType != null) {
- multipleOfType = new Boolean(inputType.multipleOfType.booleanValue());
- }
- if (inputType.primaryInput != null) {
- primaryInput = new Boolean(inputType.primaryInput.booleanValue());
- }
- dependencyGeneratorElement = inputType.dependencyGeneratorElement;
- dependencyGenerator = inputType.dependencyGenerator;
-
- // Clone the children
- if (inputType.inputOrderList != null) {
- Iterator iter = inputType.getInputOrderList().listIterator();
- while (iter.hasNext()) {
- InputOrder inputOrder = (InputOrder) iter.next();
- InputOrder newInputOrder = new InputOrder(this, inputOrder);
- getInputOrderList().add(newInputOrder);
- }
- }
- if (inputType.additionalInputList != null) {
- Iterator iter = inputType.getAdditionalInputList().listIterator();
- while (iter.hasNext()) {
- AdditionalInput additionalInput = (AdditionalInput) iter.next();
- AdditionalInput newAdditionalInput = new AdditionalInput(this, additionalInput);
- getAdditionalInputList().add(newAdditionalInput);
- }
- }
-
- setDirty(true);
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /* (non-Javadoc)
- * Loads the InputType information from the ManagedConfigElement specified in the
- * argument.
- *
- * @param element Contains the InputType information
- */
- protected void loadFromManifest(IManagedConfigElement element) {
- ManagedBuildManager.putConfigElement(this, element);
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // Get the name
- setName(element.getAttribute(IBuildObject.NAME));
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
-
- // sourceContentType
- sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
-
- // Get the supported input file extensions
- String inputs = element.getAttribute(ITool.SOURCES);
- if (inputs != null) {
- StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
- }
- }
-
- // dependencyContentType
- dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
-
- // Get the dependency (header file) extensions
- String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
- if (headers != null) {
- StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getDependencyExtensionsList().add(tokenizer.nextElement());
- }
- }
-
- // option
- optionId = element.getAttribute(IInputType.OPTION);
-
- // assignToOption
- assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
-
- // multipleOfType
- String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
- if (isMOT != null){
- multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
- }
-
- // primaryInput
- String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
- if (isPI != null){
- primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
- }
-
- // buildVariable
- buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
-
- // Store the configuration element IFF there is a dependency generator defined
- String depGenerator = element.getAttribute(ITool.DEP_CALC_ID);
- if (depGenerator != null && element instanceof DefaultManagedConfigElement) {
- dependencyGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
- }
-
- /* (non-Javadoc)
- * Initialize the InputType information from the XML element
- * specified in the argument
- *
- * @param element An XML element containing the InputType information
- */
- protected boolean loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // name
- if (element.hasAttribute(IBuildObject.NAME)) {
- setName(element.getAttribute(IBuildObject.NAME));
- }
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
- if (superClassId != null && superClassId.length() > 0) {
- superClass = ManagedBuildManager.getExtensionInputType(superClassId);
- if (superClass == null) {
- // TODO: Report error
- }
- }
-
- // sourceContentType
- IContentTypeManager manager = Platform.getContentTypeManager();
- if (element.hasAttribute(IInputType.SOURCE_CONTENT_TYPE)) {
- sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
- if (sourceContentTypeId != null && sourceContentTypeId.length() > 0) {
- sourceContentType = manager.getContentType(sourceContentTypeId);
- }
- }
-
- // sources
- if (element.hasAttribute(IInputType.SOURCES)) {
- String inputs = element.getAttribute(ITool.SOURCES);
- if (inputs != null) {
- StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
- }
- }
- }
-
- // dependencyContentType
- if (element.hasAttribute(IInputType.DEPENDENCY_CONTENT_TYPE)) {
- dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
- if (dependencyContentTypeId != null && dependencyContentTypeId.length() > 0) {
- dependencyContentType = manager.getContentType(dependencyContentTypeId);
- }
- }
-
- // dependencyExtensions
- // Get the dependency (header file) extensions
- if (element.hasAttribute(IInputType.DEPENDENCY_EXTENSIONS)) {
- String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
- if (headers != null) {
- StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getDependencyExtensionsList().add(tokenizer.nextElement());
- }
- }
- }
-
- // option
- if (element.hasAttribute(IInputType.OPTION)) {
- optionId = element.getAttribute(IInputType.OPTION);
- }
-
- // assignToOption
- if (element.hasAttribute(IInputType.ASSIGN_TO_OPTION)) {
- assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
- }
-
- // multipleOfType
- if (element.hasAttribute(IInputType.MULTIPLE_OF_TYPE)) {
- String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
- if (isMOT != null){
- multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
- }
- }
-
- // primaryInput
- if (element.hasAttribute(IInputType.PRIMARY_INPUT)) {
- String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
- if (isPI != null){
- primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
- }
- }
-
- // buildVariable
- if (element.hasAttribute(IInputType.BUILD_VARIABLE)) {
- buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
- }
-
- // Note: dependency generator cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (element.hasAttribute(ITool.DEP_CALC_ID)) {
- // TODO: Issue warning?
- }
-
- return true;
- }
-
- /**
- * Persist the InputType to the project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- if (superClass != null)
- element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
-
- element.setAttribute(IBuildObject.ID, id);
-
- if (name != null) {
- element.setAttribute(IBuildObject.NAME, name);
- }
-
- // sourceContentType
- if (sourceContentTypeId != null) {
- element.setAttribute(IInputType.SOURCE_CONTENT_TYPE, sourceContentTypeId);
- }
-
- // input file extensions
- if (getInputExtensionsList().size() > 0) {
- String inputs;
- List list = getInputExtensionsList();
- Iterator iter = list.listIterator();
- inputs = (String)iter.next();
- while (iter.hasNext()) {
- inputs += DEFAULT_SEPARATOR;
- inputs += iter.next();
- }
- element.setAttribute(IInputType.SOURCES, inputs);
- }
-
- // dependencyContentType
- if (dependencyContentTypeId != null) {
- element.setAttribute(IInputType.DEPENDENCY_CONTENT_TYPE, dependencyContentTypeId);
- }
-
- // dependency (header file) extensions
- if (getDependencyExtensionsList().size() > 0) {
- String headers;
- List list = getDependencyExtensionsList();
- Iterator iter = list.listIterator();
- headers = (String)iter.next();
- while (iter.hasNext()) {
- headers += DEFAULT_SEPARATOR;
- headers += iter.next();
- }
- element.setAttribute(IInputType.DEPENDENCY_EXTENSIONS, headers);
- }
-
- if (optionId != null) {
- element.setAttribute(IInputType.OPTION, optionId);
- }
-
- if (assignToOptionId != null) {
- element.setAttribute(IInputType.ASSIGN_TO_OPTION, assignToOptionId);
- }
-
- if (multipleOfType != null) {
- element.setAttribute(IInputType.MULTIPLE_OF_TYPE, multipleOfType.toString());
- }
-
- if (primaryInput != null) {
- element.setAttribute(IInputType.PRIMARY_INPUT, primaryInput.toString());
- }
-
- if (buildVariable != null) {
- element.setAttribute(IInputType.BUILD_VARIABLE, buildVariable);
- }
-
- // Note: dependency generator cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (dependencyGeneratorElement != null) {
- // TODO: issue warning?
- }
-
- // Serialize my children
- List childElements = getInputOrderList();
- Iterator iter = childElements.listIterator();
- while (iter.hasNext()) {
- InputOrder io = (InputOrder) iter.next();
- Element ioElement = doc.createElement(InputOrder.INPUT_ORDER_ELEMENT_NAME);
- element.appendChild(ioElement);
- io.serialize(doc, ioElement);
- }
- childElements = getAdditionalInputList();
- iter = childElements.listIterator();
- while (iter.hasNext()) {
- AdditionalInput ai = (AdditionalInput) iter.next();
- Element aiElement = doc.createElement(AdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME);
- element.appendChild(aiElement);
- ai.serialize(doc, aiElement);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /*
- * P A R E N T A N D C H I L D H A N D L I N G
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getParent()
- */
- public ITool getParent() {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#createInputOrder()
- */
- public IInputOrder createInputOrder(String path) {
- InputOrder inputOrder = new InputOrder(this, false);
- inputOrder.setPath(path);
- getInputOrderList().add(inputOrder);
- setDirty(true);
- return inputOrder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getInputOrders()
- */
- public IInputOrder[] getInputOrders() {
- IInputOrder[] orders;
- Vector ours = getInputOrderList();
- orders = (IInputOrder[])ours.toArray(new IInputOrder[ours.size()]);
- return orders;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getInputOrder()
- */
- public IInputOrder getInputOrder(String path) {
- // TODO Convert both paths to absolute?
- List orders = getInputOrderList();
- Iterator iter = orders.listIterator();
- while (iter.hasNext()) {
- InputOrder io = (InputOrder) iter.next();
- if (path.compareToIgnoreCase(io.getPath()) != 0) {
- return io;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#removeInputOrder()
- */
- public void removeInputOrder(String path) {
- IInputOrder order = getInputOrder(path);
- if (order != null) removeInputOrder(order);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#removeInputOrder()
- */
- public void removeInputOrder(IInputOrder element) {
- getInputOrderList().remove(element);
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#createAdditionalInput()
- */
- public IAdditionalInput createAdditionalInput(String paths) {
- AdditionalInput addlInput = new AdditionalInput(this, false);
- addlInput.setPaths(paths);
- getAdditionalInputList().add(addlInput);
- setDirty(true);
- return addlInput;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalInputs()
- */
- public IAdditionalInput[] getAdditionalInputs() {
- IAdditionalInput[] inputs;
- Vector ours = getAdditionalInputList();
- inputs = (IAdditionalInput[])ours.toArray(new IAdditionalInput[ours.size()]);
- return inputs;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalInput()
- */
- public IAdditionalInput getAdditionalInput(String paths) {
- // TODO Convert both paths to absolute?
- // Must match all strings
- String[] inputTokens = paths.split(";"); //$NON-NLS-1$
- List inputs = getInputOrderList();
- Iterator iter = inputs.listIterator();
- while (iter.hasNext()) {
- AdditionalInput ai = (AdditionalInput) iter.next();
- boolean match = false;
- String[] tokens = ai.getPaths();
- if (tokens.length == inputTokens.length) {
- match = true;
- for (int i = 0; i < tokens.length; i++) {
- if (tokens[i].compareToIgnoreCase(inputTokens[i]) != 0) {
- match = false;
- break;
- }
- }
- }
- if (match) return ai;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#removeAdditionalInput()
- */
- public void removeAdditionalInput(String path) {
- IAdditionalInput input = getAdditionalInput(path);
- if (input != null) removeAdditionalInput(input);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#removeAdditionalInput()
- */
- public void removeAdditionalInput(IAdditionalInput element) {
- getAdditionalInputList().remove(element);
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalDependencies()
- */
- public IPath[] getAdditionalDependencies() {
- List deps = new ArrayList();
- Iterator typeIter = getAdditionalInputList().iterator();
- while (typeIter.hasNext()) {
- AdditionalInput current = (AdditionalInput)typeIter.next();
- int kind = current.getKind();
- if (kind == IAdditionalInput.KIND_ADDITIONAL_DEPENDENCY ||
- kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
- String[] paths = current.getPaths();
- if (paths != null) {
- for (int i = 0; i < paths.length; i++) {
- if (paths[i].length() > 0) {
- deps.add(Path.fromOSString(paths[i]));
- }
- }
- }
- }
- }
- return (IPath[])deps.toArray(new IPath[deps.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalResources()
- */
- public IPath[] getAdditionalResources() {
- List ins = new ArrayList();
- Iterator typeIter = getAdditionalInputList().iterator();
- while (typeIter.hasNext()) {
- AdditionalInput current = (AdditionalInput)typeIter.next();
- int kind = current.getKind();
- if (kind == IAdditionalInput.KIND_ADDITIONAL_INPUT ||
- kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
- String[] paths = current.getPaths();
- if (paths != null) {
- for (int i = 0; i < paths.length; i++) {
- if (paths[i].length() > 0) {
- ins.add(Path.fromOSString(paths[i]));
- }
- }
- }
- }
- }
- return (IPath[])ins.toArray(new IPath[ins.size()]);
- }
-
- /* (non-Javadoc)
- * Memory-safe way to access the list of input orders
- */
- private Vector getInputOrderList() {
- if (inputOrderList == null) {
- inputOrderList = new Vector();
- }
- return inputOrderList;
- }
-
- /* (non-Javadoc)
- * Memory-safe way to access the list of input orders
- */
- private Vector getAdditionalInputList() {
- if (additionalInputList == null) {
- additionalInputList = new Vector();
- }
- return additionalInputList;
- }
-
-
- /*
- * M O D E L A T T R I B U T E A C C E S S O R S
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IInputType#getSuperClass()
- */
- public IInputType getSuperClass() {
- return superClass;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getName()
- */
- public String getName() {
- return (name == null && superClass != null) ? superClass.getName() : name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getBuildVariable()
- */
- public String getBuildVariable() {
- if (buildVariable == null) {
- // If I have a superClass, ask it
- if (superClass != null) {
- return superClass.getBuildVariable();
- } else {
- return EMPTY_STRING;
- }
- }
- return buildVariable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setBuildVariable()
- */
- public void setBuildVariable(String variableName) {
- if (variableName == null && buildVariable == null) return;
- if (buildVariable == null || variableName == null || !(variableName.equals(buildVariable))) {
- buildVariable = variableName;
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyContentType()
- */
- public IContentType getDependencyContentType() {
- if (dependencyContentType == null) {
- if (superClass != null) {
- return superClass.getDependencyContentType();
- } else {
- return null;
- }
- }
- return dependencyContentType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyContentType()
- */
- public void setDependencyContentType(IContentType type) {
- if (dependencyContentType != type) {
- dependencyContentType = type;
- if (dependencyContentType != null) {
- dependencyContentTypeId = dependencyContentType.getId();
- } else {
- dependencyContentTypeId = null;
- }
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensionsAttribute()
- */
- public String[] getDependencyExtensionsAttribute() {
- if (dependencyExtensions == null || dependencyExtensions.size() == 0) {
- // If I have a superClass, ask it
- if (superClass != null) {
- return superClass.getDependencyExtensionsAttribute();
- } else {
- if (dependencyExtensions == null) {
- dependencyExtensions = new ArrayList();
- }
- }
- }
- return (String[])dependencyExtensions.toArray(new String[dependencyExtensions.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyExtensionsAttribute()
- */
- public void setDependencyExtensionsAttribute(String extensions) {
- getDependencyExtensionsList().clear();
- if (extensions != null) {
- StringTokenizer tokenizer = new StringTokenizer(extensions, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getDependencyExtensionsList().add(tokenizer.nextElement());
- }
- }
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensions()
- */
- public String[] getDependencyExtensions(ITool tool) {
- // Use content type if specified and registered with Eclipse
- IContentType type = getDependencyContentType();
- if (type != null) {
- String[] exts = ((Tool)tool).getContentTypeFileSpecs(type);
- // TODO: This is a temporary hack until we decide how to specify the langauge (C vs. C++)
- // of a .h file. If the content type is the CDT-defined C/C++ content type, then
- // add "h" to the list if it is not already there.
- if (type.getId().compareTo("org.eclipse.cdt.core.cxxHeader") == 0) { // $NON-NLS-1$
- boolean h_found = false;
- for (int i=0; i<exts.length; i++) {
- if (exts[i].compareTo("h") == 0) { // $NON-NLS-1$
- h_found = true;
- break;
- }
- }
- if (!h_found) {
- String[] cppexts = new String[exts.length+1];
- int i = 0;
- for (; i<exts.length; i++) {
- cppexts[i] = exts[i];
- }
- cppexts[i] = "h"; // $NON-NLS-1$
- return cppexts;
- }
- }
- return exts;
- }
- return getDependencyExtensionsAttribute();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#isDependencyExtension()
- */
- public boolean isDependencyExtension(ITool tool, String ext) {
- String[] exts = getDependencyExtensions(tool);
- for (int i=0; i<exts.length; i++) {
- if (ext.equals(exts[i])) return true;
- }
- return false;
- }
-
- private List getDependencyExtensionsList() {
- if (dependencyExtensions == null) {
- dependencyExtensions = new ArrayList();
- }
- return dependencyExtensions;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyGenerator()
- */
- public IManagedDependencyGenerator getDependencyGenerator() {
- if (dependencyGenerator != null) {
- return dependencyGenerator;
- }
- IConfigurationElement element = getDependencyGeneratorElement();
- if (element != null) {
- try {
- if (element.getAttribute(ITool.DEP_CALC_ID) != null) {
- dependencyGenerator = (IManagedDependencyGenerator) element.createExecutableExtension(ITool.DEP_CALC_ID);
- return dependencyGenerator;
- }
- } catch (CoreException e) {}
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyGeneratorElement()
- */
- public IConfigurationElement getDependencyGeneratorElement() {
- if (dependencyGeneratorElement == null) {
- if (superClass != null) {
- return ((InputType)superClass).getDependencyGeneratorElement();
- }
- }
- return dependencyGeneratorElement;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyGeneratorElement()
- */
- public void setDependencyGeneratorElement(IConfigurationElement element) {
- dependencyGeneratorElement = element;
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getMultipleOfType()
- */
- public boolean getMultipleOfType() {
- if (multipleOfType == null) {
- if (superClass != null) {
- return superClass.getMultipleOfType();
- } else {
- return false; // default is false
- }
- }
- return multipleOfType.booleanValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setMultipleOfType()
- */
- public void setMultipleOfType(boolean b) {
- if (multipleOfType == null || !(b == multipleOfType.booleanValue())) {
- multipleOfType = new Boolean(b);
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getPrimaryInput()
- */
- public boolean getPrimaryInput() {
- if (primaryInput == null) {
- if (superClass != null) {
- return superClass.getPrimaryInput();
- } else {
- return false; // default is false
- }
- }
- return primaryInput.booleanValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setMultipleOfType()
- */
- public void setPrimaryInput(boolean b) {
- if (primaryInput == null || !(b == primaryInput.booleanValue())) {
- primaryInput = new Boolean(b);
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getOptionId()
- */
- public String getOptionId() {
- if (optionId == null) {
- if (superClass != null) {
- return superClass.getOptionId();
- } else {
- return null;
- }
- }
- return optionId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setOptionId()
- */
- public void setOptionId(String id) {
- if (id == null && optionId == null) return;
- if (id == null || optionId == null || !(optionId.equals(id))) {
- optionId = id;
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAssignToOptionId()
- */
- public String getAssignToOptionId() {
- if (assignToOptionId == null) {
- if (superClass != null) {
- return superClass.getAssignToOptionId();
- } else {
- return null;
- }
- }
- return assignToOptionId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setAssignToOptionId()
- */
- public void setAssignToOptionId(String id) {
- if (id == null && assignToOptionId == null) return;
- if (id == null || assignToOptionId == null || !(assignToOptionId.equals(id))) {
- assignToOptionId = id;
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getSourceContentType()
- */
- public IContentType getSourceContentType() {
- if (sourceContentType == null) {
- if (superClass != null) {
- return superClass.getSourceContentType();
- } else {
- return null;
- }
- }
- return sourceContentType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setSourceContentType()
- */
- public void setSourceContentType(IContentType type) {
- if (sourceContentType != type) {
- sourceContentType = type;
- if (sourceContentType != null) {
- sourceContentTypeId = sourceContentType.getId();
- } else {
- sourceContentTypeId = null;
- }
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getSourceExtensionsAttribute()
- */
- public String[] getSourceExtensionsAttribute() {
- if( (inputExtensions == null) || ( inputExtensions.size() == 0) ) {
- // If I have a superClass, ask it
- if (superClass != null) {
- return superClass.getSourceExtensionsAttribute();
- } else {
- inputExtensions = new ArrayList();
- }
- }
- return (String[])inputExtensions.toArray(new String[inputExtensions.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setSourceExtensionsAttribute()
- */
- public void setSourceExtensionsAttribute(String extensions) {
- getInputExtensionsList().clear();
- if (extensions != null) {
- StringTokenizer tokenizer = new StringTokenizer(extensions, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
- }
- }
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getSourceExtensions()
- */
- public String[] getSourceExtensions(ITool tool) {
- // Use content type if specified and registered with Eclipse
- IContentType type = getSourceContentType();
- if (type != null) {
- return ((Tool)tool).getContentTypeFileSpecs(type);
- }
- return getSourceExtensionsAttribute();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#isSourceExtension()
- */
- public boolean isSourceExtension(ITool tool, String ext) {
- String[] exts = getSourceExtensions(tool);
- for (int i=0; i<exts.length; i++) {
- if (ext.equals(exts[i])) return true;
- }
- return false;
- }
-
- private List getInputExtensionsList() {
- if (inputExtensions == null) {
- inputExtensions = new ArrayList();
- }
- return inputExtensions;
- }
-
- /*
- * O B J E C T S T A T E M A I N T E N A N C E
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IInputType#isExtensionElement()
- */
- public boolean isExtensionElement() {
- return isExtensionInputType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IInputType#isDirty()
- */
- public boolean isDirty() {
- // This shouldn't be called for an extension InputType
- if (isExtensionInputType) return false;
-
- // Check my children
- Iterator typeIter = getInputOrderList().iterator();
- while (typeIter.hasNext()) {
- InputOrder current = (InputOrder)typeIter.next();
- if (current.isDirty()) return true;
- }
- typeIter = getAdditionalInputList().iterator();
- while (typeIter.hasNext()) {
- AdditionalInput current = (AdditionalInput)typeIter.next();
- if (current.isDirty()) return true;
- }
-
- return isDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IInputType#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- this.isDirty = isDirty;
- // Propagate "false" to the children
- if (!isDirty) {
- Iterator typeIter = getInputOrderList().iterator();
- while (typeIter.hasNext()) {
- InputOrder current = (InputOrder)typeIter.next();
- current.setDirty(false);
- }
- typeIter = getAdditionalInputList().iterator();
- while (typeIter.hasNext()) {
- AdditionalInput current = (AdditionalInput)typeIter.next();
- current.setDirty(false);
- }
- }
- }
-
- /* (non-Javadoc)
- * Resolve the element IDs to interface references
- */
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
- // Resolve superClass
- if (superClassId != null && superClassId.length() > 0) {
- superClass = ManagedBuildManager.getExtensionInputType(superClassId);
- if (superClass == null) {
- // Report error
- ManagedBuildManager.OutputResolveError(
- "superClass", //$NON-NLS-1$
- superClassId,
- "inputType", //$NON-NLS-1$
- getId());
- }
- }
-
- // Resolve content types
- IContentTypeManager manager = Platform.getContentTypeManager();
- if (sourceContentTypeId != null && sourceContentTypeId.length() > 0) {
- sourceContentType = manager.getContentType(sourceContentTypeId);
- }
- if (dependencyContentTypeId != null && dependencyContentTypeId.length() > 0) {
- dependencyContentType = manager.getContentType(dependencyContentTypeId);
- }
-
- // Call resolveReferences on our children
- Iterator typeIter = getInputOrderList().iterator();
- while (typeIter.hasNext()) {
- InputOrder current = (InputOrder)typeIter.next();
- current.resolveReferences();
- }
- typeIter = getAdditionalInputList().iterator();
- while (typeIter.hasNext()) {
- AdditionalInput current = (AdditionalInput)typeIter.next();
- current.resolveReferences();
- }
- }
- }
-
- /**
- * @return Returns the managedBuildRevision.
- */
- public String getManagedBuildRevision() {
- if ( managedBuildRevision == null) {
- if ( getParent() != null) {
- return getParent().getManagedBuildRevision();
- }
- }
- return managedBuildRevision;
- }
-
- /**
- * @return Returns the version.
- */
- public PluginVersionIdentifier getVersion() {
- if ( version == null) {
- if ( getParent() != null) {
- return getParent().getVersion();
- }
- }
- return version;
- }
-
- public void setVersion(PluginVersionIdentifier version) {
- // Do nothing
- }
-}
+/*******************************************************************************
+ * 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.internal.core;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.content.*;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IInputOrder;
+import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class InputType extends BuildObject implements IInputType {
+
+ private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
+ private static final String EMPTY_STRING = new String();
+
+ // Superclass
+ private IInputType superClass;
+ private String superClassId;
+ // Parent and children
+ private ITool parent;
+ private Vector inputOrderList;
+ private Vector additionalInputList;
+ // Managed Build model attributes
+ private String sourceContentTypeId;
+ private IContentType sourceContentType;
+ private List inputExtensions;
+ private String dependencyContentTypeId;
+ private IContentType dependencyContentType;
+ private List dependencyExtensions;
+ private String optionId;
+ private String assignToOptionId;
+ private String buildVariable;
+ private Boolean multipleOfType;
+ private Boolean primaryInput;
+ private IConfigurationElement dependencyGeneratorElement = null;
+ private IManagedDependencyGeneratorType dependencyGenerator = null;
+ // Miscellaneous
+ private boolean isExtensionInputType = false;
+ private boolean isDirty = false;
+ private boolean resolved = true;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * This constructor is called to create an InputType defined by an extension point in
+ * a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The ITool parent of this InputType
+ * @param element The InputType definition from the manifest file or a dynamic element
+ * provider
+ */
+ public InputType(ITool parent, IManagedConfigElement element) {
+ this.parent = parent;
+ isExtensionInputType = true;
+
+ // setup for resolving
+ resolved = false;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionInputType(this);
+
+ // Load Children
+ IManagedConfigElement[] iElements = element.getChildren();
+ for (int l = 0; l < iElements.length; ++l) {
+ IManagedConfigElement iElement = iElements[l];
+ if (iElement.getName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
+ InputOrder inputOrder = new InputOrder(this, iElement);
+ getInputOrderList().add(inputOrder);
+ } else if (iElement.getName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
+ AdditionalInput addlInput = new AdditionalInput(this, iElement);
+ getAdditionalInputList().add(addlInput);
+ }
+ }
+ }
+
+ /**
+ * This constructor is called to create an InputType whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param Tool The parent of the an InputType
+ * @param InputType The superClass, if any
+ * @param String The id for the new InputType
+ * @param String The name for the new InputType
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public InputType(Tool parent, IInputType superClass, String Id, String name, boolean isExtensionElement) {
+ this.parent = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+
+ isExtensionInputType = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionInputType(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create an <code>InputType</code> based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The <code>ITool</code> the InputType will be added to.
+ * @param element The XML element that contains the InputType settings.
+ *
+ */
+ public InputType(ITool parent, Element element) {
+ this.parent = parent;
+ isExtensionInputType = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Load children
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
+ InputOrder inputOrder = new InputOrder(this, (Element)configElement);
+ getInputOrderList().add(inputOrder);
+ } else if (configElement.getNodeName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
+ AdditionalInput addlInput = new AdditionalInput(this, (Element)configElement);
+ getAdditionalInputList().add(addlInput);
+ }
+ }
+ }
+
+ /**
+ * Create an <code>InputType</code> based upon an existing InputType.
+ *
+ * @param parent The <code>ITool</code> the InputType will be added to.
+ * @param Id The identifier of the new InputType
+ * @param name The name of the new InputType
+ * @param inputType The existing InputType to clone.
+ */
+ public InputType(ITool parent, String Id, String name, InputType inputType) {
+ this.parent = parent;
+ superClass = inputType.superClass;
+ if (superClass != null) {
+ if (inputType.superClassId != null) {
+ superClassId = new String(inputType.superClassId);
+ }
+ }
+ setId(Id);
+ setName(name);
+
+ isExtensionInputType = false;
+
+ // Copy the remaining attributes
+
+ if (inputType.sourceContentTypeId != null) {
+ sourceContentTypeId = new String(inputType.sourceContentTypeId);
+ }
+ sourceContentType = inputType.sourceContentType;
+ if (inputType.inputExtensions != null) {
+ inputExtensions = new ArrayList(inputType.inputExtensions);
+ }
+ if (inputType.dependencyContentTypeId != null) {
+ dependencyContentTypeId = new String(inputType.dependencyContentTypeId);
+ }
+ dependencyContentType = inputType.dependencyContentType;
+ if (inputType.dependencyExtensions != null) {
+ dependencyExtensions = new ArrayList(inputType.dependencyExtensions);
+ }
+ if (inputType.optionId != null) {
+ optionId = new String(inputType.optionId);
+ }
+ if (inputType.assignToOptionId != null) {
+ assignToOptionId = new String(inputType.assignToOptionId);
+ }
+ if (inputType.buildVariable != null) {
+ buildVariable = new String(inputType.buildVariable);
+ }
+ if (inputType.multipleOfType != null) {
+ multipleOfType = new Boolean(inputType.multipleOfType.booleanValue());
+ }
+ if (inputType.primaryInput != null) {
+ primaryInput = new Boolean(inputType.primaryInput.booleanValue());
+ }
+ dependencyGeneratorElement = inputType.dependencyGeneratorElement;
+ dependencyGenerator = inputType.dependencyGenerator;
+
+ // Clone the children
+ if (inputType.inputOrderList != null) {
+ Iterator iter = inputType.getInputOrderList().listIterator();
+ while (iter.hasNext()) {
+ InputOrder inputOrder = (InputOrder) iter.next();
+ InputOrder newInputOrder = new InputOrder(this, inputOrder);
+ getInputOrderList().add(newInputOrder);
+ }
+ }
+ if (inputType.additionalInputList != null) {
+ Iterator iter = inputType.getAdditionalInputList().listIterator();
+ while (iter.hasNext()) {
+ AdditionalInput additionalInput = (AdditionalInput) iter.next();
+ AdditionalInput newAdditionalInput = new AdditionalInput(this, additionalInput);
+ getAdditionalInputList().add(newAdditionalInput);
+ }
+ }
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the InputType information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the InputType information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // sourceContentType
+ sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
+
+ // Get the supported input file extensions
+ String inputs = element.getAttribute(ITool.SOURCES);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+
+ // dependencyContentType
+ dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
+
+ // Get the dependency (header file) extensions
+ String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
+ if (headers != null) {
+ StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getDependencyExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+
+ // option
+ optionId = element.getAttribute(IInputType.OPTION);
+
+ // assignToOption
+ assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
+
+ // multipleOfType
+ String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
+ if (isMOT != null){
+ multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
+ }
+
+ // primaryInput
+ String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
+ if (isPI != null){
+ primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
+ }
+
+ // buildVariable
+ buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
+
+ // Store the configuration element IFF there is a dependency generator defined
+ String depGenerator = element.getAttribute(ITool.DEP_CALC_ID);
+ if (depGenerator != null && element instanceof DefaultManagedConfigElement) {
+ dependencyGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+ }
+
+ /* (non-Javadoc)
+ * Initialize the InputType information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the InputType information
+ */
+ protected boolean loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionInputType(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // sourceContentType
+ IContentTypeManager manager = Platform.getContentTypeManager();
+ if (element.hasAttribute(IInputType.SOURCE_CONTENT_TYPE)) {
+ sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
+ if (sourceContentTypeId != null && sourceContentTypeId.length() > 0) {
+ sourceContentType = manager.getContentType(sourceContentTypeId);
+ }
+ }
+
+ // sources
+ if (element.hasAttribute(IInputType.SOURCES)) {
+ String inputs = element.getAttribute(ITool.SOURCES);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ }
+
+ // dependencyContentType
+ if (element.hasAttribute(IInputType.DEPENDENCY_CONTENT_TYPE)) {
+ dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
+ if (dependencyContentTypeId != null && dependencyContentTypeId.length() > 0) {
+ dependencyContentType = manager.getContentType(dependencyContentTypeId);
+ }
+ }
+
+ // dependencyExtensions
+ // Get the dependency (header file) extensions
+ if (element.hasAttribute(IInputType.DEPENDENCY_EXTENSIONS)) {
+ String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
+ if (headers != null) {
+ StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getDependencyExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ }
+
+ // option
+ if (element.hasAttribute(IInputType.OPTION)) {
+ optionId = element.getAttribute(IInputType.OPTION);
+ }
+
+ // assignToOption
+ if (element.hasAttribute(IInputType.ASSIGN_TO_OPTION)) {
+ assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
+ }
+
+ // multipleOfType
+ if (element.hasAttribute(IInputType.MULTIPLE_OF_TYPE)) {
+ String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
+ if (isMOT != null){
+ multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
+ }
+ }
+
+ // primaryInput
+ if (element.hasAttribute(IInputType.PRIMARY_INPUT)) {
+ String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
+ if (isPI != null){
+ primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
+ }
+ }
+
+ // buildVariable
+ if (element.hasAttribute(IInputType.BUILD_VARIABLE)) {
+ buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
+ }
+
+ // Note: dependency generator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (element.hasAttribute(ITool.DEP_CALC_ID)) {
+ // TODO: Issue warning?
+ }
+
+ return true;
+ }
+
+ /**
+ * Persist the InputType to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ // sourceContentType
+ if (sourceContentTypeId != null) {
+ element.setAttribute(IInputType.SOURCE_CONTENT_TYPE, sourceContentTypeId);
+ }
+
+ // input file extensions
+ if (getInputExtensionsList().size() > 0) {
+ String inputs;
+ List list = getInputExtensionsList();
+ Iterator iter = list.listIterator();
+ inputs = (String)iter.next();
+ while (iter.hasNext()) {
+ inputs += DEFAULT_SEPARATOR;
+ inputs += iter.next();
+ }
+ element.setAttribute(IInputType.SOURCES, inputs);
+ }
+
+ // dependencyContentType
+ if (dependencyContentTypeId != null) {
+ element.setAttribute(IInputType.DEPENDENCY_CONTENT_TYPE, dependencyContentTypeId);
+ }
+
+ // dependency (header file) extensions
+ if (getDependencyExtensionsList().size() > 0) {
+ String headers;
+ List list = getDependencyExtensionsList();
+ Iterator iter = list.listIterator();
+ headers = (String)iter.next();
+ while (iter.hasNext()) {
+ headers += DEFAULT_SEPARATOR;
+ headers += iter.next();
+ }
+ element.setAttribute(IInputType.DEPENDENCY_EXTENSIONS, headers);
+ }
+
+ if (optionId != null) {
+ element.setAttribute(IInputType.OPTION, optionId);
+ }
+
+ if (assignToOptionId != null) {
+ element.setAttribute(IInputType.ASSIGN_TO_OPTION, assignToOptionId);
+ }
+
+ if (multipleOfType != null) {
+ element.setAttribute(IInputType.MULTIPLE_OF_TYPE, multipleOfType.toString());
+ }
+
+ if (primaryInput != null) {
+ element.setAttribute(IInputType.PRIMARY_INPUT, primaryInput.toString());
+ }
+
+ if (buildVariable != null) {
+ element.setAttribute(IInputType.BUILD_VARIABLE, buildVariable);
+ }
+
+ // Note: dependency generator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (dependencyGeneratorElement != null) {
+ // TODO: issue warning?
+ }
+
+ // Serialize my children
+ List childElements = getInputOrderList();
+ Iterator iter = childElements.listIterator();
+ while (iter.hasNext()) {
+ InputOrder io = (InputOrder) iter.next();
+ Element ioElement = doc.createElement(InputOrder.INPUT_ORDER_ELEMENT_NAME);
+ element.appendChild(ioElement);
+ io.serialize(doc, ioElement);
+ }
+ childElements = getAdditionalInputList();
+ iter = childElements.listIterator();
+ while (iter.hasNext()) {
+ AdditionalInput ai = (AdditionalInput) iter.next();
+ Element aiElement = doc.createElement(AdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME);
+ element.appendChild(aiElement);
+ ai.serialize(doc, aiElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getParent()
+ */
+ public ITool getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#createInputOrder()
+ */
+ public IInputOrder createInputOrder(String path) {
+ InputOrder inputOrder = new InputOrder(this, false);
+ inputOrder.setPath(path);
+ getInputOrderList().add(inputOrder);
+ setDirty(true);
+ return inputOrder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getInputOrders()
+ */
+ public IInputOrder[] getInputOrders() {
+ IInputOrder[] orders;
+ Vector ours = getInputOrderList();
+ orders = (IInputOrder[])ours.toArray(new IInputOrder[ours.size()]);
+ return orders;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getInputOrder()
+ */
+ public IInputOrder getInputOrder(String path) {
+ // TODO Convert both paths to absolute?
+ List orders = getInputOrderList();
+ Iterator iter = orders.listIterator();
+ while (iter.hasNext()) {
+ InputOrder io = (InputOrder) iter.next();
+ if (path.compareToIgnoreCase(io.getPath()) != 0) {
+ return io;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#removeInputOrder()
+ */
+ public void removeInputOrder(String path) {
+ IInputOrder order = getInputOrder(path);
+ if (order != null) removeInputOrder(order);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#removeInputOrder()
+ */
+ public void removeInputOrder(IInputOrder element) {
+ getInputOrderList().remove(element);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#createAdditionalInput()
+ */
+ public IAdditionalInput createAdditionalInput(String paths) {
+ AdditionalInput addlInput = new AdditionalInput(this, false);
+ addlInput.setPaths(paths);
+ getAdditionalInputList().add(addlInput);
+ setDirty(true);
+ return addlInput;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalInputs()
+ */
+ public IAdditionalInput[] getAdditionalInputs() {
+ IAdditionalInput[] inputs;
+ Vector ours = getAdditionalInputList();
+ inputs = (IAdditionalInput[])ours.toArray(new IAdditionalInput[ours.size()]);
+ return inputs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalInput()
+ */
+ public IAdditionalInput getAdditionalInput(String paths) {
+ // TODO Convert both paths to absolute?
+ // Must match all strings
+ String[] inputTokens = paths.split(";"); //$NON-NLS-1$
+ List inputs = getInputOrderList();
+ Iterator iter = inputs.listIterator();
+ while (iter.hasNext()) {
+ AdditionalInput ai = (AdditionalInput) iter.next();
+ boolean match = false;
+ String[] tokens = ai.getPaths();
+ if (tokens.length == inputTokens.length) {
+ match = true;
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].compareToIgnoreCase(inputTokens[i]) != 0) {
+ match = false;
+ break;
+ }
+ }
+ }
+ if (match) return ai;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#removeAdditionalInput()
+ */
+ public void removeAdditionalInput(String path) {
+ IAdditionalInput input = getAdditionalInput(path);
+ if (input != null) removeAdditionalInput(input);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#removeAdditionalInput()
+ */
+ public void removeAdditionalInput(IAdditionalInput element) {
+ getAdditionalInputList().remove(element);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalDependencies()
+ */
+ public IPath[] getAdditionalDependencies() {
+ List deps = new ArrayList();
+ Iterator typeIter = getAdditionalInputList().iterator();
+ while (typeIter.hasNext()) {
+ AdditionalInput current = (AdditionalInput)typeIter.next();
+ int kind = current.getKind();
+ if (kind == IAdditionalInput.KIND_ADDITIONAL_DEPENDENCY ||
+ kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
+ String[] paths = current.getPaths();
+ if (paths != null) {
+ for (int i = 0; i < paths.length; i++) {
+ if (paths[i].length() > 0) {
+ deps.add(Path.fromOSString(paths[i]));
+ }
+ }
+ }
+ }
+ }
+ return (IPath[])deps.toArray(new IPath[deps.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalResources()
+ */
+ public IPath[] getAdditionalResources() {
+ List ins = new ArrayList();
+ Iterator typeIter = getAdditionalInputList().iterator();
+ while (typeIter.hasNext()) {
+ AdditionalInput current = (AdditionalInput)typeIter.next();
+ int kind = current.getKind();
+ if (kind == IAdditionalInput.KIND_ADDITIONAL_INPUT ||
+ kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
+ String[] paths = current.getPaths();
+ if (paths != null) {
+ for (int i = 0; i < paths.length; i++) {
+ if (paths[i].length() > 0) {
+ ins.add(Path.fromOSString(paths[i]));
+ }
+ }
+ }
+ }
+ }
+ return (IPath[])ins.toArray(new IPath[ins.size()]);
+ }
+
+ /* (non-Javadoc)
+ * Memory-safe way to access the list of input orders
+ */
+ private Vector getInputOrderList() {
+ if (inputOrderList == null) {
+ inputOrderList = new Vector();
+ }
+ return inputOrderList;
+ }
+
+ /* (non-Javadoc)
+ * Memory-safe way to access the list of input orders
+ */
+ private Vector getAdditionalInputList() {
+ if (additionalInputList == null) {
+ additionalInputList = new Vector();
+ }
+ return additionalInputList;
+ }
+
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IInputType#getSuperClass()
+ */
+ public IInputType getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getName()
+ */
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getBuildVariable()
+ */
+ public String getBuildVariable() {
+ if (buildVariable == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getBuildVariable();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return buildVariable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setBuildVariable()
+ */
+ public void setBuildVariable(String variableName) {
+ if (variableName == null && buildVariable == null) return;
+ if (buildVariable == null || variableName == null || !(variableName.equals(buildVariable))) {
+ buildVariable = variableName;
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyContentType()
+ */
+ public IContentType getDependencyContentType() {
+ if (dependencyContentType == null) {
+ if (superClass != null) {
+ return superClass.getDependencyContentType();
+ } else {
+ return null;
+ }
+ }
+ return dependencyContentType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyContentType()
+ */
+ public void setDependencyContentType(IContentType type) {
+ if (dependencyContentType != type) {
+ dependencyContentType = type;
+ if (dependencyContentType != null) {
+ dependencyContentTypeId = dependencyContentType.getId();
+ } else {
+ dependencyContentTypeId = null;
+ }
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensionsAttribute()
+ */
+ public String[] getDependencyExtensionsAttribute() {
+ if (dependencyExtensions == null || dependencyExtensions.size() == 0) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getDependencyExtensionsAttribute();
+ } else {
+ if (dependencyExtensions == null) {
+ dependencyExtensions = new ArrayList();
+ }
+ }
+ }
+ return (String[])dependencyExtensions.toArray(new String[dependencyExtensions.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyExtensionsAttribute()
+ */
+ public void setDependencyExtensionsAttribute(String extensions) {
+ getDependencyExtensionsList().clear();
+ if (extensions != null) {
+ StringTokenizer tokenizer = new StringTokenizer(extensions, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getDependencyExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensions()
+ */
+ public String[] getDependencyExtensions(ITool tool) {
+ // Use content type if specified and registered with Eclipse
+ IContentType type = getDependencyContentType();
+ if (type != null) {
+ String[] exts = ((Tool)tool).getContentTypeFileSpecs(type);
+ // TODO: This is a temporary hack until we decide how to specify the langauge (C vs. C++)
+ // of a .h file. If the content type is the CDT-defined C/C++ content type, then
+ // add "h" to the list if it is not already there.
+ if (type.getId().compareTo("org.eclipse.cdt.core.cxxHeader") == 0) { // $NON-NLS-1$
+ boolean h_found = false;
+ for (int i=0; i<exts.length; i++) {
+ if (exts[i].compareTo("h") == 0) { // $NON-NLS-1$
+ h_found = true;
+ break;
+ }
+ }
+ if (!h_found) {
+ String[] cppexts = new String[exts.length+1];
+ int i = 0;
+ for (; i<exts.length; i++) {
+ cppexts[i] = exts[i];
+ }
+ cppexts[i] = "h"; // $NON-NLS-1$
+ return cppexts;
+ }
+ }
+ return exts;
+ }
+ return getDependencyExtensionsAttribute();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#isDependencyExtension()
+ */
+ public boolean isDependencyExtension(ITool tool, String ext) {
+ String[] exts = getDependencyExtensions(tool);
+ for (int i=0; i<exts.length; i++) {
+ if (ext.equals(exts[i])) return true;
+ }
+ return false;
+ }
+
+ private List getDependencyExtensionsList() {
+ if (dependencyExtensions == null) {
+ dependencyExtensions = new ArrayList();
+ }
+ return dependencyExtensions;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyGenerator()
+ */
+ public IManagedDependencyGeneratorType getDependencyGenerator() {
+ if (dependencyGenerator != null) {
+ return dependencyGenerator;
+ }
+ IConfigurationElement element = getDependencyGeneratorElement();
+ if (element != null) {
+ try {
+ if (element.getAttribute(ITool.DEP_CALC_ID) != null) {
+ dependencyGenerator = (IManagedDependencyGeneratorType) element.createExecutableExtension(ITool.DEP_CALC_ID);
+ return dependencyGenerator;
+ }
+ } catch (CoreException e) {}
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyGeneratorElement()
+ */
+ public IConfigurationElement getDependencyGeneratorElement() {
+ if (dependencyGeneratorElement == null) {
+ if (superClass != null) {
+ return ((InputType)superClass).getDependencyGeneratorElement();
+ }
+ }
+ return dependencyGeneratorElement;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyGeneratorElement()
+ */
+ public void setDependencyGeneratorElement(IConfigurationElement element) {
+ dependencyGeneratorElement = element;
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getMultipleOfType()
+ */
+ public boolean getMultipleOfType() {
+ if (multipleOfType == null) {
+ if (superClass != null) {
+ return superClass.getMultipleOfType();
+ } else {
+ return false; // default is false
+ }
+ }
+ return multipleOfType.booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setMultipleOfType()
+ */
+ public void setMultipleOfType(boolean b) {
+ if (multipleOfType == null || !(b == multipleOfType.booleanValue())) {
+ multipleOfType = new Boolean(b);
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getPrimaryInput()
+ */
+ public boolean getPrimaryInput() {
+ if (primaryInput == null) {
+ if (superClass != null) {
+ return superClass.getPrimaryInput();
+ } else {
+ return false; // default is false
+ }
+ }
+ return primaryInput.booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setMultipleOfType()
+ */
+ public void setPrimaryInput(boolean b) {
+ if (primaryInput == null || !(b == primaryInput.booleanValue())) {
+ primaryInput = new Boolean(b);
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getOptionId()
+ */
+ public String getOptionId() {
+ if (optionId == null) {
+ if (superClass != null) {
+ return superClass.getOptionId();
+ } else {
+ return null;
+ }
+ }
+ return optionId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setOptionId()
+ */
+ public void setOptionId(String id) {
+ if (id == null && optionId == null) return;
+ if (id == null || optionId == null || !(optionId.equals(id))) {
+ optionId = id;
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAssignToOptionId()
+ */
+ public String getAssignToOptionId() {
+ if (assignToOptionId == null) {
+ if (superClass != null) {
+ return superClass.getAssignToOptionId();
+ } else {
+ return null;
+ }
+ }
+ return assignToOptionId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setAssignToOptionId()
+ */
+ public void setAssignToOptionId(String id) {
+ if (id == null && assignToOptionId == null) return;
+ if (id == null || assignToOptionId == null || !(assignToOptionId.equals(id))) {
+ assignToOptionId = id;
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getSourceContentType()
+ */
+ public IContentType getSourceContentType() {
+ if (sourceContentType == null) {
+ if (superClass != null) {
+ return superClass.getSourceContentType();
+ } else {
+ return null;
+ }
+ }
+ return sourceContentType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setSourceContentType()
+ */
+ public void setSourceContentType(IContentType type) {
+ if (sourceContentType != type) {
+ sourceContentType = type;
+ if (sourceContentType != null) {
+ sourceContentTypeId = sourceContentType.getId();
+ } else {
+ sourceContentTypeId = null;
+ }
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getSourceExtensionsAttribute()
+ */
+ public String[] getSourceExtensionsAttribute() {
+ if( (inputExtensions == null) || ( inputExtensions.size() == 0) ) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getSourceExtensionsAttribute();
+ } else {
+ inputExtensions = new ArrayList();
+ }
+ }
+ return (String[])inputExtensions.toArray(new String[inputExtensions.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setSourceExtensionsAttribute()
+ */
+ public void setSourceExtensionsAttribute(String extensions) {
+ getInputExtensionsList().clear();
+ if (extensions != null) {
+ StringTokenizer tokenizer = new StringTokenizer(extensions, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getSourceExtensions()
+ */
+ public String[] getSourceExtensions(ITool tool) {
+ // Use content type if specified and registered with Eclipse
+ IContentType type = getSourceContentType();
+ if (type != null) {
+ return ((Tool)tool).getContentTypeFileSpecs(type);
+ }
+ return getSourceExtensionsAttribute();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#isSourceExtension()
+ */
+ public boolean isSourceExtension(ITool tool, String ext) {
+ String[] exts = getSourceExtensions(tool);
+ for (int i=0; i<exts.length; i++) {
+ if (ext.equals(exts[i])) return true;
+ }
+ return false;
+ }
+
+ private List getInputExtensionsList() {
+ if (inputExtensions == null) {
+ inputExtensions = new ArrayList();
+ }
+ return inputExtensions;
+ }
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IInputType#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionInputType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IInputType#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension InputType
+ if (isExtensionInputType) return false;
+
+ // Check my children
+ Iterator typeIter = getInputOrderList().iterator();
+ while (typeIter.hasNext()) {
+ InputOrder current = (InputOrder)typeIter.next();
+ if (current.isDirty()) return true;
+ }
+ typeIter = getAdditionalInputList().iterator();
+ while (typeIter.hasNext()) {
+ AdditionalInput current = (AdditionalInput)typeIter.next();
+ if (current.isDirty()) return true;
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IInputType#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ // Propagate "false" to the children
+ if (!isDirty) {
+ Iterator typeIter = getInputOrderList().iterator();
+ while (typeIter.hasNext()) {
+ InputOrder current = (InputOrder)typeIter.next();
+ current.setDirty(false);
+ }
+ typeIter = getAdditionalInputList().iterator();
+ while (typeIter.hasNext()) {
+ AdditionalInput current = (AdditionalInput)typeIter.next();
+ current.setDirty(false);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Resolve the element IDs to interface references
+ */
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ // Resolve superClass
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionInputType(superClassId);
+ if (superClass == null) {
+ // Report error
+ ManagedBuildManager.OutputResolveError(
+ "superClass", //$NON-NLS-1$
+ superClassId,
+ "inputType", //$NON-NLS-1$
+ getId());
+ }
+ }
+
+ // Resolve content types
+ IContentTypeManager manager = Platform.getContentTypeManager();
+ if (sourceContentTypeId != null && sourceContentTypeId.length() > 0) {
+ sourceContentType = manager.getContentType(sourceContentTypeId);
+ }
+ if (dependencyContentTypeId != null && dependencyContentTypeId.length() > 0) {
+ dependencyContentType = manager.getContentType(dependencyContentTypeId);
+ }
+
+ // Call resolveReferences on our children
+ Iterator typeIter = getInputOrderList().iterator();
+ while (typeIter.hasNext()) {
+ InputOrder current = (InputOrder)typeIter.next();
+ current.resolveReferences();
+ }
+ typeIter = getAdditionalInputList().iterator();
+ while (typeIter.hasNext()) {
+ AdditionalInput current = (AdditionalInput)typeIter.next();
+ current.resolveReferences();
+ }
+ }
+ }
+
+ /**
+ * @return Returns the managedBuildRevision.
+ */
+ public String getManagedBuildRevision() {
+ if ( managedBuildRevision == null) {
+ if ( getParent() != null) {
+ return getParent().getManagedBuildRevision();
+ }
+ }
+ return managedBuildRevision;
+ }
+
+ /**
+ * @return Returns the version.
+ */
+ public PluginVersionIdentifier getVersion() {
+ if ( version == null) {
+ if ( getParent() != null) {
+ return getParent().getVersion();
+ }
+ }
+ return version;
+ }
+
+ public void setVersion(PluginVersionIdentifier version) {
+ // Do nothing
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
index 8c59f47b8c..d454572a0c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
@@ -1,1473 +1,1473 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.core;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IIncludeEntry;
-import org.eclipse.cdt.core.model.IMacroEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
-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.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
-import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
-import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
-import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- *
- * @since 1.2
- */
-public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
- // The path container used for all managed projects
- public static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$
- private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_CONFIGURATION);
- //private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_TARGET);
- public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
- public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
- private static final String EMPTY_STRING = new String();
-
- private IManagedProject managedProject;
- private ICProject cProject;
- private IConfiguration defaultConfig;
- private String defaultConfigId;
- private boolean isDirty;
- private boolean isValid = false;
- private IResource owner;
- private boolean rebuildNeeded;
- private String version;
- private IConfiguration selectedConfig;
-
- private List targetList;
- private Map targetMap;
-
- private boolean isReadOnly = false;
- private boolean bIsContainerInited = false;
-
-
- /**
- * Basic contructor used when the project is brand new.
- *
- * @param owner
- */
- public ManagedBuildInfo(IResource owner) {
- this.owner = owner;
- cProject = CoreModel.getDefault().create(owner.getProject());
-
- // Does not need a save but should be rebuilt
- isDirty = false;
- rebuildNeeded = true;
-
- // Get the default configs
- IProject project = owner.getProject();
- defaultConfigId = null;
- try {
- defaultConfigId = project.getPersistentProperty(defaultConfigProperty);
- } catch (CoreException e) {
- // Hitting this error just means the default config is not set
- return;
- }
- }
-
- /**
- * Reads the build information from the project file and creates the
- * internal representation of the build settings for the project.
- *
- * @param owner
- * @param element
- * @param managedBuildRevision
- */
- public ManagedBuildInfo(IResource owner, Element element, String managedBuildRevision) {
- this(owner);
-
- // Recreate the managed build project element and its children
- NodeList projNodes = element.getElementsByTagName(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME);
- // TODO: There should only be 1?
- for (int projIndex = projNodes.getLength() - 1; projIndex >= 0; --projIndex) {
- ManagedProject proj = new ManagedProject(this, (Element)projNodes.item(projIndex), managedBuildRevision);
- if (!proj.resolveReferences())
- proj.setValid(false);
- }
-
- // Switch the rebuild off since this is an existing project
- rebuildNeeded = false;
-
- version = managedBuildRevision;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setManagedProject(IManagedProject)
- */
- public void setManagedProject(IManagedProject managedProject) {
- this.managedProject = managedProject;
- //setDirty(true); - It is primarily up to the ManagedProject to maintain the dirty state
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getManagedProject()
- */
- public IManagedProject getManagedProject() {
- return managedProject;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#buildsFileType(java.lang.String)
- */
- public boolean buildsFileType(String srcExt) {
- // Check to see if there is a rule to build a file with this extension
- IConfiguration config = getDefaultConfiguration();
- ITool[] tools = config.getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool != null && tool.buildsFileType(srcExt)) {
- return true;
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getBuildArtifactExtension()
- */
- public String getBuildArtifactExtension() {
- String ext = new String();
- IConfiguration config = getDefaultConfiguration();
- if (config != null) {
- ext = config.getArtifactExtension();
- }
- return ext;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getBuildArtifactName()
- */
- public String getBuildArtifactName() {
- // Get the default configuration and use its value
- String name = new String();
- IConfiguration config = getDefaultConfiguration();
- if (config != null) {
- name = config.getArtifactName();
- }
- return name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
- */
- public String getCleanCommand() {
- // Get from the model
- String command = new String();
- IConfiguration config = getDefaultConfiguration();
- if (config != null) {
- command = config.getCleanCommand();
- }
- return command;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getConfigurationName()
- */
- public String getConfigurationName() {
- // Return the human-readable name of the default configuration
- IConfiguration config = getDefaultConfiguration();
- return config == null ? new String() : config.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getConfigurationNames()
- */
- public String[] getConfigurationNames() {
- ArrayList configNames = new ArrayList();
- IConfiguration[] configs = managedProject.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- IConfiguration configuration = configs[i];
- configNames.add(configuration.getName());
- }
- configNames.trimToSize();
- return (String[])configNames.toArray(new String[configNames.size()]);
- }
-
- public ICProject getCProject() {
- return cProject;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getDefaultConfiguration()
- */
- public IConfiguration getDefaultConfiguration() {
- // Get the default config associated with the project
- if (defaultConfig == null) {
- if (managedProject != null) {
- if (defaultConfigId != null) {
- defaultConfig = managedProject.getConfiguration(defaultConfigId);
- }
- if (defaultConfig == null) {
- IConfiguration[] configs = managedProject.getConfigurations();
- for (int i = 0; i < configs.length; i++){
- if (configs[i].isSupported()){
- defaultConfig = configs[i];
- defaultConfigId = defaultConfig.getId();
- break;
- }
- }
- if (defaultConfig == null && configs.length > 0) {
- defaultConfig = configs[0];
- defaultConfigId = defaultConfig.getId();
- }
- }
- }
- }
- return defaultConfig;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getDefinedSymbols()
- */
- public Map getDefinedSymbols() {
- // Return the defined symbols for the default configuration
- HashMap symbols = getMacroPathEntries();
- return symbols;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getDependencyGenerator(java.lang.String)
- */
- public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension) {
- // Find the tool and ask the Managed Build Manager for its dep generator
- try {
- if (getDefaultConfiguration() != null) {
- ITool[] tools = getDefaultConfiguration().getFilteredTools();
- for (int index = 0; index < tools.length; ++index) {
- if(tools[index].buildsFileType(sourceExtension)) {
- return tools[index].getDependencyGeneratorForExtension(sourceExtension);
- }
- }
- }
- } catch (NullPointerException e) {
- return null;
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * Helper method to extract a list of valid tools that are filtered by the
- * project nature.
- *
- * @return
- */
- private ITool[] getFilteredTools() {
- // Get all the tools for the current config filtered by the project nature
- IConfiguration config = getDefaultConfiguration();
- return config.getFilteredTools();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForSource(java.lang.String)
- */
- public String getFlagsForSource(String extension) {
- return getToolFlagsForSource(extension,null,null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getToolFlagsForSource(java.lang.String, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
- */
- public String getToolFlagsForSource(String extension, IPath inputLocation, IPath outputLocation){
- // Get all the tools for the current config
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool != null && tool.buildsFileType(extension)) {
- try {
- return tool.getToolCommandFlagsString(inputLocation,outputLocation);
- } catch (BuildException e) {
- return null;
- }
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForConfiguration(java.lang.String)
- */
- public String getFlagsForConfiguration(String extension) {
- return getToolFlagsForConfiguration(extension, null, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getToolFlagsForConfiguration(java.lang.String, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
- */
- public String getToolFlagsForConfiguration(String extension, IPath inputLocation, IPath outputLocation){
- // Treat null extensions as an empty string
- String ext = extension == null ? new String() : extension;
-
- // Get all the tools for the current config
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- try {
- return tool.getToolCommandFlagsString(inputLocation,outputLocation);
- } catch (BuildException e) {
- return null;
- }
- }
- }
- return null;
- }
-
- private ArrayList getIncludePathEntries() {
- // Extract the resolved paths from the project (if any)
- ArrayList paths = new ArrayList();
- if (cProject != null) {
- try {
- IPathEntry[] entries = cProject.getResolvedPathEntries();
- for (int index = 0; index < entries.length; ++index) {
- int kind = entries[index].getEntryKind();
- if (kind == IPathEntry.CDT_INCLUDE) {
- IIncludeEntry include = (IIncludeEntry) entries[index];
- if (include.isSystemInclude()) {
- IPath entryPath = include.getFullIncludePath();
- paths.add(entryPath.toString());
- }
- }
- }
- } catch (CModelException e) {
- // Just return an empty array
- paths.clear();
- return paths;
- }
- }
- return paths;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
- */
- public String[] getIncludePaths() {
- // Return the include paths for the default configuration
- ArrayList paths = getIncludePathEntries();
- return (String[])paths.toArray(new String[paths.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForConfiguration(java.lang.String)
- */
- public String[] getLibsForConfiguration(String extension) {
- Vector libs = new Vector();
- ITool tool = getDefaultConfiguration().getTargetTool();
- if(tool == null)
- tool = getToolFromOutputExtension(extension);
-
- if(tool != null){
- IOption[] opts = tool.getOptions();
- // Look for the lib option type
- for (int i = 0; i < opts.length; i++) {
- IOption option = opts[i];
- try {
- if (option.getValueType() == IOption.LIBRARIES) {
-
- // check to see if the option has an applicability calculator
- IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator();
-
- if (applicabilitytCalculator == null
- || applicabilitytCalculator.isOptionUsedInCommandLine(getDefaultConfiguration(), tool, option)) {
- String command = option.getCommand();
- String[] allLibs = option.getLibraries();
- for (int j = 0; j < allLibs.length; j++)
- {
- try {
- String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
- allLibs[j],
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_OPTION,
- new OptionContextData(option, tool));
- if(resolved != null && resolved.length > 0){
- for(int k = 0; k < resolved.length; k++){
- String string = resolved[k];
- if(string.length() > 0)
- libs.add(command + string);
- }
- }
- } catch (BuildMacroException e) {
- // TODO: report error
- continue;
- }
-
- }
- }
- }
- } catch (BuildException e) {
- // TODO: report error
- continue;
- }
- }
- }
- return (String[])libs.toArray(new String[libs.size()]);
- }
-
- private HashMap getMacroPathEntries() {
- HashMap macros = new HashMap();
- if (cProject != null) {
- try {
- IPathEntry[] entries = cProject.getResolvedPathEntries();
- for (int index = 0; index < entries.length; ++index) {
- if (entries[index].getEntryKind() == IPathEntry.CDT_MACRO) {
- IMacroEntry macro = (IMacroEntry) entries[index];
- macros.put(macro.getMacroName(), macro.getMacroValue());
- }
- }
- } catch (CModelException e) {
- // return an empty map
- macros.clear();
- return macros;
- }
-
- }
- return macros;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
- */
- public String getBuildArguments() {
- if (getDefaultConfiguration() != null) {
- IToolChain toolChain = getDefaultConfiguration().getToolChain();
- IBuilder builder = toolChain.getBuilder();
- if (builder != null) {
- return builder.getArguments();
- }
- }
- return new String("-k"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeCommand()
- */
- public String getBuildCommand() {
- if (getDefaultConfiguration() != null) {
- IToolChain toolChain = getDefaultConfiguration().getToolChain();
- IBuilder builder = toolChain.getBuilder();
- if (builder != null) {
- return builder.getCommand();
- }
- }
- return new String("make"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPrebuildStep()
- */
- public String getPrebuildStep() {
- // Get the default configuration and use its value
- String name = new String();
- IConfiguration config = getDefaultConfiguration();
- if (config != null) {
- name = config.getPrebuildStep();
- }
- return name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPostbuildStep()
- */
- public String getPostbuildStep() {
- // Get the default configuration and use its value
- String name = new String();
- IConfiguration config = getDefaultConfiguration();
- if (config != null) {
- name = config.getPostbuildStep();
- }
- return name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPreannouncebuildStep()
- */
- public String getPreannouncebuildStep() {
- // Get the default configuration and use its value
- String name = new String();
- IConfiguration config = getDefaultConfiguration();
- if (config != null) {
- name = config.getPreannouncebuildStep();
- }
- return name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPostannouncebuildStep()
- */
- public String getPostannouncebuildStep() {
- // Get the default configuration and use its value
- String name = new String();
- IConfiguration config = getDefaultConfiguration();
- if (config != null) {
- name = config.getPostannouncebuildStep();
- }
- return name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputExtension(java.lang.String)
- */
- public String getOutputExtension(String resourceExtension) {
- String outputExtension = null;
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- outputExtension = tool.getOutputExtension(resourceExtension);
- if (outputExtension != null) {
- return outputExtension;
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputFlag()
- */
- public String getOutputFlag(String outputExt) {
- // Treat null extension as an empty string
- String ext = outputExt == null ? new String() : outputExt;
-
- // Get all the tools for the current config
- String flags = new String();
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- // It's OK
- if (tool.producesFileType(ext)) {
- flags = tool.getOutputFlag();
- }
- }
- return flags;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputPrefix(java.lang.String)
- */
- public String getOutputPrefix(String outputExtension) {
- // Treat null extensions as empty string
- String ext = outputExtension == null ? new String() : outputExtension;
-
- // Get all the tools for the current config
- String flags = new String();
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- flags = tool.getOutputPrefix();
- }
- }
- return flags;
- }
-
- /**
- * @return
- */
- public IResource getOwner() {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForSource(java.lang.String)
- */
- public String getToolForSource(String sourceExtension) {
- // Get all the tools for the current config
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(sourceExtension)) {
- return tool.getToolCommand();
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForConfiguration(java.lang.String)
- */
- public String getToolForConfiguration(String extension) {
- // Treat a null argument as an empty string
- String ext = extension == null ? new String() : extension;
- // Get all the tools for the current config
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- return tool.getToolCommand();
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromInputExtension(java.lang.String)
- */
- public ITool getToolFromInputExtension(String sourceExtension) {
- // Get all the tools for the current config
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(sourceExtension)) {
- return tool;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromOutputExtension(java.lang.String)
- */
- public ITool getToolFromOutputExtension(String extension) {
- // Treat a null argument as an empty string
- String ext = extension == null ? new String() : extension;
- // Get all the tools for the current config
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- return tool;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#generateCommandLineInfo(java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
- */
- public IManagedCommandLineInfo generateCommandLineInfo(
- String sourceExtension, String[] flags, String outputFlag,
- String outputPrefix, String outputName, String[] inputResources) {
- return generateToolCommandLineInfo( sourceExtension, flags,
- outputFlag, outputPrefix, outputName, inputResources, null, null );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#generateToolCommandLineInfo(java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String, java.lang.String[], org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
- */
- public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
- String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(sourceExtension)) {
- String cmd = tool.getToolCommand();
- //try to resolve the build macros in the tool command
- try{
- String resolvedCommand = null;
-
- if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$
- (outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$
- {
- resolvedCommand = ManagedBuildManager
- .getBuildMacroProvider().resolveValue(
- cmd,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputLocation,
- outputLocation, null,
- tool));
- }
-
- else {
- resolvedCommand = ManagedBuildManager
- .getBuildMacroProvider()
- .resolveValueToMakefileFormat(
- cmd,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(inputLocation,
- outputLocation, null,
- tool));
- }
- if((resolvedCommand = resolvedCommand.trim()).length() > 0)
- cmd = resolvedCommand;
-
- } catch (BuildMacroException e){
- }
-
- IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
- return gen.generateCommandLineInfo( tool, cmd,
- flags, outputFlag, outputPrefix, outputName, inputResources,
- tool.getCommandLinePattern() );
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getUserObjectsForConfiguration(java.lang.String)
- */
- public String[] getUserObjectsForConfiguration(String extension) {
- Vector objs = new Vector();
- ITool tool = getDefaultConfiguration().getTargetTool();
- if(tool == null)
- tool = getToolFromOutputExtension(extension);
-
- if(tool != null){
- IOption[] opts = tool.getOptions();
- // Look for the user object option type
- for (int i = 0; i < opts.length; i++) {
- IOption option = opts[i];
- try {
- if (option.getValueType() == IOption.OBJECTS) {
- String unresolved[] = option.getUserObjects();
- if(unresolved != null && unresolved.length > 0){
- for(int k = 0; k < unresolved.length; k++){
- try {
- String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
- unresolved[k],
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_OPTION,
- new OptionContextData(option, tool));
- if(resolved != null && resolved.length > 0)
- objs.addAll(Arrays.asList(resolved));
- } catch (BuildMacroException e) {
- // TODO: report error
- continue;
- }
- }
- }
- }
- } catch (BuildException e) {
- // TODO: report error
- continue;
- }
- }
- }
- return (String[])objs.toArray(new String[objs.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getVersion()
- */
- public String getVersion() {
- return version;
- }
-
- /* (non-Javadoc)
- *
- */
- public void initializePathEntries() {
- if (!isValid()) return;
- try {
- IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
- CoreModel.setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
- } catch (CModelException e) {
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isDirty()
- */
- public boolean isDirty() {
- // If the info has been flagged dirty, answer true
- if (isDirty) {
- return true;
- }
-
- // Check if the project is dirty
- if (managedProject != null) {
- return managedProject.isDirty();
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isValid()
- */
- public boolean isValid() {
- // If the info has been flagged as valid, answer true
- return isValid;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isReadOnly()
- */
- public boolean isReadOnly(){
- return isReadOnly;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isHeaderFile(java.lang.String)
- */
- public boolean isHeaderFile(String ext) {
- IProject project = (IProject)owner;
-
- // Check to see if there is a rule to build a file with this extension
- IConfiguration config = getDefaultConfiguration();
- ITool[] tools = config.getFilteredTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- try {
- // Make sure the tool is right for the project
- switch (tool.getNatureFilter()) {
- case ITool.FILTER_C:
- if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- return tool.isHeaderFile(ext);
- }
- break;
- case ITool.FILTER_CC:
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- return tool.isHeaderFile(ext);
- }
- break;
- case ITool.FILTER_BOTH:
- return tool.isHeaderFile(ext);
- }
- } catch (CoreException e) {
- continue;
- }
- }
- return false;
- }
-
- /**
- *
- * @return boolean
- */
- public boolean isContainerInited() {
- return bIsContainerInited;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#needsRebuild()
- */
- public boolean needsRebuild() {
- if (rebuildNeeded) return true;
-
- if (getDefaultConfiguration() != null) {
- return getDefaultConfiguration().needsRebuild();
- }
- return false;
- }
-
- /* (non-Javadoc)
- *
- */
- private void persistDefaultConfiguration() {
- // Persist the default configuration
- IProject project = owner.getProject();
- try {
- if(defaultConfigId != null)
- project.setPersistentProperty(defaultConfigProperty, defaultConfigId.toString().trim());
- } catch (CoreException e) {
- // Too bad
- }
- }
-
- /**
- * Write the contents of the build model to the persistent store
- * specified in the argument.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- // Write out the managed build project
-
- if(managedProject != null){
- Element projElement = doc.createElement(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME);
- element.appendChild(projElement);
- managedProject.serialize(doc, projElement);
- }
- else{
- Iterator iter = getTargets().listIterator();
- while (iter.hasNext()) {
- // Get the target
- Target targ = (Target)iter.next();
- // Create an XML element to hold the target settings
- Element targetElement = doc.createElement(ITarget.TARGET_ELEMENT_NAME);
- element.appendChild(targetElement);
- targ.serialize(doc, targetElement);
- }
-// persistDefaultTarget();
- }
-
-
- // Remember the default configuration
- persistDefaultConfiguration();
-
- // I'm clean now
- setDirty(false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public void setDefaultConfiguration(IConfiguration configuration) {
- // TODO: This is probably wrong. I'll bet we don't handle the case where all configs are deleted...
- // But, at least, our UI does not allow the last config to be deleted.
- // Sanity
- if (configuration == null) return;
-
- if (!configuration.equals(getDefaultConfiguration())) {
- // Save it
- defaultConfig = configuration;
- defaultConfigId = configuration.getId();
- // TODO: is this appropriate?
- persistDefaultConfiguration();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setDefaultConfiguration(java.lang.String)
- */
- public boolean setDefaultConfiguration(String configName) {
- if (configName != null) {
- // Look for the configuration with the same name as the argument
- IConfiguration[] configs = managedProject.getConfigurations();
- for (int index = configs.length - 1; index >= 0; --index) {
- IConfiguration config = configs[index];
- if (configName.equalsIgnoreCase(config.getName())) {
- setDefaultConfiguration(config);
- return true;
- }
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- // Reset the dirty status here
- this.isDirty = isDirty;
- // and in the managed project
- if (managedProject != null) {
- managedProject.setDirty(isDirty);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setValid(boolean)
- */
- public void setValid(boolean isValid) {
- // Reset the valid status
- this.isValid = isValid;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setReadOnly(boolean)
- */
- public void setReadOnly(boolean readOnly){
- if(!readOnly && isReadOnly)
- setDirty(true);
- isReadOnly = readOnly;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
- */
- public void setRebuildState(boolean rebuild) {
- // Reset the status here
- rebuildNeeded = rebuild;
- // TODO: Is the appropriate? Should the rebuild state be stored in the project file?
- // and in the managed project
- if (getDefaultConfiguration() != null) {
- getDefaultConfiguration().setRebuildState(rebuild);
- }
- }
-
- /**
- * @param version
- */
- public void setVersion(String version) {
- if (version != null && !version.equals(this.version)) {
- this.version = version;
- //setDirty(true); - It is primarily up to the ManagedProject to maintain the dirty state
- }
- updateRevision(version);
- }
-
- /**
- * @param boolean
- */
- public void setContainerInited(boolean bInited) {
- bIsContainerInited = bInited;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- // Just print out the name of the project
- return "Managed build information for " + owner.getName(); //$NON-NLS-1$
- }
-
- /**
- * Sets the owner of the receiver to be the <code>IResource</code> specified
- * in the argument.
- *
- * @param resource
- */
- public void updateOwner(IResource resource) {
- // Check to see if the owner is the same as the argument
- if (resource != null) {
- if (!owner.equals(resource)) {
- owner = resource;
- // Do the same for the managed project
- managedProject.updateOwner(resource);
- // And finally update the cModelElement
- cProject = CoreModel.getDefault().create(owner.getProject());
-
- // Save everything
- setDirty(true);
- setRebuildState(true);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedConfiguration()
- */
- public IConfiguration getSelectedConfiguration() {
- return selectedConfig;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public void setSelectedConfiguration(IConfiguration config) {
- selectedConfig = config;
- }
-
- /*
- * Note: "Target" routines are only currently applicable when loading a CDT 2.0
- * or earlier managed build project file (.cdtbuild)
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
- */
- public void addTarget(ITarget target) {
- getTargetMap().put(target.getId(), target);
- getTargets().add(target);
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#removeTarget(java.lang.String)
- */
- public void removeTarget(String id) {
- getTargets().remove(getTarget(id));
- getTargetMap().remove(id);
- setDirty(true);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public ITarget getTarget(String id) {
- return (ITarget) getTargetMap().get(id);
- }
-
- /* (non-Javadoc)
- * Safe accessor.
- *
- * @return Returns the map of IDs to ITargets.
- */
- private Map getTargetMap() {
- if (targetMap == null) {
- targetMap = new HashMap();
- }
- return targetMap;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public List getTargets() {
- if (targetList == null) {
- targetList = new ArrayList();
- }
- return targetList;
- }
-
- /**
- *
- * @return
- */
- private String getCWD() {
- String cwd = ""; //$NON-NLS-1$
- IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", getDefaultConfiguration(), false, true); //$NON-NLS-1$
- if (cwdvar != null) { cwd = cwdvar.getValue().replace('\\','/'); } //$NON-NLS-1$ //$NON-NLS-2$
- return cwd;
- }
-
- /**
- */
- private List processPath(List list, String path, int context, Object obj) {
- final String EMPTY = ""; //$NON-NLS-1$
- if (path != null) {
- if (context != 0) {
- try {
- String paths[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValue(path, EMPTY, " ", context, obj); //$NON-NLS-1$
- if (paths != null) {
- for(int i = 0; i < paths.length; i++){
- list.add(checkPath(paths[i]));
- }
- }
- } catch (BuildMacroException e) {
- }
- } else {
- list.add(checkPath(path));
- }
- }
- return list;
- }
-
- private String checkPath(String p){
- final String QUOTE = "\""; //$NON-NLS-1$
- final String EMPTY = ""; //$NON-NLS-1$
-
- if(p == null)
- return EMPTY;
-
- if (p.length()> 1 && p.startsWith(QUOTE) && p.endsWith(QUOTE)) {
- p = p.substring(1, p.length()-1);
- }
-
- if ( ".".equals(p) ) { //$NON-NLS-1$
- String cwd = getCWD();
- if (cwd.length()>0) { p = cwd; }
- }
- if (!(new Path(p)).isAbsolute()) {
- String cwd = getCWD();
- if (cwd.length()>0) { p = cwd + "/" + p; } //$NON-NLS-1$
- }
- return p;
-
- }
-
- /**
- * Obtain all possible Managed build values
- * @return
- */
- public IPathEntry[] getManagedBuildValues() {
- List entries = new ArrayList();
- int i=0;
- IPathEntry[] a = getManagedBuildValues(IPathEntry.CDT_INCLUDE);
- if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
- a = getManagedBuildValues(IPathEntry.CDT_LIBRARY);
- if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
- a = getManagedBuildValues(IPathEntry.CDT_MACRO);
- if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
-
- /**
- * Obtain all possible Managed build built-ins
- * @return
- */
- public IPathEntry[] getManagedBuildBuiltIns() {
- List entries = new ArrayList();
- int i=0;
- IPathEntry[] a = getManagedBuildBuiltIns(IPathEntry.CDT_INCLUDE);
- if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
- a = getManagedBuildBuiltIns(IPathEntry.CDT_LIBRARY);
- if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
- a = getManagedBuildBuiltIns(IPathEntry.CDT_MACRO);
- if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
-
- /**
- *
- * @param entryType
- * @return
- */
- public IPathEntry[] getManagedBuildValues(int entryType) {
- // obtain option values
- List entries = getOptionValues(entryType, false);
-
- // for includes, get env variables values; useless for other entry types
- if (entryType == IPathEntry.CDT_INCLUDE) {
- IEnvironmentVariableProvider env = ManagedBuildManager.getEnvironmentVariableProvider();
- entries = addIncludes(entries, env.getBuildPaths(getDefaultConfiguration(), IEnvVarBuildPath.BUILDPATH_INCLUDE), Path.EMPTY, 0, null);
- }
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
-
- /**
- * @param entryType
- * @return
- */
- public IPathEntry[] getManagedBuildBuiltIns(int entryType) {
- List entries = getOptionValues(entryType, true);
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
-
- /**
- *
- * @param entryType - data type to be scanned for
- * @param builtIns - return either values or built-in's
- * @return list of strings which contains all found values
- */
- private List getOptionValues(int entryType, boolean builtIns) {
- List entries = new ArrayList();
- IConfiguration cfg = getDefaultConfiguration();
-
- // process config toolchain's options
- entries = readToolsOptions(
- entryType,
- entries,
- builtIns,
- cfg);
-
-
- // code below (obtaining of resource config values)
- // is now commented because resource-related include
- // paths are displayed by UI together with config-
- // related includes, so paths are duplicated in
- // project's "includes" folder.
- //
- // Uncomment following code after UI problem fix.
-/*
- // process resource configurations
- IResourceConfiguration[] rescfgs = cfg.getResourceConfigurations();
- if (rescfgs != null) {
- for (int i=0; i<rescfgs.length; i++) {
- entries = readToolsOptions(
- entryType,
- entries,
- builtIns,
- rescfgs[i]);
- }
- }
-*/
- return entries;
- }
-
- /**
- *
- * @param optionType - data type: include | library | symbols
- * @param entries - list to be affected
- * @param builtIns - whether get actual values or builtins
- * @param obj - object to be processed (ResCfg | Cfg)
- */
- private List readToolsOptions(int entryType, List entries, boolean builtIns, IBuildObject obj) {
- ITool[] t = null;
- IPath resPath = Path.EMPTY;
-
- // check that entryType is correct
- if (entryType != IPathEntry.CDT_INCLUDE &&
-//TODO: we need to implement the proper CDT_LIBRARY handling
-//calculating the CDT_LIBRARY entries from the managed build
-//options is disabled for now, we need to define a new option type
-//that will represent library paths
-//see bug# 100844
-// entryType != IPathEntry.CDT_LIBRARY &&
- entryType != IPathEntry.CDT_MACRO) { return entries; }
-
- // calculate parameters depending of object type
- if (obj instanceof IResourceConfiguration) {
- resPath = new Path(((IResourceConfiguration)obj).getResourcePath()).removeFirstSegments(1);
- t = ((IResourceConfiguration)obj).getToolsToInvoke();
- } else if (obj instanceof IConfiguration) {
- t = ((IConfiguration)obj).getFilteredTools();
- } else { return entries; } // wrong object passed
- if (t == null) { return entries; }
-
- // process all tools and all their options
- for (int i=0; i<t.length; i++) {
- IOption[] op = t[i].getOptions();
- for (int j=0; j<op.length; j++) {
-
- // check to see if the option has an applicability calculator
- IOptionApplicability applicabilityCalculator = op[j].getApplicabilityCalculator();
- if (applicabilityCalculator != null &&
- !applicabilityCalculator.isOptionUsedInCommandLine(obj, t[i], op[j])) continue;
-
- try {
- if (entryType == IPathEntry.CDT_INCLUDE &&
- op[j].getValueType() == IOption.INCLUDE_PATH)
- {
- OptionContextData ocd = new OptionContextData(op[j], t[i]);
- addIncludes(entries, builtIns ? op[j].getBuiltIns() : op[j].getIncludePaths(), resPath, IBuildMacroProvider.CONTEXT_OPTION, ocd);
- } else if (entryType == IPathEntry.CDT_LIBRARY &&
- op[j].getValueType() == IOption.LIBRARIES)
- {
- OptionContextData ocd = new OptionContextData(op[j], t[i]);
- addLibraries(entries, builtIns ? op[j].getBuiltIns() : op[j].getLibraries(), resPath, IBuildMacroProvider.CONTEXT_OPTION, ocd);
- } else if (entryType == IPathEntry.CDT_MACRO &&
- op[j].getValueType() == IOption.PREPROCESSOR_SYMBOLS)
- {
- OptionContextData ocd = new OptionContextData(op[j], t[i]);
- addSymbols(entries, builtIns ? op[j].getBuiltIns() : op[j].getDefinedSymbols(), resPath, IBuildMacroProvider.CONTEXT_OPTION, ocd);
- } else { continue; }
- } catch (BuildException e) {}
- }
- }
- return entries;
- }
-
- /**
- *
- * @param entries
- * @param values
- * @param resPath
- * @param ocd
- */
- protected List addIncludes(List entries, String[] values, IPath resPath, int context ,Object obj) {
- return addPaths(entries, values, resPath, context, obj, IPathEntry.CDT_INCLUDE);
- }
-
- protected List addPaths(List entries, String[] values, IPath resPath, int context ,Object obj, int type){
- if (values != null && values.length > 0) {
- List list = new ArrayList();
- for (int k=0; k<values.length; k++) {
- processPath(list, values[k], context, obj);
- }
-
- Iterator iter = list.iterator();
- while(iter.hasNext()){
- IPathEntry entry = null;
- switch(type){
- case IPathEntry.CDT_INCLUDE:
- entry = CoreModel.newIncludeEntry(resPath, Path.EMPTY, new Path((String)iter.next()), true);
- break;
- case IPathEntry.CDT_LIBRARY:
- entry = CoreModel.newLibraryEntry(resPath, Path.EMPTY, new Path((String)iter.next()), null, null, null, true);
- break;
- }
- if (entry != null && !entries.contains(entry)) { entries.add(entry); }
- }
- }
- return entries;
- }
-
- /**
- *
- * @param entries
- * @param values
- * @param resPath
- * @param ocd
- */
- protected List addLibraries(List entries, String[] values, IPath resPath, int context, Object obj) {
- return addPaths(entries, values, resPath, context, obj, IPathEntry.CDT_LIBRARY);
- }
-
- /**
- *
- * @param entries
- * @param values
- * @param resPath
- */
- protected List addSymbols(List entries, String[] values, IPath resPath, int context, Object obj) {
- if (values == null) return entries;
- for (int i=0; i<values.length; i++) {
- try {
- String res[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValue(values[i],
- "", " ", context, obj); //$NON-NLS-1$ //$NON-NLS-2$
- if(res != null){
- for(int k = 0; k < res.length; k++)
- createMacroEntry(entries, res[k], resPath);
- }
- } catch (BuildMacroException e) {
- }
- }
- return entries;
- }
-
- private List createMacroEntry(List entries, String val, IPath resPath){
- if (val != null && val.length() != 0){
-
- String[] tokens = val.split("="); //$NON-NLS-1$
- String key = tokens[0].trim();
- String value = (tokens.length > 1) ? tokens[1].trim() : new String();
- // Make sure the current entries do not contain a duplicate
- boolean add = true;
- Iterator entryIter = entries.listIterator();
- while (entryIter.hasNext()) {
- IPathEntry entry = (IPathEntry) entryIter.next();
- if (entry.getEntryKind() == IPathEntry.CDT_MACRO) {
- if (((IMacroEntry)entry).getMacroName().equals(key) &&
- ((IMacroEntry)entry).getMacroValue().equals(value)) {
- add = false;
- break;
- }
- }
- }
- if (add) { entries.add(CoreModel.newMacroEntry(resPath, key, value)); }
- }
- return entries;
- }
-
- public void updateRevision(String revision){
- if(managedProject != null)
- ((ManagedProject)managedProject).updateManagedBuildRevision(revision);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 IBM Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IIncludeEntry;
+import org.eclipse.cdt.core.model.IMacroEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IPathEntryContainer;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
+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.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
+import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
+import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
+import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
+import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
+import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
+import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @since 1.2
+ */
+public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
+ // The path container used for all managed projects
+ public static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$
+ private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_CONFIGURATION);
+ //private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_TARGET);
+ public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
+ public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
+ private static final String EMPTY_STRING = new String();
+
+ private IManagedProject managedProject;
+ private ICProject cProject;
+ private IConfiguration defaultConfig;
+ private String defaultConfigId;
+ private boolean isDirty;
+ private boolean isValid = false;
+ private IResource owner;
+ private boolean rebuildNeeded;
+ private String version;
+ private IConfiguration selectedConfig;
+
+ private List targetList;
+ private Map targetMap;
+
+ private boolean isReadOnly = false;
+ private boolean bIsContainerInited = false;
+
+
+ /**
+ * Basic contructor used when the project is brand new.
+ *
+ * @param owner
+ */
+ public ManagedBuildInfo(IResource owner) {
+ this.owner = owner;
+ cProject = CoreModel.getDefault().create(owner.getProject());
+
+ // Does not need a save but should be rebuilt
+ isDirty = false;
+ rebuildNeeded = true;
+
+ // Get the default configs
+ IProject project = owner.getProject();
+ defaultConfigId = null;
+ try {
+ defaultConfigId = project.getPersistentProperty(defaultConfigProperty);
+ } catch (CoreException e) {
+ // Hitting this error just means the default config is not set
+ return;
+ }
+ }
+
+ /**
+ * Reads the build information from the project file and creates the
+ * internal representation of the build settings for the project.
+ *
+ * @param owner
+ * @param element
+ * @param managedBuildRevision
+ */
+ public ManagedBuildInfo(IResource owner, Element element, String managedBuildRevision) {
+ this(owner);
+
+ // Recreate the managed build project element and its children
+ NodeList projNodes = element.getElementsByTagName(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME);
+ // TODO: There should only be 1?
+ for (int projIndex = projNodes.getLength() - 1; projIndex >= 0; --projIndex) {
+ ManagedProject proj = new ManagedProject(this, (Element)projNodes.item(projIndex), managedBuildRevision);
+ if (!proj.resolveReferences())
+ proj.setValid(false);
+ }
+
+ // Switch the rebuild off since this is an existing project
+ rebuildNeeded = false;
+
+ version = managedBuildRevision;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setManagedProject(IManagedProject)
+ */
+ public void setManagedProject(IManagedProject managedProject) {
+ this.managedProject = managedProject;
+ //setDirty(true); - It is primarily up to the ManagedProject to maintain the dirty state
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getManagedProject()
+ */
+ public IManagedProject getManagedProject() {
+ return managedProject;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#buildsFileType(java.lang.String)
+ */
+ public boolean buildsFileType(String srcExt) {
+ // Check to see if there is a rule to build a file with this extension
+ IConfiguration config = getDefaultConfiguration();
+ ITool[] tools = config.getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool != null && tool.buildsFileType(srcExt)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getBuildArtifactExtension()
+ */
+ public String getBuildArtifactExtension() {
+ String ext = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ ext = config.getArtifactExtension();
+ }
+ return ext;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getBuildArtifactName()
+ */
+ public String getBuildArtifactName() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getArtifactName();
+ }
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
+ */
+ public String getCleanCommand() {
+ // Get from the model
+ String command = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ command = config.getCleanCommand();
+ }
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getConfigurationName()
+ */
+ public String getConfigurationName() {
+ // Return the human-readable name of the default configuration
+ IConfiguration config = getDefaultConfiguration();
+ return config == null ? new String() : config.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getConfigurationNames()
+ */
+ public String[] getConfigurationNames() {
+ ArrayList configNames = new ArrayList();
+ IConfiguration[] configs = managedProject.getConfigurations();
+ for (int i = 0; i < configs.length; i++) {
+ IConfiguration configuration = configs[i];
+ configNames.add(configuration.getName());
+ }
+ configNames.trimToSize();
+ return (String[])configNames.toArray(new String[configNames.size()]);
+ }
+
+ public ICProject getCProject() {
+ return cProject;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getDefaultConfiguration()
+ */
+ public IConfiguration getDefaultConfiguration() {
+ // Get the default config associated with the project
+ if (defaultConfig == null) {
+ if (managedProject != null) {
+ if (defaultConfigId != null) {
+ defaultConfig = managedProject.getConfiguration(defaultConfigId);
+ }
+ if (defaultConfig == null) {
+ IConfiguration[] configs = managedProject.getConfigurations();
+ for (int i = 0; i < configs.length; i++){
+ if (configs[i].isSupported()){
+ defaultConfig = configs[i];
+ defaultConfigId = defaultConfig.getId();
+ break;
+ }
+ }
+ if (defaultConfig == null && configs.length > 0) {
+ defaultConfig = configs[0];
+ defaultConfigId = defaultConfig.getId();
+ }
+ }
+ }
+ }
+ return defaultConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getDefinedSymbols()
+ */
+ public Map getDefinedSymbols() {
+ // Return the defined symbols for the default configuration
+ HashMap symbols = getMacroPathEntries();
+ return symbols;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getDependencyGenerator(java.lang.String)
+ */
+ public IManagedDependencyGeneratorType getDependencyGenerator(String sourceExtension) {
+ // Find the tool and ask the Managed Build Manager for its dep generator
+ try {
+ if (getDefaultConfiguration() != null) {
+ ITool[] tools = getDefaultConfiguration().getFilteredTools();
+ for (int index = 0; index < tools.length; ++index) {
+ if(tools[index].buildsFileType(sourceExtension)) {
+ return tools[index].getDependencyGeneratorForExtension(sourceExtension);
+ }
+ }
+ }
+ } catch (NullPointerException e) {
+ return null;
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * Helper method to extract a list of valid tools that are filtered by the
+ * project nature.
+ *
+ * @return
+ */
+ private ITool[] getFilteredTools() {
+ // Get all the tools for the current config filtered by the project nature
+ IConfiguration config = getDefaultConfiguration();
+ return config.getFilteredTools();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForSource(java.lang.String)
+ */
+ public String getFlagsForSource(String extension) {
+ return getToolFlagsForSource(extension,null,null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getToolFlagsForSource(java.lang.String, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
+ */
+ public String getToolFlagsForSource(String extension, IPath inputLocation, IPath outputLocation){
+ // Get all the tools for the current config
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool != null && tool.buildsFileType(extension)) {
+ try {
+ return tool.getToolCommandFlagsString(inputLocation,outputLocation);
+ } catch (BuildException e) {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForConfiguration(java.lang.String)
+ */
+ public String getFlagsForConfiguration(String extension) {
+ return getToolFlagsForConfiguration(extension, null, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getToolFlagsForConfiguration(java.lang.String, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
+ */
+ public String getToolFlagsForConfiguration(String extension, IPath inputLocation, IPath outputLocation){
+ // Treat null extensions as an empty string
+ String ext = extension == null ? new String() : extension;
+
+ // Get all the tools for the current config
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(ext)) {
+ try {
+ return tool.getToolCommandFlagsString(inputLocation,outputLocation);
+ } catch (BuildException e) {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ private ArrayList getIncludePathEntries() {
+ // Extract the resolved paths from the project (if any)
+ ArrayList paths = new ArrayList();
+ if (cProject != null) {
+ try {
+ IPathEntry[] entries = cProject.getResolvedPathEntries();
+ for (int index = 0; index < entries.length; ++index) {
+ int kind = entries[index].getEntryKind();
+ if (kind == IPathEntry.CDT_INCLUDE) {
+ IIncludeEntry include = (IIncludeEntry) entries[index];
+ if (include.isSystemInclude()) {
+ IPath entryPath = include.getFullIncludePath();
+ paths.add(entryPath.toString());
+ }
+ }
+ }
+ } catch (CModelException e) {
+ // Just return an empty array
+ paths.clear();
+ return paths;
+ }
+ }
+ return paths;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
+ */
+ public String[] getIncludePaths() {
+ // Return the include paths for the default configuration
+ ArrayList paths = getIncludePathEntries();
+ return (String[])paths.toArray(new String[paths.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForConfiguration(java.lang.String)
+ */
+ public String[] getLibsForConfiguration(String extension) {
+ Vector libs = new Vector();
+ ITool tool = getDefaultConfiguration().getTargetTool();
+ if(tool == null)
+ tool = getToolFromOutputExtension(extension);
+
+ if(tool != null){
+ IOption[] opts = tool.getOptions();
+ // Look for the lib option type
+ for (int i = 0; i < opts.length; i++) {
+ IOption option = opts[i];
+ try {
+ if (option.getValueType() == IOption.LIBRARIES) {
+
+ // check to see if the option has an applicability calculator
+ IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator();
+
+ if (applicabilitytCalculator == null
+ || applicabilitytCalculator.isOptionUsedInCommandLine(getDefaultConfiguration(), tool, option)) {
+ String command = option.getCommand();
+ String[] allLibs = option.getLibraries();
+ for (int j = 0; j < allLibs.length; j++)
+ {
+ try {
+ String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
+ allLibs[j],
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_OPTION,
+ new OptionContextData(option, tool));
+ if(resolved != null && resolved.length > 0){
+ for(int k = 0; k < resolved.length; k++){
+ String string = resolved[k];
+ if(string.length() > 0)
+ libs.add(command + string);
+ }
+ }
+ } catch (BuildMacroException e) {
+ // TODO: report error
+ continue;
+ }
+
+ }
+ }
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ continue;
+ }
+ }
+ }
+ return (String[])libs.toArray(new String[libs.size()]);
+ }
+
+ private HashMap getMacroPathEntries() {
+ HashMap macros = new HashMap();
+ if (cProject != null) {
+ try {
+ IPathEntry[] entries = cProject.getResolvedPathEntries();
+ for (int index = 0; index < entries.length; ++index) {
+ if (entries[index].getEntryKind() == IPathEntry.CDT_MACRO) {
+ IMacroEntry macro = (IMacroEntry) entries[index];
+ macros.put(macro.getMacroName(), macro.getMacroValue());
+ }
+ }
+ } catch (CModelException e) {
+ // return an empty map
+ macros.clear();
+ return macros;
+ }
+
+ }
+ return macros;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
+ */
+ public String getBuildArguments() {
+ if (getDefaultConfiguration() != null) {
+ IToolChain toolChain = getDefaultConfiguration().getToolChain();
+ IBuilder builder = toolChain.getBuilder();
+ if (builder != null) {
+ return builder.getArguments();
+ }
+ }
+ return new String("-k"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeCommand()
+ */
+ public String getBuildCommand() {
+ if (getDefaultConfiguration() != null) {
+ IToolChain toolChain = getDefaultConfiguration().getToolChain();
+ IBuilder builder = toolChain.getBuilder();
+ if (builder != null) {
+ return builder.getCommand();
+ }
+ }
+ return new String("make"); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPrebuildStep()
+ */
+ public String getPrebuildStep() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getPrebuildStep();
+ }
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPostbuildStep()
+ */
+ public String getPostbuildStep() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getPostbuildStep();
+ }
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPreannouncebuildStep()
+ */
+ public String getPreannouncebuildStep() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getPreannouncebuildStep();
+ }
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getPostannouncebuildStep()
+ */
+ public String getPostannouncebuildStep() {
+ // Get the default configuration and use its value
+ String name = new String();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getPostannouncebuildStep();
+ }
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputExtension(java.lang.String)
+ */
+ public String getOutputExtension(String resourceExtension) {
+ String outputExtension = null;
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ outputExtension = tool.getOutputExtension(resourceExtension);
+ if (outputExtension != null) {
+ return outputExtension;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputFlag()
+ */
+ public String getOutputFlag(String outputExt) {
+ // Treat null extension as an empty string
+ String ext = outputExt == null ? new String() : outputExt;
+
+ // Get all the tools for the current config
+ String flags = new String();
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ // It's OK
+ if (tool.producesFileType(ext)) {
+ flags = tool.getOutputFlag();
+ }
+ }
+ return flags;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputPrefix(java.lang.String)
+ */
+ public String getOutputPrefix(String outputExtension) {
+ // Treat null extensions as empty string
+ String ext = outputExtension == null ? new String() : outputExtension;
+
+ // Get all the tools for the current config
+ String flags = new String();
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(ext)) {
+ flags = tool.getOutputPrefix();
+ }
+ }
+ return flags;
+ }
+
+ /**
+ * @return
+ */
+ public IResource getOwner() {
+ return owner;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForSource(java.lang.String)
+ */
+ public String getToolForSource(String sourceExtension) {
+ // Get all the tools for the current config
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(sourceExtension)) {
+ return tool.getToolCommand();
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForConfiguration(java.lang.String)
+ */
+ public String getToolForConfiguration(String extension) {
+ // Treat a null argument as an empty string
+ String ext = extension == null ? new String() : extension;
+ // Get all the tools for the current config
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(ext)) {
+ return tool.getToolCommand();
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromInputExtension(java.lang.String)
+ */
+ public ITool getToolFromInputExtension(String sourceExtension) {
+ // Get all the tools for the current config
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(sourceExtension)) {
+ return tool;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFromOutputExtension(java.lang.String)
+ */
+ public ITool getToolFromOutputExtension(String extension) {
+ // Treat a null argument as an empty string
+ String ext = extension == null ? new String() : extension;
+ // Get all the tools for the current config
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(ext)) {
+ return tool;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#generateCommandLineInfo(java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
+ */
+ public IManagedCommandLineInfo generateCommandLineInfo(
+ String sourceExtension, String[] flags, String outputFlag,
+ String outputPrefix, String outputName, String[] inputResources) {
+ return generateToolCommandLineInfo( sourceExtension, flags,
+ outputFlag, outputPrefix, outputName, inputResources, null, null );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#generateToolCommandLineInfo(java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String, java.lang.String[], org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
+ */
+ public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
+ String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(sourceExtension)) {
+ String cmd = tool.getToolCommand();
+ //try to resolve the build macros in the tool command
+ try{
+ String resolvedCommand = null;
+
+ if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$
+ (outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$
+ {
+ resolvedCommand = ManagedBuildManager
+ .getBuildMacroProvider().resolveValue(
+ cmd,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputLocation,
+ outputLocation, null,
+ tool));
+ }
+
+ else {
+ resolvedCommand = ManagedBuildManager
+ .getBuildMacroProvider()
+ .resolveValueToMakefileFormat(
+ cmd,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(inputLocation,
+ outputLocation, null,
+ tool));
+ }
+ if((resolvedCommand = resolvedCommand.trim()).length() > 0)
+ cmd = resolvedCommand;
+
+ } catch (BuildMacroException e){
+ }
+
+ IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
+ return gen.generateCommandLineInfo( tool, cmd,
+ flags, outputFlag, outputPrefix, outputName, inputResources,
+ tool.getCommandLinePattern() );
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getUserObjectsForConfiguration(java.lang.String)
+ */
+ public String[] getUserObjectsForConfiguration(String extension) {
+ Vector objs = new Vector();
+ ITool tool = getDefaultConfiguration().getTargetTool();
+ if(tool == null)
+ tool = getToolFromOutputExtension(extension);
+
+ if(tool != null){
+ IOption[] opts = tool.getOptions();
+ // Look for the user object option type
+ for (int i = 0; i < opts.length; i++) {
+ IOption option = opts[i];
+ try {
+ if (option.getValueType() == IOption.OBJECTS) {
+ String unresolved[] = option.getUserObjects();
+ if(unresolved != null && unresolved.length > 0){
+ for(int k = 0; k < unresolved.length; k++){
+ try {
+ String resolved[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValueToMakefileFormat(
+ unresolved[k],
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_OPTION,
+ new OptionContextData(option, tool));
+ if(resolved != null && resolved.length > 0)
+ objs.addAll(Arrays.asList(resolved));
+ } catch (BuildMacroException e) {
+ // TODO: report error
+ continue;
+ }
+ }
+ }
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ continue;
+ }
+ }
+ }
+ return (String[])objs.toArray(new String[objs.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getVersion()
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /* (non-Javadoc)
+ *
+ */
+ public void initializePathEntries() {
+ if (!isValid()) return;
+ try {
+ IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
+ CoreModel.setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
+ } catch (CModelException e) {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isDirty()
+ */
+ public boolean isDirty() {
+ // If the info has been flagged dirty, answer true
+ if (isDirty) {
+ return true;
+ }
+
+ // Check if the project is dirty
+ if (managedProject != null) {
+ return managedProject.isDirty();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isValid()
+ */
+ public boolean isValid() {
+ // If the info has been flagged as valid, answer true
+ return isValid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isReadOnly()
+ */
+ public boolean isReadOnly(){
+ return isReadOnly;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isHeaderFile(java.lang.String)
+ */
+ public boolean isHeaderFile(String ext) {
+ IProject project = (IProject)owner;
+
+ // Check to see if there is a rule to build a file with this extension
+ IConfiguration config = getDefaultConfiguration();
+ ITool[] tools = config.getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ try {
+ // Make sure the tool is right for the project
+ switch (tool.getNatureFilter()) {
+ case ITool.FILTER_C:
+ if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ return tool.isHeaderFile(ext);
+ }
+ break;
+ case ITool.FILTER_CC:
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ return tool.isHeaderFile(ext);
+ }
+ break;
+ case ITool.FILTER_BOTH:
+ return tool.isHeaderFile(ext);
+ }
+ } catch (CoreException e) {
+ continue;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @return boolean
+ */
+ public boolean isContainerInited() {
+ return bIsContainerInited;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#needsRebuild()
+ */
+ public boolean needsRebuild() {
+ if (rebuildNeeded) return true;
+
+ if (getDefaultConfiguration() != null) {
+ return getDefaultConfiguration().needsRebuild();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ *
+ */
+ private void persistDefaultConfiguration() {
+ // Persist the default configuration
+ IProject project = owner.getProject();
+ try {
+ if(defaultConfigId != null)
+ project.setPersistentProperty(defaultConfigProperty, defaultConfigId.toString().trim());
+ } catch (CoreException e) {
+ // Too bad
+ }
+ }
+
+ /**
+ * Write the contents of the build model to the persistent store
+ * specified in the argument.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ // Write out the managed build project
+
+ if(managedProject != null){
+ Element projElement = doc.createElement(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME);
+ element.appendChild(projElement);
+ managedProject.serialize(doc, projElement);
+ }
+ else{
+ Iterator iter = getTargets().listIterator();
+ while (iter.hasNext()) {
+ // Get the target
+ Target targ = (Target)iter.next();
+ // Create an XML element to hold the target settings
+ Element targetElement = doc.createElement(ITarget.TARGET_ELEMENT_NAME);
+ element.appendChild(targetElement);
+ targ.serialize(doc, targetElement);
+ }
+// persistDefaultTarget();
+ }
+
+
+ // Remember the default configuration
+ persistDefaultConfiguration();
+
+ // I'm clean now
+ setDirty(false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public void setDefaultConfiguration(IConfiguration configuration) {
+ // TODO: This is probably wrong. I'll bet we don't handle the case where all configs are deleted...
+ // But, at least, our UI does not allow the last config to be deleted.
+ // Sanity
+ if (configuration == null) return;
+
+ if (!configuration.equals(getDefaultConfiguration())) {
+ // Save it
+ defaultConfig = configuration;
+ defaultConfigId = configuration.getId();
+ // TODO: is this appropriate?
+ persistDefaultConfiguration();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setDefaultConfiguration(java.lang.String)
+ */
+ public boolean setDefaultConfiguration(String configName) {
+ if (configName != null) {
+ // Look for the configuration with the same name as the argument
+ IConfiguration[] configs = managedProject.getConfigurations();
+ for (int index = configs.length - 1; index >= 0; --index) {
+ IConfiguration config = configs[index];
+ if (configName.equalsIgnoreCase(config.getName())) {
+ setDefaultConfiguration(config);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ // Reset the dirty status here
+ this.isDirty = isDirty;
+ // and in the managed project
+ if (managedProject != null) {
+ managedProject.setDirty(isDirty);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setValid(boolean)
+ */
+ public void setValid(boolean isValid) {
+ // Reset the valid status
+ this.isValid = isValid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setReadOnly(boolean)
+ */
+ public void setReadOnly(boolean readOnly){
+ if(!readOnly && isReadOnly)
+ setDirty(true);
+ isReadOnly = readOnly;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
+ */
+ public void setRebuildState(boolean rebuild) {
+ // Reset the status here
+ rebuildNeeded = rebuild;
+ // TODO: Is the appropriate? Should the rebuild state be stored in the project file?
+ // and in the managed project
+ if (getDefaultConfiguration() != null) {
+ getDefaultConfiguration().setRebuildState(rebuild);
+ }
+ }
+
+ /**
+ * @param version
+ */
+ public void setVersion(String version) {
+ if (version != null && !version.equals(this.version)) {
+ this.version = version;
+ //setDirty(true); - It is primarily up to the ManagedProject to maintain the dirty state
+ }
+ updateRevision(version);
+ }
+
+ /**
+ * @param boolean
+ */
+ public void setContainerInited(boolean bInited) {
+ bIsContainerInited = bInited;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ // Just print out the name of the project
+ return "Managed build information for " + owner.getName(); //$NON-NLS-1$
+ }
+
+ /**
+ * Sets the owner of the receiver to be the <code>IResource</code> specified
+ * in the argument.
+ *
+ * @param resource
+ */
+ public void updateOwner(IResource resource) {
+ // Check to see if the owner is the same as the argument
+ if (resource != null) {
+ if (!owner.equals(resource)) {
+ owner = resource;
+ // Do the same for the managed project
+ managedProject.updateOwner(resource);
+ // And finally update the cModelElement
+ cProject = CoreModel.getDefault().create(owner.getProject());
+
+ // Save everything
+ setDirty(true);
+ setRebuildState(true);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedConfiguration()
+ */
+ public IConfiguration getSelectedConfiguration() {
+ return selectedConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public void setSelectedConfiguration(IConfiguration config) {
+ selectedConfig = config;
+ }
+
+ /*
+ * Note: "Target" routines are only currently applicable when loading a CDT 2.0
+ * or earlier managed build project file (.cdtbuild)
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
+ */
+ public void addTarget(ITarget target) {
+ getTargetMap().put(target.getId(), target);
+ getTargets().add(target);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#removeTarget(java.lang.String)
+ */
+ public void removeTarget(String id) {
+ getTargets().remove(getTarget(id));
+ getTargetMap().remove(id);
+ setDirty(true);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public ITarget getTarget(String id) {
+ return (ITarget) getTargetMap().get(id);
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor.
+ *
+ * @return Returns the map of IDs to ITargets.
+ */
+ private Map getTargetMap() {
+ if (targetMap == null) {
+ targetMap = new HashMap();
+ }
+ return targetMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public List getTargets() {
+ if (targetList == null) {
+ targetList = new ArrayList();
+ }
+ return targetList;
+ }
+
+ /**
+ *
+ * @return
+ */
+ private String getCWD() {
+ String cwd = ""; //$NON-NLS-1$
+ IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", getDefaultConfiguration(), false, true); //$NON-NLS-1$
+ if (cwdvar != null) { cwd = cwdvar.getValue().replace('\\','/'); } //$NON-NLS-1$ //$NON-NLS-2$
+ return cwd;
+ }
+
+ /**
+ */
+ private List processPath(List list, String path, int context, Object obj) {
+ final String EMPTY = ""; //$NON-NLS-1$
+ if (path != null) {
+ if (context != 0) {
+ try {
+ String paths[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValue(path, EMPTY, " ", context, obj); //$NON-NLS-1$
+ if (paths != null) {
+ for(int i = 0; i < paths.length; i++){
+ list.add(checkPath(paths[i]));
+ }
+ }
+ } catch (BuildMacroException e) {
+ }
+ } else {
+ list.add(checkPath(path));
+ }
+ }
+ return list;
+ }
+
+ private String checkPath(String p){
+ final String QUOTE = "\""; //$NON-NLS-1$
+ final String EMPTY = ""; //$NON-NLS-1$
+
+ if(p == null)
+ return EMPTY;
+
+ if (p.length()> 1 && p.startsWith(QUOTE) && p.endsWith(QUOTE)) {
+ p = p.substring(1, p.length()-1);
+ }
+
+ if ( ".".equals(p) ) { //$NON-NLS-1$
+ String cwd = getCWD();
+ if (cwd.length()>0) { p = cwd; }
+ }
+ if (!(new Path(p)).isAbsolute()) {
+ String cwd = getCWD();
+ if (cwd.length()>0) { p = cwd + "/" + p; } //$NON-NLS-1$
+ }
+ return p;
+
+ }
+
+ /**
+ * Obtain all possible Managed build values
+ * @return
+ */
+ public IPathEntry[] getManagedBuildValues() {
+ List entries = new ArrayList();
+ int i=0;
+ IPathEntry[] a = getManagedBuildValues(IPathEntry.CDT_INCLUDE);
+ if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
+ a = getManagedBuildValues(IPathEntry.CDT_LIBRARY);
+ if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
+ a = getManagedBuildValues(IPathEntry.CDT_MACRO);
+ if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
+ return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
+ }
+
+ /**
+ * Obtain all possible Managed build built-ins
+ * @return
+ */
+ public IPathEntry[] getManagedBuildBuiltIns() {
+ List entries = new ArrayList();
+ int i=0;
+ IPathEntry[] a = getManagedBuildBuiltIns(IPathEntry.CDT_INCLUDE);
+ if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
+ a = getManagedBuildBuiltIns(IPathEntry.CDT_LIBRARY);
+ if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
+ a = getManagedBuildBuiltIns(IPathEntry.CDT_MACRO);
+ if (a != null) { for (i=0; i<a.length; i++) entries.add(a[i]); }
+ return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
+ }
+
+ /**
+ *
+ * @param entryType
+ * @return
+ */
+ public IPathEntry[] getManagedBuildValues(int entryType) {
+ // obtain option values
+ List entries = getOptionValues(entryType, false);
+
+ // for includes, get env variables values; useless for other entry types
+ if (entryType == IPathEntry.CDT_INCLUDE) {
+ IEnvironmentVariableProvider env = ManagedBuildManager.getEnvironmentVariableProvider();
+ entries = addIncludes(entries, env.getBuildPaths(getDefaultConfiguration(), IEnvVarBuildPath.BUILDPATH_INCLUDE), Path.EMPTY, 0, null);
+ }
+ return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
+ }
+
+ /**
+ * @param entryType
+ * @return
+ */
+ public IPathEntry[] getManagedBuildBuiltIns(int entryType) {
+ List entries = getOptionValues(entryType, true);
+ return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
+ }
+
+ /**
+ *
+ * @param entryType - data type to be scanned for
+ * @param builtIns - return either values or built-in's
+ * @return list of strings which contains all found values
+ */
+ private List getOptionValues(int entryType, boolean builtIns) {
+ List entries = new ArrayList();
+ IConfiguration cfg = getDefaultConfiguration();
+
+ // process config toolchain's options
+ entries = readToolsOptions(
+ entryType,
+ entries,
+ builtIns,
+ cfg);
+
+
+ // code below (obtaining of resource config values)
+ // is now commented because resource-related include
+ // paths are displayed by UI together with config-
+ // related includes, so paths are duplicated in
+ // project's "includes" folder.
+ //
+ // Uncomment following code after UI problem fix.
+/*
+ // process resource configurations
+ IResourceConfiguration[] rescfgs = cfg.getResourceConfigurations();
+ if (rescfgs != null) {
+ for (int i=0; i<rescfgs.length; i++) {
+ entries = readToolsOptions(
+ entryType,
+ entries,
+ builtIns,
+ rescfgs[i]);
+ }
+ }
+*/
+ return entries;
+ }
+
+ /**
+ *
+ * @param optionType - data type: include | library | symbols
+ * @param entries - list to be affected
+ * @param builtIns - whether get actual values or builtins
+ * @param obj - object to be processed (ResCfg | Cfg)
+ */
+ private List readToolsOptions(int entryType, List entries, boolean builtIns, IBuildObject obj) {
+ ITool[] t = null;
+ IPath resPath = Path.EMPTY;
+
+ // check that entryType is correct
+ if (entryType != IPathEntry.CDT_INCLUDE &&
+//TODO: we need to implement the proper CDT_LIBRARY handling
+//calculating the CDT_LIBRARY entries from the managed build
+//options is disabled for now, we need to define a new option type
+//that will represent library paths
+//see bug# 100844
+// entryType != IPathEntry.CDT_LIBRARY &&
+ entryType != IPathEntry.CDT_MACRO) { return entries; }
+
+ // calculate parameters depending of object type
+ if (obj instanceof IResourceConfiguration) {
+ resPath = new Path(((IResourceConfiguration)obj).getResourcePath()).removeFirstSegments(1);
+ t = ((IResourceConfiguration)obj).getToolsToInvoke();
+ } else if (obj instanceof IConfiguration) {
+ t = ((IConfiguration)obj).getFilteredTools();
+ } else { return entries; } // wrong object passed
+ if (t == null) { return entries; }
+
+ // process all tools and all their options
+ for (int i=0; i<t.length; i++) {
+ IOption[] op = t[i].getOptions();
+ for (int j=0; j<op.length; j++) {
+
+ // check to see if the option has an applicability calculator
+ IOptionApplicability applicabilityCalculator = op[j].getApplicabilityCalculator();
+ if (applicabilityCalculator != null &&
+ !applicabilityCalculator.isOptionUsedInCommandLine(obj, t[i], op[j])) continue;
+
+ try {
+ if (entryType == IPathEntry.CDT_INCLUDE &&
+ op[j].getValueType() == IOption.INCLUDE_PATH)
+ {
+ OptionContextData ocd = new OptionContextData(op[j], t[i]);
+ addIncludes(entries, builtIns ? op[j].getBuiltIns() : op[j].getIncludePaths(), resPath, IBuildMacroProvider.CONTEXT_OPTION, ocd);
+ } else if (entryType == IPathEntry.CDT_LIBRARY &&
+ op[j].getValueType() == IOption.LIBRARIES)
+ {
+ OptionContextData ocd = new OptionContextData(op[j], t[i]);
+ addLibraries(entries, builtIns ? op[j].getBuiltIns() : op[j].getLibraries(), resPath, IBuildMacroProvider.CONTEXT_OPTION, ocd);
+ } else if (entryType == IPathEntry.CDT_MACRO &&
+ op[j].getValueType() == IOption.PREPROCESSOR_SYMBOLS)
+ {
+ OptionContextData ocd = new OptionContextData(op[j], t[i]);
+ addSymbols(entries, builtIns ? op[j].getBuiltIns() : op[j].getDefinedSymbols(), resPath, IBuildMacroProvider.CONTEXT_OPTION, ocd);
+ } else { continue; }
+ } catch (BuildException e) {}
+ }
+ }
+ return entries;
+ }
+
+ /**
+ *
+ * @param entries
+ * @param values
+ * @param resPath
+ * @param ocd
+ */
+ protected List addIncludes(List entries, String[] values, IPath resPath, int context ,Object obj) {
+ return addPaths(entries, values, resPath, context, obj, IPathEntry.CDT_INCLUDE);
+ }
+
+ protected List addPaths(List entries, String[] values, IPath resPath, int context ,Object obj, int type){
+ if (values != null && values.length > 0) {
+ List list = new ArrayList();
+ for (int k=0; k<values.length; k++) {
+ processPath(list, values[k], context, obj);
+ }
+
+ Iterator iter = list.iterator();
+ while(iter.hasNext()){
+ IPathEntry entry = null;
+ switch(type){
+ case IPathEntry.CDT_INCLUDE:
+ entry = CoreModel.newIncludeEntry(resPath, Path.EMPTY, new Path((String)iter.next()), true);
+ break;
+ case IPathEntry.CDT_LIBRARY:
+ entry = CoreModel.newLibraryEntry(resPath, Path.EMPTY, new Path((String)iter.next()), null, null, null, true);
+ break;
+ }
+ if (entry != null && !entries.contains(entry)) { entries.add(entry); }
+ }
+ }
+ return entries;
+ }
+
+ /**
+ *
+ * @param entries
+ * @param values
+ * @param resPath
+ * @param ocd
+ */
+ protected List addLibraries(List entries, String[] values, IPath resPath, int context, Object obj) {
+ return addPaths(entries, values, resPath, context, obj, IPathEntry.CDT_LIBRARY);
+ }
+
+ /**
+ *
+ * @param entries
+ * @param values
+ * @param resPath
+ */
+ protected List addSymbols(List entries, String[] values, IPath resPath, int context, Object obj) {
+ if (values == null) return entries;
+ for (int i=0; i<values.length; i++) {
+ try {
+ String res[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValue(values[i],
+ "", " ", context, obj); //$NON-NLS-1$ //$NON-NLS-2$
+ if(res != null){
+ for(int k = 0; k < res.length; k++)
+ createMacroEntry(entries, res[k], resPath);
+ }
+ } catch (BuildMacroException e) {
+ }
+ }
+ return entries;
+ }
+
+ private List createMacroEntry(List entries, String val, IPath resPath){
+ if (val != null && val.length() != 0){
+
+ String[] tokens = val.split("="); //$NON-NLS-1$
+ String key = tokens[0].trim();
+ String value = (tokens.length > 1) ? tokens[1].trim() : new String();
+ // Make sure the current entries do not contain a duplicate
+ boolean add = true;
+ Iterator entryIter = entries.listIterator();
+ while (entryIter.hasNext()) {
+ IPathEntry entry = (IPathEntry) entryIter.next();
+ if (entry.getEntryKind() == IPathEntry.CDT_MACRO) {
+ if (((IMacroEntry)entry).getMacroName().equals(key) &&
+ ((IMacroEntry)entry).getMacroValue().equals(value)) {
+ add = false;
+ break;
+ }
+ }
+ }
+ if (add) { entries.add(CoreModel.newMacroEntry(resPath, key, value)); }
+ }
+ return entries;
+ }
+
+ public void updateRevision(String revision){
+ if(managedProject != null)
+ ((ManagedProject)managedProject).updateManagedBuildRevision(revision);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
index ff3b433773..1d3d52488e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java
@@ -1,524 +1,535 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-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.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
-import org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment;
-import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class ManagedProject extends BuildObject implements IManagedProject {
-
- private static final String EMPTY_STRING = new String();
- private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
-
- // Parent and children
- private IProjectType projectType;
- private String projectTypeId;
- private IResource owner;
- private List configList; // Configurations of this project type
- private Map configMap;
- // Miscellaneous
- private boolean isDirty = false;
- private boolean isValid = true;
- private boolean resolved = true;
- //holds the user-defined macros
- private StorableMacros userDefinedMacros;
- //holds user-defined environment
- private StorableEnvironment userDefinedEnvironment;
- /*
- * C O N S T R U C T O R S
- */
-
- /* (non-Javadoc)
- * Sets the Eclipse project that owns the Managed Project
- *
- * @param owner
- */
- protected ManagedProject(IResource owner) {
- this.owner = owner;
- }
-
- /**
- * Create a project instance from the project-type specified in the argument,
- * that is owned by the specified Eclipse project.
- *
- * @param owner the Eclipse project that owns the Managed Project
- * @param projectType
- */
- public ManagedProject(IResource owner, IProjectType projectType) {
- // Make the owner of the ProjectType the project resource
- this(owner);
-
- // Copy the parent's identity
- this.projectType = projectType;
- int id = ManagedBuildManager.getRandomNumber();
- setId(owner.getName() + "." + projectType.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
- setName(projectType.getName());
-
- setManagedBuildRevision(projectType.getManagedBuildRevision());
-
- // Hook me up
- IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
- buildInfo.setManagedProject(this);
- setDirty(true);
- }
-
- /**
- * Create the project instance from project file.
- *
- * @param buildInfo
- * @param element
- * @param managedBuildRevision the fileVersion of Managed Build System
- */
- public ManagedProject(ManagedBuildInfo buildInfo, Element element, String managedBuildRevision) {
- this(buildInfo.getOwner());
-
- setManagedBuildRevision(managedBuildRevision);
-
- // Initialize from the XML attributes
- if (loadFromProject(element)) {
-
- // check for migration support.
- boolean isSupportAvailable = projectType.checkForMigrationSupport();
- if (isSupportAvailable == false) {
- setValid(false);
- }
-
- // Load children
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
- Configuration config = new Configuration(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
- //load user-defined macros
- userDefinedMacros = new StorableMacros((Element)configElement);
- }
-
- }
- } else {
- setValid(false);
- }
-
- // hook me up
- buildInfo.setManagedProject(this);
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /* (non-Javadoc)
- * Initialize the project information from the XML element
- * specified in the argument
- *
- * @param element An XML element containing the project information
- */
- protected boolean loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // name
- if (element.hasAttribute(IBuildObject.NAME)) {
- setName(element.getAttribute(IBuildObject.NAME));
- }
-
- // projectType
- projectTypeId = element.getAttribute(PROJECTTYPE);
- if (projectTypeId != null && projectTypeId.length() > 0) {
- projectType = ManagedBuildManager.getExtensionProjectType(projectTypeId);
- if (projectType == null) {
- return false;
- }
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#serialize()
- */
- public void serialize(Document doc, Element element) {
- element.setAttribute(IBuildObject.ID, id);
-
- if (name != null) {
- element.setAttribute(IBuildObject.NAME, name);
- }
-
- if (projectType != null) {
- element.setAttribute(PROJECTTYPE, projectType.getId());
- }
-
- // Serialize my children
- List configElements = getConfigurationList();
- Iterator iter = configElements.listIterator();
- while (iter.hasNext()) {
- Configuration config = (Configuration) iter.next();
- Element configElement = doc.createElement(IConfiguration.CONFIGURATION_ELEMENT_NAME);
- element.appendChild(configElement);
- config.serialize(doc, configElement);
- }
-
- //serialize user-defined macros
- if(userDefinedMacros != null){
- Element macrosElement = doc.createElement(StorableMacros.MACROS_ELEMENT_NAME);
- element.appendChild(macrosElement);
- userDefinedMacros.serialize(doc,macrosElement);
- }
-
- if(userDefinedEnvironment != null){
- EnvironmentVariableProvider.fUserSupplier.storeEnvironment(this,true);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /*
- * P A R E N T A N D C H I L D H A N D L I N G
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#getOwner()
- */
- public IResource getOwner() {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#updateOwner(org.eclipse.core.resources.IResource)
- */
- public void updateOwner(IResource resource) {
- if (!resource.equals(owner)) {
- // Set the owner correctly
- owner = resource;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#getProjectType()
- */
- public IProjectType getProjectType() {
- return projectType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public IConfiguration createConfiguration(IConfiguration parent, String id) {
- Configuration config = new Configuration(this, (Configuration)parent, id, false, false);
- ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
- return (IConfiguration)config;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfigurationClone(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public IConfiguration createConfigurationClone(IConfiguration parent, String id) {
- Configuration config = new Configuration(this, (Configuration)parent, id, true, false);
- // Inform all options in the configuration and all its resource configurations
- ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
- return (IConfiguration)config;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedProject#getConfiguration()
- */
- public IConfiguration getConfiguration(String id) {
- return (IConfiguration)getConfigurationMap().get(id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#getConfigurations()
- */
- public IConfiguration[] getConfigurations() {
- IConfiguration[] configs = new IConfiguration[getConfigurationList().size()];
- Iterator iter = getConfigurationList().listIterator();
- int i = 0;
- while (iter.hasNext()) {
- Configuration config = (Configuration)iter.next();
- configs[i++] = (IConfiguration)config;
- }
- return configs;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#removeConfiguration(java.lang.String)
- */
- public void removeConfiguration(String id) {
- final String removeId = id;
-
- //handle the case of temporary configuration
- if(getConfigurationMap().get(id) == null)
- return;
-
- IWorkspaceRunnable remover = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- // Remove the specified configuration from the list and map
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- IConfiguration config = (IConfiguration)iter.next();
- if (config.getId().equals(removeId)) {
- // TODO: For now we clean the entire project. This may be overkill, but
- // it avoids a problem with leaving the configuration output directory
- // around and having the outputs try to be used by the makefile generator code.
- IResource proj = config.getOwner();
- IManagedBuildInfo info = null;
- if (proj instanceof IProject) {
- info = ManagedBuildManager.getBuildInfo(proj);
- }
- IConfiguration currentConfig = null;
- boolean isCurrent = true;
- if (info != null) {
- currentConfig = info.getDefaultConfiguration();
- if (!currentConfig.getId().equals(removeId)) {
- info.setDefaultConfiguration(config);
- isCurrent = false;
- }
- }
- ((IProject)proj).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
-
- ManagedBuildManager.performValueHandlerEvent(config,
- IManagedOptionValueHandler.EVENT_CLOSE);
- getConfigurationList().remove(config);
- getConfigurationMap().remove(removeId);
-
- if (info != null) {
- if (!isCurrent) {
- info.setDefaultConfiguration(currentConfig);
- } else {
- // If the current default config is the one being removed, reset the default config
- String[] configs = info.getConfigurationNames();
- if (configs.length > 0) {
- info.setDefaultConfiguration(configs[0]);
- }
- }
- }
- break;
- }
- }
- }
- };
- try {
- ResourcesPlugin.getWorkspace().run( remover, null );
- }
- catch( CoreException e ) {}
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * Adds the Configuration to the Configuration list and map
- *
- * @param Tool
- */
- public void addConfiguration(Configuration configuration) {
- if(!configuration.isTemporary()){
- getConfigurationList().add(configuration);
- getConfigurationMap().put(configuration.getId(), configuration);
- }
- }
-
- /* (non-Javadoc)
- * Safe accessor for the list of configurations.
- *
- * @return List containing the configurations
- */
- private List getConfigurationList() {
- if (configList == null) {
- configList = new ArrayList();
- }
- return configList;
- }
-
- /* (non-Javadoc)
- * Safe accessor for the map of configuration ids to configurations
- *
- * @return
- */
- private Map getConfigurationMap() {
- if (configMap == null) {
- configMap = new HashMap();
- }
- return configMap;
- }
-
- /*
- * M O D E L A T T R I B U T E A C C E S S O R S
- */
-
- /*
- * O B J E C T S T A T E M A I N T E N A N C E
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#(getDefaultArtifactName)
- */
- public String getDefaultArtifactName(){
- String name = new String();
- // Check for spaces
- String[] tokens = getOwner().getName().split("\\s"); //$NON-NLS-1$
- for (int index = 0; index < tokens.length; ++index) {
- name += tokens[index];
- }
- return name;
- }
-
- /* (non-Javadoc)
- * Resolve the element IDs to interface references
- */
- public boolean resolveReferences() {
- if (!resolved) {
- resolved = true;
- // Resolve project-type
- if (projectTypeId != null && projectTypeId.length() > 0) {
- projectType = ManagedBuildManager.getExtensionProjectType(projectTypeId);
- if (projectType == null) {
- return false;
- }
- }
-
- // call resolve references on any children
- Iterator configIter = getConfigurationList().iterator();
- while (configIter.hasNext()) {
- Configuration current = (Configuration)configIter.next();
- current.resolveReferences();
- }
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#isDirty()
- */
- public boolean isDirty() {
- // If I need saving, just say yes
- if (isDirty) return true;
-
- //check whether the project - specific macros are dirty
- if(userDefinedMacros != null && userDefinedMacros.isDirty())
- return true;
-
- //check whether the project - specific environment is dirty
- if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
- return true;
-
-
- // Otherwise see if any configurations need saving
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- Configuration current = (Configuration) iter.next();
- if (current.isDirty()) return true;
- }
-
- return isDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- this.isDirty = isDirty;
- // Propagate "false" to the children
- if (!isDirty) {
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- Configuration current = (Configuration) iter.next();
- current.setDirty(false);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#isValid()
- */
- public boolean isValid() {
- // TODO: In the future, children could also have a "valid" state that should be checked
- return isValid;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#setValid(boolean)
- */
- public void setValid(boolean isValid) {
- // TODO: In the future, children could also have a "valid" state...
- this.isValid = isValid;
- }
-
- /**
- * @return Returns the version.
- */
- public PluginVersionIdentifier getVersion() {
- if (version == null) {
- if ( getProjectType() != null) {
- return getProjectType().getVersion();
- }
- }
- return version;
- }
-
- public void setVersion(PluginVersionIdentifier version) {
- // Do nothing
- }
-
- /*
- * this method is called by the UserDefinedMacroSupplier to obtain user-defined
- * macros available for this managed project
- */
- public StorableMacros getUserDefinedMacros(){
- if(userDefinedMacros == null)
- userDefinedMacros = new StorableMacros();
- return userDefinedMacros;
- }
-
- public StorableEnvironment getUserDefinedEnvironmet(){
- return userDefinedEnvironment;
- }
-
- public void setUserDefinedEnvironmet(StorableEnvironment env){
- userDefinedEnvironment = env;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
- */
- public void updateManagedBuildRevision(String revision){
- super.updateManagedBuildRevision(revision);
- for(Iterator iter = getConfigurationList().iterator(); iter.hasNext();){
- Configuration cfg = (Configuration)iter.next();
- cfg.updateManagedBuildRevision(revision);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 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.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+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.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
+import org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment;
+import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ManagedProject extends BuildObject implements IManagedProject {
+
+ private static final String EMPTY_STRING = new String();
+ private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
+
+ // Parent and children
+ private IProjectType projectType;
+ private String projectTypeId;
+ private IResource owner;
+ private List configList; // Configurations of this project type
+ private Map configMap;
+ // Miscellaneous
+ private boolean isDirty = false;
+ private boolean isValid = true;
+ private boolean resolved = true;
+ //holds the user-defined macros
+ private StorableMacros userDefinedMacros;
+ //holds user-defined environment
+ private StorableEnvironment userDefinedEnvironment;
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /* (non-Javadoc)
+ * Sets the Eclipse project that owns the Managed Project
+ *
+ * @param owner
+ */
+ protected ManagedProject(IResource owner) {
+ this.owner = owner;
+ }
+
+ /**
+ * Create a project instance from the project-type specified in the argument,
+ * that is owned by the specified Eclipse project.
+ *
+ * @param owner the Eclipse project that owns the Managed Project
+ * @param projectType
+ */
+ public ManagedProject(IResource owner, IProjectType projectType) {
+ // Make the owner of the ProjectType the project resource
+ this(owner);
+
+ // Copy the parent's identity
+ this.projectType = projectType;
+ int id = ManagedBuildManager.getRandomNumber();
+ setId(owner.getName() + "." + projectType.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
+ setName(projectType.getName());
+
+ setManagedBuildRevision(projectType.getManagedBuildRevision());
+
+ // Hook me up
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
+ buildInfo.setManagedProject(this);
+ setDirty(true);
+ }
+
+ /**
+ * Create the project instance from project file.
+ *
+ * @param buildInfo
+ * @param element
+ * @param managedBuildRevision the fileVersion of Managed Build System
+ */
+ public ManagedProject(ManagedBuildInfo buildInfo, Element element, String managedBuildRevision) {
+ this(buildInfo.getOwner());
+
+ setManagedBuildRevision(managedBuildRevision);
+
+ // Initialize from the XML attributes
+ if (loadFromProject(element)) {
+
+ // check for migration support.
+ boolean isSupportAvailable = projectType.checkForMigrationSupport();
+ if (isSupportAvailable == false) {
+ setValid(false);
+ }
+
+ // Load children
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
+ Configuration config = new Configuration(this, (Element)configElement, managedBuildRevision);
+ }else if (configElement.getNodeName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
+ //load user-defined macros
+ userDefinedMacros = new StorableMacros((Element)configElement);
+ }
+
+ }
+ } else {
+ setValid(false);
+ }
+
+ // hook me up
+ buildInfo.setManagedProject(this);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Initialize the project information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the project information
+ */
+ protected boolean loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // projectType
+ projectTypeId = element.getAttribute(PROJECTTYPE);
+ if (projectTypeId != null && projectTypeId.length() > 0) {
+ projectType = ManagedBuildManager.getExtensionProjectType(projectTypeId);
+ if (projectType == null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#serialize()
+ */
+ public void serialize(Document doc, Element element) {
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (projectType != null) {
+ element.setAttribute(PROJECTTYPE, projectType.getId());
+ }
+
+ // Serialize my children
+ List configElements = getConfigurationList();
+ Iterator iter = configElements.listIterator();
+ while (iter.hasNext()) {
+ Configuration config = (Configuration) iter.next();
+ Element configElement = doc.createElement(IConfiguration.CONFIGURATION_ELEMENT_NAME);
+ element.appendChild(configElement);
+ config.serialize(doc, configElement);
+ }
+
+ //serialize user-defined macros
+ if(userDefinedMacros != null){
+ Element macrosElement = doc.createElement(StorableMacros.MACROS_ELEMENT_NAME);
+ element.appendChild(macrosElement);
+ userDefinedMacros.serialize(doc,macrosElement);
+ }
+
+ if(userDefinedEnvironment != null){
+ EnvironmentVariableProvider.fUserSupplier.storeEnvironment(this,true);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#getOwner()
+ */
+ public IResource getOwner() {
+ return owner;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#updateOwner(org.eclipse.core.resources.IResource)
+ */
+ public void updateOwner(IResource resource) {
+ if (!resource.equals(owner)) {
+ // Set the owner correctly
+ owner = resource;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#getProjectType()
+ */
+ public IProjectType getProjectType() {
+ return projectType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public IConfiguration createConfiguration(IConfiguration parent, String id) {
+ Configuration config = new Configuration(this, (Configuration)parent, id, false, false);
+ ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
+ return (IConfiguration)config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfigurationClone(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public IConfiguration createConfigurationClone(IConfiguration parent, String id) {
+ Configuration config = new Configuration(this, (Configuration)parent, id, true, false);
+ // Inform all options in the configuration and all its resource configurations
+ ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
+ return (IConfiguration)config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedProject#getConfiguration()
+ */
+ public IConfiguration getConfiguration(String id) {
+ return (IConfiguration)getConfigurationMap().get(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#getConfigurations()
+ */
+ public IConfiguration[] getConfigurations() {
+ IConfiguration[] configs = new IConfiguration[getConfigurationList().size()];
+ Iterator iter = getConfigurationList().listIterator();
+ int i = 0;
+ while (iter.hasNext()) {
+ Configuration config = (Configuration)iter.next();
+ configs[i++] = (IConfiguration)config;
+ }
+ return configs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#removeConfiguration(java.lang.String)
+ */
+ public void removeConfiguration(String id) {
+ final String removeId = id;
+
+ //handle the case of temporary configuration
+ if(getConfigurationMap().get(id) == null)
+ return;
+
+ IWorkspaceRunnable remover = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ // Remove the specified configuration from the list and map
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ IConfiguration config = (IConfiguration)iter.next();
+ if (config.getId().equals(removeId)) {
+ // TODO: For now we clean the entire project. This may be overkill, but
+ // it avoids a problem with leaving the configuration output directory
+ // around and having the outputs try to be used by the makefile generator code.
+ IResource proj = config.getOwner();
+ IManagedBuildInfo info = null;
+ if (proj instanceof IProject) {
+ info = ManagedBuildManager.getBuildInfo(proj);
+ }
+ IConfiguration currentConfig = null;
+ boolean isCurrent = true;
+ if (info != null) {
+ currentConfig = info.getDefaultConfiguration();
+ if (!currentConfig.getId().equals(removeId)) {
+ info.setDefaultConfiguration(config);
+ isCurrent = false;
+ }
+ }
+ ((IProject)proj).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
+
+ ManagedBuildManager.performValueHandlerEvent(config,
+ IManagedOptionValueHandler.EVENT_CLOSE);
+ getConfigurationList().remove(config);
+ getConfigurationMap().remove(removeId);
+
+ if (info != null) {
+ if (!isCurrent) {
+ info.setDefaultConfiguration(currentConfig);
+ } else {
+ // If the current default config is the one being removed, reset the default config
+ String[] configs = info.getConfigurationNames();
+ if (configs.length > 0) {
+ info.setDefaultConfiguration(configs[0]);
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run( remover, null );
+ }
+ catch( CoreException e ) {}
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * Adds the Configuration to the Configuration list and map
+ *
+ * @param Tool
+ */
+ public void addConfiguration(Configuration configuration) {
+ if(!configuration.isTemporary()){
+ getConfigurationList().add(configuration);
+ getConfigurationMap().put(configuration.getId(), configuration);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the list of configurations.
+ *
+ * @return List containing the configurations
+ */
+ private List getConfigurationList() {
+ if (configList == null) {
+ configList = new ArrayList();
+ }
+ return configList;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of configuration ids to configurations
+ *
+ * @return
+ */
+ public Map getConfigurationMap() {
+ if (configMap == null) {
+ configMap = new HashMap();
+ }
+ return configMap;
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#(getDefaultArtifactName)
+ */
+ public String getDefaultArtifactName(){
+ String name = new String();
+ // Check for spaces
+ String[] tokens = getOwner().getName().split("\\s"); //$NON-NLS-1$
+ for (int index = 0; index < tokens.length; ++index) {
+ name += tokens[index];
+ }
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * Resolve the element IDs to interface references
+ */
+ public boolean resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ // Resolve project-type
+ if (projectTypeId != null && projectTypeId.length() > 0) {
+ projectType = ManagedBuildManager.getExtensionProjectType(projectTypeId);
+ if (projectType == null) {
+ return false;
+ }
+ }
+
+ // call resolve references on any children
+ Iterator configIter = getConfigurationList().iterator();
+ while (configIter.hasNext()) {
+ Configuration current = (Configuration)configIter.next();
+ current.resolveReferences();
+ }
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#isDirty()
+ */
+ public boolean isDirty() {
+ // If I need saving, just say yes
+ if (isDirty) return true;
+
+ //check whether the project - specific macros are dirty
+ if(userDefinedMacros != null && userDefinedMacros.isDirty())
+ return true;
+
+ //check whether the project - specific environment is dirty
+ if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
+ return true;
+
+
+ // Otherwise see if any configurations need saving
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ Configuration current = (Configuration) iter.next();
+ if (current.isDirty()) return true;
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ // Propagate "false" to the children
+ if (!isDirty) {
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ Configuration current = (Configuration) iter.next();
+ current.setDirty(false);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#isValid()
+ */
+ public boolean isValid() {
+ // TODO: In the future, children could also have a "valid" state that should be checked
+ return isValid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#setValid(boolean)
+ */
+ public void setValid(boolean isValid) {
+ // TODO: In the future, children could also have a "valid" state...
+ this.isValid = isValid;
+ }
+
+ /**
+ * @return Returns the version.
+ */
+ public PluginVersionIdentifier getVersion() {
+ if (version == null) {
+ if ( getProjectType() != null) {
+ return getProjectType().getVersion();
+ }
+ }
+ return version;
+ }
+
+ public void setVersion(PluginVersionIdentifier version) {
+ // Do nothing
+ }
+
+ /*
+ * this method is called by the UserDefinedMacroSupplier to obtain user-defined
+ * macros available for this managed project
+ */
+ public StorableMacros getUserDefinedMacros(){
+ if(userDefinedMacros == null)
+ userDefinedMacros = new StorableMacros();
+ return userDefinedMacros;
+ }
+
+ public StorableEnvironment getUserDefinedEnvironmet(){
+ return userDefinedEnvironment;
+ }
+
+ public void setUserDefinedEnvironmet(StorableEnvironment env){
+ userDefinedEnvironment = env;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
+ */
+ public void updateManagedBuildRevision(String revision){
+ super.updateManagedBuildRevision(revision);
+ for(Iterator iter = getConfigurationList().iterator(); iter.hasNext();){
+ Configuration cfg = (Configuration)iter.next();
+ cfg.updateManagedBuildRevision(revision);
+ }
+ }
+
+ public void setProjectType(IProjectType projectType) {
+ if ( this.projectType != projectType ) {
+ this.projectType = projectType;
+ if ( this.projectType == null) {
+ projectTypeId = null;
+ } else {
+ projectTypeId = this.projectType.getId();
+ }
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
index 334f35e861..b64fb0af33 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
@@ -1,1853 +1,1867 @@
-/*******************************************************************************
- * Copyright (c) 2003, 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
- * ARM Ltd. - basic tooltip support
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.core;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
-import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler;
-import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class Option extends BuildObject implements IOption {
- // Static default return values
- private static final String EMPTY_STRING = new String();
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- // Superclass
- private IOption superClass;
- private String superClassId;
- // Parent and children
- private IHoldsOptions holder;
- // Managed Build model attributes
- private String unusedChildren;
- private Integer browseType;
- private List builtIns;
- private IOptionCategory category;
- private String categoryId;
- private String command;
- private String commandFalse;
- private String tip;
- private List enumList;
- private Map enumCommands;
- private Map enumNames;
- private Object value;
- private Object defaultValue;
- private Integer valueType;
- private Boolean isAbstract;
- private Integer resourceFilter;
- private IConfigurationElement valueHandlerElement = null;
- private IManagedOptionValueHandler valueHandler = null;
- private String valueHandlerExtraArgument;
- private IConfigurationElement applicabilityCalculatorElement = null;
- private IOptionApplicability applicabilityCalculator = null;
- private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator = null;
- // Miscellaneous
- private boolean isExtensionOption = false;
- private boolean isDirty = false;
- private boolean resolved = true;
- private boolean verified = false;
- private boolean isValid = true; /** False for options which are invalid. getOption()
- * routines will ignore invalid options. */
- private boolean wasOptRef = false; /** True for options which are created because of an
- * MBS 2.0 model OptionReference element
- */
- private boolean isUdjusted = false;
-
- /*
- * C O N S T R U C T O R S
- */
-
- /**
- * This constructor is called to create an option defined by an extension point in
- * a plugin manifest file, or returned by a dynamic element provider
- *
- * @param parent The IHoldsOptions parent of this option, or <code>null</code> if
- * defined at the top level
- * @param element The option definition from the manifest file or a dynamic element
- * provider
- */
- public Option(IHoldsOptions parent, IManagedConfigElement element) {
- this.holder = parent;
- isExtensionOption = true;
-
- // setup for resolving
- resolved = false;
-
- loadFromManifest(element);
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionOption(this);
- }
-
- /**
- * This constructor is called to create an Option whose attributes and children will be
- * added by separate calls.
- *
- * @param IHoldsOptions The parent of the option, if any
- * @param Option The superClass, if any
- * @param String The id for the new option
- * @param String The name for the new option
- * @param boolean Indicates whether this is an extension element or a managed project element
- */
- public Option(IHoldsOptions parent, IOption superClass, String Id, String name, boolean isExtensionElement) {
- this.holder = parent;
- this.superClass = superClass;
- if (this.superClass != null) {
- superClassId = this.superClass.getId();
- }
- setId(Id);
- setName(name);
- isExtensionOption = isExtensionElement;
- if (isExtensionElement) {
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionOption(this);
- } else {
- setDirty(true);
- }
- }
-
- /**
- * Create an <code>Option</code> based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param parent The <code>IHoldsOptions</code> the option will be added to.
- * @param element The XML element that contains the option settings.
- */
- public Option(IHoldsOptions parent, Element element) {
- this.holder = parent;
- isExtensionOption = false;
-
- // Initialize from the XML attributes
- loadFromProject(element);
- }
-
- /**
- * Create an <code>Option</code> based upon an existing option.
- *
- * @param parent The <code>IHoldsOptions</code> the option will be added to.
- * @param Id New ID for the option.
- * @param name New name for the option.
- * @param option The existing option to clone, except for the above fields.
- */
- public Option(IHoldsOptions parent, String Id, String name, Option option){
- this.holder = parent;
- superClass = option.superClass;
- if (superClass != null) {
- superClassId = option.superClass.getId();
- }
- setId(Id);
- setName(name);
- isExtensionOption = false;
-
- // Copy the remaining attributes
- if (option.unusedChildren != null) {
- unusedChildren = new String(option.unusedChildren);
- }
- if (option.isAbstract != null) {
- isAbstract = new Boolean(option.isAbstract.booleanValue());
- }
- if (option.command != null) {
- command = new String(option.command);
- }
- if (option.commandFalse != null) {
- commandFalse = new String(option.commandFalse);
- }
- if (option.tip != null) {
- tip = new String(option.tip);
- }
- if (option.categoryId != null) {
- categoryId = new String(option.categoryId);
- }
- if (option.builtIns != null) {
- builtIns = new ArrayList(option.builtIns);
- }
- if (option.browseType != null) {
- browseType = new Integer(option.browseType.intValue());
- }
- if (option.resourceFilter != null) {
- resourceFilter = new Integer(option.resourceFilter.intValue());
- }
- if (option.enumList != null) {
- enumList = new ArrayList(option.enumList);
- enumCommands = new HashMap(option.enumCommands);
- enumNames = new HashMap(option.enumNames);
- }
-
- if (option.valueType != null) {
- valueType = new Integer(option.valueType.intValue());
- }
- Integer vType = null;
- try {
- vType = new Integer(option.getValueType());
- if (vType != null) {
- switch (vType.intValue()) {
- case BOOLEAN:
- if (option.value != null) {
- value = new Boolean(((Boolean)option.value).booleanValue());
- }
- if (option.defaultValue != null) {
- defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
- }
- break;
- case STRING:
- case ENUMERATED:
- if (option.value != null) {
- value = new String((String)option.value);
- }
- if (option.defaultValue != null) {
- defaultValue = new String((String)option.defaultValue);
- }
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- if (option.value != null) {
- value = new ArrayList((ArrayList)option.value);
- }
- if (option.defaultValue != null) {
- defaultValue = new ArrayList((ArrayList)option.defaultValue);
- }
- break;
- }
- }
- } catch (BuildException be) {
- // TODO: should we ignore this??
- }
-
- category = option.category;
- applicabilityCalculatorElement = option.applicabilityCalculatorElement;
- applicabilityCalculator = option.applicabilityCalculator;
-
- booleanExpressionCalculator = option.booleanExpressionCalculator;
-
- if (option.valueHandlerElement != null) {
- valueHandlerElement = option.valueHandlerElement;
- valueHandler = option.valueHandler;
- }
- if (option.valueHandlerExtraArgument != null) {
- valueHandlerExtraArgument = new String(option.valueHandlerExtraArgument);
- }
-
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /* (non-Javadoc)
- * Loads the option information from the ManagedConfigElement specified in the
- * argument.
- *
- * @param element Contains the option information
- */
- protected void loadFromManifest(IManagedConfigElement element) {
- ManagedBuildManager.putConfigElement(this, element);
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // Get the name
- setName(element.getAttribute(IBuildObject.NAME));
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
-
- // Get the unused children, if any
- unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
-
- // isAbstract
- String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
- if (isAbs != null){
- isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
- }
-
- // Get the command defined for the option
- command = element.getAttribute(COMMAND);
-
- // Get the command defined for a Boolean option when the value is False
- commandFalse = element.getAttribute(COMMAND_FALSE);
-
- // Get the tooltip for the option
- tip = element.getAttribute(TOOL_TIP);
-
- // Options hold different types of values
- String valueTypeStr = element.getAttribute(VALUE_TYPE);
- if (valueTypeStr != null) {
- valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
- }
-
- // Note: The value and defaultValue attributes are loaded in the resolveReferences routine.
- // This is because we need to have the value-type, and this may be defined in a
- // superClass that is not yet loaded.
-
- // Determine if there needs to be a browse button
- String browseTypeStr = element.getAttribute(BROWSE_TYPE);
- if (browseTypeStr == null) {
- // Set to null, to indicate no browse type specification
- // This will allow any superclasses to be searched for the
- // browse type specification, and thus inherited, if found,
- // which they should be
- browseType = null;
- } else if (browseTypeStr.equals(NONE)) {
- browseType = new Integer(BROWSE_NONE);
- } else if (browseTypeStr.equals(FILE)) {
- browseType = new Integer(BROWSE_FILE);
- } else if (browseTypeStr.equals(DIR)) {
- browseType = new Integer(BROWSE_DIR);
- }
-
- categoryId = element.getAttribute(CATEGORY);
-
- // Get the resourceFilter attribute
- String resFilterStr = element.getAttribute(RESOURCE_FILTER);
- if (resFilterStr == null) {
- // Set to null, to indicate no resource filter specification
- // This will allow any superclasses to be searched for the
- // resource filter specification, and thus inherited, if found,
- // which they should be
- resourceFilter = null;
- } else if (resFilterStr.equals(ALL)) {
- resourceFilter = new Integer(FILTER_ALL);
- } else if (resFilterStr.equals(FILE)) {
- resourceFilter = new Integer(FILTER_FILE);
- } else if (resFilterStr.equals(PROJECT)) {
- resourceFilter = new Integer(FILTER_PROJECT);
- }
-
- //get enablements
- IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
- if(enablements.length > 0)
- booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
-
- // get the applicability calculator, if any
- String applicabilityCalculatorStr = element.getAttribute(APPLICABILITY_CALCULATOR);
- if (applicabilityCalculatorStr != null && element instanceof DefaultManagedConfigElement) {
- applicabilityCalculatorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- } else {
- applicabilityCalculator = booleanExpressionCalculator;
- }
-
- // valueHandler
- // Store the configuration element IFF there is a value handler defined
- String valueHandler = element.getAttribute(VALUE_HANDLER);
- if (valueHandler != null && element instanceof DefaultManagedConfigElement) {
- valueHandlerElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
- // valueHandlerExtraArgument
- valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
- }
-
- /* (non-Javadoc)
- * Initialize the option information from the XML element
- * specified in the argument
- *
- * @param element An XML element containing the option information
- */
- protected void loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // name
- if (element.hasAttribute(IBuildObject.NAME)) {
- setName(element.getAttribute(IBuildObject.NAME));
- }
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
- if (superClassId != null && superClassId.length() > 0) {
- superClass = ManagedBuildManager.getExtensionOption(superClassId);
- if (superClass == null) {
- // TODO: Report error
- }
- }
-
- // Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
- unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
- }
-
- // isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
- String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
- if (isAbs != null){
- isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
- }
- }
-
- // Get the command defined for the option
- if (element.hasAttribute(COMMAND)) {
- command = element.getAttribute(COMMAND);
- }
-
- // Get the command defined for a Boolean option when the value is False
- if (element.hasAttribute(COMMAND_FALSE)) {
- commandFalse = element.getAttribute(COMMAND_FALSE);
- }
-
- // Get the tooltip for the option
- if (element.hasAttribute(TOOL_TIP)) {
- tip = element.getAttribute(TOOL_TIP);
- }
-
- // Options hold different types of values
- if (element.hasAttribute(VALUE_TYPE)) {
- String valueTypeStr = element.getAttribute(VALUE_TYPE);
- valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
- }
-
- // Now get the actual value based upon value-type
- try {
- int valType = getValueType();
- switch (valType) {
- case BOOLEAN:
- // Convert the string to a boolean
- if (element.hasAttribute(VALUE)) {
- value = new Boolean(element.getAttribute(VALUE));
- }
- if (element.hasAttribute(DEFAULT_VALUE)) {
- defaultValue = new Boolean(element.getAttribute(DEFAULT_VALUE));
- }
- break;
- case STRING:
- // Just get the value out of the option directly
- if (element.hasAttribute(VALUE)) {
- value = element.getAttribute(VALUE);
- }
- if (element.hasAttribute(DEFAULT_VALUE)) {
- defaultValue = element.getAttribute(DEFAULT_VALUE);
- }
- break;
- case ENUMERATED:
- if (element.hasAttribute(VALUE)) {
- value = element.getAttribute(VALUE);
- }
- if (element.hasAttribute(DEFAULT_VALUE)) {
- defaultValue = element.getAttribute(DEFAULT_VALUE);
- }
-
- // Do we have enumeratedOptionValue children? If so, load them
- // to define the valid values and the default value.
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configNode = configElements.item(i);
- if (configNode.getNodeName().equals(ENUM_VALUE)) {
- Element configElement = (Element)configNode;
- String optId = configElement.getAttribute(ID);
- if (i == 0) {
- enumList = new ArrayList();
- if (defaultValue == null) {
- defaultValue = optId; // Default value to be overridden is default is specified
- }
- }
- enumList.add(optId);
- if (configElement.hasAttribute(COMMAND)) {
- getEnumCommandMap().put(optId, configElement.getAttribute(COMMAND));
- } else {
- getEnumCommandMap().put(optId, EMPTY_STRING);
- }
- getEnumNameMap().put(optId, configElement.getAttribute(NAME));
- if (configElement.hasAttribute(IS_DEFAULT)) {
- Boolean isDefault = new Boolean(configElement.getAttribute(IS_DEFAULT));
- if (isDefault.booleanValue()) {
- defaultValue = optId;
- }
- }
- }
- }
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- // Note: These string-list options do not load either the "value" or
- // "defaultValue" attributes. Instead, the ListOptionValue children
- // are loaded in the value field.
- List valueList = null;
- configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- if (i == 0) {
- valueList = new ArrayList();
- builtIns = new ArrayList();
- }
- Node configNode = configElements.item(i);
- if (configNode.getNodeName().equals(LIST_VALUE)) {
- Element valueElement = (Element)configNode;
- Boolean isBuiltIn;
- if (valueElement.hasAttribute(IS_DEFAULT)) {
- isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
- } else {
- isBuiltIn = new Boolean(false);
- }
- if (isBuiltIn.booleanValue()) {
- builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- else {
- valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- }
- }
- value = valueList;
- break;
- default :
- break;
- }
- } catch (BuildException e) {
- // TODO: report error
- }
-
- // Determine if there needs to be a browse button
- if (element.hasAttribute(BROWSE_TYPE)) {
- String browseTypeStr = element.getAttribute(BROWSE_TYPE);
-
- if (browseTypeStr == null) {
- // Set to null, to indicate no browse type specification
- // This will allow any superclasses to be searched for the
- // browse type specification, and thus inherited, if found,
- // which they should be
- browseType = null;
- } else if (browseTypeStr.equals(NONE)) {
- browseType = new Integer(BROWSE_NONE);
- } else if (browseTypeStr.equals(FILE)) {
- browseType = new Integer(BROWSE_FILE);
- } else if (browseTypeStr.equals(DIR)) {
- browseType = new Integer(BROWSE_DIR);
- }
- }
-
- if (element.hasAttribute(CATEGORY)) {
- categoryId = element.getAttribute(CATEGORY);
- if (categoryId != null) {
- category = holder.getOptionCategory(categoryId);
- }
- }
-
- // Get the resourceFilter attribute
- if (element.hasAttribute(RESOURCE_FILTER)) {
- String resFilterStr = element.getAttribute(RESOURCE_FILTER);
- if (resFilterStr == null) {
- // Set to null, to indicate no resource filter specification
- // This will allow any superclasses to be searched for the
- // resource filter specification, and thus inherited, if found,
- // which they should be
- resourceFilter = null;
- } else if (resFilterStr.equals(ALL)) {
- resourceFilter = new Integer(FILTER_ALL);
- } else if (resFilterStr.equals(FILE)) {
- resourceFilter = new Integer(FILTER_FILE);
- } else if (resFilterStr.equals(PROJECT)) {
- resourceFilter = new Integer(FILTER_PROJECT);
- }
- }
-
- // Note: valueHandlerElement and VALUE_HANDLER are not restored,
- // as they are not saved. See note in serialize().
-
- // valueHandlerExtraArgument
- if (element.hasAttribute(VALUE_HANDLER_EXTRA_ARGUMENT)) {
- valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
- }
- }
-
- private int ValueTypeStrToInt(String valueTypeStr) {
- if (valueTypeStr == null) return -1;
- if (valueTypeStr.equals(TYPE_STRING))
- return STRING;
- else if (valueTypeStr.equals(TYPE_STR_LIST))
- return STRING_LIST;
- else if (valueTypeStr.equals(TYPE_BOOL))
- return BOOLEAN;
- else if (valueTypeStr.equals(TYPE_ENUM))
- return ENUMERATED;
- else if (valueTypeStr.equals(TYPE_INC_PATH))
- return INCLUDE_PATH;
- else if (valueTypeStr.equals(TYPE_LIB))
- return LIBRARIES;
- else if (valueTypeStr.equals(TYPE_USER_OBJS))
- return OBJECTS;
- else if (valueTypeStr.equals(TYPE_DEFINED_SYMBOLS))
- return PREPROCESSOR_SYMBOLS;
- else {
- // TODO: This was the CDT 2.0 default - should we keep it?
- return PREPROCESSOR_SYMBOLS;
- }
- }
-
- /**
- * Persist the option to the project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) throws BuildException {
- if (superClass != null)
- element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
-
- element.setAttribute(IBuildObject.ID, id);
-
- if (name != null) {
- element.setAttribute(IBuildObject.NAME, name);
- }
-
- if (unusedChildren != null) {
- element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
- }
-
- if (isAbstract != null) {
- element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
- }
-
- if (command != null) {
- element.setAttribute(COMMAND, command);
- }
-
- if (commandFalse != null) {
- element.setAttribute(COMMAND_FALSE, commandFalse);
- }
-
- if (tip != null) {
- element.setAttribute(TOOL_TIP, tip);
- }
-
- /*
- * Note: We store value & value-type as a pair, so we know what type of value we are
- * dealing with when we read it back in.
- * This is also true of defaultValue.
- */
- boolean storeValueType = false;
-
- // value
- if (value != null) {
- storeValueType = true;
- switch (getValueType()) {
- case BOOLEAN:
- element.setAttribute(VALUE, ((Boolean)value).toString());
- break;
- case STRING:
- case ENUMERATED:
- element.setAttribute(VALUE, (String)value);
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- if (value != null) {
- ArrayList stringList = (ArrayList)value;
- ListIterator iter = stringList.listIterator();
- while (iter.hasNext()) {
- Element valueElement = doc.createElement(LIST_VALUE);
- valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
- valueElement.setAttribute(LIST_ITEM_BUILTIN, "false"); //$NON-NLS-1$
- element.appendChild(valueElement);
- }
- }
- // Serialize the built-ins that have been overridden
- if (builtIns != null) {
- ListIterator iter = builtIns.listIterator();
- while (iter.hasNext()) {
- Element valueElement = doc.createElement(LIST_VALUE);
- valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
- valueElement.setAttribute(LIST_ITEM_BUILTIN, "true"); //$NON-NLS-1$
- element.appendChild(valueElement);
- }
- }
- break;
- }
- }
-
- // defaultValue
- if (defaultValue != null) {
- storeValueType = true;
- switch (getValueType()) {
- case BOOLEAN:
- element.setAttribute(DEFAULT_VALUE, ((Boolean)defaultValue).toString());
- break;
- case STRING:
- case ENUMERATED:
- element.setAttribute(DEFAULT_VALUE, (String)defaultValue);
- break;
- default:
- break;
- }
- }
-
- if (storeValueType) {
- String str;
- switch (getValueType()) {
- case BOOLEAN:
- str = TYPE_BOOL;
- break;
- case STRING:
- str = TYPE_STRING;
- break;
- case ENUMERATED:
- str = TYPE_ENUM;
- break;
- case STRING_LIST:
- str = TYPE_STR_LIST;
- break;
- case INCLUDE_PATH:
- str = TYPE_INC_PATH;
- break;
- case LIBRARIES:
- str = TYPE_LIB;
- break;
- case OBJECTS:
- str = TYPE_USER_OBJS;
- break;
- case PREPROCESSOR_SYMBOLS:
- str = TYPE_DEFINED_SYMBOLS;
- break;
- default:
- // TODO; is this a problem...
- str = EMPTY_STRING;
- break;
- }
- element.setAttribute(VALUE_TYPE, str);
- }
-
- // browse type
- if (browseType != null) {
- String str;
- switch (getBrowseType()) {
- case BROWSE_NONE:
- str = NONE;
- break;
- case BROWSE_FILE:
- str = FILE;
- break;
- case BROWSE_DIR:
- str = DIR;
- break;
- default:
- str = EMPTY_STRING;
- break;
- }
- element.setAttribute(BROWSE_TYPE, str);
- }
-
- if (categoryId != null) {
- element.setAttribute(CATEGORY, categoryId);
- }
-
- // resource filter
- if (resourceFilter != null) {
- String str;
- switch (getResourceFilter()) {
- case FILTER_ALL:
- str = ALL;
- break;
- case FILTER_FILE:
- str = FILE;
- break;
- case FILTER_PROJECT:
- str = PROJECT;
- break;
- default:
- str = EMPTY_STRING;
- break;
- }
- element.setAttribute(RESOURCE_FILTER, str);
- }
-
- // Note: applicability calculator cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (applicabilityCalculatorElement != null) {
- // TODO: issue warning?
- }
-
- // Note: a value handler cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (valueHandlerElement != null) {
- // TODO: Issue warning? Stuck with behavior of this elsewhere in
- // CDT, e.g. the implementation of Tool
- }
- if (valueHandlerExtraArgument != null) {
- element.setAttribute(VALUE_HANDLER_EXTRA_ARGUMENT, valueHandlerExtraArgument);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /*
- * P A R E N T A N D C H I L D H A N D L I N G
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getParent()
- */
- public IBuildObject getParent() {
- return holder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getOptionHolder()
- */
- public IHoldsOptions getOptionHolder() {
- // Do not take superclasses into account
- return holder;
- }
-
- /*
- * M O D E L A T T R I B U T E A C C E S S O R S
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getSuperClass()
- */
- public IOption getSuperClass() {
- return superClass;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getName()
- */
- public String getName() {
- return (name == null && superClass != null) ? superClass.getName() : name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicableValues()
- */
- public String[] getApplicableValues() {
- // Does this option instance have the list of values?
- if (enumList == null) {
- if (superClass != null) {
- return superClass.getApplicableValues();
- } else {
- return EMPTY_STRING_ARRAY;
- }
- }
- // Get all of the enumerated names from the option
- if (enumList.size() == 0) {
- return EMPTY_STRING_ARRAY;
- } else {
- // Return the elements in the order they are specified in the manifest
- String[] enumNames = new String[enumList.size()];
- for (int index = 0; index < enumList.size(); ++ index) {
- enumNames[index] = (String) getEnumNameMap().get(enumList.get(index));
- }
- return enumNames;
- }
- }
-
- public boolean getBooleanValue() {
- return ((Boolean)getValue()).booleanValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseType()
- */
- public int getBrowseType() {
- if (browseType == null) {
- if (superClass != null) {
- return superClass.getBrowseType();
- } else {
- return BROWSE_NONE;
- }
- }
- return browseType.intValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getResourceFilter()
- */
- public int getResourceFilter() {
- if (resourceFilter == null) {
- if (superClass != null) {
- return superClass.getResourceFilter();
- } else {
- return FILTER_ALL;
- }
- }
- return resourceFilter.intValue();
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculatorElement()
- */
- public IConfigurationElement getApplicabilityCalculatorElement() {
-/* if (applicabilityCalculatorElement == null) {
- if (superClass != null) {
- return ((Option)superClass).getApplicabilityCalculatorElement();
- }
- }
-*/
- return applicabilityCalculatorElement;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculator()
- */
- public IOptionApplicability getApplicabilityCalculator() {
- if (applicabilityCalculator == null) {
- if (applicabilityCalculatorElement != null) {
- try {
- if (applicabilityCalculatorElement.getAttribute(APPLICABILITY_CALCULATOR) != null)
- applicabilityCalculator = (IOptionApplicability) applicabilityCalculatorElement
- .createExecutableExtension(APPLICABILITY_CALCULATOR);
- } catch (CoreException e) {
- }
- }
- else if(superClass != null)
- applicabilityCalculator = superClass.getApplicabilityCalculator();
- }
-
- return applicabilityCalculator;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getBuiltIns()
- */
- public String[] getBuiltIns() {
- // Return the list of built-ins as an array
- if (builtIns == null) {
- if (superClass != null) {
- return superClass.getBuiltIns();
- } else {
- return EMPTY_STRING_ARRAY;
- }
- }
- return (String[])builtIns.toArray(new String[builtIns.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getCategory()
- */
- public IOptionCategory getCategory() {
- if (category == null) {
- if (superClass != null) {
- return superClass.getCategory();
- } else {
- if (getOptionHolder() instanceof ITool) {
- return ((ITool)getOptionHolder()).getTopOptionCategory();
- } else {
- return null;
- }
- }
- }
- return category;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getCommand()
- */
- public String getCommand() {
- if (command == null) {
- if (superClass != null) {
- return superClass.getCommand();
- } else {
- return EMPTY_STRING;
- }
- }
- return command;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getCommandFalse()
- */
- public String getCommandFalse() {
- if (commandFalse == null) {
- if (superClass != null) {
- return superClass.getCommandFalse();
- } else {
- return EMPTY_STRING;
- }
- }
- return commandFalse;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getToolTip()
- */
- public String getToolTip() {
- if (tip == null) {
- if (superClass != null) {
- return superClass.getToolTip();
- } else {
- return EMPTY_STRING;
- }
- }
- return tip;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefinedSymbols()
- */
- public String[] getDefinedSymbols() throws BuildException {
- if (getValueType() != PREPROCESSOR_SYMBOLS) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumCommand(java.lang.String)
- */
- public String getEnumCommand(String id) throws BuildException {
- // Sanity
- if (id == null) return EMPTY_STRING;
-
- // Does this option instance have the list of values?
- if (enumList == null) {
- if (superClass != null) {
- return superClass.getEnumCommand(id);
- } else {
- return EMPTY_STRING;
- }
- }
- if (getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
-
- // First check for the command in ID->command map
- String cmd = (String) getEnumCommandMap().get(id);
- if (cmd == null) {
- // This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
- // name of the enumeration. Search for the ID that maps to the name and use that to find the
- // command.
- ListIterator iter = enumList.listIterator();
- while (iter.hasNext()) {
- String realID = (String) iter.next();
- String name = (String) getEnumNameMap().get(realID);
- if (id.equals(name)) {
- cmd = (String) getEnumCommandMap().get(realID);
- break;
- }
- }
- }
- return cmd == null ? EMPTY_STRING : cmd;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumName(java.lang.String)
- */
- public String getEnumName(String id) throws BuildException {
- // Sanity
- if (id == null) return EMPTY_STRING;
-
- // Does this option instance have the list of values?
- if (enumList == null) {
- if (superClass != null) {
- return superClass.getEnumName(id);
- } else {
- return EMPTY_STRING;
- }
- }
- if (getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
-
- // First check for the command in ID->name map
- String name = (String) getEnumNameMap().get(id);
- if (name == null) {
- // This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
- // name of the enumeration.
- name = id;
- }
- return name;
- }
-
- /* (non-Javadoc)
- * A memory-safe accessor to the map of enumerated option value IDs to the commands
- * that a tool understands.
- *
- * @return a Map of enumerated option value IDs to actual commands that are passed
- * to a tool on the command line.
- */
- private Map getEnumCommandMap() {
- if (enumCommands == null) {
- enumCommands = new HashMap();
- }
- return enumCommands;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumeratedId(java.lang.String)
- */
- public String getEnumeratedId(String name) throws BuildException {
- if (name == null) return null;
-
- // Does this option instance have the list of values?
- if (enumList == null) {
- if (superClass != null) {
- return superClass.getEnumeratedId(name);
- } else {
- return EMPTY_STRING;
- }
- }
- if (getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
-
- Set idSet = getEnumNameMap().keySet();
- Iterator iter = idSet.iterator();
- while (iter.hasNext()) {
- String id = (String) iter.next();
- String enumName = (String) getEnumNameMap().get(id);
- if (name.equals(enumName)) {
- return id;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- *
- * @return a Map of enumerated option value IDs to the selection displayed to the user.
- */
- private Map getEnumNameMap() {
- if (enumNames == null) {
- enumNames = new HashMap();
- }
- return enumNames;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getIncludePaths()
- */
- public String[] getIncludePaths() throws BuildException {
- if (getValueType() != INCLUDE_PATH) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getLibraries()
- */
- public String[] getLibraries() throws BuildException {
- if (getValueType() != LIBRARIES) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefaultEnumValue()
- */
- public String getSelectedEnum() throws BuildException {
- if (getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- return getStringValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getStringListValue()
- */
- public String[] getStringListValue() throws BuildException {
- if (getValueType() != STRING_LIST) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getStringValue()
- */
- public String getStringValue() throws BuildException {
- if (getValueType() != STRING && getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- return getValue() == null ? EMPTY_STRING : (String)getValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getUserObjects()
- */
- public String[] getUserObjects() throws BuildException {
- if (getValueType() != OBJECTS) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- // This is the right puppy, so return its list value
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueType()
- */
- public int getValueType() throws BuildException {
- if (valueType == null) {
- if (superClass != null) {
- return superClass.getValueType();
- } else {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$;
- }
- }
- return valueType.intValue();
- }
-
- /* (non-Javadoc)
- * Gets the value, applying appropriate defaults if necessary.
- */
- public Object getValue() {
- /*
- * In order to determine the current value of an option, perform the following steps until a value is found:
- * 1. Examine the value attribute of the option.
- * 2. Examine the value attribute of the optionís superClass recursively.
- * 3. Examine the dynamicDefaultValue attribute of the option and invoke it if specified. (not yet implemented)
- * 4. Examine the defaultValue attribute of the option.
- * 5. Examine the dynamicDefaultValue attribute of the optionís superClass and invoke it if specified. (not yet implemented)
- * 6. Examine the defaultValue attribute of the optionís superClass.
- * 7. Go to step 5 recursively until no more super classes.
- * 8. Use the default value for the option type.
- */
-
- Object val = getRawValue();
- if (val == null) {
- val = getDefaultValue();
- if (val == null) {
- int valType;
- try {
- valType = getValueType();
- } catch (BuildException e) {
- return EMPTY_STRING;
- }
- switch (valType) {
- case BOOLEAN:
- val = new Boolean(false);
- break;
- case STRING:
- val = EMPTY_STRING;
- break;
- case ENUMERATED:
- // TODO: Can we default to the first enumerated id?
- val = EMPTY_STRING;
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- val = new ArrayList();
- break;
- default:
- val = EMPTY_STRING;
- break;
- }
- }
- }
- return val;
- }
-
- /* (non-Javadoc)
- * Gets the raw value, applying appropriate defauls if necessary.
- */
- public Object getRawValue() {
- if (value == null) {
- if (superClass != null) {
- Option mySuperClass = (Option)superClass;
- return mySuperClass.getRawValue();
- }
- }
- return value;
- }
-
- /* (non-Javadoc)
- * Gets the raw default value.
- */
- public Object getDefaultValue() {
- // Note: string-list options do not have a default value
- if (defaultValue == null) {
- if (superClass != null) {
- return superClass.getDefaultValue();
- }
- }
- return defaultValue;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
- */
- public void setDefaultValue(Object v) {
- defaultValue = v;
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
- */
- public void setCategory(IOptionCategory category) {
- if (this.category != category) {
- this.category = category;
- if (category != null) {
- categoryId = category.getId();
- } else {
- categoryId = null;
- }
- if(!isExtensionElement())
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setCommand(String)
- */
- public void setCommand(String cmd) {
- if (cmd == null && command == null) return;
- if (cmd == null || command == null || !cmd.equals(command)) {
- command = cmd;
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setCommandFalse(String)
- */
- public void setCommandFalse(String cmd) {
- if (cmd == null && commandFalse == null) return;
- if (cmd == null || commandFalse == null || !cmd.equals(commandFalse)) {
- commandFalse = cmd;
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setToolTip(String)
- */
- public void setToolTip(String tooltip) {
- if (tooltip == null && tip == null) return;
- if (tooltip == null || tip == null || !tooltip.equals(tip)) {
- tip = tooltip;
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
- */
- public void setResourceFilter(int filter) {
- if (resourceFilter == null || !(filter == resourceFilter.intValue())) {
- resourceFilter = new Integer(filter);
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setBrowseType(int)
- */
- public void setBrowseType(int type) {
- if (browseType == null || !(type == browseType.intValue())) {
- browseType = new Integer(type);
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(boolean)
- */
- public void setValue(boolean value) throws BuildException {
- if (/*!isExtensionElement() && */getValueType() == BOOLEAN){
- this.value = new Boolean(value);
- } else {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- if(!isExtensionElement())
- setDirty(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String)
- */
- public void setValue(String value) throws BuildException {
- // Note that we can still set the human-readable value here
- if (/*!isExtensionElement() && */(getValueType() == STRING || getValueType() == ENUMERATED)) {
- this.value = value;
- } else {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- if(!isExtensionElement())
- setDirty(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String [])
- */
- public void setValue(String [] value) throws BuildException {
- if (/*!isExtensionElement() && */
- (getValueType() == STRING_LIST
- || getValueType() == INCLUDE_PATH
- || getValueType() == PREPROCESSOR_SYMBOLS
- || getValueType() == LIBRARIES
- || getValueType() == OBJECTS)) {
- // Just replace what the option reference is holding onto
- if(value == null)
- this.value = null;
- else
- this.value = new ArrayList(Arrays.asList(value));
- }
- else {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
- */
- public void setValue(Object v) {
- value = v;
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueType()
- */
- public void setValueType(int type) {
- // TODO: Verify that this is a valid type
- if (valueType == null || valueType.intValue() != type) {
- valueType = new Integer(type);
- if(!isExtensionElement())
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandlerElement()
- */
- public IConfigurationElement getValueHandlerElement() {
- if (valueHandlerElement == null) {
- if (superClass != null) {
- return ((Option)superClass).getValueHandlerElement();
- }
- }
- return valueHandlerElement;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerElement(IConfigurationElement)
- */
- public void setValueHandlerElement(IConfigurationElement element) {
- valueHandlerElement = element;
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandler()
- */
- public IManagedOptionValueHandler getValueHandler() {
- if (valueHandler != null) {
- return valueHandler;
- }
- IConfigurationElement element = getValueHandlerElement();
- if (element != null) {
- try {
- if (element.getAttribute(VALUE_HANDLER) != null) {
- valueHandler = (IManagedOptionValueHandler) element.createExecutableExtension(VALUE_HANDLER);
- return valueHandler;
- }
- } catch (CoreException e) {
- ManagedBuildManager.OptionValueHandlerError(element.getAttribute(VALUE_HANDLER), getId());
- // Assign the default handler to avoid further error messages
- valueHandler = ManagedOptionValueHandler.getManagedOptionValueHandler();
- return valueHandler;
- }
- }
- // If no handler is provided, then use the default handler
- return ManagedOptionValueHandler.getManagedOptionValueHandler();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandlerExtraArgument())
- */
- public String getValueHandlerExtraArgument() {
- if (valueHandlerExtraArgument == null) {
- if (superClass != null) {
- return superClass.getValueHandlerExtraArgument();
- } else {
- return EMPTY_STRING;
- }
- }
- return valueHandlerExtraArgument;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerExtraArgument(String))
- */
- public void setValueHandlerExtraArgument(String extraArgument) {
- if (extraArgument == null && valueHandlerExtraArgument == null) return;
- if (extraArgument == null ||
- valueHandlerExtraArgument == null ||
- !extraArgument.equals(valueHandlerExtraArgument)) {
- valueHandlerExtraArgument = extraArgument;
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
-
- /*
- * O B J E C T S T A T E M A I N T E N A N C E
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#isExtensionElement()
- */
- public boolean isExtensionElement() {
- return isExtensionOption;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#overridesOnlyValue()
- * Deprecated since 3.0.1
- */
- public boolean overridesOnlyValue() {
- if (superClass != null &&
- unusedChildren == null &&
- browseType == null &&
- (builtIns == null || builtIns.size() == 0) &&
- category == null &&
- categoryId == null &&
- command == null &&
- commandFalse == null &&
- tip == null &&
- enumList == null &&
- enumCommands == null &&
- enumNames == null &&
- defaultValue == null) {
- return true;
- } else {
- return false;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#isDirty()
- */
- public boolean isDirty() {
- // This shouldn't be called for an extension option
- if (isExtensionOption) return false;
- return isDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- this.isDirty = isDirty;
- }
-
- public void resolveReferences() {
-
- if (!resolved) {
- resolved = true;
- // Resolve superClass
- if (superClassId != null && superClassId.length() > 0) {
- superClass = ManagedBuildManager.getExtensionOption(superClassId);
- if (superClass == null) {
- // Report error
- ManagedBuildManager.OutputResolveError(
- "superClass", //$NON-NLS-1$
- superClassId,
- "option", //$NON-NLS-1$
- getId());
- } else {
- // All of our superclasses must be resolved in order to call
- // getValueType below.
- ((Option)superClass).resolveReferences();
- }
- }
- if (categoryId != null) {
- category = holder.getOptionCategory(categoryId);
- if (category == null) {
- // Report error
- ManagedBuildManager.OutputResolveError(
- "category", //$NON-NLS-1$
- categoryId,
- "option", //$NON-NLS-1$
- getId());
- }
- }
- // Process the value and default value attributes. This is delayed until now
- // because we may not know the valueType until after we have resolved the superClass above
- // Now get the actual value
- try {
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- switch (getValueType()) {
- case BOOLEAN:
- // Convert the string to a boolean
- String val = element.getAttribute(VALUE);
- if (val != null) {
- value = new Boolean(val);
- }
- val = element.getAttribute(DEFAULT_VALUE);
- if (val != null) {
- defaultValue = new Boolean(val);
- }
- break;
- case STRING:
- // Just get the value out of the option directly
- value = element.getAttribute(VALUE);
- defaultValue = element.getAttribute(DEFAULT_VALUE);
- break;
- case ENUMERATED:
- value = element.getAttribute(VALUE);
- defaultValue = element.getAttribute(DEFAULT_VALUE);
-
- // Do we have enumeratedOptionValue children? If so, load them
- // to define the valid values and the default value.
- IManagedConfigElement[] enumElements = element.getChildren(ENUM_VALUE);
- for (int i = 0; i < enumElements.length; ++i) {
- String optId = enumElements[i].getAttribute(ID);
- if (i == 0) {
- enumList = new ArrayList();
- if (defaultValue == null) {
- defaultValue = optId; // Default value to be overridden if default is specified
- }
- }
- enumList.add(optId);
- getEnumCommandMap().put(optId, enumElements[i].getAttribute(COMMAND));
- getEnumNameMap().put(optId, enumElements[i].getAttribute(NAME));
- Boolean isDefault = new Boolean(enumElements[i].getAttribute(IS_DEFAULT));
- if (isDefault.booleanValue()) {
- defaultValue = optId;
- }
- }
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- // Note: These string-list options do not load either the "value" or
- // "defaultValue" attributes. Instead, the ListOptionValue children
- // are loaded in the value field.
- List valueList = null;
- IManagedConfigElement[] valueElements = element.getChildren(LIST_VALUE);
- for (int i = 0; i < valueElements.length; ++i) {
- if (i == 0) {
- valueList = new ArrayList();
- builtIns = new ArrayList();
- }
- IManagedConfigElement valueElement = valueElements[i];
- Boolean isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
- if (isBuiltIn.booleanValue()) {
- builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- else {
- valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- }
- value = valueList;
- break;
- default :
- break;
- }
- } catch (BuildException e) {
- // TODO: report error
- }
- }
- }
-
- /**
- * @return Returns the managedBuildRevision.
- */
- public String getManagedBuildRevision() {
- if ( managedBuildRevision == null) {
- if ( getParent() != null) {
- return getParent().getManagedBuildRevision();
- }
- }
- return managedBuildRevision;
- }
-
- /* (non-Javadoc)
- * For now implement this method just as a utility to make code
- * within the Option class cleaner.
- * TODO: In future we may want to move this to IOption
- */
- protected boolean isAbstract() {
- if (isAbstract != null) {
- return isAbstract.booleanValue();
- } else {
- return false; // Note: no inheritance from superClass
- }
- }
-
- /**
- * Verifies whether the option is valid and handles
- * any errors for the option. The following errors
- * can occur:
- * (a) Options that are children of a ToolChain must
- * ALWAYS have a category
- * (b) Options that are children of a ToolChain must
- * NEVER have a resourceFilter of "file".
- * If an error occurs, the option is set to being invalid.
- *
- * @pre All references have been resolved.
- */
- private void verify() {
- if (verified) return;
- verified = true;
- // Ignore elements that are superclasses
- if ( getOptionHolder() instanceof IToolChain && isAbstract() == false ) {
- // Check for error (a)
- if (getCategory() == null) {
- ManagedBuildManager.OptionValidError(ManagedBuildManager.ERROR_CATEGORY, getId());
- // Object becomes invalid
- isValid = false;
- }
- // Check for error (b). Not specifying an attribute is OK.
- // Do not use getResourceFilter as it does not allow
- // differentiating between "all" and no attribute specified.
- if ( resourceFilter != null )
- {
- switch (getResourceFilter()) {
- case Option.FILTER_FILE:
- // TODO: Cannot differentiate between "all" and attribute not
- // specified. Thus do not produce an error. We can argue that "all"
- // means all valid resource configurations.
- ManagedBuildManager.OptionValidError(ManagedBuildManager.ERROR_FILTER, getId());
- // Object becomes invalid
- isValid = false;
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#isValid()
- */
- public boolean isValid() {
- // We use a lazy scheme to check whether the option is valid.
- // Note that by default an option is valid. verify() is only called if
- // the option has been resolved. This gets us around having to deal with
- // ordering problems during a resolve, or introducing another global
- // stage to verify the configuration after a resolve.
- // The trade-off is that errors in the MBS grammar may not be
- // detected on load, but only when a particular grammar element
- // is used, say in the GUI.
- if (verified == false && resolved == true) {
- verify();
- }
- return isValid;
- }
-
- /**
- * @return Returns true if this Option was created from an MBS 2.0 model
- * OptionReference element.
- */
- public boolean wasOptRef() {
- return wasOptRef;
- }
-
- public void setWasOptRef(boolean was) {
- wasOptRef = was;
- }
-
- /**
- * @return Returns the version.
- */
- public PluginVersionIdentifier getVersion() {
- if ( version == null) {
- if ( getParent() != null) {
- return getParent().getVersion();
- }
- }
- return version;
- }
-
- public void setVersion(PluginVersionIdentifier version) {
- // Do nothing
- }
-
- public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
- return booleanExpressionCalculator;
- }
-
- public boolean isAdjustedExtension(){
- return isUdjusted;
- }
-
- public void setAdjusted(boolean adjusted) {
- isUdjusted = adjusted;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ * ARM Ltd. - basic tooltip support
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class Option extends BuildObject implements IOption {
+ // Static default return values
+ private static final String EMPTY_STRING = new String();
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ // Superclass
+ private IOption superClass;
+ private String superClassId;
+ // Parent and children
+ private IHoldsOptions holder;
+ // Managed Build model attributes
+ private String unusedChildren;
+ private Integer browseType;
+ private List builtIns;
+ private IOptionCategory category;
+ private String categoryId;
+ private String command;
+ private String commandFalse;
+ private String tip;
+ private List enumList;
+ private Map enumCommands;
+ private Map enumNames;
+ private Object value;
+ private Object defaultValue;
+ private Integer valueType;
+ private Boolean isAbstract;
+ private Integer resourceFilter;
+ private IConfigurationElement valueHandlerElement = null;
+ private IManagedOptionValueHandler valueHandler = null;
+ private String valueHandlerExtraArgument;
+ private IConfigurationElement applicabilityCalculatorElement = null;
+ private IOptionApplicability applicabilityCalculator = null;
+ private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator = null;
+ // Miscellaneous
+ private boolean isExtensionOption = false;
+ private boolean isDirty = false;
+ private boolean resolved = true;
+ private boolean verified = false;
+ private boolean isValid = true; /** False for options which are invalid. getOption()
+ * routines will ignore invalid options. */
+ private boolean wasOptRef = false; /** True for options which are created because of an
+ * MBS 2.0 model OptionReference element
+ */
+ private boolean isUdjusted = false;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * This constructor is called to create an option defined by an extension point in
+ * a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The IHoldsOptions parent of this option, or <code>null</code> if
+ * defined at the top level
+ * @param element The option definition from the manifest file or a dynamic element
+ * provider
+ */
+ public Option(IHoldsOptions parent, IManagedConfigElement element) {
+ this.holder = parent;
+ isExtensionOption = true;
+
+ // setup for resolving
+ resolved = false;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionOption(this);
+ }
+
+ /**
+ * This constructor is called to create an Option whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param IHoldsOptions The parent of the option, if any
+ * @param Option The superClass, if any
+ * @param String The id for the new option
+ * @param String The name for the new option
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public Option(IHoldsOptions parent, IOption superClass, String Id, String name, boolean isExtensionElement) {
+ this.holder = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionOption = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionOption(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create an <code>Option</code> based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The <code>IHoldsOptions</code> the option will be added to.
+ * @param element The XML element that contains the option settings.
+ */
+ public Option(IHoldsOptions parent, Element element) {
+ this.holder = parent;
+ isExtensionOption = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+ }
+
+ /**
+ * Create an <code>Option</code> based upon an existing option.
+ *
+ * @param parent The <code>IHoldsOptions</code> the option will be added to.
+ * @param Id New ID for the option.
+ * @param name New name for the option.
+ * @param option The existing option to clone, except for the above fields.
+ */
+ public Option(IHoldsOptions parent, String Id, String name, Option option){
+ this.holder = parent;
+ superClass = option.superClass;
+ if (superClass != null) {
+ superClassId = option.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionOption = false;
+
+ // Copy the remaining attributes
+ if (option.unusedChildren != null) {
+ unusedChildren = new String(option.unusedChildren);
+ }
+ if (option.isAbstract != null) {
+ isAbstract = new Boolean(option.isAbstract.booleanValue());
+ }
+ if (option.command != null) {
+ command = new String(option.command);
+ }
+ if (option.commandFalse != null) {
+ commandFalse = new String(option.commandFalse);
+ }
+ if (option.tip != null) {
+ tip = new String(option.tip);
+ }
+ if (option.categoryId != null) {
+ categoryId = new String(option.categoryId);
+ }
+ if (option.builtIns != null) {
+ builtIns = new ArrayList(option.builtIns);
+ }
+ if (option.browseType != null) {
+ browseType = new Integer(option.browseType.intValue());
+ }
+ if (option.resourceFilter != null) {
+ resourceFilter = new Integer(option.resourceFilter.intValue());
+ }
+ if (option.enumList != null) {
+ enumList = new ArrayList(option.enumList);
+ enumCommands = new HashMap(option.enumCommands);
+ enumNames = new HashMap(option.enumNames);
+ }
+
+ if (option.valueType != null) {
+ valueType = new Integer(option.valueType.intValue());
+ }
+ Integer vType = null;
+ try {
+ vType = new Integer(option.getValueType());
+ if (vType != null) {
+ switch (vType.intValue()) {
+ case BOOLEAN:
+ if (option.value != null) {
+ value = new Boolean(((Boolean)option.value).booleanValue());
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
+ }
+ break;
+ case STRING:
+ case ENUMERATED:
+ if (option.value != null) {
+ value = new String((String)option.value);
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new String((String)option.defaultValue);
+ }
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ if (option.value != null) {
+ value = new ArrayList((ArrayList)option.value);
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new ArrayList((ArrayList)option.defaultValue);
+ }
+ break;
+ }
+ }
+ } catch (BuildException be) {
+ // TODO: should we ignore this??
+ }
+
+ category = option.category;
+ applicabilityCalculatorElement = option.applicabilityCalculatorElement;
+ applicabilityCalculator = option.applicabilityCalculator;
+
+ booleanExpressionCalculator = option.booleanExpressionCalculator;
+
+ if (option.valueHandlerElement != null) {
+ valueHandlerElement = option.valueHandlerElement;
+ valueHandler = option.valueHandler;
+ }
+ if (option.valueHandlerExtraArgument != null) {
+ valueHandlerExtraArgument = new String(option.valueHandlerExtraArgument);
+ }
+
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the option information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the option information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // Get the command defined for the option
+ command = element.getAttribute(COMMAND);
+
+ // Get the command defined for a Boolean option when the value is False
+ commandFalse = element.getAttribute(COMMAND_FALSE);
+
+ // Get the tooltip for the option
+ tip = element.getAttribute(TOOL_TIP);
+
+ // Options hold different types of values
+ String valueTypeStr = element.getAttribute(VALUE_TYPE);
+ if (valueTypeStr != null) {
+ valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
+ }
+
+ // Note: The value and defaultValue attributes are loaded in the resolveReferences routine.
+ // This is because we need to have the value-type, and this may be defined in a
+ // superClass that is not yet loaded.
+
+ // Determine if there needs to be a browse button
+ String browseTypeStr = element.getAttribute(BROWSE_TYPE);
+ if (browseTypeStr == null) {
+ // Set to null, to indicate no browse type specification
+ // This will allow any superclasses to be searched for the
+ // browse type specification, and thus inherited, if found,
+ // which they should be
+ browseType = null;
+ } else if (browseTypeStr.equals(NONE)) {
+ browseType = new Integer(BROWSE_NONE);
+ } else if (browseTypeStr.equals(FILE)) {
+ browseType = new Integer(BROWSE_FILE);
+ } else if (browseTypeStr.equals(DIR)) {
+ browseType = new Integer(BROWSE_DIR);
+ }
+
+ categoryId = element.getAttribute(CATEGORY);
+
+ // Get the resourceFilter attribute
+ String resFilterStr = element.getAttribute(RESOURCE_FILTER);
+ if (resFilterStr == null) {
+ // Set to null, to indicate no resource filter specification
+ // This will allow any superclasses to be searched for the
+ // resource filter specification, and thus inherited, if found,
+ // which they should be
+ resourceFilter = null;
+ } else if (resFilterStr.equals(ALL)) {
+ resourceFilter = new Integer(FILTER_ALL);
+ } else if (resFilterStr.equals(FILE)) {
+ resourceFilter = new Integer(FILTER_FILE);
+ } else if (resFilterStr.equals(PROJECT)) {
+ resourceFilter = new Integer(FILTER_PROJECT);
+ }
+
+ //get enablements
+ IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
+ if(enablements.length > 0)
+ booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
+
+ // get the applicability calculator, if any
+ String applicabilityCalculatorStr = element.getAttribute(APPLICABILITY_CALCULATOR);
+ if (applicabilityCalculatorStr != null && element instanceof DefaultManagedConfigElement) {
+ applicabilityCalculatorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ } else {
+ applicabilityCalculator = booleanExpressionCalculator;
+ }
+
+ // valueHandler
+ // Store the configuration element IFF there is a value handler defined
+ String valueHandler = element.getAttribute(VALUE_HANDLER);
+ if (valueHandler != null && element instanceof DefaultManagedConfigElement) {
+ valueHandlerElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+ // valueHandlerExtraArgument
+ valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
+ }
+
+ /* (non-Javadoc)
+ * Initialize the option information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the option information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionOption(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the command defined for the option
+ if (element.hasAttribute(COMMAND)) {
+ command = element.getAttribute(COMMAND);
+ }
+
+ // Get the command defined for a Boolean option when the value is False
+ if (element.hasAttribute(COMMAND_FALSE)) {
+ commandFalse = element.getAttribute(COMMAND_FALSE);
+ }
+
+ // Get the tooltip for the option
+ if (element.hasAttribute(TOOL_TIP)) {
+ tip = element.getAttribute(TOOL_TIP);
+ }
+
+ // Options hold different types of values
+ if (element.hasAttribute(VALUE_TYPE)) {
+ String valueTypeStr = element.getAttribute(VALUE_TYPE);
+ valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
+ }
+
+ // Now get the actual value based upon value-type
+ try {
+ int valType = getValueType();
+ switch (valType) {
+ case BOOLEAN:
+ // Convert the string to a boolean
+ if (element.hasAttribute(VALUE)) {
+ value = new Boolean(element.getAttribute(VALUE));
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = new Boolean(element.getAttribute(DEFAULT_VALUE));
+ }
+ break;
+ case STRING:
+ // Just get the value out of the option directly
+ if (element.hasAttribute(VALUE)) {
+ value = element.getAttribute(VALUE);
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+ }
+ break;
+ case ENUMERATED:
+ if (element.hasAttribute(VALUE)) {
+ value = element.getAttribute(VALUE);
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+ }
+
+ // Do we have enumeratedOptionValue children? If so, load them
+ // to define the valid values and the default value.
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configNode = configElements.item(i);
+ if (configNode.getNodeName().equals(ENUM_VALUE)) {
+ Element configElement = (Element)configNode;
+ String optId = configElement.getAttribute(ID);
+ if (i == 0) {
+ enumList = new ArrayList();
+ if (defaultValue == null) {
+ defaultValue = optId; // Default value to be overridden is default is specified
+ }
+ }
+ enumList.add(optId);
+ if (configElement.hasAttribute(COMMAND)) {
+ getEnumCommandMap().put(optId, configElement.getAttribute(COMMAND));
+ } else {
+ getEnumCommandMap().put(optId, EMPTY_STRING);
+ }
+ getEnumNameMap().put(optId, configElement.getAttribute(NAME));
+ if (configElement.hasAttribute(IS_DEFAULT)) {
+ Boolean isDefault = new Boolean(configElement.getAttribute(IS_DEFAULT));
+ if (isDefault.booleanValue()) {
+ defaultValue = optId;
+ }
+ }
+ }
+ }
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ // Note: These string-list options do not load either the "value" or
+ // "defaultValue" attributes. Instead, the ListOptionValue children
+ // are loaded in the value field.
+ List valueList = null;
+ configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ if (i == 0) {
+ valueList = new ArrayList();
+ builtIns = new ArrayList();
+ }
+ Node configNode = configElements.item(i);
+ if (configNode.getNodeName().equals(LIST_VALUE)) {
+ Element valueElement = (Element)configNode;
+ Boolean isBuiltIn;
+ if (valueElement.hasAttribute(IS_DEFAULT)) {
+ isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
+ } else {
+ isBuiltIn = new Boolean(false);
+ }
+ if (isBuiltIn.booleanValue()) {
+ builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ else {
+ valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ }
+ }
+ value = valueList;
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ }
+
+ // Determine if there needs to be a browse button
+ if (element.hasAttribute(BROWSE_TYPE)) {
+ String browseTypeStr = element.getAttribute(BROWSE_TYPE);
+
+ if (browseTypeStr == null) {
+ // Set to null, to indicate no browse type specification
+ // This will allow any superclasses to be searched for the
+ // browse type specification, and thus inherited, if found,
+ // which they should be
+ browseType = null;
+ } else if (browseTypeStr.equals(NONE)) {
+ browseType = new Integer(BROWSE_NONE);
+ } else if (browseTypeStr.equals(FILE)) {
+ browseType = new Integer(BROWSE_FILE);
+ } else if (browseTypeStr.equals(DIR)) {
+ browseType = new Integer(BROWSE_DIR);
+ }
+ }
+
+ if (element.hasAttribute(CATEGORY)) {
+ categoryId = element.getAttribute(CATEGORY);
+ if (categoryId != null) {
+ category = holder.getOptionCategory(categoryId);
+ }
+ }
+
+ // Get the resourceFilter attribute
+ if (element.hasAttribute(RESOURCE_FILTER)) {
+ String resFilterStr = element.getAttribute(RESOURCE_FILTER);
+ if (resFilterStr == null) {
+ // Set to null, to indicate no resource filter specification
+ // This will allow any superclasses to be searched for the
+ // resource filter specification, and thus inherited, if found,
+ // which they should be
+ resourceFilter = null;
+ } else if (resFilterStr.equals(ALL)) {
+ resourceFilter = new Integer(FILTER_ALL);
+ } else if (resFilterStr.equals(FILE)) {
+ resourceFilter = new Integer(FILTER_FILE);
+ } else if (resFilterStr.equals(PROJECT)) {
+ resourceFilter = new Integer(FILTER_PROJECT);
+ }
+ }
+
+ // Note: valueHandlerElement and VALUE_HANDLER are not restored,
+ // as they are not saved. See note in serialize().
+
+ // valueHandlerExtraArgument
+ if (element.hasAttribute(VALUE_HANDLER_EXTRA_ARGUMENT)) {
+ valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
+ }
+ }
+
+ private int ValueTypeStrToInt(String valueTypeStr) {
+ if (valueTypeStr == null) return -1;
+ if (valueTypeStr.equals(TYPE_STRING))
+ return STRING;
+ else if (valueTypeStr.equals(TYPE_STR_LIST))
+ return STRING_LIST;
+ else if (valueTypeStr.equals(TYPE_BOOL))
+ return BOOLEAN;
+ else if (valueTypeStr.equals(TYPE_ENUM))
+ return ENUMERATED;
+ else if (valueTypeStr.equals(TYPE_INC_PATH))
+ return INCLUDE_PATH;
+ else if (valueTypeStr.equals(TYPE_LIB))
+ return LIBRARIES;
+ else if (valueTypeStr.equals(TYPE_USER_OBJS))
+ return OBJECTS;
+ else if (valueTypeStr.equals(TYPE_DEFINED_SYMBOLS))
+ return PREPROCESSOR_SYMBOLS;
+ else {
+ // TODO: This was the CDT 2.0 default - should we keep it?
+ return PREPROCESSOR_SYMBOLS;
+ }
+ }
+
+ /**
+ * Persist the option to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) throws BuildException {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ if (command != null) {
+ element.setAttribute(COMMAND, command);
+ }
+
+ if (commandFalse != null) {
+ element.setAttribute(COMMAND_FALSE, commandFalse);
+ }
+
+ if (tip != null) {
+ element.setAttribute(TOOL_TIP, tip);
+ }
+
+ /*
+ * Note: We store value & value-type as a pair, so we know what type of value we are
+ * dealing with when we read it back in.
+ * This is also true of defaultValue.
+ */
+ boolean storeValueType = false;
+
+ // value
+ if (value != null) {
+ storeValueType = true;
+ switch (getValueType()) {
+ case BOOLEAN:
+ element.setAttribute(VALUE, ((Boolean)value).toString());
+ break;
+ case STRING:
+ case ENUMERATED:
+ element.setAttribute(VALUE, (String)value);
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ if (value != null) {
+ ArrayList stringList = (ArrayList)value;
+ ListIterator iter = stringList.listIterator();
+ while (iter.hasNext()) {
+ Element valueElement = doc.createElement(LIST_VALUE);
+ valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
+ valueElement.setAttribute(LIST_ITEM_BUILTIN, "false"); //$NON-NLS-1$
+ element.appendChild(valueElement);
+ }
+ }
+ // Serialize the built-ins that have been overridden
+ if (builtIns != null) {
+ ListIterator iter = builtIns.listIterator();
+ while (iter.hasNext()) {
+ Element valueElement = doc.createElement(LIST_VALUE);
+ valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
+ valueElement.setAttribute(LIST_ITEM_BUILTIN, "true"); //$NON-NLS-1$
+ element.appendChild(valueElement);
+ }
+ }
+ break;
+ }
+ }
+
+ // defaultValue
+ if (defaultValue != null) {
+ storeValueType = true;
+ switch (getValueType()) {
+ case BOOLEAN:
+ element.setAttribute(DEFAULT_VALUE, ((Boolean)defaultValue).toString());
+ break;
+ case STRING:
+ case ENUMERATED:
+ element.setAttribute(DEFAULT_VALUE, (String)defaultValue);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (storeValueType) {
+ String str;
+ switch (getValueType()) {
+ case BOOLEAN:
+ str = TYPE_BOOL;
+ break;
+ case STRING:
+ str = TYPE_STRING;
+ break;
+ case ENUMERATED:
+ str = TYPE_ENUM;
+ break;
+ case STRING_LIST:
+ str = TYPE_STR_LIST;
+ break;
+ case INCLUDE_PATH:
+ str = TYPE_INC_PATH;
+ break;
+ case LIBRARIES:
+ str = TYPE_LIB;
+ break;
+ case OBJECTS:
+ str = TYPE_USER_OBJS;
+ break;
+ case PREPROCESSOR_SYMBOLS:
+ str = TYPE_DEFINED_SYMBOLS;
+ break;
+ default:
+ // TODO; is this a problem...
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(VALUE_TYPE, str);
+ }
+
+ // browse type
+ if (browseType != null) {
+ String str;
+ switch (getBrowseType()) {
+ case BROWSE_NONE:
+ str = NONE;
+ break;
+ case BROWSE_FILE:
+ str = FILE;
+ break;
+ case BROWSE_DIR:
+ str = DIR;
+ break;
+ default:
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(BROWSE_TYPE, str);
+ }
+
+ if (categoryId != null) {
+ element.setAttribute(CATEGORY, categoryId);
+ }
+
+ // resource filter
+ if (resourceFilter != null) {
+ String str;
+ switch (getResourceFilter()) {
+ case FILTER_ALL:
+ str = ALL;
+ break;
+ case FILTER_FILE:
+ str = FILE;
+ break;
+ case FILTER_PROJECT:
+ str = PROJECT;
+ break;
+ default:
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(RESOURCE_FILTER, str);
+ }
+
+ // Note: applicability calculator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (applicabilityCalculatorElement != null) {
+ // TODO: issue warning?
+ }
+
+ // Note: a value handler cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (valueHandlerElement != null) {
+ // TODO: Issue warning? Stuck with behavior of this elsewhere in
+ // CDT, e.g. the implementation of Tool
+ }
+ if (valueHandlerExtraArgument != null) {
+ element.setAttribute(VALUE_HANDLER_EXTRA_ARGUMENT, valueHandlerExtraArgument);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getParent()
+ */
+ public IBuildObject getParent() {
+ return holder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getOptionHolder()
+ */
+ public IHoldsOptions getOptionHolder() {
+ // Do not take superclasses into account
+ return holder;
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getSuperClass()
+ */
+ public IOption getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getName()
+ */
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicableValues()
+ */
+ public String[] getApplicableValues() {
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getApplicableValues();
+ } else {
+ return EMPTY_STRING_ARRAY;
+ }
+ }
+ // Get all of the enumerated names from the option
+ if (enumList.size() == 0) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ // Return the elements in the order they are specified in the manifest
+ String[] enumNames = new String[enumList.size()];
+ for (int index = 0; index < enumList.size(); ++ index) {
+ enumNames[index] = (String) getEnumNameMap().get(enumList.get(index));
+ }
+ return enumNames;
+ }
+ }
+
+ public boolean getBooleanValue() {
+ return ((Boolean)getValue()).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseType()
+ */
+ public int getBrowseType() {
+ if (browseType == null) {
+ if (superClass != null) {
+ return superClass.getBrowseType();
+ } else {
+ return BROWSE_NONE;
+ }
+ }
+ return browseType.intValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getResourceFilter()
+ */
+ public int getResourceFilter() {
+ if (resourceFilter == null) {
+ if (superClass != null) {
+ return superClass.getResourceFilter();
+ } else {
+ return FILTER_ALL;
+ }
+ }
+ return resourceFilter.intValue();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculatorElement()
+ */
+ public IConfigurationElement getApplicabilityCalculatorElement() {
+/* if (applicabilityCalculatorElement == null) {
+ if (superClass != null) {
+ return ((Option)superClass).getApplicabilityCalculatorElement();
+ }
+ }
+*/
+ return applicabilityCalculatorElement;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculator()
+ */
+ public IOptionApplicability getApplicabilityCalculator() {
+ if (applicabilityCalculator == null) {
+ if (applicabilityCalculatorElement != null) {
+ try {
+ if (applicabilityCalculatorElement.getAttribute(APPLICABILITY_CALCULATOR) != null)
+ applicabilityCalculator = (IOptionApplicability) applicabilityCalculatorElement
+ .createExecutableExtension(APPLICABILITY_CALCULATOR);
+ } catch (CoreException e) {
+ }
+ }
+ else if(superClass != null)
+ applicabilityCalculator = superClass.getApplicabilityCalculator();
+ }
+
+ return applicabilityCalculator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getBuiltIns()
+ */
+ public String[] getBuiltIns() {
+ // Return the list of built-ins as an array
+ if (builtIns == null) {
+ if (superClass != null) {
+ return superClass.getBuiltIns();
+ } else {
+ return EMPTY_STRING_ARRAY;
+ }
+ }
+ return (String[])builtIns.toArray(new String[builtIns.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getCategory()
+ */
+ public IOptionCategory getCategory() {
+ if (category == null) {
+ if (superClass != null) {
+ return superClass.getCategory();
+ } else {
+ if (getOptionHolder() instanceof ITool) {
+ return ((ITool)getOptionHolder()).getTopOptionCategory();
+ } else {
+ return null;
+ }
+ }
+ }
+ return category;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getCommand()
+ */
+ public String getCommand() {
+ if (command == null) {
+ if (superClass != null) {
+ return superClass.getCommand();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getCommandFalse()
+ */
+ public String getCommandFalse() {
+ if (commandFalse == null) {
+ if (superClass != null) {
+ return superClass.getCommandFalse();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return commandFalse;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getToolTip()
+ */
+ public String getToolTip() {
+ if (tip == null) {
+ if (superClass != null) {
+ return superClass.getToolTip();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return tip;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefinedSymbols()
+ */
+ public String[] getDefinedSymbols() throws BuildException {
+ if (getValueType() != PREPROCESSOR_SYMBOLS) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumCommand(java.lang.String)
+ */
+ public String getEnumCommand(String id) throws BuildException {
+ // Sanity
+ if (id == null) return EMPTY_STRING;
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumCommand(id);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+
+ // First check for the command in ID->command map
+ String cmd = (String) getEnumCommandMap().get(id);
+ if (cmd == null) {
+ // This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
+ // name of the enumeration. Search for the ID that maps to the name and use that to find the
+ // command.
+ ListIterator iter = enumList.listIterator();
+ while (iter.hasNext()) {
+ String realID = (String) iter.next();
+ String name = (String) getEnumNameMap().get(realID);
+ if (id.equals(name)) {
+ cmd = (String) getEnumCommandMap().get(realID);
+ break;
+ }
+ }
+ }
+ return cmd == null ? EMPTY_STRING : cmd;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumName(java.lang.String)
+ */
+ public String getEnumName(String id) throws BuildException {
+ // Sanity
+ if (id == null) return EMPTY_STRING;
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumName(id);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+
+ // First check for the command in ID->name map
+ String name = (String) getEnumNameMap().get(id);
+ if (name == null) {
+ // This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
+ // name of the enumeration.
+ name = id;
+ }
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * A memory-safe accessor to the map of enumerated option value IDs to the commands
+ * that a tool understands.
+ *
+ * @return a Map of enumerated option value IDs to actual commands that are passed
+ * to a tool on the command line.
+ */
+ private Map getEnumCommandMap() {
+ if (enumCommands == null) {
+ enumCommands = new HashMap();
+ }
+ return enumCommands;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumeratedId(java.lang.String)
+ */
+ public String getEnumeratedId(String name) throws BuildException {
+ if (name == null) return null;
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumeratedId(name);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+
+ Set idSet = getEnumNameMap().keySet();
+ Iterator iter = idSet.iterator();
+ while (iter.hasNext()) {
+ String id = (String) iter.next();
+ String enumName = (String) getEnumNameMap().get(id);
+ if (name.equals(enumName)) {
+ return id;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ *
+ * @return a Map of enumerated option value IDs to the selection displayed to the user.
+ */
+ private Map getEnumNameMap() {
+ if (enumNames == null) {
+ enumNames = new HashMap();
+ }
+ return enumNames;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getIncludePaths()
+ */
+ public String[] getIncludePaths() throws BuildException {
+ if (getValueType() != INCLUDE_PATH) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getLibraries()
+ */
+ public String[] getLibraries() throws BuildException {
+ if (getValueType() != LIBRARIES) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefaultEnumValue()
+ */
+ public String getSelectedEnum() throws BuildException {
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ return getStringValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getStringListValue()
+ */
+ public String[] getStringListValue() throws BuildException {
+ if (getValueType() != STRING_LIST) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getStringValue()
+ */
+ public String getStringValue() throws BuildException {
+ if (getValueType() != STRING && getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ return getValue() == null ? EMPTY_STRING : (String)getValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getUserObjects()
+ */
+ public String[] getUserObjects() throws BuildException {
+ if (getValueType() != OBJECTS) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ // This is the right puppy, so return its list value
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueType()
+ */
+ public int getValueType() throws BuildException {
+ if (valueType == null) {
+ if (superClass != null) {
+ return superClass.getValueType();
+ } else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$;
+ }
+ }
+ return valueType.intValue();
+ }
+
+ /* (non-Javadoc)
+ * Gets the value, applying appropriate defaults if necessary.
+ */
+ public Object getValue() {
+ /*
+ * In order to determine the current value of an option, perform the following steps until a value is found:
+ * 1. Examine the value attribute of the option.
+ * 2. Examine the value attribute of the optionís superClass recursively.
+ * 3. Examine the dynamicDefaultValue attribute of the option and invoke it if specified. (not yet implemented)
+ * 4. Examine the defaultValue attribute of the option.
+ * 5. Examine the dynamicDefaultValue attribute of the optionís superClass and invoke it if specified. (not yet implemented)
+ * 6. Examine the defaultValue attribute of the optionís superClass.
+ * 7. Go to step 5 recursively until no more super classes.
+ * 8. Use the default value for the option type.
+ */
+
+ Object val = getRawValue();
+ if (val == null) {
+ val = getDefaultValue();
+ if (val == null) {
+ int valType;
+ try {
+ valType = getValueType();
+ } catch (BuildException e) {
+ return EMPTY_STRING;
+ }
+ switch (valType) {
+ case BOOLEAN:
+ val = new Boolean(false);
+ break;
+ case STRING:
+ val = EMPTY_STRING;
+ break;
+ case ENUMERATED:
+ // TODO: Can we default to the first enumerated id?
+ val = EMPTY_STRING;
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ val = new ArrayList();
+ break;
+ default:
+ val = EMPTY_STRING;
+ break;
+ }
+ }
+ }
+ return val;
+ }
+
+ /* (non-Javadoc)
+ * Gets the raw value, applying appropriate defauls if necessary.
+ */
+ public Object getRawValue() {
+ if (value == null) {
+ if (superClass != null) {
+ Option mySuperClass = (Option)superClass;
+ return mySuperClass.getRawValue();
+ }
+ }
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * Gets the raw default value.
+ */
+ public Object getDefaultValue() {
+ // Note: string-list options do not have a default value
+ if (defaultValue == null) {
+ if (superClass != null) {
+ return superClass.getDefaultValue();
+ }
+ }
+ return defaultValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
+ */
+ public void setDefaultValue(Object v) {
+ defaultValue = v;
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
+ */
+ public void setCategory(IOptionCategory category) {
+ if (this.category != category) {
+ this.category = category;
+ if (category != null) {
+ categoryId = category.getId();
+ } else {
+ categoryId = null;
+ }
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setCommand(String)
+ */
+ public void setCommand(String cmd) {
+ if (cmd == null && command == null) return;
+ if (cmd == null || command == null || !cmd.equals(command)) {
+ command = cmd;
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setCommandFalse(String)
+ */
+ public void setCommandFalse(String cmd) {
+ if (cmd == null && commandFalse == null) return;
+ if (cmd == null || commandFalse == null || !cmd.equals(commandFalse)) {
+ commandFalse = cmd;
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setToolTip(String)
+ */
+ public void setToolTip(String tooltip) {
+ if (tooltip == null && tip == null) return;
+ if (tooltip == null || tip == null || !tooltip.equals(tip)) {
+ tip = tooltip;
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
+ */
+ public void setResourceFilter(int filter) {
+ if (resourceFilter == null || !(filter == resourceFilter.intValue())) {
+ resourceFilter = new Integer(filter);
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setBrowseType(int)
+ */
+ public void setBrowseType(int type) {
+ if (browseType == null || !(type == browseType.intValue())) {
+ browseType = new Integer(type);
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(boolean)
+ */
+ public void setValue(boolean value) throws BuildException {
+ if (/*!isExtensionElement() && */getValueType() == BOOLEAN){
+ this.value = new Boolean(value);
+ } else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String)
+ */
+ public void setValue(String value) throws BuildException {
+ // Note that we can still set the human-readable value here
+ if (/*!isExtensionElement() && */(getValueType() == STRING || getValueType() == ENUMERATED)) {
+ this.value = value;
+ } else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String [])
+ */
+ public void setValue(String [] value) throws BuildException {
+ if (/*!isExtensionElement() && */
+ (getValueType() == STRING_LIST
+ || getValueType() == INCLUDE_PATH
+ || getValueType() == PREPROCESSOR_SYMBOLS
+ || getValueType() == LIBRARIES
+ || getValueType() == OBJECTS)) {
+ // Just replace what the option reference is holding onto
+ if(value == null)
+