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;
import org.eclipse.core.resources.IProject;
/**
*
*/
@ -28,6 +30,13 @@ public interface IConfiguration {
*/
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
* properties.

View file

@ -19,8 +19,16 @@ public interface IOption {
public static final int STRING = 0;
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 interface IOption {
*/
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;
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.
@ -38,4 +40,10 @@ public interface ITarget {
*/
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 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 @@ import org.eclipse.core.runtime.IExtensionPoint;
*/
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()];
@ -52,27 +59,14 @@ public class ManagedBuildManager {
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.
*
* @param project
* @return
*/
public static IConfiguration [] getConfigurations(IProject project) {
return null;
public static IConfiguration[] getConfigurations(IProject project) {
return getResourceConfigs(project);
}
/**
@ -82,51 +76,38 @@ public class ManagedBuildManager {
* @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;
/**
* 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) {
Configuration config = new Configuration(project, parentConfig);
addResourceConfig(project, config);
return config;
}
// Private stuff
@ -151,15 +132,56 @@ public class ManagedBuildManager {
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
}
}

View file

@ -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 @@ import org.eclipse.cdt.core.build.managed.ITool;
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)
@ -40,13 +56,6 @@ public class Configuration implements IConfiguration {
this.name = name;
}
/* (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()
*/
@ -59,16 +68,21 @@ public class Configuration implements IConfiguration {
* @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;
}
}

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;
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 @@ public class Target implements ITarget {
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 @@ public class Target implements ITarget {
}
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 @@ public class Target implements ITarget {
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 addTool(Tool tool) {
if (tools == null)
tools = new ArrayList();
tools.add(tool);
public void setTools(ITool[] tools) {
this.tools = tools;
}
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) {
this(name);
this.target = target;
target.addTool(this);
}
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>
</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&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>
</annotation>
<complexType>
<sequence>
<element ref="tool"/>
<element ref="configuration"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>

View file

@ -45,7 +45,7 @@ public class AllBuildTests extends TestCase {
*/
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");

View file

@ -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"