1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

Commit for Leo Treggiari:

The majority of the code changes were for dealing with the Java class attributes (buildfileGenerator, etc…).
The other bug fixes were:
When the user displays the properties of a file in a standard make file, the “C/C++” category is displayed in the left pane – I couldn’t figure out a way to “filter” it out.  Before the fix, the Managed Make property page was displayed and would then crash when the user selected OK.  Now, it displays a label saying that this page only applies to Managed Make projects.
When the user has automatic build set, edits the properties of a configuration, selects a different configuration, selects OK when asked to save the changes, a build for the proper configuration would start but it would pick up the tool settings from the wrong configuration (the newly selected one).
There was a bug in the Option.onlyOverridesValue method where it wasn’t checking for a zero-length built-ins list, and therefore returning the wrong answer.
There was a bug in adding a Tool to a ToolChain where the new Tool was added to the toolList but not the toolMap.
This commit is contained in:
Sean Evoy 2004-11-04 16:56:27 +00:00
parent b38be15335
commit e70d996fd9
26 changed files with 3838 additions and 2111 deletions

File diff suppressed because it is too large Load diff

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.tests.suite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuild.core.tests.ManagedBuildCoreTests;
import org.eclipse.cdt.managedbuild.core.tests.ManagedBuildCoreTests20;
import org.eclipse.cdt.managedbuild.core.tests.ManagedCommandLineGeneratorTest;
import org.eclipse.cdt.managedbuild.core.tests.ManagedProjectUpdateTests;
@ -31,6 +32,7 @@ public class AllManagedBuildTests {
"Test for org.eclipse.cdt.managedbuild.core.tests");
//$JUnit-BEGIN$
// TODO uncoment this
suite.addTest(ManagedBuildCoreTests20.suite());
suite.addTest(ManagedBuildCoreTests.suite());
suite.addTest(ManagedProjectUpdateTests.suite());
suite.addTest( ManagedCommandLineGeneratorTest.suite() );

View file

