Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-09-15 16:44:43 -0400
committerDoug Schaefer2003-09-15 16:44:43 -0400
commitd18851f2d7a8140dfd3930f1dd838e79bdf3c0db (patch)
tree3253237d790a40a4bff4cd55bf9aef6cb4d14297 /core/org.eclipse.cdt.core/build
parentc96f650a35f2ffcfd362332fbfc558a6afef241f (diff)
downloadorg.eclipse.cdt-d18851f2d7a8140dfd3930f1dd838e79bdf3c0db.tar.gz
org.eclipse.cdt-d18851f2d7a8140dfd3930f1dd838e79bdf3c0db.tar.xz
org.eclipse.cdt-d18851f2d7a8140dfd3930f1dd838e79bdf3c0db.zip
Patch for Sean Evoy:
- Move the managed builder to it's own plugins and feature.
Diffstat (limited to 'core/org.eclipse.cdt.core/build')
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/BuildException.java21
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IBuildObject.java21
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IConfiguration.java75
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java200
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java163
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java50
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java130
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java116
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java566
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/BuildObject.java50
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java319
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java505
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java317
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java120
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java412
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java371
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java359
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java339
18 files changed, 0 insertions, 4134 deletions
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/BuildException.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/BuildException.java
deleted file mode 100644
index 4ba6c708d7..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/BuildException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Created on Apr 9, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.cdt.core.build.managed;
-
-/**
- * @author dschaefe
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class BuildException extends Exception {
-
- public BuildException(String msg) {
- super(msg);
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IBuildObject.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IBuildObject.java
deleted file mode 100644
index 2529da7ec8..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IBuildObject.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.core.build.managed;
-
-public interface IBuildObject {
- // Schema element names
- public static final String ID = "id";
- public static final String NAME = "name";
-
- public String getId();
- public String getName();
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IConfiguration.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IConfiguration.java
deleted file mode 100644
index f61c914313..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IConfiguration.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.core.build.managed;
-
-import org.eclipse.core.resources.IResource;
-
-public interface IConfiguration extends IBuildObject {
- // Schema element names
- public static final String CONFIGURATION_ELEMENT_NAME = "configuration"; //$NON-NLS-1$
- public static final String TOOL_REF = "toolReference"; //$NON-NLS-1$
- public static final String PARENT = "parent"; //$NON-NLS-1$
-
- /**
- * Returns the target for this configuration.
- *
- * @return
- */
- public ITarget getTarget();
-
- /**
- * Returns the resource that owns the target that owns the configuration.
- * @return
- */
- public IResource getOwner();
-
- /**
- * Answers the configuration that the receiver is based on.
- *
- * @return
- */
- public IConfiguration getParent();
-
- /**
- * Returns the tools that are used in this configuration.
- *
- * @return
- */
- public ITool[] getTools();
-
- /**
- * Sets the value of a boolean option for this configuration.
- *
- * @param option The option to change.
- * @param value The value to apply to the option.
- * @throws BuildException
- */
- public void setOption(IOption option, boolean value)
- throws BuildException;
-
- /**
- * Sets the value of a string option for this configuration.
- *
- * @param option The option that will be effected by change.
- * @param value The value to apply to the option.
- */
- public void setOption(IOption option, String value)
- throws BuildException;
-
- /**
- * Sets the value of a list option for this configuration.
- *
- * @param option The option to change.
- * @param value The values to apply to the option.
- */
- public void setOption(IOption option, String[] value)
- throws BuildException;
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
deleted file mode 100644
index c60e45474e..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IManagedBuildInfo.java
+++ /dev/null
@@ -1,200 +0,0 @@
-package org.eclipse.cdt.core.build.managed;
-
-import java.util.List;
-
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
-public interface IManagedBuildInfo {
-
- /**
- * 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 the name of the artifact to build for the receiver.
- *
- * @return
- */
- public String getBuildArtifactName();
-
- /**
- * 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's current target.
- *
- * @return
- */
- public String[] getConfigurationNames();
-
- /**
- * Get the default configuration associated with the receiver
- *
- * @return
- */
- public IConfiguration getDefaultConfiguration(ITarget target);
-
-
- /**
- * Returns the default target in the receiver.
- *
- * @return
- */
- public ITarget getDefaultTarget();
-
- /**
- * Answers the extension that will be built by the current configuration
- * for the extension passed in the argument or <code>null</code>.
- *
- * @param resourceName
- * @return
- */
- public String getOutputExtension(String resourceExtension);
-
- /**
- * Answers the flag to be passed to the build tool to produce a specific output
- * or an empty <code>String</code> if there is no special flag. For example, the
- * GCC tools use the '-o' flag to produce a named output, for example
- * gcc -c foo.c -o foo.o
- *
- * @param outputExt
- * @return
- */
- public String getOutputFlag(String outputExt);
-
- /**
- * Get the target specified in the argument.
- *
- * @param id
- * @return
- */
- public ITarget getTarget(String id);
-
- /**
- * Answers the prefix that should be prepended to the name of the build
- * artifact. For example, a library foo, should have the prefix 'lib' and
- * the extension '.a', so the final goal would be 'libfoo.a'
- *
- * @param extension
- * @return
- */
- public String getOutputPrefix(String outputExtension);
-
- /**
- * Get all of the targets associated with the receiver.
- *
- * @return
- */
- public List getTargets();
-
- /**
- * 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.
- *
- * @param extension
- * @return
- */
- 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 target defined by the argument.
- *
- * @param extension
- * @return
- */
- public String getFlagsForTarget(String extension);
-
- /**
- * Answers the libraries the project links in.
- *
- * @param extension
- * @return
- */
- public String[] getLibsForTarget(String extension);
-
- /**
- * Answers a string array containing the arguments to be passed to
- * make. For example, if the user has selected a build that stops
- * at the first error, the array would contain {"k"}.
- *
- * @return
- */
- public String[] getMakeArguments();
-
- /**
- * Answers a <code>String</code> containing the make command invocation
- * for the default target/configuration.
- */
- public String getMakeCommand();
-
- /**
- * Returns a <code>String</code> containing the command-line invocation
- * for the tool associated with the source extension.
- *
- * @param extension
- * @return
- */
- public String getToolForSource(String extension);
-
- /**
- * Returns a <code>String</code> containing the command-line invocation
- * for the tool associated with the target extension.
- *
- * @param extension
- * @return
- */
- public String getToolForTarget(String extension);
-
- /**
- * 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);
-
- /**
- * Set the primary target for the receiver.
- *
- * @param target
- */
- public void setDefaultTarget(ITarget target);
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
deleted file mode 100644
index 496a2ace23..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.core.build.managed;
-
-/**
- *
- */
-public interface IOption extends IBuildObject {
- // Type for the value of the option
- public static final int BOOLEAN = 0;
- public static final int ENUMERATED = 1;
- public static final int STRING = 2;
- public static final int STRING_LIST = 3;
- public static final int INCLUDE_PATH = 4;
- public static final int PREPROCESSOR_SYMBOLS = 5;
- public static final int LIBRARIES = 6;
-
- // Schema attribute names for option elements
- public static final String CATEGORY = "category";
- public static final String COMMAND = "command";
- public static final String DEFAULT_VALUE = "defaultValue";
- public static final String ENUM_VALUE = "enumeratedOptionValue";
- public static final String IS_DEFAULT = "isDefault";
- public static final String LIST_VALUE = "listOptionValue";
- public static final String TYPE_BOOL = "boolean";
- public static final String TYPE_ENUM = "enumerated";
- public static final String TYPE_INC_PATH = "includePath";
- public static final String TYPE_LIB = "libs";
- public static final String TYPE_STRING = "string";
- public static final String TYPE_STR_LIST = "stringList";
- public static final String VALUE_TYPE = "valueType";
-
- // Schema attribute names for listOptionValue elements
- public static final String LIST_ITEM_VALUE = "value";
- public static final String LIST_ITEM_BUILTIN = "builtIn";
-
-
- /**
- * If this option is defined as an enumeration, this function returns
- * the list of possible values for that enum.
- *
- * If this option is not defined as an enumeration, it returns <code>null</code>.
- * @return
- */
- public String [] getApplicableValues();
-
- /**
- * Answers the value for a boolean option.
- *
- * @return
- * @throws BuildException
- */
- public boolean getBooleanValue() throws BuildException;
-
- /**
- * Answers an array of strings containing the built-in values
- * defined for a stringList, includePaths, definedSymbols, or libs
- * option. If none have been defined, the array will be empty but
- * never <code>null</code>.
- *
- * @return
- */
- public String[] getBuiltIns();
-
- /**
- * Returns the category for this option.
- *
- * @return
- */
- public IOptionCategory getCategory();
-
- /**
- * Answers a <code>String</code> containing the actual command line
- * option associated with the option
- *
- * @return
- */
- public String getCommand();
-
- /**
- * @return
- * @throws BuildException
- */
- public String[] getDefinedSymbols() throws BuildException;
-
- /**
- * Answers the command associated with the enumeration name. For
- * example, if the enumeration name was 'Default' for the debug
- * level option of the Gnu compiler, and the plugin manifest defined
- * that as -g, then the return value would be a String containing "-g"
- *
- * @return
- */
- public String getEnumCommand (String name);
-
- /**
- * Answers an array of <code>String</code> containing the includes paths
- * defined in the build model.
- *
- * @return
- * @throws BuildException
- */
- public String[] getIncludePaths() throws BuildException;
-
-
- /**
- * Answers an array or <code>String</code>s containing the libraries
- * that must be linked into the project.
- * @return
- */
- public String[] getLibraries() throws BuildException ;
-
- /**
- * Answers a <code>String</code> containing the selected enumeration in an
- * enumerated option. For an option that has not been changed by the user,
- * the receiver will answer with the default defined in the plugin manifest.
- * If the user has modified the selection, the receiver will answer with the
- * overridden selection.
- *
- * @return
- * @throws BuildException
- */
- public String getSelectedEnum () throws BuildException;
-
- /**
- * Returns the current value for this option if it is a List of Strings.
- *
- * @return
- * @throws BuildException
- */
- public String [] getStringListValue() throws BuildException;
-
- /**
- * Returns the current value for this option if it is a String
- *
- * @return
- * @throws BuildException
- */
- public String getStringValue() throws BuildException;
-
- /**
- * Returns the tool defining this option.
- *
- * @return
- */
- public ITool getTool();
-
- /**
- * Get the type for the value of the option.
- *
- * @return
- */
- public int getValueType();
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java
deleted file mode 100644
index e0b5a7bfcf..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOptionCategory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.core.build.managed;
-
-/**
- *
- */
-public interface IOptionCategory extends IBuildObject {
-
- // Schema element names
- public static final String PARENT = "parent";
-
- /**
- * Returns the list of children of this node in the option category tree
- *
- * @return
- */
- public IOptionCategory[] getChildCategories();
-
- /**
- * Returns the options in this category for a given configuration.
- *
- * @param tool
- * @return
- */
- public IOption[] getOptions(IConfiguration configuration);
-
- /**
- * Returns the category that owns this category, or null if this is the
- * top category for a tool.
- *
- * @return
- */
- public IOptionCategory getOwner();
-
- /**
- * Returns the tool that ultimately owns this category.
- *
- * @return
- */
- public ITool getTool();
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java
deleted file mode 100644
index d22f5a5610..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.core.build.managed;
-
-import org.eclipse.core.resources.IResource;
-
-/**
- * This class represents targets for the managed build process. A target
- * is some type of resource built using a given collection of tools.
- */
-public interface ITarget extends IBuildObject {
- public static final String TARGET_ELEMENT_NAME = "target"; //$NON-NLS-1$
-
- /**
- * Creates a configuration for the target populated with the tools and
- * options settings from the parent configuration. As options and tools
- * change in the parent, unoverridden values are updated in the child
- * config as well.
- *
- * @param parent
- * @param id
- * @return
- */
- public IConfiguration createConfiguration(IConfiguration parent, String id);
-
- /**
- * Creates a new configuration for the target. It is populated with
- * the tools defined for that target and options set at their defaults.
- *
- * @param id id for this configuration.
- * @return
- */
- public IConfiguration createConfiguration(String id);
-
- /**
- * Get the name of the final build artifact.
- *
- * @return
- */
- public String getArtifactName();
-
- /**
- * Answers the OS-specific command to remove files created by the build
- *
- * @return
- */
- public String getCleanCommand();
-
- /**
- * Returns all of the configurations defined by this target.
- * @return
- */
- public IConfiguration[] getConfigurations();
-
- /**
- * Get the default extension that should be applied to build artifacts
- * created by this target.
- *
- * @return
- */
- public String getDefaultExtension();
-
- /**
- * Answers the name of the make utility for the target.
- *
- * @return
- */
- public String getMakeCommand();
-
- /**
- * Returns the configuration with the given id, or null if not found.
- *
- * @param id
- * @return
- */
- public IConfiguration getConfiguration(String id);
-
- /**
- * Gets the resource that this target is applied to.
- *
- * @return
- */
- public IResource getOwner();
-
- /**
- * @return the <code>ITarget</code> that is the parent of the receiver.
- */
- public ITarget getParent();
-
- /**
- * Returns the list of platform specific tools associated with this
- * platform.
- *
- * @return
- */
- public ITool[] getTools();
-
- /**
- * Returns whether this target is abstract.
- * @return
- */
- public boolean isAbstract();
-
- /**
- * Answers <code>true</code> if the receiver is a target that is defined
- * for testing purposes only, else <code>false</code>. A test target will
- * not be shown in the UI but can still be manipulated programmatically.
- *
- * @return
- */
- public boolean isTestTarget();
-
- /**
- * Set the name of the artifact that will be produced when the receiver
- * is built.
- *
- * @param name The name of the build artifact.
- */
- public void setBuildArtifact(String name);
-
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
deleted file mode 100644
index 85f0be6c3d..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.core.build.managed;
-
-/**
- *
- */
-public interface ITool extends IBuildObject {
- // Schema element names
- public static final String TOOL_ELEMENT_NAME = "tool"; //$NON-NLS-1$
- public static final String COMMAND = "command"; //$NON-NLS-1$
- public static final String OPTION = "option"; //$NON-NLS-1$
- public static final String OPTION_CAT = "optionCategory"; //$NON-NLS-1$
- public static final String OPTION_REF = "optionReference"; //$NON-NLS-1$
- public static final String OUTPUT_FLAG = "outputFlag"; //$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 WHITE_SPACE = " "; //$NON-NLS-1$
-
- /**
- * Return <code>true</code> if the receiver builds files with the
- * specified extension, else <code>false</code>.
- *
- * @param extension
- * @return
- */
- public boolean buildsFileType(String extension);
-
- /**
- * Get a particular option.
- *
- * @param id
- * @return
- */
- public IOption getOption(String id);
-
- /**
- * Returns the options that may be customized for this tool.
- */
- public IOption[] getOptions();
-
- /**
- * 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
- */
- public String getOutputExtension(String inputExtension);
-
- /**
- * 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
- */
- public String getOutputFlag();
-
- /**
- * 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
- */
- public String getOutputPrefix();
-
- /**
- * Return the target that defines this tool, if applicable
- * @return
- */
- public ITarget getTarget();
-
- /**
- * Answers the command-line invocation defined for the receiver.
- *
- * @return
- */
- public String getToolCommand();
-
- /**
- * Answers the additional command line arguments the user has specified for
- * the tool.
- *
- * @return
- */
- public String getToolFlags() 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
- */
- public IOptionCategory getTopOptionCategory();
-
- /**
- * Answers <code>true</code> if the receiver builds a file with the extension specified
- * in the argument, else <code>false</code>.
- *
- * @param outputExtension
- * @return
- */
- public boolean producesFileType(String outputExtension);
-
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
deleted file mode 100644
index c99e26dde3..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
+++ /dev/null
@@ -1,566 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.core.build.managed;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.xerces.dom.DocumentImpl;
-import org.apache.xml.serialize.Method;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.Serializer;
-import org.apache.xml.serialize.SerializerFactory;
-import org.eclipse.cdt.core.AbstractCExtension;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.parser.*;
-import org.eclipse.cdt.internal.core.build.managed.Configuration;
-import org.eclipse.cdt.internal.core.build.managed.ManagedBuildInfo;
-import org.eclipse.cdt.internal.core.build.managed.Target;
-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.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.QualifiedName;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * This is the main entry point for getting at the build information
- * for the managed build system.
- */
-public class ManagedBuildManager extends AbstractCExtension implements IScannerInfoProvider {
-
- private static final QualifiedName buildInfoProperty = new QualifiedName(CCorePlugin.PLUGIN_ID, "managedBuildInfo");
- private static final String ROOT_ELEM_NAME = "ManagedProjectBuildInfo"; //$NON-NLS-1$
- private static final String FILE_NAME = ".cdtbuild"; //$NON-NLS-1$
- private static final ITarget[] emptyTargets = new ITarget[0];
- public static final String INTERFACE_IDENTITY = CCorePlugin.PLUGIN_ID + "." + "ManagedBuildManager"; //$NON-NLS-1$
- public static final String EXTENSION_POINT_ID = "ManagedBuildInfo"; //$NON-NLS-1$
-
- // Targets defined by extensions (i.e., not associated with a resource)
- private static boolean extensionTargetsLoaded = false;
- private static List extensionTargets;
- private static Map extensionTargetMap;
-
- // Listeners interested in build model changes
- private static Map buildModelListeners;
-
- /**
- * Returns the list of targets that are defined by this project,
- * projects referenced by this project, and by the extensions.
- *
- * @param project
- * @return
- */
- public static ITarget[] getDefinedTargets(IProject project) {
- // Make sure the extensions are loaded
- loadExtensions();
-
- // Get the targets for this project and all referenced projects
- List definedTargets = null;
- // To Do
-
- // Create the array and copy the elements over
- int size = extensionTargets.size()
- + (definedTargets != null ? definedTargets.size() : 0);
-
- ITarget[] targets = new ITarget[size];
-
- int n = 0;
- for (int i = 0; i < extensionTargets.size(); ++i)
- targets[n++] = (ITarget)extensionTargets.get(i);
-
- if (definedTargets != null)
- for (int i = 0; i < definedTargets.size(); ++i)
- targets[n++] = (ITarget)definedTargets.get(i);
-
- return targets;
- }
-
- /**
- * @return
- */
- public static Map getExtensionTargetMap() {
- if (extensionTargetMap == null) {
- extensionTargetMap = new HashMap();
- }
- return extensionTargetMap;
- }
-
- /**
- * Returns the targets owned by this project. If none are owned,
- * an empty array is returned.
- *
- * @param project
- * @return
- */
- public static ITarget[] getTargets(IResource resource) {
- IManagedBuildInfo buildInfo = getBuildInfo(resource);
-
- if (buildInfo != null) {
- List targets = buildInfo.getTargets();
- return (ITarget[])targets.toArray(new ITarget[targets.size()]);
- } else {
- return emptyTargets;
- }
- }
-
-
- /**
- * Answers the result of a best-effort search to find a target with the
- * specified ID, or <code>null</code> if one is not found.
- *
- * @param resource
- * @param id
- * @return
- */
- public static ITarget getTarget(IResource resource, String id) {
- ITarget target = null;
- // Check if the target is spec'd in the build info for the resource
- if (resource != null) {
- IManagedBuildInfo buildInfo = getBuildInfo(resource);
- if (buildInfo != null)
- target = buildInfo.getTarget(id);
- }
- // OK, check the extension map
- if (target == null) {
- target = (ITarget)getExtensionTargetMap().get(id);
- }
- return target;
- }
-
- /**
- * Creates a new target for the resource based on the parentTarget.
- *
- * @param resource
- * @param parentTarget
- * @return new <code>ITarget</code> with settings based on the parent passed in the arguments
- * @throws BuildException
- */
- public static ITarget createTarget(IResource resource, ITarget parentTarget)
- throws BuildException
- {
- IResource owner = parentTarget.getOwner();
-
- if (owner != null && owner.equals(resource))
- // Already added
- return parentTarget;
-
- if (resource instanceof IProject) {
- // Must be an extension target (why?)
- if (owner != null)
- throw new BuildException("addTarget: owner not null");
- } else {
- // Owner must be owned by the project containing this resource
- if (owner == null)
- throw new BuildException("addTarget: null owner");
- if (!owner.equals(resource.getProject()))
- throw new BuildException("addTarget: owner not project");
- }
-
- // Passed validation
- return new Target(resource, parentTarget);
- }
-
- /**
- * Sets the default configuration for the project. Note that this will also
- * update the default target if needed.
- *
- * @param project
- * @param newDefault
- */
- public static void setDefaultConfiguration(IProject project, IConfiguration newDefault) {
- if (project == null || newDefault == null) {
- return;
- }
- // Set the default in build information for the project
- IManagedBuildInfo info = getBuildInfo(project);
- if (info != null) {
- info.setDefaultConfiguration(newDefault);
- }
- }
-
- /**
- * @param config
- * @param option
- */
- private static void setDirty(IConfiguration config, IOption option) {
- // Don't bother unless this is something that effect the
- if (!(option.getValueType() == IOption.INCLUDE_PATH
- || option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) {
- return;
- }
- // Figure out if there is a listener for this change
- IResource resource = config.getOwner();
- List listeners = (List) getBuildModelListeners().get(resource);
- if (listeners == null) {
- return;
- }
- ListIterator iter = listeners.listIterator();
- while (iter.hasNext()) {
- ((IScannerInfoChangeListener)iter.next()).changeNotification(resource, getScannerInfo(resource));
- }
- }
-
- /**
- * Set the string value for an option for a given config.
- *
- * @param config The configuration the option belongs to.
- * @param option The option to set the value for.
- * @param value The boolean that the option should contain after the change.
- */
- public static void setOption(IConfiguration config, IOption option, boolean value) {
- try {
- config.setOption(option, value);
- setDirty(config, option);
- } catch (BuildException e) {
- return;
- }
- }
-
- /**
- * Set the string value for an option for a given config.
- *
- * @param config The configuration the option belongs to.
- * @param option The option to set the value for.
- * @param value The value that the option should contain after the change.
- */
- public static void setOption(IConfiguration config, IOption option, String value) {
- try {
- config.setOption(option, value);
- setDirty(config, option);
- } catch (BuildException e) {
- return;
- }
- }
-
- /**
- * Set the string array value for an option for a given config.
- *
- * @param config The configuration the option belongs to.
- * @param option The option to set the value for.
- * @param value The values the option should contain after the change.
- */
- public static void setOption(IConfiguration config, IOption option, String[] value) {
- try {
- config.setOption(option, value);
- setDirty(config, option);
- } catch (BuildException e) {
- return;
- }
- }
-
- /**
- * Saves the build information associated with a project and all resources
- * in the project to the build info file.
- *
- * @param project
- */
- public static void saveBuildInfo(IProject project) {
- // Create document
- Document doc = new DocumentImpl();
- Element rootElement = doc.createElement(ROOT_ELEM_NAME);
- doc.appendChild(rootElement);
-
- // Save the build info
- ManagedBuildInfo buildInfo = (ManagedBuildInfo) getBuildInfo(project);
- if (buildInfo != null)
- buildInfo.serialize(doc, rootElement);
-
- // Save the document
- ByteArrayOutputStream s = new ByteArrayOutputStream();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
- String xml = null;
- try {
- Serializer serializer
- = SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(new OutputStreamWriter(s, "UTF8"), format);
- serializer.asDOMSerializer().serialize(doc);
- xml = s.toString("UTF8"); //$NON-NLS-1$
- IFile rscFile = project.getFile(FILE_NAME);
- InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
- // update the resource content
- if (rscFile.exists()) {
- rscFile.setContents(inputStream, IResource.FORCE, null);
- } else {
- rscFile.create(inputStream, IResource.FORCE, null);
- }
- } catch (Exception e) {
- return;
- }
- }
-
- /**
- * @param resource
- */
- public static void removeBuildInfo(IResource resource) {
- try {
- resource.setSessionProperty(buildInfoProperty, null);
- } catch (CoreException e) {
- }
- }
-
- /**
- * Resets the build information for the project and configuration specified in the arguments.
- * The build information will contain the settings defined in the plugin manifest.
- *
- * @param project
- * @param configuration
- */
- public static void resetConfiguration(IProject project, IConfiguration configuration) {
- // Make sure the extensions are loaded
- loadExtensions();
-
- // Find out the parent of the configuration
- IConfiguration parentConfig = configuration.getParent();
- // Find the parent target the configuration
- ITarget parentTarget = parentConfig.getTarget();
-
- // Get the extension point information
- IExtensionPoint extensionPoint = CCorePlugin.getDefault().getDescriptor().getExtensionPoint(EXTENSION_POINT_ID);
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- IExtension extension = extensions[i];
- IConfigurationElement[] elements = extension.getConfigurationElements();
- for (int j = 0; j < elements.length; ++j) {
- IConfigurationElement element = elements[j];
- if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME) &&
- element.getAttribute(ITarget.ID).equals(parentTarget.getId())) {
- // We have the parent target so get the definition for the parent config
- IConfigurationElement[] targetElements = element.getChildren();
- for (int k = 0; k < targetElements.length; ++k) {
- IConfigurationElement targetElement = targetElements[k];
- if (targetElement.getName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME) &&
- targetElement.getAttribute(IConfiguration.ID).equals(parentConfig.getId())) {
- // We now have the plugin element the target was originally based on
- ((Configuration)configuration).reset(targetElement);
- }
- }
- }
- }
- }
- }
-
- // Private stuff
-
- public static void addExtensionTarget(Target target) {
- if (extensionTargets == null) {
- extensionTargets = new ArrayList();
- }
-
- extensionTargets.add(target);
- getExtensionTargetMap().put(target.getId(), target);
- }
-
- private static ManagedBuildInfo loadBuildInfo(IProject project) {
- ManagedBuildInfo buildInfo = null;
- IFile file = project.getFile(FILE_NAME);
- if (!file.exists())
- return null;
-
- try {
- InputStream stream = file.getContents();
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document document = parser.parse(stream);
- Node rootElement = document.getFirstChild();
- if (rootElement.getNodeName().equals(ROOT_ELEM_NAME)) {
- buildInfo = new ManagedBuildInfo(project, (Element)rootElement);
- project.setSessionProperty(buildInfoProperty, buildInfo);
- }
- } catch (Exception e) {
- buildInfo = null;
- }
-
- return buildInfo;
- }
-
- private static void loadExtensions() {
- if (extensionTargetsLoaded)
- return;
- extensionTargetsLoaded = true;
-
- IExtensionPoint extensionPoint = CCorePlugin.getDefault().getDescriptor().getExtensionPoint(EXTENSION_POINT_ID);
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- IExtension extension = extensions[i];
- IConfigurationElement[] elements = extension.getConfigurationElements();
- for (int j = 0; j < elements.length; ++j) {
- IConfigurationElement element = elements[j];
- if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME)) {
- new Target(element);
- }
- }
- }
- }
-
- /**
- * @param project
- * @return
- */
- public static boolean manages(IResource resource) {
- // The managed build manager manages build information for the
- // resource IFF it it is a project and has a build file with the proper
- // root element
- IProject project = null;
- if (resource instanceof IProject){
- project = (IProject)resource;
- } else if (resource instanceof IFile) {
- project = ((IFile)resource).getProject();
- } else {
- return false;
- }
- IFile file = project.getFile(FILE_NAME);
- if (file.exists()) {
- try {
- InputStream stream = file.getContents();
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document document = parser.parse(stream);
- Node rootElement = document.getFirstChild();
- if (rootElement.getNodeName().equals(ROOT_ELEM_NAME)) {
- return true;
- }
- } catch (Exception e) {
- return false;
- }
- }
- return false;
- }
-
- private static ManagedBuildInfo findBuildInfo(IResource resource, boolean create) {
- // Make sure the extension information is loaded first
- loadExtensions();
- ManagedBuildInfo buildInfo = null;
- try {
- buildInfo = (ManagedBuildInfo)resource.getSessionProperty(buildInfoProperty);
- } catch (CoreException e) {
- return buildInfo;
- }
-
- if (buildInfo == null && resource instanceof IProject) {
- buildInfo = loadBuildInfo((IProject)resource);
- }
-
- if (buildInfo == null && create) {
- try {
- buildInfo = new ManagedBuildInfo();
- resource.setSessionProperty(buildInfoProperty, buildInfo);
- } catch (CoreException e) {
- buildInfo = null;
- }
- }
-
- return buildInfo;
- }
-
- public static IManagedBuildInfo getBuildInfo(IResource resource, boolean create) {
- return (IManagedBuildInfo) findBuildInfo(resource, create);
- }
-
- public static IManagedBuildInfo getBuildInfo(IResource resource) {
- return (IManagedBuildInfo) findBuildInfo(resource, false);
- }
-
- /*
- * @return
- */
- private static Map getBuildModelListeners() {
- if (buildModelListeners == null) {
- buildModelListeners = new HashMap();
- }
- return buildModelListeners;
- }
-
- /**
- * Answers with an interface to the parse information that has been
- * associated with the resource specified in the argument.
- *
- * @deprecated This method is not part of the registration interface.
- * Clients of build information should now use getScannerInformation(IResource)
- * for one-time information requests.
- *
- * @param resource
- * @return
- */
- public static IScannerInfo getScannerInfo(IResource resource) {
- return (IScannerInfo) getBuildInfo(resource, false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
- */
- public IScannerInfo getScannerInformation(IResource resource) {
- return (IScannerInfo) getBuildInfo(resource, false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#subscribe(org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
- */
- public synchronized void subscribe(IResource resource, IScannerInfoChangeListener listener) {
- IResource project = null;
- if (resource instanceof IProject) {
- project = resource;
- } else if (resource instanceof IFile) {
- project = ((IFile)resource).getProject();
- } else {
- return;
- }
- // Get listeners for this resource
- Map map = getBuildModelListeners();
- List list = (List) map.get(project);
- if (list == null) {
- // Create a new list
- list = new ArrayList();
- }
- if (!list.contains(listener)) {
- // Add the new listener for the resource
- list.add(listener);
- map.put(project, list);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#unsubscribe(org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
- */
- public synchronized void unsubscribe(IResource resource, IScannerInfoChangeListener listener) {
- IResource project = null;
- if (resource instanceof IProject) {
- project = resource;
- } else if (resource instanceof IFile) {
- project = ((IFile)resource).getProject();
- } else {
- return;
- }
- // Remove the listener
- Map map = getBuildModelListeners();
- List list = (List) map.get(project);
- if (list != null && !list.isEmpty()) {
- // The list is not empty so try to remove listener
- list.remove(listener);
- map.put(project, list);
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/BuildObject.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/BuildObject.java
deleted file mode 100644
index 97c8f9a0c9..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/BuildObject.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Created on Apr 9, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.cdt.internal.core.build.managed;
-
-import org.eclipse.cdt.core.build.managed.IBuildObject;
-
-/**
- * @author dschaefe
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class BuildObject implements IBuildObject {
-
- protected String id;
- protected String name;
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
- */
- public String getId() {
- return id;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#setId(java.lang.String)
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
- */
- public String getName() {
- return name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String)
- */
- public void setName(String name) {
- this.name = name;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
deleted file mode 100644
index a4ce7cccb1..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.internal.core.build.managed;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.build.managed.BuildException;
-import org.eclipse.cdt.core.build.managed.IConfiguration;
-import org.eclipse.cdt.core.build.managed.IOption;
-import org.eclipse.cdt.core.build.managed.ITarget;
-import org.eclipse.cdt.core.build.managed.ITool;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IConfigurationElement;
-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 ITarget target;
- private IConfiguration parent;
- private List toolReferences;
-
- /**
- * A fresh new configuration for a target.
- *
- * @param target
- * @param id
- */
- public Configuration(Target target, String id) {
- this.id = id;
- this.target = target;
-
- target.addConfiguration(this);
- }
-
- /**
- * Create a new configuration based on one already defined.
- *
- * @param target The <code>Target</code> the receiver will be added to.
- * @param parent The <code>IConfiguration</code> to copy the settings from.
- * @param id A unique ID for the configuration.
- */
- public Configuration(Target target, IConfiguration parent, String id) {
- this.id = id;
- this.name = parent.getName();
- this.target = target;
- this.parent = parent;
-
- target.addConfiguration(this);
- }
-
- /**
- * Create a new <code>Configuration</code> based on the specification in the plugin manifest.
- *
- * @param target The <code>Target</code> the receiver will be added to.
- * @param element The element from the manifest that contains the default configuration settings.
- */
- public Configuration(Target target, IConfigurationElement element) {
- this.target = target;
-
- // id
- setId(element.getAttribute(IConfiguration.ID));
-
- // hook me up
- target.addConfiguration(this);
-
- // name
- setName(element.getAttribute(IConfiguration.NAME));
-
- IConfigurationElement[] configElements = element.getChildren();
- for (int l = 0; l < configElements.length; ++l) {
- IConfigurationElement configElement = configElements[l];
- if (configElement.getName().equals(IConfiguration.TOOL_REF)) {
- new ToolReference(this, configElement);
- }
- }
- }
-
- /**
- * Build a configuration from the project manifest file.
- *
- * @param target The <code>Target</code> the configuration belongs to.
- * @param element The element from the manifest that contains the overridden configuration information.
- */
- public Configuration(Target target, Element element) {
- this.target = target;
-
- // id
- setId(element.getAttribute(IConfiguration.ID));
-
- // hook me up
- target.addConfiguration(this);
-
- // name
- if (element.hasAttribute(IConfiguration.NAME))
- setName(element.getAttribute(IConfiguration.NAME));
-
- if (element.hasAttribute(IConfiguration.PARENT)) {
- // See if the target has a parent
- ITarget targetParent = target.getParent();
- // If so, then get my parent from it
- if (targetParent != null) {
- parent = targetParent.getConfiguration(element.getAttribute(IConfiguration.PARENT));
- }
- else {
- parent = null;
- }
- }
-
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IConfiguration.TOOL_REF)) {
- new ToolReference(this, (Element)configElement);
- }
- }
-
- }
-
- /**
- * Persist receiver 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 (parent != null)
- element.setAttribute(IConfiguration.PARENT, parent.getId());
-
- for (int i = 0; i < getToolReferences().size(); ++i) {
- ToolReference toolRef = (ToolReference)getToolReferences().get(i);
- Element toolRefElement = doc.createElement(IConfiguration.TOOL_REF);
- element.appendChild(toolRefElement);
- toolRef.serialize(doc, toolRefElement);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
- */
- public String getName() {
- return (name == null && parent != null) ? parent.getName() : name;
- }
-
- /*
- * @return
- */
- private List getToolReferences() {
- if (toolReferences == null) {
- toolReferences = new ArrayList();
- }
- return toolReferences;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
- */
- public ITool[] getTools() {
- ITool[] tools = parent != null
- ? parent.getTools()
- : target.getTools();
-
- // Replace tools with overrides
- for (int i = 0; i < tools.length; ++i) {
- ToolReference ref = getToolReference(tools[i]);
- if (ref != null)
- tools[i] = ref;
- }
-
- return tools;
- }
-
- /**
- * @param targetElement
- */
- public void reset(IConfigurationElement element) {
- // I just need to reset the tool references
- getToolReferences().clear();
- IConfigurationElement[] configElements = element.getChildren();
- for (int l = 0; l < configElements.length; ++l) {
- IConfigurationElement configElement = configElements[l];
- if (configElement.getName().equals(IConfiguration.TOOL_REF)) {
- new ToolReference(this, configElement);
- }
- }
- }
-
- /* (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#getTarget()
- */
- public ITarget getTarget() {
- return (target == null && parent != null) ? parent.getTarget() : target;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getOwner()
- */
- public IResource getOwner() {
- return getTarget().getOwner();
- }
-
- /**
- * Returns the reference for a given tool.
- *
- * @param tool
- * @return
- */
- private ToolReference getToolReference(ITool tool) {
- for (int i = 0; i < getToolReferences().size(); ++i) {
- ToolReference toolRef = (ToolReference)getToolReferences().get(i);
- if (toolRef.references(tool))
- return toolRef;
- }
- return null;
- }
-
- public void addToolReference(ToolReference toolRef) {
- getToolReferences().add(toolRef);
- }
-
- public OptionReference createOptionReference(IOption option) {
- if (option instanceof OptionReference) {
- OptionReference optionRef = (OptionReference)option;
- ToolReference toolRef = optionRef.getToolReference();
- if (toolRef.getConfiguration().equals(this))
- return optionRef;
- else {
- toolRef = new ToolReference(this, toolRef);
- return toolRef.createOptionReference(option);
- }
- } else {
- ToolReference toolRef = getToolReference(option.getTool());
- if (toolRef == null)
- toolRef = new ToolReference(this, option.getTool());
- return toolRef.createOptionReference(option);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
- */
- public void setOption(IOption option, boolean value) throws BuildException {
- // Is there a delta
- if (option.getBooleanValue() != value)
- createOptionReference(option).setValue(value);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
- */
- public void setOption(IOption option, String value) throws BuildException {
- String oldValue;
- // Check whether this is an enumerated option
- if (option.getValueType() == IOption.ENUMERATED) {
- oldValue = option.getSelectedEnum();
- }
- else {
- oldValue = option.getStringValue();
- }
- if (!oldValue.equals(value))
- createOptionReference(option).setValue(value);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
- */
- public void setOption(IOption option, String[] value) throws BuildException {
- // Is there a delta
- 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;
- default :
- oldValue = new String[0];
- break;
- }
- if(!Arrays.equals(value, oldValue))
- createOptionReference(option).setValue(value);
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
deleted file mode 100644
index 382a65e3c6..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ManagedBuildInfo.java
+++ /dev/null
@@ -1,505 +0,0 @@
-package org.eclipse.cdt.internal.core.build.managed;
-
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
- * **********************************************************************/
-
-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 org.eclipse.cdt.core.build.managed.BuildException;
-import org.eclipse.cdt.core.build.managed.IConfiguration;
-import org.eclipse.cdt.core.build.managed.IManagedBuildInfo;
-import org.eclipse.cdt.core.build.managed.IOption;
-import org.eclipse.cdt.core.build.managed.ITarget;
-import org.eclipse.cdt.core.build.managed.ITool;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.core.resources.IResource;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
-
- private IResource owner;
- private Map targetMap;
- private List targets;
- private Map defaultConfigurations;
- private ITarget defaultTarget;
-
- public ManagedBuildInfo() {
- targetMap = new HashMap();
- targets = new ArrayList();
- defaultConfigurations = new HashMap();
- }
-
- public ManagedBuildInfo(IResource owner, Element element) {
- this();
- // The id of the default configuration
- String defaultTargetId = null;
- List configIds = new ArrayList();
- Node child = element.getFirstChild();
- while (child != null) {
- if (child.getNodeName().equals("target")) {
- new Target(this, (Element)child);
- } else if (child.getNodeName().equals("defaultConfig")) {
- // We may not have read the config in yet, so just cache it
- configIds.add(((Element)child).getAttribute("id"));
- } else if (child.getNodeName().equals("defaultTarget")) {
- defaultTargetId = ((Element)child).getAttribute("id");
- }
- child = child.getNextSibling();
- }
- // All the available targets have been read in
- defaultTarget = (ITarget) targetMap.get(defaultTargetId);
- // Now we have a misserable O(N^2) operation (oh well, the data sets are small)
- ListIterator stringIter = configIds.listIterator();
- while (stringIter.hasNext()){
- String confId = (String) stringIter.next();
- ListIterator targIter = targets.listIterator();
- while (targIter.hasNext()) {
- Target targ = (Target) targIter.next();
- IConfiguration conf = targ.getConfiguration(confId);
- if (conf != null) {
- defaultConfigurations.put(targ.getId(), conf);
- break;
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
- */
- public void addTarget(ITarget target) {
- targetMap.put(target.getId(), target);
- targets.add(target);
- }
-
- /* (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(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(srcExt)) {
- return true;
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getBuildArtifactName()
- */
- public String getBuildArtifactName() {
- // Get the default target and use its value
- String name = getDefaultTarget().getArtifactName();
- return name == null ? new String() : name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
- */
- public String getCleanCommand() {
- // Get from the model
- String command = new String();
- ITarget target = getDefaultTarget();
- command = target.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(getDefaultTarget());
- 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 = getDefaultTarget().getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- IConfiguration configuration = configs[i];
- configNames.add(configuration.getName());
- }
- return (String[])configNames.toArray(new String[configNames.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getDefaultConfiguration()
- */
- public IConfiguration getDefaultConfiguration(ITarget target) {
- // Get the default config associated with the defalt target
- IConfiguration config = (IConfiguration) defaultConfigurations.get(target.getId());
-
- // If null, look up the first configuration associated with the target
- if (config == null) {
- IConfiguration[] configs = getDefaultTarget().getConfigurations();
- if (configs.length > 0) {
- config = configs[0];
- }
- }
- return config;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getDefaultTarget()
- */
- public ITarget getDefaultTarget() {
- if (defaultTarget == null) {
- defaultTarget = (ITarget) targets.get(0);
- }
- return defaultTarget;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getDefinedSymbols()
- */
- public Map getDefinedSymbols() {
- // Return the defined symbols for the default configuration
- HashMap symbols = new HashMap();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int i = 0; i < tools.length; i++) {
- ITool tool = tools[i];
- IOption[] opts = tool.getOptions();
- for (int j = 0; j < opts.length; j++) {
- IOption option = opts[j];
- if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
- try {
- ArrayList symbolList = new ArrayList();
- symbolList.addAll(Arrays.asList(option.getBuiltIns()));
- symbolList.addAll(Arrays.asList(option.getDefinedSymbols()));
- Iterator iter = symbolList.listIterator();
- while (iter.hasNext()) {
- String symbol = (String) iter.next();
- if (symbol.length() == 0){
- continue;
- }
- String key = new String();
- String value = new String();
- int index = symbol.indexOf("=");
- if (index != -1) {
- key = symbol.substring(0, index).trim();
- value = symbol.substring(index + 1).trim();
- } else {
- key = symbol.trim();
- }
- symbols.put(key, value);
- }
-
- } catch (BuildException e) {
- // we should never get here
- continue;
- }
- }
- }
- }
- return symbols;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForSource(java.lang.String)
- */
- public String getFlagsForSource(String extension) {
- // Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(extension)) {
- String flags = new String();
- try {
- flags = tool.getToolFlags();
- } catch (BuildException e) {
- // Give it your best shot with the next tool
- continue;
- }
- return flags;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFlags(java.lang.String)
- */
- public String getFlagsForTarget(String extension) {
- // Treat null extensions as an empty string
- String ext = extension == null ? new String() : extension;
-
- // Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- String flags = new String();
- try {
- flags = tool.getToolFlags();
- } catch (BuildException e) {
- // Somehow the model is out of sync for this item. Keep iterating
- continue;
- }
- return flags;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
- */
- public String[] getIncludePaths() {
- // Return the include paths for the default configuration
- ArrayList paths = new ArrayList();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int i = 0; i < tools.length; i++) {
- ITool tool = tools[i];
- IOption[] opts = tool.getOptions();
- for (int j = 0; j < opts.length; j++) {
- IOption option = opts[j];
- if (option.getValueType() == IOption.INCLUDE_PATH) {
- try {
- // Get all the built-in paths from the option
- paths.addAll(Arrays.asList(option.getBuiltIns()));
- // Get all the user-defined paths from the option
- paths.addAll(Arrays.asList(option.getIncludePaths()));
- } catch (BuildException e) {
- // we should never get here, but continue anyway
- continue;
- }
- }
- }
- }
- paths.trimToSize();
- return (String[])paths.toArray(new String[paths.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForTarget(java.lang.String)
- */
- public String[] getLibsForTarget(String extension) {
- ArrayList libs = new ArrayList();
- // Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(extension)) {
- IOption[] opts = tool.getOptions();
- // Look for the lib option type
- for (int i = 0; i < opts.length; i++) {
- IOption option = opts[i];
- if (option.getValueType() == IOption.LIBRARIES) {
- try {
- String command = option.getCommand();
- String[] allLibs = option.getLibraries();
- for (int j = 0; j < allLibs.length; j++) {
- String string = allLibs[j];
- libs.add(command + string);
- }
- } catch (BuildException e) {
- continue;
- }
- }
- }
- }
- }
- libs.trimToSize();
- return (String[])libs.toArray(new String[libs.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
- */
- public String[] getMakeArguments() {
- // TODO Stop hard-coding this
- String[] args = {""};
-
- return args;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeCommand()
- */
- public String getMakeCommand() {
- String command = new String();
- ITarget target = getDefaultTarget();
- command = target.getMakeCommand();
- return command;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getOutputExtension(java.lang.String)
- */
- public String getOutputExtension(String resourceExtension) {
- // Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- String output = tool.getOutputExtension(resourceExtension);
- if (output != null) {
- return output;
- }
- }
- 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();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- 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();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- flags = tool.getOutputPrefix();
- }
- }
- return flags;
- }
-
- public IResource getOwner() {
- return owner;
- }
- /* (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) targetMap.get(id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public List getTargets() {
- return targets;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForSource(java.lang.String)
- */
- public String getToolForSource(String extension) {
- // Get all the tools for the current config
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.buildsFileType(extension)) {
- return tool.getToolCommand();
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolInvocation(java.lang.String)
- */
- public String getToolForTarget(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
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
- for (int index = 0; index < tools.length; index++) {
- ITool tool = tools[index];
- if (tool.producesFileType(ext)) {
- return tool.getToolCommand();
- }
- }
- return null;
- }
-
- public void serialize(Document doc, Element element) {
- // Write out each target and their default config
- for (int i = 0; i < targets.size(); ++i) {
- Element targetElement = doc.createElement("target");
- element.appendChild(targetElement);
- ((Target)targets.get(i)).serialize(doc, targetElement);
- IConfiguration config = getDefaultConfiguration((ITarget)targets.get(i));
- if (config != null) {
- Element configEl = doc.createElement("defaultConfig");
- element.appendChild(configEl);
- configEl.setAttribute("id", config.getId());
- }
- }
- // Persist the default target
- if (getDefaultTarget() != null){
- Element targEl = doc.createElement("defaultTarget");
- element.appendChild(targEl);
- targEl.setAttribute("id", getDefaultTarget().getId());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public void setDefaultConfiguration(IConfiguration configuration) {
- // Get the target associated with the argument
- ITarget target = configuration.getTarget();
- // Make sure it is the default
- setDefaultTarget(target);
- defaultConfigurations.put(target.getId(), configuration);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultTarget(org.eclipse.cdt.core.build.managed.ITarget)
- */
- public void setDefaultTarget(ITarget target) {
- if (defaultTarget != null && defaultTarget.getId().equals(target.getId())) {
- return;
- }
- defaultTarget = target;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
deleted file mode 100644
index c0fa51a4c9..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Option.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.internal.core.build.managed;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.build.managed.BuildException;
-import org.eclipse.cdt.core.build.managed.IConfiguration;
-import org.eclipse.cdt.core.build.managed.IOption;
-import org.eclipse.cdt.core.build.managed.IOptionCategory;
-import org.eclipse.cdt.core.build.managed.ITool;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-/**
- *
- */
-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];
-
- // Private bookeeping attributes
- private List builtIns;
- private IOptionCategory category;
- private String command;
- private String defaultEnumName;
- private Map enumCommands;
- private ITool tool;
- private Object value;
- private int valueType;
-
-
- public Option(ITool tool) {
- this.tool = tool;
- }
-
- public Option(Tool tool, IConfigurationElement element) {
- this(tool);
-
- // Get the unique id of the option
- setId(element.getAttribute(IOption.ID));
-
- // Hook me up to a tool
- tool.addOption(this);
-
- // Get the option Name (this is what the user will see in the UI)
- setName(element.getAttribute(IOption.NAME));
-
- // Options can be grouped into categories
- String categoryId = element.getAttribute(IOption.CATEGORY);
- if (categoryId != null)
- setCategory(tool.getOptionCategory(categoryId));
-
- // Get the command defined for the option
- command = element.getAttribute(IOption.COMMAND);
-
- // Options hold different types of values
- String valueTypeStr = element.getAttribute(IOption.VALUE_TYPE);
- if (valueTypeStr == null)
- valueType = -1;
- else if (valueTypeStr.equals(IOption.TYPE_STRING))
- valueType = IOption.STRING;
- else if (valueTypeStr.equals(IOption.TYPE_STR_LIST))
- valueType = IOption.STRING_LIST;
- else if (valueTypeStr.equals(IOption.TYPE_BOOL))
- valueType = IOption.BOOLEAN;
- else if (valueTypeStr.equals(IOption.TYPE_ENUM))
- valueType = IOption.ENUMERATED;
- else if (valueTypeStr.equals(IOption.TYPE_INC_PATH))
- valueType = IOption.INCLUDE_PATH;
- else if (valueTypeStr.equals(IOption.TYPE_LIB))
- valueType = IOption.LIBRARIES;
- else
- valueType = IOption.PREPROCESSOR_SYMBOLS;
-
- // Now get the actual value
- enumCommands = new HashMap();
- switch (valueType) {
- case IOption.BOOLEAN:
- // Convert the string to a boolean
- value = new Boolean(element.getAttribute(IOption.DEFAULT_VALUE));
- break;
- case IOption.STRING:
- // Just get the value out of the option directly
- value = element.getAttribute(IOption.DEFAULT_VALUE);
- break;
- case IOption.ENUMERATED:
- List enumList = new ArrayList();
- IConfigurationElement[] enumElements = element.getChildren(IOption.ENUM_VALUE);
- for (int i = 0; i < enumElements.length; ++i) {
- String optName = enumElements[i].getAttribute(IOption.NAME);
- String optCommand = enumElements[i].getAttribute(IOption.COMMAND);
- enumList.add(optName);
- enumCommands.put(optName, optCommand);
- Boolean isDefault = new Boolean(enumElements[i].getAttribute(IOption.IS_DEFAULT));
- if (isDefault.booleanValue()) {
- defaultEnumName = optName;
- }
- }
- value = enumList;
- break;
- case IOption.STRING_LIST:
- case IOption.INCLUDE_PATH:
- case IOption.PREPROCESSOR_SYMBOLS:
- case IOption.LIBRARIES:
- List valueList = new ArrayList();
- builtIns = new ArrayList();
- IConfigurationElement[] valueElements = element.getChildren(IOption.LIST_VALUE);
- for (int i = 0; i < valueElements.length; ++i) {
- IConfigurationElement valueElement = valueElements[i];
- Boolean isBuiltIn = new Boolean(valueElement.getAttribute(IOption.LIST_ITEM_BUILTIN));
- if (isBuiltIn.booleanValue()) {
- builtIns.add(valueElement.getAttribute(IOption.LIST_ITEM_VALUE));
- }
- else {
- valueList.add(valueElement.getAttribute(IOption.LIST_ITEM_VALUE));
- }
- }
- value = valueList;
- break;
- default :
- break;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getApplicableValues()
- */
- public String[] getApplicableValues() {
- List enumValues = (List)value;
- return enumValues != null
- ? (String[])enumValues.toArray(new String[enumValues.size()])
- : EMPTY_STRING_ARRAY;
- }
-
- public boolean getBooleanValue() {
- Boolean bool = (Boolean) value;
- return bool.booleanValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getBuiltIns()
- */
- public String[] getBuiltIns() {
- // Return the list of built-ins as an array
- return builtIns == null ?
- EMPTY_STRING_ARRAY:
- (String[])builtIns.toArray(new String[builtIns.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
- */
- public IOptionCategory getCategory() {
- return category != null ? category : getTool().getTopOptionCategory();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getCommand()
- */
- public String getCommand() {
- return command;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getDefinedSymbols()
- */
- public String[] getDefinedSymbols() throws BuildException {
- if (valueType != IOption.PREPROCESSOR_SYMBOLS) {
- throw new BuildException("bad value type");
- }
- List v = (List)value;
- return v != null
- ? (String[])v.toArray(new String[v.size()])
- : EMPTY_STRING_ARRAY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
- */
- public String getEnumCommand(String name) {
- String cmd = (String) enumCommands.get(name);
- return cmd == null ? EMPTY_STRING : cmd;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getIncludePaths()
- */
- public String[] getIncludePaths() throws BuildException {
- if (valueType != IOption.INCLUDE_PATH) {
- throw new BuildException("bad value type");
- }
- List v = (List)value;
- return v != null
- ? (String[])v.toArray(new String[v.size()])
- : EMPTY_STRING_ARRAY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getLibraries()
- */
- public String[] getLibraries() throws BuildException {
- if (valueType != IOption.LIBRARIES) {
- throw new BuildException("bad value type");
- }
- List v = (List)value;
- return v != null
- ? (String[])v.toArray(new String[v.size()])
- : EMPTY_STRING_ARRAY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
- */
- public String getSelectedEnum() throws BuildException {
- if (valueType != IOption.ENUMERATED) {
- throw new BuildException("bad value type");
- }
- return defaultEnumName == null ? EMPTY_STRING : defaultEnumName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
- */
- public String[] getStringListValue() throws BuildException {
- if (valueType != IOption.STRING_LIST) {
- throw new BuildException("bad value type");
- }
- List v = (List)value;
- return v != null
- ? (String[])v.toArray(new String[v.size()])
- : EMPTY_STRING_ARRAY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getStringValue()
- */
- public String getStringValue() throws BuildException {
- if (valueType != IOption.STRING) {
- throw new BuildException("bad value type");
- }
- return value == null ? EMPTY_STRING : (String)value;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getTool()
- */
- public ITool getTool() {
- return tool;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getValueType()
- */
- public int getValueType() {
- return valueType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
- */
- public void setCategory(IOptionCategory category) {
- this.category = category;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String)
- */
- public IOption setValue(IConfiguration config, String value)
- throws BuildException
- {
- if (valueType != IOption.STRING
- || valueType != IOption.ENUMERATED)
- throw new BuildException("Bad value for type");
-
- if (config == null) {
- this.value = value;
- return this;
- } else {
- // Magic time
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String[])
- */
- public IOption setValue(IConfiguration config, String[] value)
- throws BuildException
- {
- if (valueType != IOption.STRING_LIST
- || valueType != IOption.INCLUDE_PATH
- || valueType != IOption.PREPROCESSOR_SYMBOLS
- || valueType != IOption.LIBRARIES)
- throw new BuildException("Bad value for type");
-
- if (config == null) {
- this.value = value;
- return this;
- } else {
- // More magic
- return null;
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
deleted file mode 100644
index e8e6ec6e8a..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.internal.core.build.managed;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.build.managed.IConfiguration;
-import org.eclipse.cdt.core.build.managed.IOption;
-import org.eclipse.cdt.core.build.managed.IOptionCategory;
-import org.eclipse.cdt.core.build.managed.ITool;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-/**
- *
- */
-public class OptionCategory extends BuildObject implements IOptionCategory {
-
- private IOptionCategory owner;
- private List children;
-
- private static final IOptionCategory[] emtpyCategories = new IOptionCategory[0];
-
- public OptionCategory(IOptionCategory owner) {
- this.owner = owner;
- }
-
- public OptionCategory(Tool tool, IConfigurationElement element) {
- String parentId = element.getAttribute(IOptionCategory.PARENT);
- if (parentId != null)
- owner = tool.getOptionCategory(element.getAttribute(IOptionCategory.PARENT));
- else
- owner = tool;
-
- // id
- setId(element.getAttribute(IOptionCategory.ID));
-
- // Name
- setName(element.getAttribute(IOptionCategory.NAME));
-
- // Hook me in
- if (owner instanceof Tool)
- ((Tool)owner).addChildCategory(this);
- else
- ((OptionCategory)owner).addChildCategory(this);
-
- tool.addOptionCategory(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
- */
- public IOptionCategory[] getChildCategories() {
- if (children != null)
- return (IOptionCategory[])children.toArray(new IOptionCategory[children.size()]);
- else
- return emtpyCategories;
- }
-
- public void addChildCategory(OptionCategory category) {
- if (children == null)
- children = new ArrayList();
- children.add(category);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOwner()
- */
- public IOptionCategory getOwner() {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getTool()
- */
- public ITool getTool() {
- // This will stop at the Tool's top category
- return owner.getTool();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
- */
- public IOption[] getOptions(IConfiguration configuration) {
- ITool tool = getTool();
- if (configuration != null) {
- // TODO don't like this much
- ITool[] tools = configuration.getTools();
- for (int i = 0; i < tools.length; ++i) {
- if (tools[i] instanceof ToolReference) {
- if (((ToolReference)tools[i]).references(tool)) {
- tool = tools[i];
- break;
- }
- } else if (tools[i].equals(tool))
- break;
- }
- }
-
- IOption[] allOptions = tool.getOptions();
- List myOptions = new ArrayList();
-
- for (int i = 0; i < allOptions.length; ++i) {
- IOption option = allOptions[i];
- if (option.getCategory().equals(this))
- myOptions.add(option);
- }
-
- return (IOption[])myOptions.toArray(new IOption[myOptions.size()]);
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
deleted file mode 100644
index e52d5e829d..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.internal.core.build.managed;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.cdt.core.build.managed.BuildException;
-import org.eclipse.cdt.core.build.managed.IOption;
-import org.eclipse.cdt.core.build.managed.IOptionCategory;
-import org.eclipse.cdt.core.build.managed.ITool;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- *
- */
-public class OptionReference implements IOption {
-
- // List of built-in values a tool defines
- private List builtIns;
- // Used for all option references that override the command
- private String command;
- // The option this reference overrides
- private IOption option;
- // The owner of the reference
- private ToolReference owner;
- // The actual value of the reference
- private Object value;
-
- /**
- * Created internally.
- *
- * @param owner
- * @param option
- */
- public OptionReference(ToolReference owner, IOption option) {
- this.owner = owner;
- this.option = option;
-
- // Until the option reference is changed, all values will be extracted from original option
- owner.addOptionReference(this);
- }
-
- /**
- * Created from extension point.
- *
- * @param owner
- * @param element
- */
- public OptionReference(ToolReference owner, IConfigurationElement element) {
- this.owner = owner;
- option = owner.getTool().getOption(element.getAttribute(IOption.ID));
-
- owner.addOptionReference(this);
-
- // value
- switch (option.getValueType()) {
- case IOption.BOOLEAN:
- value = new Boolean(element.getAttribute(IOption.DEFAULT_VALUE));
- break;
- case IOption.STRING:
- value = element.getAttribute(IOption.DEFAULT_VALUE);
- break;
- case IOption.ENUMERATED:
- try {
- value = option.getSelectedEnum();
- } catch (BuildException e) {
- value = new String();
- }
- break;
- case IOption.STRING_LIST:
- case IOption.INCLUDE_PATH:
- case IOption.PREPROCESSOR_SYMBOLS:
- case IOption.LIBRARIES:
- List valueList = new ArrayList();
- builtIns = new ArrayList();
- IConfigurationElement[] valueElements = element.getChildren(IOption.LIST_VALUE);
- for (int i = 0; i < valueElements.length; ++i) {
- IConfigurationElement valueElement = valueElements[i];
- Boolean isBuiltIn = new Boolean(valueElement.getAttribute(IOption.LIST_ITEM_BUILTIN));
- if (isBuiltIn.booleanValue()) {
- builtIns.add(valueElement.getAttribute(IOption.LIST_ITEM_VALUE));
- }
- else {
- valueList.add(valueElement.getAttribute(IOption.LIST_ITEM_VALUE));
- } }
- value = valueList;
- break;
- }
- }
-
- /**
- * Created from project file.
- *
- * @param owner
- * @param element
- */
- public OptionReference(ToolReference owner, Element element) {
- this.owner = owner;
- option = owner.getTool().getOption(element.getAttribute(IOption.ID));
-
- owner.addOptionReference(this);
-
- // value
- switch (option.getValueType()) {
- case IOption.BOOLEAN:
- value = new Boolean(element.getAttribute(IOption.DEFAULT_VALUE));
- break;
- case IOption.STRING:
- case IOption.ENUMERATED:
- value = (String) element.getAttribute(IOption.DEFAULT_VALUE);
- break;
- case IOption.STRING_LIST:
- case IOption.INCLUDE_PATH:
- case IOption.PREPROCESSOR_SYMBOLS:
- case IOption.LIBRARIES:
- List valueList = new ArrayList();
- builtIns = new ArrayList();
- NodeList nodes = element.getElementsByTagName(IOption.LIST_VALUE);
- for (int i = 0; i < nodes.getLength(); ++i) {
- Node node = nodes.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
- if (isBuiltIn.booleanValue()) {
- builtIns.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
- } else {
- valueList.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
- }
- }
- }
- value = valueList;
- break;
- }
-
- }
-
- /**
- * Persist receiver to project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- element.setAttribute(IOption.ID, option.getId());
-
- // value
- switch (option.getValueType()) {
- case IOption.BOOLEAN:
- element.setAttribute(IOption.DEFAULT_VALUE, ((Boolean)value).toString());
- break;
- case IOption.STRING:
- case IOption.ENUMERATED:
- element.setAttribute(IOption.DEFAULT_VALUE, (String)value);
- break;
- case IOption.STRING_LIST:
- case IOption.INCLUDE_PATH:
- case IOption.PREPROCESSOR_SYMBOLS:
- case IOption.LIBRARIES:
- ArrayList stringList = (ArrayList)value;
- ListIterator iter = stringList.listIterator();
- while (iter.hasNext()) {
- Element valueElement = doc.createElement(IOption.LIST_VALUE);
- valueElement.setAttribute(IOption.LIST_ITEM_VALUE, (String)iter.next());
- valueElement.setAttribute(IOption.LIST_ITEM_BUILTIN, "false");
- element.appendChild(valueElement);
- }
- // Serialize the built-ins that have been overridden
- if (builtIns != null) {
- iter = builtIns.listIterator();
- while (iter.hasNext()) {
- Element valueElement = doc.createElement(IOption.LIST_VALUE);
- valueElement.setAttribute(IOption.LIST_ITEM_VALUE, (String)iter.next());
- valueElement.setAttribute(IOption.LIST_ITEM_BUILTIN, "true");
- element.appendChild(valueElement);
- }
- }
- break;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getApplicableValues()
- */
- public String[] getApplicableValues() {
- return option.getApplicableValues();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
- */
- public IOptionCategory getCategory() {
- return option.getCategory();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getCommand()
- */
- public String getCommand() {
- return option.getCommand();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getDefinedSymbols()
- */
- public String[] getDefinedSymbols() throws BuildException {
- if (value == null)
- return option.getDefinedSymbols();
- else if (getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
- ArrayList list = (ArrayList)value;
- return (String[]) list.toArray(new String[list.size()]);
- }
- else
- throw new BuildException("bad value type");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
- */
- public String getEnumCommand(String name) {
- return option.getEnumCommand(name);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
- */
- public String getId() {
- // A reference has the same id as the option it references
- return option.getId();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getIncludePaths()
- */
- public String[] getIncludePaths() throws BuildException {
- if (value == null)
- return option.getIncludePaths();
- else if (getValueType() == IOption.INCLUDE_PATH) {
- ArrayList list = (ArrayList)value;
- return (String[]) list.toArray(new String[list.size()]);
- }
- else
- throw new BuildException("bad value type");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getLibraries()
- */
- public String[] getLibraries() throws BuildException {
- if (value == null)
- return option.getLibraries();
- else if (getValueType() == IOption.LIBRARIES) {
- ArrayList list = (ArrayList)value;
- return (String[]) list.toArray(new String[list.size()]);
- }
- else
- throw new BuildException("bad value type");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
- */
- public String getName() {
- // A reference has the same name as the option it references
- return option.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getBooleanValue()
- */
- public boolean getBooleanValue() throws BuildException {
- if (value == null){
- return option.getBooleanValue();
- }
- else if (getValueType() == IOption.BOOLEAN) {
- Boolean bool = (Boolean) value;
- return bool.booleanValue();
- } else {
- throw new BuildException("bad value type");
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getBuiltIns()
- */
- public String[] getBuiltIns() {
- // Return any overridden built-ins here, or the default set
- // from the option this is a reference to
- return builtIns == null ?
- option.getBuiltIns():
- (String[])builtIns.toArray(new String[builtIns.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
- */
- public String getSelectedEnum() throws BuildException {
- if (value == null) {
- // Return the default defined for the enumeration in the manifest.
- return option.getSelectedEnum();
- } else if (getValueType() == IOption.ENUMERATED) {
- // Value will contain the human-readable name of the enum
- return (String) value;
- } else {
- throw new BuildException("bad value type");
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
- */
- public String[] getStringListValue() throws BuildException {
- if (value == null)
- return option.getStringListValue();
- else if (getValueType() == IOption.STRING_LIST) {
- ArrayList list = (ArrayList)value;
- return (String[]) list.toArray(new String[list.size()]);
- }
- else
- throw new BuildException("bad value type");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getStringValue()
- */
- public String getStringValue() throws BuildException {
- if (value == null)
- return option.getStringValue();
- else if (getValueType() == IOption.STRING)
- return (String)value;
- else
- throw new BuildException("bad value type");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getTool()
- */
- public ITool getTool() {
- return owner;
- }
-
- public ToolReference getToolReference() {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getValueType()
- */
- public int getValueType() {
- return option.getValueType();
- }
-
- public boolean references(IOption target) {
- if (equals(target))
- // we are the target
- return true;
- else if (option instanceof OptionReference)
- // check the reference we are overriding
- return ((OptionReference)option).references(target);
- else
- // the real reference
- return option.equals(target);
- }
-
- /**
- * @param value
- */
- public void setValue(boolean value) throws BuildException {
- if (getValueType() == IOption.BOOLEAN)
- this.value = new Boolean(value);
- else
- throw new BuildException("bad value type");
- }
-
- public void setValue(String value) throws BuildException {
- if (getValueType() == IOption.STRING || getValueType() == IOption.ENUMERATED)
- this.value = value;
- else
- throw new BuildException("bad value type");
- }
-
- /**
- * Sets the value of the receiver to be an array of items.
- *
- * @param value An array of strings to place in the option reference.
- * @throws BuildException
- */
- public void setValue(String [] value) throws BuildException {
- if (getValueType() == IOption.STRING_LIST
- || getValueType() == IOption.INCLUDE_PATH
- || getValueType() == IOption.PREPROCESSOR_SYMBOLS
- || getValueType() == IOption.LIBRARIES) {
- // Just replace what the option reference is holding onto
- this.value = new ArrayList(Arrays.asList(value));
- }
- else
- throw new BuildException("bad value type");
- }
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java
deleted file mode 100644
index 520242ef36..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.internal.core.build.managed;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.build.managed.IConfiguration;
-import org.eclipse.cdt.core.build.managed.IManagedBuildInfo;
-import org.eclipse.cdt.core.build.managed.ITarget;
-import org.eclipse.cdt.core.build.managed.ITool;
-import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- *
- */
-public class Target extends BuildObject implements ITarget {
-
- private String artifactName;
- private String cleanCommand;
- private Map configMap;
- private List configurations;
- private String defaultExtension;
- private boolean isAbstract = false;
- private boolean isTest = false;
- private String makeCommand;
- private IResource owner;
- private ITarget parent;
- private Map toolMap;
- private List tools;
-
- private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
- private static final String EMPTY_STRING = new String();
-
- public Target(IResource owner) {
- this.owner = owner;
- }
-
- /**
- * Create a target owned by a resource based on a parent target
- *
- * @param owner
- * @param parent
- */
- public Target(IResource owner, ITarget parent) {
- // Make the owner of the target the project resource
- this(owner);
-
- // Copy the parent's identity
- this.parent = parent;
- setId(parent.getId() + ".1");
- setName(parent.getName());
- this.artifactName = parent.getArtifactName();
- this.defaultExtension = parent.getDefaultExtension();
- this.isTest = parent.isTestTarget();
- this.cleanCommand = parent.getCleanCommand();
- this.makeCommand = parent.getMakeCommand();
-
- // Hook me up
- IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner, true);
- buildInfo.addTarget(this);
- }
-
- /**
- * This constructor is called to create a target defined by an extension.
- *
- * @param element
- */
- public Target(IConfigurationElement element) {
- // id
- setId(element.getAttribute("id"));
-
- // hook me up
- ManagedBuildManager.addExtensionTarget(this);
-
- // Get the target name
- setName(element.getAttribute("name"));
-
- // Get the name of the build artifact associated with target (usually
- // in the plugin specification).
- artifactName = element.getAttribute("artifactName");
-
- // Get the default extension
- defaultExtension = element.getAttribute("defaultExtension");
-
- // parent
- String parentId = element.getAttribute("parent");
- if (parentId != null) {
- parent = ManagedBuildManager.getTarget(null, parentId);
- // copy over the parents configs
- IConfiguration[] parentConfigs = parent.getConfigurations();
- for (int i = 0; i < parentConfigs.length; ++i)
- addConfiguration(parentConfigs[i]);
- }
-
- // isAbstract
- if ("true".equals(element.getAttribute("isAbstract")))
- isAbstract = true;
-
- // Is this a test target
- isTest = ("true".equals(element.getAttribute("isTest")));
-
- // Get the clean command
- cleanCommand = element.getAttribute("cleanCommand");
- if (cleanCommand == null) {
- // See if it defined in the parent
- cleanCommand = parent.getCleanCommand();
- }
-
- // Get the make command
- makeCommand = element.getAttribute("makeCommand");
- if (makeCommand == null) {
- // See if it defined in the parent
- makeCommand = parent.getMakeCommand();
- }
-
- IConfigurationElement[] targetElements = element.getChildren();
- for (int k = 0; k < targetElements.length; ++k) {
- IConfigurationElement targetElement = targetElements[k];
- if (targetElement.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
- new Tool(this, targetElement);
- } else if (targetElement.getName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
- new Configuration(this, targetElement);
- }
- }
-
- }
-
- /**
- * Create target from project file
- *
- * @param buildInfo
- * @param element
- */
- public Target(ManagedBuildInfo buildInfo, Element element) {
- this(buildInfo.getOwner());
-
- // id
- setId(element.getAttribute("id"));
-
- // hook me up
- buildInfo.addTarget(this);
-
- // name
- setName(element.getAttribute("name"));
-
- // Get the name of the build artifact associated with target (should
- // contain what the user entered in the UI).
- artifactName = element.getAttribute("artifactName");
-
- // Get the default extension
- defaultExtension = element.getAttribute("defaultExtension");
-
- // parent
- String parentId = element.getAttribute("parent");
- if (parentId != null)
- parent = ManagedBuildManager.getTarget(null, parentId);
-
- // isAbstract
- if ("true".equals(element.getAttribute("isAbstract")))
- isAbstract = true;
-
- // Is this a test target
- isTest = ("true".equals(element.getAttribute("isTest")));
-
- // Get the clean command
- cleanCommand = element.getAttribute("cleanCommand");
-
- // Get the make command
- makeCommand = element.getAttribute("makeCommand");
-
- Node child = element.getFirstChild();
- while (child != null) {
- if (child.getNodeName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
- new Configuration(this, (Element)child);
- }
- child = child.getNextSibling();
- }
- }
-
- /**
- * Persist receiver to project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- element.setAttribute("id", getId());
- element.setAttribute("name", getName());
- if (parent != null)
- element.setAttribute("parent", parent.getId());
- element.setAttribute("isAbstract", isAbstract ? "true" : "false");
- element.setAttribute("artifactName", getArtifactName());
- element.setAttribute("defaultExtension", getDefaultExtension());
- element.setAttribute("isTest", isTest ? "true" : "false");
- element.setAttribute("cleanCommand", getCleanCommand());
- element.setAttribute("makeCommand", getMakeCommand());
-
- if (configurations != null)
- for (int i = 0; i < configurations.size(); ++i) {
- Configuration config = (Configuration)configurations.get(i);
- Element configElement = doc.createElement("configuration");
- element.appendChild(configElement);
- config.serialize(doc, configElement);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getMakeCommand()
- */
- public String getMakeCommand() {
- // Return the name of the make utility
- return makeCommand == null ? EMPTY_STRING : makeCommand;
- }
-
- public String getName() {
- return (name == null && parent != null) ? parent.getName() : name;
- }
-
- public ITarget getParent() {
- return parent;
- }
-
- public IResource getOwner() {
- return owner;
- }
-
- private int getNumTools() {
- int n = (tools == null) ? 0 : tools.size();
- if (parent != null)
- n += ((Target)parent).getNumTools();
- return n;
- }
-
- private int addToolsToArray(ITool[] toolArray, int start) {
- int n = start;
- if (parent != null)
- n = ((Target)parent).addToolsToArray(toolArray, start);
-
- if (tools != null) {
- for (int i = 0; i < tools.size(); ++i)
- toolArray[n++] = (ITool)tools.get(i);
- }
-
- return n;
- }
-
- public ITool[] getTools() {
- ITool[] toolArray = new ITool[getNumTools()];
- addToolsToArray(toolArray, 0);
- return toolArray;
- }
-
- public ITool getTool(String id) {
- ITool result = null;
- // See if receiver has it in list
- result = (ITool)toolMap.get(id);
- // If not, check if parent has it
- if (result == null && parent != null) {
- result = ((Target)parent).getTool(id);
- }
- return result;
- }
-
- public void addTool(ITool tool) {
- if (tools == null) {
- tools = new ArrayList();
- toolMap = new HashMap();
- }
-
- tools.add(tool);
- toolMap.put(tool.getId(), tool);
- }
-
- public IConfiguration[] getConfigurations() {
- if (configurations != null)
- return (IConfiguration[])configurations.toArray(new IConfiguration[configurations.size()]);
- else
- return emptyConfigs;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getDefaultExtension()
- */
- public String getDefaultExtension() {
- return defaultExtension == null ? EMPTY_STRING : defaultExtension;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getCleanCommand()
- */
- public String getCleanCommand() {
- // Return the command used to remove files
- return cleanCommand == null ? EMPTY_STRING : cleanCommand;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getArtifactName()
- */
- public String getArtifactName() {
- // Return name or an empty string
- return artifactName == null ? EMPTY_STRING : artifactName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getConfiguration()
- */
- public IConfiguration getConfiguration(String id) {
- return (IConfiguration)configMap.get(id);
- }
-
- public void addConfiguration(IConfiguration configuration) {
- if (configurations == null) {
- configurations = new ArrayList();
- configMap = new HashMap();
- }
- configurations.add(configuration);
- configMap.put(configuration.getId(), configuration);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#isAbstract()
- */
- public boolean isAbstract() {
- return isAbstract;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#isTestTarget()
- */
- public boolean isTestTarget() {
- return isTest;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration()
- */
- public IConfiguration createConfiguration(String id) {
- return new Configuration(this, id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public IConfiguration createConfiguration(IConfiguration parent, String id) {
- return new Configuration(this, parent, id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#setBuildArtifact(java.lang.String)
- */
- public void setBuildArtifact(String name) {
- artifactName = name;
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
deleted file mode 100644
index 3ed5bf404c..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.internal.core.build.managed;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.cdt.core.build.managed.BuildException;
-import org.eclipse.cdt.core.build.managed.IConfiguration;
-import org.eclipse.cdt.core.build.managed.IOption;
-import org.eclipse.cdt.core.build.managed.IOptionCategory;
-import org.eclipse.cdt.core.build.managed.ITarget;
-import org.eclipse.cdt.core.build.managed.ITool;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-/**
- * Represents a tool that can be invoked during a build.
- * Note that this class implements IOptionCategory to represent the top
- * category.
- */
-public class Tool extends BuildObject implements ITool, IOptionCategory {
-
- private static final String DEFAULT_SEPARATOR = ",";
- private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
- private static final IOption[] EMPTY_OPTIONS = new IOption[0];
-
- private ITarget target;
- private List options;
- private Map optionMap;
- private List childOptionCategories;
- private Map categoryMap;
- private String command;
- private List inputExtensions;
- private String outputExtension;
- private String outputFlag;
- private String outputPrefix;
-
- public Tool(Target target) {
- this.target = target;
- }
-
- /**
- * Constructor to create a new tool in the build model based on the information
- * defined in the plugin.xml manifest.
- *
- * @param target The target the receiver will belong to.
- * @param element The element containing the information.
- */
- public Tool(Target target, IConfigurationElement element) {
- this(target);
-
- // id
- setId(element.getAttribute(ITool.ID));
-
- // hook me up
- target.addTool(this);
-
- // name
- setName(element.getAttribute(ITool.NAME));
-
- // Get the supported input file extension
- String inputs = element.getAttribute(ITool.SOURCES) == null ?
- new String() :
- element.getAttribute(ITool.SOURCES);
- StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensions().add(tokenizer.nextElement());
- }
-
- // Get the output extension
- outputExtension = element.getAttribute(ITool.OUTPUTS) == null ?
- new String() :
- element.getAttribute(ITool.OUTPUTS);
-
- // Get the tool invocation
- command = element.getAttribute(ITool.COMMAND) == null ?
- new String() :
- element.getAttribute(ITool.COMMAND);
-
- // Get the flag to control output
- outputFlag = element.getAttribute(ITool.OUTPUT_FLAG) == null ?
- new String() :
- element.getAttribute(ITool.OUTPUT_FLAG);
-
- // Get the output prefix
- outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX) == null ?
- new String() :
- element.getAttribute(ITool.OUTPUT_PREFIX);
-
- // set up the category map
- categoryMap = new HashMap();
- addOptionCategory(this);
-
- // Check for options
- IConfigurationElement[] toolElements = element.getChildren();
- for (int l = 0; l < toolElements.length; ++l) {
- IConfigurationElement toolElement = toolElements[l];
- if (toolElement.getName().equals(ITool.OPTION)) {
- new Option(this, toolElement);
- } else if (toolElement.getName().equals(ITool.OPTION_CAT)) {
- new OptionCategory(this, toolElement);
- }
- }
- }
-
- public IOptionCategory getOptionCategory(String id) {
- return (IOptionCategory)categoryMap.get(id);
- }
-
- void addOptionCategory(IOptionCategory category) {
- categoryMap.put(category.getId(), category);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#handlesFileType(java.lang.String)
- */
- public boolean buildsFileType(String extension) {
- if (extension == null) {
- return false;
- }
- return getInputExtensions().contains(extension);
- }
-
- void addChildCategory(IOptionCategory category) {
- if (childOptionCategories == null)
- childOptionCategories = new ArrayList();
- childOptionCategories.add(category);
- }
-
- public IOption[] getOptions() {
- if (options != null)
- return (IOption[])options.toArray(new IOption[options.size()]);
- else
- return EMPTY_OPTIONS;
- }
-
- public void addOption(Option option) {
- if (options == null) {
- options = new ArrayList();
- optionMap = new HashMap();
- }
- options.add(option);
- optionMap.put(option.getId(), option);
- }
-
- public IOptionCategory getTopOptionCategory() {
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
- */
- public IOptionCategory[] getChildCategories() {
- if (childOptionCategories != null)
- return (IOptionCategory[])childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
- else
- return EMPTY_CATEGORIES;
- }
-
- /* (non-Javadoc)
- * @return
- */
- private List getInputExtensions() {
- if (inputExtensions == null) {
- inputExtensions = new ArrayList();
- }
- return inputExtensions;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#createChildCategory()
- */
- public IOptionCategory createChildCategory() {
- IOptionCategory category = new OptionCategory(this);
-
- if (childOptionCategories == null)
- childOptionCategories = new ArrayList();
- childOptionCategories.add(category);
-
- return category;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOutputFlag()
- */
- public String getOutputFlag() {
- return outputFlag == null ? new String() : outputFlag;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOutputPrefix()
- */
- public String getOutputPrefix() {
- return outputPrefix == null ? new String() : outputPrefix;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOwner()
- */
- public IOptionCategory getOwner() {
- return null;
- }
-
- public ITarget getTarget() {
- return target;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getTool()
- */
- public ITool getTool() {
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getToolCommand()
- */
- public String getToolCommand() {
- return command;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getToolFlags()
- */
- public String getToolFlags() throws BuildException {
- // Get all of the options
- StringBuffer buf = new StringBuffer();
- IOption[] opts = getOptions();
- for (int index = 0; index < opts.length; index++) {
- IOption option = opts[index];
- switch (option.getValueType()) {
- case IOption.BOOLEAN :
- if (option.getBooleanValue()) {
- buf.append(option.getCommand() + WHITE_SPACE);
- }
- break;
-
- case IOption.ENUMERATED :
- String enum = option.getEnumCommand(option.getSelectedEnum());
- if (enum.length() > 0) {
- buf.append(enum + WHITE_SPACE);
- }
- break;
-
- case IOption.STRING :
- String val = option.getStringValue();
- if (val.length() > 0) {
- buf.append(val + WHITE_SPACE);
- }
- break;
-
- case IOption.STRING_LIST :
- String listCmd = option.getCommand();
- String[] list = option.getStringListValue();
- for (int j = 0; j < list.length; j++) {
- String temp = list[j];
- buf.append(listCmd + temp + WHITE_SPACE);
- }
- break;
-
- case IOption.INCLUDE_PATH :
- String incCmd = option.getCommand();
- String[] paths = option.getIncludePaths();
- for (int j = 0; j < paths.length; j++) {
- String temp = paths[j];
- buf.append(incCmd + temp + WHITE_SPACE);
- }
- break;
-
- case IOption.PREPROCESSOR_SYMBOLS :
- String defCmd = option.getCommand();
- String[] symbols = option.getDefinedSymbols();
- for (int j = 0; j < symbols.length; j++) {
- String temp = symbols[j];
- buf.append(defCmd + temp + WHITE_SPACE);
- }
- break;
-
- default :
- break;
- }
-
- }
-
- return buf.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
- */
- public IOption[] getOptions(IConfiguration configuration) {
- ITool tool = this;
- if (configuration != null) {
- // TODO don't like this much
- ITool[] tools = configuration.getTools();
- for (int i = 0; i < tools.length; ++i) {
- if (tools[i] instanceof ToolReference) {
- if (((ToolReference)tools[i]).references(tool)) {
- tool = tools[i];
- break;
- }
- } else if (tools[i].equals(tool))
- break;
- }
- }
-
- IOption[] allOptions = tool.getOptions();
- List myOptions = new ArrayList();
-
- for (int i = 0; i < allOptions.length; ++i) {
- IOption option = allOptions[i];
- if (option.getCategory().equals(this))
- myOptions.add(option);
- }
-
- return (IOption[])myOptions.toArray(new IOption[myOptions.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
- */
- public IOption getOption(String id) {
- return (IOption)optionMap.get(id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOutput(java.lang.String)
- */
- public String getOutputExtension(String inputExtension) {
- // Examine the list of input extensions
- ListIterator iter = getInputExtensions().listIterator();
- while (iter.hasNext()) {
- if (((String)iter.next()).equals(inputExtension)) {
- return outputExtension;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#producesFileType(java.lang.String)
- */
- public boolean producesFileType(String outputExtension) {
- return this.outputExtension.equals(outputExtension);
- }
-
-}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
deleted file mode 100644
index a670db24dc..0000000000
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.internal.core.build.managed;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.build.managed.BuildException;
-import org.eclipse.cdt.core.build.managed.IConfiguration;
-import org.eclipse.cdt.core.build.managed.IOption;
-import org.eclipse.cdt.core.build.managed.IOptionCategory;
-import org.eclipse.cdt.core.build.managed.ITarget;
-import org.eclipse.cdt.core.build.managed.ITool;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- *
- */
-public class ToolReference implements ITool {
-
- private ITool parent;
- private IConfiguration owner;
- private List optionReferences;
- private Map optionRefMap;
-
- /**
- * Created a tool reference on the fly based on an existing tool.
- *
- * @param owner The <code>Configuration</code> the receiver will be added to.
- * @param parent The <code>ITool</code>tool the reference will be based on.
- */
- public ToolReference(Configuration owner, ITool parent) {
- this.owner = owner;
- this.parent = parent;
-
- owner.addToolReference(this);
- }
-
- /**
- * Created tool reference from an extension defined in a plugin manifest.
- *
- * @param owner The <code>Configuration</code> the receiver will be added to.
- * @param element The element containing build information for the reference.
- */
- public ToolReference(Configuration owner, IConfigurationElement element) {
- this.owner = owner;
-
- parent = ((Target)owner.getTarget()).getTool(element.getAttribute("id"));
-
- owner.addToolReference(this);
-
- IConfigurationElement[] toolElements = element.getChildren();
- for (int m = 0; m < toolElements.length; ++m) {
- IConfigurationElement toolElement = toolElements[m];
- if (toolElement.getName().equals(ITool.OPTION_REF)) {
- new OptionReference(this, toolElement);
- }
- }
- }
-
- /**
- * Create a new tool reference based on information contained in a project file.
- *
- * @param owner The <code>Configuration</code> the receiver will be added to.
- * @param element The element defined in the project file containing build information
- * for the receiver.
- */
- public ToolReference(Configuration owner, Element element) {
- this.owner = owner;
-
- Target parentTarget = (Target)owner.getTarget();
- parent = ((Target)parentTarget.getParent()).getTool(element.getAttribute("id"));
-
- owner.addToolReference(this);
-
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(ITool.OPTION_REF)) {
- new OptionReference(this, (Element)configElement);
- }
- }
- }
-
- /**
- * Persist receiver to project file.
- *
- * @param doc The persistent store for the reference information.
- * @param element The root element in the store the receiver must use
- * to persist settings.
- */
- public void serialize(Document doc, Element element) {
- element.setAttribute(ITool.ID, parent.getId());
-
- if (optionReferences != null)
- for (int i = 0; i < optionReferences.size(); ++i) {
- OptionReference optionRef = (OptionReference)optionReferences.get(i);
- Element optionRefElement = doc.createElement(ITool.OPTION_REF);
- element.appendChild(optionRefElement);
- optionRef.serialize(doc, optionRefElement);
- }
- }
-
- public IConfiguration getConfiguration() {
- return owner;
- }
-
- public ITool getTool() {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getToolCommand()
- */
- public String getToolCommand() {
- return parent.getToolCommand();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getToolFlags()
- */
- public String getToolFlags() throws BuildException {
- // Get all of the options
- StringBuffer buf = new StringBuffer();
- IOption[] opts = getOptions();
- for (int index = 0; index < opts.length; index++) {
- IOption option = opts[index];
- switch (option.getValueType()) {
- case IOption.BOOLEAN :
- if (option.getBooleanValue()) {
- buf.append(option.getCommand() + WHITE_SPACE);
- }
- break;
-
- case IOption.ENUMERATED :
- String enum = option.getEnumCommand(option.getSelectedEnum());
- if (enum.length() > 0) {
- buf.append(enum + WHITE_SPACE);
- }
- break;
-
- case IOption.STRING :
- String val = option.getStringValue();
- if (val.length() > 0) {
- buf.append(val + WHITE_SPACE);
- }
- break;
-
- case IOption.STRING_LIST :
- String cmd = option.getCommand();
- String[] list = option.getStringListValue();
- for (int j = 0; j < list.length; j++) {
- String temp = list[j];
- buf.append(cmd + temp + WHITE_SPACE);
- }
- break;
-
- case IOption.INCLUDE_PATH :
- String incCmd = option.getCommand();
- String[] paths = option.getIncludePaths();
- for (int j = 0; j < paths.length; j++) {
- String temp = paths[j];
- buf.append(incCmd + temp + WHITE_SPACE);
- }
- break;
-
- case IOption.PREPROCESSOR_SYMBOLS :
- String defCmd = option.getCommand();
- String[] symbols = option.getDefinedSymbols();
- for (int j = 0; j < symbols.length; j++) {
- String temp = symbols[j];
- buf.append(defCmd + temp + WHITE_SPACE);
- }
- break;
-
- default :
- break;
- }
-
- }
-
- return buf.toString().trim();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#createOption()
- */
- public IOption createOption() {
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOptions()
- */
- public IOption[] getOptions() {
- IOption[] options = parent.getOptions();
-
- // Replace with our references
- for (int i = 0; i < options.length; ++i) {
- OptionReference ref = getOptionReference(options[i]);
- if (ref != null)
- options[i] = ref;
- }
-
- return options;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOutputFlag()
- */
- public String getOutputFlag() {
- return parent.getOutputFlag();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOutputPrefix()
- */
- public String getOutputPrefix() {
- return parent.getOutputPrefix();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getTarget()
- */
- public ITarget getTarget() {
- return owner.getTarget();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getTopOptionCategory()
- */
- public IOptionCategory getTopOptionCategory() {
- return parent.getTopOptionCategory();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#producesFileType(java.lang.String)
- */
- public boolean producesFileType(String outputExtension) {
- return parent.producesFileType(outputExtension);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
- */
- public String getId() {
- return parent.getId();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
- */
- public String getName() {
- return parent.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#setId(java.lang.String)
- */
- public void setId(String id) {
- // Not allowed
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String)
- */
- public void setName(String name) {
- // Not allowed
- }
-
- public boolean references(ITool target) {
- if (equals(target))
- // we are the target
- return true;
- else if (parent instanceof ToolReference)
- // check the reference we are overriding
- return ((ToolReference)parent).references(target);
- else
- // the real reference
- return parent.equals(target);
- }
-
- private OptionReference getOptionReference(IOption option) {
- if (optionReferences != null)
- for (int i = 0; i < optionReferences.size(); ++i) {
- OptionReference optionRef = (OptionReference)optionReferences.get(i);
- if (optionRef.references(option))
- return optionRef;
- }
- return null;
- }
-
- public OptionReference createOptionReference(IOption option) {
- return new OptionReference(this, option);
- }
-
- public void addOptionReference(OptionReference optionRef) {
- if (optionReferences == null)
- optionReferences = new ArrayList();
- optionReferences.add(optionRef);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#handlesFileType(java.lang.String)
- */
- public boolean buildsFileType(String extension) {
- return parent.buildsFileType(extension);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
- */
- public IOption getOption(String id) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOutput(java.lang.String)
- */
- public String getOutputExtension(String inputExtension) {
- return parent.getOutputExtension(inputExtension);
- }
-
-}

Back to the top