Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-02-17 14:13:07 -0500
committerDoug Schaefer2003-02-17 14:13:07 -0500
commit18177e7a352c23d85e22cd645541d76aef48ac1c (patch)
tree3092150f638b573d929adaf128f245bcde019646 /core/org.eclipse.cdt.core/build
parentf79f4219470c954c3e304ffa9df99aefe9ce7699 (diff)
downloadorg.eclipse.cdt-18177e7a352c23d85e22cd645541d76aef48ac1c.tar.gz
org.eclipse.cdt-18177e7a352c23d85e22cd645541d76aef48ac1c.tar.xz
org.eclipse.cdt-18177e7a352c23d85e22cd645541d76aef48ac1c.zip
New build model from Sam Robb.
Diffstat (limited to 'core/org.eclipse.cdt.core/build')
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ACTool.java197
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ACToolchainProvider.java132
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/BuilderPlugin.java247
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICBuildConfigPoint.java59
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICBuildVariablePoint.java51
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolPoint.java59
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolTypePoint.java24
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolchainPoint.java51
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/ACExtensionPoint.java124
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CBuildConfigPoint.java70
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CBuildVariablePoint.java64
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolPoint.java69
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolTypePoint.java48
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolchainPoint.java64
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/CBuildVariable.java138
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildCmd.java50
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildCmdProcessor.java37
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfig.java306
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigListener.java47
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigManager.java125
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigProvider.java34
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigWorkingCopy.java142
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariable.java73
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariableProvider.java54
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariableResolver.java37
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICPosixBuildConstants.java48
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICTool.java96
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolType.java35
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolchain.java75
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolchainProvider.java48
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfig.java391
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigInfo.java474
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigManager.java415
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigWorkingCopy.java490
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CCygwinFilesystem.java125
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CUnixFilesystem.java58
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CUtil.java50
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/Filesystem.java161
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/IFilesystem.java66
39 files changed, 4834 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ACTool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ACTool.java
new file mode 100644
index 0000000000..1f6bb37d41
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ACTool.java
@@ -0,0 +1,197 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.cdt.core.builder.model.ICTool;
+import org.eclipse.cdt.core.builder.util.Filesystem;
+import org.eclipse.cdt.internal.core.ProcessClosure;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * <p>
+ * Abstract base class to make the life of ICTool implementers
+ * somewhat simpler.
+ * <p>
+ * Provides default implementations of all methods, such that
+ * a basic tool can be defined simply by calling the appropriate
+ * constructor.
+ * <p>
+ * Examples:
+ * <p>
+ * <code>
+ * class CGenericTool extends ACTool {
+ * CGenericTool() {
+ * super("typeid", "toolid", "toolname");
+ * }
+ * }
+ *
+ * class CExplicitTool extends ACTool {
+ * CGenericTool(IPath pathToTool) {
+ * super("typeid", "toolid", pathToTool);
+ * }
+ * }
+ * </code>
+ */
+public abstract class ACTool implements ICTool {
+
+ private String fTypeId;
+ private String fToolId;
+ private IPath fToolPath;
+
+ /**
+ * Constructor.
+ * <br>
+ * Create a tool with the given type ID and unqiue ID by specifying
+ * the absolute path to the executable.
+ * <br>
+ * @param typeId tool type ID, corresponds to a CToolType extension ID.
+ * @param id unqiue identifier for this tool instance.
+ * @param path explicit path to the tool.
+ */
+ public ACTool(String typeId, String id, IPath path) {
+ fTypeId = typeId;
+ fToolId = id;
+ fToolPath = path;
+ }
+
+ /**
+ * Constructor.
+ * <br>
+ * Create a tool with the given type ID and unqiue ID by specifying
+ * the name of an executable. The executable is located using the
+ * "which" utility.
+ * <br>
+ * @param typeId tool type ID, corresponds to a CToolType extension ID.
+ * @param id unqiue identifier for this tool instance.
+ * @param name name of the tool executable.
+ */
+ public ACTool(String typeId, String id, String exeName) {
+ fTypeId = typeId;
+ fToolId = id;
+ fToolPath = locateExe(exeName);
+ }
+
+ /**
+ * Locate the given executable by running "which name".
+ *
+ * @param name of executable.
+ * @param path to executable.
+ * @return path specifying the location of the executable
+ * with the given name. If the executable could not be
+ * located, returns <b>null</b>.
+ */
+ protected IPath locateExe(String name) {
+ IOResults ior = execHelper("which", new String[] { name }, null);
+ if (ior.stdout.size() > 0) {
+ return new Path(
+ Filesystem.getNativePath(ior.stdout.toString().trim()));
+ }
+ return null;
+ }
+
+ /**
+ * Explicity set the path to this tool's executable.
+ *
+ * @param path path to executable.
+ */
+ protected void setPath(String path) {
+ fToolPath = new Path(path);
+ }
+
+ /**
+ * Helper method that runs this tool using the provided parameters.
+ *
+ * @param parameters parameters to pass to tool when executing.
+ * @param workingDir working directory for tool execution.
+ * @return object IOResults object containing the stdout and stderr
+ * streams that resulted from running the tool.
+ */
+ protected IOResults execHelper(String[] parameters, String workingDir) {
+ return execHelper(
+ fToolPath.toString(),
+ parameters,
+ new File(workingDir));
+ }
+
+ /**
+ * Helper method that runs a specified tool using the provided parameters.
+ *
+ * @param exeName name of executable; may be a simple name or a full path.
+ * @param parameters parameters to pass to tool when executing.
+ * @param workingDir working directory for tool execution.
+ * @return object IOResults object containing the stdout and stderr
+ * streams that resulted from running the tool.
+ */
+ protected IOResults execHelper(
+ String exeName,
+ String[] parameters,
+ File dir) {
+ IOResults ior = new IOResults();
+ String[] cmds = new String[parameters.length + 1];
+
+ cmds[0] = exeName;
+ for (int i = 1; i < cmds.length; i++) {
+ cmds[i] = parameters[i - 1];
+ }
+
+ try {
+ ProcessFactory pf = ProcessFactory.getFactory();
+ Process pid = pf.exec(cmds, null, dir);
+ ProcessClosure pc = new ProcessClosure(pid, ior.stdout, ior.stderr);
+ pc.runBlocking();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return ior;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICTool#getTypeId()
+ */
+ public String getTypeId() {
+ return fTypeId;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICTool#getId()
+ */
+ public String getId() {
+ return fToolId;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICTool#getPath()
+ */
+ public IPath getPath() {
+ return (IPath) fToolPath.clone();
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICTool#exists()
+ */
+ public boolean exists() {
+ return fToolPath.toFile().exists();
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICTool#exec(String[], String)
+ */
+ public IOResults exec(String[] parameters, String workingDir) {
+ return execHelper(parameters, workingDir);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ACToolchainProvider.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ACToolchainProvider.java
new file mode 100644
index 0000000000..decaf3f352
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ACToolchainProvider.java
@@ -0,0 +1,132 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.builder.model.ICToolchain;
+import org.eclipse.cdt.core.builder.model.ICToolchainProvider;
+
+/**
+ * Abstract base class to make the life of ICToolchainProvider
+ * implementers somewhat simpler.
+ * <p>
+ * Provides default implementations of all methods, such that
+ * a basic toolchain can be defined simply by implementing the
+ * abstract doRefresh() method.
+ * <p>
+ * Examples:
+ * <p>
+ * <code>
+ * class CGenericToolchain extends ACToolchainProvider {
+ * void doRefresh() {
+ * ICToolchain tc = readToolchainInfoFromFile();
+ * addToolchain(tc.getId(), tc);
+ * }
+ * }
+ * </code>
+ */
+public abstract class ACToolchainProvider implements ICToolchainProvider {
+
+ /**
+ * Internal map of toolchain ID to toolchain instances.
+ */
+ private Map fToolchainMap;
+
+ /**
+ * Constructor.
+ * <br>
+ * Creates a new toolchain map, then calls the abstract
+ * doRefresh() method to allow derived classes to populate
+ * the map.
+ */
+ public ACToolchainProvider() {
+ fToolchainMap = new HashMap();
+ doRefresh();
+ }
+
+ /**
+ * Determines if a toolchain exists in the internal map of
+ * toolchain instances.
+ *
+ * @param id toolchain identifier.
+ * @return true if there is a toolchain instances that corresponds
+ * to the provided id.
+ */
+ protected boolean toolchainExists(String id) {
+ return fToolchainMap.containsKey(id);
+ }
+
+ /**
+ * Add a toolchain to the internal map of toolchain instances.
+ *
+ * @param id toolchain identifier.
+ * @param tc toolchain instance.
+ */
+ protected void addToolchain(String id, ICToolchain tc) {
+ fToolchainMap.put(id, tc);
+ }
+
+ /**
+ * Helper method used to retrieve a toolchain from the internal
+ * map of toolchain instances.
+ *
+ * @param id toolchain identifier.
+ * @return toolchain instance, or null if not found.
+ */
+ protected ICToolchain getToolchainHelper(String id) {
+ ICToolchain tc = null;
+ Object obj = fToolchainMap.get(id);
+ if (obj instanceof ICToolchain) {
+ tc = (ICToolchain) obj;
+ }
+ return tc;
+ }
+
+ /**
+ * Remove a toolchain from the internal map of toolchain instances.
+ *
+ * @param id toolchain identifier.
+ * @return true if toolchain is removed.
+ */
+ protected boolean removeToolchain(String id) {
+ boolean exists = toolchainExists(id);
+ if (exists) {
+ Object obj = fToolchainMap.remove(id);
+ obj = null;
+ }
+ return exists;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICToolchainProvider#getToolchain(String)
+ */
+ public ICToolchain getToolchain(String id) {
+ return getToolchainHelper(id);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICToolchainProvider#getToolchains()
+ */
+ public ICToolchain[] getToolchains() {
+ Collection tcc = fToolchainMap.values();
+ return (ICToolchain[]) tcc.toArray(new ICToolchain[tcc.size()]);
+ }
+
+ /**
+ * Implemented by derived classes. Called whenever the toolchain list needs
+ * to be refreshed.
+ */
+ abstract public void doRefresh();
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/BuilderPlugin.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/BuilderPlugin.java
new file mode 100644
index 0000000000..41baeaf18c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/BuilderPlugin.java
@@ -0,0 +1,247 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.builder.internal.CBuildConfigPoint;
+import org.eclipse.cdt.core.builder.internal.CBuildVariablePoint;
+import org.eclipse.cdt.core.builder.internal.CToolPoint;
+import org.eclipse.cdt.core.builder.internal.CToolTypePoint;
+import org.eclipse.cdt.core.builder.internal.CToolchainPoint;
+import org.eclipse.cdt.core.builder.model.ICToolType;
+import org.eclipse.cdt.core.builder.model.internal.CBuildConfigManager;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPluginDescriptor;
+
+/**
+ * Fragments aren't first class citizens in the Eclipse world.
+ * This class lets me write code in the experimental builder
+ * fragment as if there was a real plugin class that implemented
+ * some of these methods.
+ * <p>
+ * Also - I'm not sure that some of these methods don't belong
+ * elsewhere. Suggestions are welcome.
+ */
+public class BuilderPlugin {
+
+ // Pretend this is a real plugin.
+ static private BuilderPlugin thisPlugin;
+
+ // Pretend this is a real plugin.
+ static {
+ thisPlugin = new BuilderPlugin();
+ thisPlugin.loadToolTypes();
+ thisPlugin.loadToolProviders();
+ thisPlugin.loadToolchainProviders();
+ thisPlugin.loadConfigProviders();
+ thisPlugin.loadBuildVarProviders();
+ thisPlugin.dump();
+ }
+
+ // Pretend this is a real plugin.
+ private BuilderPlugin() {
+ fBuildConfigManager = new CBuildConfigManager();
+ }
+
+ // Pretend this is a real plugin.
+ private void dump() {
+ for (Iterator iter = fToolTypes.entrySet().iterator();
+ iter.hasNext();
+ ) {
+ ICToolType element =
+ (ICToolType) ((Map.Entry) iter.next()).getValue();
+ System.err.println(
+ "Tool type ("
+ + element.getName()
+ + ", "
+ + element.getId()
+ + ")");
+ }
+ for (Iterator iter = fToolProviders.entrySet().iterator();
+ iter.hasNext();
+ ) {
+ ICToolPoint element =
+ (ICToolPoint) ((Map.Entry) iter.next()).getValue();
+ System.err.println(
+ "Tool ("
+ + element.getName()
+ + ", "
+ + element.getId()
+ + ", "
+ + element.getProviderClassName()
+ + ")");
+ }
+ for (Iterator iter = fToolchainProviders.entrySet().iterator();
+ iter.hasNext();
+ ) {
+ ICToolchainPoint element =
+ (ICToolchainPoint) ((Map.Entry) iter.next()).getValue();
+ System.err.println(
+ "Toolchain ("
+ + element.getId()
+ + ", "
+ + element.getProviderClassName()
+ + ")");
+ }
+ for (Iterator iter = fBuildConfigProviders.entrySet().iterator();
+ iter.hasNext();
+ ) {
+ ICBuildConfigPoint element =
+ (ICBuildConfigPoint) ((Map.Entry) iter.next()).getValue();
+ System.err.println(
+ "BuildConfig ("
+ + element.getName()
+ + ", "
+ + element.getId()
+ + ", "
+ + element.getProviderClassName()
+ + ")");
+ }
+ for (Iterator iter = fBuildVarProviders.entrySet().iterator();
+ iter.hasNext();
+ ) {
+ ICBuildVariablePoint element =
+ (ICBuildVariablePoint) ((Map.Entry) iter.next()).getValue();
+ System.err.println(
+ "BuildVar ("
+ + element.getId()
+ + ", "
+ + element.getProviderClassName()
+ + ")");
+ }
+ }
+
+ // Pretend this is a real plugin.
+ static public BuilderPlugin getDefault() {
+ return thisPlugin;
+ }
+
+ // Pretend this is a real plugin.
+ public IPluginDescriptor getDescriptor() {
+ return CCorePlugin.getDefault().getDescriptor();
+ }
+
+ /*
+ * Data and methods to merge with CCorePlugin
+ */
+
+ private CBuildConfigManager fBuildConfigManager;
+ private Map fToolTypes;
+ private Map fToolProviders;
+ private Map fToolchainProviders;
+ private Map fBuildConfigProviders;
+ private Map fBuildVarProviders;
+
+ public CBuildConfigManager getBuildConfigurationManager() {
+ return fBuildConfigManager;
+ }
+
+ public Map getToolTypes() {
+ return fToolTypes;
+ }
+
+ public Map getToolProviders() {
+ return fToolProviders;
+ }
+
+ public Map getToolchainProviders() {
+ return fToolchainProviders;
+ }
+
+ public Map getBuildConfigurationProviders() {
+ return fBuildConfigProviders;
+ }
+
+ public Map getBuildVariableProviders() {
+ return fBuildVarProviders;
+ }
+
+ private void loadToolTypes() {
+ IPluginDescriptor descriptor = getDefault().getDescriptor();
+ IExtensionPoint extensionPoint =
+ descriptor.getExtensionPoint("CToolType");
+ IExtension[] exts = extensionPoint.getExtensions();
+ IConfigurationElement[] infos =
+ extensionPoint.getConfigurationElements();
+ fToolTypes = new HashMap(infos.length);
+ for (int i = 0; i < infos.length; i++) {
+ IConfigurationElement configurationElement = infos[i];
+ CToolTypePoint provider = new CToolTypePoint(configurationElement);
+ fToolTypes.put(provider.getId(), provider);
+ }
+ }
+
+ private void loadToolProviders() {
+ IPluginDescriptor descriptor = getDefault().getDescriptor();
+ IExtensionPoint extensionPoint = descriptor.getExtensionPoint("CTool");
+ IConfigurationElement[] infos =
+ extensionPoint.getConfigurationElements();
+ fToolProviders = new HashMap(infos.length);
+ for (int i = 0; i < infos.length; i++) {
+ IConfigurationElement configurationElement = infos[i];
+ CToolPoint provider = new CToolPoint(configurationElement);
+ fToolProviders.put(provider.getId(), provider);
+ }
+ }
+
+ private void loadToolchainProviders() {
+ IPluginDescriptor descriptor = getDefault().getDescriptor();
+ IExtensionPoint extensionPoint =
+ descriptor.getExtensionPoint("CToolchain");
+ IConfigurationElement[] infos =
+ extensionPoint.getConfigurationElements();
+ fToolchainProviders = new HashMap(infos.length);
+ for (int i = 0; i < infos.length; i++) {
+ IConfigurationElement configurationElement = infos[i];
+ CToolchainPoint provider =
+ new CToolchainPoint(configurationElement);
+ fToolchainProviders.put(provider.getId(), provider);
+ }
+ }
+
+ private void loadConfigProviders() {
+ IPluginDescriptor descriptor = getDefault().getDescriptor();
+ IExtensionPoint extensionPoint =
+ descriptor.getExtensionPoint("CBuildConfig");
+ IConfigurationElement[] infos =
+ extensionPoint.getConfigurationElements();
+ fBuildConfigProviders = new HashMap(infos.length);
+ for (int i = 0; i < infos.length; i++) {
+ IConfigurationElement configurationElement = infos[i];
+ CBuildConfigPoint provider =
+ new CBuildConfigPoint(configurationElement);
+ fBuildConfigProviders.put(provider.getId(), provider);
+ }
+ }
+
+ private void loadBuildVarProviders() {
+ IPluginDescriptor descriptor = getDefault().getDescriptor();
+ IExtensionPoint extensionPoint =
+ descriptor.getExtensionPoint("CBuildVariable");
+ IConfigurationElement[] infos =
+ extensionPoint.getConfigurationElements();
+ fBuildVarProviders = new HashMap(infos.length);
+ for (int i = 0; i < infos.length; i++) {
+ IConfigurationElement configurationElement = infos[i];
+ CBuildVariablePoint provider =
+ new CBuildVariablePoint(configurationElement);
+ fBuildVarProviders.put(provider.getId(), provider);
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICBuildConfigPoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICBuildConfigPoint.java
new file mode 100644
index 0000000000..584dfb3a3f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICBuildConfigPoint.java
@@ -0,0 +1,59 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder;
+
+import org.eclipse.cdt.core.builder.model.ICBuildConfigProvider;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Interface representing an instance of
+ * a CBuildConfig extension point.
+ */
+public interface ICBuildConfigPoint {
+
+ /**
+ * Returns the unique id for the provider.
+ *
+ * @return unique id.
+ */
+ public String getId();
+
+ /**
+ * Returns the name of the provider.
+ *
+ * @return provider name.
+ */
+ public String getName();
+
+ /**
+ * Returns the natures supported by the provider.
+ *
+ * @return natures supported by the provider.
+ */
+ public String[] getNatures();
+
+ /**
+ * Returns the name of the provider's
+ * implementing class.
+ *
+ * @return name of the provider's implementing class.
+ */
+ public String getProviderClassName();
+
+ /**
+ * Returns an instance of the provider's
+ * implementing class.
+ *
+ * @return instance of ICBuildConfigProvider.
+ */
+ public ICBuildConfigProvider getProvider() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICBuildVariablePoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICBuildVariablePoint.java
new file mode 100644
index 0000000000..6e17d20d87
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICBuildVariablePoint.java
@@ -0,0 +1,51 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder;
+
+import org.eclipse.cdt.core.builder.model.ICBuildVariableProvider;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Interface representing an instance of
+ * a CBuildVariable extension point.
+ */
+public interface ICBuildVariablePoint {
+ /**
+ * Returns the unique id for the provider.
+ *
+ * @return unique id.
+ */
+ public String getId();
+
+ /**
+ * Returns the the natures supported by the provider.
+ *
+ * @return the natures supported by the provider.
+ */
+ public String[] getNatures();
+
+ /**
+ * Returns the name of the provider's
+ * implementing class.
+ *
+ * @return name of the provider's implementing class.
+ */
+ public String getProviderClassName();
+
+ /**
+ * Returns an instance of the provider's
+ * implementing class.
+ *
+ * @return instance of ICBuildVariableProvider.
+ */
+ public ICBuildVariableProvider getProvider() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolPoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolPoint.java
new file mode 100644
index 0000000000..07e66fa707
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolPoint.java
@@ -0,0 +1,59 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder;
+
+import org.eclipse.cdt.core.builder.model.ICTool;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Interface representing an instance of
+ * a CTool extension point.
+ */
+public interface ICToolPoint {
+
+ /**
+ * Returns the unique id for the provider.
+ *
+ * @return unique id.
+ */
+ public String getId();
+
+ /**
+ * Returns the name of the provider.
+ *
+ * @return provider name.
+ */
+ public String getName();
+
+ /**
+ * Returns the string identifying the type of tool.
+ *
+ * @return type string.
+ */
+ public String getType();
+
+ /**
+ * Returns the name of the provider's
+ * implementing class.
+ *
+ * @return name of the provider's implementing class.
+ */
+ public String getProviderClassName();
+
+ /**
+ * Returns an instance of the provider's
+ * implementing class.
+ *
+ * @return instance of ICToolProvider.
+ */
+ public ICTool getProvider() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolTypePoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolTypePoint.java
new file mode 100644
index 0000000000..769942ea30
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolTypePoint.java
@@ -0,0 +1,24 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder;
+
+import org.eclipse.cdt.core.builder.model.ICToolType;
+
+/**
+ * Interface representing an instance of
+ * a CToolType extension point.
+ * <p>
+ * This interface exists solely to parallel the
+ * other extension point interfaces (ICToolPoint, etc.)
+ */
+public interface ICToolTypePoint extends ICToolType {
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolchainPoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolchainPoint.java
new file mode 100644
index 0000000000..bd9deed7a6
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/ICToolchainPoint.java
@@ -0,0 +1,51 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder;
+
+import org.eclipse.cdt.core.builder.model.ICToolchainProvider;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Interface representing an instance of
+ * a CToolchain extension point.
+ */
+public interface ICToolchainPoint {
+ /**
+ * Returns the unique id for the provider.
+ *
+ * @return unique id.
+ */
+ public String getId();
+
+ /**
+ * Returns the natures supported by the provider.
+ *
+ * @return natures supported by the provider.
+ */
+ public String[] getNatures();
+
+ /**
+ * Returns the name of the provider's
+ * implementing class.
+ *
+ * @return name of the provider's implementing class.
+ */
+ public String getProviderClassName();
+
+ /**
+ * Returns an instance of the provider's
+ * implementing class.
+ *
+ * @return instance of ICToolchainProvider.
+ */
+ public ICToolchainProvider getProvider() throws CoreException;
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/ACExtensionPoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/ACExtensionPoint.java
new file mode 100644
index 0000000000..01e92047df
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/ACExtensionPoint.java
@@ -0,0 +1,124 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.internal;
+
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * Abstract base class that represents information
+ * associated with a declared extension point.
+ * <p>
+ * Derived classes are expected to implement their
+ * own getter functions to return data from the
+ * associated IConfigurationElement in a reasonable
+ * format.
+ */
+public abstract class ACExtensionPoint {
+
+ public final static String FIELD_ID = "id"; //$NON-NLS-1$
+ public final static String FIELD_NAME = "name"; //$NON-NLS-1$
+ public final static String FIELD_TYPE = "name"; //$NON-NLS-1$
+ public final static String FIELD_NATURES = "natures"; //$NON-NLS-1$
+ public final static String FIELD_CLASS = "class"; //$NON-NLS-1$
+
+ /**
+ * Configuration element associated with this class.
+ * CONSIDER: is it expensive to hold on to this?
+ */
+ private IConfigurationElement fElement;
+
+ /**
+ * Constructor.
+ *
+ * @param element configuration element for the build configuration provider.
+ */
+ public ACExtensionPoint(IConfigurationElement element) {
+ fElement = element;
+ }
+
+ /**
+ * Returns the configuration element for the build configuration provider.
+ *
+ * @return configuration element
+ */
+ protected IConfigurationElement getConfigurationElement() {
+ return fElement;
+ }
+
+ /**
+ * Breaks up a token-delimited string into individual tokens.
+ *
+ * @param data string to tokenize.
+ * @param sep delimiter character(s).
+ * @return array of tokens extracted from the string.
+ */
+ protected String[] parseField(String data, String sep) {
+ Vector res = new Vector();
+ StringTokenizer st = new StringTokenizer(data, sep);
+ while (st.hasMoreElements()) {
+ res.add(st.nextElement());
+ }
+ return (String[]) res.toArray(new String[res.size()]);
+ }
+
+ /**
+ * Returns the value of the named field from the configuration element.
+ * If the named field is not present or has no value, returns an empty
+ * string.
+ *
+ * @param fieldName name of field.
+ * @return value of named field, or "".
+ */
+ protected String getField(String fieldName) {
+ return getField(fieldName, ""); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the value of the named field from the configuration element.
+ * If the named field is not present or has no value, returns the
+ * specified default value.
+ *
+ * @param fieldName name of field.
+ * @param defaultValue default value if field not present.
+ * @return value of named field, or default.
+ */
+ protected String getField(String fieldName, String defaultValue) {
+ String val = getConfigurationElement().getAttribute(fieldName);
+ return val != null ? val : defaultValue;
+ }
+
+ /**
+ * Returns an instance of of an implementing class. This
+ * method uses the value of the FIELD_CLASS attribute in
+ * the configuration element to create the class.
+ *
+ * @return instance of provider class.
+ */
+ protected Object getClassInstance() throws CoreException {
+ return getClassInstance(FIELD_CLASS);
+ }
+
+ /**
+ * Returns an instance of of an implementing class.
+ *
+ * @param fieldName name of field.
+ * @return instance of provider class.
+ */
+ protected Object getClassInstance(String fieldName) throws CoreException {
+ return getConfigurationElement().createExecutableExtension(fieldName);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CBuildConfigPoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CBuildConfigPoint.java
new file mode 100644
index 0000000000..7ffd3293b9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CBuildConfigPoint.java
@@ -0,0 +1,70 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.internal;
+
+import org.eclipse.cdt.core.builder.ICBuildConfigPoint;
+import org.eclipse.cdt.core.builder.model.ICBuildConfigProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * Simple wrapper for the data associated with an instance of
+ * a CBuildConfig extension point.
+ */
+public class CBuildConfigPoint
+ extends ACExtensionPoint
+ implements ICBuildConfigPoint {
+
+ /**
+ * Constructor.
+ *
+ * @param element configuration element for the build configuration provider.
+ */
+ public CBuildConfigPoint(IConfigurationElement element) {
+ super(element);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildConfigPoint#getId()
+ */
+ public String getId() {
+ return getField(FIELD_ID);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildConfigPoint#getName()
+ */
+ public String getName() {
+ return getField(FIELD_NAME);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildConfigPoint#getNatures()
+ */
+ public String[] getNatures() {
+ return parseField(getField(FIELD_NATURES, "*"), ";"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildConfigPoint#getProviderClassName()
+ */
+ public String getProviderClassName() {
+ return getField(FIELD_CLASS);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildConfigPoint#getProvider()
+ */
+ public ICBuildConfigProvider getProvider() throws CoreException {
+ return (ICBuildConfigProvider) getClassInstance(FIELD_CLASS);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CBuildVariablePoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CBuildVariablePoint.java
new file mode 100644
index 0000000000..bb4b310aac
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CBuildVariablePoint.java
@@ -0,0 +1,64 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.internal;
+
+import org.eclipse.cdt.core.builder.ICBuildVariablePoint;
+import org.eclipse.cdt.core.builder.model.ICBuildVariableProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * Simple wrapper for the data associated with an instance of
+ * a CBuildVariable extension point.
+ */
+
+public class CBuildVariablePoint
+ extends ACExtensionPoint
+ implements ICBuildVariablePoint {
+
+ /**
+ * Constructor.
+ *
+ * @param element configuration element for the build variable provider.
+ */
+ public CBuildVariablePoint(IConfigurationElement element) {
+ super(element);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildVariablePoint#getId()
+ */
+ public String getId() {
+ return getField(FIELD_ID);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildVariablePoint#getNatures()
+ */
+ public String[] getNatures() {
+ return parseField(getField(FIELD_NATURES, "*"), ";"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildVariablePoint#getProviderClassName()
+ */
+ public String getProviderClassName() {
+ return getField(FIELD_CLASS);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICBuildVariablePoint#getProvider()
+ */
+ public ICBuildVariableProvider getProvider() throws CoreException {
+ return (ICBuildVariableProvider) getClassInstance(FIELD_CLASS);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolPoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolPoint.java
new file mode 100644
index 0000000000..95eb59e32b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolPoint.java
@@ -0,0 +1,69 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.internal;
+
+import org.eclipse.cdt.core.builder.ICToolPoint;
+import org.eclipse.cdt.core.builder.model.ICTool;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * Simple wrapper for the data associated with an instance of
+ * a CTool extension point.
+ */
+
+public class CToolPoint extends ACExtensionPoint implements ICToolPoint {
+
+ /**
+ * Constructor.
+ *
+ * @param element configuration element for the tool type.
+ */
+ public CToolPoint(IConfigurationElement element) {
+ super(element);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolPoint#getId()
+ */
+ public String getId() {
+ return getField(FIELD_ID);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolPoint#getName()
+ */
+ public String getName() {
+ return getField(FIELD_NAME);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolPoint#getType()
+ */
+ public String getType() {
+ return getField(FIELD_TYPE);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolPoint#getProviderClassName()
+ */
+ public String getProviderClassName() {
+ return getField(FIELD_CLASS);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolPoint#getProvider()
+ */
+ public ICTool getProvider() throws CoreException {
+ return (ICTool) getClassInstance(FIELD_CLASS);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolTypePoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolTypePoint.java
new file mode 100644
index 0000000000..435651dd65
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolTypePoint.java
@@ -0,0 +1,48 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.internal;
+
+import org.eclipse.cdt.core.builder.ICToolTypePoint;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * Simple wrapper for the data associated with an instance of
+ * a CToolType extension point.
+ */
+public class CToolTypePoint
+ extends ACExtensionPoint
+ implements ICToolTypePoint {
+
+ /**
+ * Constructor.
+ *
+ * @param element configuration element for the tool type.
+ */
+ public CToolTypePoint(IConfigurationElement element) {
+ super(element);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICToolType#getId()
+ */
+ public String getId() {
+ return getField(FIELD_ID);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICToolType#getName()
+ */
+ public String getName() {
+ return getField(FIELD_NAME);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolchainPoint.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolchainPoint.java
new file mode 100644
index 0000000000..7ccb3fea30
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/internal/CToolchainPoint.java
@@ -0,0 +1,64 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.internal;
+
+import org.eclipse.cdt.core.builder.ICToolchainPoint;
+import org.eclipse.cdt.core.builder.model.ICToolchainProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * Simple wrapper for the data associated with an instance of
+ * a CToolchain extension point.
+ */
+
+public class CToolchainPoint
+ extends ACExtensionPoint
+ implements ICToolchainPoint {
+
+ /**
+ * Constructor.
+ *
+ * @param element configuration element for the toolchain provider.
+ */
+ public CToolchainPoint(IConfigurationElement element) {
+ super(element);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolchainPoint#getId()
+ */
+ public String getId() {
+ return getField(FIELD_ID);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolchainPoint#getNatures()
+ */
+ public String[] getNatures() {
+ return parseField(getField(FIELD_NATURES, "*"), ";"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolchainPoint#getProviderClassName()
+ */
+ public String getProviderClassName() {
+ return getField(FIELD_CLASS);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.ICToolchainPoint#getProvider()
+ */
+ public ICToolchainProvider getProvider() throws CoreException {
+ return (ICToolchainProvider) getClassInstance(FIELD_CLASS);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/CBuildVariable.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/CBuildVariable.java
new file mode 100644
index 0000000000..9c38e08d02
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/CBuildVariable.java
@@ -0,0 +1,138 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * Default implementation of the ICBuildVariable interface.
+ * <p>
+ * This implementation is capable of handling both static
+ * resolution (where the variable part is fixed at generation
+ * time) and dynamic resolution (where the variable part
+ * may change over time, depending on context.)
+ * <p>
+ * @see ICBuildVariable
+ * @see ICBuildVariableProvider
+ * @see ICBuildVariableResolver
+ */
+public class CBuildVariable implements ICBuildVariable {
+
+ private String fFixed;
+ private String fVariable;
+ private ICBuildVariableResolver fResolver;
+
+ /**
+ * Default implementation of ICBuildVariableResolver that
+ * simply returns a previously provided string as the
+ * resolved value for the build variable.
+ */
+ static private class StringResolver implements ICBuildVariableResolver {
+ private String fValue;
+
+ public StringResolver(String value) {
+ fValue = value;
+ }
+
+ public String resolveValue(ICBuildVariable var) {
+ return fValue + var.getFixed();
+ }
+ };
+
+ /**
+ * Create a new build variable with the given variable
+ * and fixed elements, and a static resolver that always
+ * returns the same value for the variable portion of
+ * the variable.
+ *
+ * @param name variable portion of build variable.
+ * @param fixed fixed portion of build variable.
+ * @param resolved resolved variable value.
+ */
+ public CBuildVariable(String name, String fixed, String resolved) {
+ this(name, fixed, new StringResolver(resolved));
+ }
+
+ /**
+ * Create a new build variable with the given fixed
+ * and variable values, and a dynamic resolver for
+ * the variable portion of the variable.
+ *
+ * @param name variable portion of build variable.
+ * @param fixed fixed portion of build variable.
+ * @param resolved resolved variable value.
+ */
+ public CBuildVariable(String name, String fixed, ICBuildVariableResolver resolver) {
+ fVariable = name;
+ fFixed = fixed;
+ fResolver = resolver;
+ }
+
+ /**
+ * Create a new build variable with the given fixed
+ * and variable values, and a dynamic resolver for
+ * the variable portion of the variable.
+ *
+ * @param name variable portion of build variable.
+ * @param fixed fixed portion of build variable.
+ * @param resolved resolved variable value.
+ */
+ public CBuildVariable(String name, ICBuildVariable base) {
+ fVariable = name;
+ fFixed = base.getFixed();
+ fResolver = base.getResolver();
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICBuildVariable#getVariable()
+ */
+ public String getVariable() {
+ return fVariable;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICBuildVariable#getFixed()
+ */
+ public String getFixed() {
+ return fFixed;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICBuildVariable#getResolver()
+ */
+ public ICBuildVariableResolver getResolver() {
+ return fResolver;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.model.ICBuildVariable#getValue()
+ */
+ public String getValue() {
+ return fResolver.resolveValue(this);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ int result = 17;
+ result = (result * 37) + fVariable.hashCode();
+ result = (result * 37) + fFixed.hashCode();
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return "[" + fVariable + "]" + fFixed;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildCmd.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildCmd.java
new file mode 100644
index 0000000000..86d51d4d8e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildCmd.java
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * A build command is generated by a tool or toolchain, and
+ * represents a command that must be executed in order to
+ * build a file.
+ */
+public interface ICBuildCmd {
+
+ /**
+ * Tool used to process the file.
+ *
+ * @return tool used to build this file.
+ */
+ ICTool getTool();
+
+ /**
+ * File this build command applies to.
+ *
+ * @return file this build command applies to.
+ */
+ IFile getFile();
+
+ /**
+ * Parameters that are to be passed to the tool
+ * when building the file.
+ *
+ * @return parameters used to build the file.
+ */
+ String[] getParameters();
+
+ /**
+ * This is a convenience method that should
+ * simply call getTool().exec(getParameters(), workingDir);
+ */
+ boolean exec(String workingDir);
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildCmdProcessor.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildCmdProcessor.java
new file mode 100644
index 0000000000..eb09e153b2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildCmdProcessor.java
@@ -0,0 +1,37 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * Consumer of build commands.
+ * <br>
+ * "Processing" a build command might mean different
+ * things for different types of processors (ex,
+ * an incremental build processor and a makefile
+ * generator.)
+ * <br>
+ * @see ICBuildCmd
+ */
+public interface ICBuildCmdProcessor {
+
+ /**
+ * Process the provided build commands. This
+ * might me executing the associated tool, recording
+ * the build command in a file, handing the command
+ * off to a remote processor for execution on another
+ * machine, etc.
+ *
+ * @param cmds build commands to process.
+ */
+ void processCommands(ICBuildCmd[] cmds);
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfig.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfig.java
new file mode 100644
index 0000000000..b9d8e1cb4f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfig.java
@@ -0,0 +1,306 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Based on org.eclipse.debug.core.ILaunchConfiguration
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * A build configuration describes how to build a project. It
+ * is a collection of the various tool- and toolchain-specific
+ * settings used to process the files in a project and produce
+ * some end result.
+ * <p>
+ * A build configuration may be shared in a repository via
+ * standard VCM mechanisms.
+ * <p>
+ * A build configuration is a handle to its underlying storage.
+ * <p>
+ * A build configuration is modified by obtaining a working copy
+ * of a build configuration, modifying the working copy, and then
+ * saving the working copy.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * <p>
+ * @see ICBuildConfigWorkingCopy
+ */
+public interface ICBuildConfig extends IAdaptable {
+
+ /*
+ * TBD: add convenience methods for accessing standard elements?
+ *
+ * String[] getIncludePaths();
+ * String[] getLibPaths();
+ * String[] getLibs();
+ * String[] getOptimizationFlags();
+ * String[] getDebugFlags();
+ * String[] getWarningFlags();
+ */
+
+ /**
+ * The file extension for build configuration files
+ * (value <code>"config"</code>).
+ * <p>
+ * CONSIDER: perhaps better to have a ".cdtconfig" file containing
+ * all build configuratons for the project in one spot?
+ */
+ public static final String BUILD_CONFIGURATION_FILE_EXTENSION = "build"; //$NON-NLS-1$
+
+ /**
+ * Configuration version. Text string.
+ */
+ public final static String CONFIG_VERSION = "config.version";
+
+ /**
+ * Configuration name. Text string.
+ */
+ public final static String CONFIG_NAME = "config.name";
+
+ /**
+ * Builds this configuration.
+ *
+ * @param monitor progress monitor, or <code>null</code>
+ */
+ public void build(IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * Returns the name of this build configuration.
+ *
+ * @return the name of this build configuration
+ */
+ public String getName();
+
+ /**
+ * Returns the location of this build configuration as a
+ * path.
+ *
+ * @return the location of this build configuration as a
+ * path
+ */
+ public IPath getLocation();
+
+ /**
+ * Returns whether this build configuration's underlying
+ * storage exists.
+ *
+ * @return whether this build configuration's underlying
+ * storage exists
+ */
+ public boolean exists();
+
+ /**
+ * Returns the integer-valued attribute with the given name.
+ * Returns the given default value if the attribute is undefined.
+ *
+ * @param attributeName the name of the attribute
+ * @param defaultValue the value to use if no value is found
+ * @return the value or the default value if no value was found.
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while retrieving the attribute from
+ * underlying storage.</li>
+ * <li>An attribute with the given name exists, but does not
+ * have an integer value</li>
+ * </ul>
+ */
+ public int getAttribute(String attributeName, int defaultValue)
+ throws CoreException;
+
+ /**
+ * Returns the string-valued attribute with the given name.
+ * Returns the given default value if the attribute is undefined.
+ *
+ * @param attributeName the name of the attribute
+ * @param defaultValue the value to use if no value is found
+ * @return the value or the default value if no value was found.
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while retrieving the attribute from
+ * underlying storage.</li>
+ * <li>An attribute with the given name exists, but does not
+ * have a String value</li>
+ * </ul>
+ */
+ public String getAttribute(String attributeName, String defaultValue)
+ throws CoreException;
+
+ /**
+ * Returns the boolean-valued attribute with the given name.
+ * Returns the given default value if the attribute is undefined.
+ *
+ * @param attributeName the name of the attribute
+ * @param defaultValue the value to use if no value is found
+ * @return the value or the default value if no value was found.
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while retrieving the attribute from
+ * underlying storage.</li>
+ * <li>An attribute with the given name exists, but does not
+ * have a boolean value</li>
+ * </ul>
+ */
+ public boolean getAttribute(String attributeName, boolean defaultValue)
+ throws CoreException;
+
+ /**
+ * Returns the <code>java.util.List</code>-valued attribute with the given name.
+ * Returns the given default value if the attribute is undefined.
+ *
+ * @param attributeName the name of the attribute
+ * @param defaultValue the value to use if no value is found
+ * @return the value or the default value if no value was found.
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while retrieving the attribute from
+ * underlying storage.</li>
+ * <li>An attribute with the given name exists, but does not
+ * have a List value</li>
+ * </ul>
+ */
+ public List getAttribute(String attributeName, List defaultValue)
+ throws CoreException;
+
+ /**
+ * Returns the <code>java.util.Map</code>-valued attribute with the given name.
+ * Returns the given default value if the attribute is undefined.
+ *
+ * @param attributeName the name of the attribute
+ * @param defaultValue the value to use if no value is found
+ * @return the value or the default value if no value was found.
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while retrieving the attribute from
+ * underlying storage.</li>
+ * <li>An attribute with the given name exists, but does not
+ * have a Map value</li>
+ * </ul>
+ */
+ public Map getAttribute(String attributeName, Map defaultValue)
+ throws CoreException;
+
+ /**
+ * Returns the file this build configuration is stored
+ * in, or <code>null</code> if this configuration is stored
+ * locally with the workspace.
+ *
+ * @return the file this build configuration is stored
+ * in, or <code>null</code> if this configuration is stored
+ * locally with the workspace
+ */
+ public IFile getFile();
+
+ /**
+ * Returns the project this build configuration is stored
+ * in.
+ *
+ * @return the file this build configuration is stored in.
+ */
+ public IProject getProject();
+
+ /**
+ * Returns whether this build configuration is stored
+ * locally with the workspace.
+ *
+ * @return whether this build configuration is stored
+ * locally with the workspace
+ */
+ public boolean isLocal();
+
+ /**
+ * Returns a working copy of this build configuration.
+ * Changes to the working copy will be applied to this
+ * build configuration when saved. The working copy will
+ * refer to this build configuration as its original
+ * build configuration.
+ *
+ * @return a working copy of this build configuration
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while initializing the contents of the
+ * working copy from this configuration's underlying storage.</li>
+ * </ul>
+ * @see ICBuildConfigWorkingCopy#getOriginal()
+ */
+ public ICBuildConfigWorkingCopy getWorkingCopy() throws CoreException;
+
+ /**
+ * Returns a copy of this build configuration, as a
+ * working copy, with the specified name. The new
+ * working copy does not refer back to this configuration
+ * as its original build configuration (the working copy
+ * will return <code>null</code> for <code>getOriginal()</code>).
+ * When the working copy is saved it will not effect this
+ * build configuration.
+ *
+ * @param name the name of the copy
+ * @return a copy of this build configuration
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while initializing the contents of the
+ * working copy from this configuration's underlying storage.</li>
+ * </ul>
+ * @see ICBuildConfigWorkingCopy#getOriginal()
+ */
+ public ICBuildConfigWorkingCopy copy(String name) throws CoreException;
+
+ /**
+ * Returns whether this build configuration is a working
+ * copy.
+ *
+ * @return whether this build configuration is a working
+ * copy
+ */
+ public boolean isWorkingCopy();
+
+ /**
+ * Deletes this build configuration. This configuration's underlying
+ * storage is deleted. Has no effect if this configuration
+ * does not exist.
+ *
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>An exception occurs while deleting this configuration's
+ * underlying storage.</li>
+ * </ul>
+ */
+ public void delete() throws CoreException;
+
+ /**
+ * Returns a memento for this build configuration, or <code>null</code>
+ * if unable to generate a memento for this configuration. A memento
+ * can be used to re-create a build configuration, via the
+ * build manager.
+ *
+ * @return a memento for this configuration
+ * @see ICBuildConfigManager#getConfiguration(IProject, String)
+ * @exception CoreException if an exception occurs generating this
+ * build configuration's memento
+ */
+ public String getMemento() throws CoreException;
+
+ /**
+ * Returns whether the contents of this build configuration are
+ * equal to the contents of the given build configuration.
+ *
+ * @return whether the contents of this build configuration are equal to the contents
+ * of the specified build configuration.
+ */
+ public boolean contentsEqual(ICBuildConfig configuration);
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigListener.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigListener.java
new file mode 100644
index 0000000000..ebd7049afc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigListener.java
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Based on org.eclipse.debug.core.ILaunchConfigurationListener
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * A build configuration listener is notified of build
+ * configurations as they are added and removed from the
+ * build configuration manager.
+ * <p>
+ * Clients may implement this interface.
+ */
+public interface ICBuildConfigListener {
+
+ /**
+ * Notifies this listener that the specified
+ * configuration has been removed.
+ *
+ * @param configuration the removed configuration
+ */
+ public void configurationRemoved(ICBuildConfig configuration);
+
+ /**
+ * Notifies this listener that the specified configuration
+ * has been added.
+ *
+ * @param configuration the newly added configuration
+ */
+ public void configurationAdded(ICBuildConfig configuration);
+
+ /**
+ * Notifies this listener that the specified configuration
+ * has changed.
+ *
+ * @param configuration the changed configuration
+ */
+ public void configurationChanged(ICBuildConfig configuration);
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigManager.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigManager.java
new file mode 100644
index 0000000000..1c375873ee
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigManager.java
@@ -0,0 +1,125 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Based on org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * The build configuration manager manages the set of registered build
+ * configurations. Clients interested in build configuration change
+ * notification may register with the build configuration manager.
+ * <p>
+ * Clients are not intended to implement this interface.
+ * </p>
+ * @see ICBuildConfigListener
+ */
+public interface ICBuildConfigManager {
+
+ /**
+ * Adds the given listener to the collection of registered
+ * configuration listeners. Has no effect if an identical
+ * listener is already registerd.
+ *
+ * @param listener the listener to register
+ */
+ public void addListener(ICBuildConfigListener listener);
+
+ /**
+ * Removes the given listener from the collection of registered
+ * configuration listeners. Has no effect if an identical listener
+ * is not already registerd.
+ *
+ * @param listener the listener to deregister
+ */
+ public void removeListener(ICBuildConfigListener listener);
+
+ /**
+ * Adds the specified configuration and notifies listeners. Has no
+ * effect if an identical configuration is already registered.
+ *
+ * @param configuration the configuration to add
+ */
+ public void addConfiguration(ICBuildConfig configuration);
+
+ /**
+ * Removes the specified configuration and notifies listeners.
+ * Has no effect if an identical configuration is not already
+ * registered.
+ *
+ * @param configuration the configuration to remove
+ * @since 2.0
+ */
+ public void removeConfiguration(ICBuildConfig configuration);
+
+ /**
+ * Returns all build configurations associated with a project.
+ * Returns an zero-length array if no configurations are associated
+ * with the project.
+ *
+ * @param project project to retrieve build configurations for.
+ * @return all build configurations of the specified type for the project.
+ * @exception CoreException if an error occurs while retreiving a build configuration
+ */
+ public ICBuildConfig[] getConfigurations(IProject project) throws CoreException;
+
+ /**
+ * Returns a handle to the configuration contained in the specified
+ * file. The file is not verified to exist or contain a proper
+ * configuration.
+ *
+ * @param file configuration file
+ * @return a handle to the configuration contained in the specified file
+ */
+ public ICBuildConfig getConfiguration(IFile file);
+
+ /**
+ * Returns a handle to the configuration specified by the given
+ * memento. The configuration may not exist.
+ *
+ * @return a handle to the configuration specified by the given memento
+ * @exception CoreException if the given memento is invalid or
+ * an exception occurs parsing the memento
+ */
+ public ICBuildConfig getConfiguration(String memento) throws CoreException;
+
+ /**
+ * Returns a handle to a newly created build configuration.
+ *
+ * @param name Name of new configuration.
+ * @return a handle to a new configuration instance.
+ */
+ public ICBuildConfigWorkingCopy getConfiguration(IProject project, String name);
+
+ /**
+ * Return <code>true</code> if there is a configuration with the specified name,
+ * <code>false</code> otherwise.
+ *
+ * @param name the name of the configuration whose existence is being checked
+ * @exception CoreException if unable to retrieve existing configuration names
+ */
+ public boolean isExistingConfigurationName(IProject project, String name) throws CoreException;
+
+ /**
+ * Return a String that can be used as the name of a configuration. The name
+ * is guaranteed to be unique (no existing configurations will have this name).
+ * The name that is returned uses the <code>namePrefix</code> as a starting point.
+ * If there is no existing configuration with this name, then <code>namePrefix</code>
+ * is returned. Otherwise, the value returned consists of the specified prefix plus
+ * some suffix that guarantees uniqueness.
+ *
+ * @param namePrefix the String that the returned name must begin with
+ */
+ public String generateUniqueConfigurationNameFrom(IProject project, String namePrefix);
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigProvider.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigProvider.java
new file mode 100644
index 0000000000..2a726c8c1b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigProvider.java
@@ -0,0 +1,34 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * ICBuildConfigProvider represents an instance of a class
+ * that initializes an empty build configuration with
+ * reasonable default values.
+ * <p>
+ * The intent is to decouple build configuration creation
+ * and initialization.
+ * <p>
+ * See also the <a href="../../../../../../CBuildConfig.html">CBuildConfig</a>
+ * extension point documentation.
+ */
+public interface ICBuildConfigProvider {
+
+ /**
+ * Set initial values in the provided build configuration
+ * working copy.
+ *
+ * @param config build configuration to initialize.
+ */
+ public void setDefaults(ICBuildConfigWorkingCopy config);
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigWorkingCopy.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigWorkingCopy.java
new file mode 100644
index 0000000000..7fcf1b3501
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildConfigWorkingCopy.java
@@ -0,0 +1,142 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * An editable copy of a build configuration. Attributes of a
+ * build configuration are modified by modifying the attributes
+ * of a working copy, and then saving the working copy.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * <p>
+ * @see ICBuildConfig
+ */
+public interface ICBuildConfigWorkingCopy extends ICBuildConfig, IAdaptable {
+
+ /**
+ * Returns whether this configuration has been modified
+ * since it was last saved or created.
+ *
+ * @return whether this configuration has been modified
+ * since it was last saved or created
+ */
+ public boolean isDirty();
+
+ /**
+ * Saves this working copy to its underlying file and returns
+ * a handle to the resulting launch configuration.
+ * Has no effect if this configuration does not need saving.
+ * Creates the underlying file if not yet created.
+ *
+ * @exception CoreException if an exception occurs while
+ * writing this configuration to its underlying file.
+ */
+ public ICBuildConfig doSave() throws CoreException;
+
+ /**
+ * Sets the integer-valued attribute with the given name.
+ *
+ * @param attributeName the name of the attribute
+ * @param value the value
+ */
+ public void setAttribute(String attributeName, int value);
+
+ /**
+ * Sets the String-valued attribute with the given name.
+ * If the value is <code>null</code>, the attribute is removed from
+ * this launch configuration.
+ *
+ * @param attributeName the name of the attribute
+ * @param value the value, or <code>null</code> if the attribute is to be undefined
+ */
+ public void setAttribute(String attributeName, String value);
+
+ /**
+ * Sets the <code>java.util.List</code>-valued attribute with the given name.
+ * The specified List <em>must</em> contain only String-valued entries.
+ * If the value is <code>null</code>, the attribute is removed from
+ * this launch configuration.
+ *
+ * @param attributeName the name of the attribute
+ * @param value the value, or <code>null</code> if the attribute is to be undefined
+ */
+ public void setAttribute(String attributeName, List value);
+
+ /**
+ * Sets the <code>java.util.Map</code>-valued attribute with the given name.
+ * The specified Map <em>must</em> contain only String keys and String values.
+ * If the value is <code>null</code>, the attribute is removed from
+ * this launch configuration.
+ *
+ * @param attributeName the name of the attribute
+ * @param value the value, or <code>null</code> if the attribute is to be undefined
+ */
+ public void setAttribute(String attributeName, Map value);
+
+ /**
+ * Sets the boolean-valued attribute with the given name.
+ *
+ * @param attributeName the name of the attribute
+ * @param value the value
+ */
+ public void setAttribute(String attributeName, boolean value);
+
+ /**
+ * Returns the original launch configuration this working copy
+ * was created from, or <code>null</code> if this is a new
+ * working copy created from a launch configuration type.
+ *
+ * @return the original launch configuration, or <code>null</code>
+ */
+ public ICBuildConfig getOriginal();
+
+ /**
+ * Renames this build configuration to the specified name.
+ * The new name cannot be <code>null</code>. Has no effect if the name
+ * is the same as the current name. If this working copy is based
+ * on an existing build configuration, this will cause
+ * the underlying build configuration file to be renamed when
+ * this working copy is saved.
+ *
+ * @param name the new name for this configuration
+ */
+ public void rename(String name);
+
+ /**
+ * Sets the container this build configuration will be stored
+ * in when saved. When set to <code>null</code>, this configuration
+ * will be stored locally with the workspace. The specified
+ * container must exist, if specified.
+ * <p>
+ * If this configuration is changed from local to non-local,
+ * a file will be created in the specified container when
+ * saved. The local file associated with this configuration
+ * will be deleted.
+ * <p>
+ * If this configuration is changed from non-local to local,
+ * a file will be created locally when saved.
+ * The original file associated with this configuration in
+ * the workspace will be deleted.
+ * <p>
+ * @param container the container in which to store this
+ * build configuration, or <code>null</code> if this
+ * configuration is to be stored locally
+ */
+ public void setContainer(IContainer container);
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariable.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariable.java
new file mode 100644
index 0000000000..cccf5b98a7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariable.java
@@ -0,0 +1,73 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * Represents a named value that is used as a variable
+ * within the build process. Build variables represent
+ * a variable prefix coupled with an optional static suffix.
+ * Using Makefile syntax as an example, the following is
+ * an examples of build variables:
+ * <p>
+ * <code>
+ * $(CROSS_TOOLS)/include
+ * </code>
+ * <p>
+ * For this particular build variable:
+ * <ul>
+ * <li>Calling <code>getVariable()</code> would return "CROSS_TOOLS"</li>
+ * <li>Calling <code>getFixed()</code> would return "/include"</li>
+ * <li>Calling <code>getValue()</code> would return the current value
+ * of the variable.</li>
+ * </ul>
+ * <p>
+ * The intent is to introduce a mechanism similar to that
+ * used by the Eclipse IDE to handle ClassPath variables.
+ * <p>
+ * @see ICBuildVariableProvider
+ * @see ICBuildVariableResolver
+ * @see CBuildVariable
+ */
+public interface ICBuildVariable {
+
+ /**
+ * Get the text that makes up the variable portion
+ * of this build variable.
+ *
+ * @return variable portion of this build variable.
+ */
+ String getVariable();
+
+ /**
+ * Get the text that makes up the fixed portion
+ * of this build variable.
+ *
+ * @return fixed portion of this build variable.
+ */
+ String getFixed();
+
+ /**
+ * Get the current value of this build variable,
+ * replacing the variable portion with whatever
+ * value is appropriate for teh current circumstances.
+ *
+ * @return Value of this build variable.
+ */
+ String getValue();
+
+ /**
+ * Get the resolver for this build variable,
+ *
+ * @return Resolver for this build variable.
+ */
+ ICBuildVariableResolver getResolver();
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariableProvider.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariableProvider.java
new file mode 100644
index 0000000000..37726afa26
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariableProvider.java
@@ -0,0 +1,54 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * Class that makes build variables available to the
+ * build process.
+ * <p>
+ * Intended for use in situations where generic build
+ * variables (ex, system root, etc.) can be provided
+ * for particular project types, or generically.
+ * <p>
+ * If possible the build variable provider should create
+ * a build variable that does not need to refer back to
+ * the provider for resolution. The default CBuildVariable
+ * implementation provides support for this type of
+ * build variable.
+ * </p>
+ * If the build variable will need information from the
+ * provider in order to resolve it's value, then the
+ * build variables will need to keep a reference to it's
+ * provider (or some other class that can resolve the
+ * variable protion of the build variable.) The default
+ * CBuildVariable implementation supports this type
+ * of build variable as well, through use of the
+ * ICBuildVariableResolver interface.
+ * <p>
+ * See also the <a href="../../../../../../CBuildConfig.html">CBuildConfig</a>
+ * extension point documentation.
+ * <p>
+ * @see ICBuildVariable
+ * @see ICBuildVariableResolver
+ * @see CBuildVariable
+ */
+public interface ICBuildVariableProvider {
+
+ /**
+ * Get the list of build variables made available
+ * through this provider.
+ *
+ * @return build variables.
+ */
+ ICBuildVariable[] getVariables();
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariableResolver.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariableResolver.java
new file mode 100644
index 0000000000..522d4aa8de
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICBuildVariableResolver.java
@@ -0,0 +1,37 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * Interface representing a class that is capable of
+ * resolving the variable portion of build variables
+ * at run time.
+ * <p>
+ * See also the <a href="../../../../../../CBuildConfig.html">CBuildConfig</a>
+ * extension point documentation.
+ * <p>
+ * @see ICBuildVariable
+ * @see ICBuildVariableProvider
+ * @see CBuildVariable
+ */
+
+public interface ICBuildVariableResolver {
+
+ /**
+ * Given a build variable, determine what it's
+ * resolved value should be.
+ *
+ * @return resolved value, or <code>null</code>.
+ */
+ public String resolveValue(ICBuildVariable var);
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICPosixBuildConstants.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICPosixBuildConstants.java
new file mode 100644
index 0000000000..d9ca2f1e09
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICPosixBuildConstants.java
@@ -0,0 +1,48 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * Standard build configuration constants.
+ */
+public interface ICPosixBuildConstants {
+ public final static String CPP_INCLUDES = "posix.cpp.includes"; //$NON-NLS-1$
+ public final static String CPP_DEFINITIONS = "posix.cpp.definitions"; //$NON-NLS-1$
+
+ public final static String CC_ENABLE_PROFILE = "posix.cc.profile"; //$NON-NLS-1$
+ public final static String CC_ENABLE_DEBUG = "posix.cc.debug"; //$NON-NLS-1$
+ public final static String CC_ENABLE_OPTIMIZE = "posix.cc.optimize"; //$NON-NLS-1$
+ public final static String CC_OPTIMZE_LEVEL = "posix.cc.optimize.level"; //$NON-NLS-1$
+ public final static String CC_USER_ARGS = "posix.cc.user"; //$NON-NLS-1$
+
+ public final static String CC_OPTIMIZE_NONE = "none"; //$NON-NLS-1$
+ public final static String CC_OPTIMIZE_SOME = "some"; //$NON-NLS-1$
+ public final static String CC_OPTIMIZE_FULL = "full"; //$NON-NLS-1$
+
+ public final static String CC_WARN_ALL = "posix.cc.warn.all"; //$NON-NLS-1$
+ public final static String CC_WARN_ASERROR = "posix.cc.warn.aserror"; //$NON-NLS-1$
+ public final static String CC_WARN_FORMAT = "posix.cc.warn.format"; //$NON-NLS-1$
+ public final static String CC_WARN_POINTERAR = "posix.cc.warn.pointerar"; //$NON-NLS-1$
+ public final static String CC_WARN_SWITCH = "posix.cc.warn.switch"; //$NON-NLS-1$
+ public final static String CC_WARN_UNREACH = "posix.cc.warn.unreach"; //$NON-NLS-1$
+ public final static String CC_WARN_UNUSED = "posix.cc.warn.unused"; //$NON-NLS-1$
+
+ public final static String LD_OUTPUT = "posix.ld.output"; //$NON-NLS-1$
+ public final static String LD_USER_ARGS = "posix.ld.user"; //$NON-NLS-1$
+ public final static String LD_LINK_STATIC = "posix.ld.link.static"; //$NON-NLS-1$
+ public final static String LD_LINK_AS_PROGRAM = "posix.ld.link.as.program"; //$NON-NLS-1$
+ public final static String LD_LINK_AS_SHARED = "posix.ld.link.as.shared"; //$NON-NLS-1$
+ public final static String LD_LINK_AS_ARCHIVE = "posix.ld.link.as.archive"; //$NON-NLS-1$
+ public final static String LD_STRIP = "posix.ld.strip"; //$NON-NLS-1$
+ public final static String LD_LIBS = "posix.ld.libs"; //$NON-NLS-1$
+ public final static String LD_LIBPATHS = "posix.ld.libpaths"; //$NON-NLS-1$
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICTool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICTool.java
new file mode 100644
index 0000000000..686cf8f054
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICTool.java
@@ -0,0 +1,96 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+import java.io.ByteArrayOutputStream;
+
+import org.eclipse.cdt.core.IErrorParser;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * ICTool represents an instance of a tool.
+ * <p>
+ * Tools represent a particular executable (ex, "gcc", etc.)
+ * that can be run in order to produce some output. The
+ * exec() method provides a shorthand that allows a caller
+ * to execute the tool and gather the resultant output
+ * streams.
+ * <p>
+ * Toolchain providers use this interface to represent
+ * individual tools within a toolchain.
+ * <p>
+ * Stand-alone tool providers (flex, yacc, rpcgen, etc.) make
+ * use of this to define generic build tools that can be "mixed
+ * in" to any toolchain.
+ * <p>
+ * See also the <a href="../../../../../../CTool.html">CTool</a>
+ * extension point documentation.
+ */
+public interface ICTool {
+
+ /**
+ * Convenince class that just contains a reference to
+ * two byte array output streams named sterr and stdout.
+ */
+ class IOResults {
+ public ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+ public ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+ }
+
+ /**
+ * Returns the type ID for this tool. This type ID corresponds
+ * to a CToolType extension ID
+ *
+ * @return the type ID for this tool.
+ */
+ String getTypeId();
+
+ /**
+ * Returns a unique identifuer for this tool instance.
+ *
+ * @return the type ID for this tool.
+ */
+ String getId();
+
+ /**
+ * Returns the explicit path to the executable associated
+ * with this tool instance..
+ *
+ * @return path to executable.
+ */
+ IPath getPath();
+
+ /**
+ * Indicates whether or not the executable referenced by this
+ * tool instance actually exists.
+ *
+ * @return true if the associated tool executable exists.
+ */
+ boolean exists();
+
+ /**
+ * Run the executable referenced by this tool, using the
+ * supplied parameters.
+ *
+ * @param parameters parameters to pass to tool when executing.
+ * @param workingDir working directory for tool execution.
+ */
+ IOResults exec(String[] parameters, String workingDir);
+
+ /**
+ * Get an instance of an error parser that is capable
+ * of dealing with the tool's output.
+ *
+ * @return error parser for the tool.
+ */
+ IErrorParser getErrorParser();
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolType.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolType.java
new file mode 100644
index 0000000000..5bf0714cc5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolType.java
@@ -0,0 +1,35 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * Interface representing a particular tool classification
+ * (ex, GNU c compiler, etc.)
+ * <p>
+ * See also the <a href="../../../../../../CToolType.html">CToolType</a>
+ * extension point documentation.
+ */
+public interface ICToolType {
+ /**
+ * Returns the unique id for the tool type.
+ *
+ * @return unique id.
+ */
+ public String getId();
+
+ /**
+ * Returns the name of the tool type.
+ *
+ * @return provider name.
+ */
+ public String getName();
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolchain.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolchain.java
new file mode 100644
index 0000000000..459e454129
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolchain.java
@@ -0,0 +1,75 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * The ICToolchain interface represents a collection of
+ * associated tools. A typical toolchain might consist
+ * of a compiler, an assembler, a linker, etc.
+ * <p>
+ * Many ICToolchain operations happen in the context of
+ * a build configuration, and so take an ICBuildConfig
+ * parameter. The build configuration provides the
+ * toolchain with information about the parameters to
+ * use when generating build commands.
+ */
+public interface ICToolchain {
+
+ /**
+ * Get the build commands needed to build a file.
+ *
+ * @param file file that needs to be built.
+ * @param cfg build configuration context.
+ * @return build command(s) needed to build this file,
+ * or <b>null</b> the specified file cannot (or should
+ * not) be processed by this toolchain.
+ */
+ ICBuildCmd[] getBuildCommands(IFile file, ICBuildConfig cfg);
+
+ /**
+ * Get the dependencies for a file.
+ *
+ * @param file file to compute dependencies for.
+ * @param cfg build configuration context.
+ * @return file(s) that the given file depends on,
+ * or <b>null</b> the specified file does not have
+ * any dependencies.
+ */
+ IFile[] getDependencies(IFile file, ICBuildConfig cfg);
+
+ /**
+ * Get the output files generated by building a file.
+ *
+ * @param file file to compute outputs for.
+ * @param cfg build configuration context.
+ * @return file(s) that will be generated in the process
+ * of building the specified file.
+ */
+ IFile[] getOutputs(IFile file, ICBuildConfig cfg);
+
+ /**
+ * Get the tools associated with this toolchain.
+ *
+ * @return tools associated with this toolchain
+ */
+ ICTool[] getTools();
+
+ /**
+ * Indicate whether or not this toolchain is capable of and
+ * interested in handling the specified file.
+ * @param file file to examine.
+ * @return true if the toolchain can process the file.
+ */
+ boolean canProcess(IFile file);
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolchainProvider.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolchainProvider.java
new file mode 100644
index 0000000000..22e85dae3c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/ICToolchainProvider.java
@@ -0,0 +1,48 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model;
+
+/**
+ * Interface representing a class that makes one or more
+ * toolchains (collections of related tools) available to
+ * the IDE.
+ * <br>
+ * Using a toolchain provider allows clients to implement
+ * toolchain location logic in whatever manner suits them
+ * best. For example, a toolchain provider may locate a
+ * toolchain by examining the local filesystem, reading
+ * a configuration file, providing UI elements to allow
+ * a user to specify particular executable to use as part
+ * of a specialize toolchain, etc.
+ * <p>
+ * See also the <a href="../../../../../../CToolchain.html">CToolchain</a>
+ * extension point documentation.
+ */
+public interface ICToolchainProvider {
+
+ /**
+ * Return the ICToolchain instances managed by this provider.
+ *
+ * @return toolchain instances managed by this provider.
+ */
+ ICToolchain[] getToolchains();
+
+ /**
+ * Return an ICToolchain instance managed by this provider.
+ *
+ * @param id toolchain ID.
+ * @return toolchain instance, or <b>null</b> if the
+ * provider does not recognize the toolchain ID.
+ */
+ ICToolchain getToolchain(String id);
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfig.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfig.java
new file mode 100644
index 0000000000..d01638cf36
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfig.java
@@ -0,0 +1,391 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model.internal;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xerces.dom.DocumentImpl;
+import org.eclipse.cdt.core.builder.BuilderPlugin;
+import org.eclipse.cdt.core.builder.model.ICBuildConfig;
+import org.eclipse.cdt.core.builder.model.ICBuildConfigWorkingCopy;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.core.DebugCoreMessages;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author sam.robb
+ */
+public class CBuildConfig extends PlatformObject implements ICBuildConfig {
+
+ /**
+ * Location this configuration is stored in. This
+ * is the key for a build configuration handle.
+ */
+ private IPath fLocation;
+
+ /**
+ * Constructs a build configuration in the given location.
+ *
+ * @param location path to where this build configuration's
+ * underlying file is located
+ */
+ protected CBuildConfig(IPath location) {
+ setLocation(location);
+ }
+
+ /**
+ * Constructs a launch configuration from the given
+ * memento.
+ *
+ * @param memento configuration memento
+ * @exception CoreException if the memento is invalid or
+ * an exception occurrs reading the memento
+ */
+ protected CBuildConfig(String memento) throws CoreException {
+ Exception ex = null;
+ try {
+ Element root = null;
+ DocumentBuilder parser =
+ DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ StringReader reader = new StringReader(memento);
+ InputSource source = new InputSource(reader);
+ root = parser.parse(source).getDocumentElement();
+
+ String localString = root.getAttribute("local"); //$NON-NLS-1$
+ String path = root.getAttribute("path"); //$NON-NLS-1$
+
+ String message = null;
+ if (path == null) {
+ message = DebugCoreMessages.getString("LaunchConfiguration.Invalid_build_configuration_memento__missing_path_attribute_3"); //$NON-NLS-1$
+ } else if (localString == null) {
+ message = DebugCoreMessages.getString("LaunchConfiguration.Invalid_build_configuration_memento__missing_local_attribute_4"); //$NON-NLS-1$
+ }
+ if (message != null) {
+ IStatus s = newStatus(message, DebugException.INTERNAL_ERROR, null);
+ throw new CoreException(s);
+ }
+
+ IPath location = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(path);
+
+ setLocation(location);
+ return;
+ } catch (ParserConfigurationException e) {
+ ex = e;
+ } catch (SAXException e) {
+ ex = e;
+ } catch (IOException e) {
+ ex = e;
+ }
+ IStatus s = newStatus(DebugCoreMessages.getString("LaunchConfiguration.Exception_occurred_parsing_memento_5"), DebugException.INTERNAL_ERROR, ex); //$NON-NLS-1$
+ throw new CoreException(s);
+ }
+
+ /**
+ * Creates and returns a new error status based on
+ * the given mesasge, code, and exception.
+ *
+ * @param message error message
+ * @param code error code
+ * @param e exception or <code>null</code>
+ * @return status
+ */
+ protected IStatus newStatus(String message, int code, Throwable e) {
+ return new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), code, message, e);
+ }
+
+ /**
+ * @see ICBuildConfig#build(IProgressMonitor)
+ */
+ public void build(IProgressMonitor monitor) throws CoreException {
+ }
+
+ /**
+ * A configuration's name is that of the last segment
+ * in it's location (subtract the ".build" extension).
+ *
+ * @see ICBuildConfig#getName()
+ */
+ public String getName() {
+ return getLastLocationSegment();
+ }
+
+ private String getLastLocationSegment() {
+ String name = getLocation().lastSegment();
+ name = name.substring(0, name.length() - (BUILD_CONFIGURATION_FILE_EXTENSION.length() + 1));
+ return name;
+ }
+
+ /**
+ * @see ICBuildConfig#getLocation()
+ */
+ public IPath getLocation() {
+ return fLocation;
+ }
+
+ /**
+ * Sets the location of this configuration's underlying
+ * file.
+ *
+ * @param location the location of this configuration's underlying
+ * file
+ */
+ private void setLocation(IPath location) {
+ fLocation = location;
+ }
+
+ /**
+ * @see ICBuildConfig#exists()
+ */
+ public boolean exists() {
+ IFile file = getFile();
+ if (file == null) {
+ return getLocation().toFile().exists();
+ } else {
+ return file.exists();
+ }
+ }
+
+ /**
+ * @see ICBuildConfig#getAttribute(String, int)
+ */
+ public int getAttribute(String attributeName, int defaultValue) throws CoreException {
+ return getInfo().getIntAttribute(attributeName, defaultValue);
+ }
+
+ /**
+ * @see ICBuildConfig#getAttribute(String, String)
+ */
+ public String getAttribute(String attributeName, String defaultValue) throws CoreException {
+ return getInfo().getStringAttribute(attributeName, defaultValue);
+ }
+
+ /**
+ * @see ICBuildConfig#getAttribute(String, boolean)
+ */
+ public boolean getAttribute(String attributeName, boolean defaultValue) throws CoreException {
+ return getInfo().getBooleanAttribute(attributeName, defaultValue);
+ }
+
+ /**
+ * @see ICBuildConfig#getAttribute(String, List)
+ */
+ public List getAttribute(String attributeName, List defaultValue) throws CoreException {
+ return getInfo().getListAttribute(attributeName, defaultValue);
+ }
+
+ /**
+ * @see ICBuildConfig#getAttribute(String, Map)
+ */
+ public Map getAttribute(String attributeName, Map defaultValue) throws CoreException {
+ return getInfo().getMapAttribute(attributeName, defaultValue);
+ }
+
+ /**
+ * @see ICBuildConfig#isLocal()
+ */
+ public boolean isLocal() {
+ return getFile() == null;
+ }
+
+ /**
+ * @see ICBuildConfig#getWorkingCopy()
+ */
+ public ICBuildConfigWorkingCopy getWorkingCopy() throws CoreException {
+ return new CBuildConfigWorkingCopy(this);
+ }
+
+ /**
+ * @see ICBuildConfig#copy(String name)
+ */
+ public ICBuildConfigWorkingCopy copy(String name) throws CoreException {
+ ICBuildConfigWorkingCopy copy = new CBuildConfigWorkingCopy(this, name);
+ return copy;
+ }
+
+ /**
+ * @see ICBuildConfig#isWorkingCopy()
+ */
+ public boolean isWorkingCopy() {
+ return false;
+ }
+
+ /**
+ * @see ICBuildConfig#delete()
+ */
+ public void delete() throws CoreException {
+ if (exists()) {
+ if (isLocal()) {
+ if (!(getLocation().toFile().delete())) {
+ throw new DebugException(
+ new Status(Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, DebugCoreMessages.getString("LaunchConfiguration.Failed_to_delete_build_configuration._1"), null) //$NON-NLS-1$
+ );
+ }
+ // manually update the build manager cache since there
+ // will be no resource delta
+ getBuildConfigurationManager().configurationDeleted(this);
+ } else {
+ // delete the resource using IFile API such that
+ // resource deltas are fired.
+ IResource file = getFile();
+ if (file != null) {
+ file.delete(true, null);
+ } else {
+ // Error - the exists test passed, but could not locate file
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the info object containing the attributes
+ * of this configuration
+ *
+ * @return info for this handle
+ * @exception CoreException if unable to retrieve the
+ * info object
+ */
+ protected CBuildConfigInfo getInfo() throws CoreException {
+ return getBuildConfigurationManager().getInfo(this);
+ }
+
+ /**
+ * Returns the build manager
+ *
+ * @return build manager
+ */
+ protected CBuildConfigManager getBuildConfigurationManager() {
+ return BuilderPlugin.getDefault().getBuildConfigurationManager();
+ }
+
+ /**
+ * @see ICBuildConfig#getMemento()
+ */
+ public String getMemento() throws CoreException {
+ IPath relativePath = getFile().getFullPath();
+ relativePath = relativePath.setDevice(null);
+
+ Document doc = new DocumentImpl();
+ Element node = doc.createElement("buildConfiguration"); //$NON-NLS-1$
+ doc.appendChild(node);
+ node.setAttribute("local", (new Boolean(isLocal())).toString()); //$NON-NLS-1$
+ node.setAttribute("path", relativePath.toString()); //$NON-NLS-1$
+
+ try {
+ return CBuildConfigManager.serializeDocument(doc);
+ } catch (IOException e) {
+ IStatus status = newStatus(DebugCoreMessages.getString("LaunchConfiguration.Exception_occurred_creating_build_configuration_memento_9"), DebugException.INTERNAL_ERROR, e); //$NON-NLS-1$
+ throw new CoreException(status);
+ }
+ }
+
+ /**
+ * @see ICBuildConfig#getFile()
+ */
+ public IFile getFile() {
+ return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(getLocation());
+ }
+
+ /**
+ * @see ICBuildConfig#getProject()
+ */
+ public IProject getProject() {
+ return getFile().getProject();
+ }
+
+ /**
+ * @see ICBuildConfig#contentsEqual(ICBuildConfig)
+ */
+ public boolean contentsEqual(ICBuildConfig object) {
+ try {
+ if (object instanceof CBuildConfig) {
+ CBuildConfig otherConfig = (CBuildConfig) object;
+ return getName().equals(otherConfig.getName())
+ && getLocation().equals(otherConfig.getLocation())
+ && getInfo().equals(otherConfig.getInfo());
+ }
+ return false;
+ } catch (CoreException ce) {
+ return false;
+ }
+ }
+
+ /**
+ * Returns whether this configuration is equal to the
+ * given configuration. Two configurations are equal if
+ * they are stored in the same location (and neither one
+ * is a working copy).
+ *
+ * @return whether this configuration is equal to the
+ * given configuration
+ * @see Object#equals(Object)
+ */
+ public boolean equals(Object object) {
+ if (object instanceof ICBuildConfig) {
+ if (isWorkingCopy()) {
+ return this == object;
+ }
+ ICBuildConfig config = (ICBuildConfig) object;
+ if (!config.isWorkingCopy()) {
+ return config.getLocation().equals(getLocation());
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see Object#hashCode()
+ */
+ public int hashCode() {
+ return getLocation().hashCode();
+ }
+
+ /**
+ * Returns the container this build configuration is
+ * stored in, or <code>null</code> if this build configuration
+ * is stored locally.
+ *
+ * @return the container this build configuration is
+ * stored in, or <code>null</code> if this build configuration
+ * is stored locally
+ */
+ protected IContainer getContainer() {
+ IFile file = getFile();
+ if (file != null) {
+ return file.getParent();
+ }
+ return null;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigInfo.java
new file mode 100644
index 0000000000..112769b419
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigInfo.java
@@ -0,0 +1,474 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model.internal;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.xerces.dom.DocumentImpl;
+import org.eclipse.cdt.core.builder.BuilderPlugin;
+import org.eclipse.cdt.core.builder.model.ICBuildConfigManager;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.core.DebugCoreMessages;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author sam.robb
+ *
+ * The information associated with a build configuration
+ * handle.
+ */
+public class CBuildConfigInfo {
+
+ /**
+ * This configurations attribute table.
+ * Keys are <code>String</code>s and values
+ * are one of <code>String</code>, <code>Integer</code>,
+ * or <code>Boolean</code>.
+ */
+ private HashMap fAttributes;
+
+ /**
+ * Constructs a new empty info
+ */
+ protected CBuildConfigInfo() {
+ setAttributeTable(new HashMap(10));
+ }
+
+ /**
+ * Returns this configuration's attribute table.
+ *
+ * @return attribute table
+ */
+ private HashMap getAttributeTable() {
+ return fAttributes;
+ }
+
+ /**
+ * Sets this configuration's attribute table.
+ *
+ * @param table attribute table
+ */
+ private void setAttributeTable(HashMap table) {
+ fAttributes = table;
+ }
+
+ /**
+ * Returns the <code>String</code> attribute with the
+ * given key or the given default value if undefined.
+ *
+ * @return attribute specified by given key or the defaultValue
+ * if undefined
+ * @exception if the attribute with the given key exists
+ * but is not a <code>String</code>
+ */
+ protected String getStringAttribute(String key, String defaultValue) throws CoreException {
+ Object attr = getAttributeTable().get(key);
+ if (attr != null) {
+ if (attr instanceof String) {
+ return (String)attr;
+ } else {
+ throw new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_java.lang.String._1"), new String[] {key}), null //$NON-NLS-1$
+ )
+ );
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Returns the <code>int</code> attribute with the
+ * given key or the given default value if undefined.
+ *
+ * @return attribute specified by given key or the defaultValue
+ * if undefined
+ * @exception if the attribute with the given key exists
+ * but is not an <code>int</code>
+ */
+ protected int getIntAttribute(String key, int defaultValue) throws CoreException {
+ Object attr = getAttributeTable().get(key);
+ if (attr != null) {
+ if (attr instanceof Integer) {
+ return ((Integer)attr).intValue();
+ } else {
+ throw new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_int._2"), new String[] {key}), null //$NON-NLS-1$
+ )
+ );
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Returns the <code>boolean</code> attribute with the
+ * given key or the given default value if undefined.
+ *
+ * @return attribute specified by given key or the defaultValue
+ * if undefined
+ * @exception if the attribute with the given key exists
+ * but is not a <code>boolean</code>
+ */
+ protected boolean getBooleanAttribute(String key, boolean defaultValue) throws CoreException {
+ Object attr = getAttributeTable().get(key);
+ if (attr != null) {
+ if (attr instanceof Boolean) {
+ return ((Boolean)attr).booleanValue();
+ } else {
+ throw new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_boolean._3"), new String[] {key}), null //$NON-NLS-1$
+ )
+ );
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Returns the <code>java.util.List</code> attribute with the
+ * given key or the given default value if undefined.
+ *
+ * @return attribute specified by given key or the defaultValue
+ * if undefined
+ * @exception if the attribute with the given key exists
+ * but is not a <code>java.util.List</code>
+ */
+ protected List getListAttribute(String key, List defaultValue) throws CoreException {
+ Object attr = getAttributeTable().get(key);
+ if (attr != null) {
+ if (attr instanceof List) {
+ return (List)attr;
+ } else {
+ throw new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_java.util.List._1"), new String[] {key}), null //$NON-NLS-1$
+ )
+ );
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Returns the <code>java.util.Map</code> attribute with the
+ * given key or the given default value if undefined.
+ *
+ * @return attribute specified by given key or the defaultValue
+ * if undefined
+ * @exception if the attribute with the given key exists
+ * but is not a <code>java.util.Map</code>
+ */
+ protected Map getMapAttribute(String key, Map defaultValue) throws CoreException {
+ Object attr = getAttributeTable().get(key);
+ if (attr != null) {
+ if (attr instanceof Map) {
+ return (Map)attr;
+ } else {
+ throw new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_java.util.Map._1"), new String[] {key}), null //$NON-NLS-1$
+ )
+ );
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Returns a copy of this info object
+ *
+ * @return copy of this info
+ */
+ protected CBuildConfigInfo getCopy() {
+ CBuildConfigInfo copy = new CBuildConfigInfo();
+ copy.setAttributeTable((HashMap)getAttributeTable().clone());
+ return copy;
+ }
+
+ /**
+ * Sets the given attribute to the given value. Only
+ * working copy's should use this API.
+ *
+ * @param key attribute key
+ * @param value attribuet value
+ */
+ protected void setAttribute(String key, Object value) {
+ if (value == null) {
+ getAttributeTable().remove(key);
+ } else {
+ getAttributeTable().put(key, value);
+ }
+ }
+
+ /**
+ * Returns the content of this info as XML
+ *
+ * @return the content of this info as XML
+ * @exception IOException if an exception occurs creating the XML
+ */
+ protected String getAsXML() throws IOException {
+
+ Document doc = new DocumentImpl();
+ Element configRootElement = doc.createElement("buildConfiguration"); //$NON-NLS-1$
+ doc.appendChild(configRootElement);
+
+ Iterator keys = getAttributeTable().keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String)keys.next();
+ Object value = getAttributeTable().get(key);
+ if (value == null) {
+ continue;
+ }
+ Element element = null;
+ String valueString = null;
+ if (value instanceof String) {
+ valueString = (String)value;
+ element = createKeyValueElement(doc, "stringAttribute", key, valueString); //$NON-NLS-1$
+ } else if (value instanceof Integer) {
+ valueString = ((Integer)value).toString();
+ element = createKeyValueElement(doc, "intAttribute", key, valueString); //$NON-NLS-1$
+ } else if (value instanceof Boolean) {
+ valueString = ((Boolean)value).toString();
+ element = createKeyValueElement(doc, "booleanAttribute", key, valueString); //$NON-NLS-1$
+ } else if (value instanceof List) {
+ element = createListElement(doc, "listAttribute", key, (List)value); //$NON-NLS-1$
+ } else if (value instanceof Map) {
+ element = createMapElement(doc, "mapAttribute", key, (Map)value); //$NON-NLS-1$
+ }
+ configRootElement.appendChild(element);
+ }
+
+ return CBuildConfigManager.serializeDocument(doc);
+ }
+
+ /**
+ * Helper method that creates a 'key value' element of the specified type with the
+ * specified attribute values.
+ */
+ protected Element createKeyValueElement(Document doc, String elementType, String key, String value) {
+ Element element = doc.createElement(elementType);
+ element.setAttribute("key", key); //$NON-NLS-1$
+ element.setAttribute("value", value); //$NON-NLS-1$
+ return element;
+ }
+
+ protected Element createListElement(Document doc, String elementType, String listKey, List list) {
+ Element listElement = doc.createElement(elementType);
+ listElement.setAttribute("key", listKey); //$NON-NLS-1$
+ Iterator iterator = list.iterator();
+ while (iterator.hasNext()) {
+ String value = (String) iterator.next();
+ Element element = doc.createElement("listEntry"); //$NON-NLS-1$
+ element.setAttribute("value", value); //$NON-NLS-1$
+ listElement.appendChild(element);
+ }
+ return listElement;
+ }
+
+ protected Element createMapElement(Document doc, String elementType, String mapKey, Map map) {
+ Element mapElement = doc.createElement(elementType);
+ mapElement.setAttribute("key", mapKey); //$NON-NLS-1$
+ Iterator iterator = map.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ String value = (String) map.get(key);
+ Element element = doc.createElement("mapEntry"); //$NON-NLS-1$
+ element.setAttribute("key", key); //$NON-NLS-1$
+ element.setAttribute("value", value); //$NON-NLS-1$
+ mapElement.appendChild(element);
+ }
+ return mapElement;
+ }
+
+ protected void initializeFromXML(Element root) throws CoreException {
+ if (!root.getNodeName().equalsIgnoreCase("buildConfiguration")) { //$NON-NLS-1$
+ throw getInvalidFormatDebugException();
+ }
+
+ NodeList list = root.getChildNodes();
+ int length = list.getLength();
+ for (int i = 0; i < length; ++i) {
+ Node node = list.item(i);
+ short type = node.getNodeType();
+ if (type == Node.ELEMENT_NODE) {
+ Element element = (Element) node;
+ String nodeName = element.getNodeName();
+
+ if (nodeName.equalsIgnoreCase("stringAttribute")) { //$NON-NLS-1$
+ setStringAttribute(element);
+ } else if (nodeName.equalsIgnoreCase("intAttribute")) { //$NON-NLS-1$
+ setIntegerAttribute(element);
+ } else if (nodeName.equalsIgnoreCase("booleanAttribute")) { //$NON-NLS-1$
+ setBooleanAttribute(element);
+ } else if (nodeName.equalsIgnoreCase("listAttribute")) { //$NON-NLS-1$
+ setListAttribute(element);
+ } else if (nodeName.equalsIgnoreCase("mapAttribute")) { //$NON-NLS-1$
+ setMapAttribute(element);
+ }
+ }
+ }
+ }
+
+ protected void setStringAttribute(Element element) throws CoreException {
+ String key = getKeyAttribute(element);
+ String value = getValueAttribute(element);
+ setAttribute(key, value);
+ }
+
+ protected void setIntegerAttribute(Element element) throws CoreException {
+ String key = getKeyAttribute(element);
+ String value = getValueAttribute(element);
+ setAttribute(key, new Integer(value));
+ }
+
+ protected void setBooleanAttribute(Element element) throws CoreException {
+ String key = getKeyAttribute(element);
+ String value = getValueAttribute(element);
+ setAttribute(key, new Boolean(value));
+ }
+
+ protected void setListAttribute(Element element) throws CoreException {
+ String listKey = element.getAttribute("key"); //$NON-NLS-1$
+ NodeList nodeList = element.getChildNodes();
+ int entryCount = nodeList.getLength();
+ List list = new ArrayList(entryCount);
+ for (int i = 0; i < entryCount; i++) {
+ Node node = nodeList.item(i);
+ short type = node.getNodeType();
+ if (type == Node.ELEMENT_NODE) {
+ Element subElement = (Element) node;
+ String nodeName = subElement.getNodeName();
+ if (!nodeName.equalsIgnoreCase("listEntry")) { //$NON-NLS-1$
+ throw getInvalidFormatDebugException();
+ }
+ String value = getValueAttribute(subElement);
+ list.add(value);
+ }
+ }
+ setAttribute(listKey, list);
+ }
+
+ protected void setMapAttribute(Element element) throws CoreException {
+ String mapKey = element.getAttribute("key"); //$NON-NLS-1$
+ NodeList nodeList = element.getChildNodes();
+ int entryCount = nodeList.getLength();
+ Map map = new HashMap(entryCount);
+ for (int i = 0; i < entryCount; i++) {
+ Node node = nodeList.item(i);
+ short type = node.getNodeType();
+ if (type == Node.ELEMENT_NODE) {
+ Element subElement = (Element) node;
+ String nodeName = subElement.getNodeName();
+ if (!nodeName.equalsIgnoreCase("mapEntry")) { //$NON-NLS-1$
+ throw getInvalidFormatDebugException();
+ }
+ String key = getKeyAttribute(subElement);
+ String value = getValueAttribute(subElement);
+ map.put(key, value);
+ }
+ }
+ setAttribute(mapKey, map);
+ }
+
+ protected String getKeyAttribute(Element element) throws CoreException {
+ String key = element.getAttribute("key"); //$NON-NLS-1$
+ if (key == null) {
+ throw getInvalidFormatDebugException();
+ }
+ return key;
+ }
+
+ protected String getValueAttribute(Element element) throws CoreException {
+ String value = element.getAttribute("value"); //$NON-NLS-1$
+ if (value == null) {
+ throw getInvalidFormatDebugException();
+ }
+ return value;
+ }
+
+ protected DebugException getInvalidFormatDebugException() {
+ return
+ new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, DebugCoreMessages.getString("LaunchConfigurationInfo.Invalid_launch_configuration_XML._10"), null //$NON-NLS-1$
+ )
+ );
+ }
+
+ /**
+ * Two <code>CBuildConfigInfo</code> objects are equal if and only if
+ * they have the same set of attributes with the same values.
+ *
+ * @see Object#equals(Object)
+ */
+ public boolean equals(Object obj) {
+
+ // Make sure it's a LaunchConfigurationInfo object
+ if (!(obj instanceof CBuildConfigInfo)) {
+ return false;
+ }
+
+ CBuildConfigInfo other = (CBuildConfigInfo) obj;
+
+ // Make sure the attributes are the same
+ return compareAttributes(fAttributes, other.getAttributeTable());
+ }
+
+ /**
+ * Returns whether the two attribute maps are equal, consulting
+ * registered comparator extensions.
+ *
+ * @param map1 attribute map
+ * @param map2 attribute map
+ * @return whether the two attribute maps are equal
+ */
+ protected boolean compareAttributes(HashMap map1, HashMap map2) {
+ ICBuildConfigManager manager = BuilderPlugin.getDefault().getBuildConfigurationManager();
+ if (map1.size() == map2.size()) {
+ Iterator attributes = map1.keySet().iterator();
+ while (attributes.hasNext()) {
+ String key = (String)attributes.next();
+ Object attr1 = map1.get(key);
+ Object attr2 = map2.get(key);
+ if (attr2 == null) {
+ return false;
+ }
+ if (!attr1.equals(attr2)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigManager.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigManager.java
new file mode 100644
index 0000000000..a82144a7a9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigManager.java
@@ -0,0 +1,415 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model.internal;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+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.builder.model.ICBuildConfig;
+import org.eclipse.cdt.core.builder.model.ICBuildConfigListener;
+import org.eclipse.cdt.core.builder.model.ICBuildConfigManager;
+import org.eclipse.cdt.core.builder.model.ICBuildConfigWorkingCopy;
+import org.eclipse.core.resources.IContainer;
+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.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.core.DebugCoreMessages;
+import org.eclipse.debug.internal.core.ListenerList;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Manages build configurations.
+ *
+ * @see ICBuildConfigManager
+ */
+public class CBuildConfigManager implements ICBuildConfigManager {
+
+ /**
+ * Collection of listeners
+ */
+ private ListenerList fListeners = new ListenerList(5);
+
+ /**
+ * Types of notifications
+ */
+ public static final int ADDED = 0;
+ public static final int REMOVED = 1;
+ public static final int CHANGED = 2;
+
+ /**
+ * Serializes a XML document into a string - encoded in UTF8 format,
+ * with platform line separators.
+ *
+ * @param doc document to serialize
+ * @return the document as a string
+ */
+ public static String serializeDocument(Document doc) throws IOException {
+ ByteArrayOutputStream s= new ByteArrayOutputStream();
+ OutputFormat format = new OutputFormat();
+ format.setIndenting(true);
+ format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
+
+ Serializer serializer =
+ SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
+ new OutputStreamWriter(s, "UTF8"), //$NON-NLS-1$
+ format);
+ serializer.asDOMSerializer().serialize(doc);
+ return s.toString("UTF8"); //$NON-NLS-1$
+ }
+
+ /**
+ * @see ICBuildConfigManager#addListener(ICBuildConfigListener)
+ */
+ public void addListener(ICBuildConfigListener listener) {
+ fListeners.add(listener);
+ }
+
+ /**
+ * @see ICBuildConfigManager#removeListener(ICBuildConfigListener)
+ */
+ public void removeListener(ICBuildConfigListener listener) {
+ fListeners.remove(listener);
+ }
+
+ /**
+ * @see ICBuildConfigManager#addConfiguration(ICBuildConfig)
+ */
+ public void addConfiguration(ICBuildConfig configuration) {
+ fireUpdate(configuration, ADDED);
+ }
+
+ /**
+ * @see ICBuildConfigManager#removeConfiguration(ICBuildConfig)
+ */
+ public void removeConfiguration(ICBuildConfig configuration) {
+ fireUpdate(configuration, REMOVED);
+ }
+
+ /**
+ * @see ICBuildConfigManager#generateUniqueConfigurationNameFrom(IProject, String)
+ */
+ public String generateUniqueConfigurationNameFrom(IProject project, String baseName) {
+ int index = 1;
+ int length= baseName.length();
+ int copyIndex = baseName.lastIndexOf(" ("); //$NON-NLS-1$
+ if (copyIndex > -1 && length > copyIndex + 2 && baseName.charAt(length - 1) == ')') {
+ String trailer = baseName.substring(copyIndex + 2, length -1);
+ if (isNumber(trailer)) {
+ try {
+ index = Integer.parseInt(trailer);
+ baseName = baseName.substring(0, copyIndex);
+ } catch (NumberFormatException nfe) {
+ }
+ }
+ }
+ String newName = baseName;
+ try {
+ StringBuffer buffer= null;
+ while (isExistingConfigurationName(project, newName)) {
+ buffer = new StringBuffer(baseName);
+ buffer.append(" ("); //$NON-NLS-1$
+ buffer.append(String.valueOf(index));
+ index++;
+ buffer.append(')');
+ newName = buffer.toString();
+ }
+ } catch (CoreException e) {
+ DebugPlugin.log(e);
+ }
+ return newName;
+ }
+
+ /**
+ * @see ICBuildConfigManager#getConfiguration(IFile)
+ */
+ public ICBuildConfig getConfiguration(IFile file) {
+ return new CBuildConfig(file.getLocation());
+ }
+
+ /**
+ * @see ICBuildConfigManager#getConfiguration(String)
+ */
+ public ICBuildConfig getConfiguration(String memento) throws CoreException {
+ return new CBuildConfig(memento);
+ }
+
+ public ICBuildConfigWorkingCopy getConfiguration(IProject project, String name) {
+ if ((name == null) || (name.length() < 1)) {
+ name = "New Configuration";
+ }
+ name = generateUniqueConfigurationNameFrom(project, name);
+ return new CBuildConfigWorkingCopy(project, name);
+ }
+
+ /**
+ * @see ICBuildConfigManager#getConfigurations(IProject)
+ */
+ public ICBuildConfig[] getConfigurations(IProject project) throws CoreException {
+ List configs = findConfigurations(project, ICBuildConfig.BUILD_CONFIGURATION_FILE_EXTENSION);
+ return (ICBuildConfig[]) configs.toArray(new ICBuildConfig[configs.size()]);
+ }
+
+ /**
+ * @see ICBuildConfigManager#isExistingConfigurationName(IProject, String)
+ */
+ public boolean isExistingConfigurationName(IProject project, String name) throws CoreException {
+ List configFiles;
+ int count = 0;
+
+ configFiles = findConfigurations(project, ICBuildConfig.BUILD_CONFIGURATION_FILE_EXTENSION);
+ count = configFiles.size();
+
+ if (count > 0) {
+ for (Iterator iter = configFiles.iterator(); iter.hasNext();) {
+ ICBuildConfig element = (ICBuildConfig) iter.next();
+ if (name.equals(element.getName())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Fires notification to the listeners that a configuration
+ * has been added, removed, updated, or deleted.
+ */
+ protected void fireUpdate(ICBuildConfig configuration, int update) {
+ Object[] copiedListeners = fListeners.getListeners();
+ for (int i= 0; i < copiedListeners.length; i++) {
+ ICBuildConfigListener listener = (ICBuildConfigListener) copiedListeners[i];
+ switch (update) {
+ case ADDED:
+ listener.configurationAdded(configuration);
+ break;
+ case REMOVED:
+ listener.configurationRemoved(configuration);
+ break;
+ case CHANGED:
+ listener.configurationChanged(configuration);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Notifies the manager that a configuration has been deleted.
+ *
+ * @param project the project containing the configuration
+ * @param config the configuration that was deleted
+ */
+ protected void configurationDeleted(ICBuildConfig configuration) throws CoreException {
+ fireUpdate(configuration, REMOVED);
+ }
+
+ /**
+ * Notifies the manager that a configuration has been added.
+ *
+ * @param project the project containing the configuration
+ * @param config the configuration that was added
+ */
+ protected void configurationAdded(ICBuildConfig configuration) throws CoreException {
+ if (isValid(configuration)) {
+ fireUpdate(configuration, ADDED);
+ } else {
+ fireUpdate(configuration, ADDED);
+ }
+ }
+
+ /**
+ * Notifies the manager that a configuration has been added.
+ *
+ * @param project the project containing the configuration
+ * @param config the launch configuration that was changed
+ */
+ protected void configurationChanged(ICBuildConfig configuration) {
+ if (isValid(configuration)) {
+ fireUpdate(configuration, CHANGED);
+ } else {
+ fireUpdate(configuration, REMOVED);
+ }
+ }
+
+ /**
+ * Returns the info object for the specified launch configuration.
+ * If the configuration exists, but is not yet in the cache,
+ * an info object is built and added to the cache.
+ *
+ * @exception CoreException if an exception occurs building
+ * the info object
+ * @exception DebugException if the config does not exist
+ */
+ protected CBuildConfigInfo getInfo(ICBuildConfig config) throws CoreException {
+ CBuildConfigInfo info = null;
+
+ if (config.exists()) {
+ InputStream stream = null;
+
+ try {
+ IFile file = ((CBuildConfig) config).getFile();
+ stream = file.getContents();
+ info = createInfoFromXML(stream);
+ } catch (FileNotFoundException e) {
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
+ } catch (SAXException e) {
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
+ } catch (ParserConfigurationException e) {
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
+ } catch (IOException e) {
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ } else {
+ throw createDebugException(DebugCoreMessages.getString("LaunchManager.Launch_configuration_does_not_exist._6"), null); //$NON-NLS-1$
+ }
+
+ return info;
+ }
+
+ /**
+ * Return a LaunchConfigurationInfo object initialized from XML contained in
+ * the specified stream. Simply pass out any exceptions encountered so that
+ * caller can deal with them. This is important since caller may need access to the
+ * actual exception.
+ */
+ protected CBuildConfigInfo createInfoFromXML(InputStream stream)
+ throws CoreException, ParserConfigurationException, IOException, SAXException {
+ Element root = null;
+ DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ root = parser.parse(new InputSource(stream)).getDocumentElement();
+ CBuildConfigInfo info = new CBuildConfigInfo();
+ info.initializeFromXML(root);
+ return info;
+ }
+
+ /**
+ * Return an instance of DebugException containing the specified message and Throwable.
+ */
+ protected DebugException createDebugException(String message, Throwable throwable) {
+ return new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, message, throwable
+ )
+ );
+ }
+
+ /**
+ * Finds and returns all configurations in the given
+ * container (and subcontainers)
+ *
+ * @param container the container to search
+ * @exception CoreException an exception occurs traversing
+ * the container.
+ * @return all configurations in the given container
+ */
+ protected List findConfigurations(IContainer container, String extension) throws CoreException {
+ List list = new ArrayList(10);
+ if (container instanceof IProject && !((IProject)container).isOpen()) {
+ return list;
+ }
+ searchForFiles(container, extension, list);
+ Iterator iter = list.iterator();
+ List configs = new ArrayList(list.size());
+ while (iter.hasNext()) {
+ IFile file = (IFile)iter.next();
+ configs.add(getConfiguration(file));
+ }
+ return configs;
+ }
+
+ /**
+ * Recursively searches the given container for files with the given
+ * extension.
+ *
+ * @param container the container to search in
+ * @param extension the file extension being searched for
+ * @param list the list to add the matching files to
+ * @exception CoreException if an exception occurs traversing
+ * the container
+ */
+ protected void searchForFiles(IContainer container, String extension, List list) throws CoreException {
+ IResource[] members = container.members();
+ for (int i = 0; i < members.length; i++) {
+ if (members[i] instanceof IContainer) {
+ if (members[i] instanceof IProject && !((IProject)members[i]) .isOpen()) {
+ continue;
+ }
+ searchForFiles((IContainer)members[i], extension, list);
+ } else if (members[i] instanceof IFile) {
+ IFile file = (IFile)members[i];
+ if (extension.equalsIgnoreCase(file.getFileExtension())) {
+ list.add(file);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns whether the given String is composed solely of digits
+ */
+ private boolean isNumber(String string) {
+ int numChars= string.length();
+ if (numChars == 0) {
+ return false;
+ }
+ for (int i= 0; i < numChars; i++) {
+ if (!Character.isDigit(string.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns whether the given configuration passes a basic
+ * integritiy test.
+ *
+ * @param config the configuration to verify
+ * @return whether the config meets basic integrity constraints
+ */
+ protected boolean isValid(ICBuildConfig config) {
+ // TODO: Tests?
+ return (null != config);
+ }
+}
+
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigWorkingCopy.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigWorkingCopy.java
new file mode 100644
index 0000000000..aa7fe2a640
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/model/internal/CBuildConfigWorkingCopy.java
@@ -0,0 +1,490 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.model.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.builder.model.ICBuildConfig;
+import org.eclipse.cdt.core.builder.model.ICBuildConfigWorkingCopy;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.core.DebugCoreMessages;
+
+/**
+ * @author sam.robb
+ */
+public class CBuildConfigWorkingCopy extends CBuildConfig implements ICBuildConfigWorkingCopy {
+
+ /**
+ * Handle of original launch configuration this
+ * working copy is based on
+ */
+ private CBuildConfig fOriginal;
+
+ /**
+ * Working copy of attributes.
+ */
+ private CBuildConfigInfo fInfo;
+
+ /**
+ * Whether this working copy has been modified since
+ * it was created
+ */
+ private boolean fDirty = false;
+
+ /**
+ * The name for this configuration.
+ */
+ private String fName;
+
+ /**
+ * Indicates whether this working copy has been explicitly renamed.
+ */
+ private boolean fRenamed = false;
+
+ /**
+ * Suppress change notification until created
+ */
+ private boolean fSuppressChange = true;
+
+ /**
+ * The container this working copy will be
+ * stored in when saved.
+ */
+ private IContainer fContainer;
+
+ /**
+ * Constructs a working copy of the specified launch
+ * configuration.
+ *
+ * @param original launch configuration to make
+ * a working copy of
+ * @exception CoreException if unable to initialize this
+ * working copy's attributes based on the original configuration
+ */
+ protected CBuildConfigWorkingCopy(CBuildConfig original) throws CoreException {
+ super(original.getLocation());
+ setName(original.getName());
+ copyFrom(original);
+ setOriginal(original);
+ fSuppressChange = false;
+ }
+
+ /**
+ * Constructs a copy of the specified launch
+ * configuration, with the given (new) name.
+ *
+ * @param original launch configuration to make
+ * a working copy of
+ * @param name the new name for the copy of the launch
+ * configuration
+ * @exception CoreException if unable to initialize this
+ * working copy's attributes based on the original configuration
+ */
+ protected CBuildConfigWorkingCopy(CBuildConfig original, String name) throws CoreException {
+ super(original.getLocation());
+ copyFrom(original);
+ setName(name);
+ fSuppressChange = false;
+ }
+
+ /**
+ * Constructs a new working copy to be created in the specified
+ * location.
+ *
+ * @param container the container that the configuration will be created in
+ * or <code>null</code> if to be local
+ * @param name the name of the new launch configuration
+ * @param type the type of this working copy
+ */
+ protected CBuildConfigWorkingCopy(IContainer container, String name) {
+ super((IPath)null);
+ setName(name);
+ setInfo(new CBuildConfigInfo());
+ setContainer(container);
+ fSuppressChange = false;
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#isDirty()
+ */
+ public boolean isDirty() {
+ return fDirty;
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#doSave()
+ */
+ public ICBuildConfig doSave() throws CoreException {
+ if (isDirty()) {
+ IWorkspaceRunnable wr = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor pm) throws CoreException {
+ // write the new file
+ CBuildConfigWorkingCopy.this.writeNewFile();
+ // delete the old file if this is not a new configuration
+ // or the file was renamed/moved
+ if (!CBuildConfigWorkingCopy.this.isNew()) {
+ if (CBuildConfigWorkingCopy.this.isMoved()) {
+ CBuildConfigWorkingCopy.this.getOriginal().delete();
+ }
+ }
+ resetDirty();
+ }
+ };
+
+ ResourcesPlugin.getWorkspace().run(wr, null);
+ }
+
+ return new CBuildConfig(getLocation());
+ }
+
+ /**
+ * Writes the new configuration information to a file.
+ *
+ * @exception CoreException if writing the file fails
+ */
+ protected void writeNewFile() throws CoreException {
+ String xml = null;
+ try {
+ xml = getInfo().getAsXML();
+ } catch (IOException e) {
+ throw new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("CBuildConfigWorkingCopy.{0}_occurred_generating_launch_configuration_XML._1"), new String[]{e.toString()}), null //$NON-NLS-1$
+ )
+ );
+ }
+
+ if (isLocal()) {
+ // use java.io to update configuration file
+ try {
+ boolean added = false;
+ File file = getLocation().toFile();
+ File dir = getLocation().removeLastSegments(1).toFile();
+ dir.mkdirs();
+ if (!file.exists()) {
+ added = true;
+ file.createNewFile();
+ }
+ FileOutputStream stream = new FileOutputStream(file);
+ stream.write(xml.getBytes("UTF8")); //$NON-NLS-1$
+ stream.close();
+ if (added) {
+ getBuildConfigurationManager().configurationAdded(new CBuildConfig(getLocation()));
+ } else {
+ getBuildConfigurationManager().configurationChanged(new CBuildConfig(getLocation()));
+ }
+ } catch (IOException e) {
+ throw new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("CBuildConfigWorkingCopy.{0}_occurred_generating_launch_configuration_XML._1"), new String[]{e.toString()}), null //$NON-NLS-1$
+ )
+ );
+ }
+ } else {
+ // use resource API to update configuration file
+ IFile file = getFile();
+ IContainer dir = file.getParent();
+ if (!dir.exists()) {
+ throw new DebugException(
+ new Status(
+ Status.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.REQUEST_FAILED, DebugCoreMessages.getString("CBuildConfigWorkingCopy.Specified_container_for_launch_configuration_does_not_exist_2"), null //$NON-NLS-1$
+ )
+ );
+ }
+ ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes());
+ if (!file.exists()) {
+ file.create(stream, false, null);
+ //getLaunchManager().CBuildConfigurationAdded(new CBuildConfig(getLocation()));
+ } else {
+ file.setContents(stream, false, false, null);
+ //getLaunchManager().CBuildConfigurationChanged(new CBuildConfig(getLocation()));
+ }
+ }
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#setAttribute(String, int)
+ */
+ public void setAttribute(String attributeName, int value) {
+ getInfo().setAttribute(attributeName, new Integer(value));
+ setDirty();
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#setAttribute(String, String)
+ */
+ public void setAttribute(String attributeName, String value) {
+ getInfo().setAttribute(attributeName, value);
+ setDirty();
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#setAttribute(String, boolean)
+ */
+ public void setAttribute(String attributeName, boolean value) {
+ getInfo().setAttribute(attributeName, new Boolean(value));
+ setDirty();
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#setAttribute(String, List)
+ */
+ public void setAttribute(String attributeName, List value) {
+ getInfo().setAttribute(attributeName, value);
+ setDirty();
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#setAttribute(String, Map)
+ */
+ public void setAttribute(String attributeName, Map value) {
+ getInfo().setAttribute(attributeName, value);
+ setDirty();
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#getOriginal()
+ */
+ public ICBuildConfig getOriginal() {
+ return fOriginal;
+ }
+
+ /**
+ * Sets the launch configuration this working copy
+ * is based on. Initializes the attributes of this
+ * working copy to the current values of the given
+ * configuration.
+ *
+ * @param originl the launch configuration this working
+ * copy is based on.
+ * @exception CoreException if unable to initialize this
+ * working copy based on the original's current attribute
+ * set
+ */
+ private void copyFrom(CBuildConfig original) throws CoreException {
+ CBuildConfigInfo info = original.getInfo();
+ setInfo(info.getCopy());
+ setContainer(original.getContainer());
+ resetDirty();
+ }
+
+ /**
+ * Sets the launch configuration this working copy
+ * is based on.
+ *
+ * @param originl the launch configuration this working
+ * copy is based on.
+ */
+ private void setOriginal(CBuildConfig original) {
+ fOriginal = original;
+ }
+
+ /**
+ * Sets the working copy info object for this working copy.
+ *
+ * @param info a copy of attributes from this working copy's
+ * original launch configuration
+ */
+ protected void setInfo(CBuildConfigInfo info) {
+ fInfo = info;
+ }
+
+ /**
+ * @see ICBuildConfig#isWorkingCopy()
+ */
+ public boolean isWorkingCopy() {
+ return true;
+ }
+
+ /**
+ * A working copy keeps a local info object that is not
+ * cached with the launch manager.
+ *
+ * @see CBuildConfig#getInfo()
+ */
+ protected CBuildConfigInfo getInfo() {
+ return fInfo;
+ }
+
+ /**
+ * Sets this working copy's state to dirty.
+ * Notifies listeners that this working copy has
+ * changed.
+ */
+ private void setDirty() {
+ fDirty = true;
+ if (!suppressChangeNotification()) {
+ getBuildConfigurationManager().configurationChanged(this);
+ }
+ }
+
+ /**
+ * Sets this working copy's state to not dirty.
+ */
+ private void resetDirty() {
+ fDirty = false;
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#rename(String)
+ */
+ public void rename(String name) {
+ if (!getName().equals(name)) {
+ setName(name);
+ fRenamed = isNew() || !(getOriginal().getName().equals(name));
+ }
+ }
+
+ /**
+ * Sets the new name for this configuration.
+ *
+ * @param name the new name for this configuration
+ */
+ private void setName(String name) {
+ fName = name;
+ setDirty();
+ }
+
+ /**
+ * @see ICBuildConfig#getName()
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * @see ICBuildConfig#isLocal()
+ */
+ public boolean isLocal() {
+ return getContainer() == null;
+ }
+
+ /**
+ * Returns the location this launch configuration will reside at
+ * when saved.
+ *
+ * @see ICBuildConfig#getLocation()
+ */
+ public IPath getLocation() {
+ if (isMoved()) {
+ IPath path = getContainer().getLocation();
+ path = path.append(getName() + "." + BUILD_CONFIGURATION_FILE_EXTENSION); //$NON-NLS-1$
+ return path;
+ } else {
+ return getOriginal().getLocation();
+ }
+ }
+
+ /**
+ * Returns whether this working copy is new, or is a
+ * working copy of another launch configuration.
+ *
+ * @return whether this working copy is new, or is a
+ * working copy of another launch configuration
+ */
+ protected boolean isNew() {
+ return getOriginal() == null;
+ }
+
+ /**
+ * Returns whether this working copy is new or if its
+ * location has changed from that of its original.
+ *
+ * @return whether this working copy is new or if its
+ * location has changed from that of its original
+ */
+ protected boolean isMoved() {
+ if (isNew() || fRenamed) {
+ return true;
+ }
+ IContainer newContainer = getContainer();
+ IContainer originalContainer = ((CBuildConfig)getOriginal()).getContainer();
+ if (newContainer == originalContainer) {
+ return false;
+ }
+ if (newContainer == null) {
+ return !originalContainer.equals(newContainer);
+ } else {
+ return !newContainer.equals(originalContainer);
+ }
+ }
+
+ /**
+ * A working copy cannot generate a memento.
+ *
+ * @see ICBuildConfig#getMemento()
+ */
+ public String getMemento() {
+ return null;
+ }
+
+ /**
+ * Returns whether change notification should be
+ * suppressed
+ */
+ protected boolean suppressChangeNotification() {
+ return fSuppressChange;
+ }
+
+ /**
+ * @see ICBuildConfigWorkingCopy#setContainer(IContainer)
+ */
+ public void setContainer(IContainer container) {
+ if (container == fContainer) {
+ return;
+ }
+ if (container != null) {
+ if (container.equals(fContainer)) {
+ return;
+ }
+ } else {
+ if (fContainer.equals(container)) {
+ return;
+ }
+ }
+ fContainer = container;
+ setDirty();
+ }
+
+ /**
+ * Returns the container this working copy will be
+ * stored in when saved, or <code>null</code> if
+ * this working copy is local.
+ *
+ * @return the container this working copy will be
+ * stored in when saved, or <code>null</code> if
+ * this working copy is local
+ */
+ protected IContainer getContainer() {
+ return fContainer;
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CCygwinFilesystem.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CCygwinFilesystem.java
new file mode 100644
index 0000000000..60d0aa444e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CCygwinFilesystem.java
@@ -0,0 +1,125 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.cdt.internal.core.ProcessClosure;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+
+/**
+ * Performs file path translation on a Windows + Cygwin system.
+ * <p>
+ * This allows for translation between "native" Windows path
+ * names and Cygwin style path names.
+ */
+public class CCygwinFilesystem implements IFilesystem {
+
+ private static String CONVERT_CMD = "cygpath"; //$NON-NLS-1$
+ private static String CONVERT_TO_UNIX = "-u"; //$NON-NLS-1$
+ private static String CONVERT_TO_NATIVE = "-w"; //$NON-NLS-1$
+
+ private String fHome;
+
+ public CCygwinFilesystem() {
+ super();
+ fHome =
+ getNativePath(IFilesystem.FILESYSTEM_ROOT)
+ + IFilesystem.FILESYSTEM_ROOT;
+ }
+
+ /**
+ * Helper function for converting native (Windows) paths to Unix paths,
+ * and vice versa.
+ *
+ * @param path the path to covert.
+ * @param cmdFlags how to convert the path. Supported values for are
+ * CONVERT_TO_UNIX and CONVERT_TO_NATIVE.
+ */
+ private String convertPath(String path, String cmdFlags) {
+
+ ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+ ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+ String[] cmds = { CONVERT_CMD, cmdFlags, path };
+ String newPath = path;
+
+ // In the event that cygpath is not found, or fails for some reason,
+ // this function will return a Cygwinized/Javaized version of the
+ // path (ex, "C:\foo\bar" will become "C:/foo/bar").
+
+ try {
+ ProcessFactory pf = ProcessFactory.getFactory();
+ Process pid = pf.exec(cmds);
+ ProcessClosure pc = new ProcessClosure(pid, stdout, stderr);
+
+ pc.runBlocking();
+
+ newPath = stdout.toString().trim();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return newPath.replace(PATHSEP_WINDOWS, PATHSEP_CYGWIN);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getRoot()
+ */
+ public String getRoot() {
+ return fHome;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getNativePath(String)
+ */
+ public String getNativePath(String path) {
+ return convertPath(path, CONVERT_TO_NATIVE);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getNativePath(File)
+ */
+ public String getNativePath(File path) {
+ return getNativePath(path.toString());
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getUnixPath(String)
+ */
+ public String getUnixPath(String path) {
+
+ path = convertPath(path, CONVERT_TO_UNIX);
+
+ // Make sure there are no spaces in the path and if there are, escape them.
+ String subString = new String(""); //$NON-NLS-1$
+ int len = 0;
+ int begin = 0;
+ while ((len = path.indexOf(" ")) >= 0) { //$NON-NLS-1$
+ subString += path.substring(begin, len);
+ subString += "\\ "; //$NON-NLS-1$
+ path = path.substring(len + 1);
+ }
+ subString += path;
+
+ return subString;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getUnixPath(File)
+ */
+ public String getUnixPath(File path) {
+ return getUnixPath(path.toString());
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CUnixFilesystem.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CUnixFilesystem.java
new file mode 100644
index 0000000000..c0616b0ee9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CUnixFilesystem.java
@@ -0,0 +1,58 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.util;
+
+import java.io.File;
+
+/**
+ * Performs file path translation on a Unix system.
+ * <p>
+ * This is essentially uninteresting, as the whole purpose of the filesystem
+ * abstraction is to provide for some minimal support for Unix-y file paths
+ * under Windows + Cygwin.
+ */
+public class CUnixFilesystem implements IFilesystem {
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getRoot()
+ */
+ public String getRoot() {
+ return IFilesystem.FILESYSTEM_ROOT;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getNativePath(String)
+ */
+ public String getNativePath(String path) {
+ return new String(path);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getNativePath(File)
+ */
+ public String getNativePath(File path) {
+ return path.toString();
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getUnixPath(String)
+ */
+ public String getUnixPath(String path) {
+ return new String(path);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getUnixPath(File)
+ */
+ public String getUnixPath(File path) {
+ return path.toString();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CUtil.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CUtil.java
new file mode 100644
index 0000000000..f1eef587b9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/CUtil.java
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.util;
+
+/**
+ * @author sam.robb
+ *
+ * Collection of generic utility functions.
+ */
+public class CUtil {
+
+ /**
+ * Given a name, this function will decide whether the
+ * name conforms to rules for naming valid C identifiers.
+ */
+ public static boolean isValidCIdentifier(String name) {
+
+ // any sequence of letters, digits, or underscores,
+ // which begins with a letter or underscore
+
+ if ((name == null) || (name.length() < 1)) {
+ return false;
+ }
+
+ char c = name.charAt(0);
+
+ if ((c != '_') && !Character.isLetter(c)) {
+ return false;
+ }
+
+ for (int i = 1; i < name.length(); i++) {
+ c = name.charAt(i);
+ if ((c != '_') && !Character.isLetterOrDigit(c)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/Filesystem.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/Filesystem.java
new file mode 100644
index 0000000000..764ba0004a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/Filesystem.java
@@ -0,0 +1,161 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+import org.eclipse.core.internal.runtime.Assert;
+
+/**
+ * Singleton that wraps the concept of the current OS's
+ * filesystem in a way that allows us to work properly
+ * under Cygwin.
+ */
+public class Filesystem {
+
+ private static IFilesystem fInstance;
+
+ /**
+ * Create the IFilesystem instance appropriate for the current OS.
+ *
+ * Right now, this is based off of the speratorChar reported by
+ * java.io.File; there is probably a better way to deal with this.
+ */
+ static {
+ // init to null, update with class reference if we can
+ // otherwise leave null to signal that we don't have a valid file system.
+ if (File.separatorChar == IFilesystem.FILESYSTEM_ROOT.charAt(0)) {
+ fInstance = new CUnixFilesystem();
+ } else {
+ fInstance = new CCygwinFilesystem();
+ }
+ }
+
+ private static IFilesystem getInstance() {
+ if (fInstance == null) {
+ throw new FileSystemException ("Problems encountered while searching for your file system.");
+ }
+ return fInstance;
+ }
+
+ public static boolean isValid() {
+ return (fInstance != null);
+ }
+
+ public static class FileSystemException extends Error {
+ FileSystemException (String s) {
+ super(s);
+ }
+ }
+
+ /**
+ * Private constructor to prevent instatiation.
+ *
+ * All members of this class are static, and intended to be accessed
+ * via "Filesystem.[method_name]".
+ */
+ private Filesystem() {
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getRoot()
+ */
+ public static String getRoot() {
+ return getInstance().getRoot();
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getNativePath(String)
+ */
+ public static String getNativePath(String path) {
+ return getInstance().getNativePath(path);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getNativePath(File)
+ */
+ public static String getNativePath(File path) {
+ return getInstance().getNativePath(path);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getUnixPath(String)
+ */
+ public static String getUnixPath(String path) {
+ return getInstance().getUnixPath(path);
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.builder.util.IFilesystem#getUnixPath(File)
+ */
+ public static String getUnixPath(File path) {
+ return getInstance().getUnixPath(path);
+ }
+
+ /**
+ * Copy a file from sourceFile to destFile. Performs a binary file copy,
+ * reading data from sourceFile as a byte stream, and writing it to destFile
+ * as a byte stream.
+ *
+ * @param sourceFile File to copy.
+ * @param destFile Where to copy the file to.
+ * @param replaceIfExists If true, if destFile exists, it is replaced.
+ * @return True if the file was copied; false otherwise.
+ */
+ public static boolean copyFile(File sourceFile, File destFile, boolean replaceIfExists) {
+ Assert.isNotNull(sourceFile);
+ Assert.isNotNull(destFile);
+
+ if (!sourceFile.exists()) {
+ return false;
+ }
+
+ if (sourceFile.equals(destFile)) {
+ return false;
+ }
+
+ if (replaceIfExists && destFile.exists()) {
+ destFile.delete();
+ }
+
+ if (destFile.exists()) {
+ return false;
+ }
+
+ FileInputStream fis = null;
+ FileOutputStream fos = null;
+ byte[] buf = new byte[1024];
+ int i = 0;
+
+ try {
+ fis = new FileInputStream(sourceFile);
+ fos = new FileOutputStream(destFile);
+
+ while(-1 != (i = fis.read(buf))) {
+ fos.write(buf, 0, i);
+ }
+
+ fos.close();
+ fis.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (destFile.exists()) {
+ destFile.delete();
+ }
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/IFilesystem.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/IFilesystem.java
new file mode 100644
index 0000000000..476add3c7a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/builder/util/IFilesystem.java
@@ -0,0 +1,66 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Timesys 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:
+ * Timesys - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.core.builder.util;
+
+import java.io.File;
+
+/**
+ * Abstracts information about a filesystem in order to allow
+ * translation between native/unix pathnames.
+ */
+public interface IFilesystem {
+
+ public static String FILESYSTEM_ROOT = "/"; //$NON-NLS-1$
+ public static char PATHSEP_WINDOWS = '\\'; //$NON-NLS-1$
+ public static char PATHSEP_CYGWIN = '\\'; //$NON-NLS-1$
+
+ /**
+ * Get the root directory for the filesystem.
+ *
+ * The root directory is returned in native filesystem format
+ * (ex, "C:/cygwin/" on Windows, "/" on Unix.) The returned
+ * string is guaranteed to have a trailing path seperator.
+ */
+ public String getRoot();
+
+ /**
+ * Convert the provided path into a native path.
+ *
+ * @param path path to convert.
+ * @return native representation of path.
+ */
+ public String getNativePath(String path);
+
+ /**
+ * Convert the provided path into a native path.
+ *
+ * @param path path to convert.
+ * @return native representation of path.
+ */
+ public String getNativePath(File path);
+
+ /**
+ * Convert the provided path into a unix path.
+ *
+ * @param path path to convert.
+ * @return unix representation of path.
+ */
+ public String getUnixPath(String path);
+
+ /**
+ * Convert the provided path into a unix path.
+ *
+ * @param path path to convert.
+ * @return unix representation of path.
+ */
+ public String getUnixPath(File path);
+}

Back to the top