1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Updates to the new build model.

This commit is contained in:
Doug Schaefer 2003-04-07 20:56:27 +00:00
parent c936206685
commit e7a699b56c
14 changed files with 256 additions and 94 deletions

View file

@ -10,6 +10,8 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.core.build.managed; package org.eclipse.cdt.core.build.managed;
import org.eclipse.core.resources.IProject;
/** /**
* *
*/ */
@ -28,6 +30,13 @@ public interface IConfiguration {
*/ */
public ITarget getTarget(); 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 * Returns the configuration from which this configuration inherits
* properties. * properties.

View file

@ -19,8 +19,16 @@ public interface IOption {
public static final int STRING = 0; public static final int STRING = 0;
public static final int STRING_LIST = 1; public static final int STRING_LIST = 1;
/**
* Returns the tool defining this option.
*
* @return
*/
public ITool getTool();
/** /**
* Returns the category for this option. * Returns the category for this option.
*
* @return * @return
*/ */
public IOptionCategory getCategory(); public IOptionCategory getCategory();
@ -62,4 +70,24 @@ public interface IOption {
*/ */
public String [] getStringListValue(); 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);
} }

View file

@ -10,6 +10,8 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.core.build.managed; package org.eclipse.cdt.core.build.managed;
import org.eclipse.core.resources.IProject;
/** /**
* This class represents targets for the managed build process. A target * This class represents targets for the managed build process. A target
* is some type of resource built using a given collection of tools. * is some type of resource built using a given collection of tools.
@ -38,4 +40,10 @@ public interface ITarget {
*/ */
public ITool[] getTools(); public ITool[] getTools();
/**
* Returns all of the configurations defined by this target.
* @return
*/
public IConfiguration[] getAvailableConfigurations(IProject project);
} }

View file

