[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied Patch: Update to new build model
|
Just a few updates to the build model I'm working on
as it matures a bit.
Doug Schaefer
Senior
Staff Software Engineer
Rational Software - IBM Software Group
Ottawa (Kanata), Ontario, Canada
|
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/plugin.xml,v
retrieving revision 1.4
diff -u -r1.4 plugin.xml
--- plugin.xml 7 Apr 2003 02:46:59 -0000 1.4
+++ plugin.xml 7 Apr 2003 20:49:56 -0000
@@ -45,8 +45,8 @@
id="linux.compiler.flags">
</option>
<option
- default="-O"
name="Optimization Flags"
+ default="-O"
type="string"
category="linux.compiler.optimization"
id="linux.compiler.optimizationFlags">
@@ -62,6 +62,14 @@
name="Linker"
id="org.eclipse.cdt.ui.tests.tool.linux.link">
</tool>
+ <configuration
+ name="Release"
+ id="linux.exec.release">
+ </configuration>
+ <configuration
+ name="Debug"
+ id="linux.exec.debug">
+ </configuration>
</target>
<target
name="Linux Shared Library"
Index: build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java,v
retrieving revision 1.1
diff -u -r1.1 AllBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java 7 Apr 2003 02:46:59 -0000 1.1
+++ build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java 7 Apr 2003 20:49:56 -0000
@@ -45,8 +45,8 @@
*/
public void testExtensions() {
// Note secret null parameter which means just extensions
- ITarget[] targets = ManagedBuildManager.getAvailableTargets(null);
-
+ ITarget[] targets = ManagedBuildManager.getTargets(null);
+
ITarget target = targets[0];
assertEquals(target.getName(), "Linux");
ITool[] tools = target.getTools();
Index: build/org/eclipse/cdt/core/build/managed/IConfiguration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IConfiguration.java,v
retrieving revision 1.1
diff -u -r1.1 IConfiguration.java
--- build/org/eclipse/cdt/core/build/managed/IConfiguration.java 7 Apr 2003 02:47:01 -0000 1.1
+++ build/org/eclipse/cdt/core/build/managed/IConfiguration.java 7 Apr 2003 20:49:08 -0000
@@ -10,6 +10,8 @@
**********************************************************************/
package org.eclipse.cdt.core.build.managed;
+import org.eclipse.core.resources.IProject;
+
/**
*
*/
@@ -27,6 +29,13 @@
* @return
*/
public ITarget getTarget();
+
+ /**
+ * Returns the project owning this configuration
+ * or null if this configuration is not associated with a project.
+ * @return
+ */
+ public IProject getProject();
/**
* Returns the configuration from which this configuration inherits
Index: build/org/eclipse/cdt/core/build/managed/IOption.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IOption.java,v
retrieving revision 1.1
diff -u -r1.1 IOption.java
--- build/org/eclipse/cdt/core/build/managed/IOption.java 7 Apr 2003 02:47:01 -0000 1.1
+++ build/org/eclipse/cdt/core/build/managed/IOption.java 7 Apr 2003 20:49:08 -0000
@@ -20,7 +20,15 @@
public static final int STRING_LIST = 1;
/**
+ * Returns the tool defining this option.
+ *
+ * @return
+ */
+ public ITool getTool();
+
+ /**
* Returns the category for this option.
+ *
* @return
*/
public IOptionCategory getCategory();
@@ -62,4 +70,24 @@
*/
public String [] getStringListValue();
+ /**
+ * Sets the value for this option in a given configuration.
+ * A new instance of the option for the configuration may be created.
+ * The appropriate new option is returned.
+ *
+ * @param config
+ * @param value
+ */
+ public IOption setStringValue(IConfiguration config, String value);
+
+ /**
+ * Sets the value for this option in a given configuration.
+ * A new instance of the option for the configuration may be created.
+ * The appropriate new option is returned.
+ *
+ * @param config
+ * @param value
+ */
+ public IOption setStringValue(IConfiguration config, String[] value);
+
}
Index: build/org/eclipse/cdt/core/build/managed/ITarget.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java,v
retrieving revision 1.1
diff -u -r1.1 ITarget.java
--- build/org/eclipse/cdt/core/build/managed/ITarget.java 7 Apr 2003 02:47:01 -0000 1.1
+++ build/org/eclipse/cdt/core/build/managed/ITarget.java 7 Apr 2003 20:49:08 -0000
@@ -10,6 +10,8 @@
**********************************************************************/
package org.eclipse.cdt.core.build.managed;
+import org.eclipse.core.resources.IProject;
+
/**
* This class represents targets for the managed build process. A target
* is some type of resource built using a given collection of tools.
@@ -37,5 +39,11 @@
* @return
*/
public ITool[] getTools();
+
+ /**
+ * Returns all of the configurations defined by this target.
+ * @return
+ */
+ public IConfiguration[] getAvailableConfigurations(IProject project);
}
Index: build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java,v
retrieving revision 1.1
diff -u -r1.1 ManagedBuildManager.java
--- build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java 7 Apr 2003 02:47:01 -0000 1.1
+++ build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java 7 Apr 2003 20:49:08 -0000
@@ -14,13 +14,17 @@
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.internal.core.build.managed.Configuration;
import org.eclipse.cdt.internal.core.build.managed.Target;
import org.eclipse.cdt.internal.core.build.managed.Tool;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.QualifiedName;
/**
* This is the main entry point for getting at the build information
@@ -28,20 +32,23 @@
*/
public class ManagedBuildManager {
+ private static final QualifiedName configProperty
+ = new QualifiedName(CCorePlugin.PLUGIN_ID, "config");
+
/**
- * Returns the list of platforms that are available to be used in
- * conjunction with the given resource. Generally this will include
- * platforms defined by extensions as well as platforms defined by
+ * Returns the list of targets that are available to be used in
+ * conjunction with the given project. Generally this will include
+ * targets defined by extensions as well as targets defined by
* the project and all projects this project reference.
*
* @param project
* @return
*/
- public static ITarget[] getAvailableTargets(IProject project) {
+ public static ITarget[] getTargets(IProject project) {
// Make sure the extensions are loaded
loadExtensions();
- // Get the platforms for this project and all referenced projects
+ // Get the targets for this project and all referenced projects
// Create the array and copy the elements over
ITarget[] targets = new ITarget[extensionTargets.size()];
@@ -53,26 +60,13 @@
}
/**
- * Returns the list of configurations belonging to the given platform
- * that can be applied to the given project. This does not include
- * the configurations already applied to the project.
- *
- * @param resource
- * @param platform
- * @return
- */
- public static IConfiguration [] getAvailableConfigurations(IProject project, ITarget platform) {
- return null;
- }
-
- /**
* Returns the list of configurations associated with the given project.
*
* @param project
* @return
*/
- public static IConfiguration [] getConfigurations(IProject project) {
- return null;
+ public static IConfiguration[] getConfigurations(IProject project) {
+ return getResourceConfigs(project);
}
/**
@@ -82,53 +76,40 @@
* @return
*/
public static IConfiguration[] getConfigurations(IFile file) {
- return null;
+ // TODO not ready for prime time...
+ return getResourceConfigs(file);
}
-
+
/**
- * Creates a configuration containing the tools defined by the target.
+ * Adds a configuration containing the tools defined by the target to
+ * the given project.
*
* @param target
* @param project
* @return
*/
- public static IConfiguration createConfiguration(IProject project, ITarget target) {
+ public static IConfiguration addConfiguration(IProject project, ITarget target) {
+ Configuration config = new Configuration(project, target);
return null;
}
-
+
/**
- * Creates a configuration that inherits from the parent configuration.
- *
+ * Adds a configuration inheriting from the given configuration.
+ *
* @param origConfig
* @param resource
* @return
*/
- public static IConfiguration createConfiguration(IProject project, IConfiguration parentConfig) {
- return null;
+ public static IConfiguration addConfiguration(IProject project, IConfiguration parentConfig) {
+ if (parentConfig.getProject() != null)
+ // Can only inherit from target configs
+ return null;
+
+ Configuration config = new Configuration(project, parentConfig);
+ addResourceConfig(project, config);
+ return config;
}
- /**
- * Sets the String value for an option.
- *
- * @param project
- * @param config
- * @param option
- * @param value
- */
- public static void setOptionValue(IProject project, IConfiguration config, IOption option, String value) {
- }
-
- /**
- * Sets the String List value for an option.
- *
- * @param project
- * @param config
- * @param option
- * @param value
- */
- public static void setOptionValue(IProject project, IConfiguration config, IOption option, String[] value) {
- }
-
// Private stuff
private static List extensionTargets;
@@ -151,15 +132,56 @@
Target target = new Target(element.getAttribute("name"));
extensionTargets.add(target);
+ List configs = null;
IConfigurationElement[] targetElements = element.getChildren();
for (int k = 0; k < targetElements.length; ++k) {
- IConfigurationElement platformElement = targetElements[k];
- if (platformElement.getName().equals("tool")) {
- Tool tool = new Tool(platformElement.getAttribute("name"), target);
+ IConfigurationElement targetElement = targetElements[k];
+ if (targetElement.getName().equals("tool")) {
+ Tool tool = new Tool(targetElement.getAttribute("name"), target);
+ } else if (targetElement.getName().equals("configuration")) {
+ if (configs == null)
+ configs = new ArrayList();
+ configs.add(new Configuration(target));
}
}
+
+ if (configs != null) {
+ IConfiguration[] configArray = new IConfiguration[configs.size()];
+ configArray = (IConfiguration[])configs.toArray(configArray);
+ target.setConfigurations(configArray);
+ }
}
}
}
}
+
+ private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
+
+ private static IConfiguration[] getResourceConfigs(IResource resource) {
+ IConfiguration[] configs = null;
+
+ try {
+ configs = (IConfiguration[])resource.getSessionProperty(configProperty);
+ } catch (CoreException e) {
+ }
+
+ return (configs != null) ? configs : emptyConfigs;
+ }
+
+ private static void addResourceConfig(IResource resource, IConfiguration config) {
+ IConfiguration[] configs = getResourceConfigs(resource);
+
+ IConfiguration[] newConfigs = new IConfiguration[configs.length + 1];
+ for (int i = 0; i < configs.length; ++i)
+ newConfigs[i] = configs[i];
+ newConfigs[configs.length] = config;
+
+ try {
+ resource.setSessionProperty(configProperty, newConfigs);
+ } catch (CoreException e) {
+ }
+
+ // TODO save the config info to the project build file
+ }
+
}
Index: build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java,v
retrieving revision 1.1
diff -u -r1.1 Configuration.java
--- build/org/eclipse/cdt/internal/core/build/managed/Configuration.java 7 Apr 2003 02:47:01 -0000 1.1
+++ build/org/eclipse/cdt/internal/core/build/managed/Configuration.java 7 Apr 2003 20:49:09 -0000
@@ -10,9 +10,12 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.build.managed;
+import java.util.List;
+
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.core.resources.IProject;
/**
*
@@ -20,17 +23,30 @@
public class Configuration implements IConfiguration {
private String name;
- private ITarget platform;
+ private ITarget target;
+ private IProject project;
+ private IConfiguration parent;
+ private List toolReference;
- public Configuration(ITarget platform) {
- this.platform = platform;
+ public Configuration(Target target) {
+ this.target = target;
+ }
+
+ public Configuration(IProject project, ITarget target) {
+ this.project = project;
+ this.target = target;
}
+ public Configuration(IProject project, IConfiguration parent) {
+ this.project = project;
+ this.parent = parent;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
*/
public String getName() {
- return name;
+ return (name == null && parent != null) ? parent.getName() : name;
}
/* (non-Javadoc)
@@ -41,13 +57,6 @@
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getPlatform()
- */
- public ITarget getPlatform() {
- return platform;
- }
-
- /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
*/
public ITool[] getTools() {
@@ -59,16 +68,21 @@
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
*/
public IConfiguration getParent() {
- // TODO Auto-generated method stub
- return null;
+ return parent;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTarget()
*/
public ITarget getTarget() {
- // TODO Auto-generated method stub
- return null;
+ return (target == null && parent != null) ? parent.getTarget() : target;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getProject()
+ */
+ public IProject getProject() {
+ return (project == null && parent != null) ? parent.getProject() : project;
}
}
Index: build/org/eclipse/cdt/internal/core/build/managed/Option.java
===================================================================
RCS file: build/org/eclipse/cdt/internal/core/build/managed/Option.java
diff -N build/org/eclipse/cdt/internal/core/build/managed/Option.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/internal/core/build/managed/Option.java 7 Apr 2003 20:49:09 -0000
@@ -0,0 +1,18 @@
+/**********************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.core.build.managed;
+
+/**
+ *
+ */
+public class Option {
+
+}
Index: build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
===================================================================
RCS file: build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
diff -N build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/internal/core/build/managed/OptionCategory.java 7 Apr 2003 20:49:09 -0000
@@ -0,0 +1,18 @@
+/**********************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.core.build.managed;
+
+/**
+ *
+ */
+public class OptionCategory {
+
+}
Index: build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
===================================================================
RCS file: build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
diff -N build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java 7 Apr 2003 20:49:09 -0000
@@ -0,0 +1,18 @@
+/**********************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.core.build.managed;
+
+/**
+ *
+ */
+public class OptionReference {
+
+}
Index: build/org/eclipse/cdt/internal/core/build/managed/Target.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java,v
retrieving revision 1.1
diff -u -r1.1 Target.java
--- build/org/eclipse/cdt/internal/core/build/managed/Target.java 7 Apr 2003 02:47:01 -0000 1.1
+++ build/org/eclipse/cdt/internal/core/build/managed/Target.java 7 Apr 2003 20:49:09 -0000
@@ -10,11 +10,10 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.build.managed;
-import java.util.ArrayList;
-import java.util.List;
-
+import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.core.resources.IProject;
/**
*
@@ -23,7 +22,8 @@
private String name;
private Target parent;
- private List tools;
+ private ITool[] tools;
+ private IConfiguration[] configurations;
public Target(String name) {
this.name = name;
@@ -47,7 +47,7 @@
}
private int getNumTools() {
- int n = (tools == null) ? 0 : tools.size();
+ int n = (tools == null) ? 0 : tools.length;
if (parent != null)
n += parent.getNumTools();
return n;
@@ -59,22 +59,30 @@
n = parent.addToolsToArray(toolArray, start);
if (tools != null) {
- for (int i = 0; i < tools.size(); ++i)
- toolArray[n++] = (ITool)tools.get(i);
+ for (int i = 0; i < tools.length; ++i)
+ toolArray[n++] = (ITool)tools[i];
}
return n;
}
+
public ITool[] getTools() {
ITool[] toolArray = new ITool[getNumTools()];
addToolsToArray(toolArray, 0);
return toolArray;
}
+
+ public void setTools(ITool[] tools) {
+ this.tools = tools;
+ }
+
+ public void setConfigurations(IConfiguration [] configurations) {
+ this.configurations = configurations;
+ }
- public void addTool(Tool tool) {
- if (tools == null)
- tools = new ArrayList();
- tools.add(tool);
+ public IConfiguration[] getAvailableConfigurations(IProject project) {
+ // TODO Auto-generated method stub
+ return null;
}
}
Index: build/org/eclipse/cdt/internal/core/build/managed/Tool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java,v
retrieving revision 1.1
diff -u -r1.1 Tool.java
--- build/org/eclipse/cdt/internal/core/build/managed/Tool.java 7 Apr 2003 02:47:01 -0000 1.1
+++ build/org/eclipse/cdt/internal/core/build/managed/Tool.java 7 Apr 2003 20:49:09 -0000
@@ -30,7 +30,6 @@
public Tool(String name, Target target) {
this(name);
this.target = target;
- target.addTool(this);
}
public String getName() {
Index: build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
===================================================================
RCS file: build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
diff -N build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java 7 Apr 2003 20:49:09 -0000
@@ -0,0 +1,18 @@
+/**********************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.core.build.managed;
+
+/**
+ *
+ */
+public class ToolReference {
+
+}
Index: schema/ManagedBuildTools.exsd
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/schema/ManagedBuildTools.exsd,v
retrieving revision 1.1
diff -u -r1.1 ManagedBuildTools.exsd
--- schema/ManagedBuildTools.exsd 7 Apr 2003 02:47:01 -0000 1.1
+++ schema/ManagedBuildTools.exsd 7 Apr 2003 20:49:10 -0000
@@ -177,13 +177,6 @@
</documentation>
</annotation>
</attribute>
- <attribute name="platform" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
</complexType>
</element>
@@ -224,12 +217,13 @@
<element name="target">
<annotation>
<documentation>
- Represents a type of resource that is the target of the build process, for example, a Linux Library. A target contains a sequence of tool definitions. Targets are arranged in an inheritance hierarchy where a target inherits the list of tools from it's parent and can add to or override tools in this list.
+ Represents a type of resource that is the target of the build process, for example, a Linux Library. A target contains a sequence of tool definitions and configurations. Targets are arranged in an inheritance hierarchy where a target inherits the list of tools from it's parent and can add to or override tools in this list.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="tool"/>
+ <element ref="configuration"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>