@ -0,0 +1,91 @@
/**********************************************************************
* Copyright (c) 2004 Intel 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:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.managedbuild.core.tests;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.MultiStatus;
/**
* Test build file generator
*/
public class BuildFileGenerator implements IManagedBuilderMakefileGenerator {
private IManagedBuilderMakefileGenerator defGen = new GnuMakefileGenerator();
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#generateDependencies()
*/
public void generateDependencies() throws CoreException {
defGen.generateDependencies();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#generateMakefiles(org.eclipse.core.resources.IResourceDelta)
*/
public MultiStatus generateMakefiles(IResourceDelta delta)
throws CoreException {
return defGen.generateMakefiles(delta);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#getBuildWorkingDir()
*/
public IPath getBuildWorkingDir() {
IPath current = defGen.getBuildWorkingDir();
current.append("temp");
return current;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#getMakefileName()
*/
public String getMakefileName() {
return new String("TestBuildFile.mak");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#initialize(org.eclipse.core.resources.IProject, org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo, org.eclipse.core.runtime.IProgressMonitor)
*/
public void initialize(IProject project, IManagedBuildInfo info,
IProgressMonitor monitor) {
defGen.initialize(project, info, monitor);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#isGeneratedResource(org.eclipse.core.resources.IResource)
*/
public boolean isGeneratedResource(IResource resource) {
return defGen.isGeneratedResource(resource);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#regenerateDependencies(boolean)
*/
public void regenerateDependencies(boolean force) throws CoreException {
defGen.regenerateDependencies(force);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#regenerateMakefiles()
*/
public MultiStatus regenerateMakefiles() throws CoreException {
return defGen.regenerateMakefiles();
}
}

View file

@ -0,0 +1,76 @@
/**********************************************************************
* Copyright (c) 2004 Intel 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:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.managedbuild.core.tests;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
/**
* Test command line generator
*/
public class ManagedBuildCommandLineGenerator implements
IManagedCommandLineGenerator {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator#generateCommandLineInfo(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String, java.lang.String[], java.lang.String)
*/
public IManagedCommandLineInfo generateCommandLineInfo(ITool tool,
String commandName, String[] flags, String outputFlag,
String outputPrefix, String outputName, String[] inputResources,
String commandLinePattern) {
ManagedBuildCommandLineInfo info = new ManagedBuildCommandLineInfo();
// Concatenate the tool name and the passed in command name
info.commandName = new String(tool.getName() + commandName);
// Put out the flags backwards
String myflags = new String();
for (int i = flags.length - 1; i >= 0; i--) {
if (i < flags.length - 1) myflags += " ";
myflags += flags[i];
}
info.commandFlags = myflags;
// Alphabetize the inputs and add foo.cpp
String[] inputs = new String[inputResources.length + 1];
String myinputs = new String();
for (int i=0; i<inputResources.length; i++) {
inputs[i] = inputResources[i];
}
inputs[inputResources.length] = "foo.cpp";
// Sort
for (int i = 0; i < inputs.length; i++) {
for (int j = 1; j < inputs.length; j++) {
if (inputs[j].compareTo(inputs[j-1]) < 0) {
String temp = inputs[j-1];
inputs[j-1] = inputs[j];
inputs[j] = temp;
}
}
}
for (int i = 0; i < inputs.length; i++) {
if (i > 0) myinputs += " ";
myinputs += inputs[i];
}
info.commandInputs = myinputs;
// Don't change the command line pattern
info.commandLinePattern = new String(commandLinePattern);
// Config artifact name
info.commandOutput = new String(((IToolChain)tool.getParent()).getParent().getArtifactName());
// -Oh
info.commandOutputFlag = new String("-0h");
// ""
info.commandOutputPrefix = new String("");
// "This is a test command line"
info.commandLine = new String("This is a test command line");
return info;
}
}

View file

@ -0,0 +1,84 @@
/**********************************************************************
* Copyright (c) 2004 Intel 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:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.managedbuild.core.tests;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
/**
* Command line info for use with ManagedBuildCommandLineGenerator
*/
public class ManagedBuildCommandLineInfo implements IManagedCommandLineInfo {
public String commandLine;
public String commandLinePattern;
public String commandName;
public String commandFlags;
public String commandInputs;
public String commandOutput;
public String commandOutputFlag;
public String commandOutputPrefix;
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo#getCommandLine()
*/
public String getCommandLine() {
return commandLine;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo#getCommandLinePattern()
*/
public String getCommandLinePattern() {
return commandLinePattern;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo#getCommandName()
*/
public String getCommandName() {
return commandName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo#getFlags()
*/
public String getFlags() {
return commandFlags;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo#getInputs()
*/
public String getInputs() {
return commandInputs;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo#getOutput()
*/
public String getOutput() {
return commandOutput;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo#getOutputFlag()
*/
public String getOutputFlag() {
return commandOutputFlag;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo#getOutputPrefix()
*/
public String getOutputPrefix() {
return commandOutputPrefix;
}
}

View file

@ -10,13 +10,21 @@
**********************************************************************/
package org.eclipse.cdt.managedbuild.core.tests;
import java.util.ArrayList;
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
public class ManagedCommandLineGeneratorTest extends TestCase {
@ -58,6 +66,7 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
suite.addTest( new ManagedCommandLineGeneratorTest( "testGenerateCommandLineInfoPatterns" ) );
// TODO: The parameters set to NULL in these tests are not currently allowed to be null
//suite.addTest( new ManagedCommandLineGeneratorTest( "testGenerateCommandLineInfoParameters" ) );
suite.addTest( new ManagedCommandLineGeneratorTest( "testCustomGenerator" ) );
return suite;
}
@ -101,4 +110,47 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
assertEquals( info.getCommandLine().trim(), commandLineEtalonesForParameters[5].trim() );
}
public final void testCustomGenerator() {
// First, verify the elements in the project type
IProjectType proj = ManagedBuildManager.getProjectType("cdt.managedbuild.test.java.attrs");
assertNotNull(proj);
IConfiguration[] configs = proj.getConfigurations();
assertEquals(1, configs.length);
IConfiguration config = proj.getConfiguration("cdt.managedbuild.test.java.attrs.config");
assertNotNull(config);
ITool[] tools = config.getTools();
assertEquals(1, tools.length);
ITool tool = config.getTool("cdt.managedbuild.test.java.attrs.tool");
assertNotNull(tool);
IOption[] options = tool.getOptions();
assertEquals(20, options.length);
IOption option = tool.getOption("testgnu.c.compiler.option.preprocessor.def.symbols.test");
assertNotNull(option);
Object val = option.getValue();
assertTrue(val instanceof ArrayList);
ArrayList list = (ArrayList)val;
assertEquals("foo", list.get(0));
assertEquals("bar", list.get(1));
// Next, invoke the commandLineGenerator for this tool
IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
String[] flags = {"-a", "-b", "-c"};
String[] inputs = {"xy.cpp", "ab.cpp", "lt.cpp", "c.cpp"};
IManagedCommandLineInfo info = gen.generateCommandLineInfo(tool, "MyName", flags, "-of", "opre", "TheOutput.exe", inputs, "[COMMAND] [FLAGS]");
assertEquals("compiler.gnu.cMyName", info.getCommandName());
assertEquals("-c -b -a", info.getFlags());
assertEquals("ab.cpp c.cpp foo.cpp lt.cpp xy.cpp", info.getInputs());
assertEquals("-0h", info.getOutputFlag());
assertEquals("", info.getOutputPrefix());
assertEquals("Testme", info.getOutput());
assertEquals("[COMMAND] [FLAGS]", info.getCommandLinePattern());
assertEquals("This is a test command line", info.getCommandLine());
// Next, invoke the build file generator for the tool chain
IManagedBuilderMakefileGenerator makeGen = ManagedBuildManager.getBuildfileGenerator(config);
String name = makeGen.getMakefileName();
assertEquals("TestBuildFile.mak", name);
}
}

View file

@ -409,6 +409,9 @@
<documentation>
Specifies the name of the class that implements IManagedCommandLineGenerator (TBS).
</documentation>
<appInfo>
<meta.attribute kind="java"/>
</appInfo>
</annotation>
</attribute>
<attribute name="dependencyCalculator" type="string">

View file

@ -26,6 +26,7 @@ import org.eclipse.core.runtime.IConfigurationElement;
public interface IBuilder extends IBuildObject {
public static final String ARGUMENTS = "arguments"; //$NON-NLS-1$
public static final String BUILDER_ELEMENT_NAME = "builder"; //$NON-NLS-1$
public static final String BUILDFILEGEN_ID ="buildfileGenerator"; //$NON-NLS-1$
public static final String COMMAND = "command"; //$NON-NLS-1$
/**

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.managedbuilder.internal.core.ProjectType;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IResource;
/**
@ -121,18 +120,6 @@ public interface ITarget extends IBuildObject {
*/
public String getDefaultExtension();
/**
* Answers a class instance that implements an interface to generate
* source-level dependencies for the tool specified in the argument.
* This method may return <code>null</code> in which case, the receiver
* should assume that the tool does not require dependency information
* when the project is built.
*
* @param toolId
* @return
*/
public IManagedDependencyGenerator getDependencyGenerator(String toolId);
/**
* Answers the command line arguments to pass to the make utility used
* by the receiver to build a project.

View file

@ -12,6 +12,10 @@ package org.eclipse.cdt.managedbuilder.core;
import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
/**
* This class represents a utility of some sort that is used in the build process.
* A tool will generally process one or more resources to produce output resources.
@ -22,6 +26,7 @@ public interface ITool extends IBuildObject {
public static final String COMMAND = "command"; //$NON-NLS-1$
public static final String COMMAND_LINE_PATTERN = "commandLinePattern"; //$NON-NLS-1$
public static final String COMMAND_LINE_GENERATOR = "commandLineGenerator"; //$NON-NLS-1$
public static final String DEP_CALC_ID ="dependencyCalculator"; //$NON-NLS-1$
public static final String INTERFACE_EXTS = "headerExtensions"; //$NON-NLS-1$
public static final String NATURE = "natureFilter"; //$NON-NLS-1$
public static final String OPTION = "option"; //$NON-NLS-1$
@ -268,11 +273,50 @@ public interface ITool extends IBuildObject {
public void setCommandLinePattern(String pattern);
/**
* Returns command line generator specified for this tool
* Returns the plugin.xml element of the commandLineGenerator extension or <code>null</code> if none.
*
* @return IConfigurationElement
*/
public IConfigurationElement getCommandLineGeneratorElement();
/**
* Sets the CommandLineGenerator plugin.xml element
*
* @param element
*/
public void setCommandLineGeneratorElement(IConfigurationElement element);
/**
* Returns the command line generator specified for this tool
* @return IManagedCommandLineGenerator
*/
public IManagedCommandLineGenerator getCommandLineGenerator();
/**
* Returns the plugin.xml element of the dependencyGenerator extension or <code>null</code> if none.
*
* @return IConfigurationElement
*/
public IConfigurationElement getDependencyGeneratorElement();
/**
* Sets the DependencyGenerator plugin.xml element
*
* @param element
*/
public void setDependencyGeneratorElement(IConfigurationElement element);
/**
* Returns a class instance that implements an interface to generate
* source-level dependencies for the tool specified in the argument.
* This method may return <code>null</code> in which case, the receiver
* should assume that the tool does not require dependency information
* when the project is built.
*
* @return IManagedDependencyGenerator
*/
public IManagedDependencyGenerator getDependencyGenerator();
/**
* Returns an array of command line arguments that have been specified for
* the tool.

View file

@ -58,7 +58,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.TargetPlatform;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
@ -72,7 +71,6 @@ 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.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
@ -211,68 +209,6 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return (IProjectType)getExtensionProjectTypeMap().get(id);
}
/**
* Answers an instance of a class that implements the
* <code>IManagedDependencyGenerator</code> interface to generate
* the source-level dependencies that make utilities rely on to
* properly rebuild projects
*
* @param toolId the unique <code>ID</code> of the tool to look for
* @return the dependency generator for the tool specified in the argument or <code>null</code>
*/
public static IManagedDependencyGenerator getDependencyGenerator(String toolId) {
return (IManagedDependencyGenerator) getExtensionDepCalcMap().get(toolId);
}
/**
* @param toolId
* @return
*/
public static IManagedDependencyGenerator createDependencyGenerator(String toolId) {
try {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(EXTENSION_POINT_ID);
if (extension != null) {
// There could be many of these
IExtension[] extensions = extension.getExtensions();
// Get the "configuraton elements" defined in the plugin.xml file.
// Note that these "configuration elements" are not related to the
// managed build system "configurations".
// From the PDE Guide:
// A configuration element, with its attributes and children, directly
// reflects the content and structure of the extension section within the
// declaring plug-in's manifest (plugin.xml) file.
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
IConfigurationElement element = configElements[j];
if (element.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
if (element.getAttribute(ITool.ID).equals(toolId)) {
if (element.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
return (IManagedDependencyGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
}
}
} else if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME)) {
IConfigurationElement[] children = element.getChildren(ITool.TOOL_ELEMENT_NAME);
for (int k = 0; k < children.length; ++k) {
IConfigurationElement child = children[k];
if (child.getAttribute(ITool.ID).equals(toolId)) {
if (child.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
return (IManagedDependencyGenerator) child.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
}
}
}
}
}
}
}
}
catch (CoreException e) {
// Probably not defined
}
return null;
}
protected static Map getExtensionDepCalcMap() {
if (depCalculatorsMap == null) {
depCalculatorsMap = new HashMap();
@ -591,8 +527,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return (IManagedBuilderMakefileGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.MAKEGEN_ID);
}
} else {
if (element.getAttribute(ManagedBuilderCorePlugin.BUILDFILEGEN_ID) != null) {
return (IManagedBuilderMakefileGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.BUILDFILEGEN_ID);
if (element.getAttribute(IBuilder.BUILDFILEGEN_ID) != null) {
return (IManagedBuilderMakefileGenerator) element.createExecutableExtension(IBuilder.BUILDFILEGEN_ID);
}
}
}
@ -609,29 +545,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param toolId - id selected id
* @return IManagedCommandLineGenerator
*/
public static IManagedCommandLineGenerator getCommandLineGenerator( String toolId ) {
try {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(EXTENSION_POINT_ID);
if (extension != null) {
// There could be many of these
IExtension[] extensions = extension.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
IConfigurationElement element = configElements[j];
if (element.getName().equals(ITool.COMMAND_LINE_GENERATOR)) {
if (element.getAttribute(ITool.ID).equals(toolId)) {
if (element.getAttribute(ManagedBuilderCorePlugin.COMMANDLINEGEN_ID) != null) {
return (IManagedCommandLineGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.COMMANDLINEGEN_ID);
}
}
}
}
}
}
} catch( CoreException ex ) {
public static IManagedCommandLineGenerator getCommandLineGenerator(IConfiguration config, String toolId) {
ITool tool = config.getTool(toolId);
if (tool != null) {
return tool.getCommandLineGenerator();
}
return ManagedCommandLineGenerator.getCommandLineGenerator();
}
@ -913,12 +830,12 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Save the document
IFile projectFile = project.getFile(SETTINGS_FILE_NAME);
String utfString = stream.toString("UTF8"); //$NON-NLS-1$
String utfString = stream.toString("UTF-8"); //$NON-NLS-1$
if (projectFile.exists()) {
projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
} else {
projectFile.create(new ByteArrayInputStream(utfString.getBytes("UTF8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
projectFile.create(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
}
// Close the streams
@ -1034,7 +951,6 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*/
public static void addExtensionTool(Tool tool) {
getExtensionToolMap().put(tool.getId(), tool);
getExtensionDepCalcMap().put(tool.getId(), createDependencyGenerator(tool.getId()));
}
/**

View file

@ -20,13 +20,10 @@ import org.osgi.framework.BundleContext;
public class ManagedBuilderCorePlugin extends Plugin {
private static final String PLUGIN_ID = "org.eclipse.cdt.managedbuilder.core"; //$NON-NLS-1$
// The attribute name for the dependency calculator
public static final String DEP_CALC_ID ="dependencyCalculator"; //$NON-NLS-1$
// The shared instance
private static ManagedBuilderCorePlugin plugin;
// The attribute name for the makefile generator
public static final String MAKEGEN_ID ="makefileGenerator"; //$NON-NLS-1$
public static final String BUILDFILEGEN_ID ="buildfileGenerator"; //$NON-NLS-1$
public static final String COMMANDLINEGEN_ID = "commandlineGenerator"; //$NON-NLS-1$
// The unique id for all managed make projects
public static final String MANAGED_MAKE_PROJECT_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".managedMake"; //$NON-NLS-1$

View file

@ -19,7 +19,6 @@ import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.runtime.IConfigurationElement;
import org.w3c.dom.Document;
@ -193,10 +192,12 @@ public class Builder extends BuildObject implements IBuilder {
// Get the semicolon separated list of IDs of the error parsers
errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
// build file generator
if (element instanceof DefaultManagedConfigElement)
// Store the configuration element IFF there is a build file generator defined
String buildfileGenerator = element.getAttribute(BUILDFILEGEN_ID);
if (buildfileGenerator != null && element instanceof DefaultManagedConfigElement) {
buildFileGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
}
/* (non-Javadoc)
* Initialize the builder information from the XML element
@ -253,7 +254,7 @@ public class Builder extends BuildObject implements IBuilder {
// Note: build file generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (element.hasAttribute(ManagedBuilderCorePlugin.BUILDFILEGEN_ID)) {
if (element.hasAttribute(IBuilder.BUILDFILEGEN_ID)) {
// TODO: Issue warning?
}
}
@ -465,6 +466,18 @@ public class Builder extends BuildObject implements IBuilder {
setDirty(true);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuilder#getBuildFileGeneratorElement()
*/
public IConfigurationElement getBuildFileGeneratorElement() {
if (buildFileGeneratorElement == null) {
if (superClass != null) {
return superClass.getBuildFileGeneratorElement();
}
}
return buildFileGeneratorElement;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuilder#setBuildFileGeneratorElement(String)
*/
@ -473,13 +486,6 @@ public class Builder extends BuildObject implements IBuilder {
setDirty(true);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuilder#getBuildFileGeneratorElement()
*/
public IConfigurationElement getBuildFileGeneratorElement() {
return buildFileGeneratorElement;
}
/*
* O B J E C T S T A T E M A I N T E N A N C E
*/

View file

@ -30,11 +30,8 @@ import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@ -46,9 +43,6 @@ import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
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.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@ -56,7 +50,6 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
/**
@ -396,44 +389,6 @@ public class GeneratedMakefileBuilder extends ACBuilder {
monitor.subTask(statusMsg);
}
/**
* @param toolId
* @return
*/
public IManagedDependencyGenerator getDependencyCalculator(String toolId) {
try {
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ManagedBuilderCorePlugin.DEP_CALC_ID);
if (extension != null) {
// There could be many of these
IExtension[] extensions = extension.getExtensions();
// Get the "configuraton elements" defined in the plugin.xml file.
// Note that these "configuration elements" are not related to the
// managed build system "configurations".
// From the PDE Guide:
// A configuration element, with its attributes and children, directly
// reflects the content and structure of the extension section within the
// declaring plug-in's manifest (plugin.xml) file.
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
IConfigurationElement element = configElements[j];
if (element.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
if (element.getAttribute(ITool.ID).equals(toolId)) {
if (element.getAttribute(ManagedBuilderCorePlugin.DEP_CALC_ID) != null) {
return (IManagedDependencyGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.DEP_CALC_ID);
}
}
}
}
}
}
}
catch (CoreException e) {
// Probably not defined
}
return null;
}
/* (non-Javadoc)
*
* @return

View file

@ -30,7 +30,6 @@ import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainer;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
@ -290,7 +289,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
ITool[] tools = getDefaultConfiguration().getFilteredTools();
for (int index = 0; index < tools.length; ++index) {
if(tools[index].buildsFileType(sourceExtension)) {
return ManagedBuildManager.getDependencyGenerator(tools[index].getId());
return tools[index].getDependencyGenerator();
}
}
}

View file

@ -1275,7 +1275,7 @@ public class Option extends BuildObject implements IOption {
if (superClass != null &&
unusedChildren == null &&
browseType == null &&
builtIns == null &&
(builtIns == null || builtIns.size() == 0) &&
category == null &&
categoryId == null &&
command == null &&

View file

@ -31,7 +31,6 @@ import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Platform;
import org.w3c.dom.Document;
@ -272,7 +271,6 @@ public class Target extends BuildObject implements ITarget {
public void addTool(ITool tool) {
getToolList().add(tool);
getToolMap().put(tool.getId(), tool);
getDepCalcMap().put(tool.getId(), ManagedBuildManager.createDependencyGenerator(tool.getId()));
}
/**
@ -446,26 +444,6 @@ public class Target extends BuildObject implements ITarget {
return depCalculatorsMap;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getDependencyCalculator(java.lang.String)
*/
public IManagedDependencyGenerator getDependencyGenerator(String toolId) {
// If I have this tool defined locally, answer its dependency calculator
IManagedDependencyGenerator answer = (IManagedDependencyGenerator) getDepCalcMap().get(toolId);
// I do not have a local tool definition
if (answer == null && parent != null) {
answer = parent.getDependencyGenerator(toolId);
}
// Perhaps this is a reference, in which case the build manager is cacheing its generator
if (answer == null && parent == null) {
answer = ManagedBuildManager.getDependencyGenerator(toolId);
}
return answer;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserIds()
*/

View file

@ -31,6 +31,9 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.CoreException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -72,11 +75,14 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
private String outputPrefix;
private String errorParserIds;
private String commandLinePattern;
private IConfigurationElement commandLineGeneratorElement = null;
private IManagedCommandLineGenerator commandLineGenerator = null;
private IConfigurationElement dependencyGeneratorElement = null;
private IManagedDependencyGenerator dependencyGenerator = null;
// Miscellaneous
private boolean isExtensionTool = false;
private boolean isDirty = false;
private boolean resolved = true;
private IManagedCommandLineGenerator commandLineGenerator = null;
/*
* C O N S T R U C T O R S
@ -267,6 +273,11 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
outputPrefix = new String(tool.outputPrefix);
}
commandLineGeneratorElement = tool.commandLineGeneratorElement;
commandLineGenerator = tool.commandLineGenerator;
dependencyGeneratorElement = tool.dependencyGeneratorElement;
dependencyGenerator = tool.dependencyGenerator;
// Clone the children
// Note: This constructor ignores OptionCategories since they should not be
// found on an non-extension tool
@ -372,6 +383,18 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
// Get command line pattern
commandLinePattern = element.getAttribute( ITool.COMMAND_LINE_PATTERN );
// Store the configuration element IFF there is a command line generator defined
String commandLineGenerator = element.getAttribute(COMMAND_LINE_GENERATOR);
if (commandLineGenerator != null && element instanceof DefaultManagedConfigElement) {
commandLineGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
// Store the configuration element IFF there is a dependency generator defined
String depGenerator = element.getAttribute(DEP_CALC_ID);
if (depGenerator != null && element instanceof DefaultManagedConfigElement) {
dependencyGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
}
}
/* (non-Javadoc)
@ -603,6 +626,18 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
option.serialize(doc, optionElement);
}
// Note: command line generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (commandLineGeneratorElement != null) {
// TODO: issue warning?
}
// Note: dependency generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it!
if (dependencyGeneratorElement != null) {
// TODO: issue warning?
}
// I am clean now
isDirty = false;
} catch (Exception e) {
@ -1076,6 +1111,84 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getCommandLineGeneratorElement()
*/
public IConfigurationElement getCommandLineGeneratorElement() {
if (commandLineGeneratorElement == null) {
if (superClass != null) {
return superClass.getCommandLineGeneratorElement();
}
}
return commandLineGeneratorElement;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#setCommandLineGeneratorElement(String)
*/
public void setCommandLineGeneratorElement(IConfigurationElement element) {
commandLineGeneratorElement = element;
setDirty(true);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getCommandLineGenerator()
*/
public IManagedCommandLineGenerator getCommandLineGenerator() {
if (commandLineGenerator != null) {
return commandLineGenerator;
}
IConfigurationElement element = getCommandLineGeneratorElement();
if (element != null) {
try {
if (element.getAttribute(COMMAND_LINE_GENERATOR) != null) {
commandLineGenerator = (IManagedCommandLineGenerator) element.createExecutableExtension(COMMAND_LINE_GENERATOR);
return commandLineGenerator;
}
} catch (CoreException e) {}
}
return ManagedCommandLineGenerator.getCommandLineGenerator();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getDependencyGeneratorElement()
*/
public IConfigurationElement getDependencyGeneratorElement() {
if (dependencyGeneratorElement == null) {
if (superClass != null) {
return superClass.getDependencyGeneratorElement();
}
}
return dependencyGeneratorElement;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#setDependencyGeneratorElement(String)
*/
public void setDependencyGeneratorElement(IConfigurationElement element) {
dependencyGeneratorElement = element;
setDirty(true);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getDependencyGenerator()
*/
public IManagedDependencyGenerator getDependencyGenerator() {
if (dependencyGenerator != null) {
return dependencyGenerator;
}
IConfigurationElement element = getDependencyGeneratorElement();
if (element != null) {
try {
if (element.getAttribute(DEP_CALC_ID) != null) {
dependencyGenerator = (IManagedDependencyGenerator) element.createExecutableExtension(DEP_CALC_ID);
return dependencyGenerator;
}
} catch (CoreException e) {}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getNatureFilter()
*/
@ -1166,14 +1279,6 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getCommandLineGenerator()
*/
public IManagedCommandLineGenerator getCommandLineGenerator() {
if( commandLineGenerator == null ) commandLineGenerator = ManagedBuildManager.getCommandLineGenerator( this.getId() );
return commandLineGenerator;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputFlag(java.lang.String)
*/

View file

@ -106,7 +106,7 @@ public class ToolChain extends BuildObject implements IToolChain {
IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
for (int n = 0; n < tools.length; ++n) {
Tool toolChild = new Tool(this, tools[n]);
getToolList().add(toolChild);
addTool(toolChild);
}
}

View file

@ -25,6 +25,8 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -924,6 +926,40 @@ public class ToolReference implements IToolReference {
return parent.getCommandLineGenerator();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGenerator()
*/
public IConfigurationElement getCommandLineGeneratorElement() {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#setCommandLineGenerator(IConfigurationElement)
*/
public void setCommandLineGeneratorElement(IConfigurationElement element) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getDependencyGenerator()
*/
public IManagedDependencyGenerator getDependencyGenerator() {
if( parent == null ) return null;
return parent.getDependencyGenerator();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGenerator()
*/
public IConfigurationElement getDependencyGeneratorElement() {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#setCommandLineGenerator(IConfigurationElement)
*/
public void setDependencyGeneratorElement(IConfigurationElement element) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getCommandFlags()
*/

View file

@ -369,7 +369,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
buildRule = relativePath + WILDCARD + OptDotExt + COLON + WHITESPACE + ROOT + SEPARATOR + resourcePath + WILDCARD + DOT + inputExtension;
} // end fix for PR 70491
IConfiguration config = info.getSelectedConfiguration();
IConfiguration config = info.getDefaultConfiguration();
// For testing only
/* if( config.getResourceConfigurations().length > 0) {
@ -517,10 +517,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Visit the resources in this folder
IResource[] resources = module.members();
IConfiguration config = info.getSelectedConfiguration();
if (config == null) {
config = info.getDefaultConfiguration();
}
IConfiguration config = info.getDefaultConfiguration();
IResourceConfiguration resConfig;
for (int i = 0; i < resources.length; i++) {

View file

@ -86,6 +86,7 @@ ResourceBuildPropertyPage.label.ExcludeCheckBox= Exclude from build
ResourceBuildPropertyPage.selection.configuration.all=All configurations
ResourceBuildPropertyPage.label.ToolTree=Tools
ResourceBuildPropertyPage.label.ToolOptions=Options
ResourceBuildPropertyPage.label.NotMBSFile=The project is closed or the file is not contained within a Managed Make project.
# ----------- Entry Dialog -----------
BrowseEntryDialog.error.Folder_name_invalid = Folder name invalid

View file

@ -189,8 +189,8 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
}
/* (non-Javadoc)
* Method displayOptionsForTool.
* @param toolReference
* Method displayOptionsForCategory
* @param category
*/
private void displayOptionsForCategory(IOptionCategory category) {
// Do nothing if the selected category is is unchanged
@ -264,6 +264,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
}
/* (non-Javadoc)
* Method displayOptionsForTool
* @param tool
*/
private void displayOptionsForTool(ITool tool) {
@ -315,9 +316,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
// Make the current page visible
currentSettingsPage.setVisible(true);
// save the last page build options.
// If the last page is tool page then parse all the options
// and put it in the appropriate preference store.
// Save the last page build options.
if (oldPage != null){
if(oldPage instanceof BuildOptionSettingsPage) {
((BuildOptionSettingsPage)oldPage).storeSettings();
@ -327,7 +326,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
//((BuildToolSettingsPage)oldPage).parseAllOptions();
}
}
//update the field editor that displays all the build options
// Update the field editor that displays all the build options
if(currentSettingsPage instanceof BuildToolSettingsPage)
((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField();

View file

@ -15,6 +15,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
@ -23,6 +24,7 @@ import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.dialogs.MessageDialog;
@ -66,6 +68,7 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
private static final String RESOURCE_SETTINGS_LABEL = LABEL + ".ResourceSettings"; //$NON-NLS-1$
private static final String TREE_LABEL = LABEL + ".ToolTree"; //$NON-NLS-1$
private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
private static final String NOTMBSFILE_LABEL = LABEL + ".NotMBSFile"; //$NON-NLS-1$
private static final String EXCLUDE_CHECKBOX = LABEL + ".ExcludeCheckBox"; //$NON-NLS-1$
private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
private static final String RESOURCE_PLAT_TIP = TIP + ".ResourcePlatform"; //$NON-NLS-1$
@ -83,11 +86,12 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
// private Point lastShellSize;
private Button excludedCheckBox;
private boolean isExcluded = false;
/*
* Bookeeping variables
*/
private boolean isExcluded = false;
private boolean noContentOnPage = false;
private IConfiguration[] configurations;
@ -111,8 +115,6 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
}
protected Control createContents(Composite parent) {
GridData gd;
// Create the container we return to the property page editor
Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
@ -122,6 +124,26 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
compositeLayout.marginWidth = 0;
composite.setLayout( compositeLayout );
// Check to see if we are dealing with a managed build project
boolean openMBSProject;
try {
openMBSProject = (getProject().hasNature(ManagedCProjectNature.MNG_NATURE_ID));
} catch (CoreException e) {
openMBSProject = false;
}
if (openMBSProject) {
contentForMBSFile(composite);
} else {
noContent(composite);
}
return composite;
}
protected void contentForMBSFile(Composite composite) {
GridData gd;
// Initialize the key data
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
if (info.getVersion() == null) {
@ -130,7 +152,6 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
invalidInfo.setFont(composite.getFont());
invalidInfo.setText(ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.error.version_low")); //$NON-NLS-1$
invalidInfo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING,GridData.VERTICAL_ALIGN_CENTER, true, true));
return composite;
}
// Add a config selection area
@ -188,7 +209,15 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
// Update the contents of the configuration widget
populateConfigurations();
WorkbenchHelp.setHelp(composite,ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
return composite;
}
protected void noContent(Composite composite) {
Label label = new Label(composite, SWT.LEFT);
label.setText(ManagedBuilderUIMessages.getResourceString(NOTMBSFILE_LABEL));
label.setFont(composite.getFont());
noContentOnPage = true;
noDefaultAndApplyButton();
}
private void handleIsExcluded() {
@ -310,8 +339,12 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
*/
public boolean performOk() {
// If there is no content on the page, then there is nothing to do
if (noContentOnPage) return true;
// If the user did not visit this page, then there is nothing to do.
if (!displayedConfig) return true;
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
fOptionBlock.performApply(monitor);