@ -14,13 +14,17 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; 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.Target;
import org.eclipse.cdt.internal.core.build.managed.Tool; import org.eclipse.cdt.internal.core.build.managed.Tool;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; 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.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.QualifiedName;
/** /**
* This is the main entry point for getting at the build information * This is the main entry point for getting at the build information
@ -28,20 +32,23 @@ import org.eclipse.core.runtime.IExtensionPoint;
*/ */
public class ManagedBuildManager { 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 * Returns the list of targets that are available to be used in
* conjunction with the given resource. Generally this will include * conjunction with the given project. Generally this will include
* platforms defined by extensions as well as platforms defined by * targets defined by extensions as well as targets defined by
* the project and all projects this project reference. * the project and all projects this project reference.
* *
* @param project * @param project
* @return * @return
*/ */
public static ITarget[] getAvailableTargets(IProject project) { public static ITarget[] getTargets(IProject project) {
// Make sure the extensions are loaded // Make sure the extensions are loaded
loadExtensions(); 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 // Create the array and copy the elements over
ITarget[] targets = new ITarget[extensionTargets.size()]; ITarget[] targets = new ITarget[extensionTargets.size()];
@ -52,27 +59,14 @@ public class ManagedBuildManager {
return targets; return targets;
} }
/**
* 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. * Returns the list of configurations associated with the given project.
* *
* @param project * @param project
* @return * @return
*/ */
public static IConfiguration [] getConfigurations(IProject project) { public static IConfiguration[] getConfigurations(IProject project) {
return null; return getResourceConfigs(project);
} }
/** /**
@ -82,51 +76,38 @@ public class ManagedBuildManager {
* @return * @return
*/ */
public static IConfiguration[] getConfigurations(IFile file) { 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 target
* @param project * @param project
* @return * @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; return null;
} }
/** /**
* Creates a configuration that inherits from the parent configuration. * Adds a configuration inheriting from the given configuration.
* *
* @param origConfig * @param origConfig
* @param resource * @param resource
* @return * @return
*/ */
public static IConfiguration createConfiguration(IProject project, IConfiguration parentConfig) { public static IConfiguration addConfiguration(IProject project, IConfiguration parentConfig) {
return null; if (parentConfig.getProject() != null)
} // Can only inherit from target configs
return null;
/** Configuration config = new Configuration(project, parentConfig);
* Sets the String value for an option. addResourceConfig(project, config);
* return config;
* @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 stuff
@ -151,15 +132,56 @@ public class ManagedBuildManager {
Target target = new Target(element.getAttribute("name")); Target target = new Target(element.getAttribute("name"));
extensionTargets.add(target); extensionTargets.add(target);
List configs = null;
IConfigurationElement[] targetElements = element.getChildren(); IConfigurationElement[] targetElements = element.getChildren();
for (int k = 0; k < targetElements.length; ++k) { for (int k = 0; k < targetElements.length; ++k) {
IConfigurationElement platformElement = targetElements[k]; IConfigurationElement targetElement = targetElements[k];
if (platformElement.getName().equals("tool")) { if (targetElement.getName().equals("tool")) {
Tool tool = new Tool(platformElement.getAttribute("name"), target); 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
}
} }

View file

@ -10,9 +10,12 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.internal.core.build.managed; 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.IConfiguration;
import org.eclipse.cdt.core.build.managed.ITarget; import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool; import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.core.resources.IProject;
/** /**
* *
@ -20,17 +23,30 @@ import org.eclipse.cdt.core.build.managed.ITool;
public class Configuration implements IConfiguration { public class Configuration implements IConfiguration {
private String name; private String name;
private ITarget platform; private ITarget target;
private IProject project;
private IConfiguration parent;
private List toolReference;
public Configuration(ITarget platform) { public Configuration(Target target) {
this.platform = platform; 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) /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getName() * @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
*/ */
public String getName() { public String getName() {
return name; return (name == null && parent != null) ? parent.getName() : name;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -40,13 +56,6 @@ public class Configuration implements IConfiguration {
this.name = name; this.name = name;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPlatform()
*/
public ITarget getPlatform() {
return platform;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools() * @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
*/ */
@ -59,16 +68,21 @@ public class Configuration implements IConfiguration {
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent() * @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
*/ */
public IConfiguration getParent() { public IConfiguration getParent() {
// TODO Auto-generated method stub return parent;
return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTarget() * @see org.eclipse.cdt.core.build.managed.IConfiguration#getTarget()
*/ */
public ITarget getTarget() { public ITarget getTarget() {
// TODO Auto-generated method stub return (target == null && parent != null) ? parent.getTarget() : target;
return null; }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getProject()
*/
public IProject getProject() {
return (project == null && parent != null) ? parent.getProject() : project;
} }
} }

View file

@ -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 {
}

View file

@ -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 {
}

View file

@ -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 {
}

View file

@ -10,11 +10,10 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.internal.core.build.managed; package org.eclipse.cdt.internal.core.build.managed;
import java.util.ArrayList; import org.eclipse.cdt.core.build.managed.IConfiguration;
import java.util.List;
import org.eclipse.cdt.core.build.managed.ITarget; import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool; import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.core.resources.IProject;
/** /**
* *
@ -23,7 +22,8 @@ public class Target implements ITarget {
private String name; private String name;
private Target parent; private Target parent;
private List tools; private ITool[] tools;
private IConfiguration[] configurations;
public Target(String name) { public Target(String name) {
this.name = name; this.name = name;
@ -47,7 +47,7 @@ public class Target implements ITarget {
} }
private int getNumTools() { private int getNumTools() {
int n = (tools == null) ? 0 : tools.size(); int n = (tools == null) ? 0 : tools.length;
if (parent != null) if (parent != null)
n += parent.getNumTools(); n += parent.getNumTools();
return n; return n;
@ -59,22 +59,30 @@ public class Target implements ITarget {
n = parent.addToolsToArray(toolArray, start); n = parent.addToolsToArray(toolArray, start);
if (tools != null) { if (tools != null) {
for (int i = 0; i < tools.size(); ++i) for (int i = 0; i < tools.length; ++i)
toolArray[n++] = (ITool)tools.get(i); toolArray[n++] = (ITool)tools[i];
} }
return n; return n;
} }
public ITool[] getTools() { public ITool[] getTools() {
ITool[] toolArray = new ITool[getNumTools()]; ITool[] toolArray = new ITool[getNumTools()];
addToolsToArray(toolArray, 0); addToolsToArray(toolArray, 0);
return toolArray; return toolArray;
} }
public void addTool(Tool tool) { public void setTools(ITool[] tools) {
if (tools == null) this.tools = tools;
tools = new ArrayList(); }
tools.add(tool);
public void setConfigurations(IConfiguration [] configurations) {
this.configurations = configurations;
}
public IConfiguration[] getAvailableConfigurations(IProject project) {
// TODO Auto-generated method stub
return null;
} }
} }

View file

@ -30,7 +30,6 @@ public class Tool implements ITool {
public Tool(String name, Target target) { public Tool(String name, Target target) {
this(name); this(name);
this.target = target; this.target = target;
target.addTool(this);
} }
public String getName() { public String getName() {

View file

@ -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 {
}

View file

@ -177,13 +177,6 @@
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="platform" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType> </complexType>
</element> </element>
@ -224,12 +217,13 @@
<element name="target"> <element name="target">
<annotation> <annotation>
<documentation> <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&apos;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&apos;s parent and can add to or override tools in this list.
</documentation> </documentation>
</annotation> </annotation>
<complexType> <complexType>
<sequence> <sequence>
<element ref="tool"/> <element ref="tool"/>
<element ref="configuration"/>
</sequence> </sequence>
<attribute name="id" type="string" use="required"> <attribute name="id" type="string" use="required">
<annotation> <annotation>

View file

@ -45,7 +45,7 @@ public class AllBuildTests extends TestCase {
*/ */
public void testExtensions() { public void testExtensions() {
// Note secret null parameter which means just extensions // Note secret null parameter which means just extensions
ITarget[] targets = ManagedBuildManager.getAvailableTargets(null); ITarget[] targets = ManagedBuildManager.getTargets(null);
ITarget target = targets[0]; ITarget target = targets[0];
assertEquals(target.getName(), "Linux"); assertEquals(target.getName(), "Linux");

View file

@ -45,8 +45,8 @@
id="linux.compiler.flags"> id="linux.compiler.flags">
</option> </option>
<option <option
default="-O"
name="Optimization Flags" name="Optimization Flags"
default="-O"
type="string" type="string"
category="linux.compiler.optimization" category="linux.compiler.optimization"
id="linux.compiler.optimizationFlags"> id="linux.compiler.optimizationFlags">
@ -62,6 +62,14 @@
name="Linker" name="Linker"
id="org.eclipse.cdt.ui.tests.tool.linux.link"> id="org.eclipse.cdt.ui.tests.tool.linux.link">
</tool> </tool>
<configuration
name="Release"
id="linux.exec.release">
</configuration>
<configuration
name="Debug"
id="linux.exec.debug">
</configuration>
</target> </target>
<target <target
name="Linux Shared Library" name="Linux Shared Library"