Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Build model proposal

Hi,

I agree with the vision. Rather than talk in the general, I've attached the interfaces that we are using for all this. It's actually pretty simple. Comment where you think something is not open enough.

In english, a makefile generator and build property manager work with ToolChains that are contributed through extension points. A ToolChain is represented by an IToolChain interface which is responsible for providing the tabs to set tool chain properties (like compiler switches), generation of the build commands and basic file testing. More details in the files.

I'm not up on XML schemas yet so, example extension XML is below.

   <extension point="com.tensilica.xide.cdt.ToolChain">
   <params pretty_name="XtTools with XCC"
  
id="com.tensilica.xide.cdt.xttoolchain.XccToolChain"
   class="com.tensilica.xide.cdt.xttoolchain.XccToolChain" />
   </extension>

   <extension point="com.tensilica.xide.cdt.ToolChain">
   <params pretty_name="XtTools with GCC"
  
id="com.tensilica.xide.cdt.xttoolchain.GccToolChain"
   class="com.tensilica.xide.cdt.xttoolchain.GccToolChain" />
   </extension>

package com.tensilica.xide.cdt;

import org.eclipse.core.resources.IFile;
import com.tensilica.xide.cdt.bldprop.BuildProperties;
import com.tensilica.xide.cdt.bldprop.ui.BuildTab;
import java.util.ArrayList;

/**
 * The ToolChain interface describes a set of compliation tools to the
 * environment. There is a basic assumption that these tools are not java
 * based tools, but are tools that must be spawned in a separate process.
 * <p>
 * The IToolChain is basically responsible for three things. IToolChain
 * identifies which files are buildable by that tool chain. IToolChain 
 * provides tabs for the BuildPropertiesDialog to configure parameters
 * that the toolchains needs and IToolChains construct build lines.
 * 
 * @author songer
 */
public interface IToolChain 
{
	/** 
	 * Checks to see if the toolchain knows how to build this file.
	 * 
	 * @param IFile file to be tested.
	 * 
	 * @returns true if this toolchain knows how to build the file,
	 * false if it does not.
	 */
	public boolean buildsFile(IFile file);
	
	/**
	 * Builds the shell command to build a particular file
	 * 
	 * @param file file for which to constuct the command.
	 * @param prop properties for the command.
	 * 
	 * @return the command as an arraylist
	 */
	public ArrayList buildCommand( IFile file, BuildProperties prop );
	
	/**
	 * Gets the tabs for the properties dialog
	 * 
	 * @return array of tabs 
	 */
	public BuildTab[] getTabs();
}
package com.tensilica.xide.cdt.bldprop.ui;

import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Composite;
import com.tensilica.xide.cdt.bldprop.BuildProperties;

/**
 * Abstract superclass for tabs in the build panel. The parent will use
 * this class to display and modify properties. The methods serve the 
 * following roles.
 * <p>
 * <code>createControl</code> - called by the master to create the controls for 
 * this panel. the method is expected to update the control instance 
 * variable.
 * <p>
 * <code>getName</code> - called by the master for the name to display for
 * the tab.
 * <p>
 * @author songer
 */
abstract public class BuildTab 
{
	/** control for this class */
	protected Control control;
	
	/** sets the control */
	protected void setControl( Control c )
	{
		control = c;	
	}
	
	public Control getControl( )
	{
		return control;
	}

	/** creates the tabs control */	
	abstract public void createControl(Composite parent);
	
	/** returns the tab's name, this string is displayed in the
	 * tab in BuildPropertiesDialog */
	abstract public String getName();
	
	/** Must set the values from the UI into the build properties. The
	 * dialog is taking care of revert et all, so there is no need to
	 * worry about it. Just read the UI and set. */
	abstract public void performApply( BuildProperties p );
	
	/** reads in the values from the build properties and puts them
	 * into the UI */
	abstract public void initFrom( BuildProperties p );
}

Back to the top