name
or return the project in
+ * the workspace of the same name if it exists.
+ *
+ * @param name The name of the project to create or retrieve.
+ * @return
+ * @throws CoreException
+ */
+ static public IProject createProject(String name) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject newProjectHandle = root.getProject(name);
+ IProject project = null;
+
+ if (!newProjectHandle.exists()) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceDescription workspaceDesc = workspace.getDescription();
+ workspaceDesc.setAutoBuilding(false);
+ workspace.setDescription(workspaceDesc);
+ IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
+ //description.setLocation(root.getLocation());
+ project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
+ } else {
+ newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, null);
+ project = newProjectHandle;
+ }
+
+ // Open the project if we have to
+ if (!project.isOpen()) {
+ project.open(new NullProgressMonitor());
+ }
+
+ return project;
+ }
+
+ /**
+ * Remove the IProject
with the name specified in the argument from the
+ * receiver's workspace.
+ *
+ * @param name
+ */
+ static public void removeProject(String name) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(name);
+ if (project.exists()) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e1) {
+ } finally {
+ try {
+ System.gc();
+ System.runFinalization();
+ project.delete(true, true, null);
+ } catch (CoreException e2) {
+ Assert.assertTrue(false);
+ }
+ }
+ }
+ }
+
+ static public IProject createProject(String projectName, File zip) throws CoreException, InvocationTargetException, IOException {
+ IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
+ IProject project= root.getProject(projectName);
+ if (project.exists())
+ removeProject(projectName);
+
+ importFilesFromZip(new ZipFile(zip),project.getFullPath(),null);
+
+ return createProject(projectName);
+ }
+
+ static public void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
+ ZipFileStructureProvider structureProvider= new ZipFileStructureProvider(srcZipFile);
+ try {
+ ImportOperation op= new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new IOverwriteQuery() {
+ public String queryOverwrite(String file) {
+ return ALL;
+ }
+ });
+ op.run(monitor);
+ } catch (InterruptedException e) {
+ // should not happen
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
index ca7e287cf62..8bc3cfa5a68 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
@@ -10,7 +10,10 @@
**********************************************************************/
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.ManagedCommandLineGeneratorTest;
+import org.eclipse.cdt.managedbuild.core.tests.ManagedProjectUpdateTests;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -20,13 +23,17 @@ import junit.framework.TestSuite;
*/
public class AllManagedBuildTests {
public static void main(String[] args) {
+ CCorePlugin.getDefault().getCoreModel().getIndexManager().reset();
junit.textui.TestRunner.run(AllManagedBuildTests.suite());
}
public static Test suite() {
TestSuite suite = new TestSuite(
"Test for org.eclipse.cdt.managedbuild.core.tests");
//$JUnit-BEGIN$
+// TODO uncoment this
suite.addTest(ManagedBuildCoreTests.suite());
+ suite.addTest(ManagedProjectUpdateTests.suite());
+ suite.addTest( ManagedCommandLineGeneratorTest.suite() );
//$JUnit-END$
return suite;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java
index 9772909426a..7ad5f9478f3 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java
@@ -12,7 +12,6 @@ package org.eclipse.cdt.managedbuild.core.tests;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -36,18 +35,18 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolReference;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.core.Option;
-import org.eclipse.cdt.managedbuilder.internal.core.OptionReference;
-import org.eclipse.cdt.managedbuilder.internal.core.ToolReference;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -91,7 +90,7 @@ public class ManagedBuildCoreTests extends TestCase {
suite.addTest(new ManagedBuildCoreTests("testProjectCreation"));
suite.addTest(new ManagedBuildCoreTests("testConfigurations"));
suite.addTest(new ManagedBuildCoreTests("testConfigurationReset"));
- suite.addTest(new ManagedBuildCoreTests("testTargetBuildArtifact"));
+ suite.addTest(new ManagedBuildCoreTests("testConfigBuildArtifact"));
suite.addTest(new ManagedBuildCoreTests("testMakeCommandManipulation"));
suite.addTest(new ManagedBuildCoreTests("testScannerInfoInterface"));
suite.addTest(new ManagedBuildCoreTests("testBug43450"));
@@ -107,50 +106,50 @@ public class ManagedBuildCoreTests extends TestCase {
* defined in this plugin
*/
public void testExtensions() throws Exception {
- ITarget testRoot = null;
- ITarget testSub = null;
- ITarget testSubSub = null;
- ITarget testForwardChild = null;
- ITarget testForwardParent = null;
- ITarget testForwardGrandchild = null;
- int numProviderTargets = 0;
+ IProjectType testRoot = null;
+ IProjectType testSub = null;
+ IProjectType testSubSub = null;
+ IProjectType testForwardChild = null;
+ IProjectType testForwardParent = null;
+ IProjectType testForwardGrandchild = null;
+ int numTypes = 0;
// Note secret null parameter which means just extensions
- ITarget[] targets = ManagedBuildManager.getDefinedTargets(null);
+ IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes();
- for (int i = 0; i < targets.length; ++i) {
- ITarget target = targets[i];
+ for (int i = 0; i < projTypes.length; ++i) {
+ IProjectType type = projTypes[i];
- if (target.getName().equals("Test Root")) {
- testRoot = target;
- checkRootTarget(testRoot);
- } else if (target.getName().equals("Test Sub")) {
- testSub = target;
- checkSubTarget(testSub);
- } else if (target.getName().equals("Test Sub Sub")) {
- testSubSub = target;
- checkSubSubTarget(testSubSub);
- } else if (target.getName().equals("Forward Child")) {
- testForwardChild = target;
- } else if (target.getName().equals("Forward Parent")) {
- testForwardParent = target;
- } else if (target.getName().equals("Forward Grandchild")) {
- testForwardGrandchild = target;
- } else if (target.getId().startsWith("test.provider.Test_")) {
- numProviderTargets++;
- checkProviderTarget(target);
+ if (type.getName().equals("Test Root")) {
+ testRoot = type;
+ checkRootProjectType(testRoot);
+ } else if (type.getName().equals("Test Sub")) {
+ testSub = type;
+ checkSubProjectType(testSub);
+ } else if (type.getName().equals("Test Sub Sub")) {
+ testSubSub = type;
+ checkSubSubProjectType(testSubSub);
+ } else if (type.getName().equals("Forward Child")) {
+ testForwardChild = type;
+ } else if (type.getName().equals("Forward Parent")) {
+ testForwardParent = type;
+ } else if (type.getName().equals("Forward Grandchild")) {
+ testForwardGrandchild = type;
+ } else if (type.getId().startsWith("test.provider.Test_")) {
+ numTypes++;
+ checkProviderProjectType(type);
}
}
// check that the forward references are properly resolved.
assertNotNull(testForwardChild);
assertNotNull(testForwardParent);
assertNotNull(testForwardGrandchild);
- checkForwardTargets(testForwardParent, testForwardChild, testForwardGrandchild);
+ checkForwardProjectTypes(testForwardParent, testForwardChild, testForwardGrandchild);
- // check that the proper number of target were dynamically provided
- assertEquals(3, numProviderTargets);
+ // check that the proper number of projectTypes were dynamically provided
+ assertEquals(3, numTypes);
- // All these targets are defines in the plugin files, so none
+ // All these project types are defines in the plugin files, so none
// of them should be null at this point
assertNotNull(testRoot);
assertNotNull(testSub);
@@ -158,7 +157,7 @@ public class ManagedBuildCoreTests extends TestCase {
}
/**
- * This test exercises the interface the ITarget
exposes to manipulate
+ * This test exercises the interface the IConfiguration
exposes to manipulate
* its make command.
*/
public void testMakeCommandManipulation () {
@@ -179,23 +178,27 @@ public class ManagedBuildCoreTests extends TestCase {
}
assertNotNull(project);
- // Now open the root target
- ITarget[] targets = ManagedBuildManager.getTargets(project);
- assertEquals(1, targets.length);
+ // Now get the default configuration
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ assertNotNull(info);
+ IManagedProject managedProj = info.getManagedProject();
+ assertNotNull(managedProj);
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ assertNotNull(defaultConfig);
- // Does it have a default make command
- assertFalse(targets[0].hasOverridenMakeCommand());
- assertEquals(oldMakeCmd, targets[0].getMakeCommand());
+ // Does it have a default build command
+ assertFalse(defaultConfig.hasOverriddenBuildCommand());
+ assertEquals(oldMakeCmd, defaultConfig.getBuildCommand());
// Change it
- targets[0].setMakeCommand(newMakeCmd);
- assertEquals(newMakeCmd, targets[0].getMakeCommand());
- assertTrue(targets[0].hasOverridenMakeCommand());
+ defaultConfig.setBuildCommand(newMakeCmd);
+ assertEquals(newMakeCmd, defaultConfig.getBuildCommand());
+ assertTrue(defaultConfig.hasOverriddenBuildCommand());
// Reset it
- targets[0].resetMakeCommand();
- assertFalse(targets[0].hasOverridenMakeCommand());
- assertEquals(oldMakeCmd, targets[0].getMakeCommand());
+ defaultConfig.setBuildCommand(null);
+ assertFalse(defaultConfig.hasOverriddenBuildCommand());
+ assertEquals(oldMakeCmd, defaultConfig.getBuildCommand());
ManagedBuildManager.saveBuildInfo(project, false);
}
@@ -203,7 +206,7 @@ public class ManagedBuildCoreTests extends TestCase {
/**
* The purpose of this test is to exercise the build path info interface.
- * To get to that point, a new target/config has to be created in the test
+ * To get to that point, a new project/config has to be created in the test
* project and the default configuration changed.
*
* @throws CoreException
@@ -232,31 +235,46 @@ public class ManagedBuildCoreTests extends TestCase {
expectedPaths[3] = (new Path("C:\\home\\tester/include")).toOSString();
expectedPaths[4] = project.getLocation().append( "Sub Config\\\"..\\includes\"" ).toOSString();
- // Create a new target in the project based on the sub target
- ITarget baseTarget = ManagedBuildManager.getTarget(project, "test.sub");
- assertNotNull(baseTarget);
- ITarget newTarget = null;
- try {
- newTarget = ManagedBuildManager.createTarget(project, baseTarget);
- } catch (BuildException e) {
- fail("Failed adding new target to project: " + e.getLocalizedMessage());
- }
- assertNotNull(newTarget);
+ // Create a new managed project based on the sub project type
+ IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub");
+ assertNotNull(projType);
+ // Create the managed-project (.cdtbuild) for our project
+ IManagedProject newProject = null;
+ try {
+ newProject = ManagedBuildManager.createManagedProject(project, projType);
+ } catch (BuildException e) {
+ fail("Failed creating new project: " + e.getLocalizedMessage());
+ }
+ assertNotNull(newProject);
+ ManagedBuildManager.setNewProjectVersion(project);
+
// Copy over the configs
- IConfiguration[] baseConfigs = baseTarget.getConfigurations();
+ IConfiguration[] baseConfigs = projType.getConfigurations();
for (int i = 0; i < baseConfigs.length; ++i) {
- newTarget.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
+ newProject.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
}
// Change the default configuration to the sub config
- IConfiguration[] configs = newTarget.getConfigurations();
+ IConfiguration[] configs = newProject.getConfigurations();
assertEquals(4, configs.length);
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
- buildInfo.setDefaultConfiguration(newTarget.getConfiguration(configs[0].getId()));
+ buildInfo.setDefaultConfiguration(newProject.getConfiguration(configs[0].getId()));
- // Save the build info
- ManagedBuildManager.saveBuildInfo(project, false);
+ // Save, close, reopen
+ ManagedBuildManager.saveBuildInfo(project, true);
+ ManagedBuildManager.removeBuildInfo(project);
+ try {
+ project.close(null);
+ } catch (CoreException e) {
+ fail("Failed on project close: " + e.getLocalizedMessage());
+ }
+ try {
+ project.open(null);
+ } catch (CoreException e) {
+ fail("Failed on project open: " + e.getLocalizedMessage());
+ }
+ buildInfo = ManagedBuildManager.getBuildInfo(project);
// Use the plugin mechanism to discover the supplier of the path information
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID + ".ScannerInfoProvider");
@@ -299,12 +317,12 @@ public class ManagedBuildCoreTests extends TestCase {
// Add some defined symbols programmatically
String[] expectedSymbols = {"DEBUG", "GNOME = ME "};
- IConfiguration defaultConfig = buildInfo.getDefaultConfiguration(newTarget);
+ IConfiguration defaultConfig = buildInfo.getDefaultConfiguration();
ITool[] tools = defaultConfig.getTools();
ITool subTool = null;
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
- if("tool.sub".equalsIgnoreCase(tool.getId())) {
+ if("tool.sub".equalsIgnoreCase(tool.getSuperClass().getId())) {
subTool = tool;
break;
}
@@ -314,15 +332,19 @@ public class ManagedBuildCoreTests extends TestCase {
IOption[] opts = subTool.getOptions();
for (int i = 0; i < opts.length; i++) {
IOption option = opts[i];
- if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
- symbolOpt = option;
- break;
+ try {
+ if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
+ symbolOpt = option;
+ break;
+ }
+ } catch (BuildException e) {
+ fail("Failed getting option value-type: " + e.getLocalizedMessage());
}
}
assertNotNull(symbolOpt);
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
assertFalse(info.isDirty());
- ManagedBuildManager.setOption(defaultConfig, symbolOpt, expectedSymbols);
+ ManagedBuildManager.setOption(defaultConfig, subTool, symbolOpt, expectedSymbols);
assertTrue(info.isDirty());
info.setDirty(false);
assertFalse(info.isDirty());
@@ -353,11 +375,10 @@ public class ManagedBuildCoreTests extends TestCase {
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
}
- // Make sure there is one and only one target with 3 configs
- ITarget[] definedTargets = ManagedBuildManager.getTargets(project);
- assertEquals(1, definedTargets.length);
- ITarget rootTarget = definedTargets[0];
- IConfiguration[] definedConfigs = rootTarget.getConfigurations();
+ // Make sure there is a ManagedProject with 3 configs
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IManagedProject managedProj = info.getManagedProject();
+ IConfiguration[] definedConfigs = managedProj.getConfigurations();
assertEquals(3, definedConfigs.length);
IConfiguration baseConfig = definedConfigs[0];
assertEquals(definedConfigs[0].getName(), rootName);
@@ -365,8 +386,8 @@ public class ManagedBuildCoreTests extends TestCase {
assertEquals(definedConfigs[2].getName(), completeOverrideName);
// Create a new configuration and test the rename function
- IConfiguration newConfig = rootTarget.createConfiguration(baseConfig, testConfigId);
- assertEquals(4, rootTarget.getConfigurations().length);
+ IConfiguration newConfig = managedProj.createConfigurationClone(baseConfig, testConfigId);
+ assertEquals(4, managedProj.getConfigurations().length);
newConfig.setName(testConfigName);
assertEquals(newConfig.getId(), testConfigId);
assertEquals(newConfig.getName(), testConfigName);
@@ -384,37 +405,49 @@ public class ManagedBuildCoreTests extends TestCase {
// Override options in the new configuration
IOptionCategory topCategory = rootTool.getTopOptionCategory();
assertEquals("Root Tool", topCategory.getName());
- IOption[] options = topCategory.getOptions(null);
- assertEquals(2, options.length);
- ManagedBuildManager.setOption(newConfig, options[0], listVal);
- ManagedBuildManager.setOption(newConfig, options[1], boolVal);
+ Object[][] options = topCategory.getOptions(newConfig);
+ int i;
+ for (i=0; inull
if none.
+ *
+ * @return IConfigurationElement
+ */
+ public IConfigurationElement getBuildFileGeneratorElement();
+
+ /**
+ * Returns the name of the build/make utility for the configuration.
+ *
+ * @return String
+ */
+ public String getCommand();
+
+ /**
+ * Returns the semicolon separated list of unique IDs of the error parsers associated
+ * with the builder.
+ *
+ * @return String
+ */
+ public String getErrorParserIds();
+
+ /**
+ * Returns the ordered list of unique IDs of the error parsers associated with the
+ * builder.
+ *
+ * @return String[]
+ */
+ public String[] getErrorParserList();
+
+ /**
+ * Returns the tool-chain that is the parent of this builder.
+ *
+ * @return IToolChain
+ */
+ public IToolChain getParent();
+
+ /**
+ * Returns the IBuilder
that is the superclass of this
+ * target platform, or null
if the attribute was not specified.
+ *
+ * @return IBuilder
+ */
+ public IBuilder getSuperClass();
+
+ /**
+ * Returns a semi-colon delimited list of child Ids of the superclass'
+ * children that should not be automatically inherited by this element.
+ * Returns an empty string if the attribute was not specified.
+ * @return String
+ */
+ public String getUnusedChildren();
+
+ /**
+ * Returns whether this element is abstract. Returns false
+ * if the attribute was not specified.
+ *
+ * @return boolean
+ */
+ public boolean isAbstract();
+
+ /**
+ * Returns true
if this element has changes that need to
+ * be saved in the project file, else false
.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Returns true
if this builder was loaded from a manifest file,
+ * and false
if it was loaded from a project (.cdtbuild) file.
+ *
+ * @return boolean
+ */
+ public boolean isExtensionElement();
+
+ /**
+ * Sets the arguments to be passed to the build utility used by the
+ * receiver to produce a build goal.
+ *
+ * @param makeArgs
+ */
+ public void setArguments(String makeArgs);
+
+ /**
+ * Sets the BuildFileGenerator plugin.xml element
+ *
+ * @param element
+ */
+ public void setBuildFileGeneratorElement(IConfigurationElement element);
+
+ /**
+ * Sets the build command for the receiver to the value in the argument.
+ *
+ * @param command
+ */
+ public void setCommand(String command);
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Sets the semicolon separated list of error parser ids
+ *
+ * @param ids
+ */
+ public void setErrorParserIds(String ids);
+
+ /**
+ * Sets the isAbstract attribute of the builder.
+ *
+ * @param b
+ */
+ public void setIsAbstract(boolean b);
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java
index 846291eb556..bc1b2403070 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java
@@ -10,126 +10,333 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
-import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+/**
+ * A tool-integrator defines default configurations as children of the project type.
+ * These provide a template for the configurations added to the user's project,
+ * which are stored in the project's .cdtbuild file.
+ *
+ * The configuration contains one child of type tool-chain. This describes how the
+ * project's resources are transformed into the build artifact. The configuration can
+ * contain one or more children of type resourceConfiguration. These describe build
+ * settings of individual resources that are different from the configuration as a whole.
+ *
+ * @since 2.1
+ */
public interface IConfiguration extends IBuildObject {
+ public static final String ARTIFACT_NAME = "artifactName"; //$NON-NLS-1$
+ public static final String CLEAN_COMMAND = "cleanCommand"; //$NON-NLS-1$
// Schema element names
public static final String CONFIGURATION_ELEMENT_NAME = "configuration"; //$NON-NLS-1$
- public static final String TOOLREF_ELEMENT_NAME = "toolReference"; //$NON-NLS-1$
+ public static final String ERROR_PARSERS = "errorParsers"; //$NON-NLS-1$
+ public static final String EXTENSION = "artifactExtension"; //$NON-NLS-1$
public static final String PARENT = "parent"; //$NON-NLS-1$
+ /**
+ * Creates a child resource configuration corresponding to the passed in file.
+ *
+ * @param file
+ * @return IResourceConfiguration
+ */
+ public IResourceConfiguration createResourceConfiguration(IFile file);
+
+ /**
+ * Creates the IToolChain
child of this configuration.
+ *
+ * @param ToolChain The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ *
+ * @return IToolChain
+ */
+ public IToolChain createToolChain(IToolChain superClass, String Id, String name, boolean isExtensionElement);
+
+ /**
+ * Returns the extension that should be applied to build artifacts created by
+ * this configuration.
+ *
+ * @return String
+ */
+ public String getArtifactExtension();
+
+ /**
+ * Returns the name of the final build artifact.
+ *
+ * @return String
+ */
+ public String getArtifactName();
+
+ /**
+ * Returns the build arguments from this configuration's builder
+ *
+ * @return String
+ */
+ public String getBuildArguments();
+
+ /**
+ * Returns the build command from this configuration's builder
+ *
+ * @return String
+ */
+ public String getBuildCommand();
+
+ /**
+ * Answers the OS-specific command to remove files created by the build
+ * of this configuration.
+ *
+ * @return String
+ */
+ public String getCleanCommand();
+
+ /**
+ * Answers the semicolon separated list of unique IDs of the error parsers associated
+ * with this configuration.
+ *
+ * @return String
+ */
+ public String getErrorParserIds();
+
+ /**
+ * Answers the ordered list of unique IDs of the error parsers associated
+ * with this configuration.
+ *
+ * @return String[]
+ */
+ public String[] getErrorParserList();
+
/**
* Projects have C or CC natures. Tools can specify a filter so they are not
* misapplied to a project. This method allows the caller to retrieve a list
* of tools from a project that are correct for a project's nature.
*
- * @param project the project to filter for
* @return an array of ITools
that have compatible filters
- * for the specified project
+ * for this configuration.
*/
- ITool[] getFilteredTools(IProject project);
+ ITool[] getFilteredTools();
/**
- * Returns the resource that owns the target that owns the configuration.
- * @return
+ * Returns the managed-project parent of this configuration, if this is a
+ * project configuration. Otherwise, returns null
.
+ *
+ * @return IManagedProject
+ */
+ public IManagedProject getManagedProject();
+
+ /**
+ * Returns the Eclipse project that owns the configuration.
+ *
+ * @return IResource
*/
public IResource getOwner();
/**
- * Answers the configuration that the receiver is based on.
+ * Returns the configuration that this configuration is based on.
*
- * @return
+ * @return IConfiguration
*/
public IConfiguration getParent();
/**
- * Returns the target for this configuration.
+ * Returns the project-type parent of this configuration, if this is an
+ * extension configuration. Otherwise, returns null
.
*
- * @return
+ * @return IProjectType
*/
- public ITarget getTarget();
+ public IProjectType getProjectType();
/**
- * Answers the ITool
in the receiver with the same
- * id as the argument, or null
.
+ * Returns the resource configuration child of this configuration
+ * that is associated with the project resource, or null
if none.
+ *
+ * @return IResourceConfiguration
+ */
+ public IResourceConfiguration getResourceConfiguration(String path);
+
+ /**
+ * Returns the resource configuration children of this configuration.
+ *
+ * @return IResourceConfigurations[]
+ */
+ public IResourceConfiguration[] getResourceConfigurations();
+
+ /**
+ * Returns the ITool
in this configuration's tool-chain with
+ * the same id as the argument, or null
.
*
* @param id unique identifier to search for
- * @return
+ * @return ITool
*/
- public ITool getToolById(String id);
+ public ITool getTool(String id);
/**
- * Returns the tools that are used in this configuration.
+ * Returns the IToolChain
child of this configuration.
*
- * @return
+ * @return IToolChain
+ */
+ public IToolChain getToolChain();
+
+ /**
+ * Returns the command-line invocation command for the specified tool.
+ *
+ * @param tool The tool that will have its command retrieved.
+ * @return String The command
+ */
+ public String getToolCommand(ITool tool);
+
+ /**
+ * Returns the tools that are used in this configuration's tool-chain.
+ *
+ * @return ITool[]
*/
public ITool[] getTools();
/**
- * Answers true
the receiver has changes that need to be saved
- * in the project file, else false
.
+ * Returns true
if this configuration has overridden the default build
+ * build command in this configuration, otherwise false
.
+ *
+ * @return boolean
+ */
+ public boolean hasOverriddenBuildCommand();
+
+ /**
+ * Returns true
if this configuration has changes that need to
+ * be saved in the project file, else false
.
+ * Should not be called for an extension configuration.
*
* @return boolean
*/
public boolean isDirty();
+
+ /**
+ * Returns true
if this configuration was loaded from a manifest file,
+ * and false
if it was loaded from a project (.cdtbuild) file.
+ *
+ * @return boolean
+ */
+ public boolean isExtensionElement();
/**
- * Answers whether the receiver has been changed and requires the
+ * Returns whether this configuration has been changed and requires the
* project to be rebuilt.
*
- * @return true
if the receiver contains a change
- * that needs the project to be rebuilt
+ * @return true
if the configuration contains a change
+ * that needs the project to be rebuilt.
+ * Should not be called for an extension configuration.
*/
public boolean needsRebuild();
/**
+ * Removes a resource configuration from the configuration's list.
+ *
+ * @param option
+ */
+ public void removeResourceConfiguration(IResourceConfiguration resConfig);
+
+ /**
+ * Set (override) the extension that should be appended to the build artifact
+ * for the receiver.
+ *
+ * @param extension
+ */
+ public void setArtifactExtension(String extension);
+
+ /**
+ * Set the name of the artifact that will be produced when the receiver
+ * is built.
+ *
+ * @param name
+ */
+ public void setArtifactName(String name);
+
+ /**
+ * Sets the arguments to be passed to the build utility used by the
+ * receiver to produce a build goal.
+ *
+ * @param makeArgs
+ */
+ public void setBuildArguments(String makeArgs);
+
+ /**
+ * Sets the build command for the receiver to the value in the argument.
+ *
+ * @param command
+ */
+ public void setBuildCommand(String command);
+
+ /**
+ * Sets the command used to clean the outputs of this configuration.
+ *
+ * @param name
+ */
+ public void setCleanCommand(String command);
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
* @param isDirty
*/
public void setDirty(boolean isDirty);
+ /**
+ * Sets the semicolon separated list of error parser ids
+ *
+ * @param ids
+ */
+ public void setErrorParserIds(String ids);
+
/**
* Sets the name of the receiver to the value specified in the argument
*
* @param name
*/
public void setName(String name);
-
+
/**
* Sets the value of a boolean option for this configuration.
*
+ * @param tool The Tool parent of the option.
* @param option The option to change.
* @param value The value to apply to the option.
*
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
* @throws BuildException
*/
- public void setOption(IOption option, boolean value)
+ public IOption setOption(ITool tool, IOption option, boolean value)
throws BuildException;
/**
* Sets the value of a string option for this configuration.
*
+ * @param tool The Tool parent of the option.
* @param option The option that will be effected by change.
* @param value The value to apply to the option.
*
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
* @throws BuildException
*/
- public void setOption(IOption option, String value)
+ public IOption setOption(ITool tool, IOption option, String value)
throws BuildException;
/**
* Sets the value of a list option for this configuration.
*
+ * @param tool The Tool parent of the option.
* @param option The option to change.
* @param value The values to apply to the option.
*
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
* @throws BuildException
*/
- public void setOption(IOption option, String[] value)
+ public IOption setOption(ITool tool, IOption option, String[] value)
throws BuildException;
/**
- * Sets the rebuild state in the receiver.
+ * Sets the rebuild state in this configuration.
*
* @param rebuild true
will force a rebuild the next time the project builds
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
@@ -137,11 +344,10 @@ public interface IConfiguration extends IBuildObject {
void setRebuildState(boolean rebuild);
/**
- * Overrides the tool command for a tool defined in the receiver.
+ * Overrides the tool command for a tool defined in this configuration's tool-chain.
*
- * @param tool The tool that will have its command modified
+ * @param tool The tool that will have its command modified.
* @param command The command
*/
public void setToolCommand(ITool tool, String command);
-
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfigurationV2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfigurationV2.java
new file mode 100644
index 00000000000..4bf14b3c477
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfigurationV2.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 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.managedbuilder.core;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * This class represents a project configuration in the old (CDT 2.0)
+ * managed build system model.
+ *
+ * The configuration contains one or more children of type tool-reference.
+ *
+ * This class was deprecated in 2.1
+ */
+public interface IConfigurationV2 extends IBuildObject {
+ // Schema element names
+ public static final String CONFIGURATION_ELEMENT_NAME = "configuration"; //$NON-NLS-1$
+ public static final String TOOLREF_ELEMENT_NAME = "toolReference"; //$NON-NLS-1$
+ public static final String PARENT = "parent"; //$NON-NLS-1$
+
+ /**
+ * Projects have C or CC natures. Tools can specify a filter so they are not
+ * misapplied to a project. This method allows the caller to retrieve a list
+ * of tools from a project that are correct for a project's nature.
+ *
+ * @param project the project to filter for
+ * @return an array of ITools
that have compatible filters
+ * for the specified project
+ */
+ ITool[] getFilteredTools(IProject project);
+
+ /**
+ * Returns the resource that owns the project that owns the configuration.
+ * @return
+ */
+ public IResource getOwner();
+
+ /**
+ * Answers the configuration that this configuration is based on.
+ *
+ * @return
+ */
+ public IConfigurationV2 getParent();
+
+ /**
+ * Returns the target for this configuration.
+ *
+ * @return
+ */
+ public ITarget getTarget();
+
+ /**
+ * Answers the ITool
in the receiver with the same
+ * id as the argument, or null
.
+ *
+ * @param id unique identifier to search for
+ * @return ITool
+ */
+ public ITool getToolById(String id);
+
+ /**
+ * Returns the tools that are used in this configuration.
+ *
+ * @return ITool[]
+ */
+ public ITool[] getTools();
+
+ /**
+ * Returns the tool references that are children of this configuration.
+ *
+ * @return
+ */
+ public IToolReference[] getToolReferences();
+
+ /**
+ * Answers true
the receiver has changes that need to be saved
+ * in the project file, else false
.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Answers whether the receiver has been changed and requires the
+ * project to be rebuilt.
+ *
+ * @return true
if the receiver contains a change
+ * that needs the project to be rebuilt
+ */
+ public boolean needsRebuild();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Sets the name of the receiver to the value specified in the argument
+ *
+ * @param name
+ */
+ public void setName(String name);
+
+ /**
+ * Sets the value of a boolean option for this configuration.
+ *
+ * @param option The option to change.
+ * @param value The value to apply to the option.
+ *
+ * @throws BuildException
+ */
+ public void setOption(IOption option, boolean value)
+ throws BuildException;
+
+ /**
+ * Sets the value of a string option for this configuration.
+ *
+ * @param option The option that will be effected by change.
+ * @param value The value to apply to the option.
+ *
+ * @throws BuildException
+ */
+ public void setOption(IOption option, String value)
+ throws BuildException;
+
+ /**
+ * Sets the value of a list option for this configuration.
+ *
+ * @param option The option to change.
+ * @param value The values to apply to the option.
+ *
+ * @throws BuildException
+ */
+ public void setOption(IOption option, String[] value)
+ throws BuildException;
+
+ /**
+ * Sets the rebuild state in the receiver.
+ *
+ * @param rebuild true
will force a rebuild the next time the project builds
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
+ */
+ void setRebuildState(boolean rebuild);
+
+ /**
+ * Overrides the tool command for a tool defined in the receiver.
+ *
+ * @param tool The tool that will have its command modified
+ * @param command The command
+ */
+ public void setToolCommand(ITool tool, String command);
+
+ /**
+ * Sets the configuration that was created from this V2.0 configuration.
+ *
+ * @param config
+ */
+ public void setCreatedConfig(IConfiguration config);
+
+ /**
+ * Returns the configuration that was created from this V2.0 configuration.
+ *
+ * @return IConfiguration
+ */
+ public IConfiguration getCreatedConfig();
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
index 3ae0c4885bb..050e857054d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedBuildInfo.java
@@ -1,5 +1,3 @@
-package org.eclipse.cdt.managedbuilder.core;
-
/**********************************************************************
* Copyright (c) 2003,2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
@@ -10,15 +8,35 @@ package org.eclipse.cdt.managedbuilder.core;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
import java.util.List;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
+/*
+ * There is a ManagedBuildInfo per CDT managed build project. Here are
+ * some notes on their usage:
+ * o You can look up the managed build info associated with a CDT
+ * project by using ManagedBuildManager.getBuildInfo(IProject).
+ * o Given a ManagedBuildInfo, you can retrieve the associated CDT
+ * managed build system project by using getManagedProject.
+ * o The usage model of a ManagedBuildInfo is:
+ * 1. Call setDefaultConfiguration to set the context
+ * 2. Call other methods (e.g. getBuildArtifactName) which get
+ * information from the default configuration, and the other managed
+ * build system model elements that can be reached from the
+ * configuration.
+ */
public interface IManagedBuildInfo {
public static final String DEFAULT_CONFIGURATION = "defaultConfig"; //$NON-NLS-1$
public static final String DEFAULT_TARGET = "defaultTarget"; //$NON-NLS-1$
+ /*
+ * Note: "Target" routines are only currently applicable when loading a CDT 2.0
+ * or earlier managed build project file (.cdtbuild)
+ */
+
/**
* Add a new target to the build information for the receiver
*
@@ -35,6 +53,28 @@ public interface IManagedBuildInfo {
*/
public boolean buildsFileType(String srcExt);
+ /**
+ * Returns IManagedCommandLineInfo
for source with extension
+ * @param sourceExtension - source extension
+ * @param flags - build flags
+ * @param outputFlag - output flag for build tool
+ * @param outputPrefix
+ * @param outputName
+ * @param inputResources
+ * @return IManagedCommandLineInfo
+ */
+ public IManagedCommandLineInfo generateCommandLineInfo( String sourceExtension, String[] flags,
+ String outputFlag, String outputPrefix, String outputName, String[] inputResources );
+
+ /**
+ * Answers a String
containing the arguments to be passed to make.
+ * For example, if the user has selected a build that keeps going on error, the
+ * answer would contain {"-k"}.
+ *
+ * @return String
+ */
+ public String getBuildArguments();
+
/**
* Answers the file extension for the receivers build goal without a separator.
@@ -50,6 +90,12 @@ public interface IManagedBuildInfo {
*/
public String getBuildArtifactName();
+ /**
+ * Answers a String
containing the make command invocation
+ * for the default configuration.
+ */
+ public String getBuildCommand();
+
/**
* Answers the command needed to remove files on the build machine
*
@@ -67,7 +113,7 @@ public interface IManagedBuildInfo {
/**
* Answers a String
array containing the names of all the configurations
- * defined for the project's current target.
+ * defined for the project.
*
* @return
*/
@@ -78,21 +124,23 @@ public interface IManagedBuildInfo {
*
* @return
*/
- public IConfiguration getDefaultConfiguration(ITarget target);
-
-
- /**
- * Returns the default target in the receiver.
- *
- * @return
- */
- public ITarget getDefaultTarget();
+ public IConfiguration getDefaultConfiguration();
/**
* @param sourceExtension
* @return
*/
public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension);
+
+ /**
+ * Returns a String
containing the flags, including
+ * those overridden by the user, for the tool in the configuration
+ * defined by the argument.
+ *
+ * @param extension
+ * @return
+ */
+ public String getFlagsForConfiguration(String extension);
/**
* Returns a String
containing the flags, including
@@ -104,38 +152,20 @@ public interface IManagedBuildInfo {
*/
public String getFlagsForSource(String extension);
- /**
- * Returns a String
containing the flags, including
- * those overridden by the user, for the tool that handles the
- * type of target defined by the argument.
- *
- * @param extension
- * @return
- */
- public String getFlagsForTarget(String extension);
-
/**
* Answers the libraries the project links in.
*
* @param extension
* @return
*/
- public String[] getLibsForTarget(String extension);
+ public String[] getLibsForConfiguration(String extension);
/**
- * Answers a String
containing the arguments to be passed to make.
- * For example, if the user has selected a build that keeps going on error, the
- * answer would contain {"-k"}.
+ * Returns the ManagedProject associated with this build info
*
- * @return String
+ * @return IManagedProject
*/
- public String getMakeArguments();
-
- /**
- * Answers a String
containing the make command invocation
- * for the default target/configuration.
- */
- public String getMakeCommand();
+ public IManagedProject getManagedProject( );
/**
* Answers the extension that will be built by the current configuration
@@ -168,12 +198,12 @@ public interface IManagedBuildInfo {
public String getOutputPrefix(String outputExtension);
/**
- * Get the currently selected target. This is used while the project
+ * Returns the currently selected configuration. This is used while the project
* property pages are displayed
*
- * @return target
+ * @return IConfiguration
*/
- public ITarget getSelectedTarget();
+ public IConfiguration getSelectedConfiguration();
/**
* Get the target specified in the argument.
@@ -190,6 +220,15 @@ public interface IManagedBuildInfo {
*/
public List getTargets();
+ /**
+ * Returns a String
containing the command-line invocation
+ * for the tool associated with the extension.
+ *
+ * @param extension the file extension of the build goal
+ * @return a String containing the command line invocation for the tool
+ */
+ public String getToolForConfiguration(String extension);
+
/**
* Returns a String
containing the command-line invocation
* for the tool associated with the source extension.
@@ -198,15 +237,6 @@ public interface IManagedBuildInfo {
* @return a String containing the command line invocation for the tool
*/
public String getToolForSource(String sourceExtension);
-
- /**
- * Returns a String
containing the command-line invocation
- * for the tool associated with the target extension.
- *
- * @param extension the file extension of the build goal
- * @return a String containing the command line invocation for the tool
- */
- public String getToolForTarget(String extension);
/**
* Answers a String
array containing the contents of the
@@ -215,7 +245,7 @@ public interface IManagedBuildInfo {
* @param extension the file ecxtension of the build target
* @return
*/
- public String[] getUserObjectsForTarget(String extension);
+ public String[] getUserObjectsForConfiguration(String extension);
/**
@@ -234,12 +264,20 @@ public interface IManagedBuildInfo {
/**
* Answers true
if the extension matches one of the special
- * file extensions the tools for the target consider to be a header file.
+ * file extensions the tools for the configuration consider to be a header file.
*
* @param ext the file extension of the resource
* @return boolean
*/
public boolean isHeaderFile(String ext);
+
+ /**
+ * gets the read only status of Managed Build Info
+ *
+ * @return true
if Managed Build Info is read only
+ * otherwise returns false
+ */
+ public boolean isReadOnly();
/**
@@ -275,19 +313,26 @@ public interface IManagedBuildInfo {
*/
public boolean setDefaultConfiguration(String configName);
- /**
- * Set the primary target for the receiver.
- *
- * @param target
- */
- public void setDefaultTarget(ITarget target);
-
/**
* Set the dirty flag for the build model to the value of the argument.
*
* @param isDirty
*/
public void setDirty(boolean isDirty);
+
+ /**
+ * Sets the ManagedProject associated with this build info
+ *
+ * @param project
+ */
+ public void setManagedProject(IManagedProject project);
+
+ /**
+ * sets the read only status of Managed Build Info
+ *
+ * @param readOnly
+ */
+ public void setReadOnly(boolean readOnly);
/**
* Sets the rebuild state in the receiver to the value of the argument.
@@ -300,10 +345,10 @@ public interface IManagedBuildInfo {
public void setRebuildState(boolean rebuild);
/**
- * Set the currently selected target. This is used while the project
+ * Sets the currently selected configuration. This is used while the project
* property pages are displayed
*
- * @param target the user selection
+ * @param configuration the user selection
*/
- public void setSelectedTarget(ITarget target);
+ public void setSelectedConfiguration(IConfiguration configuration);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedCommandLineGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedCommandLineGenerator.java
new file mode 100644
index 00000000000..40dc49ab54f
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedCommandLineGenerator.java
@@ -0,0 +1,28 @@
+/**********************************************************************
+ * 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.managedbuilder.core;
+
+public interface IManagedCommandLineGenerator {
+ /**
+ *
+ * @param tool
+ * @param commandNamee
+ * @param flags
+ * @param outputFlag
+ * @param outputPrefix
+ * @param outputName
+ * @param inputResources
+ * @param commandLinePattern
+ * @return
+ */
+ public IManagedCommandLineInfo generateCommandLineInfo( ITool tool, String commandName, String[] flags,
+ String outputFlag, String outputPrefix, String outputName, String[] inputResources, String commandLinePattern );
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedCommandLineInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedCommandLineInfo.java
new file mode 100644
index 00000000000..0b21a64dacd
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedCommandLineInfo.java
@@ -0,0 +1,61 @@
+/**********************************************************************
+ * 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.managedbuilder.core;
+
+public interface IManagedCommandLineInfo {
+ /**
+ * provide fully qualified command line string for tool invokation
+ * @return command line
+ */
+ public String getCommandLine();
+
+ /**
+ * give command line pattern
+ * @return
+ */
+ public String getCommandLinePattern();
+
+ /**
+ * provide tool name
+ * @return
+ */
+ public String getCommandName();
+
+ /**
+ * give command flags
+ * @return
+ */
+ public String getFlags();
+
+ /**
+ * provide list of resources used by tool for transformation
+ * @return
+ */
+ public String getInputs();
+
+ /**
+ * return output file name
+ * @return
+ */
+ public String getOutput();
+
+ /**
+ * give command flag to generate output
+ * @return
+ */
+ public String getOutputFlag();
+
+ /**
+ * return output prefix
+ * @return
+ */
+ public String getOutputPrefix();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java
new file mode 100644
index 00000000000..1beb1aa3754
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java
@@ -0,0 +1,147 @@
+/**********************************************************************
+ * 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.managedbuilder.core;
+
+import org.eclipse.core.resources.IResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * This class represents a project instance in the managed build system.
+ * Project instances are stored in the .cdtbuild file. Note that there
+ * is no reason to define a project element in a manifest file – it
+ * would never be used.
+ *
+ * The following steps occur when a CDT user creates a new Managed Build + * project: + * 1. A new project element is created. Its projectType attribute is set + * to the projectType that the user selected. Its name attribute is + * set to the project name that the user entered. + * 2. When the user adds a default configuration, a configuration + * element is created as a child of the project element created in + * step 1. + * 3. Add a tool-chain element that specifies as its superClass the + * tool-chain that is the child of the selected configuration element. + * 4. For each tool element child of the tool-chain that is the child of + * the selected configuration element, create a tool element child of + * the cloned configuration’s tool-chain element that specifies the + * original tool element as its superClass. + * This prepares the new project/configurations for modification by the user. + * + * @since 2.1 + */ +public interface IManagedProject extends IBuildObject { + public static final String MANAGED_PROJECT_ELEMENT_NAME = "project"; //$NON-NLS-1$ + public static final String PROJECTTYPE = "projectType"; //$NON-NLS-1$ + + /** + * Creates a configuration for this project populated with the tools + * and options settings from the parent configuration. As options and + * tools change in the parent, unoverridden values are updated in the + * child configuration as well. + *
+ * This method performs steps 3 & 4 described above.
+ *
+ * @param parent The IConfiguration
to use as a settings template
+ * @param id The unique id the new configuration will have
+ * @return IConfiguration of the new configuration
+ */
+ public IConfiguration createConfiguration(IConfiguration parent, String id);
+
+ /**
+ * Creates a configuration for this project populated with the tools
+ * and options settings from the parent configuration. As opposed to the
+ * createConfiguration
method, this method creates a configuration
+ * from an existing configuration in the project.
+ *
+ * In this case, the new configuration is cloned from the existing configuration,
+ * and does not retain a pointer to the existing configuration.
+ *
+ * @param parent The IConfiguration
to clone
+ * @param id The unique id the new configuration will have
+ * @return IConfiguration of the new configuration
+ */
+ public IConfiguration createConfigurationClone(IConfiguration parent, String id);
+
+ /**
+ * Removes the configuration with the ID specified in the argument.
+ *
+ * @param id The unique id of the configuration
+ */
+ public void removeConfiguration(String id);
+
+ /**
+ * Returns all of the configurations defined by this project-type.
+ *
+ * @return IConfiguration[]
+ */
+ public IConfiguration[] getConfigurations();
+
+ /**
+ * Returns the configuration with the given id, or null
if not found.
+ *
+ * @param id The unique id of the configuration
+ * @return IConfiguration
+ */
+ public IConfiguration getConfiguration(String id);
+
+ /**
+ * Answers the IProjectType
that is the superclass of this
+ * project-type, or null
if the attribute was not specified.
+ *
+ * @return IProjectType
+ */
+ public IProjectType getProjectType();
+
+ /**
+ * Returns the owner of the managed project (an IProject).
+ *
+ * @return IResource
+ */
+ public IResource getOwner();
+
+ /**
+ * Sets the owner of the managed project.
+ *
+ * @param resource
+ */
+ public void updateOwner(IResource resource);
+
+ /**
+ * Returns true
if this project has changes that need to
+ * be saved in the project file, else false
.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Persist the managed project to the project file (.cdtbuild).
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element);
+
+ /**
+ * Returns the default build artifact name for the project
+ *
+ * @return String
+ */
+ public String getDefaultArtifactName();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java
index 09605b5352c..1894974e2b9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java
@@ -31,9 +31,16 @@ public interface IOption extends IBuildObject {
public static final String FILE = "file"; //$NON-NLS-1$
public static final int BROWSE_DIR = 2;
public static final String DIR = "directory"; //$NON-NLS-1$
+
+ // Resource Filter type
+ public static final int FILTER_ALL = 0;
+ public static final String ALL = "all"; //$NON-NLS-1$
+ public static final int FILTER_FILE = 1;
+ public static final int FILTER_PROJECT = 2;
+ public static final String PROJECT = "project"; //$NON-NLS-1$
// Schema attribute names for option elements
- public static final String BROSWE_TYPE = "browseType"; //$NON-NLS-1$
+ public static final String BROWSE_TYPE = "browseType"; //$NON-NLS-1$
public static final String CATEGORY = "category"; //$NON-NLS-1$
public static final String COMMAND = "command"; //$NON-NLS-1$
public static final String COMMAND_FALSE = "commandFalse"; //$NON-NLS-1$
@@ -41,6 +48,7 @@ public interface IOption extends IBuildObject {
public static final String ENUM_VALUE = "enumeratedOptionValue"; //$NON-NLS-1$
public static final String IS_DEFAULT = "isDefault"; //$NON-NLS-1$
public static final String LIST_VALUE = "listOptionValue"; //$NON-NLS-1$
+ public static final String RESOURCE_FILTER = "resourceFilter"; //$NON-NLS-1$
public static final String TYPE_BOOL = "boolean"; //$NON-NLS-1$
public static final String TYPE_ENUM = "enumerated"; //$NON-NLS-1$
public static final String TYPE_INC_PATH = "includePath"; //$NON-NLS-1$
@@ -48,12 +56,28 @@ public interface IOption extends IBuildObject {
public static final String TYPE_STRING = "string"; //$NON-NLS-1$
public static final String TYPE_STR_LIST = "stringList"; //$NON-NLS-1$
public static final String TYPE_USER_OBJS = "userObjs"; //$NON-NLS-1$
+ public static final String TYPE_DEFINED_SYMBOLS = "definedSymbols"; //$NON-NLS-1$
+ public static final String VALUE = "value"; //$NON-NLS-1$
public static final String VALUE_TYPE = "valueType"; //$NON-NLS-1$
// Schema attribute names for listOptionValue elements
public static final String LIST_ITEM_VALUE = "value"; //$NON-NLS-1$
public static final String LIST_ITEM_BUILTIN = "builtIn"; //$NON-NLS-1$
+ /**
+ * Returns the tool defining this option.
+ *
+ * @return ITool
+ */
+ public ITool getParent();
+
+ /**
+ * Returns the IOption
that is the superclass of this
+ * option, or null
if the attribute was not specified.
+ *
+ * @return IOption
+ */
+ public IOption getSuperClass();
/**
* If this option is defined as an enumeration, this function returns
@@ -74,10 +98,33 @@ public interface IOption extends IBuildObject {
public boolean getBooleanValue() throws BuildException;
/**
- * @return
+ * Returns the setting of the browseType attribute
+ *
+ * @return int
*/
public int getBrowseType();
+ /**
+ * Sets the browseType attribute.
+ *
+ * @param int
+ */
+ public void setBrowseType(int type);
+
+ /**
+ * Returns the setting of the resourceFilter attribute
+ *
+ * @return int
+ */
+ public int getResourceFilter();
+
+ /**
+ * Sets the resourceFilter attribute.
+ *
+ * @param int
+ */
+ public void setResourceFilter(int filter);
+
/**
* Answers an array of strings containing the built-in values
* defined for a stringList, includePaths, definedSymbols, or libs
@@ -95,6 +142,13 @@ public interface IOption extends IBuildObject {
*/
public IOptionCategory getCategory();
+ /**
+ * Sets the category for this option.
+ *
+ * @param IOptionCategory
+ */
+ public void setCategory(IOptionCategory category);
+
/**
* Answers a String
containing the actual command line
* option associated with the option
@@ -103,12 +157,28 @@ public interface IOption extends IBuildObject {
*/
public String getCommand();
+ /**
+ * Sets a String
containing the actual command line
+ * option associated with the option
+ *
+ * @param String
+ */
+ public void setCommand(String command);
+
/**
* Answers a String
containing the actual command line
* option associated with a Boolean option when the value is False
* @return String
*/
public String getCommandFalse();
+
+ /**
+ * Sets a String
containing the actual command line
+ * option associated with a Boolean option when the value is False
+ *
+ * @param String
+ */
+ public void setCommandFalse(String commandFalse);
/**
* Answers the user-defined preprocessor symbols.
@@ -127,20 +197,20 @@ public interface IOption extends IBuildObject {
*
* @return
*/
- public String getEnumCommand (String id);
+ public String getEnumCommand (String id) throws BuildException;
/**
* Answers the "name" associated with the enumeration id.
*
* @return
*/
- public String getEnumName (String id);
+ public String getEnumName (String id) throws BuildException;
/**
* @param name
* @return
*/
- public String getEnumeratedId(String name);
+ public String getEnumeratedId(String name) throws BuildException;
/**
* Answers an array of String
containing the includes paths
@@ -151,7 +221,6 @@ public interface IOption extends IBuildObject {
*/
public String[] getIncludePaths() throws BuildException;
-
/**
* Answers an array or String
s containing the libraries
* that must be linked into the project.
@@ -188,15 +257,7 @@ public interface IOption extends IBuildObject {
* @throws BuildException
*/
public String getStringValue() throws BuildException;
-
- /**
- * Returns the tool defining this option.
- *
- * @return ITool
- */
- public ITool getTool();
-
-
+
/**
* Answers all of the user-defined object files that must be linked with
* the final build target.
@@ -206,11 +267,91 @@ public interface IOption extends IBuildObject {
*/
public String [] getUserObjects() throws BuildException;
+ /**
+ * Returns the raw value of this option.
+ *
+ * @return Object The Object that contains the raw value of the option. The type
+ * of Object is specific to the option type.
+ */
+ public Object getValue();
+
+ /**
+ * Returns the raw default value of this option.
+ *
+ * @return Object The Object that contains the raw default value of the option. The type
+ * of Object is specific to the option type.
+ */
+ public Object getDefaultValue();
+
/**
* Get the type for the value of the option.
*
* @return int
*/
- public int getValueType();
+ public int getValueType() throws BuildException;
+ /**
+ * Sets the boolean value of the receiver to the value specified in the argument.
+ * If the receiver is not a reference to a boolean option, method will throw an
+ * exception.
+ *
+ * @param value
+ * @throws BuildException
+ */
+ public void setValue(boolean value) throws BuildException;
+
+ /**
+ * Sets the string value of the receiver to the value specified in the argument.
+ *
+ * @param value
+ * @throws BuildException
+ */
+ public void setValue(String value) throws BuildException;
+
+ /**
+ * Sets the value of the receiver to be an array of strings.
+ *
+ * @param value An array of strings to place in the option reference.
+ * @throws BuildException
+ */
+ public void setValue(String [] value) throws BuildException;
+
+ /**
+ * Sets the raw value of this option.
+ *
+ * @param v The Object that contains the raw value of the option. The type
+ * of Object is specific to the option type.
+ */
+ public void setValue(Object v);
+
+ /**
+ * Sets the default value of this option.
+ *
+ * @param v The Object that contains the default value of the option. The type
+ * of Object is specific to the option type.
+ */
+ public void setDefaultValue(Object v);
+
+ /**
+ * Sets the value-type of this option. Use with care.
+ *
+ * @param type
+ */
+ public void setValueType(int type);
+
+ /**
+ * Returns true
if this option was loaded from a manifest file,
+ * and false
if it was loaded from a project (.cdtbuild) file.
+ *
+ * @return boolean
+ */
+ public boolean isExtensionElement();
+
+ /**
+ * Returns true
if this option only oveerides the value attribute
+ * of its superclass and false
if it overrides other attributes.
+ *
+ * @return boolean
+ */
+ public boolean overridesOnlyValue();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java
index 748f44db220..f8bd5a00b9d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOptionCategory.java
@@ -17,6 +17,13 @@ public interface IOptionCategory extends IBuildObject {
// Schema element names
public static final String OWNER = "owner"; //$NON-NLS-1$
+
+// Resource Filter type
+ public static final int FILTER_ALL = 0;
+ public static final String ALL = "all"; //$NON-NLS-1$
+ public static final int FILTER_FILE = 1;
+ public static final int FILTER_PROJECT = 2;
+ public static final String PROJECT = "project"; //$NON-NLS-1$
/**
* Returns the list of children of this node in the option category tree
@@ -26,12 +33,14 @@ public interface IOptionCategory extends IBuildObject {
public IOptionCategory[] getChildCategories();
/**
- * Returns the options in this category for a given configuration.
+ * Returns an array of ITool/IOption pairs for the options in this category
+ * for a given configuration.
*
* @param tool
- * @return
+ * @return Object[][]
*/
- public IOption[] getOptions(IConfiguration configuration);
+ public Object[][] getOptions(IConfiguration configuration);
+ public Object[][] getOptions(IResourceConfiguration resConfig);
/**
* Returns the category that owns this category, or null if this is the
@@ -47,4 +56,19 @@ public interface IOptionCategory extends IBuildObject {
* @return
*/
public ITool getTool();
+
+ /**
+ * Returns true
if this element has changes that need to
+ * be saved in the project file, else false
.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java
new file mode 100644
index 00000000000..f139b73d8f9
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java
@@ -0,0 +1,131 @@
+/**********************************************************************
+ * 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.managedbuilder.core;
+
+/**
+ * This class represents project-types in the managed build system.
+ * A project-type is a tool-integrator defined class of project which
+ * acts as a template for the projects that a user will create.
+ * The project-type contains one or more children of type configuration.
+ * These are the default configurations that the user can choose from.
+ * Note that there is no reason to define a project-type element in a
+ * .cdtbuild file. It would never be used since project-type elements
+ * are used to primarily populate the "New Project" dialog boxes.
+ * Project types can be arranged into hierarchies to promote the efficient
+ * sharing of configurations. If you have defined a project type that
+ * should not be selected by the user, but is a root for other project
+ * types, it may be declared abstract by setting the isAbstract attribute
+ * to ‘true’. Abstract project types do not appear in the UI. You must
+ * provide a unique identifier for the project type in the id attribute.
+ * Children of the abstract project type will have the same configurations
+ * that the abstract project type has, unless they are explicitly named
+ * in the unusedChildren attribute of the child project. For these
+ * children to function properly, their superClass attribute must contain
+ * the unique identifier of the super class project type.
+ * A concrete project type must have at least one configuration defined
+ * for it. A project type must also define (or inherit) a set of tool-chain
+ * definitions that work together to produce the build goal as an output.
+ * You must also provide a meaningful name that will be displayed to the
+ * user in the UI and New Project wizards.
+ *
+ * @since 2.1
+ */
+public interface IProjectType extends IBuildObject {
+ public static final String PROJECTTYPE_ELEMENT_NAME = "projectType"; //$NON-NLS-1$
+ public static final String SUPERCLASS = "superClass"; //$NON-NLS-1$
+ public static final String IS_ABSTRACT = "isAbstract"; //$NON-NLS-1$
+ public static final String UNUSED_CHILDREN = "unusedChildren"; //$NON-NLS-1$
+ public static final String IS_TEST = "isTest"; //$NON-NLS-1$
+
+ /**
+ * Creates a configuration for this project-type populated with the tools
+ * and options settings from the parent configuration. As options and
+ * tools change in the parent, unoverridden values are updated in the
+ * child configuration as well.
+ *
+ * NOTE: This routine affects the in-memory representation of the
+ * project-type, but since project-types are never written to the
+ * .cdtbuild file, the manifest definition does not change.
+ *
+ * @param parent The IConfiguration
to use as a settings template
+ * @param id The unique id the new configuration will have
+ * @param name The name the new configuration will have
+ * @return IConfiguration of the new configuration
+ */
+ public IConfiguration createConfiguration(IConfiguration parent, String id, String name);
+
+ /**
+ * Removes the configuration with the ID specified in the argument.
+ *
+ * NOTE: This routine affects the in-memory representation of the
+ * project-type, but since project-types are never written to the
+ * .cdtbuild file, the manifest definition does not change.
+ *
+ * @param id The unique id of the configuration
+ */
+ public void removeConfiguration(String id);
+
+ /**
+ * Returns all of the configurations defined by this project-type.
+ *
+ * @return IConfiguration[]
+ */
+ public IConfiguration[] getConfigurations();
+
+ /**
+ * Returns the configuration with the given id, or null
if not found.
+ *
+ * @param id The unique id of the configuration
+ * @return IConfiguration
+ */
+ public IConfiguration getConfiguration(String id);
+
+ /**
+ * Returns the IProjectType
that is the superclass of this
+ * project-type, or null
if the attribute was not specified.
+ *
+ * @return IProjectType
+ */
+ public IProjectType getSuperClass();
+
+ /**
+ * Returns whether this element is abstract. Returns false
+ * if the attribute was not specified.
+ * @return boolean
+ */
+ public boolean isAbstract();
+
+ /**
+ * Sets the isAbstract attribute of the tool-chain.
+ *
+ * @param b
+ */
+ public void setIsAbstract(boolean b);
+
+ /**
+ * Returns a semi-colon delimited list of child Ids of the superclass'
+ * children that should not be automatically inherited by this element.
+ * Returns an empty string if the attribute was not specified.
+ * @return String
+ */
+ public String getUnusedChildren();
+
+ /**
+ * Returns true
if the project-type is defined
+ * for testing purposes only, else false
. A test project-type will
+ * not be shown in the UI but can still be manipulated programmatically.
+ * Returns false
if the attribute was not specified.
+ *
+ * @return boolean
+ */
+ public boolean isTestProjectType();
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceConfiguration.java
new file mode 100644
index 00000000000..431a5af65ec
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IResourceConfiguration.java
@@ -0,0 +1,171 @@
+/**********************************************************************
+ * 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.managedbuilder.core;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * This class is a place to define build attributes of individual
+ * resources that are different from the configuration as a whole. The
+ * resourceConfiguration element can have multiple tool children. They
+ * define the tool(s) to be used to build the specified resource. The
+ * tool(s) can execute before, after, or instead of the default tool for
+ * the resources (see the toolOrder attribute in the tool element).
+ *
+ * @since 2.1
+ */
+public interface IResourceConfiguration extends IBuildObject {
+ public static final String RESOURCE_CONFIGURATION_ELEMENT_NAME = "resourceConfiguration"; //$NON-NLS-1$
+ public static final String RESOURCE_PATH = "resourcePath"; //$NON-NLS-1$
+ public static final String EXCLUDE = "exclude"; //$NON-NLS-1$
+
+ //TODO: Set name and ID in the constructors to be
+ // configuration-name#resource-path
+
+ /**
+ * Returns the configuration that is the parent of this resource configuration.
+ *
+ * @return IConfiguration
+ */
+ public IConfiguration getParent();
+
+ /**
+ * Returns whether the resource referenced by this element should be excluded
+ * from builds of the parent configuration.
+ * Returns false
if the attribute was not specified.
+ *
+ * @return boolean
+ */
+ public boolean isExcluded();
+
+ /**
+ * Returns the path of the project resource that this element references.
+ * TODO: What is the format of the path? Absolute? Relative? Canonical?
+ *
+ * @return String
+ */
+ public String getResourcePath();
+
+ /**
+ * Sets the "excluded" flag for the resource.
+ * If true
, the project resource identified by the resoursePath
+ * attribute is excluded from the build of the parent configuration.
+ *
+ * @param boolean
+ */
+ public void setExclude(boolean excluded);
+
+ /**
+ * Sets the resource path to which this resource configuration applies.
+ */
+ public void setResourcePath(String path);
+
+ /**
+ * Returns true
if this element has changes that need to
+ * be saved in the project file, else false
.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Returns the list of tools associated with this resource configuration.
+ *
+ * @return ITool[]
+ */
+ public ITool[] getTools();
+
+ /**
+ * Returns the tool in this resource configuration with the ID specified
+ * in the argument, or null
+ *
+ * @param id The ID of the requested tool
+ * @return ITool
+ */
+ public ITool getTool(String id);
+
+ /**
+ * Creates a Tool
child for this resource configuration.
+ *
+ * @param ITool The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ *
+ * @return ITool
+ */
+ public ITool createTool(ITool superClass, String Id, String name, boolean isExtensionElement);
+
+ /**
+ * Overrides the tool command for a tool defined in this resource configuration's tool.
+ *
+ * @param tool The tool that will have its command modified
+ * @param command The command
+ */
+ public void setToolCommand(ITool tool, String command);
+ /**
+ * Sets the value of a boolean option for this resource configuration.
+ *
+ * @param tool The Tool parent of the option.
+ * @param option The option to change.
+ * @param value The value to apply to the option.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
+ * @throws BuildException
+ */
+ public IOption setOption(ITool tool, IOption option, boolean value)
+ throws BuildException;
+
+ /**
+ * Sets the value of a string option for this resource configuration.
+ *
+ * @param tool The Tool parent of the option.
+ * @param option The option that will be effected by change.
+ * @param value The value to apply to the option.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
+ * @throws BuildException
+ */
+ public IOption setOption(ITool tool, IOption option, String value)
+ throws BuildException;
+
+ /**
+ * Sets the value of a list option for this resource configuration.
+ *
+ * @param tool The Tool parent of the option.
+ * @param option The option to change.
+ * @param value The values to apply to the option.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ *
+ * @throws BuildException
+ */
+ public IOption setOption(ITool tool, IOption option, String[] value)
+ throws BuildException;
+
+
+ /**
+ * Returns the Eclipse project that owns the resource configuration.
+ *
+ * @return IResource
+ */
+ public IResource getOwner();
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITarget.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITarget.java
index e1fad3621c8..c6156e20b56 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITarget.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITarget.java
@@ -10,12 +10,15 @@
**********************************************************************/
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;
/**
* This class represents targets for the managed build process. A target
* is some type of resource built using a given collection of tools.
+ *
+ * Note: This class was deprecated in 2.1
*/
public interface ITarget extends IBuildObject {
public static final String TARGET_ELEMENT_NAME = "target"; //$NON-NLS-1$
@@ -39,20 +42,20 @@ public interface ITarget extends IBuildObject {
* change in the parent, unoverridden values are updated in the child
* config as well.
*
- * @param parent The IConfiguration
to use as a settings template
+ * @param parent The IConfigurationV2
to use as a settings template
* @param id The unique id the new configuration will have
- * @return IConfiguration
+ * @return IConfigurationV2
*/
- public IConfiguration createConfiguration(IConfiguration parent, String id);
+ public IConfigurationV2 createConfiguration(IConfigurationV2 parent, String id);
/**
* Creates a new configuration for the target. It is populated with
* the tools defined for that target and options set at their defaults.
*
* @param id id for this configuration.
- * @return IConfiguration
+ * @return IConfigurationV2
*/
- public IConfiguration createConfiguration(String id);
+ public IConfigurationV2 createConfiguration(String id);
/**
* Answers the extension that should be applied to build artifacts created by
@@ -105,9 +108,9 @@ public interface ITarget extends IBuildObject {
/**
* Returns all of the configurations defined by this target.
*
- * @return IConfiguration[]
+ * @return IConfigurationV2[]
*/
- public IConfiguration[] getConfigurations();
+ public IConfigurationV2[] getConfigurations();
/**
* Get the default extension that should be applied to build artifacts
@@ -149,9 +152,9 @@ public interface ITarget extends IBuildObject {
* Returns the configuration with the given id, or null
if not found.
*
* @param id
- * @return IConfiguration
+ * @return IConfigurationV2
*/
- public IConfiguration getConfiguration(String id);
+ public IConfigurationV2 getConfiguration(String id);
/**
* Gets the resource that this target is applied to.
@@ -245,13 +248,6 @@ public interface ITarget extends IBuildObject {
*/
public void removeConfiguration(String id);
- /**
- * Resets the make command in the receiver to the value specified in
- * its parent.
- *
- */
- public void resetMakeCommand();
-
/**
* Set (override) the extension that should be appended to the build artifact
* for the receiver.
@@ -283,7 +279,6 @@ public interface ITarget extends IBuildObject {
*/
public void setMakeCommand(String command);
-
/**
* Sets the semicolon separated list of error parser ids
*
@@ -306,4 +301,18 @@ public interface ITarget extends IBuildObject {
*/
public void updateOwner(IResource resource);
+ /**
+ * Converts a CDT V2.0 target into a ProjectType + Configuration + Toolchain +
+ * Builder + TargetPlatform.
+ *
+ */
+ public void convertToProjectType();
+
+ /**
+ * Returns the ProjectType
that this Target has been converted to,
+ * or null
if it has not been converted.
+ *
+ * @return ProjectType
+ */
+ public ProjectType getCreatedProjectType();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java
new file mode 100644
index 00000000000..8b8ffa30c46
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java
@@ -0,0 +1,130 @@
+/**********************************************************************
+ * 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.managedbuilder.core;
+
+/**
+ * This class defines the os/architecture combination upon which the
+ * outputs of a tool-chain can be deployed. The osList and archList
+ * attributes contain the Eclipse names of the operating systems and
+ * architectures described by this element.
+ *
+ * @since 2.1
+ */
+public interface ITargetPlatform extends IBuildObject {
+ public static final String TARGET_PLATFORM_ELEMENT_NAME = "targetPlatform"; //$NON-NLS-1$
+ public static final String BINARY_PARSER = "binaryParser"; //$NON-NLS-1$
+ public static final String OS_LIST = "osList"; //$NON-NLS-1$
+ public static final String ARCH_LIST = "archList"; //$NON-NLS-1$
+
+ /**
+ * Returns the tool-chain that is the parent of this target platform.
+ *
+ * @return IToolChain
+ */
+ public IToolChain getParent();
+
+ /**
+ * Returns the ITargetPlatform
that is the superclass of this
+ * target platform, or null
if the attribute was not specified.
+ *
+ * @return ITargetPlatform
+ */
+ public ITargetPlatform getSuperClass();
+
+ /**
+ * Returns whether this element is abstract. Returns false
+ * if the attribute was not specified.
+ *
+ * @return boolean
+ */
+ public boolean isAbstract();
+
+ /**
+ * Sets the isAbstract attribute of the target paltform.
+ *
+ * @param b
+ */
+ public void setIsAbstract(boolean b);
+
+ /**
+ * Returns a semi-colon delimited list of child Ids of the superclass'
+ * children that should not be automatically inherited by this element.
+ * Returns an empty string if the attribute was not specified.
+ * @return String
+ */
+ public String getUnusedChildren();
+
+ /**
+ * Returns an array of operating systems this target platform represents.
+ *
+ * @return String[]
+ */
+ public String[] getOSList();
+
+ /**
+ * Sets the OS list.
+ *
+ * @param String[] The list of OS names
+ */
+ public void setOSList(String[] OSs);
+
+ /**
+ * Returns an array of architectures this target platform represents.
+ *
+ * @return String[]
+ */
+ public String[] getArchList();
+
+ /**
+ * Sets the architecture list.
+ *
+ * @param String[] The list of architecture names
+ */
+ public void setArchList(String[] archs);
+
+ /**
+ * Returns the unique ID of the binary parser associated with the target platform.
+ *
+ * @return String
+ */
+ public String getBinaryParserId();
+
+ /**
+ * Sets the string id of the binary parser for this target platform.
+ *
+ * @param id
+ */
+ public void setBinaryParserId(String id);
+
+ /**
+ * Returns true
if this element has changes that need to
+ * be saved in the project file, else false
.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Returns true
if this target platform was loaded from a manifest file,
+ * and false
if it was loaded from a project (.cdtbuild) file.
+ *
+ * @return boolean
+ */
+ public boolean isExtensionElement();
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
index 61c35a33dbc..c5dca6321eb 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java
@@ -13,11 +13,15 @@ package org.eclipse.cdt.managedbuilder.core;
import java.util.List;
/**
- *
+ * 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.
+ * Most tools have a set of options that can be used to modify the behavior of the tool.
*/
public interface ITool extends IBuildObject {
// Schema element names
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 INTERFACE_EXTS = "headerExtensions"; //$NON-NLS-1$
public static final String NATURE = "natureFilter"; //$NON-NLS-1$
public static final String OPTION = "option"; //$NON-NLS-1$
@@ -35,40 +39,30 @@ public interface ITool extends IBuildObject {
public static final int FILTER_BOTH = 2;
/**
- * Return true
if the receiver builds files with the
- * specified extension, else false
.
+ * Returns the tool-chain or resource configuration that is the parent of this tool.
*
- * @param extension file extension of the source
- * @return boolean
+ * @return IBuildObject
*/
- public boolean buildsFileType(String extension);
-
- /**
- * Answers the list of valid source extensions the receiver know how to build.
- * The list may be empty but will never be null
.
- *
- * @return List
- */
- public List getInputExtensions();
+ public IBuildObject getParent();
/**
- * Answers a constant corresponding to the project nature the tool should be used
- * for. Possible answers are:
- *
- *
IOption
from
@@ -101,6 +95,94 @@ public interface ITool extends IBuildObject {
* @return IOption[]
*/
public IOption[] getOptions();
+
+ /**
+ * Returns the ITool
that is the superclass of this
+ * tool, or null
if the attribute was not specified.
+ *
+ * @return ITool
+ */
+ public ITool getSuperClass();
+
+ /**
+ * Returns whether this element is abstract. Returns false
+ * if the attribute was not specified.
+ * @return boolean
+ */
+ public boolean isAbstract();
+
+ /**
+ * Sets the isAbstract attribute of the tool-chain.
+ *
+ * @param b
+ */
+ public void setIsAbstract(boolean b);
+
+ /**
+ * Returns a semi-colon delimited list of child Ids of the superclass'
+ * children that should not be automatically inherited by this element.
+ * Returns an empty string if the attribute was not specified.
+ * @return String
+ */
+ public String getUnusedChildren();
+
+ /**
+ * Returns the semicolon separated list of unique IDs of the error parsers associated
+ * with the tool.
+ *
+ * @return String
+ */
+ public String getErrorParserIds();
+
+ /**
+ * Returns the ordered list of unique IDs of the error parsers associated with the
+ * tool.
+ *
+ * @return String[]
+ */
+ public String[] getErrorParserList();
+
+ /**
+ * Sets the semicolon separated list of error parser ids
+ *
+ * @param ids
+ */
+ public void setErrorParserIds(String ids);
+
+ /**
+ * Returns the list of valid source extensions this tool knows how to build.
+ * The list may be empty but will never be null
.
+ *
+ * @return List
+ */
+ public List getInputExtensions();
+
+ /**
+ * Returns the list of valid header extensions for this tool.
+ * The list may be empty but will never be null
.
+ *
+ * @return List
+ */
+ public List getInterfaceExtensions();
+
+ /**
+ * Answers a constant corresponding to the project nature the tool should be used
+ * for. Possible answers are:
+ *
+ * true
, then the tool command was modified
+ */
+ public boolean setToolCommand(String command);
+
+ /**
+ * Returns command line pattern for this tool
+ * @return String
+ */
+ public String getCommandLinePattern();
+
+ /**
+ * Sets the command line pattern for this tool
+ * @param String
+ */
+ public void setCommandLinePattern(String pattern);
+
+ /**
+ * Returns command line generator specified for this tool
+ * @return IManagedCommandLineGenerator
+ */
+ public IManagedCommandLineGenerator getCommandLineGenerator();
+
+ /**
+ * Returns an array of command line arguments that have been specified for
+ * the tool.
+ * @return String[]
+ * @throws BuildException
+ */
+ public String[] getCommandFlags() throws BuildException;
+
/**
* Answers the additional command line arguments the user has specified for
* the tool.
@@ -163,6 +297,22 @@ public interface ITool extends IBuildObject {
* @return IOptionCategory
*/
public IOptionCategory getTopOptionCategory();
+
+ /**
+ * Returns the option category children of this tool.
+ *
+ * @return IOptionCategory[]
+ */
+ public IOptionCategory[] getChildCategories();
+
+ /**
+ * Return true
if the receiver builds files with the
+ * specified extension, else false
.
+ *
+ * @param extension file extension of the source
+ * @return boolean
+ */
+ public boolean buildsFileType(String extension);
/**
* Answers true
if the tool considers the file extension to be
@@ -182,4 +332,26 @@ public interface ITool extends IBuildObject {
*/
public boolean producesFileType(String outputExtension);
+ /**
+ * Returns true
if this tool has changes that need to
+ * be saved in the project file, else false
.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Returns true
if this tool was loaded from a manifest file,
+ * and false
if it was loaded from a project (.cdtbuild) file.
+ *
+ * @return boolean
+ */
+ public boolean isExtensionElement();
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java
new file mode 100644
index 00000000000..20887343228
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java
@@ -0,0 +1,251 @@
+/**********************************************************************
+ * 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.managedbuilder.core;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * This class represents a tool-integrator-defined, ordered set of tools
+ * that transform the project’s input into the project’s outputs. A
+ * tool-chain can be defined as part of a configuration, or as an
+ * independent specification that is referenced in a separate configuration
+ * via the toolChain superclass attribute.
+ *
+ * The toolChain contains one or more children of type tool. These define
+ * the tools used in the tool-chain. The toolChain contains one child of
+ * type targetPlatform. This defines the architecture/os combination where
+ * the outputs of the project can be deployed. The toolChain contains one
+ * child of type builder. This defines the “build” or “make” utility that
+ * is used to drive the transformation of the inputs into outputs.
+ *
+ * @since 2.1
+ */
+public interface IToolChain extends IBuildObject {
+ public static final String TOOL_CHAIN_ELEMENT_NAME = "toolChain"; //$NON-NLS-1$
+ public static final String OS_LIST = "osList"; //$NON-NLS-1$
+ public static final String ARCH_LIST = "archList"; //$NON-NLS-1$
+ public static final String ERROR_PARSERS = "errorParsers"; //$NON-NLS-1$
+ // The attribute name for the scanner info collector
+ public static final String SCANNER_INFO_ID = "scannerInfoCollector"; //$NON-NLS-1$
+
+ /**
+ * Returns the configuration that is the parent of this tool-chain.
+ *
+ * @return IConfiguration
+ */
+ public IConfiguration getParent();
+
+ /**
+ * Creates the TargetPlatform
child of this tool-chain.
+ *
+ * @param ITargetPlatform The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ *
+ * @return ITargetPlatform
+ */
+ public ITargetPlatform createTargetPlatform(ITargetPlatform superClass, String Id, String name, boolean isExtensionElement);
+
+ /**
+ * Returns the target-platform child of this tool-chain
+ *
+ * @return ITargetPlatform
+ */
+ public ITargetPlatform getTargetPlatform();
+
+ /**
+ * If the tool chain is not an extension element, and it has its own TargetPlatform child,
+ * remove the TargetPlatform so that the tool chain uses its superclass' TargetPlatform
+ */
+ public void removeLocalTargetPlatform();
+
+ /**
+ * Creates the Builder
child of this tool-chain.
+ *
+ * @param IBuilder The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ *
+ * @return IBuilder
+ */
+ public IBuilder createBuilder(IBuilder superClass, String Id, String name, boolean isExtensionElement);
+
+ /**
+ * If the tool chain is not an extension element, and it has its own Builder child,
+ * remove the builder so that the tool chain uses its superclass' Builder
+ */
+ public void removeLocalBuilder();
+
+ /**
+ * Returns the builder child of this tool-chain.
+ *
+ * @return IBuilder
+ */
+ public IBuilder getBuilder();
+
+ /**
+ * Creates a Tool
child of this tool-chain.
+ *
+ * @param ITool The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ *
+ * @return ITool
+ */
+ public ITool createTool(ITool superClass, String Id, String name, boolean isExtensionElement);
+
+ /**
+ * Returns an array of tool children of this tool-chain
+ *
+ * @return ITool[]
+ */
+ public ITool[] getTools();
+
+ /**
+ * Returns the tool in this tool-chain with the ID specified in the argument,
+ * or null
+ *
+ * @param id The ID of the requested tool
+ * @return ITool
+ */
+ public ITool getTool(String id);
+
+ /**
+ * Returns the IToolChain
that is the superclass of this
+ * tool-chain, or null
if the attribute was not specified.
+ *
+ * @return IToolChain
+ */
+ public IToolChain getSuperClass();
+
+ /**
+ * Returns whether this element is abstract. Returns false
+ * if the attribute was not specified.
+ * @return boolean
+ */
+ public boolean isAbstract();
+
+ /**
+ * Sets the isAbstract attribute of the tool-chain.
+ *
+ * @param b
+ */
+ public void setIsAbstract(boolean b);
+
+ /**
+ * Returns a semi-colon delimited list of child Ids of the superclass'
+ * children that should not be automatically inherited by this element.
+ * Returns an empty string if the attribute was not specified.
+ * @return String
+ */
+ public String getUnusedChildren();
+
+ /**
+ * Returns an array of operating systems the tool-chain outputs can run on.
+ *
+ * @return String[]
+ */
+ public String[] getOSList();
+
+ /**
+ * Sets the OS list.
+ *
+ * @param String[] The list of OS names
+ */
+ public void setOSList(String[] OSs);
+
+ /**
+ * Returns an array of architectures the tool-chain outputs can run on.
+ *
+ * @return String[]
+ */
+ public String[] getArchList();
+
+ /**
+ * Sets the architecture list.
+ *
+ * @param String[] The list of architecture names
+ */
+ public void setArchList(String[] archs);
+
+ /**
+ * Returns the semicolon separated list of unique IDs of the error parsers associated
+ * with the tool-chain.
+ *
+ * @return String
+ */
+ public String getErrorParserIds();
+
+ /**
+ * Returns the semicolon separated list of unique IDs of the error parsers associated
+ * with the tool-chain, filtered for the specified configuration.
+ *
+ * @param config
+ * @return String
+ */
+ public String getErrorParserIds(IConfiguration config);
+
+ /**
+ * Returns the ordered list of unique IDs of the error parsers associated with the
+ * tool-chain.
+ *
+ * @return String[]
+ */
+ public String[] getErrorParserList();
+
+ /**
+ * Sets the semicolon separated list of error parser ids.
+ *
+ * @param ids
+ */
+ public void setErrorParserIds(String ids);
+
+ /**
+ * Returns the plugin.xml element of the scannerInfoCollector extension or null
if none.
+ *
+ * @return IConfigurationElement
+ */
+ public IConfigurationElement getScannerInfoCollectorElement();
+
+ /**
+ * Sets the ScannerInfoCollector plugin.xml element
+ *
+ * @param element
+ */
+ public void setScannerInfoCollectorElement(IConfigurationElement element);
+
+ /**
+ * Returns true
if this tool-chain has changes that need to
+ * be saved in the project file, else false
.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Returns true
if this tool-chain was loaded from a manifest file,
+ * and false
if it was loaded from a project (.cdtbuild) file.
+ *
+ * @return boolean
+ */
+ public boolean isExtensionElement();
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolReference.java
index 7d69183d4ba..960570585d7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolReference.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolReference.java
@@ -15,6 +15,9 @@ import java.util.List;
import org.eclipse.cdt.managedbuilder.internal.core.OptionReference;
+/*
+ * Note: This class was deprecated in 2.1
+ */
public interface IToolReference extends ITool {
/**
@@ -69,4 +72,40 @@ public interface IToolReference extends ITool {
*/
public boolean setToolCommand(String cmd);
+ /*
+ * The following methods are added to allow the converter from ToolReference -> Tool
+ * to retrieve the actual value of attributes. These routines do not go to the
+ * referenced Tool for a value if the ToolReference does not have a value.
+ */
+
+ /**
+ * Answers all of the output extensions that the receiver can build.
+ *
+ * @return String
+ */
+ public String getRawOutputExtensions();
+
+ /**
+ * Answers the argument that must be passed to a specific tool in order to
+ * control the name of the output artifact. For example, the GCC compile and
+ * linker use '-o', while the archiver does not.
+ *
+ * @return String
+ */
+ public String getRawOutputFlag();
+
+ /**
+ * Answers the prefix that the tool should prepend to the name of the build artifact.
+ * For example, a librarian usually prepends 'lib' to the target.a
+ * @return String
+ */
+ public String getRawOutputPrefix();
+
+ /**
+ * Answers the command-line invocation defined for the receiver.
+ *
+ * @return String
+ */
+ public String getRawToolCommand();
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
index 6df1ead75f8..e634db1efbe 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
@@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.Random;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -41,19 +42,32 @@ import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.managedbuilder.internal.core.Builder;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
+import org.eclipse.cdt.managedbuilder.internal.core.Option;
+import org.eclipse.cdt.managedbuilder.internal.core.OptionCategory;
+import org.eclipse.cdt.managedbuilder.internal.core.ProjectType;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
import org.eclipse.cdt.managedbuilder.internal.core.Target;
+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;
+import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -65,6 +79,8 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -82,33 +98,79 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static final String SETTINGS_FILE_NAME = ".cdtbuild"; //$NON-NLS-1$
private static final ITarget[] emptyTargets = new ITarget[0];
public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ManagedBuildManager"; //$NON-NLS-1$
- public static final String EXTENSION_POINT_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ManagedBuildInfo"; //$NON-NLS-1$
+ public static final String EXTENSION_POINT_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".buildDefinitions"; //$NON-NLS-1$
+ public static final String EXTENSION_POINT_ID_V2 = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ManagedBuildInfo"; //$NON-NLS-1$
private static final String REVISION_ELEMENT_NAME = "managedBuildRevision"; //$NON-NLS-1$
private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$
private static final String MANIFEST_VERSION_ERROR ="ManagedBuildManager.error.manifest.version.error"; //$NON-NLS-1$
private static final String PROJECT_VERSION_ERROR ="ManagedBuildManager.error.project.version.error"; //$NON-NLS-1$
// This is the version of the manifest and project files that
- private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(2, 0, 0);
+ private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(2, 1, 0);
private static Map depCalculatorsMap;
- private static boolean extensionTargetsLoaded = false;
- private static Map extensionTargetMap;
- private static List extensionTargets;
+ private static boolean projectTypesLoaded = false;
+ // Project types defined in the manifest files
+ private static Map projectTypeMap;
+ private static List projectTypes;
+ // Configurations defined in the manifest files
+ private static Map extensionConfigurationMap;
+ // Resource configurations defined in the manifest files
+ private static Map extensionResourceConfigurationMap;
+ // Tool-chains defined in the manifest files
+ private static Map extensionToolChainMap;
+ // Tools defined in the manifest files
private static Map extensionToolMap;
+ // Target Platforms defined in the manifest files
+ private static Map extensionTargetPlatformMap;
+ // Builders defined in the manifest files
+ private static Map extensionBuilderMap;
+ // Options defined in the manifest files
+ private static Map extensionOptionMap;
+ // Option Categories defined in the manifest files
+ private static Map extensionOptionCategoryMap;
+ // Targets defined in the manifest files (CDT V2.0 object model)
+ private static Map extensionTargetMap;
+ // "Selected configuraton" elements defined in the manifest files.
+ // These are configuration elements that map to objects in the internal
+ // representation of the manifest files. For example, ListOptionValues
+ // and enumeratedOptionValues are NOT included.
+ // 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.
private static Map configElementMap;
-
-
// Listeners interested in build model changes
private static Map buildModelListeners;
+ // Random number for derived object model elements
+ private static Random randomNumber;
/**
- * Returns the list of targets that are defined by this project,
+ * Returns the next random number.
+ *
+ * @return int A positive integer
+ */
+ public static int getRandomNumber() {
+ if (randomNumber == null) {
+ // Set the random number seed
+ randomNumber = new Random();
+ randomNumber.setSeed(System.currentTimeMillis());
+ }
+ int i = randomNumber.nextInt();
+ if (i < 0) {
+ i *= -1;
+ }
+ return i;
+ }
+
+ /**
+ * Returns the list of project types that are defined by this project,
* projects referenced by this project, and by the extensions.
*
- * @param project
- * @return
+ * @return IProjectType[]
*/
- public static ITarget[] getDefinedTargets(IProject project) {
+ public static IProjectType[] getDefinedProjectTypes() {
try {
// Make sure the extensions are loaded
loadExtensions();
@@ -117,28 +179,38 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
e.printStackTrace();
}
- // Get the targets for this project and all referenced projects
- List definedTargets = null;
+ // Get the project types for this project and all referenced projects
+ List definedTypes = null;
// To Do
// Create the array and copy the elements over
- int size = extensionTargets != null ?
- extensionTargets.size() + (definedTargets != null ? definedTargets.size() : 0) :
+ int size = projectTypes != null ?
+ projectTypes.size() + (definedTypes != null ? definedTypes.size() : 0) :
0;
- ITarget[] targets = new ITarget[size];
+ IProjectType[] types = new IProjectType[size];
int n = 0;
- for (int i = 0; i < extensionTargets.size(); ++i)
- targets[n++] = (ITarget)extensionTargets.get(i);
+ for (int i = 0; i < projectTypes.size(); ++i)
+ types[n++] = (IProjectType)projectTypes.get(i);
- if (definedTargets != null)
- for (int i = 0; i < definedTargets.size(); ++i)
- targets[n++] = (ITarget)definedTargets.get(i);
+ if (definedTypes != null)
+ for (int i = 0; i < definedTypes.size(); ++i)
+ types[n++] = (IProjectType)definedTypes.get(i);
- return targets;
+ return types;
}
-
+
+ /**
+ * Returns the project type with the passed in ID
+ *
+ * @param String
+ * @return IProjectType
+ */
+ public static IProjectType getProjectType(String id) {
+ return (IProjectType)getExtensionProjectTypeMap().get(id);
+ }
+
/**
* Answers an instance of a class that implements the
* IManagedDependencyGenerator
interface to generate
@@ -163,6 +235,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
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++) {
@@ -202,21 +281,57 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
/* (non-Javadoc)
- * Safe accessor for the map of IDs to Targets
+ * Safe accessor for the map of IDs to ProjectTypes
*
- * @return
+ * @return Map
*/
- protected static Map getExtensionTargetMap() {
- if (extensionTargetMap == null) {
- extensionTargetMap = new HashMap();
+ protected static Map getExtensionProjectTypeMap() {
+ if (projectTypeMap == null) {
+ projectTypeMap = new HashMap();
}
- return extensionTargetMap;
+ return projectTypeMap;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of IDs to Configurations
+ *
+ * @return Map
+ */
+ protected static Map getExtensionConfigurationMap() {
+ if (extensionConfigurationMap == null) {
+ extensionConfigurationMap = new HashMap();
+ }
+ return extensionConfigurationMap;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of IDs to Resource Configurations
+ *
+ * @return Map
+ */
+ protected static Map getExtensionResourceConfigurationMap() {
+ if (extensionResourceConfigurationMap == null) {
+ extensionResourceConfigurationMap = new HashMap();
+ }
+ return extensionResourceConfigurationMap;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of IDs to ToolChains
+ *
+ * @return Map
+ */
+ protected static Map getExtensionToolChainMap() {
+ if (extensionToolChainMap == null) {
+ extensionToolChainMap = new HashMap();
+ }
+ return extensionToolChainMap;
}
/* (non-Javadoc)
* Safe accessor for the map of IDs to Tools
*
- * @return
+ * @return Map
*/
protected static Map getExtensionToolMap() {
if (extensionToolMap == null) {
@@ -225,6 +340,66 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return extensionToolMap;
}
+ /* (non-Javadoc)
+ * Safe accessor for the map of IDs to TargetPlatforms
+ *
+ * @return Map
+ */
+ protected static Map getExtensionTargetPlatformMap() {
+ if (extensionTargetPlatformMap == null) {
+ extensionTargetPlatformMap = new HashMap();
+ }
+ return extensionTargetPlatformMap;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of IDs to Builders
+ *
+ * @return Map
+ */
+ protected static Map getExtensionBuilderMap() {
+ if (extensionBuilderMap == null) {
+ extensionBuilderMap = new HashMap();
+ }
+ return extensionBuilderMap;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of IDs to Options
+ *
+ * @return Map
+ */
+ protected static Map getExtensionOptionMap() {
+ if (extensionOptionMap == null) {
+ extensionOptionMap = new HashMap();
+ }
+ return extensionOptionMap;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of IDs to Option Categories
+ *
+ * @return Map
+ */
+ protected static Map getExtensionOptionCategoryMap() {
+ if (extensionOptionCategoryMap == null) {
+ extensionOptionCategoryMap = new HashMap();
+ }
+ return extensionOptionCategoryMap;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of IDs to Targets (CDT V2.0 object model)
+ *
+ * @return Map
+ */
+ protected static Map getExtensionTargetMap() {
+ if (extensionTargetMap == null) {
+ extensionTargetMap = new HashMap();
+ }
+ return extensionTargetMap;
+ }
+
/**
* Returns the targets owned by this project. If none are owned,
* an empty array is returned.
@@ -244,14 +419,103 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
/**
- * Answers the tool with the ID specified in the argument or null
.
+ * Returns the project type from the manifest with the ID specified in the argument
+ * or null
.
*
* @param id
- * @return
+ * @return IProjectType
*/
- public static ITool getTool(String id) {
+ public static IProjectType getExtensionProjectType(String id) {
+ return (IProjectType) getExtensionProjectTypeMap().get(id);
+ }
+
+ /**
+ * Returns the configuration from the manifest with the ID specified in the argument
+ * or null
.
+ *
+ * @param id
+ * @return IConfiguration
+ */
+ public static IConfiguration getExtensionConfiguration(String id) {
+ return (IConfiguration) getExtensionConfigurationMap().get(id);
+ }
+
+ /**
+ * Returns the resource configuration from the manifest with the ID specified in the argument
+ * or null
.
+ *
+ * @param id
+ * @return IResourceConfiguration
+ */
+ public static IResourceConfiguration getExtensionResourceConfiguration(String id) {
+ return (IResourceConfiguration) getExtensionResourceConfigurationMap().get(id);
+ }
+
+ /**
+ * Returns the tool-chain from the manifest with the ID specified in the argument
+ * or null
.
+ *
+ * @param id
+ * @return IToolChain
+ */
+ public static IToolChain getExtensionToolChain(String id) {
+ return (IToolChain) getExtensionToolChainMap().get(id);
+ }
+
+ /**
+ * Returns the tool from the manifest with the ID specified in the argument
+ * or null
.
+ *
+ * @param id
+ * @return ITool
+ */
+ public static ITool getExtensionTool(String id) {
return (ITool) getExtensionToolMap().get(id);
}
+
+ /**
+ * Returns the target platform from the manifest with the ID specified in the argument
+ * or null
.
+ *
+ * @param id
+ * @return ITargetPlatform
+ */
+ public static ITargetPlatform getExtensionTargetPlatform(String id) {
+ return (ITargetPlatform) getExtensionTargetPlatformMap().get(id);
+ }
+
+ /**
+ * Returns the builder from the manifest with the ID specified in the argument
+ * or null
.
+ *
+ * @param id
+ * @return IBuilder
+ */
+ public static IBuilder getExtensionBuilder(String id) {
+ return (IBuilder) getExtensionBuilderMap().get(id);
+ }
+
+ /**
+ * Returns the option from the manifest with the ID specified in the argument
+ * or null
.
+ *
+ * @param id
+ * @return IOption
+ */
+ public static IOption getExtensionOption(String id) {
+ return (IOption) getExtensionOptionMap().get(id);
+ }
+
+ /**
+ * Returns the target from the manifest with the ID specified in the argument
+ * or null
- CDT V2.0 object model.
+ *
+ * @param id
+ * @return ITarget
+ */
+ public static ITarget getExtensionTarget(String id) {
+ return (ITarget) getExtensionTargetMap().get(id);
+ }
/**
* Answers the result of a best-effort search to find a target with the
@@ -295,20 +559,20 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
/**
- * Sets the currently selected target. This is used while the project
+ * Sets the currently selected configuration. This is used while the project
* property pages are displayed
*
* @param project
* @param target
*/
- public static void setSelectedTarget(IProject project, ITarget target) {
- if (project == null || target == null) {
+ public static void setSelectedConfiguration(IProject project, IConfiguration config) {
+ if (project == null) {
return;
}
// Set the default in build information for the project
IManagedBuildInfo info = getBuildInfo(project);
if (info != null) {
- info.setSelectedTarget(target);
+ info.setSelectedConfiguration(config);
}
}
@@ -316,24 +580,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param targetId
* @return
*/
- public static IManagedBuilderMakefileGenerator getMakefileGenerator(String targetId) {
+ public static IManagedBuilderMakefileGenerator getBuildfileGenerator(IConfiguration config) {
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(ITarget.TARGET_ELEMENT_NAME)) {
- if (element.getAttribute(ITarget.ID).equals(targetId)) {
- if (element.getAttribute(ManagedBuilderCorePlugin.MAKEGEN_ID) != null) {
- return (IManagedBuilderMakefileGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.MAKEGEN_ID);
- }
- }
- }
+ IToolChain toolChain = config.getToolChain();
+ IBuilder builder = toolChain.getBuilder();
+ IConfigurationElement element = builder.getBuildFileGeneratorElement();
+ if (element != null) {
+ if (element.getName().equalsIgnoreCase("target")) { //$NON-NLS-1$
+ if (element.getAttribute(ManagedBuilderCorePlugin.MAKEGEN_ID) != null) {
+ return (IManagedBuilderMakefileGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.MAKEGEN_ID);
+ }
+ } else {
+ if (element.getAttribute(ManagedBuilderCorePlugin.BUILDFILEGEN_ID) != null) {
+ return (IManagedBuilderMakefileGenerator) element.createExecutableExtension(ManagedBuilderCorePlugin.BUILDFILEGEN_ID);
}
}
}
@@ -344,16 +603,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// If no generator is defined, return the default GNU generator
return new GnuMakefileGenerator();
}
-
- /**
- * Targets may have a scanner collector defined that knows how to discover
- * built-in compiler defines and includes search paths. Find the scanner
- * collector implentation for the target specified.
- *
- * @param string the unique id of the target to search for
- * @return an implementation of IManagedScannerInfoCollector
+
+ /**
+ * load tool provider defined or default (if not found) command line generator special for selected tool
+ * @param toolId - id selected id
+ * @return IManagedCommandLineGenerator
*/
- public static IManagedScannerInfoCollector getScannerInfoCollector(String targetId) {
+ public static IManagedCommandLineGenerator getCommandLineGenerator( String toolId ) {
try {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(EXTENSION_POINT_ID);
@@ -364,16 +620,39 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
IConfigurationElement element = configElements[j];
- if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME)) {
- if (element.getAttribute(ITarget.ID).equals(targetId)) {
- if (element.getAttribute(ManagedBuilderCorePlugin.SCANNER_INFO_ID) != null) {
- return (IManagedScannerInfoCollector) element.createExecutableExtension(ManagedBuilderCorePlugin.SCANNER_INFO_ID);
+ 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 ) {
+
+ }
+ return ManagedCommandLineGenerator.getCommandLineGenerator();
+ }
+
+ /**
+ * Targets may have a scanner collector defined that knows how to discover
+ * built-in compiler defines and includes search paths. Find the scanner
+ * collector implementation for the target specified.
+ *
+ * @param string the unique id of the target to search for
+ * @return an implementation of IManagedScannerInfoCollector
+ */
+ public static IManagedScannerInfoCollector getScannerInfoCollector(IConfiguration config) {
+ try {
+ IToolChain toolChain = config.getToolChain();
+ IConfigurationElement element = toolChain.getScannerInfoCollectorElement();
+ if (element != null) {
+ if (element.getAttribute(IToolChain.SCANNER_INFO_ID) != null) {
+ return (IManagedScannerInfoCollector) element.createExecutableExtension(IToolChain.SCANNER_INFO_ID);
+ }
+ }
}
catch (CoreException e) {
// Probably not defined
@@ -388,14 +667,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param project
* @return target
*/
- public static ITarget getSelectedTarget(IProject project) {
+ public static IConfiguration getSelectedConfiguration(IProject project) {
if (project == null) {
return null;
}
// Set the default in build information for the project
IManagedBuildInfo info = getBuildInfo(project);
if (info != null) {
- return info.getSelectedTarget();
+ return info.getSelectedConfiguration();
}
return null;
}
@@ -407,10 +686,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*/
private static void notifyListeners(IConfiguration config, IOption option) {
// Continue if change is something that effect the scanner
- if (!(option.getValueType() == IOption.INCLUDE_PATH
- || option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) {
- return;
- }
+ try {
+ if (!(option.getValueType() == IOption.INCLUDE_PATH
+ || option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) {
+ return;
+ }
+ } catch (BuildException e) {return;}
+
// Figure out if there is a listener for this change
IResource resource = config.getOwner();
List listeners = (List) getBuildModelListeners().get(resource);
@@ -423,6 +705,27 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
}
+ private static void notifyListeners(IResourceConfiguration resConfig, IOption option) {
+ // Continue if change is something that effect the scanreser
+ try {
+ if (!(option.getValueType() == IOption.INCLUDE_PATH
+ || option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) {
+ return;
+ }
+ } catch (BuildException e) {return;}
+
+ // Figure out if there is a listener for this change
+ IResource resource = resConfig.getOwner();
+ List listeners = (List) getBuildModelListeners().get(resource);
+ if (listeners == null) {
+ return;
+ }
+ ListIterator iter = listeners.listIterator();
+ while (iter.hasNext()) {
+ ((IScannerInfoChangeListener)iter.next()).changeNotification(resource, (IScannerInfo)getBuildInfo(resource));
+ }
+ }
+
/**
* Adds the version of the managed build system to the project
* specified in the argument.
@@ -441,47 +744,109 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param config The configuration the option belongs to.
* @param option The option to set the value for.
* @param value The boolean that the option should contain after the change.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
*/
- public static void setOption(IConfiguration config, IOption option, boolean value) {
+ public static IOption setOption(IConfiguration config, ITool tool, IOption option, boolean value) {
+ IOption retOpt;
try {
// Request a value change and set dirty if real change results
- config.setOption(option, value);
+ retOpt = config.setOption(tool, option, value);
notifyListeners(config, option);
} catch (BuildException e) {
- return;
+ return null;
}
+ return retOpt;
}
+ public static IOption setOption(IResourceConfiguration resConfig, ITool tool, IOption option, boolean value) {
+ IOption retOpt;
+ try {
+ // Request a value change and set dirty if real change results
+ retOpt = resConfig.setOption(tool, option, value);
+ notifyListeners(resConfig, option);
+ } catch (BuildException e) {
+ return null;
+ }
+ return retOpt;
+ }
/**
* Set the string value for an option for a given config.
*
* @param config The configuration the option belongs to.
* @param option The option to set the value for.
* @param value The value that the option should contain after the change.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
*/
- public static void setOption(IConfiguration config, IOption option, String value) {
+ public static IOption setOption(IConfiguration config, ITool tool, IOption option, String value) {
+ IOption retOpt;
try {
- config.setOption(option, value);
+ retOpt = config.setOption(tool, option, value);
notifyListeners(config, option);
} catch (BuildException e) {
- return;
+ return null;
}
+ return retOpt;
}
/**
+ * Set the string value for an option for a given resource config.
+ *
+ * @param resConfig The resource configuration the option belongs to.
+ * @param option The option to set the value for.
+ * @param value The value that the option should contain after the change.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ */
+ public static IOption setOption(IResourceConfiguration resConfig, ITool tool, IOption option, String value) {
+ IOption retOpt;
+ try {
+ retOpt = resConfig.setOption(tool, option, value);
+ notifyListeners(resConfig, option);
+ } catch (BuildException e) {
+ return null;
+ }
+ return retOpt;
+ }
+/**
* Set the string array value for an option for a given config.
*
* @param config The configuration the option belongs to.
* @param option The option to set the value for.
* @param value The values the option should contain after the change.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
*/
- public static void setOption(IConfiguration config, IOption option, String[] value) {
+ public static IOption setOption(IConfiguration config, ITool tool, IOption option, String[] value) {
+ IOption retOpt;
try {
- config.setOption(option, value);
+ retOpt = config.setOption(tool, option, value);
notifyListeners(config, option);
} catch (BuildException e) {
- return;
+ return null;
}
+ return retOpt;
+ }
+
+ /**
+ * Set the string array value for an option for a given resource config.
+ *
+ * @param resConfig The resource configuration the option belongs to.
+ * @param option The option to set the value for.
+ * @param value The values the option should contain after the change.
+ *
+ * @return IOption The modified option. This can be the same option or a newly created option.
+ */
+ public static IOption setOption(IResourceConfiguration resConfig, ITool tool, IOption option, String[] value) {
+ IOption retOpt;
+ try {
+ retOpt = resConfig.setOption(tool, option, value);
+ notifyListeners(resConfig, option);
+ } catch (BuildException e) {
+ return null;
+ }
+ return retOpt;
}
/**
@@ -499,7 +864,15 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
}
-
+ public static void setToolCommand(IResourceConfiguration resConfig, ITool tool, String command) {
+ // The tool may be a reference.
+ if (tool instanceof IToolReference) {
+ // If so, just set the command in the reference
+ ((IToolReference)tool).setToolCommand(command);
+ } else {
+ resConfig.setToolCommand(tool, command);
+ }
+ }
/**
* Saves the build information associated with a project and all resources
* in the project to the build info file.
@@ -517,7 +890,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
ManagedBuildInfo buildInfo = (ManagedBuildInfo) getBuildInfo(project);
// Save the build info
- if (buildInfo != null && (force == true || buildInfo.isDirty())) {
+ if (buildInfo != null && !buildInfo.isReadOnly() && (force == true || buildInfo.isDirty())) {
// For post-2.0 projects, there will be a version
String projectVersion = buildInfo.getVersion();
if (projectVersion != null) {
@@ -543,9 +916,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
String utfString = stream.toString("UTF8"); //$NON-NLS-1$
if (projectFile.exists()) {
- projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF8")), IResource.FORCE, new NullProgressMonitor());
+ projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
} else {
- projectFile.create(new ByteArrayInputStream(utfString.getBytes("UTF8")), IResource.FORCE, new NullProgressMonitor());
+ projectFile.create(new ByteArrayInputStream(utfString.getBytes("UTF8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$
}
// Close the streams
@@ -593,35 +966,61 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param configuration
*/
public static void resetConfiguration(IProject project, IConfiguration configuration) {
- // Make sure the extensions are loaded
- try {
- loadExtensions();
- } catch (BuildException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- // Find out the parent of the configuration
- IConfiguration parentConfig = configuration.getParent();
-
- // Get the config element for the parent from the map
- IManagedConfigElement configElement = getConfigElement(parentConfig);
-
// reset the configuration
- ((Configuration)configuration).reset(configElement);
+ ((Configuration)configuration).reset();
+ }
+
+ public static void resetResourceConfiguration(IProject project, IResourceConfiguration resConfig) {
+ // reset the configuration
+ ((ResourceConfiguration) resConfig).reset();
+ }
+ /**
+ * Adds a ProjectType that is is specified in the manifest to the
+ * build system. It is available to any element that
+ * has a reference to it as part of its description.
+ *
+ * @param projectType
+ */
+ public static void addExtensionProjectType(ProjectType projectType) {
+ if (projectTypes == null) {
+ projectTypes = new ArrayList();
+ }
+
+ projectTypes.add(projectType);
+ getExtensionProjectTypeMap().put(projectType.getId(), projectType);
}
-
/**
- * @param target
+ * Adds a Configuration that is is specified in the manifest to the
+ * build system. It is available to any element that
+ * has a reference to it as part of its description.
+ *
+ * @param configuration
*/
- public static void addExtensionTarget(Target target) {
- if (extensionTargets == null) {
- extensionTargets = new ArrayList();
- }
-
- extensionTargets.add(target);
- getExtensionTargetMap().put(target.getId(), target);
+ public static void addExtensionConfiguration(Configuration configuration) {
+ getExtensionConfigurationMap().put(configuration.getId(), configuration);
+ }
+
+ /**
+ * Adds a Resource Configuration that is is specified in the manifest to the
+ * build system. It is available to any element that
+ * has a reference to it as part of its description.
+ *
+ * @param resourceConfiguration
+ */
+ public static void addExtensionResourceConfiguration(ResourceConfiguration resourceConfiguration) {
+ getExtensionResourceConfigurationMap().put(resourceConfiguration.getId(), resourceConfiguration);
+ }
+
+ /**
+ * Adds a ToolChain that is is specified in the manifest to the
+ * build system. It is available to any element that
+ * has a reference to it as part of its description.
+ *
+ * @param toolChain
+ */
+ public static void addExtensionToolChain(ToolChain toolChain) {
+ getExtensionToolChainMap().put(toolChain.getId(), toolChain);
}
/**
@@ -638,6 +1037,75 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
getExtensionDepCalcMap().put(tool.getId(), createDependencyGenerator(tool.getId()));
}
+ /**
+ * Adds a TargetPlatform that is is specified in the manifest to the
+ * build system. It is available to any element that
+ * has a reference to it as part of its description.
+ *
+ * @param targetPlatform
+ */
+ public static void addExtensionTargetPlatform(TargetPlatform targetPlatform) {
+ getExtensionTargetPlatformMap().put(targetPlatform.getId(), targetPlatform);
+ }
+
+ /**
+ * Adds a Builder that is is specified in the manifest to the
+ * build system. It is available to any element that
+ * has a reference to it as part of its description.
+ *
+ * @param Builder
+ */
+ public static void addExtensionBuilder(Builder builder) {
+ getExtensionBuilderMap().put(builder.getId(), builder);
+ }
+
+ /**
+ * Adds a Option that is is specified in the manifest to the
+ * build system. It is available to any element that
+ * has a reference to it as part of its description.
+ *
+ * @param option
+ */
+ public static void addExtensionOption(Option option) {
+ getExtensionOptionMap().put(option.getId(), option);
+ }
+
+ /**
+ * Adds a OptionCategory that is is specified in the manifest to the
+ * build system. It is available to any element that
+ * has a reference to it as part of its description.
+ *
+ * @param optionCategory
+ */
+ public static void addExtensionOptionCategory(OptionCategory optionCategory) {
+ getExtensionOptionCategoryMap().put(optionCategory.getId(), optionCategory);
+ }
+
+ /**
+ * Adds a Target that is is specified in the manifest to the
+ * build system. It is available to any CDT 2.0 object model element that
+ * has a reference to it as part of its description.
+ *
+ * @param target
+ */
+ public static void addExtensionTarget(Target target) {
+ getExtensionTargetMap().put(target.getId(), target);
+ }
+
+ /**
+ * Creates a new project instance for the resource based on the parent project type.
+ *
+ * @param resource
+ * @param parentTarget
+ * @return new ITarget
with settings based on the parent passed in the arguments
+ * @throws BuildException
+ */
+ public static IManagedProject createManagedProject(IResource resource, IProjectType parent)
+ throws BuildException
+ {
+ return new ManagedProject(resource, parent);
+ }
+
/**
* Creates a new target for the resource based on the parentTarget.
*
@@ -721,7 +1189,6 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// In this case we should trigger an init and deltas
newEntries.add(ManagedBuildInfo.containerEntry);
cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), new NullProgressMonitor());
- info.setContainerCreated(true);
}
}
@@ -753,15 +1220,33 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* Load the build information for the specified resource from its project
* file. Pay attention to the version number too.
*/
- private static ManagedBuildInfo loadBuildInfo(IProject project) {
+ private static ManagedBuildInfo loadBuildInfo(IProject project) throws Exception {
ManagedBuildInfo buildInfo = null;
IFile file = project.getFile(SETTINGS_FILE_NAME);
if (!file.exists())
return null;
// So there is a project file, load the information there
+ InputStream stream = null;
+ try {
+ stream = file.getContents();
+ } catch (ResourceException e) {
+ // TODO: Why couldn't the file be read?
+ if (e.getStatus().getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) {
+ // TODO: Issue a warning?
+ // Read it anyway...
+ try {
+ stream = file.getContents(true);
+ } catch (Exception fe) {
+ throw fe;
+ }
+ }
+ } catch (Exception e) {
+ buildInfo = null;
+ // TODO: Issue an error message that the managed build project file (.cdtbuild) is invalid
+ }
+
try {
- InputStream stream = file.getContents();
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = parser.parse(stream);
String fileVersion = null;
@@ -793,66 +1278,302 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
if (fileVersion != null) {
buildInfo.setVersion(fileVersion);
}
+ if(!UpdateManagedProjectManager.isCompatibleProject(buildInfo)){
+ try{
+ UpdateManagedProjectManager.updateProject(project,buildInfo);
+ } catch(CoreException e){
+ //TODO: error occured while updating the project,
+ //handle error, log error or display the message
+ }
+ }
project.setSessionProperty(buildInfoProperty, buildInfo);
}
} catch (Exception e) {
+ throw e;
}
return buildInfo;
}
/* (non-Javadoc)
+ * This method loads all of the managed build system manifest files
+ * that have been installed with CDT. An internal hierarchy of
+ * objects is created that contains the information from the manifest
+ * files. The information is then accessed through the ManagedBuildManager.
+ *
* Since the class does not have a constructor but all public methods
* call this method first, it is effectively a startup method
*/
private static void loadExtensions() throws BuildException {
- if (extensionTargetsLoaded)
+ if (projectTypesLoaded)
return;
- // Get those extensions
+ // Do this once
+ projectTypesLoaded = true;
+
+ // Get the extensions that use the current CDT managed build model
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
- IExtension[] extensions = extensionPoint.getExtensions();
+ if( extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions != null) {
- // First call the constructors
- for (int i = 0; i < extensions.length; ++i) {
- IExtension extension = extensions[i];
- // Can we read this manifest
- if (!isVersionCompatible(extension)) {
- //The version of the Plug-in is greater than what the manager thinks it understands
- throw new BuildException(ManagedMakeMessages.getResourceString(MANIFEST_VERSION_ERROR));
- }
- IConfigurationElement[] elements = extension.getConfigurationElements();
- loadConfigElements(DefaultManagedConfigElement.convertArray(elements));
- }
- // Then call resolve.
- Iterator toolIter = getExtensionToolMap().values().iterator();
- while (toolIter.hasNext()) {
- try {
- Tool tool = (Tool)toolIter.next();
- tool.resolveReferences();
- } catch (Exception ex) {
- // TODO: log
- ex.printStackTrace();
+ // First call the constructors of the internal classes that correspond to the
+ // build model elements
+ for (int i = 0; i < extensions.length; ++i) {
+ IExtension extension = extensions[i];
+ // Can we read this manifest
+ if (!isVersionCompatible(extension)) {
+ //The version of the Plug-in is greater than what the manager thinks it understands
+ throw new BuildException(ManagedMakeMessages.getResourceString(MANIFEST_VERSION_ERROR));
+ }
+ // 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.
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ loadConfigElements(DefaultManagedConfigElement.convertArray(elements));
+ }
+ // Then call resolve.
+ //
+ // Here are notes on "references" within the managed build system.
+ // References are "pointers" from one model element to another.
+ // These are encoded in manifest and managed build system project files (.cdtbuild)
+ // using unique string IDs (e.g. "cdt.managedbuild.tool.gnu.c.linker").
+ // These string IDs are "resolved" to pointers to interfaces in model
+ // elements in the in-memory represent of the managed build system information.
+ //
+ // Here are the current "rules" for references:
+ // 1. A reference is always resolved to an interface pointer in the
+ // referenced object.
+ // 2. A reference is always TO an extension object - that is, an object
+ // loaded from a manifest file or a dynamic element provider. It cannot
+ // be to an object loaded from a managed build system project file (.cdtbuild).
+ //
+
+ Iterator projectTypeIter = getExtensionProjectTypeMap().values().iterator();
+ while (projectTypeIter.hasNext()) {
+ try {
+ ProjectType projectType = (ProjectType)projectTypeIter.next();
+ projectType.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ Iterator configurationIter = getExtensionConfigurationMap().values().iterator();
+ while (configurationIter.hasNext()) {
+ try {
+ Configuration configuration = (Configuration)configurationIter.next();
+ configuration.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ Iterator resConfigIter = getExtensionResourceConfigurationMap().values().iterator();
+ while (resConfigIter.hasNext()) {
+ try {
+ ResourceConfiguration resConfig = (ResourceConfiguration)resConfigIter.next();
+ resConfig.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ Iterator toolChainIter = getExtensionToolChainMap().values().iterator();
+ while (toolChainIter.hasNext()) {
+ try {
+ ToolChain toolChain = (ToolChain)toolChainIter.next();
+ toolChain.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ Iterator toolIter = getExtensionToolMap().values().iterator();
+ while (toolIter.hasNext()) {
+ try {
+ Tool tool = (Tool)toolIter.next();
+ tool.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ Iterator targetPlatformIter = getExtensionTargetPlatformMap().values().iterator();
+ while (targetPlatformIter.hasNext()) {
+ try {
+ TargetPlatform targetPlatform = (TargetPlatform)targetPlatformIter.next();
+ targetPlatform.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ Iterator builderIter = getExtensionBuilderMap().values().iterator();
+ while (builderIter.hasNext()) {
+ try {
+ Builder builder = (Builder)builderIter.next();
+ builder.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ Iterator optionIter = getExtensionOptionMap().values().iterator();
+ while (optionIter.hasNext()) {
+ try {
+ Option option = (Option)optionIter.next();
+ option.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ Iterator optionCatIter = getExtensionOptionCategoryMap().values().iterator();
+ while (optionCatIter.hasNext()) {
+ try {
+ OptionCategory optionCat = (OptionCategory)optionCatIter.next();
+ optionCat.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
}
}
- Iterator targetIter = getExtensionTargetMap().values().iterator();
- while (targetIter.hasNext()) {
- try {
- Target target = (Target)targetIter.next();
- target.resolveReferences();
- } catch (Exception ex) {
- // TODO: log
- ex.printStackTrace();
+
+ // Get the extensions that use the CDT 2.0 build model
+ extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID_V2);
+ if( extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions != null) {
+ if (extensions.length > 0) {
+
+ // Call the constructors of the internal classes that correspond to the
+ // V2.0 build model elements. Some of these objects are converted to new model objects.
+ // Others can use the same classes.
+ for (int i = 0; i < extensions.length; ++i) {
+ IExtension extension = extensions[i];
+ // Can we read this manifest
+ if (!isVersionCompatible(extension)) {
+ //The version of the Plug-in is greater than what the manager thinks it understands
+ throw new BuildException(ManagedMakeMessages.getResourceString(MANIFEST_VERSION_ERROR));
+ }
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ loadConfigElementsV2(DefaultManagedConfigElement.convertArray(elements));
+ }
+ // Resolve references
+ Iterator targetIter = getExtensionTargetMap().values().iterator();
+ while (targetIter.hasNext()) {
+ try {
+ Target target = (Target)targetIter.next();
+ target.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ // The V2 model can also add top-level Tools - they need to be "resolved"
+ Iterator toolIter = getExtensionToolMap().values().iterator();
+ while (toolIter.hasNext()) {
+ try {
+ Tool tool = (Tool)toolIter.next();
+ tool.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ // Convert the targets to the new model
+ targetIter = getExtensionTargetMap().values().iterator();
+ while (targetIter.hasNext()) {
+ try {
+ Target target = (Target)targetIter.next();
+ // Check to see if it has already been converted - if not, do it
+ if (target.getCreatedProjectType() == null) {
+ target.convertToProjectType();
+ }
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ // Resolve references for new ProjectTypes
+ Iterator projTypeIter = getExtensionProjectTypeMap().values().iterator();
+ while (projTypeIter.hasNext()) {
+ try {
+ ProjectType projType = (ProjectType)projTypeIter.next();
+ projType.resolveReferences();
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+
+ // TODO: Clear the target and configurationV2 maps so that the object can be garbage collected
+ // We can't do this yet, because the UpdateManagedProjectAction class may need these elements later
+ // Can we change UpdateManagedProjectAction to see the converted model elements?
+ //targetIter = getExtensionTargetMap().values().iterator();
+ //while (targetIter.hasNext()) {
+ // try {
+ // Target target = (Target)targetIter.next();
+ // ManagedBuildManager.removeConfigElement(target);
+ // getExtensionTargetMap().remove(target);
+ // } catch (Exception ex) {
+ // // TODO: log
+ // ex.printStackTrace();
+ // }
+ //}
+ //getExtensionConfigurationV2Map().clear();
+ }
}
}
- // Let's never do that again
- extensionTargetsLoaded = true;
}
private static void loadConfigElements(IManagedConfigElement[] elements) {
for (int toolIndex = 0; toolIndex < elements.length; ++toolIndex) {
try {
IManagedConfigElement element = elements[toolIndex];
- // Load the targets
+ // Load the top level elements, which in turn load their children
+ if (element.getName().equals(IProjectType.PROJECTTYPE_ELEMENT_NAME)) {
+ new ProjectType(element);
+ } else if (element.getName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
+ new Configuration((ProjectType)null, element);
+ } else if (element.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
+ new ToolChain((Configuration)null, element);
+ } else if (element.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
+ new Tool((ProjectType)null, element);
+ } else if (element.getName().equals(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME)) {
+ new TargetPlatform((ToolChain)null, element);
+ } else if (element.getName().equals(IBuilder.BUILDER_ELEMENT_NAME)) {
+ new Builder((ToolChain)null, element);
+ } else if (element.getName().equals(IManagedConfigElementProvider.ELEMENT_NAME)) {
+ // don't allow nested config providers.
+ if (element instanceof DefaultManagedConfigElement) {
+ IManagedConfigElement[] providedConfigs;
+ IManagedConfigElementProvider provider = createConfigProvider(
+ (DefaultManagedConfigElement)element);
+ providedConfigs = provider.getConfigElements();
+ loadConfigElements(providedConfigs); // This must use the current build model
+ }
+ } else {
+ // TODO: Report an error (log?)
+ }
+ } catch (Exception ex) {
+ // TODO: log
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static void loadConfigElementsV2(IManagedConfigElement[] elements) {
+ for (int toolIndex = 0; toolIndex < elements.length; ++toolIndex) {
+ try {
+ IManagedConfigElement element = elements[toolIndex];
+ // Load the top level elements, which in turn load their children
if (element.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
new Tool(element);
} else if (element.getName().equals(ITarget.TARGET_ELEMENT_NAME)) {
@@ -864,7 +1585,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
IManagedConfigElementProvider provider = createConfigProvider(
(DefaultManagedConfigElement)element);
providedConfigs = provider.getConfigElements();
- loadConfigElements(providedConfigs);
+ loadConfigElementsV2(providedConfigs); // This must use the 2.0 build model
}
}
} catch (Exception ex) {
@@ -977,10 +1698,16 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return null;
}
+ if(buildInfo == null && resource instanceof IProject)
+ buildInfo = findBuildInfoSynchronized((IProject)resource);
+/*
// Nothing in session store, so see if we can load it from cdtbuild
if (buildInfo == null && resource instanceof IProject) {
- buildInfo = loadBuildInfo((IProject)resource);
- // Make sure there was no error
+ try {
+ buildInfo = loadBuildInfo((IProject)resource);
+ } catch (Exception e) {
+ // TODO: Issue error reagarding not being able to load the project file (.cdtbuild)
+ }
try {
// Check if the project needs its container initialized
@@ -989,6 +1716,61 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// We can live without a path entry container if the build information is valid
}
}
+*/
+ return buildInfo;
+ }
+
+ /* (non-Javadoc)
+ * this method is called if managed build info session property
+ * was not set. The caller will use the workspace root rool
+ * to synchronize with other callers
+ * findBuildInfoSynchronized could also be called from project converter
+ * in this case the ManagedBuildInfo saved in the converter would be returned
+ *
+ * @param resource
+ * @return
+ */
+ private static ManagedBuildInfo findBuildInfoSynchronized(IProject project/*, boolean create*/) {
+ ManagedBuildInfo buildInfo = null;
+ final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
+ IJobManager jobManager = Platform.getJobManager();
+
+ // Check if there is any build info associated with this project for this session
+ try{
+ jobManager.beginRule(rule, null);
+ try {
+ buildInfo = (ManagedBuildInfo)project.getSessionProperty(buildInfoProperty);
+ // Make sure that if a project has build info, that the info is not corrupted
+ if (buildInfo != null) {
+ buildInfo.updateOwner(project);
+ }
+ } catch (CoreException e) {
+ // return null;
+ }
+
+ // Check weather getBuildInfo is called from converter
+ if(buildInfo == null)
+ buildInfo = UpdateManagedProjectManager.getConvertedManagedBuildInfo(project);
+
+ // Nothing in session store, so see if we can load it from cdtbuild
+ if (buildInfo == null) {
+ try {
+ buildInfo = loadBuildInfo(project);
+ } catch (Exception e) {
+ // TODO: Issue error reagarding not being able to load the project file (.cdtbuild)
+ }
+
+ try {
+ // Check if the project needs its container initialized
+ initBuildInfoContainer(buildInfo);
+ } catch (CoreException e) {
+ // We can live without a path entry container if the build information is valid
+ }
+ }
+ }
+ finally{
+ jobManager.endRule(rule);
+ }
return buildInfo;
}
@@ -1092,6 +1874,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static void putConfigElement(IBuildObject buildObj, IManagedConfigElement configElement) {
getConfigElementMap().put(buildObj, configElement);
}
+
+ /**
+ * Removes an item from the map
+ */
+ private static void removeConfigElement(IBuildObject buildObj) {
+ getConfigElementMap().remove(buildObj);
+ }
/**
* This method public for implementation reasons. Not intended for use
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
index 23c8cdcc1e0..af6c9ff6297 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
@@ -1,5 +1,3 @@
-package org.eclipse.cdt.managedbuilder.core;
-
/**********************************************************************
* Copyright (c) 2003, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.core;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
@@ -25,10 +24,10 @@ public class ManagedBuilderCorePlugin extends Plugin {
public static final String DEP_CALC_ID ="dependencyCalculator"; //$NON-NLS-1$
// The shared instance
private static ManagedBuilderCorePlugin plugin;
- // The attribute name for the scanner info collector
- public static final String SCANNER_INFO_ID = "scannerInfoCollector"; //$NON-NLS-1$
// 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$
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
new file mode 100644
index 00000000000..e98af542a25
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
@@ -0,0 +1,526 @@
+/**********************************************************************
+ * 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.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+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;
+import org.w3c.dom.Element;
+
+public class Builder extends BuildObject implements IBuilder {
+
+ private static final String EMPTY_STRING = new String();
+
+ // Superclass
+ private IBuilder superClass;
+ private String superClassId;
+ // Parent and children
+ private IToolChain parent;
+ // Managed Build model attributes
+ private String unusedChildren;
+ private String errorParserIds;
+ private Boolean isAbstract;
+ private String command;
+ private String args;
+ private IConfigurationElement buildFileGeneratorElement;
+ // Miscellaneous
+ private boolean isExtensionBuilder = false;
+ private boolean isDirty = false;
+ private boolean resolved = true;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * This constructor is called to create a builder defined by an extension point in
+ * a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The IToolChain parent of this builder, or null
if
+ * defined at the top level
+ * @param element The builder definition from the manifest file or a dynamic element
+ * provider
+ */
+ public Builder(IToolChain parent, IManagedConfigElement element) {
+ this.parent = parent;
+ isExtensionBuilder = true;
+
+ // setup for resolving
+ resolved = false;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionBuilder(this);
+ }
+
+ /**
+ * This constructor is called to create a Builder whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param ToolChain The parent of the builder, if any
+ * @param Builder The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public Builder(ToolChain parent, IBuilder superClass, String Id, String name, boolean isExtensionElement) {
+ this.parent = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionBuilder = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionBuilder(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create a Builder
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The IToolChain
the Builder will be added to.
+ * @param element The XML element that contains the Builder settings.
+ */
+ public Builder(IToolChain parent, Element element) {
+ this.parent = parent;
+ isExtensionBuilder = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+ }
+
+ /**
+ * Create a Builder
based upon an existing builder.
+ *
+ * @param parent The IToolChain
the builder will be added to.
+ * @param builder The existing builder to clone.
+ */
+ public Builder(IToolChain parent, String Id, String name, Builder builder) {
+ this.parent = parent;
+ superClass = builder.superClass;
+ if (superClass != null) {
+ if (builder.superClassId != null) {
+ superClassId = new String(builder.superClassId);
+ }
+ }
+ setId(Id);
+ setName(name);
+ isExtensionBuilder = false;
+
+ // Copy the remaining attributes
+ if (builder.unusedChildren != null) {
+ unusedChildren = new String(builder.unusedChildren);
+ }
+ if (builder.errorParserIds != null) {
+ errorParserIds = new String(builder.errorParserIds);
+ }
+ if (builder.isAbstract != null) {
+ isAbstract = new Boolean(builder.isAbstract.booleanValue());
+ }
+ if (builder.command != null) {
+ command = new String(builder.command);
+ }
+ if (builder.args != null) {
+ args = new String(builder.args);
+ }
+ buildFileGeneratorElement = builder.buildFileGeneratorElement;
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the project-type information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the tool-chain information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // command
+ command = element.getAttribute(IBuilder.COMMAND);
+
+ // arguments
+ args = element.getAttribute(IBuilder.ARGUMENTS);
+
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
+
+ // build file generator
+ if (element instanceof DefaultManagedConfigElement)
+ buildFileGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+
+ /* (non-Javadoc)
+ * Initialize the builder information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the builder information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionBuilder(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // command
+ if (element.hasAttribute(IBuilder.COMMAND)) {
+ command = element.getAttribute(IBuilder.COMMAND);
+ }
+
+ // arguments
+ if (element.hasAttribute(IBuilder.ARGUMENTS)) {
+ args = element.getAttribute(IBuilder.ARGUMENTS);
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(IToolChain.ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
+ }
+
+ // 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)) {
+ // TODO: Issue warning?
+ }
+ }
+
+ /**
+ * Persist the builder to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ if (errorParserIds != null) {
+ element.setAttribute(IToolChain.ERROR_PARSERS, errorParserIds);
+ }
+
+ if (command != null) {
+ element.setAttribute(IBuilder.COMMAND, command);
+ }
+
+ if (args != null) {
+ element.setAttribute(IBuilder.ARGUMENTS, args);
+ }
+
+ // Note: build file generator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (buildFileGeneratorElement != null) {
+ // TODO: issue warning?
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder#getParent()
+ */
+ public IToolChain getParent() {
+ return parent;
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#getSuperClass()
+ */
+ public IBuilder getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder#getName()
+ */
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder#isAbstract()
+ */
+ public boolean isAbstract() {
+ if (isAbstract != null) {
+ return isAbstract.booleanValue();
+ } else {
+ return false; // Note: no inheritance from superClass
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder#getUnusedChildren()
+ */
+ public String getUnusedChildren() {
+ if (unusedChildren != null) {
+ return unusedChildren;
+ } else
+ return EMPTY_STRING; // Note: no inheritance from superClass
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder#getCommand()
+ */
+ public String getCommand() {
+ if (command == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getCommand();
+ } else {
+ return new String("make"); //$NON-NLS-1$
+ }
+ }
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder#getArguments()
+ */
+ public String getArguments() {
+ if (args == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getArguments();
+ } else {
+ return new String("-k"); //$NON-NLS-1$
+ }
+ }
+ return args;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ String ids = errorParserIds;
+ if (ids == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ ids = superClass.getErrorParserIds();
+ }
+ }
+ return ids;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ String parserIDs = getErrorParserIds();
+ String[] errorParsers = null;
+ if (parserIDs != null) {
+ // Check for an empty string
+ if (parserIDs.length() == 0) {
+ errorParsers = new String[0];
+ } else {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ List list = new ArrayList(tok.countTokens());
+ while (tok.hasMoreElements()) {
+ list.add(tok.nextToken());
+ }
+ String[] strArr = {""}; //$NON-NLS-1$
+ errorParsers = (String[]) list.toArray(strArr);
+ }
+ } else {
+ errorParsers = new String[0];
+ }
+ return errorParsers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder.setCommand(String)
+ */
+ public void setCommand(String cmd) {
+ if (cmd == null && command == null) return;
+ if (command == null || cmd == null || !cmd.equals(command)) {
+ command = cmd;
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder#setArguments(String)
+ */
+ public void setArguments(String newArgs) {
+ if (newArgs == null && args == null) return;
+ if (args == null || newArgs == null || !newArgs.equals(args)) {
+ args = newArgs;
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ String currentIds = getErrorParserIds();
+ if (ids == null && currentIds == null) return;
+ if (currentIds == null || ids == null || !(currentIds.equals(ids))) {
+ errorParserIds = ids;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * Sets the isAbstract attribute
+ */
+ public void setIsAbstract(boolean b) {
+ isAbstract = new Boolean(b);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#setBuildFileGeneratorElement(String)
+ */
+ public void setBuildFileGeneratorElement(IConfigurationElement element) {
+ buildFileGeneratorElement = element;
+ 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
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionBuilder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension Builder
+ if (isExtensionBuilder) return false;
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ }
+
+ /* (non-Javadoc)
+ * Resolve the element IDs to interface references
+ */
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ // Resolve superClass
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionBuilder(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index 4b2d76b3371..fff0585bb80 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -12,285 +12,488 @@ package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
import java.util.Vector;
import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolReference;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
+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.Platform;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class Configuration extends BuildObject implements IConfiguration {
- private boolean isDirty = false;
+
+ private static final String EMPTY_STRING = new String();
+
+ // Parent and children
private IConfiguration parent;
+ private ProjectType projectType;
+ private ManagedProject managedProject;
+ private ToolChain toolChain;
+ private List resourceConfigurationList;
+ private Map resourceConfigurationMap;
+ // Managed Build model attributes
+ private String artifactName;
+ private String cleanCommand;
+ private String artifactExtension;
+ private String errorParserIds;
+ // Miscellaneous
+ private boolean isExtensionConfig = false;
+ private boolean isDirty = false;
private boolean rebuildNeeded = false;
private boolean resolved = true;
- private ITarget target;
- private List toolReferences;
+
+ /*
+ * C O N S T R U C T O R S
+ */
/**
- * Build a configuration from the project manifest file.
+ * Create an extension configuration from the project manifest file element.
*
- * @param target The Target
the configuration belongs to.
- * @param element The element from the manifest that contains the overridden configuration information.
+ * @param projectType The ProjectType
the configuration will be added to.
+ * @param element The element from the manifest that contains the configuration information.
*/
- public Configuration(Target target, Element element) {
- this.target = target;
+ public Configuration(ProjectType projectType, IManagedConfigElement element) {
+ this.projectType = projectType;
+ isExtensionConfig = true;
+
+ // setup for resolving
+ resolved = false;
+
+ // Initialize from the XML attributes
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionConfiguration(this);
+
+ // Hook me up to the ProjectType
+ if (projectType != null) {
+ projectType.addConfiguration(this);
+ }
+
+ // Load the children
+ IManagedConfigElement[] configElements = element.getChildren();
+ for (int l = 0; l < configElements.length; ++l) {
+ IManagedConfigElement configElement = configElements[l];
+ if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
+ toolChain = new ToolChain(this, configElement);
+ }else if (configElement.getName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
+ ResourceConfiguration resConfig = new ResourceConfiguration(this, configElement);
+ addResourceConfiguration(resConfig);
+ }
+ }
+ }
+
+ /**
+ * Create a new extension configuration based on one already defined.
+ *
+ * @param projectType The ProjectType
the configuration will be added to.
+ * @param parentConfig The IConfiguration
to copy the settings from.
+ * @param id A unique ID for the new configuration.
+ */
+ public Configuration(ProjectType projectType, IConfiguration parentConfig, String id) {
+ setId(id);
+ this.projectType = projectType;
+ isExtensionConfig = true;
+
+ // setup for resolving
+ resolved = false;
+
+ if (parentConfig != null) {
+ name = parentConfig.getName();
+ // If this contructor is called to clone an existing
+ // configuration, the parent of the parent should be stored.
+ // As of 2.1, there is still one single level of inheritence to
+ // worry about
+ parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent();
+ }
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionConfiguration(this);
+
+ // Hook me up to the ProjectType
+ if (projectType != null) {
+ projectType.addConfiguration(this);
+ }
+ }
+
+ /**
+ * Create a new extension configuration and fill in the attributes and childen later.
+ *
+ * @param projectType The ProjectType
the configuration will be added to.
+ * @param id A unique ID for the new configuration.
+ * @param name A name for the new configuration.
+ */
+ public Configuration(ProjectType projectType, IConfiguration parentConfig, String id, String name) {
+ setId(id);
+ setName(name);
+ this.projectType = projectType;
+ parent = parentConfig;
+ isExtensionConfig = true;
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionConfiguration(this);
+
+ // Hook me up to the ProjectType
+ if (projectType != null) {
+ projectType.addConfiguration(this);
+ }
+ }
+
+ /**
+ * Create a Configuration
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param managedProject The ManagedProject
the configuration will be added to.
+ * @param element The XML element that contains the configuration settings.
+ */
+ public Configuration(ManagedProject managedProject, Element element) {
+ this.managedProject = managedProject;
+ isExtensionConfig = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Hook me up
+ managedProject.addConfiguration(this);
+
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
+ toolChain = new ToolChain(this, (Element)configElement);
+ }else if (configElement.getNodeName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
+ ResourceConfiguration resConfig = new ResourceConfiguration(this, (Element)configElement);
+ addResourceConfiguration(resConfig);
+ }
+ }
+ }
+
+ /**
+ * Create a new project, non-extension, configuration based on one already defined.
+ *
+ * @param managedProject The ManagedProject
the configuration will be added to.
+ * @param parentConfig The IConfiguration
to copy the settings from.
+ * @param id A unique ID for the new configuration.
+ */
+ public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneTools) {
+ setId(id);
+ setName(cloneConfig.getName());
+ this.managedProject = managedProject;
+ isExtensionConfig = false;
+
+ // If this contructor is called to clone an existing
+ // configuration, the parent of the cloning config should be stored.
+ parent = cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent();
+
+ // Copy the remaining attributes
+ projectType = cloneConfig.projectType;
+ if (cloneConfig.artifactName != null) {
+ artifactName = new String(cloneConfig.artifactName);
+ }
+ if (cloneConfig.cleanCommand != null) {
+ cleanCommand = new String(cloneConfig.cleanCommand);
+ }
+ if (cloneConfig.artifactExtension != null) {
+ artifactExtension = new String(cloneConfig.artifactExtension);
+ }
+ if (cloneConfig.errorParserIds != null) {
+ errorParserIds = new String(cloneConfig.errorParserIds);
+ }
+
+ // Clone the configuration's children
+ // Tool Chain
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (cloneConfig.parent != null) {
+ subId = cloneConfig.parent.getToolChain().getId() + "." + nnn; //$NON-NLS-1$
+ subName = cloneConfig.parent.getToolChain().getName(); //$NON-NLS-1$
+ } else {
+ subId = cloneConfig.getToolChain().getId() + "." + nnn; //$NON-NLS-1$
+ subName = cloneConfig.getToolChain().getName(); //$NON-NLS-1$
+ }
+
+ if (cloneTools) {
+ toolChain = new ToolChain(this, subId, subName, (ToolChain)cloneConfig.getToolChain());
+ } else {
+ // Add a tool-chain element that specifies as its superClass the
+ // tool-chain that is the child of the configuration.
+ ToolChain superChain = (ToolChain)cloneConfig.getToolChain();
+ subId = superChain.getId() + "." + nnn; //$NON-NLS-1$
+ IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false);
+
+ // For each tool element child of the tool-chain that is the child of
+ // the selected configuration element, create a tool element child of
+ // the cloned configuration’s tool-chain element that specifies the
+ // original tool element as its superClass.
+ Iterator iter = superChain.getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool toolChild = (Tool) iter.next();
+ nnn = ManagedBuildManager.getRandomNumber();
+ subId = toolChild.getId() + "." + nnn; //$NON-NLS-1$
+ newChain.createTool(toolChild, subId, toolChild.getName(), false);
+ }
+ }
+
+ // Resource Configurations
+ if (cloneConfig.resourceConfigurationList != null) {
+ List resElements = cloneConfig.getResourceConfigurationList();
+ Iterator iter = resElements.listIterator();
+ while (iter.hasNext()) {
+ ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
+ subId = getId() + "." + resConfig.getResourcePath(); //$NON-NLS-1$
+ ResourceConfiguration newResConfig = new ResourceConfiguration(this, resConfig, subId);
+ addResourceConfiguration(newResConfig);
+ }
+ }
+
+ // Hook me up
+ managedProject.addConfiguration(this);
+ setDirty(true);
+ setRebuildState(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Initialize the configuration information from an element in the
+ * manifest file or provided by a dynamicElementProvider
+ *
+ * @param element An obejct implementing IManagedConfigElement
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
// id
setId(element.getAttribute(IConfiguration.ID));
+
+ // name
+ name = element.getAttribute(IConfiguration.NAME);
- // hook me up
- target.addConfiguration(this);
+ // parent
+ String parentID = element.getAttribute(IConfiguration.PARENT);
+ if (parentID != null) {
+ // Lookup the parent configuration by ID
+ parent = ManagedBuildManager.getExtensionConfiguration(parentID);
+ }
+
+ // Get the name of the build artifact associated with configuration
+ artifactName = element.getAttribute(ARTIFACT_NAME);
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+
+ // Get the artifact extension
+ artifactExtension = element.getAttribute(EXTENSION);
+
+ // Get the clean command
+ cleanCommand = element.getAttribute(CLEAN_COMMAND);
+ }
+
+ /* (non-Javadoc)
+ * Initialize the configuration information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the configuration information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IConfiguration.ID));
+
// name
if (element.hasAttribute(IConfiguration.NAME))
setName(element.getAttribute(IConfiguration.NAME));
if (element.hasAttribute(IConfiguration.PARENT)) {
- // See if the target has a parent
- ITarget targetParent = target.getParent();
- // If so, then get my parent from it
- if (targetParent != null) {
- parent = targetParent.getConfiguration(element.getAttribute(IConfiguration.PARENT));
- }
- else {
- parent = null;
+ // See if the parent belongs to the same project
+ parent = managedProject.getConfiguration(element.getAttribute(IConfiguration.PARENT));
+ // If not, then try the extension configurations
+ if (parent == null) {
+ parent = ManagedBuildManager.getExtensionConfiguration(element.getAttribute(IConfiguration.PARENT));
}
}
+
+ // Get the name of the build artifact associated with target (usually
+ // in the plugin specification).
+ if (element.hasAttribute(ARTIFACT_NAME)) {
+ artifactName = element.getAttribute(ARTIFACT_NAME);
+ }
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IConfiguration.TOOLREF_ELEMENT_NAME)) {
- new ToolReference(this, (Element)configElement);
- }
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+ }
+
+ // Get the artifact extension
+ if (element.hasAttribute(EXTENSION)) {
+ artifactExtension = element.getAttribute(EXTENSION);
+ }
+
+ // Get the clean command
+ if (element.hasAttribute(CLEAN_COMMAND)) {
+ cleanCommand = element.getAttribute(CLEAN_COMMAND);
}
-
}
/**
- * Create a new configuration based on one already defined.
+ * Persist this configuration to project file.
*
- * @param target The Target
the receiver will be added to.
- * @param parentConfig The IConfiguration
to copy the settings from.
- * @param id A unique ID for the configuration.
+ * @param doc
+ * @param element
*/
- public Configuration(Target target, IConfiguration parentConfig, String id) {
- this.id = id;
- this.name = parentConfig.getName();
- this.target = target;
+ public void serialize(Document doc, Element element) {
+ element.setAttribute(IConfiguration.ID, id);
+
+ if (name != null)
+ element.setAttribute(IConfiguration.NAME, name);
+
+ if (parent != null)
+ element.setAttribute(IConfiguration.PARENT, parent.getId());
+
+ if (artifactName != null)
+ element.setAttribute(ARTIFACT_NAME, artifactName);
+
+ if (errorParserIds != null)
+ element.setAttribute(ERROR_PARSERS, errorParserIds);
- // If this contructor is called to clone an existing
- // configuration, the parent of the parent should be stored.
- // As of 2.0, there is still one single level of inheritence to
- // worry about
- parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent();
-
- // Check that the tool and the project match
- IProject project = (IProject) target.getOwner();
-
- // Get the tool references from the target and parent
- List allToolRefs = new Vector(target.getLocalToolReferences());
- allToolRefs.addAll(((Configuration)parentConfig).getLocalToolReferences());
- Iterator iter = allToolRefs.listIterator();
+ if (artifactExtension != null)
+ element.setAttribute(EXTENSION, artifactExtension);
+
+ if (cleanCommand != null)
+ element.setAttribute(CLEAN_COMMAND, cleanCommand);
+
+ // Serialize my children
+ Element toolChainElement = doc.createElement(IToolChain.TOOL_CHAIN_ELEMENT_NAME);
+ element.appendChild(toolChainElement);
+ toolChain.serialize(doc, toolChainElement);
+ List resElements = getResourceConfigurationList();
+ Iterator iter = resElements.listIterator();
while (iter.hasNext()) {
- ToolReference toolRef = (ToolReference)iter.next();
-
- // Make a new ToolReference based on the tool in the ref
- ITool parentTool = toolRef.getTool();
- ToolReference newRef = new ToolReference(this, parentTool);
-
- // The reference may have a different command than the parent tool
- String refCmd = toolRef.getToolCommand();
- if (!refCmd.equals(parentTool.getToolCommand())) {
- newRef.setToolCommand(refCmd);
- }
-
- List optRefs = toolRef.getOptionReferenceList();
- Iterator optIter = optRefs.listIterator();
- while (optIter.hasNext()) {
- OptionReference optRef = (OptionReference)optIter.next();
- IOption opt = optRef.getOption();
- try {
- switch (opt.getValueType()) {
- case IOption.BOOLEAN:
- new OptionReference(newRef, opt).setValue(optRef.getBooleanValue());
- break;
- case IOption.STRING:
- new OptionReference(newRef, opt).setValue(optRef.getStringValue());
- break;
- case IOption.ENUMERATED:
- new OptionReference(newRef, opt).setValue(optRef.getSelectedEnum());
- break;
- case IOption.STRING_LIST :
- new OptionReference(newRef, opt).setValue(optRef.getStringListValue());
- break;
- case IOption.INCLUDE_PATH :
- new OptionReference(newRef, opt).setValue(optRef.getIncludePaths());
- break;
- case IOption.PREPROCESSOR_SYMBOLS :
- new OptionReference(newRef, opt).setValue(optRef.getDefinedSymbols());
- break;
- case IOption.LIBRARIES :
- new OptionReference(newRef, opt).setValue(optRef.getLibraries());
- break;
- case IOption.OBJECTS :
- new OptionReference(newRef, opt).setValue(optRef.getUserObjects());
- break;
- }
- } catch (BuildException e) {
- continue;
- }
- }
+ ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
+ Element resElement = doc.createElement(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME);
+ element.appendChild(resElement);
+ resConfig.serialize(doc, resElement);
}
- target.addConfiguration(this);
+ // I am clean now
+ isDirty = false;
}
- /**
- * Create a new Configuration
based on the specification in the plugin manifest.
- *
- * @param target The Target
the receiver will be added to.
- * @param element The element from the manifest that contains the default configuration settings.
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
*/
- public Configuration(Target target, IManagedConfigElement element) {
- this.target = target;
-
- // setup for resolving
- ManagedBuildManager.putConfigElement(this, element);
- resolved = false;
-
- // id
- setId(element.getAttribute(IConfiguration.ID));
-
- // hook me up
- target.addConfiguration(this);
-
- // name
- setName(element.getAttribute(IConfiguration.NAME));
-
- IManagedConfigElement[] configElements = element.getChildren();
- for (int l = 0; l < configElements.length; ++l) {
- IManagedConfigElement configElement = configElements[l];
- if (configElement.getName().equals(IConfiguration.TOOLREF_ELEMENT_NAME)) {
- new ToolReference(this, configElement);
- }
- }
- }
-
- /**
- * A fresh new configuration for a target.
- *
- * @param target
- * @param id
- */
- public Configuration(Target target, String id) {
- this.id = id;
- this.target = target;
-
- target.addConfiguration(this);
- }
-
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
-// IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- Iterator refIter = getLocalToolReferences().iterator();
- while (refIter.hasNext()) {
- ToolReference ref = (ToolReference)refIter.next();
- ref.resolveReferences();
- }
- }
- }
-
- /**
- * Adds a tool reference to the receiver.
- *
- * @param toolRef
- */
- public void addToolReference(ToolReference toolRef) {
- getLocalToolReferences().add(toolRef);
- }
/* (non-Javadoc)
- * @param option
- * @return
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
*/
- private OptionReference createOptionReference(IOption option) {
- ToolReference searchRef = null;
- ToolReference answer = null;
- // The option may already be a reference created to hold user settings
- if (option instanceof OptionReference) {
- // The option reference belongs to an existing tool reference
- OptionReference optionRef = (OptionReference)option;
- searchRef = optionRef.getToolReference();
-
- // That tool reference may belong to a target or to the configuration
- if (searchRef.ownedByConfiguration(this))
- return optionRef;
- else {
- // All this means is that the tool ref does not belong to the receiver.
- // The receiver may also have a reference to the tool
- if ((answer = findLocalReference(searchRef)) == null) {
- // Otherwise, create one and save the option setting in it
- answer = new ToolReference(this, searchRef);
- }
- return answer.createOptionReference(option);
- }
- } else {
- // Find out if a tool reference already exists
- searchRef = (ToolReference) getToolReference(option.getTool());
- if (searchRef == null) {
- answer = new ToolReference(this, option.getTool());
- } else {
- // The reference may belong to the target
- if (!searchRef.ownedByConfiguration(this)) {
- answer = new ToolReference(this, searchRef);
- } else {
- answer = searchRef;
- }
- }
- return answer.createOptionReference(option);
- }
+ public IConfiguration getParent() {
+ return parent;
}
/* (non-Javadoc)
- * @param toolRef
- * @return
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getOwner()
*/
- private ToolReference findLocalReference(ToolReference toolRef) {
- Iterator iter = getLocalToolReferences().iterator();
-
+ public IResource getOwner() {
+ if (managedProject != null)
+ return managedProject.getOwner();
+ else {
+ return null; // Extension configurations don't have an "owner"
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getProjectType()
+ */
+ public IProjectType getProjectType() {
+ return (IProjectType)projectType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getManagedProject()
+ */
+ public IManagedProject getManagedProject() {
+ return (IManagedProject)managedProject;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain(IToolChain, String, String, boolean)
+ */
+ public IToolChain createToolChain(IToolChain superClass, String Id, String name, boolean isExtensionElement) {
+ toolChain = new ToolChain(this, superClass, Id, name, isExtensionElement);
+ setDirty(true);
+ return (IToolChain)toolChain;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain()
+ */
+ public IToolChain getToolChain() {
+ return (IToolChain)toolChain;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getResourceConfigurations()
+ */
+ public IResourceConfiguration[] getResourceConfigurations() {
+ IResourceConfiguration[] resConfigs = new IResourceConfiguration[getResourceConfigurationList().size()];
+ Iterator iter = getResourceConfigurationList().listIterator();
+ int i = 0;
while (iter.hasNext()) {
- ToolReference ref = (ToolReference)iter.next();
- if (toolRef.getTool().equals(ref.getTool())) {
- return ref;
- }
+ ResourceConfiguration resConfig = (ResourceConfiguration)iter.next();
+ resConfigs[i++] = (IResourceConfiguration)resConfig;
}
-
- return null;
+ return resConfigs;
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools(org.eclipse.core.resources.IProject)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceConfiguration(java.lang.String)
*/
- public ITool[] getFilteredTools(IProject project) {
- ITool[] localTools = getTools();
+ public IResourceConfiguration getResourceConfiguration(String resPath) {
+ ResourceConfiguration resConfig = (ResourceConfiguration)getResourceConfigurationMap().get(resPath);
+ return (IResourceConfiguration)resConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools()
+ */
+ public ITool[] getFilteredTools() {
+ if (toolChain == null) {
+ return new ITool[0];
+ }
+ ITool[] localTools = toolChain.getTools();
+ IManagedProject manProj = getManagedProject();
+ if (manProj == null) {
+ // If this is not associated with a project, then there is nothing to filter with
+ return localTools;
+ }
+ IProject project = (IProject)manProj.getOwner();
Vector tools = new Vector(localTools.length);
for (int i = 0; i < localTools.length; i++) {
ITool tool = localTools[i];
@@ -322,307 +525,109 @@ public class Configuration extends BuildObject implements IConfiguration {
return (ITool[])tools.toArray(new ITool[tools.size()]);
}
- /* (non-javadoc)
- * A safety method to avoid NPEs. It answers the tool reference list in the
- * receiver. It does not look at the tool references defined in the parent.
- *
- * @return List
- */
- protected List getLocalToolReferences() {
- if (toolReferences == null) {
- toolReferences = new ArrayList();
- }
- return toolReferences;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
- */
- public String getName() {
- return (name == null && parent != null) ? parent.getName() : name;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
*/
public ITool[] getTools() {
- ITool[] tools = parent != null
- ? parent.getTools()
- : target.getTools();
-
- // Validate that the tools correspond to the nature
- IProject project = (IProject)target.getOwner();
- if (project != null) {
- List validTools = new ArrayList();
-
- // The target is associated with a real project
- for (int i = 0; i < tools.length; ++i) {
- ITool tool = tools[i];
- // Make sure the tool filter and project nature agree
- switch (tool.getNatureFilter()) {
- case ITool.FILTER_C:
- try {
- if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- validTools.add(tool);
- }
- } catch (CoreException e) {
- continue;
- }
- break;
- case ITool.FILTER_CC:
- try {
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- validTools.add(tool);
- }
- } catch (CoreException e) {
- continue;
- }
- break;
- case ITool.FILTER_BOTH:
- validTools.add(tool);
- break;
- }
- }
- // Now put the valid tools back into the array
- tools = (ITool[]) validTools.toArray(new ITool[validTools.size()]);
- }
-
- // Replace tools with local overrides
- for (int i = 0; i < tools.length; ++i) {
- IToolReference ref = getToolReference(tools[i]);
- if (ref != null)
- tools[i] = ref;
- }
-
- return tools;
+ return toolChain.getTools();
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isDirty()
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTool(java.lang.String)
*/
- public boolean isDirty() {
- // If I need saving, just say yes
- if (isDirty) return true;
-
- // Otherwise see if any tool references need saving
- Iterator iter = getLocalToolReferences().listIterator();
- while (iter.hasNext()) {
- IToolReference ref = (IToolReference) iter.next();
- if (ref.isDirty()) return true;
- }
-
- return isDirty;
+ public ITool getTool(String id) {
+ return toolChain.getTool(id);
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#needsRebuild()
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
*/
- public boolean needsRebuild() {
- return rebuildNeeded;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
- */
- public IConfiguration getParent() {
- return parent;
- }
-
- /* (non-javadoc)
- *
- * @param tool
- * @return List
- */
- protected List getOptionReferences(ITool tool) {
- List references = new ArrayList();
-
- // Get all the option references I add for this tool
- IToolReference toolRef = getToolReference(tool);
- if (toolRef != null) {
- references.addAll(toolRef.getOptionReferenceList());
- }
-
- // See if there is anything that my parents add that I don't
- if (parent != null) {
- List temp = ((Configuration)parent).getOptionReferences(tool);
- Iterator iter = temp.listIterator();
- while (iter.hasNext()) {
- OptionReference ref = (OptionReference) iter.next();
- if (!references.contains(ref)) {
- references.add(ref);
- }
- }
- }
-
- return references;
+ public String getToolCommand(ITool tool) {
+ // TODO: Do we need to verify that the tool is part of the configuration?
+ return tool.getToolCommand();
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolById(java.lang.String)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
*/
- public ITool getToolById(String id) {
- ITool[] tools = parent != null
- ? parent.getTools()
- : target.getTools();
-
- // Replace tools with local overrides
- for (int i = 0; i < tools.length; ++i) {
- IToolReference ref = getToolReference(tools[i]);
- if (ref != null)
- tools[i] = ref;
- }
-
- // Search the result for the ID
- for (int index = tools.length - 1; index >= 0; --index) {
- if (tools[index].getId().equals(id)) {
- return tools[index];
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getTarget()
- */
- public ITarget getTarget() {
- return (target == null && parent != null) ? parent.getTarget() : target;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IConfiguration#getOwner()
- */
- public IResource getOwner() {
- return getTarget().getOwner();
- }
-
- /* (non-Javadoc)
- * Returns the reference for a given tool or null
if one is not
- * found.
- *
- * @param tool
- * @return ToolReference
- */
- private IToolReference getToolReference(ITool tool) {
- // Sanity
- if (tool == null) return null;
-
- // See if the receiver has a reference to the tool
- Iterator iter = getLocalToolReferences().listIterator();
- while (iter.hasNext()) {
- ToolReference temp = (ToolReference)iter.next();
- if (temp.references(tool)) {
- return temp;
- }
- }
-
- // See if the target that the receiver belongs to has a reference to the tool
- ITool[] targetTools = target.getTools();
- for (int index = targetTools.length - 1; index >= 0; --index) {
- ITool targetTool = targetTools[index];
- if (targetTool instanceof ToolReference) {
- if (((ToolReference)targetTool).references(tool)) {
- return (ToolReference)targetTool;
- }
- }
- }
- return null;
- }
-
- /**
- * @param targetElement
- */
- public void reset(IManagedConfigElement element) {
- // I just need to reset the tool references
- getLocalToolReferences().clear();
- IManagedConfigElement[] configElements = element.getChildren();
- for (int l = 0; l < configElements.length; ++l) {
- IManagedConfigElement configElement = configElements[l];
- if (configElement.getName().equals(IConfiguration.TOOLREF_ELEMENT_NAME)) {
- ToolReference ref = new ToolReference(this, configElement);
- ref.resolveReferences();
- }
- }
- isDirty = true;
- }
-
- /**
- * Persist receiver to project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- element.setAttribute(IConfiguration.ID, id);
-
- if (name != null)
- element.setAttribute(IConfiguration.NAME, name);
-
- if (parent != null)
- element.setAttribute(IConfiguration.PARENT, parent.getId());
-
- // Serialize only the tool references defined in the configuration
- Iterator iter = getLocalToolReferences().listIterator();
- while (iter.hasNext()) {
- ToolReference toolRef = (ToolReference) iter.next();
- Element toolRefElement = doc.createElement(IConfiguration.TOOLREF_ELEMENT_NAME);
- element.appendChild(toolRefElement);
- toolRef.serialize(doc, toolRefElement);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- // Override the dirty flag
- this.isDirty = isDirty;
- // And do the same for the tool references
- Iterator iter = getLocalToolReferences().listIterator();
- while (iter.hasNext()) {
- ((ToolReference)iter.next()).setDirty(isDirty);
- }
+ public void setToolCommand(ITool tool, String command) {
+ // TODO: Do we need to verify that the tool is part of the configuration?
+ tool.setToolCommand(command);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
*/
- public void setOption(IOption option, boolean value) throws BuildException {
- // Is there a delta
+ public IOption setOption(ITool tool, IOption option, boolean value) throws BuildException {
+ // Is there a change?
+ IOption retOpt = option;
if (option.getBooleanValue() != value) {
- createOptionReference(option).setValue(value);
- isDirty = true;
+ if (option.isExtensionElement()) {
+ // If the extension element is only overriding the "value" of its superclass, hook the
+ // new option up to its superclass directly. This is to avoid references to oddly id'ed
+ // elements that are automatically generated from V2.0 model optionReferences. If these
+ // end up in the project file, then the project could have a problem when the integration
+ // provider switches to providing the new model.
+ IOption newSuperClass = option;
+ if (option.overridesOnlyValue()) {
+ newSuperClass = option.getSuperClass();
+ }
+ // Create an Option element for the managed build project file (.CDTBUILD)
+ String subId;
+ int nnn = ManagedBuildManager.getRandomNumber();
+ subId = newSuperClass.getId() + "." + nnn; //$NON-NLS-1$
+ retOpt = tool.createOption(newSuperClass, subId, null, false);
+ retOpt.setValueType(option.getValueType());
+ retOpt.setValue(value);
+ setDirty(true);
+ } else {
+ option.setValue(value);
+ }
rebuildNeeded = true;
}
+ return retOpt;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
*/
- public void setOption(IOption option, String value) throws BuildException {
+ public IOption setOption(ITool tool, IOption option, String value) throws BuildException {
+ IOption retOpt = option;
String oldValue;
- // Check whether this is an enumerated option
- if (option.getValueType() == IOption.ENUMERATED) {
- oldValue = option.getSelectedEnum();
- }
- else {
- oldValue = option.getStringValue();
- }
+ oldValue = option.getStringValue();
if (oldValue != null && !oldValue.equals(value)) {
- createOptionReference(option).setValue(value);
- isDirty = true;
+ if (option.isExtensionElement()) {
+ // If the extension element is only overriding the "value" of its superclass, hook the
+ // new option up to its superclass directly. This is to avoid references to oddly id'ed
+ // elements that are automatically generated from V2.0 model optionReferences. If these
+ // end up in the project file, then the project could have a problem when the integration
+ // provider switches to providing the new model.
+ IOption newSuperClass = option;
+ if (option.overridesOnlyValue()) {
+ newSuperClass = option.getSuperClass();
+ }
+ // Create an Option element for the managed build project file (.CDTBUILD)
+ String subId;
+ int nnn = ManagedBuildManager.getRandomNumber();
+ subId = newSuperClass.getId() + "." + nnn; //$NON-NLS-1$
+ retOpt = tool.createOption(newSuperClass, subId, null, false);
+ retOpt.setValueType(option.getValueType());
+ retOpt.setValue(value);
+ setDirty(true);
+ } else {
+ option.setValue(value);
+ }
rebuildNeeded = true;
}
+ return retOpt;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
*/
- public void setOption(IOption option, String[] value) throws BuildException {
- // Is there a delta
+ public IOption setOption(ITool tool, IOption option, String[] value) throws BuildException {
+ IOption retOpt = option;
+ // Is there a change?
String[] oldValue;
switch (option.getValueType()) {
case IOption.STRING_LIST :
@@ -645,10 +650,338 @@ public class Configuration extends BuildObject implements IConfiguration {
break;
}
if(!Arrays.equals(value, oldValue)) {
- createOptionReference(option).setValue(value);
- isDirty = true;
+ if (option.isExtensionElement()) {
+ // If the extension element is only overriding the "value" of its superclass, hook the
+ // new option up to its superclass directly. This is to avoid references to oddly id'ed
+ // elements that are automatically generated from V2.0 model optionReferences. If these
+ // end up in the project file, then the project could have a problem when the integration
+ // provider switches to providing the new model.
+ IOption newSuperClass = option;
+ if (option.overridesOnlyValue()) {
+ newSuperClass = option.getSuperClass();
+ }
+ // Create an Option element for the managed build project file (.CDTBUILD)
+ String subId;
+ int nnn = ManagedBuildManager.getRandomNumber();
+ subId = newSuperClass.getId() + "." + nnn; //$NON-NLS-1$
+ retOpt = tool.createOption(newSuperClass, subId, null, false);
+ retOpt.setValueType(option.getValueType());
+ retOpt.setValue(value);
+ setDirty(true);
+ } else {
+ option.setValue(value);
+ }
rebuildNeeded = true;
}
+ return retOpt;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the list of resource configs.
+ *
+ * @return List containing the tools
+ */
+ private List getResourceConfigurationList() {
+ if (resourceConfigurationList == null) {
+ resourceConfigurationList = new ArrayList();
+ }
+ return resourceConfigurationList;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of resource paths to resource configs
+ *
+ * @return
+ */
+ private Map getResourceConfigurationMap() {
+ if (resourceConfigurationMap == null) {
+ resourceConfigurationMap = new HashMap();
+ }
+ return resourceConfigurationMap;
+ }
+
+ /* (non-Javadoc)
+ * Adds the Resource Configuration to the Resource Configuration list and map
+ *
+ * @param resConfig
+ */
+ public void addResourceConfiguration(ResourceConfiguration resConfig) {
+ getResourceConfigurationList().add(resConfig);
+ getResourceConfigurationMap().put(resConfig.getResourcePath(), resConfig);
+ }
+
+ public void removeResourceConfiguration(IResourceConfiguration resConfig) {
+ getResourceConfigurationList().remove((ResourceConfiguration)resConfig);
+ }
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getName()
+ */
+ public String getName() {
+ return (name == null && parent != null) ? parent.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getArtifactExtension()
+ */
+ public String getArtifactExtension() {
+ if (artifactExtension == null) {
+ // Ask my parent first
+ if (parent != null) {
+ return parent.getArtifactExtension();
+ } else {
+ return EMPTY_STRING;
+ }
+ } else {
+ return artifactExtension;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getArtifactName()
+ */
+ public String getArtifactName() {
+ if (artifactName == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getArtifactName();
+ } else {
+ // I'm it and this is not good!
+ return EMPTY_STRING;
+ }
+ } else {
+ return artifactName;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildArguments()
+ */
+ public String getBuildArguments() {
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if (builder != null) {
+ return builder.getArguments();
+ }
+ return new String("-k"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildCommand()
+ */
+ public String getBuildCommand() {
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if (builder != null) {
+ return builder.getCommand();
+ }
+ return new String("make"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#getCleanCommand()
+ */
+ public String getCleanCommand() {
+ // Return the command used to remove files
+ if (cleanCommand == null) {
+ if (parent != null) {
+ return parent.getCleanCommand();
+ } else {
+ // User forgot to specify it. Guess based on OS.
+ if (Platform.getOS().equals("OS_WIN32")) { //$NON-NLS-1$
+ return new String("del"); //$NON-NLS-1$
+ } else {
+ return new String("rm"); //$NON-NLS-1$
+ }
+ }
+ } else {
+ // This was spec'd in the manifest
+ return cleanCommand;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ if (errorParserIds != null) {
+ return errorParserIds;
+ }
+ // If I have a parent, ask it
+ String errorParsers = null;
+ if (parent != null) {
+ errorParsers = parent.getErrorParserIds();
+ }
+ // If no error parsers are specified by the configuration, the default is
+ // the error parsers from the tool-chain
+ if (errorParsers == null && toolChain != null) {
+ errorParsers = toolChain.getErrorParserIds(this);
+ }
+ return errorParsers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ String parserIDs = getErrorParserIds();
+ String[] errorParsers;
+ if (parserIDs != null) {
+ // Check for an empty string
+ if (parserIDs.length() == 0) {
+ errorParsers = new String[0];
+ } else {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ List list = new ArrayList(tok.countTokens());
+ while (tok.hasMoreElements()) {
+ list.add(tok.nextToken());
+ }
+ String[] strArr = {""}; //$NON-NLS-1$
+ errorParsers = (String[]) list.toArray(strArr);
+ }
+ } else {
+ // If no error parsers are specified, the default is
+ // all error parsers
+ errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
+ }
+ return errorParsers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String)
+ */
+ public void setArtifactExtension(String extension) {
+ if (extension == null && artifactExtension == null) return;
+ if (artifactExtension == null || extension == null || !artifactExtension.equals(extension)) {
+ artifactExtension = extension;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfiguration#setArtifactName(java.lang.String)
+ */
+ public void setArtifactName(String name) {
+ if (name == null && artifactName == null) return;
+ if (artifactName == null || name == null || !artifactName.equals(name)) {
+ artifactName = name;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ String currentIds = getErrorParserIds();
+ if (ids == null && currentIds == null) return;
+ if (currentIds == null || ids == null || !(currentIds.equals(ids))) {
+ errorParserIds = ids;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setCleanCommand()
+ */
+ public void setCleanCommand(String command) {
+ if (command == null && cleanCommand == null) return;
+ if (cleanCommand == null || command == null || !cleanCommand.equals(command)) {
+ cleanCommand = command;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildArguments()
+ */
+ public void setBuildArguments(String makeArgs) {
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if (builder.isExtensionElement()) {
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId = builder.getId() + "." + nnn; //$NON-NLS-1$
+ String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
+ builder = toolChain.createBuilder(builder, subId, builderName, false);
+ }
+ builder.setArguments(makeArgs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildCommand()
+ */
+ public void setBuildCommand(String command) {
+ IToolChain tc = getToolChain();
+ IBuilder builder = tc.getBuilder();
+ if (builder.isExtensionElement()) {
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId = builder.getId() + "." + nnn; //$NON-NLS-1$
+ String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
+ builder = toolChain.createBuilder(builder, subId, builderName, false);
+ }
+ builder.setCommand(command);
+ }
+
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension configuration
+ if (isExtensionConfig) return false;
+
+ // If I need saving, just say yes
+ if (isDirty) return true;
+
+ // Otherwise see if any children need saving
+ if (toolChain.isDirty()) return true;
+ Iterator iter = getResourceConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ ResourceConfiguration current = (ResourceConfiguration) iter.next();
+ if (current.isDirty()) return true;
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#needsRebuild()
+ */
+ public boolean needsRebuild() {
+ return rebuildNeeded;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ // Override the dirty flag
+ this.isDirty = isDirty;
+ // Propagate "false" to the children
+ if (!isDirty) {
+ toolChain.setDirty(false);
+ Iterator iter = getResourceConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ ResourceConfiguration current = (ResourceConfiguration) iter.next();
+ current.setDirty(false);
+ }
+ }
}
/* (non-Javadoc)
@@ -659,23 +992,90 @@ public class Configuration extends BuildObject implements IConfiguration {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#hasOverriddenBuildCommand()
*/
- public void setToolCommand(ITool tool, String command) {
- // Make sure the command is different
- if (command != null) {
- // Does this config have a ref to the tool
- IToolReference ref = getToolReference(tool);
- if (ref == null) {
- // Then make one
- ref = new ToolReference(this, tool);
+ public boolean hasOverriddenBuildCommand() {
+ IBuilder builder = getToolChain().getBuilder();
+ if (builder != null) {
+ IBuilder superB = builder.getSuperClass();
+ if (superB != null) {
+ String command = builder.getCommand();
+ if (command != null) {
+ String superC = superB.getCommand();
+ if (superC != null) {
+ if (!command.equals(superC)) {
+ return true;
+ }
+ }
+ }
+ String args = builder.getArguments();
+ if (args != null) {
+ String superA = superB.getArguments();
+ if (superA != null) {
+ if (!args.equals(superA)) {
+ return true;
+ }
+ }
+ }
}
- // Set the ref's command
- if (ref != null) {
- isDirty = ref.setToolCommand(command);
- rebuildNeeded = isDirty;
+ }
+ return false;
+ }
+
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+
+ // call resolve references on any children
+ toolChain.resolveReferences();
+ Iterator resConfigIter = getResourceConfigurationList().iterator();
+ while (resConfigIter.hasNext()) {
+ ResourceConfiguration current = (ResourceConfiguration)resConfigIter.next();
+ current.resolveReferences();
+ }
+ }
+ }
+
+ /**
+ * Reset the configuration's, tools', options
+ */
+ public void reset() {
+ // We just need to remove all Options
+ ITool[] tools = getTools();
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ IOption[] opts = tool.getOptions();
+ for (int j = 0; j < opts.length; j++) {
+ tool.removeOption(opts[j]);
}
}
}
+ /*
+ * Create a resource configuration object for the passed-in file
+ */
+ public IResourceConfiguration createResourceConfiguration(IFile file)
+ {
+ String path = file.getFullPath().toString();
+ String resourceName = file.getName();
+ String id = getId() + "." + path; //$NON-NLS-1$
+ ResourceConfiguration resConfig = new ResourceConfiguration( (IConfiguration) this, id, resourceName, path);
+
+ // Get file extension.
+ String extString = file.getFileExtension();
+
+ // Add the resource specific tools to this resource.
+ ITool tools[] = getFilteredTools();
+ String subId = new String();
+ for (int i = 0; i < tools.length; i++) {
+ if( tools[i].buildsFileType(extString) ) {
+ subId = tools[i].getId() + "." + path; //$NON-NLS-1$
+ resConfig.createTool(tools[i], subId, tools[i].getName(), false);
+ }
+ }
+
+ // Add this resource to the list.
+ addResourceConfiguration(resConfig);
+ return resConfig;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConfigurationV2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConfigurationV2.java
new file mode 100644
index 00000000000..ad401d1eb1d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ConfigurationV2.java
@@ -0,0 +1,710 @@
+/**********************************************************************
+ * Copyright (c) 2003,2004 IBM Rational Software 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.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolReference;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class is deprecated in 2.1
+ */
+public class ConfigurationV2 extends BuildObject implements IConfigurationV2 {
+ private boolean isDirty = false;
+ private IConfigurationV2 parent;
+ private boolean rebuildNeeded = false;
+ private boolean resolved = true;
+ private ITarget target;
+ private List toolReferences;
+ private IConfiguration createdConfig;
+
+ /**
+ * Build a configuration from the project manifest file.
+ *
+ * @param target The Target
the configuration belongs to.
+ * @param element The element from the manifest that contains the overridden configuration information.
+ */
+ public ConfigurationV2(Target target, Element element) {
+ this.target = target;
+
+ // id
+ setId(element.getAttribute(IConfigurationV2.ID));
+
+ // hook me up
+ target.addConfiguration(this);
+
+ // name
+ if (element.hasAttribute(IConfigurationV2.NAME))
+ setName(element.getAttribute(IConfigurationV2.NAME));
+
+ if (element.hasAttribute(IConfigurationV2.PARENT)) {
+ // See if the target has a parent
+ ITarget targetParent = target.getParent();
+ // If so, then get my parent from it
+ if (targetParent != null) {
+ parent = targetParent.getConfiguration(element.getAttribute(IConfigurationV2.PARENT));
+ }
+ else {
+ parent = null;
+ }
+ }
+
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(IConfigurationV2.TOOLREF_ELEMENT_NAME)) {
+ new ToolReference(this, (Element)configElement);
+ }
+ }
+
+ }
+
+ /**
+ * Create a new configuration based on one already defined.
+ *
+ * @param target The Target
the receiver will be added to.
+ * @param parentConfig The IConfigurationV2
to copy the settings from.
+ * @param id A unique ID for the configuration.
+ */
+ public ConfigurationV2(Target target, IConfigurationV2 parentConfig, String id) {
+ this.id = id;
+ this.name = parentConfig.getName();
+ this.target = target;
+
+ // If this contructor is called to clone an existing
+ // configuration, the parent of the parent should be stored.
+ // As of 2.0, there is still one single level of inheritence to
+ // worry about
+ parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent();
+
+ // Check that the tool and the project match
+ IProject project = (IProject) target.getOwner();
+
+ // Get the tool references from the target and parent
+ List allToolRefs = new Vector(target.getLocalToolReferences());
+ allToolRefs.addAll(((ConfigurationV2)parentConfig).getLocalToolReferences());
+ Iterator iter = allToolRefs.listIterator();
+ while (iter.hasNext()) {
+ ToolReference toolRef = (ToolReference)iter.next();
+
+ // Make a new ToolReference based on the tool in the ref
+ ITool parentTool = toolRef.getTool();
+ ToolReference newRef = new ToolReference(this, parentTool);
+
+ // The reference may have a different command than the parent tool
+ String refCmd = toolRef.getToolCommand();
+ if (!refCmd.equals(parentTool.getToolCommand())) {
+ newRef.setToolCommand(refCmd);
+ }
+
+ List optRefs = toolRef.getOptionReferenceList();
+ Iterator optIter = optRefs.listIterator();
+ while (optIter.hasNext()) {
+ OptionReference optRef = (OptionReference)optIter.next();
+ IOption opt = optRef.getOption();
+ try {
+ switch (opt.getValueType()) {
+ case IOption.BOOLEAN:
+ new OptionReference(newRef, opt).setValue(optRef.getBooleanValue());
+ break;
+ case IOption.STRING:
+ new OptionReference(newRef, opt).setValue(optRef.getStringValue());
+ break;
+ case IOption.ENUMERATED:
+ new OptionReference(newRef, opt).setValue(optRef.getSelectedEnum());
+ break;
+ case IOption.STRING_LIST :
+ new OptionReference(newRef, opt).setValue(optRef.getStringListValue());
+ break;
+ case IOption.INCLUDE_PATH :
+ new OptionReference(newRef, opt).setValue(optRef.getIncludePaths());
+ break;
+ case IOption.PREPROCESSOR_SYMBOLS :
+ new OptionReference(newRef, opt).setValue(optRef.getDefinedSymbols());
+ break;
+ case IOption.LIBRARIES :
+ new OptionReference(newRef, opt).setValue(optRef.getLibraries());
+ break;
+ case IOption.OBJECTS :
+ new OptionReference(newRef, opt).setValue(optRef.getUserObjects());
+ break;
+ }
+ } catch (BuildException e) {
+ continue;
+ }
+ }
+ }
+
+ target.addConfiguration(this);
+ }
+
+ /**
+ * Create a new ConfigurationV2
based on the specification in the plugin manifest.
+ *
+ * @param target The Target
the receiver will be added to.
+ * @param element The element from the manifest that contains the default configuration settings.
+ */
+ public ConfigurationV2(Target target, IManagedConfigElement element) {
+ this.target = target;
+
+ // setup for resolving
+ ManagedBuildManager.putConfigElement(this, element);
+ resolved = false;
+
+ // id
+ setId(element.getAttribute(IConfigurationV2.ID));
+
+ // hook me up
+ target.addConfiguration(this);
+
+ // name
+ setName(element.getAttribute(IConfigurationV2.NAME));
+
+ IManagedConfigElement[] configElements = element.getChildren();
+ for (int l = 0; l < configElements.length; ++l) {
+ IManagedConfigElement configElement = configElements[l];
+ if (configElement.getName().equals(IConfigurationV2.TOOLREF_ELEMENT_NAME)) {
+ new ToolReference(this, configElement);
+ }
+ }
+ }
+
+ /**
+ * A fresh new configuration for a target.
+ *
+ * @param target
+ * @param id
+ */
+ public ConfigurationV2(Target target, String id) {
+ this.id = id;
+ this.target = target;
+
+ target.addConfiguration(this);
+ }
+
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+// IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ Iterator refIter = getLocalToolReferences().iterator();
+ while (refIter.hasNext()) {
+ ToolReference ref = (ToolReference)refIter.next();
+ ref.resolveReferences();
+ }
+ }
+ }
+
+ /**
+ * Adds a tool reference to the receiver.
+ *
+ * @param toolRef
+ */
+ public void addToolReference(ToolReference toolRef) {
+ getLocalToolReferences().add(toolRef);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#getToolReferences()
+ */
+ public IToolReference[] getToolReferences() {
+ List list = getLocalToolReferences();
+ IToolReference[] tools = new IToolReference[list.size()];
+ list.toArray(tools);
+ return tools;
+ }
+
+ /* (non-Javadoc)
+ * @param option
+ * @return
+ */
+ private OptionReference createOptionReference(IOption option) {
+ ToolReference searchRef = null;
+ ToolReference answer = null;
+ // The option may already be a reference created to hold user settings
+ if (option instanceof OptionReference) {
+ // The option reference belongs to an existing tool reference
+ OptionReference optionRef = (OptionReference)option;
+ searchRef = optionRef.getToolReference();
+
+ // That tool reference may belong to a target or to the configuration
+ if (searchRef.ownedByConfiguration(this))
+ return optionRef;
+ else {
+ // All this means is that the tool ref does not belong to the receiver.
+ // The receiver may also have a reference to the tool
+ if ((answer = findLocalReference(searchRef)) == null) {
+ // Otherwise, create one and save the option setting in it
+ answer = new ToolReference(this, searchRef);
+ }
+ return answer.createOptionReference(option);
+ }
+ } else {
+ // Find out if a tool reference already exists
+ searchRef = (ToolReference) getToolReference(option.getParent());
+ if (searchRef == null) {
+ answer = new ToolReference(this, option.getParent());
+ } else {
+ // The reference may belong to the target
+ if (!searchRef.ownedByConfiguration(this)) {
+ answer = new ToolReference(this, searchRef);
+ } else {
+ answer = searchRef;
+ }
+ }
+ return answer.createOptionReference(option);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @param toolRef
+ * @return
+ */
+ private ToolReference findLocalReference(ToolReference toolRef) {
+ Iterator iter = getLocalToolReferences().iterator();
+
+ while (iter.hasNext()) {
+ ToolReference ref = (ToolReference)iter.next();
+ if (toolRef.getTool().equals(ref.getTool())) {
+ return ref;
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#getFilteredTools(org.eclipse.core.resources.IProject)
+ */
+ public ITool[] getFilteredTools(IProject project) {
+ ITool[] localTools = getTools();
+ Vector tools = new Vector(localTools.length);
+ for (int i = 0; i < localTools.length; i++) {
+ ITool tool = localTools[i];
+ try {
+ // Make sure the tool is right for the project
+ switch (tool.getNatureFilter()) {
+ case ITool.FILTER_C:
+ if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ tools.add(tool);
+ }
+ break;
+ case ITool.FILTER_CC:
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ tools.add(tool);
+ }
+ break;
+ case ITool.FILTER_BOTH:
+ tools.add(tool);
+ break;
+ default:
+ break;
+ }
+ } catch (CoreException e) {
+ continue;
+ }
+ }
+
+ // Answer the filtered tools as an array
+ return (ITool[])tools.toArray(new ITool[tools.size()]);
+ }
+
+ /* (non-javadoc)
+ * A safety method to avoid NPEs. It answers the tool reference list in the
+ * receiver. It does not look at the tool references defined in the parent.
+ *
+ * @return List
+ */
+ protected List getLocalToolReferences() {
+ if (toolReferences == null) {
+ toolReferences = new ArrayList();
+ }
+ return toolReferences;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#getName()
+ */
+ public String getName() {
+ return (name == null && parent != null) ? parent.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#getTools()
+ */
+ public ITool[] getTools() {
+ ITool[] tools = parent != null
+ ? parent.getTools()
+ : target.getTools();
+
+ // Validate that the tools correspond to the nature
+ IProject project = (IProject)target.getOwner();
+ if (project != null) {
+ List validTools = new ArrayList();
+
+ // The target is associated with a real project
+ for (int i = 0; i < tools.length; ++i) {
+ ITool tool = tools[i];
+ // Make sure the tool filter and project nature agree
+ switch (tool.getNatureFilter()) {
+ case ITool.FILTER_C:
+ try {
+ if (project.hasNature(CProjectNature.C_NATURE_ID) && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ validTools.add(tool);
+ }
+ } catch (CoreException e) {
+ continue;
+ }
+ break;
+ case ITool.FILTER_CC:
+ try {
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+ validTools.add(tool);
+ }
+ } catch (CoreException e) {
+ continue;
+ }
+ break;
+ case ITool.FILTER_BOTH:
+ validTools.add(tool);
+ break;
+ }
+ }
+ // Now put the valid tools back into the array
+ tools = (ITool[]) validTools.toArray(new ITool[validTools.size()]);
+ }
+
+ // Replace tools with local overrides
+ for (int i = 0; i < tools.length; ++i) {
+ IToolReference ref = getToolReference(tools[i]);
+ if (ref != null)
+ tools[i] = ref;
+ }
+
+ return tools;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#isDirty()
+ */
+ public boolean isDirty() {
+ // If I need saving, just say yes
+ if (isDirty) return true;
+
+ // Otherwise see if any tool references need saving
+ Iterator iter = getLocalToolReferences().listIterator();
+ while (iter.hasNext()) {
+ IToolReference ref = (IToolReference) iter.next();
+ if (ref.isDirty()) return true;
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#needsRebuild()
+ */
+ public boolean needsRebuild() {
+ return rebuildNeeded;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#getParent()
+ */
+ public IConfigurationV2 getParent() {
+ return parent;
+ }
+
+ /* (non-javadoc)
+ *
+ * @param tool
+ * @return List
+ */
+ protected List getOptionReferences(ITool tool) {
+ List references = new ArrayList();
+
+ // Get all the option references I add for this tool
+ IToolReference toolRef = getToolReference(tool);
+ if (toolRef != null) {
+ references.addAll(toolRef.getOptionReferenceList());
+ }
+
+ // See if there is anything that my parents add that I don't
+ if (parent != null) {
+ List temp = ((ConfigurationV2)parent).getOptionReferences(tool);
+ Iterator iter = temp.listIterator();
+ while (iter.hasNext()) {
+ OptionReference ref = (OptionReference) iter.next();
+ if (!references.contains(ref)) {
+ references.add(ref);
+ }
+ }
+ }
+
+ return references;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#getToolById(java.lang.String)
+ */
+ public ITool getToolById(String id) {
+ ITool[] tools = parent != null
+ ? parent.getTools()
+ : target.getTools();
+
+ // Replace tools with local overrides
+ for (int i = 0; i < tools.length; ++i) {
+ IToolReference ref = getToolReference(tools[i]);
+ if (ref != null)
+ tools[i] = ref;
+ }
+
+ // Search the result for the ID
+ for (int index = tools.length - 1; index >= 0; --index) {
+ if (tools[index].getId().equals(id)) {
+ return tools[index];
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#getTarget()
+ */
+ public ITarget getTarget() {
+ return (target == null && parent != null) ? parent.getTarget() : target;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#getOwner()
+ */
+ public IResource getOwner() {
+ return getTarget().getOwner();
+ }
+
+ /* (non-Javadoc)
+ * Returns the reference for a given tool or null
if one is not
+ * found.
+ *
+ * @param tool
+ * @return ToolReference
+ */
+ private IToolReference getToolReference(ITool tool) {
+ // Sanity
+ if (tool == null) return null;
+
+ // See if the receiver has a reference to the tool
+ Iterator iter = getLocalToolReferences().listIterator();
+ while (iter.hasNext()) {
+ ToolReference temp = (ToolReference)iter.next();
+ if (temp.references(tool)) {
+ return temp;
+ }
+ }
+
+ // See if the target that the receiver belongs to has a reference to the tool
+ ITool[] targetTools = target.getTools();
+ for (int index = targetTools.length - 1; index >= 0; --index) {
+ ITool targetTool = targetTools[index];
+ if (targetTool instanceof ToolReference) {
+ if (((ToolReference)targetTool).references(tool)) {
+ return (ToolReference)targetTool;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param targetElement
+ */
+ public void reset(IManagedConfigElement element) {
+ // I just need to reset the tool references
+ getLocalToolReferences().clear();
+ IManagedConfigElement[] configElements = element.getChildren();
+ for (int l = 0; l < configElements.length; ++l) {
+ IManagedConfigElement configElement = configElements[l];
+ if (configElement.getName().equals(IConfigurationV2.TOOLREF_ELEMENT_NAME)) {
+ ToolReference ref = new ToolReference(this, configElement);
+ ref.resolveReferences();
+ }
+ }
+ isDirty = true;
+ }
+
+ /**
+ * Persist receiver to project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ element.setAttribute(IConfigurationV2.ID, id);
+
+ if (name != null)
+ element.setAttribute(IConfigurationV2.NAME, name);
+
+ if (parent != null)
+ element.setAttribute(IConfigurationV2.PARENT, parent.getId());
+
+ // Serialize only the tool references defined in the configuration
+ Iterator iter = getLocalToolReferences().listIterator();
+ while (iter.hasNext()) {
+ ToolReference toolRef = (ToolReference) iter.next();
+ Element toolRefElement = doc.createElement(IConfigurationV2.TOOLREF_ELEMENT_NAME);
+ element.appendChild(toolRefElement);
+ toolRef.serialize(doc, toolRefElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ // Override the dirty flag
+ this.isDirty = isDirty;
+ // And do the same for the tool references
+ Iterator iter = getLocalToolReferences().listIterator();
+ while (iter.hasNext()) {
+ ((ToolReference)iter.next()).setDirty(isDirty);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
+ */
+ public void setOption(IOption option, boolean value) throws BuildException {
+ // Is there a delta
+ if (option.getBooleanValue() != value) {
+ createOptionReference(option).setValue(value);
+ isDirty = true;
+ rebuildNeeded = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
+ */
+ public void setOption(IOption option, String value) throws BuildException {
+ String oldValue;
+ // Check whether this is an enumerated option
+ if (option.getValueType() == IOption.ENUMERATED) {
+ oldValue = option.getSelectedEnum();
+ }
+ else {
+ oldValue = option.getStringValue();
+ }
+ if (oldValue != null && !oldValue.equals(value)) {
+ createOptionReference(option).setValue(value);
+ isDirty = true;
+ rebuildNeeded = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IConfigurationV2#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
+ */
+ public void setOption(IOption option, String[] value) throws BuildException {
+ // Is there a delta
+ String[] oldValue;
+ switch (option.getValueType()) {
+ case IOption.STRING_LIST :
+ oldValue = option.getStringListValue();
+ break;
+ case IOption.INCLUDE_PATH :
+ oldValue = option.getIncludePaths();
+ break;
+ case IOption.PREPROCESSOR_SYMBOLS :
+ oldValue = option.getDefinedSymbols();
+ break;
+ case IOption.LIBRARIES :
+ oldValue = option.getLibraries();
+ break;
+ case IOption.OBJECTS :
+ oldValue = option.getUserObjects();
+ break;
+ default :
+ oldValue = new String[0];
+ break;
+ }
+ if(!Arrays.equals(value, oldValue)) {
+ createOptionReference(option).setValue(value);
+ isDirty = true;
+ rebuildNeeded = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#setRebuildState(boolean)
+ */
+ public void setRebuildState(boolean rebuild) {
+ rebuildNeeded = rebuild;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
+ */
+ public void setToolCommand(ITool tool, String command) {
+ // Make sure the command is different
+ if (command != null) {
+ // Does this config have a ref to the tool
+ IToolReference ref = getToolReference(tool);
+ if (ref == null) {
+ // Then make one
+ ref = new ToolReference(this, tool);
+ }
+ // Set the ref's command
+ if (ref != null) {
+ isDirty = ref.setToolCommand(command);
+ rebuildNeeded = isDirty;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#setCreatedConfig(IConfiguration)
+ */
+ public void setCreatedConfig(IConfiguration config) {
+ createdConfig = config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IConfigurationV2#getCreatedConfig()
+ */
+ public IConfiguration getCreatedConfig() {
+ return createdConfig;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
index bf56a060005..7fe125d4236 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
@@ -1,8 +1,6 @@
-package org.eclipse.cdt.managedbuilder.internal.core;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * Copyright (c) 2002,2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.internal.core;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
import java.io.IOException;
import java.io.OutputStream;
@@ -232,8 +231,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
// Create a makefile generator for the build
- String targetID = info.getDefaultTarget().getParent().getId();
- IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getMakefileGenerator(targetID);
+ IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
// So let's figure out why we got called
@@ -309,8 +307,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Create a makefile generator for the build
status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.build.clean", buildDir.getName()); //$NON-NLS-1$
monitor.subTask(status);
- String targetID = info.getDefaultTarget().getParent().getId();
- IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getMakefileGenerator(targetID);
+ IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
cleanBuild(info, generator, monitor);
}
@@ -352,8 +349,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
checkCancel(monitor);
String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.rebuild.makefiles", getProject().getName()); //$NON-NLS-1$
monitor.subTask(statusMsg);
- String targetID = info.getDefaultTarget().getParent().getId();
- generator = ManagedBuildManager.getMakefileGenerator(targetID);
+ generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
MultiStatus result = generator.regenerateMakefiles();
if (result.getCode() == IStatus.WARNING || result.getCode() == IStatus.INFO) {
@@ -410,6 +406,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
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++) {
@@ -583,7 +586,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
// Flag to the user that make is about to be called
- IPath makeCommand = new Path(info.getMakeCommand());
+ IPath makeCommand = new Path(info.getBuildCommand());
if (makeCommand != null) {
String[] msgs = new String[2];
msgs[0] = makeCommand.toString();
@@ -624,7 +627,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// Get the arguments to be passed to make from build model
ArrayList makeArgs = new ArrayList();
- String arg = info.getMakeArguments();
+ String arg = info.getBuildArguments();
if (arg.length() > 0) {
String[] args = arg.split("\\s"); //$NON-NLS-1$
for (int i = 0; i < args.length; ++i) {
@@ -655,7 +658,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
// Hook up an error parser manager
- String[] errorParsers = info.getDefaultTarget().getErrorParserList();
+ String[] errorParsers = info.getDefaultConfiguration().getErrorParserList();
ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectory, this, errorParsers);
epm.setOutputStream(consoleOutStream);
OutputStream stdout = epm.getOutputStream();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
index c7a0b09f270..3edfd56b327 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
@@ -30,11 +30,17 @@ 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.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-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.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
@@ -60,20 +66,22 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultTarget"); //$NON-NLS-1$
public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
+ private static final String EMPTY_STRING = new String();
- private boolean containerCreated;
- private ICProject cProject;
- private String defaultConfigIds;
- private Map defaultConfigMap;
- private ITarget defaultTarget;
- private String defaultTargetId;
+ private IManagedProject managedProject;
+ private ICProject cProject;
+ private IConfiguration defaultConfig;
+ private String defaultConfigId;
private boolean isDirty;
private IResource owner;
private boolean rebuildNeeded;
- private ITarget selectedTarget;
+ private String version;
+ private IConfiguration selectedConfig;
+
private List targetList;
private Map targetMap;
- private String version;
+
+ private boolean isReadOnly = false;
/**
@@ -85,29 +93,17 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
this.owner = owner;
cProject = CoreModel.getDefault().create(owner.getProject());
- // The container for this project has never been created
- containerCreated = false;
-
// Does not need a save but should be rebuilt
isDirty = false;
rebuildNeeded = true;
- // The id of the default target from the project persistent settings store
+ // Get the default configs
IProject project = owner.getProject();
- defaultTargetId = null;
+ defaultConfigId = null;
try {
- defaultTargetId = project.getPersistentProperty(defaultTargetProperty);
+ defaultConfigId = project.getPersistentProperty(defaultConfigProperty);
} catch (CoreException e) {
- // We have all the build elements so we can stop if this occurs
- return;
- }
-
- // Get the default configs for every target out of the same store
- defaultConfigIds = null;
- try {
- defaultConfigIds = project.getPersistentProperty(defaultConfigProperty);
- } catch (CoreException e) {
- // Again, hitting this error just means the default config is not set
+ // Hitting this error just means the default config is not set
return;
}
}
@@ -122,13 +118,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public ManagedBuildInfo(IResource owner, Element element) {
this(owner);
- // Container has already been created for this project
- containerCreated = true;
-
- // Inflate the targets
- NodeList targetNodes = element.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME);
- for (int targIndex = targetNodes.getLength() - 1; targIndex >= 0; --targIndex) {
- new Target(this, (Element)targetNodes.item(targIndex));
+ // Recreate the managed build project element and its children
+ NodeList projNodes = element.getElementsByTagName(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME);
+ // TODO: There should only be 1?
+ for (int projIndex = projNodes.getLength() - 1; projIndex >= 0; --projIndex) {
+ ManagedProject proj = new ManagedProject(this, (Element)projNodes.item(projIndex));
+ proj.resolveReferences();
}
// Switch the rebuild off since this is an existing project
@@ -136,24 +131,27 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setManagedProject(IManagedProject)
*/
- public void addTarget(ITarget target) {
- getTargetMap().put(target.getId(), target);
- getTargets().add(target);
- setDirty(true);
+ public void setManagedProject(IManagedProject managedProject) {
+ this.managedProject = managedProject;
+ //setDirty(true); - It is primarily up to the ManagedProject to maintain the dirty state
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getManagedProject()
+ */
+ public IManagedProject getManagedProject() {
+ return managedProject;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#buildsFileType(java.lang.String)
*/
public boolean buildsFileType(String srcExt) {
- // Make sure the owner is treated as a project for the duration
- IProject project = (IProject)owner;
-
// Check to see if there is a rule to build a file with this extension
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(project);
+ IConfiguration config = getDefaultConfiguration();
+ ITool[] tools = config.getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
if (tool != null && tool.buildsFileType(srcExt)) {
@@ -168,9 +166,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
public String getBuildArtifactExtension() {
String ext = new String();
- ITarget target = getDefaultTarget();
- if (target != null) {
- ext = target.getArtifactExtension();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ ext = config.getArtifactExtension();
}
return ext;
}
@@ -179,11 +177,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getBuildArtifactName()
*/
public String getBuildArtifactName() {
- // Get the default target and use its value
+ // Get the default configuration and use its value
String name = new String();
- ITarget target = getDefaultTarget();
- if (target != null) {
- name = target.getArtifactName();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ name = config.getArtifactName();
}
return name;
}
@@ -194,9 +192,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public String getCleanCommand() {
// Get from the model
String command = new String();
- ITarget target = getDefaultTarget();
- if (target != null) {
- command = target.getCleanCommand();
+ IConfiguration config = getDefaultConfiguration();
+ if (config != null) {
+ command = config.getCleanCommand();
}
return command;
}
@@ -206,7 +204,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
public String getConfigurationName() {
// Return the human-readable name of the default configuration
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ IConfiguration config = getDefaultConfiguration();
return config == null ? new String() : config.getName();
}
@@ -215,7 +213,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
public String[] getConfigurationNames() {
ArrayList configNames = new ArrayList();
- IConfiguration[] configs = getDefaultTarget().getConfigurations();
+ IConfiguration[] configs = managedProject.getConfigurations();
for (int i = 0; i < configs.length; i++) {
IConfiguration configuration = configs[i];
configNames.add(configuration.getName());
@@ -228,71 +226,17 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return cProject;
}
- /* (non-Javadoc)
- *
- * @return Returns the map of ITarget ids to IConfigurations.
- */
- private Map getDefaultConfigMap() {
- if (defaultConfigMap == null) {
- defaultConfigMap = new HashMap();
- // We read this as part of the constructor
- if (defaultConfigIds != null) {
- String[] majorTokens = defaultConfigIds.split(MAJOR_SEPERATOR);
- for (int index = majorTokens.length - 1; index >= 0; --index) {
- // Now split each token into the target and config id component
- String idToken = majorTokens[index];
- if (idToken != null) {
- String[] minorTokens = idToken.split(MINOR_SEPERATOR);
- // The first token is the target ID
- ITarget target = getTarget(minorTokens[0]);
- if (target == null) continue;
- // The second is the configuration ID
- IConfiguration config = target.getConfiguration(minorTokens[1]);
- if (config != null) {
- defaultConfigMap.put(target.getId(), config);
- }
- }
- }
- }
- }
- return defaultConfigMap;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getDefaultConfiguration()
*/
- public IConfiguration getDefaultConfiguration(ITarget target) {
- // Get the default config associated with the defalt target
- IConfiguration config = (IConfiguration) getDefaultConfigMap().get(target.getId());
-
- // If null, look up the first configuration associated with the target
- if (config == null) {
- IConfiguration[] configs = getDefaultTarget().getConfigurations();
- if (configs.length > 0) {
- config = configs[0];
+ public IConfiguration getDefaultConfiguration() {
+ // Get the default config associated with the project
+ if (defaultConfig == null) {
+ if (defaultConfigId != null && managedProject != null) {
+ defaultConfig = managedProject.getConfiguration(defaultConfigId);
}
}
- return config;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getDefaultTarget()
- */
- public ITarget getDefaultTarget() {
- if (defaultTarget == null) {
- // See if there is a target that was persisted
- if (defaultTargetId != null) {
- defaultTarget = (ITarget) getTargetMap().get(defaultTargetId);
- }
- // If that failed, look for anything
- if (defaultTarget == null) {
- // Are there any defined targets
- if (getTargets().size() > 0) {
- return (ITarget) getTargets().get(0);
- }
- }
- }
- return defaultTarget;
+ return defaultConfig;
}
/* (non-Javadoc)
@@ -301,16 +245,18 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public Map getDefinedSymbols() {
// Return the defined symbols for the default configuration
HashMap symbols = getMacroPathEntries();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getFilteredTools(owner.getProject());
+ IConfiguration config = getDefaultConfiguration();
+ if(config == null)
+ return symbols;
+ ITool[] tools = config.getFilteredTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
// Now extract the valid tool's options
IOption[] opts = tool.getOptions();
for (int j = 0; j < opts.length; j++) {
IOption option = opts[j];
- if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
- try {
+ try {
+ if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
ArrayList symbolList = new ArrayList();
symbolList.addAll(Arrays.asList(option.getDefinedSymbols()));
Iterator iter = symbolList.listIterator();
@@ -324,11 +270,10 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
String value = (tokens.length > 1) ? tokens[1].trim() : new String();
symbols.put(key, value);
}
-
- } catch (BuildException e) {
- // we should never get here
- continue;
}
+ } catch (BuildException e) {
+ // TODO: report error
+ continue;
}
}
}
@@ -339,13 +284,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getDependencyGenerator(java.lang.String)
*/
public IManagedDependencyGenerator getDependencyGenerator(String sourceExtension) {
- // Find the tool and ask the target for its dep generator
+ // Find the tool and ask the Managed Build Manager for its dep generator
try {
- ITarget target = getDefaultTarget();
- ITool[] tools = getFilteredTools();
- for (int index = 0; index < tools.length; ++index) {
- if(tools[index].buildsFileType(sourceExtension)) {
- return target.getDependencyGenerator(tools[index].getId());
+ if (getDefaultConfiguration() != null) {
+ ITool[] tools = getDefaultConfiguration().getFilteredTools();
+ for (int index = 0; index < tools.length; ++index) {
+ if(tools[index].buildsFileType(sourceExtension)) {
+ return ManagedBuildManager.getDependencyGenerator(tools[index].getId());
+ }
}
}
} catch (NullPointerException e) {
@@ -363,9 +309,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
private ITool[] getFilteredTools() {
// Get all the tools for the current config filtered by the project nature
- IProject project = owner.getProject();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- return config.getFilteredTools(project);
+ IConfiguration config = getDefaultConfiguration();
+ return config.getFilteredTools();
}
/* (non-Javadoc)
@@ -388,9 +333,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolFlags(java.lang.String)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getFlagsForConfiguration(java.lang.String)
*/
- public String getFlagsForTarget(String extension) {
+ public String getFlagsForConfiguration(String extension) {
// Treat null extensions as an empty string
String ext = extension == null ? new String() : extension;
@@ -440,22 +385,22 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public String[] getIncludePaths() {
// Return the include paths for the default configuration
ArrayList paths = getIncludePathEntries();
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ IConfiguration config = getDefaultConfiguration();
IPath location = owner.getLocation();
// If the build info is out of date this might be null
if (location == null) {
location = new Path("."); //$NON-NLS-1$
}
IPath root = location.addTrailingSeparator().append(config.getName());
- ITool[] tools = config.getFilteredTools(owner.getProject());
+ ITool[] tools = config.getFilteredTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
// The tool checks out for this project, get its options
IOption[] opts = tool.getOptions();
for (int j = 0; j < opts.length; j++) {
IOption option = opts[j];
- if (option.getValueType() == IOption.INCLUDE_PATH) {
- try {
+ try {
+ if (option.getValueType() == IOption.INCLUDE_PATH) {
// Get all the user-defined paths from the option as absolute paths
String[] userPaths = option.getIncludePaths();
for (int index = 0; index < userPaths.length; ++index) {
@@ -466,11 +411,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
IPath absPath = root.addTrailingSeparator().append(userPath);
paths.add(absPath.makeAbsolute().toOSString());
}
- }
- } catch (BuildException e) {
- // we should never get here, but continue anyway
- continue;
+ }
}
+ } catch (BuildException e) {
+ // TODO: report error
+ continue;
}
}
}
@@ -480,9 +425,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForTarget(java.lang.String)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getLibsForConfiguration(java.lang.String)
*/
- public String[] getLibsForTarget(String extension) {
+ public String[] getLibsForConfiguration(String extension) {
Vector libs = new Vector();
ITool[] tools = getFilteredTools();
for (int index = 0; index < tools.length; index++) {
@@ -492,17 +437,18 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Look for the lib option type
for (int i = 0; i < opts.length; i++) {
IOption option = opts[i];
- if (option.getValueType() == IOption.LIBRARIES) {
- try {
+ try {
+ if (option.getValueType() == IOption.LIBRARIES) {
String command = option.getCommand();
String[] allLibs = option.getLibraries();
for (int j = 0; j < allLibs.length; j++) {
String string = allLibs[j];
libs.add(command + string);
}
- } catch (BuildException e) {
- continue;
}
+ } catch (BuildException e) {
+ // TODO: report error
+ continue;
}
}
}
@@ -534,15 +480,25 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeArguments()
*/
- public String getMakeArguments() {
- return getDefaultTarget().getMakeArguments();
+ public String getBuildArguments() {
+ if (getDefaultConfiguration() != null) {
+ IToolChain toolChain = getDefaultConfiguration().getToolChain();
+ IBuilder builder = toolChain.getBuilder();
+ return builder.getArguments();
+ }
+ return EMPTY_STRING;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getMakeCommand()
*/
- public String getMakeCommand() {
- return getDefaultTarget().getMakeCommand();
+ public String getBuildCommand() {
+ if (getDefaultConfiguration() != null) {
+ IToolChain toolChain = getDefaultConfiguration().getToolChain();
+ IBuilder builder = toolChain.getBuilder();
+ return builder.getCommand();
+ }
+ return EMPTY_STRING;
}
/* (non-Javadoc)
@@ -607,42 +563,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return owner;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedTarget()
- */
- public ITarget getSelectedTarget() {
- return selectedTarget;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public ITarget getTarget(String id) {
- return (ITarget) getTargetMap().get(id);
- }
-
- /* (non-Javadoc)
- * Safe accessor.
- *
- * @return Returns the map of IDs to ITargets.
- */
- private Map getTargetMap() {
- if (targetMap == null) {
- targetMap = new HashMap();
- }
- return targetMap;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public List getTargets() {
- if (targetList == null) {
- targetList = new ArrayList();
- }
- return targetList;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolForSource(java.lang.String)
*/
@@ -661,7 +581,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getToolInvocation(java.lang.String)
*/
- public String getToolForTarget(String extension) {
+ public String getToolForConfiguration(String extension) {
// Treat a null argument as an empty string
String ext = extension == null ? new String() : extension;
// Get all the tools for the current config
@@ -674,11 +594,30 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#generateCommandLineInfo(java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
+ */
+ public IManagedCommandLineInfo generateCommandLineInfo(
+ String sourceExtension, String[] flags, String outputFlag,
+ String outputPrefix, String outputName, String[] inputResources) {
+ ITool[] tools = getFilteredTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(sourceExtension)) {
+ IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
+ return gen.generateCommandLineInfo( tool, tool.getToolCommand(),
+ flags, outputFlag, outputPrefix, outputName, inputResources,
+ tool.getCommandLinePattern() );
+ }
+ }
+ return null;
+ }
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getUserObjectsForTarget(java.lang.String)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#getUserObjectsForConfiguration(java.lang.String)
*/
- public String[] getUserObjectsForTarget(String extension) {
+ public String[] getUserObjectsForConfiguration(String extension) {
Vector objs = new Vector();
// Get all the tools for the current config
ITool[] tools = getFilteredTools();
@@ -690,12 +629,13 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Look for the user object option type
for (int i = 0; i < opts.length; i++) {
IOption option = opts[i];
- if (option.getValueType() == IOption.OBJECTS) {
- try {
+ try {
+ if (option.getValueType() == IOption.OBJECTS) {
objs.addAll(Arrays.asList(option.getUserObjects()));
- } catch (BuildException e) {
- continue;
}
+ } catch (BuildException e) {
+ // TODO: report error
+ continue;
}
}
}
@@ -730,15 +670,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return true;
}
- // Check if any of the defined targets are dirty
- Iterator iter = getTargets().listIterator();
- while (iter.hasNext()) {
- if (((ITarget)iter.next()).isDirty()) {
- return true;
- }
- }
-
- return false;
+ // Check if the project is dirty
+ return managedProject.isDirty();
}
/* (non-Javadoc)
@@ -748,8 +681,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
IProject project = (IProject)owner;
// Check to see if there is a rule to build a file with this extension
- IConfiguration config = getDefaultConfiguration(getDefaultTarget());
- ITool[] tools = config.getTools();
+ IConfiguration config = getDefaultConfiguration();
+ ITool[] tools = config.getFilteredTools();
for (int index = 0; index < tools.length; index++) {
ITool tool = tools[index];
try {
@@ -781,68 +714,25 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public boolean needsRebuild() {
if (rebuildNeeded) return true;
- Iterator iter = getTargets().listIterator();
- while (iter.hasNext()) {
- if (((ITarget)iter.next()).needsRebuild()) {
- return true;
- }
+ if (getDefaultConfiguration() != null) {
+ return getDefaultConfiguration().needsRebuild();
}
-
return false;
}
/* (non-Javadoc)
*
*/
- private void persistDefaultConfigurations() {
- // Create a buffer of the default configuration IDs
- StringBuffer defaultConfigs = new StringBuffer();
- Iterator iter = getTargets().listIterator();
- while (iter.hasNext()) {
- // Persist the default target configuration pair as null
if
+ * defined at the top level
+ * @param element The option definition from the manifest file or a dynamic element
+ * provider
+ */
+ public Option(Tool parent, IManagedConfigElement element) {
+ this.tool = parent;
+ isExtensionOption = true;
+
// setup for resolving
- ManagedBuildManager.putConfigElement(this, element);
resolved = false;
+
+ loadFromManifest(element);
- // Get the unique id of the option
- setId(element.getAttribute(ID));
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionOption(this);
+ }
+
+ /**
+ * This constructor is called to create an Option whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param Tool The parent of the tool, if any
+ * @param Option The superClass, if any
+ * @param String The id for the new option
+ * @param String The name for the new option
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public Option(Tool parent, IOption superClass, String Id, String name, boolean isExtensionElement) {
+ this.tool = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionOption = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionOption(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create an Option
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The ITool
the option will be added to.
+ * @param element The XML element that contains the option settings.
+ */
+ public Option(Tool parent, Element element) {
+ this.tool = parent;
+ isExtensionOption = false;
- // Hook me up to a tool
- tool.addOption(this);
+ // Initialize from the XML attributes
+ loadFromProject(element);
+ }
+
+ /**
+ * Create an Option
based upon an existing option.
+ *
+ * @param parent The ITool
the option will be added to.
+ * @param tool The existing option to clone.
+ */
+ public Option(ITool parent, String Id, String name, Option option){
+ this.tool = parent;
+ superClass = option.superClass;
+ if (superClass != null) {
+ superClassId = option.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionOption = false;
- // Get the option Name (this is what the user will see in the UI)
- setName(element.getAttribute(NAME));
+ // Copy the remaining attributes
+ if (option.unusedChildren != null) {
+ unusedChildren = new String(option.unusedChildren);
+ }
+ if (option.isAbstract != null) {
+ isAbstract = new Boolean(option.isAbstract.booleanValue());
+ }
+ if (option.command != null) {
+ command = new String(option.command);
+ }
+ if (option.commandFalse != null) {
+ commandFalse = new String(option.commandFalse);
+ }
+ if (option.categoryId != null) {
+ categoryId = new String(option.categoryId);
+ }
+ if (option.builtIns != null) {
+ builtIns = new ArrayList(option.builtIns);
+ }
+ if (option.browseType != null) {
+ browseType = new Integer(option.browseType.intValue());
+ }
+ if (option.resourceFilter != null) {
+ resourceFilter = new Integer(option.resourceFilter.intValue());
+ }
+ if (option.enumList != null) {
+ enumList = new ArrayList(option.enumList);
+ enumCommands = new HashMap(option.enumCommands);
+ enumNames = new HashMap(option.enumNames);
+ }
+ if (option.valueType != null) {
+ valueType = new Integer(option.valueType.intValue());
+ switch (valueType.intValue()) {
+ case BOOLEAN:
+ if (option.value != null) {
+ value = new Boolean(((Boolean)option.value).booleanValue());
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
+ }
+ break;
+ case STRING:
+ case ENUMERATED:
+ if (option.value != null) {
+ value = new String((String)option.value);
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new String((String)option.defaultValue);
+ }
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ if (option.value != null) {
+ value = new ArrayList((ArrayList)option.value);
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new ArrayList((ArrayList)option.defaultValue);
+ }
+ break;
+ }
+ }
+ category = option.category;
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the option information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the option information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
// Get the command defined for the option
command = element.getAttribute(COMMAND);
@@ -72,125 +255,510 @@ public class Option extends BuildObject implements IOption {
// Options hold different types of values
String valueTypeStr = element.getAttribute(VALUE_TYPE);
- if (valueTypeStr == null)
- valueType = -1;
- else if (valueTypeStr.equals(TYPE_STRING))
- valueType = STRING;
- else if (valueTypeStr.equals(TYPE_STR_LIST))
- valueType = STRING_LIST;
- else if (valueTypeStr.equals(TYPE_BOOL))
- valueType = BOOLEAN;
- else if (valueTypeStr.equals(TYPE_ENUM))
- valueType = ENUMERATED;
- else if (valueTypeStr.equals(TYPE_INC_PATH))
- valueType = INCLUDE_PATH;
- else if (valueTypeStr.equals(TYPE_LIB))
- valueType = LIBRARIES;
- else if (valueTypeStr.equals(TYPE_USER_OBJS))
- valueType = OBJECTS;
- else
- valueType = PREPROCESSOR_SYMBOLS;
-
- // Now get the actual value
- switch (valueType) {
- case BOOLEAN:
- // Convert the string to a boolean
- value = new Boolean(element.getAttribute(DEFAULT_VALUE));
- break;
- case STRING:
- // Just get the value out of the option directly
- value = element.getAttribute(DEFAULT_VALUE);
- break;
- case ENUMERATED:
- List enumList = new ArrayList();
- IManagedConfigElement[] enumElements = element.getChildren(ENUM_VALUE);
- for (int i = 0; i < enumElements.length; ++i) {
- String optId = enumElements[i].getAttribute(ID);
- enumList.add(optId);
- getEnumCommandMap().put(optId, enumElements[i].getAttribute(COMMAND));
- getEnumNameMap().put(optId, enumElements[i].getAttribute(NAME));
- Boolean isDefault = new Boolean(enumElements[i].getAttribute(IS_DEFAULT));
- if (isDefault.booleanValue()) {
- defaultEnumId = optId;
- }
- }
- value = enumList;
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- List valueList = new ArrayList();
- builtIns = new ArrayList();
- IManagedConfigElement[] valueElements = element.getChildren(LIST_VALUE);
- for (int i = 0; i < valueElements.length; ++i) {
- IManagedConfigElement valueElement = valueElements[i];
- Boolean isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
- if (isBuiltIn.booleanValue()) {
- builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- else {
- valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- }
- value = valueList;
- break;
- default :
- break;
+ if (valueTypeStr != null) {
+ valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
}
+
+ // Note: The value and defaultValue attributes are loaded in the resolveReferences routine.
+ // This is because we need to have the value-type, and this may be defined in a
+ // superClass that is not yet loaded.
// Determine if there needs to be a browse button
- String browseTypeStr = element.getAttribute(BROSWE_TYPE);
+ String browseTypeStr = element.getAttribute(BROWSE_TYPE);
if (browseTypeStr == null || browseTypeStr.equals(NONE)) {
- browseType = BROWSE_NONE;
+ browseType = new Integer(BROWSE_NONE);
} else if (browseTypeStr.equals(FILE)) {
- browseType = BROWSE_FILE;
+ browseType = new Integer(BROWSE_FILE);
} else if (browseTypeStr.equals(DIR)) {
- browseType = BROWSE_DIR;
+ browseType = new Integer(BROWSE_DIR);
+ }
+
+ categoryId = element.getAttribute(CATEGORY);
+
+ // Get the resourceFilter attribute
+ String resFilterStr = element.getAttribute(RESOURCE_FILTER);
+ if (resFilterStr == null || resFilterStr.equals(ALL)) {
+ resourceFilter = new Integer(FILTER_ALL);
+ } else if (resFilterStr.equals(FILE)) {
+ resourceFilter = new Integer(FILTER_FILE);
+ } else if (resFilterStr.equals(PROJECT)) {
+ resourceFilter = new Integer(FILTER_PROJECT);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Initialize the option information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the option information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
}
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionOption(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the command defined for the option
+ if (element.hasAttribute(COMMAND)) {
+ command = element.getAttribute(COMMAND);
+ }
+
+ // Get the command defined for a Boolean option when the value is False
+ if (element.hasAttribute(COMMAND_FALSE)) {
+ commandFalse = element.getAttribute(COMMAND_FALSE);
+ }
+
+ // Options hold different types of values
+ if (element.hasAttribute(VALUE_TYPE)) {
+ String valueTypeStr = element.getAttribute(VALUE_TYPE);
+ valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
+ }
+
+ // Now get the actual value based upon value-type
+ try {
+ int valType = getValueType();
+ switch (valType) {
+ case BOOLEAN:
+ // Convert the string to a boolean
+ if (element.hasAttribute(VALUE)) {
+ value = new Boolean(element.getAttribute(VALUE));
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = new Boolean(element.getAttribute(DEFAULT_VALUE));
+ }
+ break;
+ case STRING:
+ // Just get the value out of the option directly
+ if (element.hasAttribute(VALUE)) {
+ value = element.getAttribute(VALUE);
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+ }
+ break;
+ case ENUMERATED:
+ if (element.hasAttribute(VALUE)) {
+ value = element.getAttribute(VALUE);
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+ }
+
+ // Do we have enumeratedOptionValue children? If so, load them
+ // to define the valid values and the default value.
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configNode = configElements.item(i);
+ if (configNode.getNodeName().equals(ENUM_VALUE)) {
+ Element configElement = (Element)configNode;
+ String optId = configElement.getAttribute(ID);
+ if (i == 0) {
+ enumList = new ArrayList();
+ if (defaultValue == null) {
+ defaultValue = optId; // Default value to be overridden is default is specified
+ }
+ }
+ enumList.add(optId);
+ if (configElement.hasAttribute(COMMAND)) {
+ getEnumCommandMap().put(optId, configElement.getAttribute(COMMAND));
+ } else {
+ getEnumCommandMap().put(optId, EMPTY_STRING);
+ }
+ getEnumNameMap().put(optId, configElement.getAttribute(NAME));
+ if (configElement.hasAttribute(IS_DEFAULT)) {
+ Boolean isDefault = new Boolean(configElement.getAttribute(IS_DEFAULT));
+ if (isDefault.booleanValue()) {
+ defaultValue = optId;
+ }
+ }
+ }
+ }
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ // Note: These string-list options do not load either the "value" or
+ // "defaultValue" attributes. Instead, the ListOptionValue children
+ // are loaded in the value field.
+ List valueList = null;
+ configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ if (i == 0) {
+ valueList = new ArrayList();
+ builtIns = new ArrayList();
+ }
+ Node configNode = configElements.item(i);
+ if (configNode.getNodeName().equals(LIST_VALUE)) {
+ Element valueElement = (Element)configNode;
+ Boolean isBuiltIn;
+ if (valueElement.hasAttribute(IS_DEFAULT)) {
+ isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
+ } else {
+ isBuiltIn = new Boolean(false);
+ }
+ if (isBuiltIn.booleanValue()) {
+ builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ else {
+ valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ }
+ }
+ value = valueList;
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ }
+
+ // Determine if there needs to be a browse button
+ if (element.hasAttribute(BROWSE_TYPE)) {
+ String browseTypeStr = element.getAttribute(BROWSE_TYPE);
+ if (browseTypeStr == null || browseTypeStr.equals(NONE)) {
+ browseType = new Integer(BROWSE_NONE);
+ } else if (browseTypeStr.equals(FILE)) {
+ browseType = new Integer(BROWSE_FILE);
+ } else if (browseTypeStr.equals(DIR)) {
+ browseType = new Integer(BROWSE_DIR);
+ }
+ }
+
+ if (element.hasAttribute(CATEGORY)) {
+ categoryId = element.getAttribute(CATEGORY);
+ if (categoryId != null) {
+ category = ((Tool)tool).getOptionCategory(categoryId);
+ }
+ }
+
+ // Get the resourceFilter attribute
+ if (element.hasAttribute(RESOURCE_FILTER)) {
+ String resFilterStr = element.getAttribute(RESOURCE_FILTER);
+ if (resFilterStr == null || resFilterStr.equals(ALL)) {
+ resourceFilter = new Integer(FILTER_ALL);
+ } else if (resFilterStr.equals(FILE)) {
+ resourceFilter = new Integer(FILTER_FILE);
+ } else if (resFilterStr.equals(PROJECT)) {
+ resourceFilter = new Integer(FILTER_PROJECT);
+ }
+ }
}
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- // Options can be grouped into categories
- String categoryId = element.getAttribute(CATEGORY);
- if (categoryId != null)
- setCategory(((Tool)tool).getOptionCategory(categoryId));
+ private int ValueTypeStrToInt(String valueTypeStr) {
+ if (valueTypeStr == null) return -1;
+ if (valueTypeStr.equals(TYPE_STRING))
+ return STRING;
+ else if (valueTypeStr.equals(TYPE_STR_LIST))
+ return STRING_LIST;
+ else if (valueTypeStr.equals(TYPE_BOOL))
+ return BOOLEAN;
+ else if (valueTypeStr.equals(TYPE_ENUM))
+ return ENUMERATED;
+ else if (valueTypeStr.equals(TYPE_INC_PATH))
+ return INCLUDE_PATH;
+ else if (valueTypeStr.equals(TYPE_LIB))
+ return LIBRARIES;
+ else if (valueTypeStr.equals(TYPE_USER_OBJS))
+ return OBJECTS;
+ else if (valueTypeStr.equals(TYPE_DEFINED_SYMBOLS))
+ return PREPROCESSOR_SYMBOLS;
+ else {
+ // TODO: This was the CDT 2.0 default - should we keep it?
+ return PREPROCESSOR_SYMBOLS;
}
}
+
+ /**
+ * Persist the option to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) throws BuildException {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ if (command != null) {
+ element.setAttribute(COMMAND, command);
+ }
+
+ if (commandFalse != null) {
+ element.setAttribute(COMMAND_FALSE, commandFalse);
+ }
+
+ /*
+ * Note: We store value & value-type as a pair, so we know what type of value we are
+ * dealing with when we read it back in.
+ * This is also true of defaultValue.
+ */
+ boolean storeValueType = false;
+
+ // value
+ if (value != null) {
+ storeValueType = true;
+ switch (getValueType()) {
+ case BOOLEAN:
+ element.setAttribute(VALUE, ((Boolean)value).toString());
+ break;
+ case STRING:
+ case ENUMERATED:
+ element.setAttribute(VALUE, (String)value);
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ if (value != null) {
+ ArrayList stringList = (ArrayList)value;
+ ListIterator iter = stringList.listIterator();
+ while (iter.hasNext()) {
+ Element valueElement = doc.createElement(LIST_VALUE);
+ valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
+ valueElement.setAttribute(LIST_ITEM_BUILTIN, "false"); //$NON-NLS-1$
+ element.appendChild(valueElement);
+ }
+ }
+ // Serialize the built-ins that have been overridden
+ if (builtIns != null) {
+ ListIterator iter = builtIns.listIterator();
+ while (iter.hasNext()) {
+ Element valueElement = doc.createElement(LIST_VALUE);
+ valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
+ valueElement.setAttribute(LIST_ITEM_BUILTIN, "true"); //$NON-NLS-1$
+ element.appendChild(valueElement);
+ }
+ }
+ break;
+ }
+ }
+
+ // defaultValue
+ if (defaultValue != null) {
+ storeValueType = true;
+ switch (getValueType()) {
+ case BOOLEAN:
+ element.setAttribute(DEFAULT_VALUE, ((Boolean)defaultValue).toString());
+ break;
+ case STRING:
+ case ENUMERATED:
+ element.setAttribute(DEFAULT_VALUE, (String)defaultValue);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (storeValueType) {
+ String str;
+ switch (getValueType()) {
+ case BOOLEAN:
+ str = TYPE_BOOL;
+ break;
+ case STRING:
+ str = TYPE_STRING;
+ break;
+ case ENUMERATED:
+ str = TYPE_ENUM;
+ break;
+ case STRING_LIST:
+ str = TYPE_STR_LIST;
+ break;
+ case INCLUDE_PATH:
+ str = TYPE_INC_PATH;
+ break;
+ case LIBRARIES:
+ str = TYPE_LIB;
+ break;
+ case OBJECTS:
+ str = TYPE_USER_OBJS;
+ break;
+ case PREPROCESSOR_SYMBOLS:
+ str = TYPE_DEFINED_SYMBOLS;
+ break;
+ default:
+ // TODO; is this a problem...
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(VALUE_TYPE, str);
+ }
+
+ // browse type
+ if (browseType != null) {
+ String str;
+ switch (getBrowseType()) {
+ case BROWSE_NONE:
+ str = NONE;
+ break;
+ case BROWSE_FILE:
+ str = FILE;
+ break;
+ case BROWSE_DIR:
+ str = DIR;
+ break;
+ default:
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(BROWSE_TYPE, str);
+ }
+
+ if (categoryId != null) {
+ element.setAttribute(CATEGORY, categoryId);
+ }
+
+ // resource filter
+ if (resourceFilter != null) {
+ String str;
+ switch (getResourceFilter()) {
+ case FILTER_ALL:
+ str = ALL;
+ break;
+ case FILTER_FILE:
+ str = FILE;
+ break;
+ case FILTER_PROJECT:
+ str = PROJECT;
+ break;
+ default:
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(RESOURCE_FILTER, str);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getParent()
+ */
+ public ITool getParent() {
+ return tool;
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getSuperClass()
+ */
+ public IOption getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#getName()
+ */
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getApplicableValues()
*/
public String[] getApplicableValues() {
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getApplicableValues();
+ } else {
+ return EMPTY_STRING_ARRAY;
+ }
+ }
// Get all of the enumerated names from the option
- List ids = (List) value;
- if (ids == null || ids.size() == 0) {
+ if (enumList.size() == 0) {
return EMPTY_STRING_ARRAY;
} else {
// Return the elements in the order they are specified in the manifest
- String[] enumNames = new String[ids.size()];
- for (int index = 0; index < ids.size(); ++ index) {
- enumNames[index] = (String) getEnumNameMap().get(ids.get(index));
+ String[] enumNames = new String[enumList.size()];
+ for (int index = 0; index < enumList.size(); ++ index) {
+ enumNames[index] = (String) getEnumNameMap().get(enumList.get(index));
}
return enumNames;
}
}
-
+
public boolean getBooleanValue() {
- Boolean bool = (Boolean) value;
- return bool.booleanValue();
+ return ((Boolean)getValue()).booleanValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseType()
*/
public int getBrowseType() {
- return browseType;
+ if (browseType == null) {
+ if (superClass != null) {
+ return superClass.getBrowseType();
+ } else {
+ return BROWSE_NONE;
+ }
+ }
+ return browseType.intValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getResourceFilter()
+ */
+ public int getResourceFilter() {
+ if (resourceFilter == null) {
+ if (superClass != null) {
+ return superClass.getResourceFilter();
+ } else {
+ return FILTER_ALL;
+ }
+ }
+ return resourceFilter.intValue();
}
/* (non-Javadoc)
@@ -198,22 +766,41 @@ public class Option extends BuildObject implements IOption {
*/
public String[] getBuiltIns() {
// Return the list of built-ins as an array
- return builtIns == null ?
- EMPTY_STRING_ARRAY:
- (String[])builtIns.toArray(new String[builtIns.size()]);
+ if (builtIns == null) {
+ if (superClass != null) {
+ return superClass.getBuiltIns();
+ } else {
+ return EMPTY_STRING_ARRAY;
+ }
+ }
+ return (String[])builtIns.toArray(new String[builtIns.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCategory()
*/
public IOptionCategory getCategory() {
- return category != null ? category : getTool().getTopOptionCategory();
+ if (category == null) {
+ if (superClass != null) {
+ return superClass.getCategory();
+ } else {
+ return getParent().getTopOptionCategory();
+ }
+ }
+ return category;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getCommand()
*/
public String getCommand() {
+ if (command == null) {
+ if (superClass != null) {
+ return superClass.getCommand();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
return command;
}
@@ -221,6 +808,13 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getCommandFalse()
*/
public String getCommandFalse() {
+ if (commandFalse == null) {
+ if (superClass != null) {
+ return superClass.getCommandFalse();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
return commandFalse;
}
@@ -228,10 +822,10 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getDefinedSymbols()
*/
public String[] getDefinedSymbols() throws BuildException {
- if (valueType != PREPROCESSOR_SYMBOLS) {
+ if (getValueType() != PREPROCESSOR_SYMBOLS) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
- ArrayList v = (ArrayList)value;
+ ArrayList v = (ArrayList)getValue();
if (v == null) {
return EMPTY_STRING_ARRAY;
} else {
@@ -243,18 +837,29 @@ public class Option extends BuildObject implements IOption {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
*/
- public String getEnumCommand(String id) {
+ public String getEnumCommand(String id) throws BuildException {
// Sanity
if (id == null) return EMPTY_STRING;
-
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumCommand(id);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+
// First check for the command in ID->command map
String cmd = (String) getEnumCommandMap().get(id);
if (cmd == null) {
// This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
// name of the enumeration. Search for the ID that maps to the name and use that to find the
// command.
- List ids = (List) value;
- ListIterator iter = ids.listIterator();
+ ListIterator iter = enumList.listIterator();
while (iter.hasNext()) {
String realID = (String) iter.next();
String name = (String) getEnumNameMap().get(realID);
@@ -270,9 +875,21 @@ public class Option extends BuildObject implements IOption {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumName(java.lang.String)
*/
- public String getEnumName(String id) {
+ public String getEnumName(String id) throws BuildException {
// Sanity
if (id == null) return EMPTY_STRING;
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumName(id);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
// First check for the command in ID->name map
String name = (String) getEnumNameMap().get(id);
@@ -301,8 +918,21 @@ public class Option extends BuildObject implements IOption {
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumeratedId(java.lang.String)
*/
- public String getEnumeratedId(String name) {
+ public String getEnumeratedId(String name) throws BuildException {
if (name == null) return null;
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumeratedId(name);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+
Set idSet = getEnumNameMap().keySet();
Iterator iter = idSet.iterator();
while (iter.hasNext()) {
@@ -330,10 +960,10 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getIncludePaths()
*/
public String[] getIncludePaths() throws BuildException {
- if (valueType != INCLUDE_PATH) {
+ if (getValueType() != INCLUDE_PATH) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
- ArrayList v = (ArrayList)value;
+ ArrayList v = (ArrayList)getValue();
if (v == null) {
return EMPTY_STRING_ARRAY;
} else {
@@ -346,10 +976,10 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getLibraries()
*/
public String[] getLibraries() throws BuildException {
- if (valueType != LIBRARIES) {
+ if (getValueType() != LIBRARIES) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
- ArrayList v = (ArrayList)value;
+ ArrayList v = (ArrayList)getValue();
if (v == null) {
return EMPTY_STRING_ARRAY;
} else {
@@ -362,20 +992,20 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getDefaultEnumValue()
*/
public String getSelectedEnum() throws BuildException {
- if (valueType != ENUMERATED) {
+ if (getValueType() != ENUMERATED) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
- return defaultEnumId == null ? EMPTY_STRING : defaultEnumId;
+ return getStringValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getStringListValue()
*/
public String[] getStringListValue() throws BuildException {
- if (valueType != STRING_LIST) {
+ if (getValueType() != STRING_LIST) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
- ArrayList v = (ArrayList)value;
+ ArrayList v = (ArrayList)getValue();
if (v == null) {
return EMPTY_STRING_ARRAY;
} else {
@@ -388,28 +1018,21 @@ public class Option extends BuildObject implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getStringValue()
*/
public String getStringValue() throws BuildException {
- if (valueType != STRING) {
+ if (getValueType() != STRING && getValueType() != ENUMERATED) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
- return value == null ? EMPTY_STRING : (String)value;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getTool()
- */
- public ITool getTool() {
- return tool;
+ return getValue() == null ? EMPTY_STRING : (String)getValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getUserObjects()
*/
public String[] getUserObjects() throws BuildException {
- if (valueType != OBJECTS) {
+ if (getValueType() != OBJECTS) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
// This is the right puppy, so return its list value
- ArrayList v = (ArrayList)value;
+ ArrayList v = (ArrayList)getValue();
if (v == null) {
return EMPTY_STRING_ARRAY;
} else {
@@ -421,55 +1044,360 @@ public class Option extends BuildObject implements IOption {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getValueType()
*/
- public int getValueType() {
- return valueType;
+ public int getValueType() throws BuildException {
+ if (valueType == null) {
+ if (superClass != null) {
+ return superClass.getValueType();
+ } else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$;
+ }
+ }
+ return valueType.intValue();
}
+ /* (non-Javadoc)
+ * Gets the value, applying appropriate defaults if necessary.
+ */
+ public Object getValue() {
+ /*
+ * In order to determine the current value of an option, perform the following steps until a value is found:
+ * 1. Examine the value attribute of the option.
+ * 2. Examine the value attribute of the option’s superClass recursively.
+ * 3. Examine the dynamicDefaultValue attribute of the option and invoke it if specified. (not yet implemented)
+ * 4. Examine the defaultValue attribute of the option.
+ * 5. Examine the dynamicDefaultValue attribute of the option’s superClass and invoke it if specified. (not yet implemented)
+ * 6. Examine the defaultValue attribute of the option’s superClass.
+ * 7. Go to step 5 recursively until no more super classes.
+ * 8. Use the default value for the option type.
+ */
+
+ Object val = getRawValue();
+ if (val == null) {
+ val = getDefaultValue();
+ if (val == null) {
+ int valType;
+ try {
+ valType = getValueType();
+ } catch (BuildException e) {
+ return EMPTY_STRING;
+ }
+ switch (valType) {
+ case BOOLEAN:
+ val = new Boolean(false);
+ break;
+ case STRING:
+ val = EMPTY_STRING;
+ break;
+ case ENUMERATED:
+ // TODO: Can we default to the first enumerated id?
+ val = EMPTY_STRING;
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ val = new ArrayList();
+ break;
+ default:
+ val = EMPTY_STRING;
+ break;
+ }
+ }
+ }
+ return val;
+ }
+
+ /* (non-Javadoc)
+ * Gets the raw value, applying appropriate defauls if necessary.
+ */
+ public Object getRawValue() {
+ if (value == null) {
+ if (superClass != null) {
+ Option mySuperClass = (Option)superClass;
+ return mySuperClass.getRawValue();
+ }
+ }
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * Gets the raw default value.
+ */
+ public Object getDefaultValue() {
+ // Note: string-list options do not have a default value
+ if (defaultValue == null) {
+ if (superClass != null) {
+ return superClass.getDefaultValue();
+ }
+ }
+ return defaultValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setValue(Object)
+ */
+ public void setDefaultValue(Object v) {
+ defaultValue = v;
+ setDirty(true);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
*/
public void setCategory(IOptionCategory category) {
this.category = category;
+ setDirty(true);
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setCommand(String)
*/
- public IOption setValue(IConfiguration config, String value)
- throws BuildException
- {
- if (valueType != IOption.STRING
- || valueType != ENUMERATED)
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
-
- if (config == null) {
- this.value = value;
- return this;
- } else {
- // Magic time
- return null;
+ public void setCommand(String cmd) {
+ if (cmd == null && command == null) return;
+ if (cmd == null || command == null || !cmd.equals(command)) {
+ command = cmd;
+ isDirty = true;
}
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#setStringValue(org.eclipse.cdt.core.build.managed.IConfiguration, java.lang.String[])
+ * @see org.eclipse.cdt.core.build.managed.IOption#setCommandFalse(String)
*/
- public IOption setValue(IConfiguration config, String[] value)
- throws BuildException
- {
- if (valueType != STRING_LIST
- || valueType != INCLUDE_PATH
- || valueType != PREPROCESSOR_SYMBOLS
- || valueType != LIBRARIES
- || valueType != OBJECTS)
+ public void setCommandFalse(String cmd) {
+ if (cmd == null && commandFalse == null) return;
+ if (cmd == null || commandFalse == null || !cmd.equals(commandFalse)) {
+ commandFalse = cmd;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
+ */
+ public void setResourceFilter(int filter) {
+ if (resourceFilter == null || !(filter == resourceFilter.intValue())) {
+ resourceFilter = new Integer(filter);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setBrowseType(int)
+ */
+ public void setBrowseType(int type) {
+ if (browseType == null || !(type == browseType.intValue())) {
+ browseType = new Integer(type);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setValue(boolean)
+ */
+ public void setValue(boolean value) throws BuildException {
+ if (!isExtensionElement() && getValueType() == BOOLEAN)
+ this.value = new Boolean(value);
+ else {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
-
- if (config == null) {
+ }
+ setDirty(true);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setValue(String)
+ */
+ public void setValue(String value) throws BuildException {
+ // Note that we can still set the human-readable value here
+ if (!isExtensionElement() && (getValueType() == STRING || getValueType() == ENUMERATED)) {
this.value = value;
- return this;
} else {
- // More magic
- return null;
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ setDirty(true);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setValue(String [])
+ */
+ public void setValue(String [] value) throws BuildException {
+ if (!isExtensionElement() &&
+ (getValueType() == STRING_LIST
+ || getValueType() == INCLUDE_PATH
+ || getValueType() == PREPROCESSOR_SYMBOLS
+ || getValueType() == LIBRARIES
+ || getValueType() == OBJECTS)) {
+ // Just replace what the option reference is holding onto
+ this.value = new ArrayList(Arrays.asList(value));
+ }
+ else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setValue(Object)
+ */
+ public void setValue(Object v) {
+ value = v;
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setValueType()
+ */
+ public void setValueType(int type) {
+ // TODO: Verify that this is a valid type
+ if (valueType == null || valueType.intValue() != type) {
+ valueType = new Integer(type);
+ setDirty(true);
+ }
+ }
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionOption;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#overridesOnlyValue()
+ */
+ public boolean overridesOnlyValue() {
+ if (superClass != null &&
+ unusedChildren == null &&
+ browseType == null &&
+ builtIns == null &&
+ category == null &&
+ categoryId == null &&
+ command == null &&
+ commandFalse == null &&
+ enumList == null &&
+ enumCommands == null &&
+ enumNames == null &&
+ defaultValue == null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension option
+ if (isExtensionOption) return false;
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ }
+
+ public void resolveReferences() {
+
+ if (!resolved) {
+ resolved = true;
+ // Resolve superClass
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionOption(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+ if (categoryId != null) {
+ category = ((Tool)tool).getOptionCategory(categoryId);
+ }
+ // Process the value and default value attributes. This is delayed until now
+ // because we may not know the valueType until after we have resolved the superClass above
+ // Now get the actual value
+ try {
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ switch (getValueType()) {
+ case BOOLEAN:
+ // Convert the string to a boolean
+ String val = element.getAttribute(VALUE);
+ if (val != null) {
+ value = new Boolean(val);
+ }
+ val = element.getAttribute(DEFAULT_VALUE);
+ if (val != null) {
+ defaultValue = new Boolean(val);
+ }
+ break;
+ case STRING:
+ // Just get the value out of the option directly
+ value = element.getAttribute(VALUE);
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+ break;
+ case ENUMERATED:
+ value = element.getAttribute(VALUE);
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+
+ // Do we have enumeratedOptionValue children? If so, load them
+ // to define the valid values and the default value.
+ IManagedConfigElement[] enumElements = element.getChildren(ENUM_VALUE);
+ for (int i = 0; i < enumElements.length; ++i) {
+ String optId = enumElements[i].getAttribute(ID);
+ if (i == 0) {
+ enumList = new ArrayList();
+ if (defaultValue == null) {
+ defaultValue = optId; // Default value to be overridden if default is specified
+ }
+ }
+ enumList.add(optId);
+ getEnumCommandMap().put(optId, enumElements[i].getAttribute(COMMAND));
+ getEnumNameMap().put(optId, enumElements[i].getAttribute(NAME));
+ Boolean isDefault = new Boolean(enumElements[i].getAttribute(IS_DEFAULT));
+ if (isDefault.booleanValue()) {
+ defaultValue = optId;
+ }
+ }
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ // Note: These string-list options do not load either the "value" or
+ // "defaultValue" attributes. Instead, the ListOptionValue children
+ // are loaded in the value field.
+ List valueList = null;
+ IManagedConfigElement[] valueElements = element.getChildren(LIST_VALUE);
+ for (int i = 0; i < valueElements.length; ++i) {
+ if (i == 0) {
+ valueList = new ArrayList();
+ builtIns = new ArrayList();
+ }
+ IManagedConfigElement valueElement = valueElements[i];
+ Boolean isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
+ if (isBuiltIn.booleanValue()) {
+ builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ else {
+ valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ }
+ value = valueList;
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ }
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java
index 946db2da521..e6665df31ce 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionCategory.java
@@ -13,63 +13,159 @@ package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
*
*/
public class OptionCategory extends BuildObject implements IOptionCategory {
- private IOptionCategory owner;
- private List children;
- private Tool tool;
- private boolean resolved = true;
-
private static final IOptionCategory[] emtpyCategories = new IOptionCategory[0];
+
+ // Parent and children
+ private Tool tool;
+ private List children; // Note: These are logical Option Category children, not "model" children
+ // Managed Build model attributes
+ private IOptionCategory owner; // The logical Option Category parent
+ private String ownerId;
+ // Miscellaneous
+ private boolean isExtensionOptionCategory = false;
+ private boolean isDirty = false;
+ private boolean resolved = true;
+ /*
+ * C O N S T R U C T O R S
+ */
+
public OptionCategory(IOptionCategory owner) {
this.owner = owner;
}
- public OptionCategory(Tool tool, IManagedConfigElement element) {
+ /**
+ * This constructor is called to create an option category defined by an extension point in
+ * a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The IToolChain parent of this builder, or null
if
+ * defined at the top level
+ * @param element The builder definition from the manifest file or a dynamic element
+ * provider
+ */
+ public OptionCategory(Tool parent, IManagedConfigElement element) {
+ this.tool = parent;
+ isExtensionOptionCategory = true;
+
// setup for resolving
- ManagedBuildManager.putConfigElement(this, element);
resolved = false;
- this.tool = tool;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionOptionCategory(this);
+
+ // Add the category to the tool
+ tool.addOptionCategory(this);
+ }
+
+ /**
+ * Create an Tool
the OptionCategory will be added to.
+ * @param element The XML element that contains the OptionCategory settings.
+ */
+ public OptionCategory(Tool parent, Element element) {
+ tool = parent;
+ isExtensionOptionCategory = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Add the category to the tool
+ tool.addOptionCategory(this);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ public void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
// id
setId(element.getAttribute(IOptionCategory.ID));
- // Name
+ // name
setName(element.getAttribute(IOptionCategory.NAME));
-
- tool.addOptionCategory(this);
+ // owner
+ ownerId = element.getAttribute(IOptionCategory.OWNER);
}
+
+ /* (non-Javadoc)
+ * Initialize the OptionCategory information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the OptionCategory information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- String parentId = element.getAttribute(IOptionCategory.OWNER);
- if (parentId != null)
- owner = tool.getOptionCategory(parentId);
- else
- owner = tool;
-
- // Hook me in
- if (owner instanceof Tool)
- ((Tool)owner).addChildCategory(this);
- else
- ((OptionCategory)owner).addChildCategory(this);
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
}
+
+ // owner
+ if (element.hasAttribute(IOptionCategory.OWNER)) {
+ ownerId = element.getAttribute(IOptionCategory.OWNER);
+ }
+ if (ownerId != null) {
+ owner = tool.getOptionCategory(ownerId);
+ } else {
+ owner = tool;
+ }
+
+ // Hook me in
+ if (owner instanceof Tool)
+ ((Tool)owner).addChildCategory(this);
+ else
+ ((OptionCategory)owner).addChildCategory(this);
}
+
+ /**
+ * Persist the OptionCategory to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (owner != null)
+ element.setAttribute(IOptionCategory.OWNER, owner.getId());
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
@@ -86,6 +182,72 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
children = new ArrayList();
children.add(category);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
+ */
+ public Object[][] getOptions(IConfiguration configuration) {
+ ITool[] tools = null;
+ if (configuration != null) {
+ tools = configuration.getTools();
+ }
+ return getOptions(tools, FILTER_PROJECT);
+ }
+
+ public Object[][] getOptions(IResourceConfiguration resConfig) {
+ ITool[] tools = null;
+ if (resConfig != null) {
+ tools = resConfig.getTools();
+ }
+ return getOptions(tools, FILTER_FILE);
+ }
+
+ private Object[][] getOptions(ITool[] tools, int filterValue) {
+ ITool catTool = getTool();
+ ITool tool = null;
+
+ if (tools != null) {
+ // Find the child of the configuration/resource configuration that represents the same tool.
+ // It could the tool itself, or a "sub-class" of the tool.
+ for (int i = 0; i < tools.length; ++i) {
+ ITool current = tools[i];
+ do {
+ if (catTool == current) {
+ tool = tools[i];
+ break;
+ }
+ } while ((current = current.getSuperClass()) != null);
+ if (tool != null) break;
+ }
+ }
+ if (tool == null) {
+ tool = catTool;
+ }
+
+ // Get all of the tool's options and see which ones are part of
+ // this category.
+ IOption[] allOptions = tool.getOptions();
+ Object[][] myOptions = new Object[allOptions.length][2];
+ int index = 0;
+ for (int i = 0; i < allOptions.length; ++i) {
+ IOption option = allOptions[i];
+ if (option.getCategory().equals(this)) {
+
+ // Check whether this option can be displayed for a specific resource type.
+ if( (option.getResourceFilter() == FILTER_ALL) || (option.getResourceFilter() == filterValue) ) {
+ myOptions[index] = new Object[2];
+ myOptions[index][0] = tool;
+ myOptions[index][1] = option;
+ index++;
+ }
+ }
+ }
+
+ return myOptions;
+ }
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOwner()
@@ -102,35 +264,47 @@ public class OptionCategory extends BuildObject implements IOptionCategory {
return owner.getTool();
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
*/
- public IOption[] getOptions(IConfiguration configuration) {
- ITool tool = getTool();
- if (configuration != null) {
- // TODO don't like this much
- ITool[] tools = configuration.getTools();
- for (int i = 0; i < tools.length; ++i) {
- if (tools[i] instanceof IToolReference) {
- if (((IToolReference)tools[i]).references(tool)) {
- tool = tools[i];
- break;
- }
- } else if (tools[i].equals(tool))
- break;
- }
- }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOptionCategory#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionOptionCategory;
+ }
- IOption[] allOptions = tool.getOptions();
- List myOptions = new ArrayList();
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOptionCategory#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension OptionCategory
+ if (isExtensionOptionCategory) return false;
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IIOptionCategory#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ }
+
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ if (ownerId != null)
+ owner = tool.getOptionCategory(ownerId);
+ else
+ owner = tool;
- for (int i = 0; i < allOptions.length; ++i) {
- IOption option = allOptions[i];
- if (option.getCategory().equals(this))
- myOptions.add(option);
+ // Hook me in
+ if (owner instanceof Tool)
+ ((Tool)owner).addChildCategory(this);
+ else
+ ((OptionCategory)owner).addChildCategory(this);
}
-
- return (IOption[])myOptions.toArray(new IOption[myOptions.size()]);
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java
index c115677ec1e..a7f6d074c52 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java
@@ -34,9 +34,13 @@ import org.w3c.dom.NodeList;
*/
public class OptionReference implements IOption {
+ private static final String EMPTY_STRING = new String();
+
// List of built-in values a tool defines
private List builtIns;
// Used for all option references that override the command
+ // Note: This is not currently used - don't start using it because
+ // it is not handled in converting from the CDT 2.0 object model
private String command;
// The option this reference overrides
private IOption option;
@@ -99,11 +103,16 @@ public class OptionReference implements IOption {
return;
}
+ int optValType;
+ try {
+ optValType = option.getValueType();
+ } catch (BuildException e) {return;}
+
// Hook the reference up
owner.addOptionReference(this);
// value
- switch (option.getValueType()) {
+ switch (optValType) {
case BOOLEAN:
value = new Boolean(element.getAttribute(DEFAULT_VALUE));
break;
@@ -155,8 +164,15 @@ public class OptionReference implements IOption {
((OptionReference)option).resolveReferences();
}
+ // Note: The "value" loaded here when the optionReference is read from the manifest file.
+ // This because the "valueType" is only known once the option reference is resolved.
+ int optValType;
+ try {
+ optValType = option.getValueType();
+ } catch (BuildException e) {return;}
+
// value
- switch (option.getValueType()) {
+ switch (optValType) {
case BOOLEAN:
value = new Boolean(element.getAttribute(DEFAULT_VALUE));
break;
@@ -165,14 +181,9 @@ public class OptionReference implements IOption {
break;
case ENUMERATED:
String temp = element.getAttribute(DEFAULT_VALUE);
- if (temp == null) {
- try {
- temp = option.getSelectedEnum();
- } catch (BuildException e) {
- temp = new String();
- }
+ if (temp != null) {
+ value = temp;
}
- value = temp;
break;
case STRING_LIST:
case INCLUDE_PATH:
@@ -189,7 +200,8 @@ public class OptionReference implements IOption {
}
else {
valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- } }
+ }
+ }
value = valueList;
break;
}
@@ -205,8 +217,16 @@ public class OptionReference implements IOption {
public void serialize(Document doc, Element element) {
element.setAttribute(ID, option.getId());
+ int optValType;
+ try {
+ optValType = option.getValueType();
+ } catch (BuildException e) {
+ // TODO: Issue an error message
+ return;
+ }
+
// value
- switch (option.getValueType()) {
+ switch (optValType) {
case BOOLEAN:
element.setAttribute(DEFAULT_VALUE, ((Boolean)value).toString());
break;
@@ -291,10 +311,12 @@ public class OptionReference implements IOption {
resolveReferences();
}
if (option != null) {
- return option.getEnumCommand(id);
- } else {
- return new String();
+ try {
+ String command = option.getEnumCommand(id);
+ return command;
+ } catch (BuildException e) {}
}
+ return new String();
}
/* (non-Javadoc)
@@ -305,10 +327,12 @@ public class OptionReference implements IOption {
resolveReferences();
}
if (option != null) {
- return option.getEnumName(id);
- } else {
- return new String();
- }
+ try {
+ String name = option.getEnumName(id);
+ return name;
+ } catch (BuildException e) {}
+ }
+ return new String();
}
/* (non-Javadoc)
@@ -319,11 +343,12 @@ public class OptionReference implements IOption {
resolveReferences();
}
if (option != null) {
- return option.getEnumeratedId(name);
- } else {
- return new String();
+ try {
+ String id = option.getEnumeratedId(name);
+ return id;
+ } catch (BuildException e) {}
}
-
+ return new String();
}
/* (non-Javadoc)
@@ -474,9 +499,9 @@ public class OptionReference implements IOption {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOption#getTool()
+ * @see org.eclipse.cdt.core.build.managed.IOption#getParent()
*/
- public ITool getTool() {
+ public ITool getParent() {
return owner;
}
@@ -507,9 +532,21 @@ public class OptionReference implements IOption {
* @see org.eclipse.cdt.core.build.managed.IOption#getValueType()
*/
public int getValueType() {
- return option.getValueType();
+ int optValType;
+ try {
+ optValType = option.getValueType();
+ } catch (BuildException e) {return -1;}
+
+ return optValType;
}
+ /* (non-Javadoc)
+ * Returns the raw value.
+ */
+ public Object getValue() {
+ return value;
+ }
+
/**
* Answers true
if the receiver is a reference to the
* IOption
specified in the argument, esle answers false
.
@@ -593,4 +630,95 @@ public class OptionReference implements IOption {
}
}
+ /*
+ * The following methods are here in order to implement the new ITool methods.
+ * They should never be called.
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#overridesOnlyValue()
+ */
+ public boolean overridesOnlyValue() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * Sets the raw value.
+ */
+ public void setValue(Object v) {
+ value = v;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setValueType()
+ */
+ public void setValueType(int type) {
+ }
+
+ /* (non-Javadoc)
+ * Returns the raw default value.
+ */
+ public Object getDefaultValue() {
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setValue(Object)
+ */
+ public void setDefaultValue(Object v) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getSuperClass()
+ */
+ public IOption getSuperClass() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getResourceFilter()
+ */
+ public int getResourceFilter() {
+ return FILTER_ALL;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
+ */
+ public void setResourceFilter(int filter) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setBrowseType(int)
+ */
+ public void setBrowseType(int type) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
+ */
+ public void setCategory(IOptionCategory category) {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setCommand(String)
+ */
+ public void setCommand(String cmd) {
+ if (cmd == null && command == null) return;
+ if (cmd == null || command == null || !cmd.equals(command)) {
+ command = cmd;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOption#setCommandFalse(String)
+ */
+ public void setCommandFalse(String cmd) {
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java
new file mode 100644
index 00000000000..594affaa1b7
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java
@@ -0,0 +1,336 @@
+/**********************************************************************
+ * 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.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+
+public class ProjectType extends BuildObject implements IProjectType {
+
+ private static final String EMPTY_STRING = new String();
+ private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
+
+ // Superclass
+ private IProjectType superClass;
+ private String superClassId;
+ // Parent and children
+ private List configList; // Configurations of this project type
+ private Map configMap;
+ // Managed Build model attributes
+ private Boolean isAbstract;
+ private Boolean isTest;
+ private String unusedChildren;
+ // Miscellaneous
+ private boolean resolved = true;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * This constructor is called to create a projectType defined by an extension point in
+ * a plugin manifest file.
+ *
+ * @param element
+ */
+ public ProjectType(IManagedConfigElement element) {
+ // setup for resolving
+ resolved = false;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionProjectType(this);
+
+ // Load the configuration children
+ IManagedConfigElement[] configs = element.getChildren(IConfiguration.CONFIGURATION_ELEMENT_NAME);
+ for (int n = 0; n < configs.length; ++n) {
+ Configuration config = new Configuration(this, configs[n]);
+ }
+ }
+
+ /**
+ * This constructor is called to create a project type whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param ProjectType The superClass, if any
+ * @param String The id for the new project type
+ * @param String The name for the new project type
+ */
+ public ProjectType(ProjectType superClass, String Id, String name) {
+ // setup for resolving
+ resolved = false;
+
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionProjectType(this);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Load the project-type information from the XML element specified in the
+ * argument
+ * @param element An XML element containing the project type information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(ID));
+
+ // Get the name
+ setName(element.getAttribute(NAME));
+
+ // superClass
+ superClassId = element.getAttribute(SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // Is this a test project type
+ String isTestStr = element.getAttribute(IS_TEST); //$NON-NLS-1$
+ if (isTestStr != null){
+ isTest = new Boolean("true".equals(isTestStr)); //$NON-NLS-1$
+ }
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IProjectType#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public IConfiguration createConfiguration(IConfiguration parent, String id, String name) {
+ Configuration config = new Configuration(this, parent, id, name);
+ return (IConfiguration)config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IProjectType#getConfiguration()
+ */
+ public IConfiguration getConfiguration(String id) {
+ return (IConfiguration)getConfigurationMap().get(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IProjectType#getConfigurations()
+ */
+ public IConfiguration[] getConfigurations() {
+ IConfiguration[] configs = new IConfiguration[getConfigurationList().size()];
+ Iterator iter = getConfigurationList().listIterator();
+ int i = 0;
+ while (iter.hasNext()) {
+ Configuration config = (Configuration)iter.next();
+ configs[i++] = (IConfiguration)config;
+ }
+ return configs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IProjectType#removeConfiguration(java.lang.String)
+ */
+ public void removeConfiguration(String id) {
+ // Remove the specified configuration from the list and map
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ IConfiguration config = (IConfiguration)iter.next();
+ if (config.getId().equals(id)) {
+ getConfigurationList().remove(config);
+ getConfigurationMap().remove(id);
+ break;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Adds the Configuration to the Configuration list and map
+ *
+ * @param Tool
+ */
+ public void addConfiguration(Configuration configuration) {
+ getConfigurationList().add(configuration);
+ getConfigurationMap().put(configuration.getId(), configuration);
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the list of configurations.
+ *
+ * @return List containing the configurations
+ */
+ private List getConfigurationList() {
+ if (configList == null) {
+ configList = new ArrayList();
+ }
+ return configList;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of configuration ids to configurations
+ *
+ * @return
+ */
+ private Map getConfigurationMap() {
+ if (configMap == null) {
+ configMap = new HashMap();
+ }
+ return configMap;
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
+ */
+ public String getName() {
+ // If I am unnamed, see if I can inherit one from my parent
+ if (name == null) {
+ if (superClass != null) {
+ return superClass.getName();
+ } else {
+ return new String(""); //$NON-NLS-1$
+ }
+ } else {
+ return name;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IProjectType#getSuperClass()
+ */
+ public IProjectType getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IProjectType#isAbstract()
+ */
+ public boolean isAbstract() {
+ if (isAbstract != null) {
+ return isAbstract.booleanValue();
+ } else {
+ return false; // Note: no inheritance from superClass
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IProjectType#unusedChildren()
+ */
+ public String getUnusedChildren() {
+ if (unusedChildren != null) {
+ return unusedChildren;
+ } else
+ return EMPTY_STRING; // Note: no inheritance from superClass
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IProjectType#isTestProjectType()
+ */
+ public boolean isTestProjectType() {
+ if (isTest == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.isTestProjectType();
+ } else {
+ return false;
+ }
+ }
+ return isTest.booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * Sets the isAbstract attribute
+ */
+ public void setIsAbstract(boolean b) {
+ isAbstract = new Boolean(b);
+ }
+
+ /* (non-Javadoc)
+ * Sets the isTest attribute
+ */
+ public void setIsTest(boolean b) {
+ isTest = new Boolean(b);
+ }
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * Resolve the element IDs to interface references
+ */
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ // Resolve superClass
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionProjectType(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // Add configurations from our superClass that are not overridden here
+ if (superClass != null) {
+ ((ProjectType)superClass).resolveReferences();
+ IConfiguration[] superConfigs = superClass.getConfigurations();
+ for (int i = 0; i < superConfigs.length; i++) {
+ String superId = superConfigs[i].getId();
+
+ check: {
+ IConfiguration[] currentConfigs = getConfigurations();
+ for (int j = 0; j < currentConfigs.length; j++) {
+ IConfiguration config = currentConfigs[j];
+ while (config.getParent() != null) {
+ if (config.getParent().getId().equals(superId)) break check;
+ config = config.getParent();
+ }
+ }
+ addConfiguration((Configuration)superConfigs[i]);
+ } // end check
+
+ }
+ }
+
+ // Call resolve references on any children
+ Iterator configIter = getConfigurationList().iterator();
+ while (configIter.hasNext()) {
+ Configuration current = (Configuration)configIter.next();
+ current.resolveReferences();
+ }
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java
new file mode 100644
index 00000000000..aa477aa3b08
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceConfiguration.java
@@ -0,0 +1,618 @@
+/**********************************************************************
+ * 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.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ResourceConfiguration extends BuildObject implements IResourceConfiguration {
+
+ private static final String EMPTY_STRING = new String();
+
+ // Parent and children
+ private IConfiguration parent;
+ private List toolList;
+ private Map toolMap;
+ // Managed Build model attributes
+ private String resPath;
+ private Boolean isExcluded;
+ // Miscellaneous
+ private boolean isExtensionResourceConfig = false;
+ private boolean isDirty = false;
+ private boolean resolved = true;
+ private boolean rebuildNeeded = false;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * This constructor is called to create a resource configuration defined by an
+ * extension point in a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The IConfiguration parent of this resource configuration
+ * @param element The resource configuration definition from the manifest file
+ * or a dynamic element provider
+ */
+ public ResourceConfiguration(IConfiguration parent, IManagedConfigElement element) {
+ this.parent = parent;
+ isExtensionResourceConfig = true;
+
+ // setup for resolving
+ resolved = false;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionResourceConfiguration(this);
+
+ // Load the tool children
+ IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
+ for (int n = 0; n < tools.length; ++n) {
+ Tool toolChild = new Tool(this, tools[n]);
+ toolList.add(toolChild);
+ }
+ }
+
+ /**
+ * Create a ResourceConfiguration
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The IConfiguration
the resource configuration will be added to.
+ * @param element The XML element that contains the resource configuration settings.
+ */
+ public ResourceConfiguration(IConfiguration parent, Element element) {
+ this.parent = parent;
+ isExtensionResourceConfig = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Load children
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(ITool.TOOL_ELEMENT_NAME)) {
+ Tool tool = new Tool((IBuildObject)this, (Element)configElement);
+ addTool(tool);
+ }
+ }
+ }
+
+ public ResourceConfiguration(IConfiguration parent, String id, String resourceName, String path){
+ this.parent = parent;
+
+ setId(id);
+ setName(resourceName);
+
+ resPath = path;
+ isDirty = false;
+ isExcluded = new Boolean(false);
+ }
+
+ /**
+ * Create a new resource configuration based on one already defined.
+ *
+ * @param managedProject The ManagedProject
the configuration will be added to.
+ * @param parentConfig The IConfiguration
to copy the settings from.
+ * @param id A unique ID for the new configuration.
+ */
+ public ResourceConfiguration(IConfiguration parent, ResourceConfiguration cloneConfig, String id) {
+ setId(id);
+ setName(cloneConfig.getName());
+ this.parent = parent;
+ isExtensionResourceConfig = false;
+
+ // Copy the remaining attributes
+ if (cloneConfig.resPath != null) {
+ resPath = new String(cloneConfig.resPath);
+ }
+ if (cloneConfig.isExcluded != null) {
+ isExcluded = new Boolean(cloneConfig.isExcluded.booleanValue());
+ }
+
+ // Clone the resource configuration's tool children
+ if (cloneConfig.toolList != null) {
+ Iterator iter = cloneConfig.getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool toolChild = (Tool) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (toolChild.getSuperClass() != null) {
+ subId = toolChild.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChild.getSuperClass().getName();
+ } else {
+ subId = toolChild.getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChild.getName();
+ }
+ // The superclass for the cloned tool is not the same as the one from the tool being cloned.
+ // The superclasses reside in different configurations.
+ ITool toolSuperClass = null;
+ // Search for the tool in this configuration that has the same grand-superClass as the
+ // tool being cloned
+ ITool[] tools = parent.getTools();
+ for (int i=0; inull
if
+ * defined at the top level
+ * @param element The TargetPlatform definition from the manifest file or a dynamic element
+ * provider
+ */
+ public TargetPlatform(IToolChain parent, IManagedConfigElement element) {
+ this.parent = parent;
+ isExtensionTargetPlatform = true;
+
+ // setup for resolving
+ resolved = false;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionTargetPlatform(this);
+ }
+
+ /**
+ * This constructor is called to create a TargetPlatform whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param ToolChain The parent of the builder, if any
+ * @param TargetPlatform The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public TargetPlatform(ToolChain parent, ITargetPlatform superClass, String Id, String name, boolean isExtensionElement) {
+ this.parent = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionTargetPlatform = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionTargetPlatform(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create a TargetPlatform
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The IToolChain
the TargetPlatform will be added to.
+ * @param element The XML element that contains the TargetPlatform settings.
+ */
+ public TargetPlatform(IToolChain parent, Element element) {
+ this.parent = parent;
+ isExtensionTargetPlatform = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+ }
+
+ /**
+ * Create a TargetPlatform
based upon an existing TargetPlatform.
+ *
+ * @param parent The IToolChain
the TargetPlatform will be added to.
+ * @param builder The existing TargetPlatform to clone.
+ */
+ public TargetPlatform(IToolChain parent, String Id, String name, TargetPlatform targetPlatform) {
+ this.parent = parent;
+ superClass = targetPlatform.superClass;
+ if (superClass != null) {
+ if (targetPlatform.superClassId != null) {
+ superClassId = new String(targetPlatform.superClassId);
+ }
+ }
+ setId(Id);
+ setName(name);
+ isExtensionTargetPlatform = false;
+
+ // Copy the remaining attributes
+ if (targetPlatform.unusedChildren != null) {
+ unusedChildren = new String(targetPlatform.unusedChildren);
+ }
+ if (targetPlatform.errorParserIds != null) {
+ errorParserIds = new String(targetPlatform.errorParserIds);
+ }
+ if (targetPlatform.isAbstract != null) {
+ isAbstract = new Boolean(targetPlatform.isAbstract.booleanValue());
+ }
+ if (targetPlatform.osList != null) {
+ osList = new ArrayList(targetPlatform.osList);
+ }
+ if (targetPlatform.archList != null) {
+ archList = new ArrayList(targetPlatform.archList);
+ }
+ if (targetPlatform.binaryParserId != null) {
+ binaryParserId = new String(targetPlatform.binaryParserId);
+ }
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the target platform information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the tool-chain information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // Get the comma-separated list of valid OS
+ String os = element.getAttribute(OS_LIST);
+ if (os != null) {
+ osList = new ArrayList();
+ String[] osTokens = os.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osTokens.length; ++i) {
+ osList.add(osTokens[i].trim());
+ }
+ }
+
+ // Get the comma-separated list of valid Architectures
+ String arch = element.getAttribute(ARCH_LIST);
+ if (arch != null) {
+ archList = new ArrayList();
+ String[] archTokens = arch.split(","); //$NON-NLS-1$
+ for (int j = 0; j < archTokens.length; ++j) {
+ archList.add(archTokens[j].trim());
+ }
+ }
+
+ // Get the ID of the binary parser
+ binaryParserId = element.getAttribute(BINARY_PARSER);
+ }
+
+ /* (non-Javadoc)
+ * Initialize the target platform information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the target platform information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionTargetPlatform(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the comma-separated list of valid OS
+ if (element.hasAttribute(OS_LIST)) {
+ String os = element.getAttribute(OS_LIST);
+ if (os != null) {
+ osList = new ArrayList();
+ String[] osTokens = os.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osTokens.length; ++i) {
+ osList.add(osTokens[i].trim());
+ }
+ }
+ }
+
+ // Get the comma-separated list of valid Architectures
+ if (element.hasAttribute(ARCH_LIST)) {
+ String arch = element.getAttribute(ARCH_LIST);
+ if (arch != null) {
+ archList = new ArrayList();
+ String[] archTokens = arch.split(","); //$NON-NLS-1$
+ for (int j = 0; j < archTokens.length; ++j) {
+ archList.add(archTokens[j].trim());
+ }
+ }
+ }
+
+ // binaryParserId
+ if (element.hasAttribute(BINARY_PARSER)) {
+ binaryParserId = element.getAttribute(BINARY_PARSER);
+ }
+
+ }
+
+ /**
+ * Persist the target platform to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ if (binaryParserId != null) {
+ element.setAttribute(BINARY_PARSER, binaryParserId);
+ }
+
+ if (osList != null) {
+ Iterator osIter = osList.listIterator();
+ String listValue = EMPTY_STRING;
+ while (osIter.hasNext()) {
+ String current = (String) osIter.next();
+ listValue += current;
+ if ((osIter.hasNext())) {
+ listValue += ","; //$NON-NLS-1$
+ }
+ }
+ element.setAttribute(OS_LIST, listValue);
+ }
+
+ if (archList != null) {
+ Iterator archIter = archList.listIterator();
+ String listValue = EMPTY_STRING;
+ while (archIter.hasNext()) {
+ String current = (String) archIter.next();
+ listValue += current;
+ if ((archIter.hasNext())) {
+ listValue += ","; //$NON-NLS-1$
+ }
+ }
+ element.setAttribute(ARCH_LIST, listValue);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITargetPlatform#getParent()
+ */
+ public IToolChain getParent() {
+ return parent;
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITargetPlatform#getSuperClass()
+ */
+ public ITargetPlatform getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITargetPlatform#getName()
+ */
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITargetPlatform#isAbstract()
+ */
+ public boolean isAbstract() {
+ if (isAbstract != null) {
+ return isAbstract.booleanValue();
+ } else {
+ return false; // Note: no inheritance from superClass
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITargetPlatform#getUnusedChildren()
+ */
+ public String getUnusedChildren() {
+ if (unusedChildren != null) {
+ return unusedChildren;
+ } else
+ return EMPTY_STRING; // Note: no inheritance from superClass
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITargetPlatform#getBinaryParserI()
+ */
+ public String getBinaryParserId() {
+ if (binaryParserId == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getBinaryParserId();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return binaryParserId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITargetPlatform#getArchList()
+ */
+ public String[] getArchList() {
+ if (archList == null) {
+ // Ask superClass for its list
+ if (superClass != null) {
+ return superClass.getArchList();
+ } else {
+ // I have no superClass and no defined list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) archList.toArray(new String[archList.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITargetPlatform#getOSList()
+ */
+ public String[] getOSList() {
+ if (osList == null) {
+ // Ask superClass for its list
+ if (superClass != null) {
+ return superClass.getOSList();
+ } else {
+ // I have no superClass and no defined filter list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) osList.toArray(new String[osList.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IBuilder#setBinaryParserId(String)
+ */
+ public void setBinaryParserId(String id) {
+ if (id == null && binaryParserId == null) return;
+ if (binaryParserId == null || id == null || !id.equals(binaryParserId)) {
+ binaryParserId = id;
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Sets the isAbstract attribute
+ */
+ public void setIsAbstract(boolean b) {
+ isAbstract = new Boolean(b);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * Sets the OS list.
+ *
+ * @param String[] The list of OS names
+ */
+ public void setOSList(String[] OSs) {
+ if (osList == null) {
+ osList = new ArrayList();
+ } else {
+ osList.clear();
+ }
+ for (int i = 0; i < OSs.length; i++) {
+ osList.add(OSs[i]);
+ }
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * Sets the architecture list.
+ *
+ * @param String[] The list of OS names
+ */
+ public void setArchList(String[] archs) {
+ if (archList == null) {
+ archList = new ArrayList();
+ } else {
+ archList.clear();
+ }
+ for (int i = 0; i < archs.length; i++) {
+ archList.add(archs[i]);
+ }
+ setDirty(true);
+ }
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionTargetPlatform;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension Builder
+ if (isExtensionTargetPlatform) return false;
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuilder#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ }
+
+ /* (non-Javadoc)
+ * Resolve the element IDs to interface references
+ */
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ // Resolve superClass
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionTargetPlatform(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
index 313f5df2ac4..62cdb1823b0 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
@@ -20,13 +20,21 @@ import java.util.StringTokenizer;
import java.util.Vector;
import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolReference;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* Represents a tool that can be invoked during a build.
@@ -35,25 +43,45 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
*/
public class Tool extends BuildObject implements ITool, IOptionCategory {
+ public static final String DEFAULT_PATTERN = "${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}"; //$NON-NLS-1$
+
private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
private static final IOption[] EMPTY_OPTIONS = new IOption[0];
+ private static final String EMPTY_STRING = new String();
+ // Superclass
+ private ITool superClass;
+ private String superClassId;
+ // Parent and children
+ private IBuildObject parent;
private Vector categoryIds;
private Map categoryMap;
private List childOptionCategories;
+ private Vector optionList;
+ private Map optionMap;
+ // Managed Build model attributes
+ private String unusedChildren;
+ private Boolean isAbstract;
private String command;
private List inputExtensions;
private List interfaceExtensions;
- private int natureFilter;
- private Vector optionList;
- private Map optionMap;
+ private Integer natureFilter;
private String outputExtensions;
private String outputFlag;
private String outputPrefix;
+ private String errorParserIds;
+ private String commandLinePattern;
+ // 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
+ */
+
/**
* Constructor to create a tool based on an element from the plugin
* manifest.
@@ -61,24 +89,741 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
* @param element The element containing the information about the tool.
*/
public Tool(IManagedConfigElement element) {
+ isExtensionTool = true;
+
+ // setup for resolving
+ resolved = false;
+
loadFromManifest(element);
// hook me up
ManagedBuildManager.addExtensionTool(this);
+
+ // set up the category map
+ addOptionCategory(this);
+
+ // Check for optionList
+ IManagedConfigElement[] toolElements = element.getChildren();
+ for (int l = 0; l < toolElements.length; ++l) {
+ IManagedConfigElement toolElement = toolElements[l];
+ if (toolElement.getName().equals(ITool.OPTION)) {
+ Option option = new Option(this, toolElement);
+ addOption(option);
+ } else if (toolElement.getName().equals(ITool.OPTION_CAT)) {
+ new OptionCategory(this, toolElement);
+ }
+ }
}
/**
- * Constructor to create a new tool for a target based on the information
+ * Constructor to create a new tool for a tool-chain based on the information
* defined in the plugin.xml manifest.
*
- * @param target The target the receiver will belong to.
+ * @param parent The parent of this tool. This can be a ToolChain or a
+ * ResourceConfiguration.
* @param element The element containing the information about the tool.
*/
- public Tool(Target target, IManagedConfigElement element) {
- loadFromManifest(element);
+ public Tool(IBuildObject parent, IManagedConfigElement element) {
+ this(element);
+ this.parent = parent;
+ }
+
+ /**
+ * This constructor is called to create a Tool whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param ToolChain The parent of the tool, if any
+ * @param Tool The superClass, if any
+ * @param String The id for the new tool
+ * @param String The name for the new tool
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public Tool(ToolChain parent, ITool superClass, String Id, String name, boolean isExtensionElement) {
+ this.parent = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionTool = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionTool(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * This constructor is called to create a Tool whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param ResourceConfiguration, The parent of the tool, if any
+ * @param Tool The superClass, if any
+ * @param String The id for the new tool
+ * @param String The name for the new tool
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+
+ public Tool(ResourceConfiguration parent, ITool superClass, String Id, String name, boolean isExtensionElement) {
+ this.parent = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionTool = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionTool(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create a Tool
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The IToolChain
or IResourceConfiguration
+ * the tool will be added to.
+ * @param element The XML element that contains the tool settings.
+ */
+ public Tool(IBuildObject parent, Element element) {
+ this.parent = parent;
+ isExtensionTool = false;
- // hook me up
- target.addTool(this);
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // set up the category map
+ addOptionCategory(this);
+
+ // Check for optionList
+ NodeList toolElements = element.getChildNodes();
+ for (int i = 0; i < toolElements.getLength(); ++i) {
+ Node toolElement = toolElements.item(i);
+ if (toolElement.getNodeName().equals(ITool.OPTION)) {
+ Option option = new Option(this, (Element)toolElement);
+ addOption(option);
+ } else if (toolElement.getNodeName().equals(ITool.OPTION_CAT)) {
+ new OptionCategory(this, (Element)toolElement);
+ }
+ }
+ }
+
+ /**
+ * Create a Tool
based upon an existing tool.
+ *
+ * @param parent The IToolChain
or IResourceConfiguration
+ * the tool will be added to.
+ * @param tool The existing tool to clone.
+ */
+ public Tool(IBuildObject parent, ITool toolSuperClass, String Id, String name, Tool tool){
+ this.parent = parent;
+ if (toolSuperClass != null) {
+ superClass = toolSuperClass;
+ } else {
+ superClass = tool.superClass;
+ }
+ if (superClass != null) {
+ superClassId = superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionTool = false;
+
+ // Copy the remaining attributes
+ if (tool.unusedChildren != null) {
+ unusedChildren = new String(tool.unusedChildren);
+ }
+ if (tool.errorParserIds != null) {
+ errorParserIds = new String(tool.errorParserIds);
+ }
+ if (tool.isAbstract != null) {
+ isAbstract = new Boolean(tool.isAbstract.booleanValue());
+ }
+ if (tool.command != null) {
+ command = new String(tool.command);
+ }
+ if (tool.inputExtensions != null) {
+ inputExtensions = new ArrayList(tool.inputExtensions);
+ }
+ if (tool.interfaceExtensions != null) {
+ interfaceExtensions = new ArrayList(tool.interfaceExtensions);
+ }
+ if (tool.natureFilter != null) {
+ natureFilter = new Integer(tool.natureFilter.intValue());
+ }
+ if (tool.outputExtensions != null) {
+ outputExtensions = new String(tool.outputExtensions);
+ }
+ if (tool.outputFlag != null) {
+ outputFlag = new String(tool.outputFlag);
+ }
+ if (tool.outputPrefix != null) {
+ outputPrefix = new String(tool.outputPrefix);
+ }
+
+ // Clone the children
+ // Note: This constructor ignores OptionCategories since they should not be
+ // found on an non-extension tool
+ if (tool.optionList != null) {
+ Iterator iter = tool.getOptionList().listIterator();
+ while (iter.hasNext()) {
+ Option option = (Option) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (option.getSuperClass() != null) {
+ subId = option.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = option.getSuperClass().getName();
+ } else {
+ subId = option.getId() + "." + nnn; //$NON-NLS-1$
+ subName = option.getName();
+ }
+ Option newOption = new Option(this, subId, subName, option);
+ addOption(newOption);
+ }
+ }
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Load the tool information from the XML element specified in the
+ * argument
+ * @param element An XML element containing the tool information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ // setup for resolving
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(ITool.ID));
+
+ // name
+ setName(element.getAttribute(ITool.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
+
+ // Get the nature filter
+ String nature = element.getAttribute(NATURE);
+ if (nature != null) {
+ if ("both".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_BOTH);
+ } else if ("cnature".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_C);
+ } else if ("ccnature".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_CC);
+ } else {
+ natureFilter = new Integer(FILTER_BOTH);
+ }
+ }
+
+ // Get the supported input file extensions
+ String inputs = element.getAttribute(ITool.SOURCES);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+
+ // Get the interface (header file) extensions
+ String headers = element.getAttribute(INTERFACE_EXTS);
+ if (headers != null) {
+ StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInterfaceExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+
+ // Get the output extension
+ outputExtensions = element.getAttribute(ITool.OUTPUTS);
+
+ // Get the tool invocation command
+ command = element.getAttribute(ITool.COMMAND);
+
+ // Get the flag to control output
+ outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
+
+ // Get the output prefix
+ outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
+
+ // Get command line pattern
+ commandLinePattern = element.getAttribute( ITool.COMMAND_LINE_PATTERN );
+ }
+
+ /* (non-Javadoc)
+ * Initialize the tool information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the tool information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ if( getParent() instanceof IResourceConfiguration ) {
+ IResourceConfiguration resConfig = (IResourceConfiguration) getParent();
+ superClass = resConfig.getParent().getTool(superClassId);
+ } else {
+ superClass = ManagedBuildManager.getExtensionTool(superClassId);
+ }
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(IToolChain.ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
+ }
+
+ // Get the nature filter
+ if (element.hasAttribute(NATURE)) {
+ String nature = element.getAttribute(NATURE);
+ if (nature != null) {
+ if ("both".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_BOTH);
+ } else if ("cnature".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_C);
+ } else if ("ccnature".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_CC);
+ } else {
+ natureFilter = new Integer(FILTER_BOTH);
+ }
+ }
+ }
+
+ // Get the supported input file extension
+ if (element.hasAttribute(ITool.SOURCES)) {
+ String inputs = element.getAttribute(ITool.SOURCES);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ }
+
+ // Get the interface (header file) extensions
+ if (element.hasAttribute(INTERFACE_EXTS)) {
+ String headers = element.getAttribute(INTERFACE_EXTS);
+ if (headers != null) {
+ StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInterfaceExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ }
+
+ // Get the output extension
+ if (element.hasAttribute(ITool.OUTPUTS)) {
+ outputExtensions = element.getAttribute(ITool.OUTPUTS);
+ }
+
+ // Get the tool invocation command
+ if (element.hasAttribute(ITool.COMMAND)) {
+ command = element.getAttribute(ITool.COMMAND);
+ }
+
+ // Get the flag to control output
+ if (element.hasAttribute(ITool.OUTPUT_FLAG)) {
+ outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
+ }
+
+ // Get the output prefix
+ if (element.hasAttribute(ITool.OUTPUT_PREFIX)) {
+ outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
+ }
+
+ // Get command line pattern
+ if( element.hasAttribute( ITool.COMMAND_LINE_PATTERN ) ) {
+ commandLinePattern = element.getAttribute( ITool.COMMAND_LINE_PATTERN );
+ }
+ }
+
+ /**
+ * Persist the tool to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ try {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ // id
+ element.setAttribute(IBuildObject.ID, id);
+
+ // name
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ // unused children
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ // isAbstract
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ // error parsers
+ if (errorParserIds != null) {
+ element.setAttribute(IToolChain.ERROR_PARSERS, errorParserIds);
+ }
+
+ // nature filter
+ if (natureFilter != null) {
+ String nature;
+ if (natureFilter.intValue() == FILTER_C) {
+ nature = "cnature"; //$NON-NLS-1$
+ } else if (natureFilter.intValue() == FILTER_CC) {
+ nature = "ccnature"; //$NON-NLS-1$
+ } else {
+ nature = "both"; //$NON-NLS-1$
+ }
+ element.setAttribute(NATURE, nature);
+ }
+
+ // input file extensions
+ if (getInputExtensionsList().size() > 0) {
+ String inputs;
+ List list = getInputExtensionsList();
+ Iterator iter = list.listIterator();
+ inputs = (String)iter.next();
+ while (iter.hasNext()) {
+ inputs += DEFAULT_SEPARATOR;
+ inputs += iter.next();
+ }
+ element.setAttribute(ITool.SOURCES, inputs);
+ }
+
+ // interface (header file) extensions
+ if (getInterfaceExtensionsList().size() > 0) {
+ String headers;
+ List list = getInterfaceExtensionsList();
+ Iterator iter = list.listIterator();
+ headers = (String)iter.next();
+ while (iter.hasNext()) {
+ headers += DEFAULT_SEPARATOR;
+ headers += iter.next();
+ }
+ element.setAttribute(INTERFACE_EXTS, headers);
+ }
+
+ // output extension
+ if (outputExtensions != null) {
+ element.setAttribute(ITool.OUTPUTS, outputExtensions);
+ }
+
+ // command
+ if (command != null) {
+ element.setAttribute(ITool.COMMAND, command);
+ }
+
+ // flag to control output
+ if (outputFlag != null) {
+ element.setAttribute(ITool.OUTPUT_FLAG, outputFlag);
+ }
+
+ // output prefix
+ if (outputPrefix != null) {
+ element.setAttribute(ITool.OUTPUT_PREFIX, outputPrefix);
+ }
+
+ // command line pattern
+ if (commandLinePattern != null) {
+ element.setAttribute(ITool.COMMAND_LINE_PATTERN, commandLinePattern);
+ }
+
+ // Serialize my children
+ if (childOptionCategories != null) {
+ Iterator iter = childOptionCategories.listIterator();
+ while (iter.hasNext()) {
+ OptionCategory optCat = (OptionCategory)iter.next();
+ Element optCatElement = doc.createElement(OPTION);
+ element.appendChild(optCatElement);
+ optCat.serialize(doc, optCatElement);
+ }
+ }
+ List optionElements = getOptionList();
+ Iterator iter = optionElements.listIterator();
+ while (iter.hasNext()) {
+ Option option = (Option) iter.next();
+ Element optionElement = doc.createElement(OPTION);
+ element.appendChild(optionElement);
+ option.serialize(doc, optionElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ } catch (Exception e) {
+ // TODO: issue an error message
+ }
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getParent()
+ */
+ public IBuildObject getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setParent(IBuildObject)
+ */
+ public void setToolParent(IBuildObject newParent) {
+ this.parent = newParent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#createOption(IOption, String, String, boolean)
+ */
+ public IOption createOption(IOption superClass, String Id, String name, boolean isExtensionElement) {
+ Option option = new Option(this, superClass, Id, name, isExtensionElement);
+ addOption(option);
+ setDirty(true);
+ return option;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#createOption(IOption, String, String, boolean)
+ */
+ public void removeOption(IOption option) {
+ getOptionList().remove(option);
+ getOptionMap().remove(option.getId());
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getOptions()
+ */
+ public IOption[] getOptions() {
+ IOption[] options = null;
+ // Merge our options with our superclass' options.
+ if (superClass != null) {
+ options = superClass.getOptions();
+ }
+ // Our options take precedence.
+ Vector ourOpts = getOptionList();
+ if (options != null) {
+ for (int i = 0; i < ourOpts.size(); i++) {
+ IOption ourOpt = (IOption)ourOpts.get(i);
+ int j;
+ for (j = 0; j < options.length; j++) {
+ if (options[j].overridesOnlyValue()) {
+ if (ourOpt.getSuperClass().getId().equals(options[j].getSuperClass().getId())) {
+ options[j] = ourOpt;
+ break;
+ }
+ } else {
+ if (ourOpt.getSuperClass().getId().equals(options[j].getId())) {
+ options[j] = ourOpt;
+ break;
+ }
+ }
+ }
+ // No Match? Add it.
+ if (j == options.length) {
+ IOption[] newOptions = new IOption[options.length + 1];
+ for (int k = 0; k < options.length; k++) {
+ newOptions[k] = options[k];
+ }
+ newOptions[j] = ourOpt;
+ options = newOptions;
+ }
+ }
+ } else {
+ options = (IOption[])ourOpts.toArray(new IOption[ourOpts.size()]);
+ }
+ return options;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getTopOptionCategory()
+ */
+ public IOptionCategory getTopOptionCategory() {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getOption(java.lang.String)
+ */
+ public IOption getOption(String id) {
+ return getOptionById(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOptionById(java.lang.String)
+ */
+ public IOption getOptionById(String id) {
+ IOption opt = (IOption)getOptionMap().get(id);
+ if (opt == null) {
+ if (superClass != null) {
+ return superClass.getOptionById(id);
+ }
+ }
+ return opt;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
+ */
+ public IOptionCategory[] getChildCategories() {
+ if (childOptionCategories != null)
+ return (IOptionCategory[])childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
+ else {
+ if (superClass != null) {
+ return superClass.getChildCategories();
+ } else {
+ return EMPTY_CATEGORIES;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOwner()
+ */
+ public IOptionCategory getOwner() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
+ */
+ public Object[][] getOptions(IConfiguration configuration) {
+ // Find the child of the configuration that represents the same tool.
+ // It could the tool itself, or a "sub-class" of the tool.
+ if (configuration != null) {
+ ITool[] tools = configuration.getTools();
+ return getOptions(tools);
+ } else {
+ return getAllOptions(this);
+ }
+ }
+
+ public Object[][] getOptions(IResourceConfiguration resConfig) {
+ ITool[] tools = resConfig.getTools();
+ return getOptions(tools);
+ }
+
+ private Object[][] getOptions(ITool[] tools) {
+ ITool catTool = this;
+ ITool tool = null;
+ for (int i = 0; i < tools.length; ++i) {
+ ITool current = tools[i];
+ do {
+ if (catTool == current) {
+ tool = tools[i];
+ break;
+ }
+ } while ((current = current.getSuperClass()) != null);
+ if (tool != null) break;
+ }
+ // Get all of the tool's options and see which ones are part of
+ // this category.
+ if( tool == null)
+ return null;
+
+ return getAllOptions(tool);
+ }
+
+ private Object[][] getAllOptions(ITool tool) {
+ IOption[] allOptions = tool.getOptions();
+ Object[][] myOptions = new Object[allOptions.length][2];
+ int index = 0;
+ for (int i = 0; i < allOptions.length; ++i) {
+ IOption option = allOptions[i];
+ IOptionCategory optCat = option.getCategory();
+ if (optCat instanceof ITool) {
+ // Determine if the category is this tool or a superclass
+ ITool current = this;
+ boolean match = false;
+ do {
+ if (optCat == current) {
+ match = true;
+ break;
+ }
+ } while ((current = current.getSuperClass()) != null);
+ if (match) {
+ myOptions[index] = new Object[2];
+ myOptions[index][0] = tool;
+ myOptions[index][1] = option;
+ index++;
+ }
+ }
+ }
+
+ return myOptions;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getTool()
+ */
+ public ITool getTool() {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * Memory-safe way to access the vector of category IDs
+ */
+ private Vector getCategoryIds() {
+ if (categoryIds == null) {
+ categoryIds = new Vector();
+ }
+ return categoryIds;
}
/**
@@ -104,25 +849,16 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
// Map the categories by ID for resolution later
getCategoryMap().put(category.getId(), category);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#handlesFileType(java.lang.String)
- */
- public boolean buildsFileType(String extension) {
- if (extension == null) {
- return false;
- }
- return getInputExtensions().contains(extension);
- }
- /* (non-Javadoc)
- * Memory-safe way to access the vector of category IDs
+ /**
+ * Answers the IOptionCategory
that has the unique identifier
+ * specified in the argument.
+ *
+ * @param id The unique identifier of the option category
+ * @return IOptionCategory
with the id specified in the argument
*/
- private Vector getCategoryIds() {
- if (categoryIds == null) {
- categoryIds = new Vector();
- }
- return categoryIds;
+ public IOptionCategory getOptionCategory(String id) {
+ return (IOptionCategory)getCategoryMap().get(id);
}
/* (non-Javadoc)
@@ -154,42 +890,130 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
return optionMap;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getOptions()
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
*/
- public IOption[] getOptions() {
- return (IOption[])getOptionList().toArray(new IOption[getOptionList().size()]);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getSuperClass()
+ */
+ public ITool getSuperClass() {
+ return superClass;
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getTopOptionCategory()
+ * @see org.eclipse.cdt.core.build.managed.ITool#getName()
*/
- public IOptionCategory getTopOptionCategory() {
- return this;
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
+ * @see org.eclipse.cdt.core.build.managed.ITool#isAbstract()
*/
- public IOptionCategory[] getChildCategories() {
- if (childOptionCategories != null)
- return (IOptionCategory[])childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
- else
- return EMPTY_CATEGORIES;
+ public boolean isAbstract() {
+ if (isAbstract != null) {
+ return isAbstract.booleanValue();
+ } else {
+ return false; // Note: no inheritance from superClass
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setIsAbstract(boolean)
+ */
+ public void setIsAbstract(boolean b) {
+ isAbstract = new Boolean(b);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getUnusedChildren()
+ */
+ public String getUnusedChildren() {
+ if (unusedChildren != null) {
+ return unusedChildren;
+ } else
+ return EMPTY_STRING; // Note: no inheritance from superClass
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ String ids = errorParserIds;
+ if (ids == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ ids = superClass.getErrorParserIds();
+ }
+ }
+ return ids;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ String parserIDs = getErrorParserIds();
+ String[] errorParsers;
+ if (parserIDs != null) {
+ // Check for an empty string
+ if (parserIDs.length() == 0) {
+ errorParsers = new String[0];
+ } else {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ List list = new ArrayList(tok.countTokens());
+ while (tok.hasMoreElements()) {
+ list.add(tok.nextToken());
+ }
+ String[] strArr = {""}; //$NON-NLS-1$
+ errorParsers = (String[]) list.toArray(strArr);
+ }
+ } else {
+ errorParsers = new String[0];
+ }
+ return errorParsers;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions()
*/
public List getInputExtensions() {
+ if( (inputExtensions == null) || ( inputExtensions.size() == 0) ) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getInputExtensions();
+ } else {
+ inputExtensions = new ArrayList();
+ }
+ }
+ return inputExtensions;
+ }
+
+ private List getInputExtensionsList() {
if (inputExtensions == null) {
- inputExtensions = new ArrayList();
+ inputExtensions = new ArrayList();
}
return inputExtensions;
}
- private List getInterfaceExtensions() {
+ public List getInterfaceExtensions() {
+ if (interfaceExtensions == null || interfaceExtensions.size() == 0) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getInterfaceExtensions();
+ } else {
+ if (interfaceExtensions == null) {
+ interfaceExtensions = new ArrayList();
+ }
+ }
+ }
+ return interfaceExtensions;
+ }
+
+ private List getInterfaceExtensionsList() {
if (interfaceExtensions == null) {
interfaceExtensions = new ArrayList();
}
@@ -200,198 +1024,280 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
* @see org.eclipse.cdt.core.build.managed.ITool#getOutputFlag()
*/
public String getOutputFlag() {
- return outputFlag == null ? new String() : outputFlag.trim();
+ if (outputFlag == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getOutputFlag();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return outputFlag;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getOutputPrefix()
*/
public String getOutputPrefix() {
- return outputPrefix == null ? new String() : outputPrefix.trim();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOwner()
- */
- public IOptionCategory getOwner() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getTool()
- */
- public ITool getTool() {
- return this;
+ if (outputPrefix == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getOutputPrefix();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return outputPrefix;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getToolCommand()
*/
public String getToolCommand() {
- return command.trim();
+ if (command == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getToolCommand();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return command;
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getToolFlags()
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getCommandLinePattern()
*/
- public String getToolFlags() throws BuildException {
- // Get all of the optionList
- StringBuffer buf = new StringBuffer();
- IOption[] opts = getOptions();
- for (int index = 0; index < opts.length; index++) {
- IOption option = opts[index];
- switch (option.getValueType()) {
- case IOption.BOOLEAN :
- String boolCmd;
- if (option.getBooleanValue()) {
- boolCmd = option.getCommand();
- } else {
- // Note: getCommandFalse is new with CDT 2.0
- boolCmd = option.getCommandFalse();
- }
- if (boolCmd != null && boolCmd.length() > 0) {
- buf.append(boolCmd + WHITE_SPACE);
- }
- break;
-
- case IOption.ENUMERATED :
- String enum = option.getEnumCommand(option.getSelectedEnum());
- if (enum.length() > 0) {
- buf.append(enum + WHITE_SPACE);
- }
- break;
-
- case IOption.STRING :
- String strCmd = option.getCommand();
- String val = option.getStringValue();
- if (val.length() > 0) {
- if (strCmd != null) buf.append(strCmd);
- buf.append(val + WHITE_SPACE);
- }
- break;
-
- case IOption.STRING_LIST :
- String listCmd = option.getCommand();
- String[] list = option.getStringListValue();
- for (int j = 0; j < list.length; j++) {
- String temp = list[j];
- if (listCmd != null) buf.append(listCmd);
- buf.append(temp + WHITE_SPACE);
- }
- break;
-
- case IOption.INCLUDE_PATH :
- String incCmd = option.getCommand();
- String[] paths = option.getIncludePaths();
- for (int j = 0; j < paths.length; j++) {
- String temp = paths[j];
- buf.append(incCmd + temp + WHITE_SPACE);
- }
- break;
-
- case IOption.PREPROCESSOR_SYMBOLS :
- String defCmd = option.getCommand();
- String[] symbols = option.getDefinedSymbols();
- for (int j = 0; j < symbols.length; j++) {
- String temp = symbols[j];
- buf.append(defCmd + temp + WHITE_SPACE);
- }
- break;
-
- default :
- break;
- }
-
+ public String getCommandLinePattern() {
+ if (commandLinePattern != null) {
+ return commandLinePattern;
+ } else {
+ return new String(DEFAULT_PATTERN); // Default pattern
}
-
- return buf.toString().trim();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
- */
- public IOption[] getOptions(IConfiguration configuration) {
- ITool tool = this;
- if (configuration != null) {
- // TODO don't like this much
- ITool[] tools = configuration.getTools();
- for (int i = 0; i < tools.length; ++i) {
- if (tools[i] instanceof IToolReference) {
- if (((IToolReference)tools[i]).references(tool)) {
- tool = tools[i];
- break;
- }
- } else if (tools[i].equals(tool))
- break;
- }
- }
-
- IOption[] allOptions = tool.getOptions();
- ArrayList myOptions = new ArrayList();
-
- for (int i = 0; i < allOptions.length; ++i) {
- IOption option = allOptions[i];
- if (option.getCategory().equals(this))
- myOptions.add(option);
- }
-
- myOptions.trimToSize();
- return (IOption[])myOptions.toArray(new IOption[myOptions.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getNatureFilter()
*/
public int getNatureFilter() {
- return natureFilter;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getOption(java.lang.String)
- */
- public IOption getOption(String id) {
- return getOptionById(id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
- */
- public IOption getOptionById(String id) {
- return (IOption)getOptionMap().get(id);
- }
-
- /**
- * Answers the IOptionCategory
that has the unique identifier
- * specified in the argument.
- *
- * @param id The unique identifier of the option category
- * @return IOptionCategory
with the id specified in the argument
- */
- public IOptionCategory getOptionCategory(String id) {
- return (IOptionCategory)getCategoryMap().get(id);
+ if (natureFilter == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getNatureFilter();
+ } else {
+ return FILTER_BOTH;
+ }
+ }
+ return natureFilter.intValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputExtensions()
*/
public String[] getOutputExtensions() {
+ // TODO: Why is this treated differently than inputExtensions?
+ if (outputExtensions == null) {
+ if (superClass != null) {
+ return superClass.getOutputExtensions();
+ } else {
+ return null;
+ }
+ }
return outputExtensions.split(DEFAULT_SEPARATOR);
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOutput(java.lang.String)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOutputExtension(java.lang.String)
*/
public String getOutputExtension(String inputExtension) {
// Examine the list of input extensions
ListIterator iter = getInputExtensions().listIterator();
+ int i = 0;
while (iter.hasNext()) {
if (((String)iter.next()).equals(inputExtension)) {
- return outputExtensions;
+ String[] exts = getOutputExtensions();
+ if (exts != null) {
+ if (i < exts.length) {
+ return exts[i];
+ } else {
+ return exts[exts.length - 1];
+ }
+ }
}
+ i++;
}
return null;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ String currentIds = getErrorParserIds();
+ if (ids == null && currentIds == null) return;
+ if (currentIds == null || ids == null || !(currentIds.equals(ids))) {
+ errorParserIds = ids;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setToolCommand(java.lang.String)
+ */
+ public boolean setToolCommand(String cmd) {
+ if (cmd == null && command == null) return false;
+ if (cmd == null || command == null || !cmd.equals(command)) {
+ command = cmd;
+ isDirty = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setCommandLinePattern()
+ */
+ public void setCommandLinePattern(String pattern) {
+ if (pattern == null && commandLinePattern == null) return;
+ if (pattern == null || commandLinePattern == null || !pattern.equals(commandLinePattern)) {
+ commandLinePattern = pattern;
+ isDirty = true;
+ }
+ }
+
+ /* (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)
+ */
+ public void setOutputFlag(String flag) {
+ if (flag == null && outputFlag == null) return;
+ if (outputFlag == null || flag == null || !(flag.equals(outputFlag))) {
+ outputFlag = flag;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputPrefix(java.lang.String)
+ */
+ public void setOutputPrefix(String prefix) {
+ if (prefix == null && outputPrefix == null) return;
+ if (outputPrefix == null || prefix == null || !(prefix.equals(outputPrefix))) {
+ outputPrefix = prefix;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputExtensions(java.lang.String)
+ */
+ public void setOutputExtensions(String ext) {
+ if (ext == null && outputExtensions == null) return;
+ if (outputExtensions == null || ext == null || !(ext.equals(outputExtensions))) {
+ outputExtensions = ext;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getCommandFlags()
+ */
+ public String[] getCommandFlags() throws BuildException {
+ IOption[] opts = getOptions();
+ ArrayList flags = new ArrayList();
+ StringBuffer sb = new StringBuffer();
+ for (int index = 0; index < opts.length; index++) {
+ IOption option = opts[index];
+ sb.setLength( 0 );
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ String boolCmd;
+ if (option.getBooleanValue()) {
+ boolCmd = option.getCommand();
+ } else {
+ // Note: getCommandFalse is new with CDT 2.0
+ boolCmd = option.getCommandFalse();
+ }
+ if (boolCmd != null && boolCmd.length() > 0) {
+ sb.append(boolCmd);
+ }
+ break;
+
+ case IOption.ENUMERATED :
+ String enum = option.getEnumCommand(option.getSelectedEnum());
+ if (enum.length() > 0) {
+ sb.append(enum);
+ }
+ break;
+
+ case IOption.STRING :
+ String strCmd = option.getCommand();
+ String val = option.getStringValue();
+ if (val.length() > 0) {
+ sb.append( evaluateCommand( strCmd, val ) );
+ }
+ break;
+
+ case IOption.STRING_LIST :
+ String listCmd = option.getCommand();
+ String[] list = option.getStringListValue();
+ for (int j = 0; j < list.length; j++) {
+ String temp = list[j];
+ sb.append( evaluateCommand( listCmd, temp ) + WHITE_SPACE );
+ }
+ break;
+
+ case IOption.INCLUDE_PATH :
+ String incCmd = option.getCommand();
+ String[] paths = option.getIncludePaths();
+ for (int j = 0; j < paths.length; j++) {
+ String temp = paths[j];
+ sb.append( evaluateCommand( incCmd, temp ) + WHITE_SPACE);
+ }
+ break;
+
+ case IOption.PREPROCESSOR_SYMBOLS :
+ String defCmd = option.getCommand();
+ String[] symbols = option.getDefinedSymbols();
+ for (int j = 0; j < symbols.length; j++) {
+ String temp = symbols[j];
+ sb.append( evaluateCommand( defCmd, temp ) + WHITE_SPACE);
+ }
+ break;
+
+ default :
+ break;
+ }
+ if( sb.toString().trim().length() > 0 ) flags.add( sb.toString().trim() );
+ }
+ String[] f = new String[ flags.size() ];
+ return (String[])flags.toArray( f );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getToolFlags()
+ */
+ public String getToolFlags() throws BuildException {
+ // Get all of the optionList
+ StringBuffer buf = new StringBuffer();
+ String[] flags = getCommandFlags();
+ for (int index = 0; index < flags.length; index++) {
+ if( flags[ index ] != null ) {
+ buf.append( flags[ index ] + WHITE_SPACE );
+ }
+ }
+
+ return buf.toString().trim();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#isHeaderFile(java.lang.String)
*/
@@ -401,104 +1307,94 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
return getInterfaceExtensions().contains(ext);
}
-
+
/* (non-Javadoc)
- * Load the tool information from the XML element specified in the
- * argument
- * @param element An XML element containing the tool information
+ * @see org.eclipse.cdt.core.build.managed.ITool#buildsFileType(java.lang.String)
*/
- protected void loadFromManifest(IManagedConfigElement element) {
- // setup for resolving
- ManagedBuildManager.putConfigElement(this, element);
- this.resolved = false;
-
- // id
- setId(element.getAttribute(ITool.ID));
-
- // name
- setName(element.getAttribute(ITool.NAME));
-
- // Get the nature filter
- String nature = element.getAttribute(NATURE);
- if (nature == null || "both".equals(nature)) { //$NON-NLS-1$
- natureFilter = FILTER_BOTH;
- } else if ("cnature".equals(nature)) { //$NON-NLS-1$
- natureFilter = FILTER_C;
- } else if ("ccnature".equals(nature)) { //$NON-NLS-1$
- natureFilter = FILTER_CC;
- } else {
- natureFilter = FILTER_BOTH;
+ public boolean buildsFileType(String extension) {
+ if (extension == null) {
+ return false;
}
-
- // Get the supported input file extension
- String inputs = element.getAttribute(ITool.SOURCES) == null ?
- new String() :
- element.getAttribute(ITool.SOURCES);
- StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensions().add(tokenizer.nextElement());
- }
-
- // Get the interface (header file) extensions
- String headers = element.getAttribute(INTERFACE_EXTS);
- if (headers == null) {
- headers = new String();
- }
- tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInterfaceExtensions().add(tokenizer.nextElement());
- }
-
- // Get the output extension
- outputExtensions = element.getAttribute(ITool.OUTPUTS) == null ?
- new String() :
- element.getAttribute(ITool.OUTPUTS);
-
- // Get the tool invocation
- command = element.getAttribute(ITool.COMMAND) == null ?
- new String() :
- element.getAttribute(ITool.COMMAND);
-
- // Get the flag to control output
- outputFlag = element.getAttribute(ITool.OUTPUT_FLAG) == null ?
- new String() :
- element.getAttribute(ITool.OUTPUT_FLAG);
-
- // Get the output prefix
- outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX) == null ?
- new String() :
- element.getAttribute(ITool.OUTPUT_PREFIX);
-
- // set up the category map
- addOptionCategory(this);
-
- // Check for optionList
- IManagedConfigElement[] toolElements = element.getChildren();
- for (int l = 0; l < toolElements.length; ++l) {
- IManagedConfigElement toolElement = toolElements[l];
- if (toolElement.getName().equals(ITool.OPTION)) {
- new Option(this, toolElement);
- } else if (toolElement.getName().equals(ITool.OPTION_CAT)) {
- new OptionCategory(this, toolElement);
- }
- }
-
+ return getInputExtensions().contains(extension);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#producesFileType(java.lang.String)
*/
public boolean producesFileType(String outputExtension) {
- return this.outputExtensions.equals(outputExtension);
+ String[] exts = getOutputExtensions();
+ if (exts != null) {
+ for (int i = 0; i < exts.length; i++) {
+ if (exts[i].equals(outputExtension))
+ return true;
+ }
+ }
+ return false;
}
- /**
- *
+/*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionTool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension tool
+ if (isExtensionTool) return false;
+
+ // If I need saving, just say yes
+ if (isDirty) return true;
+
+ // Otherwise see if any options need saving
+ List optionElements = getOptionList();
+ Iterator iter = optionElements.listIterator();
+ while (iter.hasNext()) {
+ Option option = (Option) iter.next();
+ if (option.isDirty()) return true;
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ // Propagate "false" to the children
+ if (!isDirty) {
+ List optionElements = getOptionList();
+ Iterator iter = optionElements.listIterator();
+ while (iter.hasNext()) {
+ Option option = (Option) iter.next();
+ option.setDirty(false);
+ }
+
+ }
+ }
+
+ /* (non-Javadoc)
+ * Resolve the element IDs to interface references
*/
public void resolveReferences() {
if (!resolved) {
resolved = true;
- // Tool doesn't have any references, but children might
+ // Resolve superClass
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionTool(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+ // Call resolveReferences on our children
Iterator optionIter = getOptionList().iterator();
while (optionIter.hasNext()) {
Option current = (Option)optionIter.next();
@@ -517,4 +1413,10 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
}
}
+
+ private String evaluateCommand( String command, String values ) {
+ if( command == null ) return values.trim();
+ if( command.indexOf( "$(" ) > 0 ) return command.replaceAll( "\\$\\([value|Value|VALUE]\\)", values.trim() ).trim(); //$NON-NLS-1$ //$NON-NLS-2$
+ else return (new String(command + values)).trim();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
new file mode 100644
index 00000000000..9471a158ee3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
@@ -0,0 +1,960 @@
+/**********************************************************************
+ * 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.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ToolChain extends BuildObject implements IToolChain {
+
+ private static final String EMPTY_STRING = new String();
+
+ // Superclass
+ private IToolChain superClass;
+ private String superClassId;
+ // Parent and children
+ private IConfiguration parent;
+ private List toolList;
+ private Map toolMap;
+ private TargetPlatform targetPlatform;
+ private Builder builder;
+ // Managed Build model attributes
+ private String unusedChildren;
+ private String errorParserIds;
+ private List osList;
+ private List archList;
+ private Boolean isAbstract;
+ private IConfigurationElement scannerInfoCollectorElement;
+ // Miscellaneous
+ private boolean isExtensionToolChain = false;
+ private boolean isDirty = false;
+ private boolean resolved = true;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * This constructor is called to create a tool-chain defined by an extension point in
+ * a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The IConfiguration parent of this tool-chain, or null
if
+ * defined at the top level
+ * @param element The tool-chain definition from the manifest file or a dynamic element
+ * provider
+ */
+ public ToolChain(IConfiguration parent, IManagedConfigElement element) {
+ this.parent = parent;
+ isExtensionToolChain = true;
+
+ // setup for resolving
+ resolved = false;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionToolChain(this);
+
+ // Load the TargetPlatform child
+ IManagedConfigElement[] targetPlatforms =
+ element.getChildren(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
+ if (targetPlatforms.length < 1 || targetPlatforms.length > 1) {
+ // TODO: Report error
+ }
+ if (targetPlatforms.length > 0) {
+ targetPlatform = new TargetPlatform(this, targetPlatforms[0]);
+ }
+
+ // Load the Builder child
+ IManagedConfigElement[] builders =
+ element.getChildren(IBuilder.BUILDER_ELEMENT_NAME);
+ if (builders.length < 1 || builders.length > 1) {
+ // TODO: Report error
+ }
+ if (builders.length > 0) {
+ builder = new Builder(this, builders[0]);
+ }
+
+ // Load the tool children
+ 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);
+ }
+ }
+
+ /**
+ * This constructor is called to create a ToolChain whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param Configuration The parent of the tool chain, if any
+ * @param ToolChain The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public ToolChain(Configuration parent, IToolChain superClass, String Id, String name, boolean isExtensionElement) {
+ this.parent = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionToolChain = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionToolChain(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create a ToolChain
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The IConfiguration
the tool-chain will be added to.
+ * @param element The XML element that contains the tool-chain settings.
+ */
+ public ToolChain(IConfiguration parent, Element element) {
+ this.parent = parent;
+ isExtensionToolChain = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Load children
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(ITool.TOOL_ELEMENT_NAME)) {
+ Tool tool = new Tool(this, (Element)configElement);
+ addTool(tool);
+ }else if (configElement.getNodeName().equals(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME)) {
+ if (targetPlatform != null) {
+ // TODO: report error
+ }
+ targetPlatform = new TargetPlatform(this, (Element)configElement);
+ }else if (configElement.getNodeName().equals(IBuilder.BUILDER_ELEMENT_NAME)) {
+ if (builder != null) {
+ // TODO: report error
+ }
+ builder = new Builder(this, (Element)configElement);
+ }
+ }
+ }
+
+ /**
+ * Create a ToolChain
based upon an existing tool chain.
+ *
+ * @param parent The IConfiguration
the tool-chain will be added to.
+ * @param toolChain The existing tool-chain to clone.
+ */
+ public ToolChain(IConfiguration parent, String Id, String name, ToolChain toolChain) {
+ this.parent = parent;
+ superClass = toolChain.superClass;
+ if (superClass != null) {
+ if (toolChain.superClassId != null) {
+ superClassId = new String(toolChain.superClassId);
+ }
+ }
+ setId(Id);
+ setName(name);
+ isExtensionToolChain = false;
+
+ // Copy the remaining attributes
+ if (toolChain.unusedChildren != null) {
+ unusedChildren = new String(toolChain.unusedChildren);
+ }
+ if (toolChain.errorParserIds != null) {
+ errorParserIds = new String(toolChain.errorParserIds);
+ }
+ if (toolChain.osList != null) {
+ osList = new ArrayList(toolChain.osList);
+ }
+ if (toolChain.archList != null) {
+ archList = new ArrayList(toolChain.archList);
+ }
+ if (toolChain.isAbstract != null) {
+ isAbstract = new Boolean(toolChain.isAbstract.booleanValue());
+ }
+ scannerInfoCollectorElement = toolChain.scannerInfoCollectorElement;
+
+ // Clone the children
+ if (toolChain.builder != null) {
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (toolChain.builder.getSuperClass() != null) {
+ subId = toolChain.builder.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChain.builder.getSuperClass().getName();
+ } else {
+ subId = toolChain.builder.getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChain.builder.getName();
+ }
+ builder = new Builder(this, subId, subName, toolChain.builder);
+ }
+ if (toolChain.targetPlatform != null) {
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (toolChain.targetPlatform.getSuperClass() != null) {
+ subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChain.targetPlatform.getSuperClass().getName();
+ } else {
+ subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChain.targetPlatform.getName();
+ }
+ targetPlatform = new TargetPlatform(this, subId, subName, toolChain.targetPlatform);
+ }
+ if (toolChain.toolList != null) {
+ Iterator iter = toolChain.getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool toolChild = (Tool) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (toolChild.getSuperClass() != null) {
+ subId = toolChild.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChild.getSuperClass().getName();
+ } else {
+ subId = toolChild.getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChild.getName();
+ }
+ Tool newTool = new Tool(this, null, subId, subName, toolChild);
+ addTool(newTool);
+ }
+ }
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the tool-chain information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the tool-chain information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+
+ // Store the configuration element IFF there is a scanner info collector defined
+ String scannerInfoCollector = element.getAttribute(SCANNER_INFO_ID);
+ if (scannerInfoCollector != null && element instanceof DefaultManagedConfigElement) {
+ scannerInfoCollectorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+
+ // Get the comma-separated list of valid OS
+ String os = element.getAttribute(OS_LIST);
+ if (os != null) {
+ osList = new ArrayList();
+ String[] osTokens = os.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osTokens.length; ++i) {
+ osList.add(osTokens[i].trim());
+ }
+ }
+
+ // Get the comma-separated list of valid Architectures
+ String arch = element.getAttribute(ARCH_LIST);
+ if (arch != null) {
+ archList = new ArrayList();
+ String[] archTokens = arch.split(","); //$NON-NLS-1$
+ for (int j = 0; j < archTokens.length; ++j) {
+ archList.add(archTokens[j].trim());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Initialize the tool-chain information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the tool-chain information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionToolChain(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+ }
+
+ // Get the comma-separated list of valid OS
+ if (element.hasAttribute(OS_LIST)) {
+ String os = element.getAttribute(OS_LIST);
+ if (os != null) {
+ osList = new ArrayList();
+ String[] osTokens = os.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osTokens.length; ++i) {
+ osList.add(osTokens[i].trim());
+ }
+ }
+ }
+
+ // Get the comma-separated list of valid Architectures
+ if (element.hasAttribute(ARCH_LIST)) {
+ String arch = element.getAttribute(ARCH_LIST);
+ if (arch != null) {
+ archList = new ArrayList();
+ String[] archTokens = arch.split(","); //$NON-NLS-1$
+ for (int j = 0; j < archTokens.length; ++j) {
+ archList.add(archTokens[j].trim());
+ }
+ }
+ }
+ }
+
+ /**
+ * Persist the tool-chain to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ if (errorParserIds != null) {
+ element.setAttribute(ERROR_PARSERS, errorParserIds);
+ }
+
+ if (osList != null) {
+ Iterator osIter = osList.listIterator();
+ String listValue = EMPTY_STRING;
+ while (osIter.hasNext()) {
+ String current = (String) osIter.next();
+ listValue += current;
+ if ((osIter.hasNext())) {
+ listValue += ","; //$NON-NLS-1$
+ }
+ }
+ element.setAttribute(OS_LIST, listValue);
+ }
+
+ if (archList != null) {
+ Iterator archIter = archList.listIterator();
+ String listValue = EMPTY_STRING;
+ while (archIter.hasNext()) {
+ String current = (String) archIter.next();
+ listValue += current;
+ if ((archIter.hasNext())) {
+ listValue += ","; //$NON-NLS-1$
+ }
+ }
+ element.setAttribute(ARCH_LIST, listValue);
+ }
+
+ // Serialize my children
+ if (targetPlatform != null) {
+ Element targetPlatformElement = doc.createElement(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
+ element.appendChild(targetPlatformElement);
+ targetPlatform.serialize(doc, targetPlatformElement);
+ }
+ if (builder != null) {
+ Element builderElement = doc.createElement(IBuilder.BUILDER_ELEMENT_NAME);
+ element.appendChild(builderElement);
+ builder.serialize(doc, builderElement);
+ }
+ List toolElements = getToolList();
+ Iterator iter = toolElements.listIterator();
+ while (iter.hasNext()) {
+ Tool tool = (Tool) iter.next();
+ Element toolElement = doc.createElement(ITool.TOOL_ELEMENT_NAME);
+ element.appendChild(toolElement);
+ tool.serialize(doc, toolElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getConfiguration()
+ */
+ public IConfiguration getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#createTargetPlatform(ITargetPlatform, String, String, boolean)
+ */
+ public ITargetPlatform createTargetPlatform(ITargetPlatform superClass, String id, String name, boolean isExtensionElement) {
+ targetPlatform = new TargetPlatform(this, superClass, id, name, isExtensionElement);
+ setDirty(true);
+ return (ITargetPlatform)targetPlatform;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getTargetPlatform()
+ */
+ public ITargetPlatform getTargetPlatform() {
+ if (targetPlatform == null) {
+ if (superClass != null) {
+ return superClass.getTargetPlatform();
+ }
+ }
+ return (ITargetPlatform)targetPlatform;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalTargetPlatform()
+ */
+ public void removeLocalTargetPlatform() {
+ if (targetPlatform == null) return;
+ targetPlatform = null;
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#createBuilder(IBuilder, String, String, boolean)
+ */
+ public IBuilder createBuilder(IBuilder superClass, String id, String name, boolean isExtensionElement) {
+ builder = new Builder(this, superClass, id, name, isExtensionElement);
+ setDirty(true);
+ return (IBuilder)builder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getBuilder()
+ */
+ public IBuilder getBuilder() {
+ if (builder == null) {
+ if (superClass != null) {
+ return superClass.getBuilder();
+ }
+ }
+ return (IBuilder)builder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalBuilder()
+ */
+ public void removeLocalBuilder() {
+ if (builder == null) return;
+ builder = null;
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#createTool(ITool, String, String, boolean)
+ */
+ public ITool createTool(ITool superClass, String id, String name, boolean isExtensionElement) {
+ Tool tool = new Tool(this, superClass, id, name, isExtensionElement);
+ addTool(tool);
+ setDirty(true);
+ return (ITool)tool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getTools()
+ */
+ public ITool[] getTools() {
+ ITool[] tools = null;
+ // Merge our tools with our superclass' tools
+ if (superClass != null) {
+ tools = superClass.getTools();
+ }
+ // Our tools take precedence
+ if (tools != null) {
+ Iterator iter = getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool tool = (Tool)iter.next();
+ int j;
+ for (j = 0; j < tools.length; j++) {
+ if (tool.getSuperClass().getId().equals(tools[j].getId())) {
+ tools[j] = tool;
+ break;
+ }
+ }
+ // No Match? Add it.
+ if (j == tools.length) {
+ ITool[] newTools = new ITool[tools.length + 1];
+ for (int k = 0; k < tools.length; k++) {
+ newTools[k] = tools[k];
+ }
+ newTools[j] = tool;
+ tools = newTools;
+ }
+ }
+ } else {
+ tools = new ITool[getToolList().size()];
+ Iterator iter = getToolList().listIterator();
+ int i = 0;
+ while (iter.hasNext()) {
+ Tool tool = (Tool)iter.next();
+ tools[i++] = (ITool)tool;
+ }
+ }
+ return tools;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTool(java.lang.String)
+ */
+ public ITool getTool(String id) {
+ Tool tool = (Tool)getToolMap().get(id);
+ return (ITool)tool;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the list of tools.
+ *
+ * @return List containing the tools
+ */
+ public List getToolList() {
+ if (toolList == null) {
+ toolList = new ArrayList();
+ }
+ return toolList;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of tool ids to tools
+ *
+ * @return
+ */
+ private Map getToolMap() {
+ if (toolMap == null) {
+ toolMap = new HashMap();
+ }
+ return toolMap;
+ }
+
+ /* (non-Javadoc)
+ * Adds the Tool to the Tool-chain list and map
+ *
+ * @param Tool
+ */
+ public void addTool(Tool tool) {
+ getToolList().add(tool);
+ getToolMap().put(tool.getId(), tool);
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSuperClass()
+ */
+ public IToolChain getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getName()
+ */
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#isAbstract()
+ */
+ public boolean isAbstract() {
+ if (isAbstract != null) {
+ return isAbstract.booleanValue();
+ } else {
+ return false; // Note: no inheritance from superClass
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getUnusedChildren()
+ */
+ public String getUnusedChildren() {
+ if (unusedChildren != null) {
+ return unusedChildren;
+ } else
+ return EMPTY_STRING; // Note: no inheritance from superClass
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ String ids = errorParserIds;
+ if (ids == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ ids = superClass.getErrorParserIds();
+ }
+ }
+ if (ids == null) {
+ // Collect the error parsers from my children
+ ids = builder.getErrorParserIds();
+ ITool[] tools = getTools();
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ String toolIds = tool.getErrorParserIds();
+ if (toolIds != null && toolIds.length() > 0) {
+ if (ids != null) {
+ ids += ";"; //$NON-NLS-1$
+ ids += toolIds;
+ } else {
+ ids = toolIds;
+ }
+ }
+ }
+ }
+ return ids;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds(IConfiguration)
+ */
+ public String getErrorParserIds(IConfiguration config) {
+ String ids = errorParserIds;
+ if (ids == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ ids = superClass.getErrorParserIds(config);
+ }
+ }
+ if (ids == null) {
+ // Collect the error parsers from my children
+ if (builder != null) {
+ ids = builder.getErrorParserIds();
+ }
+ ITool[] tools = config.getFilteredTools();
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ String toolIds = tool.getErrorParserIds();
+ if (toolIds != null && toolIds.length() > 0) {
+ if (ids != null) {
+ ids += ";"; //$NON-NLS-1$
+ ids += toolIds;
+ } else {
+ ids = toolIds;
+ }
+ }
+ }
+ }
+ return ids;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ String parserIDs = getErrorParserIds();
+ String[] errorParsers;
+ if (parserIDs != null) {
+ // Check for an empty string
+ if (parserIDs.length() == 0) {
+ errorParsers = new String[0];
+ } else {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ List list = new ArrayList(tok.countTokens());
+ while (tok.hasMoreElements()) {
+ list.add(tok.nextToken());
+ }
+ String[] strArr = {""}; //$NON-NLS-1$
+ errorParsers = (String[]) list.toArray(strArr);
+ }
+ } else {
+ errorParsers = new String[0];
+ }
+ return errorParsers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getArchList()
+ */
+ public String[] getArchList() {
+ if (archList == null) {
+ // Ask superClass for its list
+ if (superClass != null) {
+ return superClass.getArchList();
+ } else {
+ // I have no superClass and no defined list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) archList.toArray(new String[archList.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getOSList()
+ */
+ public String[] getOSList() {
+ if (osList == null) {
+ // Ask superClass for its list
+ if (superClass != null) {
+ return superClass.getOSList();
+ } else {
+ // I have no superClass and no defined filter list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) osList.toArray(new String[osList.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setIsAbstract(boolean)
+ */
+ public void setIsAbstract(boolean b) {
+ isAbstract = new Boolean(b);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setErrorParserIds(String)
+ */
+ public void setErrorParserIds(String ids) {
+ String currentIds = getErrorParserIds();
+ if (ids == null && currentIds == null) return;
+ if (currentIds == null || ids == null || !(currentIds.equals(ids))) {
+ errorParserIds = ids;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setOSList(String[])
+ */
+ public void setOSList(String[] OSs) {
+ if (osList == null) {
+ osList = new ArrayList();
+ } else {
+ osList.clear();
+ }
+ for (int i = 0; i < OSs.length; i++) {
+ osList.add(OSs[i]);
+ }
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setArchList(String[])
+ */
+ public void setArchList(String[] archs) {
+ if (archList == null) {
+ archList = new ArrayList();
+ } else {
+ archList.clear();
+ }
+ for (int i = 0; i < archs.length; i++) {
+ archList.add(archs[i]);
+ }
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getScannerInfoCollectorElement()
+ */
+ public IConfigurationElement getScannerInfoCollectorElement() {
+ if (scannerInfoCollectorElement == null) {
+ if (superClass != null) {
+ return superClass.getScannerInfoCollectorElement();
+ }
+ }
+ return scannerInfoCollectorElement;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setScannerInfoCollectorElement(IConfigurationElement)
+ */
+ public void setScannerInfoCollectorElement(IConfigurationElement element) {
+ scannerInfoCollectorElement = element;
+ setDirty(true);
+ }
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionToolChain;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension tool-chain
+ if (isExtensionToolChain) return false;
+
+ // If I need saving, just say yes
+ if (isDirty) return true;
+
+ // Otherwise see if any tools need saving
+ Iterator iter = getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool toolChild = (Tool) iter.next();
+ if (toolChild.isDirty()) return true;
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ // Propagate "false" to the children
+ if (!isDirty) {
+ Iterator iter = getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool toolChild = (Tool) iter.next();
+ toolChild.setDirty(false);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Resolve the element IDs to interface references
+ */
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ // Resolve superClass
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionToolChain(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+ // Call resolveReferences on our children
+ if (targetPlatform != null) {
+ targetPlatform.resolveReferences();
+ }
+ if (builder != null) {
+ builder.resolveReferences();
+ }
+ Iterator iter = getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool toolChild = (Tool) iter.next();
+ toolChild.resolveReferences();
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Normalize the list of output extensions,for all tools in the toolchain by populating the list
+ * with an empty string for those tools which have no explicit output extension (as defined in the
+ * manifest file. In a post 2.1 manifest, all tools must have a specifed output extension, even
+ * if it is "")
+ */
+ public void normalizeOutputExtensions(){
+ ITool[] tools = getTools();
+ if (tools != null) {
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ String[] extensions = tool.getOutputExtensions();
+ if (extensions == null) {
+ tool.setOutputExtensions(""); //$NON-NLS-1$
+ continue;
+ }
+ if (extensions.length == 0){
+ tool.setOutputExtensions(""); //$NON-NLS-1$
+ continue;
+ }
+ }
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
index f72f61ede10..899fb263187 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
@@ -17,13 +17,14 @@ import java.util.List;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
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.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -46,23 +47,23 @@ public class ToolReference implements IToolReference {
* Create a new tool reference based on information contained in
* a project file.
*
- * @param owner The Configuration
the receiver will be added to.
+ * @param owner The ConfigurationV2
the receiver will be added to.
* @param element The element defined in the project file containing build information
* for the receiver.
*/
public ToolReference(BuildObject owner, Element element) {
this.owner = owner;
- if (owner instanceof Configuration) {
+ if (owner instanceof ConfigurationV2) {
if (parent == null) {
- Target parentTarget = (Target) ((Configuration)owner).getTarget();
+ Target parentTarget = (Target) ((ConfigurationV2)owner).getTarget();
try {
parent = ((Target)parentTarget.getParent()).getTool(element.getAttribute(ID));
} catch (NullPointerException e) {
parent = null;
}
}
- ((Configuration)owner).addToolReference(this);
+ ((ConfigurationV2)owner).addToolReference(this);
} else if (owner instanceof Target) {
if (parent == null) {
try {
@@ -115,8 +116,8 @@ public class ToolReference implements IToolReference {
this.owner = owner;
// hook me up
- if (owner instanceof Configuration) {
- ((Configuration)owner).addToolReference(this);
+ if (owner instanceof ConfigurationV2) {
+ ((ConfigurationV2)owner).addToolReference(this);
} else if (owner instanceof Target) {
((Target)owner).addToolReference(this);
}
@@ -201,8 +202,8 @@ public class ToolReference implements IToolReference {
}
}
- if (owner instanceof Configuration) {
- ((Configuration)owner).addToolReference(this);
+ if (owner instanceof ConfigurationV2) {
+ ((ConfigurationV2)owner).addToolReference(this);
} else if (owner instanceof Target) {
((Target)owner).addToolReference(this);
}
@@ -234,8 +235,8 @@ public class ToolReference implements IToolReference {
resolved = true;
IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
// resolve my parent
- if (owner instanceof Configuration) {
- Target target = (Target) ((Configuration)owner).getTarget();
+ if (owner instanceof ConfigurationV2) {
+ Target target = (Target) ((ConfigurationV2)owner).getTarget();
parent = target.getTool(element.getAttribute(ID));
} else if (owner instanceof Target) {
parent = ((Target)owner).getTool(element.getAttribute(ID));
@@ -300,8 +301,8 @@ public class ToolReference implements IToolReference {
*/
protected List getAllOptionRefs() {
// First get all the option references this tool reference contains
- if (owner instanceof Configuration) {
- return ((Configuration)owner).getOptionReferences(parent);
+ if (owner instanceof ConfigurationV2) {
+ return ((ConfigurationV2)owner).getOptionReferences(parent);
} else if (owner instanceof Target) {
return ((Target)owner).getOptionReferences(parent);
} else {
@@ -644,9 +645,9 @@ public class ToolReference implements IToolReference {
* @param config
* @return
*/
- public boolean ownedByConfiguration(IConfiguration config) {
- if (owner instanceof Configuration) {
- return ((IConfiguration)owner).equals(config);
+ public boolean ownedByConfiguration(IConfigurationV2 config) {
+ if (owner instanceof ConfigurationV2) {
+ return ((IConfigurationV2)owner).equals(config);
}
return false;
}
@@ -716,6 +717,39 @@ public class ToolReference implements IToolReference {
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputFlag(java.lang.String)
+ */
+ public void setOutputFlag(String flag) {
+ if (flag == null) return;
+ if (outputFlag == null || !(flag.equals(outputFlag))) {
+ outputFlag = flag;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputPrefix(java.lang.String)
+ */
+ public void setOutputPrefix(String prefix) {
+ if (prefix == null) return;
+ if (outputPrefix == null || !(prefix.equals(outputPrefix))) {
+ outputPrefix = prefix;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputExtensions(java.lang.String)
+ */
+ public void setOutputExtensions(String ext) {
+ if (ext == null) return;
+ if (outputExtensions == null || !(ext.equals(outputExtensions))) {
+ outputExtensions = ext;
+ isDirty = true;
+ }
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@@ -732,4 +766,169 @@ public class ToolReference implements IToolReference {
}
}
+ /*
+ * The following methods are here in order to implement the new ITool methods.
+ * They should never be called.
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getSuperClass()
+ */
+ public ITool getSuperClass() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#isAbstract()
+ */
+ public boolean isAbstract() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getUnusedChildren()
+ */
+ public String getUnusedChildren() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ }
+
+ public List getInterfaceExtensions() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return false;
+ }
+
+ /*
+ * The following methods are added to allow the converter from ToolReference -> Tool
+ * to retrieve the actual value of attributes. These routines do not go to the
+ * referenced Tool for a value if the ToolReference does not have a value.
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputExtensions()
+ */
+ public String getRawOutputExtensions() {
+ return outputExtensions;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputFlag()
+ */
+ public String getRawOutputFlag() {
+ return outputFlag;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputPrefix()
+ */
+ public String getRawOutputPrefix() {
+ return outputPrefix;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawToolCommand()
+ */
+ public String getRawToolCommand() {
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#createOption()
+ */
+ public IOption createOption(IOption superClass, String Id, String name, boolean b) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#removeOption()
+ */
+ public void removeOption(IOption o) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
+ */
+ public IOptionCategory[] getChildCategories() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setParent(IBuildObject)
+ */
+ public void setToolParent(IBuildObject newParent) {
+ if (parent == null) {
+ // bad reference
+ return;
+ }
+ // Set the parent in the parent of this ToolRefernce, the tool
+ ((Tool)parent).setToolParent(newParent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setIsAbstract(boolean)
+ */
+ public void setIsAbstract(boolean b) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getParent()
+ */
+ public IBuildObject getParent() {
+ return owner;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLinePattern()
+ */
+ public String getCommandLinePattern() {
+ if( parent == null ) return new String();
+ return parent.getCommandLinePattern();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLinePattern()
+ */
+ public void setCommandLinePattern(String pattern) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGenerator()
+ */
+ public IManagedCommandLineGenerator getCommandLineGenerator() {
+ if( parent == null ) return null;
+ return parent.getCommandLineGenerator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandFlags()
+ */
+ public String[] getCommandFlags() throws BuildException {
+ if( parent == null ) return null;
+ return parent.getCommandFlags();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
index ac1e3ff76e9..c7efc2d1f61 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
@@ -26,6 +26,7 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITarget;
@@ -126,7 +127,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
}
protected void calculateBuiltIns(ITarget defaultTarget, IConfiguration config) {
- ITool[] tools = config.getFilteredTools(info.getOwner().getProject());
+ ITool[] tools = config.getFilteredTools();
// Iterate over the list
for (int toolIndex = 0; toolIndex < tools.length; ++toolIndex) {
@@ -135,24 +136,26 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
IOption[] options = tool.getOptions();
for (int optIndex = 0; optIndex < options.length; ++optIndex) {
IOption option = options[optIndex];
- if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
- String[] builtIns = option.getBuiltIns();
- Map macroMap = new HashMap();
- for (int biIndex = 0; biIndex < builtIns.length; ++biIndex) {
- String symbol = builtIns[biIndex];
- String[] tokens = symbol.split("="); //$NON-NLS-1$
- String macro = tokens[0].trim();
- String value = (tokens.length > 1) ? tokens[1] : new String();
- macroMap.put(macro, value);
+ try {
+ if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) {
+ String[] builtIns = option.getBuiltIns();
+ Map macroMap = new HashMap();
+ for (int biIndex = 0; biIndex < builtIns.length; ++biIndex) {
+ String symbol = builtIns[biIndex];
+ String[] tokens = symbol.split("="); //$NON-NLS-1$
+ String macro = tokens[0].trim();
+ String value = (tokens.length > 1) ? tokens[1] : new String();
+ macroMap.put(macro, value);
+ }
+ addDefinedSymbols(macroMap);
+ } else if (option.getValueType() == IOption.INCLUDE_PATH) {
+ // Make sure it is a built-in, not a user-defined path
+ String[] values = option.getBuiltIns();
+ if (values.length > 0) {
+ addIncludePaths(Arrays.asList(values));
+ }
}
- addDefinedSymbols(macroMap);
- } else if (option.getValueType() == IOption.INCLUDE_PATH) {
- // Make sure it is a built-in, not a user-defined path
- String[] values = option.getBuiltIns();
- if (values.length > 0) {
- addIncludePaths(Arrays.asList(values));
- }
- }
+ } catch (BuildException e) {}
}
}
@@ -199,22 +202,15 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information is null"); //$NON-NLS-1$
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
}
- defaultTarget = info.getDefaultTarget();
- if (defaultTarget == null) {
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ if (defaultConfig == null) {
// The build information has not been loaded yet
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information has not been loaded yet"); //$NON-NLS-1$
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
}
- ITarget parent = defaultTarget.getParent();
- if (parent == null) {
- // The build information has not been loaded yet
- ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information has not been loaded yet"); //$NON-NLS-1$
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
-
+
// See if we can load a dynamic resolver
- String baseTargetId = parent.getId();
- IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
+ IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(defaultConfig);
if (collector != null) {
ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries collected dynamically"); //$NON-NLS-1$
collector.setProject(info.getOwner().getProject());
@@ -223,10 +219,9 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
addDefinedSymbols(collector.getDefinedSymbols());
} else {
// If none supplied, use the built-ins
- IConfiguration config = info.getDefaultConfiguration(defaultTarget);
- if (config != null) {
- calculateBuiltIns(defaultTarget, config);
- ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries set using built-in definitions from " + config.getName()); //$NON-NLS-1$
+ if (defaultConfig != null) {
+ calculateBuiltIns(defaultTarget, defaultConfig);
+ ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries set using built-in definitions from " + defaultConfig.getName()); //$NON-NLS-1$
} else {
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Configuration is null"); //$NON-NLS-1$
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
index ab2d934bfe9..9039080ff5b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.makegen.gnu;
-
/**********************************************************************
- * Copyright (c) 2003,2004 Rational Software Corporation and others.
+ * Copyright (c) 2003,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.makegen.gnu;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.makegen.gnu;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -27,9 +26,14 @@ import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.model.Util;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+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.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
@@ -343,19 +347,45 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
String projectLocation = project.getLocation().toString();
String resourcePath = null;
String buildRule = null;
+ String OptDotExt = ""; //$NON-NLS-1$
+ boolean isItLinked = false;
+
+ if (outputExtension != "") //$NON-NLS-1$
+ OptDotExt = DOT + outputExtension;
+
// figure out path to use to resource
if(!resourceLocation.toString().startsWith(projectLocation)) {
// it IS linked, so use the actual location
+ isItLinked = true;
resourcePath = resourceLocation.toString();
// Need a hardcoded rule, not a pattern rule, as a linked file
// can reside in any path
- buildRule = relativePath + resourceName + DOT + outputExtension + COLON + WHITESPACE + resourcePath;
+ buildRule = relativePath + resourceName + OptDotExt + COLON + WHITESPACE + resourcePath;
} else {
// use the relative path (not really needed to store per se but in the future someone may want this)
resourcePath = relativePath;
+
// The rule and command to add to the makefile
- buildRule = relativePath + WILDCARD + DOT + outputExtension + COLON + WHITESPACE + ROOT + SEPARATOR + resourcePath + WILDCARD + DOT + inputExtension;
+ buildRule = relativePath + WILDCARD + OptDotExt + COLON + WHITESPACE + ROOT + SEPARATOR + resourcePath + WILDCARD + DOT + inputExtension;
} // end fix for PR 70491
+
+ IConfiguration config = info.getSelectedConfiguration();
+
+ // For testing only
+/* if( config.getResourceConfigurations().length > 0) {
+ IResourceConfiguration[] resConfigs = config.getResourceConfigurations();
+ for (int i = 0; i < resConfigs.length; i++) {
+ System.out.println("Name :" + resConfigs[i].getName());
+ }
+ }
+*/
+
+// We need to check whether we have any resource specific build information.
+ IResourceConfiguration resConfig = null;
+ if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
+ if( resConfig != null) {
+ buildRule = resourcePath + resourceName + OptDotExt + COLON + WHITESPACE + "$(ROOT)/" + resourcePath + resourceName + DOT + inputExtension; //$NON-NLS-1$
+ }
// No duplicates in a makefile
if (getRuleList().contains(buildRule)) {
@@ -366,14 +396,58 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
buffer.append(buildRule + NEWLINE);
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_START_FILE + WHITESPACE + IN_MACRO + SINGLE_QUOTE + NEWLINE);
- buildFlags = info.getFlagsForSource(inputExtension);
- outflag = info.getOutputFlag(outputExtension);
- outputPrefix = info.getOutputPrefix(outputExtension);
-
- // The command to build
- String buildCmd = cmd + WHITESPACE + buildFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + OUT_MACRO + WHITESPACE + IN_MACRO;
- buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE);
- buffer.append(TAB + AT + buildCmd);
+
+ IManagedCommandLineInfo cmdLInfo = null;
+ String[] inputs = null;
+ if( resConfig != null) {
+ ITool[] tools = resConfig.getTools();
+ try {
+ buildFlags = tools[0].getToolFlags();
+ } catch (BuildException e) {
+ buildFlags = null;
+ }
+ outflag = tools[0].getOutputFlag();
+ outputPrefix = tools[0].getOutputPrefix();
+ cmd = tools[0].getToolCommand();
+// The command to build
+
+ String fileName;
+ String rootDir = "../"; //$NON-NLS-1$
+ if (isItLinked)
+ fileName = resourcePath;
+ else
+ fileName = rootDir + relativePath + resConfig.getName();
+
+ inputs = new String[1]; inputs[0] = fileName;
+ String[] flags = null;
+ try {
+ flags = tools[0].getCommandFlags();
+ } catch( BuildException ex ) {
+ // TODO add some routines to catch this
+ flags = null;
+ }
+ IManagedCommandLineGenerator cmdLGen = tools[0].getCommandLineGenerator();
+ cmdLInfo = cmdLGen.generateCommandLineInfo( tools[0], cmd, flags, outflag, outputPrefix,
+ resourcePath + resourceName + OptDotExt, inputs, tools[0].getCommandLinePattern() );
+
+ String buildCmd = cmdLInfo.getCommandLine();
+// String buildCmd = cmd + WHITESPACE + buildFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + resourceName + OptDotExt + WHITESPACE + fileName;
+ buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE);
+ buffer.append(TAB + AT + buildCmd);
+ } else {
+ buildFlags = info.getFlagsForSource(inputExtension);
+ outflag = info.getOutputFlag(outputExtension);
+ outputPrefix = info.getOutputPrefix(outputExtension);
+ String[] flags = buildFlags.split( "\\s" ); //$NON-NLS-1$
+ inputs = new String[1]; inputs[0] = IN_MACRO;
+ cmdLInfo = info.generateCommandLineInfo( inputExtension, flags, outflag, outputPrefix, OUT_MACRO, inputs );
+ // The command to build
+ String buildCmd = null;
+ if( cmdLInfo == null ) buildCmd = cmd + WHITESPACE + buildFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + OUT_MACRO + WHITESPACE + IN_MACRO;
+ else buildCmd = cmdLInfo.getCommandLine();
+ buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE);
+ buffer.append(TAB + AT + buildCmd);
+ }
// determine if there are any deps to calculate
if (doDepGen && depGen.getCalculatorType() == IManagedDependencyGenerator.TYPE_COMMAND) {
@@ -409,7 +483,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
HashMap extensionToRuleStringMap = new HashMap();
// get the set of output extensions for all tools
- Set outputExtensionsSet = getOutputExtentions();
+ Set outputExtensionsSet = getOutputExtensions();
// put in rules if the file type is not a generated file
Iterator iter = buildTools.iterator();
@@ -421,7 +495,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// create a macro of the form "EXTENSION_SRCS := "
String extensionName = exListIterator.next().toString();
if(!extensionToRuleStringMap.containsKey(extensionName) && // do we already have a map entry?
- !getOutputExtentions().contains(extensionName)) { // is the file generated?
+ !getOutputExtensions().contains(extensionName)) { // is the file generated?
// Get the name in the proper macro format
StringBuffer macroName = getMacroName(extensionName);
@@ -443,16 +517,27 @@ 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();
+ }
+ IResourceConfiguration resConfig;
+
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (resource.getType() == IResource.FILE) {
+ // Check whether this resource is excluded from build
+ resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
+ if( (resConfig != null) && (resConfig.isExcluded()) )
+ continue;
+
String ext = resource.getFileExtension();
if (info.buildsFileType(ext)) {
// look for the extension in the map
StringBuffer bufferForExtension = new StringBuffer();
bufferForExtension.append(extensionToRuleStringMap.get(ext).toString());
if(bufferForExtension != null &&
- !getOutputExtentions().contains(bufferForExtension.toString())) {
+ !getOutputExtensions().contains(bufferForExtension.toString())) {
bufferForExtension.append(resource.getName() + WHITESPACE + LINEBREAK);
@@ -520,8 +605,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
StringBuffer buffer = new StringBuffer();
// Assemble the information needed to generate the targets
- String cmd = info.getToolForTarget(extension);
- String flags = info.getFlagsForTarget(extension);
+ String cmd = info.getToolForConfiguration(extension);
+ String flags = info.getFlagsForConfiguration(extension);
String outflag = info.getOutputFlag(extension);
String outputPrefix = info.getOutputPrefix(extension);
String targets = rebuild ? "clean all" : "all"; //$NON-NLS-1$ //$NON-NLS-2$
@@ -807,7 +892,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
String fileName = getFileName(deletedFile);
String srcExtension = deletedFile.getFileExtension();
String targetExtension = info.getOutputExtension(srcExtension);
- fileName += DOT + targetExtension;
+ if (targetExtension != "") //$NON-NLS-1$
+ fileName += DOT + targetExtension;
IPath projectRelativePath = deletedFile.getProjectRelativePath().removeLastSegments(1);
IPath targetFilePath = getBuildWorkingDir().append(projectRelativePath).append(fileName);
IResource depFile = project.findMember(targetFilePath);
@@ -1127,7 +1213,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
*
* @return a Set
containing all of the output extensions
*/
- protected Set getOutputExtentions() {
+ protected Set getOutputExtensions() {
if (outputExtensionsSet == null) {
// The set of output extensions which will be produced by this tool.
// It is presumed that this set is not very large (likely < 10) so
@@ -1138,8 +1224,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// and add that to our list of output extensions.
Iterator iter = buildTools.iterator();
while(iter.hasNext()) {
- String[] outputs = ((ITool)iter.next()) .getOutputExtensions();
- outputExtensionsSet.addAll(Arrays.asList(outputs));
+ ITool tool = (ITool)iter.next();
+ String[] outputs = tool.getOutputExtensions();
+ if (outputs != null) {
+ outputExtensionsSet.addAll(Arrays.asList(outputs));
+ }
}
}
return outputExtensionsSet;
@@ -1190,7 +1279,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
extension = new String();
}
// Cache the build tools
- buildTools = new Vector(Arrays.asList(info.getDefaultTarget().getTools()));
+ buildTools = new Vector(Arrays.asList(info.getDefaultConfiguration().getFilteredTools()));
}
/* (non-Javadoc)
@@ -1424,7 +1513,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Add the libraries this project depends on
macroBuffer.append("LIBS := "); //$NON-NLS-1$
- String[] libs = info.getLibsForTarget(extension);
+ String[] libs = info.getLibsForConfiguration(extension);
for (int i = 0; i < libs.length; i++) {
String string = libs[i];
macroBuffer.append(LINEBREAK + string);
@@ -1433,7 +1522,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Add the extra user-specified objects
macroBuffer.append("USER_OBJS := "); //$NON-NLS-1$
- String[] userObjs = info.getUserObjectsForTarget(extension);
+ String[] userObjs = info.getUserObjectsForConfiguration(extension);
for (int j = 0; j < userObjs.length; j++) {
String string = userObjs[j];
macroBuffer.append(LINEBREAK + string);
@@ -1468,15 +1557,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// checked however.
// Generated files should not appear in the list.
- if(!getOutputExtentions().contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
+ if(!getOutputExtensions().contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
handledInputExtensions.add(extensionName);
StringBuffer macroName = getMacroName(extensionName);
-
+ String OptDotExt = ""; //$NON-NLS-1$
+ if (tool.getOutputExtension(extensionName) != "") //$NON-NLS-1$
+ OptDotExt = DOT + tool.getOutputExtension(extensionName);
+
// create dependency rule of the form
// OBJS = $(macroName1: $(ROOT)/%.input1=%.output1) ... $(macroNameN: $(ROOT)/%.inputN=%.outputN)
objectsBuffer.append(WHITESPACE + "$(" + macroName + COLON + "$(ROOT)" + SEPARATOR + WILDCARD //$NON-NLS-1$ //$NON-NLS-2$
- + DOT + extensionName + "=" + WILDCARD + DOT + //$NON-NLS-1$
- tool.getOutputExtension(extensionName) + ")" ); //$NON-NLS-1$
+ + DOT + extensionName + "=" + WILDCARD + OptDotExt + ")" ); //$NON-NLS-1$ //$NON-NLS-2$
// And another for the deps makefiles
// DEPS = $(macroName1: $(ROOT)/%.input1=%.DEP_EXT) ... $(macroNameN: $(ROOT)/%.inputN=%.DEP_EXT)
@@ -1512,7 +1603,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
while(exListIterator.hasNext()) {
// create a macro of the form "EXTENSION_SRCS :="
String extensionName = exListIterator.next().toString();
- if(!getOutputExtentions().contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
+ if(!getOutputExtensions().contains(extensionName) && !handledInputExtensions.contains(extensionName)) {
handledInputExtensions.add(extensionName);
StringBuffer macroName = getMacroName(extensionName);
buffer.append(macroName + WHITESPACE + ":=" + WHITESPACE + NEWLINE); //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/ConverterMessages.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/ConverterMessages.java
new file mode 100644
index 00000000000..75f851069c9
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/ConverterMessages.java
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * 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.managedbuilder.projectconverter;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class ConverterMessages {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.projectconverter.PluginResources";//$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private ConverterMessages() {
+ }
+/*
+ public static String getString(String key) {
+ // TODO Auto-generated method stub
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+*/
+ public static String getResourceString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (NullPointerException e) {
+ return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public static String getFormattedString(String key, String arg) {
+ return MessageFormat.format(getResourceString(key), new String[] { arg });
+ }
+
+ public static String getFormattedString(String key, String[] args) {
+ return MessageFormat.format(getResourceString(key), args);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/PluginResources.properties
new file mode 100644
index 00000000000..0956f33209a
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/PluginResources.properties
@@ -0,0 +1,42 @@
+#########################################
+# 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
+#########################################
+
+UpdateManagedProject20.0=Backing up the settings file for {0}
+UpdateManagedProject20.1=Updating build settings for project {0}
+UpdateManagedProject20.10=No configurations were found for project {0}
+UpdateManagedProject20.11=Build exception occured while creating managed project {0} : {1}
+UpdateManagedProject20.2=convertConfiguration: Configuration {0} was not found
+UpdateManagedProject20.3=convertToolRef: Tool ID attribute does not exist
+UpdateManagedProject20.4=convertToolRef: Toolchain does not contain tools
+UpdateManagedProject20.5=convertToolRef: Parent not found for tool {0}
+UpdateManagedProject20.6=convertOptionRef: option ID attribute does not exist
+UpdateManagedProject20.7=convertOptionRef: option {0} not found
+UpdateManagedProject20.8=convertOptionRef: BuildException occured: {0}
+UpdateManagedProject20.9=Project type {0} not found
+UpdateManagedProject12.0=Backing up the settings file for {0}
+UpdateManagedProject12.1=Updating build settings for project {0}
+UpdateManagedProject12.2=configuration {0} not found
+UpdateManagedProject12.3=Parent not found for option {0}
+UpdateManagedProject12.4=option {0} not found
+UpdateManagedProject12.5=convertOptionRef: BuildException occured: {0}
+UpdateManagedProject12.6=Project type {0} not found
+UpdateManagedProject12.7=No configurations were found for project {0}
+UpdateManagedProject12.8=Build exception occured while creating managed project {0} : {1}
+UpdateManagedProject12.9=Toolchain does not contain tools
+UpdateManagedProject12.10=Parent not found for tool {0}
+UpdateManagedProject12.11=tool {0} not found
+UpdateManagedProjectManager.0=Backup File Already Exists
+UpdateManagedProjectManager.1=A backup file {0} already exists for the project {1}.\n Do you want to convert the project anyway?
+UpdateManagedProjectManager.2=The update operation has been cancelled.\n The build system will not be able to read the project settings until you update the project.
+UpdateManagedProjectManager.3=Update Managed Builder Project
+UpdateManagedProjectManager.4=The project {0} build settings are stored in a format that is no longer supported (version {1}).\n\nWould you like to convert it to the newer version ({2})?\n\nNOTE: Converted projects can no longer be loaded by previous versions of the Managed Build System.\nIf you select "No", project settings will be available in readonly mode.
+UpdateManagedProjectManager.5=Managed project conversion FAILED: \n ManagedBuildManager version {0} is not equivalent to ManagedProject version {1} (project ID = {2})
+UpdateManagedProjectManager.6=the project .cdtbuild file does not exist
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java
similarity index 59%
rename from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java
rename to build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java
index 35b568bf141..242280b3045 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/actions/UpdateManagedProjectAction.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java
@@ -1,67 +1,48 @@
/**********************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * Intel Corporation - Initial API and implementation
**********************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.actions;
+package org.eclipse.cdt.managedbuilder.projectconverter;
-import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Random;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-/**
- * @since 2.0
- */
-public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegate {
+class UpdateManagedProject12 {
private static final String ID_CYGWIN = "cygwin"; //$NON-NLS-1$
@@ -104,44 +85,12 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
private static final int TYPE_SHARED = 1;
private static final int TYPE_STATIC = 2;
- /* (non-Javadoc)
- * Create a back-up file containing the pre-2.0 project settings.
- *
- * @param settingsFile
- * @param monitor
- * @param project
- * @throws CoreException
- */
- protected static void backupFile(IFile settingsFile, IProgressMonitor monitor, IProject project) throws CoreException {
- // Make a back-up of the settings file
- String newName = settingsFile.getName() + "_12backup"; //$NON-NLS-1$
- IContainer destFolder = (IContainer)project;
- IFile backupFile = destFolder.getFile(new Path(newName));
- if (backupFile.exists()) {
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- boolean shouldUpdate = MessageDialog.openQuestion(shell,
- ManagedBuilderUIMessages.getResourceString("ManagedBuildConvert.12x.warning.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("ManagedBuildConvert.12x.warning.message", project.getName())); //$NON-NLS-1$
- if (shouldUpdate) {
- backupFile.delete(true, monitor);
- } else {
- monitor.setCanceled(true);
- throw new OperationCanceledException(ManagedBuilderUIMessages.getFormattedString("ManagedBuildConvert.12x.cancelled.message", project.getName())); //$NON-NLS-1$
- }
- }
- settingsFile.copy(backupFile.getFullPath(), true, monitor);
- }
-
- protected static void convertConfiguration(ITarget newTarget, ITarget newParent, Element oldConfig, IProgressMonitor monitor) {
- IConfiguration newParentConfig = null;
- IConfiguration newConfig = null;
+ protected static String getNewConfigurationId(String oldId){
boolean cygwin = false;
boolean debug = false;
int type = -1;
- // Figure out what the original parent of the config is
- String parentId = oldConfig.getAttribute(IConfiguration.PARENT);
- StringTokenizer idTokens = new StringTokenizer(parentId, ID_SEPARATOR);
+ StringTokenizer idTokens = new StringTokenizer(oldId, ID_SEPARATOR);
while (idTokens.hasMoreTokens()) {
String id = idTokens.nextToken();
if (id.equalsIgnoreCase(ID_CYGWIN)) {
@@ -169,33 +118,71 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
defId += ID_STATIC;
break;
}
- defId += ID_SEPARATOR + (debug ? "debug" : "release"); //$NON-NLS-1$ //$NON-NLS-2$
- newParentConfig = newParent.getConfiguration(defId);
+ defId += ID_SEPARATOR + (debug ? "debug" : "release"); //$NON-NLS-1$ //$NON-NLS-2$
+ return defId;
+ }
+
+ protected static void convertConfiguration(IManagedProject newProject, IProjectType newParent, Element oldConfig, IProgressMonitor monitor)
+ throws CoreException {
+ IConfiguration newParentConfig = null;
+ IConfiguration newConfig = null;
+
+
+ // Figure out what the original parent of the config is
+ String parentId = oldConfig.getAttribute(IConfigurationV2.PARENT);
+ parentId = getNewConfigurationId(parentId);
+
+ newParentConfig = newParent.getConfiguration(parentId);
if (newParentConfig == null) {
- // Create a default gnu exe release or debug
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.2",parentId), null)); //$NON-NLS-1$
}
+
// Generate a random number for the new config id
- Random rand = new Random();
- rand.setSeed(System.currentTimeMillis());
- int randomElement = rand.nextInt();
- if (randomElement < 0) {
- randomElement *= -1;
- }
+ int randomElement = ManagedBuildManager.getRandomNumber();
+ String newConfigId = parentId + ID_SEPARATOR + randomElement;
// Create the new configuration
- newConfig = newTarget.createConfiguration(newParentConfig, defId + ID_SEPARATOR + randomElement);
+ newConfig = newProject.createConfiguration(newParentConfig, newConfigId);
+
+ Element oldTarget = (Element)oldConfig.getParentNode();
+ if(oldTarget.hasAttribute(ITarget.ARTIFACT_NAME)){
+ String artName = oldTarget.getAttribute(ITarget.ARTIFACT_NAME);
+ String ext = newConfig.getArtifactExtension();
+ int extIndex = artName.lastIndexOf("."); //$NON-NLS-1$
+ try{
+ if(extIndex != -1){
+ String name_ext = artName.substring(extIndex+1);
+ if(!"".equals(name_ext) && name_ext.equalsIgnoreCase(ext)) //$NON-NLS-1$
+ artName = artName.substring(0,extIndex);
+ }
+ }
+ catch(IndexOutOfBoundsException e){
+
+ }
+ newConfig.setArtifactName(artName);
+
+// newConfig(oldTarget.getAttribute(ITarget.ARTIFACT_NAME));
+ }
// Convert the tool references
- NodeList toolRefNodes = oldConfig.getElementsByTagName(IConfiguration.TOOLREF_ELEMENT_NAME);
+ IToolChain toolChain = newConfig.getToolChain();
+
+ NodeList toolRefNodes = oldConfig.getElementsByTagName(IConfigurationV2.TOOLREF_ELEMENT_NAME);
for (int refIndex = 0; refIndex < toolRefNodes.getLength(); ++refIndex) {
- convertToolRef(newConfig, (Element) toolRefNodes.item(refIndex), monitor);
+ try{
+ convertToolRef(toolChain, (Element) toolRefNodes.item(refIndex), monitor);
+ }
+ catch(CoreException e){
+ newProject.removeConfiguration(newConfigId);
+ throw e;
+ }
}
monitor.worked(1);
}
- protected static void convertOptionRef(IConfiguration newConfig, ITool newTool, Element optRef) {
- String optId = optRef.getAttribute(IOption.ID);
- if (optId == null) return;
- String[] idTokens = optId.split("\\."); //$NON-NLS-1$
+ protected static String getNewOptionId(IToolChain toolChain, ITool tool, String oldId)
+ throws CoreException{
+ String[] idTokens = oldId.split("\\."); //$NON-NLS-1$
// New ID will be in for gnu.[compiler|link|lib].[c|c++|both].option.{1.2_component}
Vector newIdVector = new Vector(idTokens.length + 2);
@@ -262,26 +249,56 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
}
// Construct the new ID
- String newOptionId = new String();
+ String optId = new String();
for (int rebuildIndex = 0; rebuildIndex < newIdVector.size(); ++ rebuildIndex) {
String token = (String) newIdVector.get(rebuildIndex);
- newOptionId += token;
+ optId += token;
if (rebuildIndex < newIdVector.size() - 1) {
- newOptionId += ID_SEPARATOR;
+ optId += ID_SEPARATOR;
}
}
- // Get the option from the new tool
- IOption newOpt = newTool.getOptionById(newOptionId);
- if (newOpt == null) {
- // TODO flag warning condition to user
- return;
+ IConfiguration configuration = toolChain.getParent();
+
+ IOption options[] = tool.getOptions();
+ for(int i = 0; i < options.length; i++){
+ IOption curOption = options[i];
+ IOption parent = curOption.getSuperClass();
+ String curOptionId = curOption.getId();
+
+ if(parent == null)
+ continue;
+
+ String parentId = parent.getId();
+ if(!parentId.equals(optId))
+ continue;
+
+ return curOption.getId();
}
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.3",optId), null)); //$NON-NLS-1$
+ }
+
+ protected static void convertOptionRef(IToolChain toolChain, ITool tool, Element optRef)
+ throws CoreException {
+ String optId = optRef.getAttribute(IOption.ID);
+ if (optId == null) return;
+
+ optId = getNewOptionId(toolChain, tool, optId);
+ // Get the option from the new tool
+ IOption newOpt = tool.getOptionById(optId);
+ if (newOpt == null) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.4",optId), null)); //$NON-NLS-1$
+ }
+
+ IConfiguration configuration = toolChain.getParent();
+
try {
switch (newOpt.getValueType()) {
case IOption.BOOLEAN:
Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
- newConfig.setOption(newOpt, bool.booleanValue());
+ configuration.setOption(tool, newOpt, bool.booleanValue());
break;
case IOption.STRING:
case IOption.ENUMERATED:
@@ -289,7 +306,7 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
String name = (String) optRef.getAttribute(IOption.DEFAULT_VALUE);
// Convert it to the ID
String idValue = newOpt.getEnumeratedId(name);
- newConfig.setOption(newOpt, idValue != null ? idValue : name);
+ configuration.setOption(tool, newOpt, idValue != null ? idValue : name);
break;
case IOption.STRING_LIST:
case IOption.INCLUDE_PATH:
@@ -307,29 +324,23 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
}
}
}
- newConfig.setOption(newOpt, (String[])values.toArray(new String[values.size()]));
+ configuration.setOption(tool, newOpt, (String[])values.toArray(new String[values.size()]));
break;
}
} catch (BuildException e) {
- // TODO flag error to user
- return;
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.5",e.getMessage()), e)); //$NON-NLS-1$
}
}
- protected static ITarget convertTarget(IProject project, Element oldTarget, IProgressMonitor monitor) {
- // What we want to create
- ITarget newTarget = null;
- ITarget newParent = null;
+
+ protected static String getNewProjectId(String oldId){
// The type of target we are converting from/to
int type = -1;
// Use the Cygwin or generic target form
boolean posix = false;
-
- // Get the parent
- String id = oldTarget.getAttribute(ITarget.PARENT);
-
- // Figure out the new target definition to use for that type
- StringTokenizer idTokens = new StringTokenizer(id, ID_SEPARATOR);
+
+ StringTokenizer idTokens = new StringTokenizer(oldId, ID_SEPARATOR);
while (idTokens.hasMoreTokens()) {
String token = idTokens.nextToken();
if (token.equals(ID_LINUX) || token.equals(ID_SOLARIS)) {
@@ -354,42 +365,69 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
case TYPE_STATIC :
defID += ID_STATIC;
break;
- }
-
+ }
+ return defID;
+ }
+
+ protected static IManagedProject convertTarget(IProject project, Element oldTarget, IProgressMonitor monitor) throws CoreException{
+ // What we want to create
+ IManagedProject newProject = null;
+ IProjectType newParent = null;
+
+ // Get the parent
+ String id = oldTarget.getAttribute(ITarget.PARENT);
+ String parentID = getNewProjectId(id);
+
// Get the new target definitions we need for the conversion
- newParent = ManagedBuildManager.getTarget(project, defID);
+ newParent = ManagedBuildManager.getProjectType(parentID);
+
if (newParent == null) {
- // Return null and let the caller deal with the error reporting
- return null;
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.6",parentID), null)); //$NON-NLS-1$
}
try {
// Create a new target based on the new parent
- newTarget = ManagedBuildManager.createTarget(project, newParent);
- newTarget.setArtifactName(oldTarget.getAttribute(ITarget.ARTIFACT_NAME));
+ newProject = ManagedBuildManager.createManagedProject(project, newParent);
// Create new configurations
- NodeList configNodes = oldTarget.getElementsByTagName(IConfiguration.CONFIGURATION_ELEMENT_NAME);
+ NodeList configNodes = oldTarget.getElementsByTagName(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
for (int configIndex = 0; configIndex < configNodes.getLength(); ++configIndex) {
- convertConfiguration(newTarget, newParent, (Element) configNodes.item(configIndex), monitor);
+ try{
+ convertConfiguration(newProject, newParent, (Element) configNodes.item(configIndex), monitor);
+ }
+ catch(CoreException e){
+
+ }
+ }
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration[] newConfigs = newProject.getConfigurations();
+ if (newConfigs.length > 0) {
+ info.setDefaultConfiguration(newConfigs[0]);
+ info.setSelectedConfiguration(newConfigs[0]);
+ }
+ else{
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.7",newProject.getName()), null)); //$NON-NLS-1$
}
} catch (BuildException e) {
- // Probably just a mismatch between option value and option
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.8",new String[]{newProject.getName(),e.getMessage()}), null)); //$NON-NLS-1$
}
monitor.worked(1);
- return newTarget;
+ return newProject;
}
- protected static void convertToolRef(IConfiguration newConfig, Element oldToolRef, IProgressMonitor monitor) {
- String oldToolId = oldToolRef.getAttribute(IToolReference.ID);
+ protected static String getNewToolId(IToolChain toolChain, String oldId)
+ throws CoreException {
// All known tools have id NEW_TOOL_ROOT.[c|cpp].[compiler|linker|archiver]
- String newToolId = NEW_TOOL_ROOT;
+ String toolId = NEW_TOOL_ROOT;
boolean cppFlag = true;
int toolType = -1;
// Figure out what kind of tool the ref pointed to
- StringTokenizer idTokens = new StringTokenizer(oldToolId, ID_SEPARATOR);
+ StringTokenizer idTokens = new StringTokenizer(oldId, ID_SEPARATOR);
while (idTokens.hasMoreTokens()) {
String token = idTokens.nextToken();
if(token.equals(TOOL_LANG_C)) {
@@ -408,27 +446,76 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
}
// Now complete the new tool id
- newToolId += ID_SEPARATOR + (cppFlag ? "cpp" : "c") + ID_SEPARATOR; //$NON-NLS-1$ //$NON-NLS-2$
+ toolId += ID_SEPARATOR + (cppFlag ? "cpp" : "c") + ID_SEPARATOR; //$NON-NLS-1$ //$NON-NLS-2$
switch (toolType) {
case TOOL_TYPE_COMPILER:
- newToolId += TOOL_NAME_COMPILER;
+ toolId += TOOL_NAME_COMPILER;
break;
case TOOL_TYPE_LINKER:
- newToolId += TOOL_NAME_LINKER;
+ toolId += TOOL_NAME_LINKER;
break;
case TOOL_TYPE_ARCHIVER:
- newToolId += TOOL_NAME_ARCHIVER;
+ toolId += TOOL_NAME_ARCHIVER;
break;
}
+ IConfiguration configuration = toolChain.getParent();
+ ITool tools[] = configuration.getTools();
+ if(tools == null) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getResourceString("UpdateManagedProject12.9"), null)); //$NON-NLS-1$
+ }
+
+ for(int i = 0; i < tools.length; i++){
+ ITool curTool = tools[i];
+ ITool parent = curTool.getSuperClass();
+ String curToolId = curTool.getId();
+
+ if(parent == null)
+ continue;
+
+ parent = parent.getSuperClass();
+ if(parent == null)
+ continue;
+
+ String parentId = parent.getId();
+ if(!parentId.equals(toolId))
+ continue;
+
+ try{
+ Integer.decode(curToolId.substring(curToolId.lastIndexOf('.')+1)); //$NON-NLS-1$
+ }
+ catch(IndexOutOfBoundsException e){
+ continue;
+ }
+ catch(NumberFormatException e){
+ continue;
+ }
+ return curTool.getId();
+ }
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.10",toolId), null)); //$NON-NLS-1$
+ }
+
+ protected static void convertToolRef(IToolChain toolChain, Element oldToolRef, IProgressMonitor monitor)
+ throws CoreException {
+ String toolId = oldToolRef.getAttribute(IToolReference.ID);
+
+ toolId = getNewToolId(toolChain, toolId);
+
+ IConfiguration configuration = toolChain.getParent();
+
// Get the new tool out of the configuration
- ITool newTool = newConfig.getToolById(newToolId);
+ ITool newTool = configuration.getTool(toolId);
// Check that this is not null
+ if(newTool == null)
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject12.11",toolId), null)); //$NON-NLS-1$
// The ref may or may not contain overridden options
NodeList optRefs = oldToolRef.getElementsByTagName(ITool.OPTION_REF);
for (int refIndex = optRefs.getLength() - 1; refIndex >= 0; --refIndex) {
- convertOptionRef(newConfig, newTool, (Element) optRefs.item(refIndex));
+ convertOptionRef(toolChain, newTool, (Element) optRefs.item(refIndex));
}
monitor.worked(1);
}
@@ -438,7 +525,7 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
* @param project the IProject
that needs to be upgraded
* @throws CoreException
*/
- protected static void doProjectUpdate(IProgressMonitor monitor, IProject project) throws CoreException {
+ static void doProjectUpdate(IProgressMonitor monitor, IProject project) throws CoreException {
String[] projectName = new String[]{project.getName()};
IFile settingsFile = project.getFile(ManagedBuildManager.SETTINGS_FILE_NAME);
if (!settingsFile.exists()) {
@@ -447,10 +534,10 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
}
// Backup the file
- monitor.beginTask(ManagedBuilderUIMessages.getFormattedString("ManagedBuildConvert.12x.monitor.message.backup", projectName), 1); //$NON-NLS-1$
- backupFile(settingsFile, monitor, project);
+ monitor.beginTask(ConverterMessages.getFormattedString("UpdateManagedProject12.0", projectName), 1); //$NON-NLS-1$
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
-
+ UpdateManagedProjectManager.backupFile(settingsFile, "_12backup", monitor, project); ; //$NON-NLS-1$
+
//Now convert each target to the new format
try {
// Load the old build file
@@ -462,119 +549,29 @@ public class UpdateManagedProjectAction implements IWorkbenchWindowActionDelegat
NodeList targetNodes = document.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME);
// This is a guess, but typically the project has 1 target, 2 configs, and 6 tool defs
int listSize = targetNodes.getLength();
- monitor.beginTask(ManagedBuilderUIMessages.getFormattedString("ManagedBuildConvert.12x.monitor.message.project", projectName), listSize * 9); //$NON-NLS-1$
+ monitor.beginTask(ConverterMessages.getFormattedString("UpdateManagedProject12.1", projectName), listSize * 9); //$NON-NLS-1$
for (int targIndex = 0; targIndex < listSize; ++targIndex) {
Element oldTarget = (Element) targetNodes.item(targIndex);
String oldTargetId = oldTarget.getAttribute(ITarget.ID);
- ITarget newTarget = convertTarget(project, oldTarget, monitor);
+ IManagedProject newProject = convertTarget(project, oldTarget, monitor);
// Remove the old target
- if (newTarget != null) {
+ if (newProject != null) {
info.removeTarget(oldTargetId);
monitor.worked(9);
}
}
// Upgrade the version
((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString());
- } catch (ParserConfigurationException e) {
- ManagedBuilderUIPlugin.log(e);
- } catch (FactoryConfigurationError e) {
- ManagedBuilderUIPlugin.log(e);
- } catch (SAXException e) {
- ManagedBuilderUIPlugin.log(e);
- } catch (IOException e) {
- ManagedBuilderUIPlugin.log(e);
+ }catch (CoreException e){
+ throw e;
+ }catch (Exception e) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ e.getMessage(), e));
} finally {
ManagedBuildManager.saveBuildInfo(project, false);
monitor.done();
}
}
- /**
- * Determines which projects in the workspace are still using
- * the settings format defined in CDT 1.2.x.
- *
- * @return an array of IProject
that need to have their
- * project settings updated to the CDT 2.0 format
- */
- public static IProject[] getVersion12Projects() {
- IProject[] projects = ManagedBuilderUIPlugin.getWorkspace().getRoot().getProjects();
- Vector result = new Vector();
- for (int index = projects.length - 1; index >=0 ; --index) {
- if (projects[index].isAccessible()) {
- IProjectDescription description;
- try {
- description = projects[index].getDescription();
- } catch (CoreException e) {
- // This can only mean that something really bad has happened
- continue;
- }
- // Make sure it has a managed nature
- if (description == null || !description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
- continue;
- }
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[index]);
- if (info != null && info.getVersion()== null) {
- // This is a pre-2.0 file (no version info)
- result.add(projects[index]);
- }
- }
- }
-
- return (IProject[]) result.toArray(new IProject[result.size()]);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- // TODO Auto-generated method stub
-
- }
-
- static public void run(boolean fork, IRunnableContext context, final IProject project) {
- try {
- context.run(fork, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- doProjectUpdate(monitor, project);
- }
- };
- ManagedBuilderUIPlugin.getWorkspace().run(runnable, monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } catch (OperationCanceledException e) {
- throw new InterruptedException(e.getMessage());
- }
- }
- });
- } catch (InterruptedException e) {
- return;
- } catch (InvocationTargetException e) {
- CCorePlugin.log(e); //$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- // TODO Auto-generated method stub
-
- }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java
new file mode 100644
index 00000000000..e77227b51de
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java
@@ -0,0 +1,428 @@
+/**********************************************************************
+ * 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.managedbuilder.projectconverter;
+
+
+import java.io.InputStream;
+import java.util.Vector;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.IToolReference;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
+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.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+class UpdateManagedProject20 {
+ private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
+
+ /**
+ * @param monitor the monitor to allow users to cancel the long-running operation
+ * @param project the IProject
that needs to be upgraded
+ * @throws CoreException
+ */
+ static void doProjectUpdate(IProgressMonitor monitor, IProject project) throws CoreException {
+ String[] projectName = new String[]{project.getName()};
+ IFile settingsFile = project.getFile(ManagedBuildManager.SETTINGS_FILE_NAME);
+ if (!settingsFile.exists()) {
+ monitor.done();
+ return;
+ }
+
+ // Backup the file
+ monitor.beginTask(ConverterMessages.getFormattedString("UpdateManagedProject20.0", projectName), 1); //$NON-NLS-1$
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ UpdateManagedProjectManager.backupFile(settingsFile, "_20backup", monitor, project); //$NON-NLS-1$
+
+ try {
+ // Load the old build file
+ InputStream stream = settingsFile.getContents();
+ DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = parser.parse(stream);
+
+ // Clone the target based on the proper target definition
+ NodeList targetNodes = document.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME);
+ // This is a guess, but typically the project has 1 target, 2 configs, and 6 tool defs
+ int listSize = targetNodes.getLength();
+ monitor.beginTask(ConverterMessages.getFormattedString("UpdateManagedProject20.1", projectName), listSize * 9); //$NON-NLS-1$
+ for (int targIndex = 0; targIndex < listSize; ++targIndex) {
+ Element oldTarget = (Element) targetNodes.item(targIndex);
+ String oldTargetId = oldTarget.getAttribute(ITarget.ID);
+ IManagedProject newProject = convertTarget(project, oldTarget, monitor);
+
+ // Remove the old target
+ if (newProject != null) {
+ info.removeTarget(oldTargetId);
+ monitor.worked(9);
+ }
+ }
+ // Upgrade the version
+ ((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString());
+ }catch (CoreException e){
+ throw e;
+ }catch (Exception e) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ e.getMessage(), e));
+ } finally {
+ ManagedBuildManager.saveBuildInfo(project, false);
+ monitor.done();
+ }
+
+ }
+
+ protected static IManagedProject convertTarget(IProject project, Element oldTarget, IProgressMonitor monitor)
+ throws CoreException{
+ // What we want to create
+ IManagedProject newProject = null;
+ IProjectType newParent = null;
+
+ // Get the parent
+ String parentID = oldTarget.getAttribute(ITarget.PARENT);
+
+ String targetID = oldTarget.getAttribute(ITarget.ID);
+
+ // Get the new target definitions we need for the conversion
+ newParent = ManagedBuildManager.getProjectType(parentID);
+
+ if (newParent == null) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject20.9",parentID), null)); //$NON-NLS-1$
+ }
+
+ try {
+ // Create a new ManagedProject based on the new parent
+ newProject = ManagedBuildManager.createManagedProject(project, newParent);
+
+ // Create new configurations
+ NodeList configNodes = oldTarget.getElementsByTagName(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
+ for (int configIndex = 0; configIndex < configNodes.getLength(); ++configIndex) {
+ try{
+ convertConfiguration(newProject, newParent, (Element) configNodes.item(configIndex), monitor);
+ }
+ catch(CoreException e){
+ //TODO: implement logging
+ //should we continue or fail ??
+ }
+ }
+
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration[] newConfigs = newProject.getConfigurations();
+ if (newConfigs.length > 0) {
+ info.setDefaultConfiguration(newConfigs[0]);
+ info.setSelectedConfiguration(newConfigs[0]);
+ }
+ else{
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject20.10",newProject.getName()), null)); //$NON-NLS-1$
+ }
+ } catch (BuildException e) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject20.11",new String[]{newProject.getName(),e.getMessage()}), null)); //$NON-NLS-1$
+ }
+
+ monitor.worked(1);
+ return newProject;
+ }
+
+ protected static void convertConfiguration(IManagedProject newProject, IProjectType newParent, Element oldConfig, IProgressMonitor monitor)
+ throws CoreException {
+ IConfiguration newParentConfig = null;
+ IConfiguration newConfig = null;
+
+ // Figure out what the original parent of the config is
+ String parentId = oldConfig.getAttribute(IConfigurationV2.PARENT);
+
+ newParentConfig = newParent.getConfiguration(parentId);
+ if (newParentConfig == null) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject20.2", parentId), null)); //$NON-NLS-1$
+ }
+ // Generate a random number for the new config id
+ int randomElement = ManagedBuildManager.getRandomNumber();
+ String newConfigId = parentId + ID_SEPARATOR + randomElement;
+ // Create the new configuration
+ newConfig = newProject.createConfiguration(newParentConfig, newConfigId);
+
+ if(oldConfig.hasAttribute(IConfigurationV2.NAME))
+ newConfig.setName(oldConfig.getAttribute(IConfigurationV2.NAME));
+
+ Element targetEl = (Element)oldConfig.getParentNode();
+
+ if(targetEl.hasAttribute(ITarget.ARTIFACT_NAME))
+ newConfig.setArtifactName(targetEl.getAttribute(ITarget.ARTIFACT_NAME));
+
+ if(targetEl.hasAttribute(ITarget.ERROR_PARSERS))
+ newConfig.setErrorParserIds(targetEl.getAttribute(ITarget.ERROR_PARSERS));
+
+ if(targetEl.hasAttribute(ITarget.CLEAN_COMMAND))
+ newConfig.setCleanCommand(targetEl.getAttribute(ITarget.CLEAN_COMMAND));
+
+ if(targetEl.hasAttribute(ITarget.EXTENSION))
+ newConfig.setArtifactExtension(targetEl.getAttribute(ITarget.EXTENSION));
+
+ // Convert the tool references
+
+ IToolChain toolChain = newConfig.getToolChain();
+
+ if(targetEl.hasAttribute(ITarget.OS_LIST)){
+ String oses = targetEl.getAttribute(ITarget.OS_LIST);
+ String osList[] = oses.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osList.length; ++i) {
+ osList[i]=osList[i].trim();
+ }
+ toolChain.setOSList(osList);
+ }
+
+ if(targetEl.hasAttribute(ITarget.ARCH_LIST)){
+ String archs = targetEl.getAttribute(ITarget.ARCH_LIST);
+ String archList[] = archs.split(","); //$NON-NLS-1$
+ for (int i = 0; i < archList.length; ++i) {
+ archList[i]=archList[i].trim();
+ }
+ toolChain.setArchList(archList);
+ }
+
+ if(targetEl.hasAttribute(ITarget.BINARY_PARSER)){
+ String binaryParser = targetEl.getAttribute(ITarget.BINARY_PARSER);
+ ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
+ if(targetPlatform.isExtensionElement()){
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId = targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
+ String builderName = targetPlatform.getName() + "." + newConfig.getName(); //$NON-NLS-1$
+ toolChain.createTargetPlatform(targetPlatform,subId,builderName,false);
+ }
+ targetPlatform.setBinaryParserId(binaryParser);
+ }
+
+ if(targetEl.hasAttribute(ITarget.MAKE_COMMAND)){
+ String makeCommand = targetEl.getAttribute(ITarget.MAKE_COMMAND);
+ IBuilder builder = toolChain.getBuilder();
+ if (builder.isExtensionElement()) {
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId = builder.getId() + "." + nnn; //$NON-NLS-1$
+ String builderName = builder.getName() + "." + newConfig.getName(); //$NON-NLS-1$
+ builder = toolChain.createBuilder(builder, subId, builderName, false);
+ }
+ builder.setCommand(makeCommand);
+ }
+
+ if(targetEl.hasAttribute(ITarget.MAKE_ARGS)){
+ String makeArguments = targetEl.getAttribute(ITarget.MAKE_ARGS);
+ IBuilder builder = toolChain.getBuilder();
+ if (builder.isExtensionElement()) {
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId = builder.getId() + "." + nnn; //$NON-NLS-1$
+ String builderName = builder.getName() + "." + newConfig.getName(); //$NON-NLS-1$
+ builder = toolChain.createBuilder(builder, subId, builderName, false);
+ }
+ builder.setArguments(makeArguments);
+ }
+
+ NodeList toolRefNodes = oldConfig.getElementsByTagName(IConfigurationV2.TOOLREF_ELEMENT_NAME);
+ for (int refIndex = 0; refIndex < toolRefNodes.getLength(); ++refIndex) {
+ try{
+ convertToolRef(toolChain, (Element) toolRefNodes.item(refIndex), monitor);
+ }
+ catch(CoreException e){
+ newProject.removeConfiguration(newConfigId);
+ throw e;
+ }
+ }
+
+ monitor.worked(1);
+ }
+
+ protected static void convertToolRef(IToolChain toolChain, Element oldToolRef, IProgressMonitor monitor)
+ throws CoreException {
+ if(!oldToolRef.hasAttribute(IToolReference.ID)) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getResourceString("UpdateManagedProject20.3"), null)); //$NON-NLS-1$
+ }
+
+ String toolId = oldToolRef.getAttribute(IToolReference.ID);
+ IConfiguration configuration = toolChain.getParent();
+
+ ITool tools[] = configuration.getTools();
+ if(tools == null) {
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getResourceString("UpdateManagedProject20.4"), null)); //$NON-NLS-1$
+ }
+
+ ITool tool = null;
+ for(int i = 0; i < tools.length; i++){
+ ITool curTool = tools[i];
+ ITool parent = curTool.getSuperClass();
+ String curToolId = curTool.getId();
+
+ if(parent == null)
+ continue;
+
+ parent = parent.getSuperClass();
+ if(parent == null)
+ continue;
+
+ String parentId = parent.getId();
+ if(!parentId.equals(toolId))
+ continue;
+
+ try{
+ Integer.decode(curToolId.substring(curToolId.lastIndexOf('.')+1)); //$NON-NLS-1$
+ }
+ catch(IndexOutOfBoundsException e){
+ continue;
+ }
+ catch(NumberFormatException e){
+ continue;
+ }
+ tool = curTool;
+ break;
+ }
+
+ if(tool == null){
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject20.5",toolId), null)); //$NON-NLS-1$
+ }
+
+ //the tool found, proceed with conversion ...
+
+ if(oldToolRef.hasAttribute(IToolReference.COMMAND))
+ tool.setToolCommand(oldToolRef.getAttribute(IToolReference.COMMAND));
+
+ if(oldToolRef.hasAttribute(IToolReference.OUTPUT_FLAG))
+ tool.setOutputFlag(oldToolRef.getAttribute(IToolReference.OUTPUT_FLAG));
+
+ if(oldToolRef.hasAttribute(IToolReference.OUTPUT_PREFIX))
+ tool.setOutputPrefix(oldToolRef.getAttribute(IToolReference.OUTPUT_PREFIX));
+
+
+ if(oldToolRef.hasAttribute(IToolReference.OUTPUTS)){
+ String outputs = oldToolRef.getAttribute(IToolReference.OUTPUTS);
+ tool.setOutputExtensions(outputs);
+ }
+
+ NodeList optRefs = oldToolRef.getElementsByTagName(ITool.OPTION_REF);
+ for (int refIndex = optRefs.getLength() - 1; refIndex >= 0; --refIndex) {
+ convertOptionRef(toolChain, tool, (Element) optRefs.item(refIndex), monitor);
+ }
+
+ monitor.worked(1);
+ }
+
+ protected static void convertOptionRef(IToolChain toolChain, ITool tool, Element optRef, IProgressMonitor monitor)
+ throws CoreException {
+
+ if(!optRef.hasAttribute(IOption.ID)){
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getResourceString("UpdateManagedProject20.6"), null)); //$NON-NLS-1$
+ }
+
+ String optId = optRef.getAttribute(IOption.ID);
+
+ IConfiguration configuration = toolChain.getParent();
+
+ IOption options[] = tool.getOptions();
+ IOption option = null;
+
+ for(int i = 0; i < options.length; i++){
+ IOption curOption = options[i];
+ IOption parent = curOption.getSuperClass();
+ String curOptionId = curOption.getId();
+
+ if(parent == null)
+ continue;
+
+ String parentId = parent.getId();
+ if(!parentId.equals(optId))
+ continue;
+
+ option = curOption;
+ break;
+ }
+
+ if(option == null)
+ option = tool.getOptionById(optId);
+
+ if(option == null){
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject20.7",optId), null)); //$NON-NLS-1$
+ }
+
+ try{
+ int type = option.getValueType();
+
+ switch(type){
+ case IOption.BOOLEAN:{
+ if(optRef.hasAttribute(IOption.DEFAULT_VALUE)){
+ Boolean bool = new Boolean(optRef.getAttribute(IOption.DEFAULT_VALUE));
+ configuration.setOption(tool,option,bool.booleanValue());
+ }
+ break;
+ }
+ case IOption.ENUMERATED:
+ case IOption.STRING:{
+ if(optRef.hasAttribute(IOption.DEFAULT_VALUE))
+ configuration.setOption(tool,option,optRef.getAttribute(IOption.DEFAULT_VALUE));
+ break;
+ }
+ case IOption.STRING_LIST:
+ case IOption.INCLUDE_PATH:
+ case IOption.PREPROCESSOR_SYMBOLS:
+ case IOption.LIBRARIES:
+ case IOption.OBJECTS:{
+ Vector values = new Vector();
+ NodeList nodes = optRef.getElementsByTagName(IOption.LIST_VALUE);
+ for (int j = 0; j < nodes.getLength(); ++j) {
+ Node node = nodes.item(j);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Boolean isBuiltIn = new Boolean(((Element)node).getAttribute(IOption.LIST_ITEM_BUILTIN));
+ if (!isBuiltIn.booleanValue()) {
+ values.add(((Element)node).getAttribute(IOption.LIST_ITEM_VALUE));
+ }
+ }
+ }
+ configuration.setOption(tool,option,(String[])values.toArray(new String[values.size()]));
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ catch(BuildException e){
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProject20.8",e.getMessage()), e)); //$NON-NLS-1$
+ }
+
+ }
+}
+
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java
new file mode 100644
index 00000000000..4a8d46c16dd
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java
@@ -0,0 +1,295 @@
+/**********************************************************************
+ * 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.managedbuilder.projectconverter;
+
+import java.util.HashMap;
+
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
+import org.eclipse.core.resources.IContainer;
+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.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+
+public class UpdateManagedProjectManager {
+ static private HashMap fUpdateManagers = new HashMap();
+ static private IOverwriteQuery fBackupFileOverwriteQuery = null;
+ static private IOverwriteQuery fOpenQuestionQuery = null;
+ static private IOverwriteQuery fUpdateProjectQuery = null;
+
+ private ManagedBuildInfo fConvertedInfo= null;
+ private boolean fIsInfoReadOnly = false;
+ final private IProject fProject;
+
+ private UpdateManagedProjectManager(IProject project){
+ fProject = project;
+ }
+
+ public static void setBackupFileOverwriteQuery(IOverwriteQuery backupFileOverwriteQuery){
+ fBackupFileOverwriteQuery = backupFileOverwriteQuery;
+ }
+/*
+ public static void setOpenQuestionQuery(IOverwriteQuery openQuestionQuery){
+ fOpenQuestionQuery = openQuestionQuery;
+ }
+*/
+ public static void setUpdateProjectQuery(IOverwriteQuery updateProjectQuery){
+ fUpdateProjectQuery = updateProjectQuery;
+ }
+
+ private static boolean getBooleanFromQueryAnswer(String answer){
+ if(IOverwriteQuery.ALL.equalsIgnoreCase(answer) ||
+ IOverwriteQuery.YES.equalsIgnoreCase(answer))
+ return true;
+ else
+ return false;
+ }
+
+ synchronized static private UpdateManagedProjectManager getUpdateManager(IProject project){
+ UpdateManagedProjectManager mngr = getExistingUpdateManager(project);
+ if(mngr == null)
+ mngr = createUpdateManager(project);
+ return mngr;
+ }
+
+ static private UpdateManagedProjectManager getExistingUpdateManager(IProject project){
+ return (UpdateManagedProjectManager)fUpdateManagers.get(project.getName());
+ }
+
+ static private UpdateManagedProjectManager createUpdateManager(IProject project){
+ UpdateManagedProjectManager mngr = new UpdateManagedProjectManager(project);
+ fUpdateManagers.put(project.getName(),mngr);
+ return mngr;
+ }
+
+ static private void removeUpdateManager(IProject project){
+ UpdateManagedProjectManager mngr = getExistingUpdateManager(project);
+ if(mngr == null)
+ return;
+ fUpdateManagers.remove(project.getName());
+ }
+
+ static protected PluginVersionIdentifier getManagedBuildInfoVersion(String version){
+ if(version == null)
+ version = "1.2"; //$NON-NLS-1$
+ return new PluginVersionIdentifier(version);
+ }
+
+ static public boolean isCompatibleProject(IManagedBuildInfo info) {
+ if(info == null)
+ return false;
+
+ PluginVersionIdentifier projVersion = getManagedBuildInfoVersion(info.getVersion());
+
+ PluginVersionIdentifier compVersion = ManagedBuildManager.getBuildInfoVersion();
+
+ if(projVersion.isEquivalentTo(compVersion))
+ return true;
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * Create a back-up file
+ *
+ * @param settingsFile
+ * @param suffix
+ * @param monitor
+ * @param project
+ */
+ static void backupFile(IFile settingsFile, String suffix, IProgressMonitor monitor, IProject project){
+ UpdateManagedProjectManager mngr = getExistingUpdateManager(project);
+ if(mngr == null || mngr.fIsInfoReadOnly)
+ return;
+ IContainer destFolder = (IContainer)project;
+ IFile dstFile = destFolder.getFile(new Path(settingsFile.getName()+suffix));
+ mngr.backupFile(settingsFile, dstFile, monitor, project, fBackupFileOverwriteQuery);
+ }
+
+ /* (non-Javadoc)
+ * Create a back-up file
+ *
+ * @param srcFile
+ * @param dstFile
+ * @param monitor
+ * @param project
+ * @param query
+ */
+ private void backupFile(IFile srcFile, IFile dstFile, IProgressMonitor monitor, IProject project, IOverwriteQuery query){
+ try{
+ if (dstFile.exists()) {
+ boolean shouldUpdate;
+ if(query != null)
+ shouldUpdate = getBooleanFromQueryAnswer(query.queryOverwrite(dstFile.getFullPath().toString()));
+ else
+ shouldUpdate = openQuestion(ConverterMessages.getResourceString("UpdateManagedProjectManager.0"), //$NON-NLS-1$
+ ConverterMessages.getFormattedString("UpdateManagedProjectManager.1", new String[] {dstFile.getName(),project.getName()})); //$NON-NLS-1$
+
+ if (shouldUpdate) {
+ dstFile.delete(true, monitor);
+ } else {
+// monitor.setCanceled(true);
+ throw new OperationCanceledException(ConverterMessages.getFormattedString("UpdateManagedProjectManager.2", project.getName())); //$NON-NLS-1$
+ }
+ }
+ srcFile.copy(dstFile.getFullPath(), true, monitor);
+ }
+ catch(Exception e){
+ fIsInfoReadOnly = true;
+ }
+ }
+
+ private void restoreFile(String backupFileName, String restoreFileName, IProgressMonitor monitor, IProject project){
+ IContainer destFolder = (IContainer)project;
+ IFile restoreFile = destFolder.getFile(new Path(restoreFileName));
+ IFile backupFile = destFolder.getFile(new Path(backupFileName));
+
+ try{
+ if (restoreFile.exists())
+ restoreFile.delete(true, monitor);
+ backupFile.copy(restoreFile.getFullPath(), true, monitor);
+ }
+ catch(Exception e){
+ fIsInfoReadOnly = true;
+ }
+ }
+
+ static private boolean openQuestion(final String title, final String message){
+ if(fOpenQuestionQuery != null)
+ return getBooleanFromQueryAnswer(fOpenQuestionQuery.queryOverwrite(message));
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if(window == null){
+ IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
+ window = windows[0];
+ }
+
+ final Shell shell = window.getShell();
+ final boolean [] answer = new boolean[1];
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ answer[0] = MessageDialog.openQuestion(shell,title,message);
+ }
+ });
+ return answer[0];
+ }
+
+ /**
+ * returns ManagedBuildInfo for the current project
+ * if converter is currently running
+ * @param project project for which ManagedBuildInfo is needed
+ * @return the pointer to the project ManagedBuildInfo or null
+ * if converter is no running
+ */
+ static public ManagedBuildInfo getConvertedManagedBuildInfo(IProject project){
+ UpdateManagedProjectManager mngr = getExistingUpdateManager(project);
+ if(mngr == null)
+ return null;
+ return mngr.getConvertedManagedBuildInfo();
+ }
+
+ private ManagedBuildInfo getConvertedManagedBuildInfo(){
+ return fConvertedInfo;
+ }
+
+ private void doProjectUpdate(ManagedBuildInfo info)
+ throws CoreException {
+ fConvertedInfo = info;
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ IFile settingsFile = fProject.getFile(ManagedBuildManager.SETTINGS_FILE_NAME);
+ IFile backupFile = fProject.getFile(ManagedBuildManager.SETTINGS_FILE_NAME + "_initial"); //$NON-NLS-1$
+ if(isCompatibleProject(info))
+ return;
+
+ try {
+ if (!settingsFile.exists())
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getResourceString("UpdateManagedProjectManager.6"),null)); //$NON-NLS-1$
+
+
+ backupFile(settingsFile, backupFile, monitor, fProject, new IOverwriteQuery(){
+ public String queryOverwrite(String file) {
+ return ALL;
+ }
+ });
+
+ PluginVersionIdentifier version = getManagedBuildInfoVersion(info.getVersion());
+
+ boolean shouldUpdate;
+ if(fUpdateProjectQuery != null)
+ shouldUpdate = getBooleanFromQueryAnswer(fUpdateProjectQuery.queryOverwrite(fProject.getFullPath().toString()));
+ else
+ shouldUpdate = openQuestion(ConverterMessages.getResourceString("UpdateManagedProjectManager.3"), //$NON-NLS-1$
+ ConverterMessages.getFormattedString("UpdateManagedProjectManager.4", new String[]{fProject.getName(),version.toString(),ManagedBuildManager.getBuildInfoVersion().toString()}) //$NON-NLS-1$
+ );
+
+ if (!shouldUpdate)
+ fIsInfoReadOnly = true;
+
+ if(version.isEquivalentTo(new PluginVersionIdentifier(1,2,0))){
+ UpdateManagedProject12.doProjectUpdate(monitor, fProject);
+ version = getManagedBuildInfoVersion(info.getVersion());
+ }
+ if(version.isEquivalentTo(new PluginVersionIdentifier(2,0,0))){
+ UpdateManagedProject20.doProjectUpdate(monitor, fProject);
+ version = getManagedBuildInfoVersion(info.getVersion());
+ }
+
+ if(!isCompatibleProject(info)){
+ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
+ ConverterMessages.getFormattedString("UpdateManagedProjectManager.5", //$NON-NLS-1$
+ new String [] {
+ ManagedBuildManager.getBuildInfoVersion().toString(),
+ version.toString(),
+ info.getManagedProject().getId()
+ }
+ ),null));
+ }
+ } catch (CoreException e) {
+ fIsInfoReadOnly = true;
+ throw e;
+ } finally{
+ if(fIsInfoReadOnly){
+ restoreFile(backupFile.getName(), settingsFile.getName(), monitor, fProject);
+ info.setReadOnly(true);
+ }
+ }
+ }
+
+ /**
+ * updates the managed project
+ *
+ * @param project the project to be updated
+ * @param info the ManagedBuildInfo for the current project
+ * @throws CoreException if conversion failed
+ */
+ static public void updateProject(IProject project, ManagedBuildInfo info)
+ throws CoreException{
+ try{
+ getUpdateManager(project).doProjectUpdate(info);
+ } finally {
+ removeUpdateManager(project);
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
index 624440fdfb0..3f89dfce555 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
@@ -21,6 +21,10 @@ MngCCWizard.description=Create a new C++ project and let Eclipse create and mana
MngBuildProp.name=C/C++ Build
MngOtherProp.name= Error/Binary Parsers
+#The Resource Property page
+MngResourceProp.name=C/C++ Build
+
+
# Build Model Names
TargetName.gnu=GNU
TargetName.gnu.exe=Executable (Gnu)
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index a1a083f7af2..ba3d1dc6933 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -65,37 +65,43 @@
+
true
if any of the pages are dirty
+ * @return boolean
+ */
+ public boolean isDirty() {
+ Iterator iter = getOptionPages().iterator();
+ while (iter.hasNext()) {
+ ICOptionPage tab = (ICOptionPage)iter.next();
+ if (tab instanceof BuildSettingsBlock) {
+ if (((BuildSettingsBlock)tab).isDirty()) return true;
+ } else if (tab instanceof ToolsSettingsBlock) {
+ if (((ToolsSettingsBlock)tab).isDirty()) return true;
+ } else if (tab instanceof ErrorParserBlock) {
+ if (((ErrorParserBlock)tab).isDirty()) return true;
+ } else if (tab instanceof BinaryParserBlock) {
+ //TODO ManagedBuildSystem needs its own binary parser block
+ }
+
+ }
+ return false;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java
deleted file mode 100644
index e4954e03d6a..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedMakeStartup.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004 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.managedbuilder.internal.ui;
-
-import org.eclipse.cdt.managedbuilder.ui.actions.UpdateManagedProjectAction;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IStartup;
-
-/**
- *
- */
-public class ManagedMakeStartup implements IStartup {
- /* (non-Javadoc)
- * @see org.eclipse.ui.IStartup#earlyStartup()
- */
- public void earlyStartup() {
- // Get any 1.2 projects from the workspace
- final IProject[] projects = UpdateManagedProjectAction.getVersion12Projects();
- if (projects.length > 0) {
- Display.getDefault().asyncExec(new Runnable() {
- // Start the process that will update the 1.2 projects
- public void run() {
- Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
- for (int index = projects.length - 1; index >= 0; --index) {
- IProject project = projects[index];
- boolean shouldUpdate = MessageDialog.openQuestion(shell,
- ManagedBuilderUIMessages.getResourceString("ManagedBuilderStartup.update.12x.title"), //$NON-NLS-1$
- ManagedBuilderUIMessages.getFormattedString("ManagedBuilderStartup.update.12x.message", new String[]{project.getName()})); //$NON-NLS-1$
- // Go for it
- if (shouldUpdate) {
- ProgressMonitorDialog pd = new ProgressMonitorDialog(shell);
- UpdateManagedProjectAction.run(false, pd, project);
- }
- }
-
- }
- });
- }
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java
index 02cc74db91f..8579d0b4571 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.internal.ui;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,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 v0.5
* which accompanies this distribution, and is available at
@@ -10,10 +8,13 @@ package org.eclipse.cdt.managedbuilder.internal.ui;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui;
import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.help.WorkbenchHelp;
@@ -27,7 +28,7 @@ public class ManagedProjectOptionBlock extends TabFolderOptionBlock {
* @param parent
*/
public ManagedProjectOptionBlock(ICOptionContainer parent) {
- super(parent);
+ super(parent, false);
}
/* (non-Javadoc)
@@ -49,9 +50,27 @@ public class ManagedProjectOptionBlock extends TabFolderOptionBlock {
public Control createContents(Composite parent) {
Control control = super.createContents( parent );
+ ((GridLayout)((Composite)control).getLayout()).marginWidth = 1;
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ ((Composite)control).setLayoutData(gd);
+
if (getErrorParserBlock()!= null)
WorkbenchHelp.setHelp(getErrorParserBlock().getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_ERROR_PARSER);
return control;
}
+
+ public void updateValues() {
+ if (getErrorParserBlock()!= null) {
+ getErrorParserBlock().updateValues();
+ }
+ if (getBinaryParserBlock()!= null) {
+ // TODO
+ //getBinaryParserBlock().updateValues();
+ }
+ }
+
+ public void update() {
+ super.update();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
index 86749492e38..706c7b43a46 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
@@ -3,16 +3,9 @@
# All Rights Reserved.
#########################################
-# ------- 1.2 Project Update Messages -------
-ManagedBuilderStartup.update.12x.title=Update Managed Builder Project
-ManagedBuilderStartup.update.12x.message=The project {0} has been detected in your workspace.\n Its build settings are stored in a format that is no longer supported.\n Would you like to convert them now?
-ManagedBuilderStartup.update.exception.error=Error
-ManagedBuilderStartup.update.exception.message=Error updating project {0}
-ManagedBuildConvert.12x.monitor.message.project=Updating build settings for project {0}
-ManagedBuildConvert.12x.monitor.message.backup=Backing up the settings file for {0}
-ManagedBuildConvert.12x.warning.title=Backup File Already Exists
-ManagedBuildConvert.12x.warning.message=A backup file already exists for the project {0}.\n Shall I try to convert the project anyway?
-ManagedBuildConvert.12x.cancelled.message=The update operation has been cancelled.\n The build system will not be able to read the project settings until you update the project.
+# ------- Project Update Messages -------
+ManagedBuilderStartup.update.20x.title=Update Managed Builder Project
+ManagedBuilderStartup.update.20x.message=The project {0} has been detected in your workspace.\n Its build settings are stored in a format that is no longer supported.\n Would you like to convert them now?
# ------- NewProjectCreationPluginPage-------
MngMakeProjectWizard.op_error=Managed Make Error
@@ -36,12 +29,12 @@ MngCCWizardSettings.title=Managed Make C++ Settings
MngCCWizardSettings.description=Define the Managed Make C++ build settings.
# -- Strings for the platform selection page --
-MngMakeProjectWizard.config.title=Select a Target
+MngMakeProjectWizard.config.title=Select a type of project
MngMakeProjectWizard.config.desc=Select the platform and configurations you wish to deploy on
-PlatformBlock.tip.platform=Select the target of the build goal
-PlatformBlock.label.platform=Build Target:
+PlatformBlock.tip.platform=Select the type of project for the build goal
+PlatformBlock.label.platform=Project Type:
PlatformBlock.label.configs=Configurations:
-PlatformBlock.label.showall=Show All Targets
+PlatformBlock.label.showall=Show All Project Types
PlatformBlock.message.error.noconfigs=You must select at least one configuration
# -- Strings for the additional options tab
@@ -49,14 +42,12 @@ MngMakeProjectWizard.options.title=Additional Project Settings
MngMakeProjectWizard.options.desc=Define the inter-project dependencies, if any.
# ----------- Configuration Selection Page -----------
-BuildPropertyPage.label.Platform=Platform:
+BuildPropertyPage.label.Platform=Project Type:
BuildPropertyPage.label.Configuration=Configuration:
BuildPropertyPage.label.Active=Active configuration
-BuildPropertyPage.label.Settings=Configuration settings
+BuildPropertyPage.label.Settings=Configuration Settings
BuildPropertyPage.label.AddConfButton=Manage...
BuildPropertyPage.selection.configuration.all=All configurations
-BuildPropertyPage.label.ToolTree=Tools
-BuildPropertyPage.label.ToolOptions=Options
BuildPropertyPage.tip.platform=Select a platform for the project
BuildPropertyPage.tip.config=Select the configuration to edit
BuildPropertyPage.tip.addconf=Add configurations for the platform
@@ -64,6 +55,37 @@ BuildPropertyPage.tip.remconf=Remove configurations for the platform
BuildPropertyPage.manage.title=Manage
BuildPropertyPage.error.Unknown_tree_element=Unknown type of element in tree of type {0}
BuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be upgraded.
+BuildPropertyPage.defaults.title=Reset Configuration Tools
+BuildPropertyPage.defaults.message=This action will reset all of the tools in the selected configuration to their default settings.\n\nDo you want to proceed?
+BuildPropertyPage.changes.save.title=Apply Configuration Changes
+BuildPropertyPage.changes.save.question=You have made changes to the {0} configuration.\n\nDo you want to apply these changes before switching to the {1} configuration?
+BuildPropertyPage.changes.save.error=The configuration changes could not be applied.
+
+#--------------- Resource Configuration Selection Page --------------
+ResourceBuildPropertyPage.defaults.title=Reset Resource Configuration Tool
+ResourceBuildPropertyPage.defaults.message=This action will reset all options of the tool in the current resource configuration to their default settings.\n\nDo you want to proceed?
+
+# ----------- Tools Settings Block -----------
+ToolsSettingsBlock.label.Settings=Tool Settings
+ToolsSettingsBlock.label.ToolTree=Tools
+ToolsSettingsBlock.label.ToolOptions=Options
+
+# ----------- Build Settings Block -----------
+BuildSettingsBlock.label.Settings=Build Settings
+BuildSettingsBlock.label.makecmdgroup=Make command
+BuildSettingsBlock.label.makecmddef=Use default command
+BuildSettingsBlock.label.output.group=Build output
+BuildSettingsBlock.label.output.name=Artifact name:
+BuildSettingsBlock.label.output.extension=Artifact extension:
+
+# ------------Resource Configuration Selection Page
+ResourceBuildPropertyPage.label.ActiveResource=Active Resource configuration
+ResourceBuildPropertyPage.label.ResourceSettings=Resource Configuration settings
+ResourceBuildPropertyPage.label.Configuration=Configuration:
+ResourceBuildPropertyPage.label.ExcludeCheckBox= Exclude from build
+ResourceBuildPropertyPage.selection.configuration.all=All configurations
+ResourceBuildPropertyPage.label.ToolTree=Tools
+ResourceBuildPropertyPage.label.ToolOptions=Options
# ----------- Entry Dialog -----------
BrowseEntryDialog.error.Folder_name_invalid = Folder name invalid
@@ -81,11 +103,6 @@ NewConfiguration.error.title=Error
NewConfiguration.error.duplicateName=A configuration named "{0}" already exists.
# ----------- Target/Config management dialog -----------------
-ManageConfig.label.makecmdgroup=Make command
-ManageConfig.label.makecmddef=Use default command
-ManageConfig.label.output.group=Build output
-ManageConfig.label.output.name=Artifact name:
-ManageConfig.label.output.extension=Artifact extension:
ManageConfig.label.configs=Manage configurations
ManageConfig.label.restore=Restore
ManageConfig.label.configs.current=Current:
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java
new file mode 100644
index 00000000000..2da2a71f429
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java
@@ -0,0 +1,639 @@
+/**********************************************************************
+ * Copyright (c) 2002,2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * QNX Software Systems - Move to Make plugin
+ * Intel Corp - Use in Managed Make system
+***********************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionSettingsPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildSettingsPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolsSettingsStore;
+import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.ToolListContentProvider;
+import org.eclipse.cdt.managedbuilder.ui.properties.ToolListLabelProvider;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+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.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Shell;
+
+public class ToolsSettingsBlock extends AbstractCOptionPage {
+
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "ToolsSettingsBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$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 int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
+
+ /*
+ * Dialog widgets
+ */
+ private TreeViewer optionList;
+ private SashForm sashForm;
+ private Group sashGroup;
+ private Composite settingsPageContainer;
+ private ScrolledComposite containerSC;
+
+ /*
+ * Bookeeping variables
+ */
+ private Map configToPageListMap;
+ private BuildToolsSettingsStore settingsStore;
+ private Map settingsStoreMap;
+ private BuildPropertyPage parent;
+ private ResourceBuildPropertyPage resParent;
+ private BuildSettingsPage currentSettingsPage;
+ private IOptionCategory selectedCategory;
+ private ToolListContentProvider provider;
+ private ITool selectedTool;
+ private Object element;
+
+ /**
+ * The minimum page size; 200 by 200 by default.
+ *
+ * @see #setMinimumPageSize
+ */
+ private Point minimumPageSize = new Point(200, 200);
+
+ /**
+ * Layout for the page container.
+ *
+ */
+ private class PageLayout extends Layout {
+ public void layout(Composite composite, boolean force) {
+ Rectangle rect = composite.getClientArea();
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ children[i].setSize(rect.width, rect.height);
+ }
+ }
+ public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
+ if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
+ return new Point(wHint, hHint);
+ }
+ int x = minimumPageSize.x;
+ int y = minimumPageSize.y;
+
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
+ x = Math.max(x, size.x);
+ y = Math.max(y, size.y);
+ }
+ if (wHint != SWT.DEFAULT) {
+ x = wHint;
+ }
+ if (hHint != SWT.DEFAULT) {
+ y = hHint;
+ }
+ return new Point(x, y);
+ }
+ }
+
+ /*
+ * Constructor
+ */
+ public ToolsSettingsBlock(BuildPropertyPage parent, Object element)
+ {
+ super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
+ super.setContainer(parent);
+ this.parent = parent;
+ configToPageListMap = new HashMap();
+ this.element = element;
+ }
+
+ public ToolsSettingsBlock(ResourceBuildPropertyPage resParent, Object element)
+ {
+ super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL));
+ super.setContainer((ICOptionContainer) resParent);
+ this.resParent = resParent;
+ configToPageListMap = new HashMap();
+ this.element = element;
+ }
+
+ public void createControl(Composite parent) {
+
+ // Create the sash form
+ sashForm = new SashForm(parent, SWT.NONE);
+ sashForm.setOrientation(SWT.HORIZONTAL);
+ sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 5;
+ layout.marginWidth = 5;
+ sashForm.setLayout(layout);
+
+ setControl(sashForm);
+ createSelectionArea(sashForm);
+ createEditArea(sashForm);
+ initializeSashForm();
+
+ //WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
+ }
+
+ protected void createSelectionArea (Composite parent) {
+ // Create a label and list viewer
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ optionList = new TreeViewer(composite, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
+ optionList.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleOptionSelection();
+ }
+ });
+ optionList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ optionList.setLabelProvider(new ToolListLabelProvider());
+ }
+
+ /* (non-Javadoc)
+ * Method displayOptionsForTool.
+ * @param toolReference
+ */
+ private void displayOptionsForCategory(IOptionCategory category) {
+ // Do nothing if the selected category is is unchanged
+ if (category == selectedCategory) {
+ return;
+ }
+ selectedTool = null;
+ selectedCategory = category;
+
+ // Cache the current build setting page
+ BuildSettingsPage oldPage = currentSettingsPage;
+ currentSettingsPage = null;
+
+ // Create a new settings page if necessary
+ List pages = getPagesForConfig();
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page instanceof BuildOptionSettingsPage &&
+ ((BuildOptionSettingsPage)page).isForCategory(category)) {
+ currentSettingsPage = page;
+ break;
+ }
+ }
+ if (currentSettingsPage == null) {
+ if ( this.element instanceof IProject) {
+ currentSettingsPage = new BuildOptionSettingsPage(parent.getSelectedConfiguration(), category);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(parent);
+ } else if ( this.element instanceof IFile) {
+ currentSettingsPage = new BuildOptionSettingsPage(resParent.getCurrentResourceConfig(), category);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(resParent);
+ }
+ if (currentSettingsPage.getControl() == null) {
+ currentSettingsPage.createControl(settingsPageContainer);
+ }
+ }
+
+ // Make all the other pages invisible
+ Control[] children = settingsPageContainer.getChildren();
+ Control currentControl = currentSettingsPage.getControl();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != currentControl)
+ children[i].setVisible(false);
+ }
+ 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.
+ if (oldPage != null){
+ if(oldPage instanceof BuildOptionSettingsPage) {
+ ((BuildOptionSettingsPage)oldPage).storeSettings();
+ }
+ else if(oldPage instanceof BuildToolSettingsPage) {
+ ((BuildToolSettingsPage)oldPage).storeSettings();
+ //((BuildToolSettingsPage)oldPage).parseAllOptions();
+ }
+ }
+ //update the field editors in the current page
+ if(currentSettingsPage instanceof BuildOptionSettingsPage)
+ ((BuildOptionSettingsPage)currentSettingsPage).updateFields();
+
+ if (oldPage != null)
+ oldPage.setVisible(false);
+
+ // Set the size of the scrolled area
+ containerSC.setMinSize(currentSettingsPage.computeSize());
+ settingsPageContainer.layout();
+ }
+
+ /* (non-Javadoc)
+ * @param tool
+ */
+ private void displayOptionsForTool(ITool tool) {
+ if (tool == selectedTool) {
+ return;
+ }
+ // Unselect the category
+ selectedCategory = null;
+ // record that the tool selection has changed
+ selectedTool = tool;
+
+ // Cache the current build setting page
+ BuildSettingsPage oldPage = currentSettingsPage;
+ currentSettingsPage = null;
+
+ // Create a new page if we need one
+ List pages = getPagesForConfig();
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page instanceof BuildToolSettingsPage &&
+ ((BuildToolSettingsPage)page).isForTool(tool)) {
+ currentSettingsPage = page;
+ break;
+ }
+ }
+ if (currentSettingsPage == null) {
+ if ( this.element instanceof IProject) {
+ currentSettingsPage = new BuildToolSettingsPage(parent.getSelectedConfiguration(), tool);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(parent);
+ } else if(this.element instanceof IFile) {
+ currentSettingsPage = new BuildToolSettingsPage(resParent.getCurrentResourceConfig(), tool);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(resParent);
+ }
+ if (currentSettingsPage.getControl() == null) {
+ currentSettingsPage.createControl(settingsPageContainer);
+ }
+ }
+ // Make all the other pages invisible
+ Control[] children = settingsPageContainer.getChildren();
+ Control currentControl = currentSettingsPage.getControl();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != currentControl)
+ children[i].setVisible(false);
+ }
+
+ // 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.
+ if (oldPage != null){
+ if(oldPage instanceof BuildOptionSettingsPage) {
+ ((BuildOptionSettingsPage)oldPage).storeSettings();
+ }
+ else if(oldPage instanceof BuildToolSettingsPage) {
+ ((BuildToolSettingsPage)oldPage).storeSettings();
+ //((BuildToolSettingsPage)oldPage).parseAllOptions();
+ }
+ }
+ //update the field editor that displays all the build options
+ if(currentSettingsPage instanceof BuildToolSettingsPage)
+ ((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField();
+
+ if (oldPage != null)
+ oldPage.setVisible(false);
+
+ // Set the size of the scrolled area
+ containerSC.setMinSize(currentSettingsPage.computeSize());
+ settingsPageContainer.layout();
+ }
+
+ /* (non-Javadoc)
+ * Add the tabs relevant to the project to edit area tab folder.
+ */
+ protected void createEditArea(Composite parent) {
+ containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ containerSC.setExpandHorizontal(true);
+ containerSC.setExpandVertical(true);
+
+ // Add a container for the build settings page
+ settingsPageContainer = new Composite(containerSC, SWT.NULL);
+ settingsPageContainer.setLayout(new PageLayout());
+
+ containerSC.setContent(settingsPageContainer);
+ containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ settingsPageContainer.layout();
+ }
+
+ /*
+ * (non-javadoc)
+ * Initialize the relative weights (widths) of the 2 sides of the sash.
+ */
+ protected void initializeSashForm() {
+ sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
+ }
+
+ protected void initializeValues() {
+ setValues();
+ }
+
+ public void updateValues() {
+ setValues();
+ }
+
+ protected void setValues() {
+
+ if (provider == null) {
+// IResource element = parent.getProject();
+ IResource resource = (IResource) element;
+ provider = new ToolListContentProvider(resource.getType());
+ optionList.setContentProvider(provider);
+ }
+ if ( element instanceof IProject ) {
+ optionList.setInput(parent.getSelectedConfiguration());
+ } else if ( element instanceof IFile){
+ optionList.setInput(resParent.getCurrentResourceConfig());
+ }
+
+ optionList.expandAll();
+
+ // Create (or retrieve) the settings store for the configuration/resource configuration
+ BuildToolsSettingsStore store = null;
+ if ( element instanceof IProject ) {
+ store = (BuildToolsSettingsStore) getSettingsStoreMap().get(parent.getSelectedConfiguration().getId());
+ if (store == null) {
+ store = new BuildToolsSettingsStore(parent.getSelectedConfiguration());
+ getSettingsStoreMap().put(parent.getSelectedConfiguration().getId(), store);
+ }
+ } else if ( element instanceof IFile) {
+ store = (BuildToolsSettingsStore) getSettingsStoreMap().get(resParent.getCurrentResourceConfig().getId());
+ if (store == null) {
+ store = new BuildToolsSettingsStore(resParent.getCurrentResourceConfig());
+ getSettingsStoreMap().put(resParent.getCurrentResourceConfig().getId(), store);
+ }
+ }
+ settingsStore = store;
+
+ // Select the first tool in the list
+ Object[] elements = null;
+ Object primary = null;
+ if( element instanceof IProject){
+ elements = provider.getElements(parent.getSelectedConfiguration());
+ } else if ( element instanceof IFile) {
+ elements = provider.getElements(resParent.getCurrentResourceConfig());
+ }
+ primary = elements.length > 0 ? elements[0] : null;
+
+ if (primary != null) {
+ optionList.setSelection(new StructuredSelection(primary));
+ }
+ }
+
+ public void removeValues(String id) {
+ getSettingsStoreMap().remove(id);
+ }
+
+ private void handleOptionSelection() {
+ // Get the selection from the tree list
+ IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
+
+ // Set the option page based on the selection
+ Object element = selection.getFirstElement();
+ if (element instanceof ITool) {
+ displayOptionsForTool((ITool)element);
+ } else if (element instanceof IOptionCategory) {
+ displayOptionsForCategory((IOptionCategory)element);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+ */
+ public void performDefaults() {
+ if ( element instanceof IProject) {
+ performDefaults( (IProject)element);
+ } else if ( element instanceof IFile) {
+ performDefaults( (IFile)element);
+ }
+ return;
+ }
+
+ public void performDefaults(IProject project) {
+ // TODO: Should this reset all tools of the configuration, or just
+ // the currently selected tool category? Right now it is all tools.
+
+ // Display a "Confirm" dialog box, since:
+ // 1. The defaults are immediately applied
+ // 2. The action cannot be undone
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldDefault = MessageDialog.openConfirm(shell,
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.defaults.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.defaults.message")); //$NON-NLS-1$
+ if (!shouldDefault) return;
+
+ // Empty the page list
+ List pages = getPagesForConfig();
+ pages.clear();
+
+ // Get the build manager to reset build info for project
+ ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration());
+
+ // Recreate the settings store for the configuration
+ settingsStore = new BuildToolsSettingsStore(parent.getSelectedConfiguration());
+
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(parent.getProject(), parent.getSelectedConfiguration());
+ ManagedBuildManager.saveBuildInfo(parent.getProject(), false);
+
+ // Reset the category or tool selection and run selection event handler
+ selectedCategory = null;
+ selectedTool = null;
+ handleOptionSelection();
+
+ setDirty(false);
+ }
+
+ public void performDefaults(IFile file) {
+ // TODO: Should this reset all options of the tool in current resource configuration, or just
+ // the currently selected tool category? Right now it is all options.
+
+ // Display a "Confirm" dialog box, since:
+ // 1. The defaults are immediately applied
+ // 2. The action cannot be undone
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldDefault = MessageDialog.openConfirm(shell,
+ ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.defaults.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.defaults.message")); //$NON-NLS-1$
+ if (!shouldDefault) return;
+
+ // Empty the page list
+ List pages = getPagesForConfig();
+ pages.clear();
+
+ // Get the build manager to reset build info for project
+ ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig());
+
+ // Recreate the settings store for the configuration
+ settingsStore = new BuildToolsSettingsStore(resParent.getCurrentResourceConfig());
+
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(resParent.getProject(), resParent.getSelectedConfiguration());
+ ManagedBuildManager.saveBuildInfo(resParent.getProject(), false);
+
+ // Reset the category or tool selection and run selection event handler
+ selectedCategory = null;
+ selectedTool = null;
+ handleOptionSelection();
+
+ setDirty(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
+ */
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+
+ // Force each settings page to update
+ List pages = getPagesForConfig();
+ // Make sure we have something to work on
+ if (pages == null) {
+ // Nothing to do
+ return;
+ }
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page == null) continue;
+ if (page instanceof BuildToolSettingsPage) {
+ // if the currentsettings page is not the tool settings page
+ // then update the all build options field editor based on the
+ // build options in other options settings page.
+ if (!(currentSettingsPage instanceof BuildToolSettingsPage))
+ ((BuildToolSettingsPage)page).updateAllOptionField();
+ ((BuildToolSettingsPage)page).performOk();
+ } else if (page instanceof BuildOptionSettingsPage) {
+ ((BuildOptionSettingsPage)page).performOk();
+ }
+ }
+
+ setDirty(false);
+ }
+
+ /* (non-Javadoc)
+ * Answers the list of settings pages for the selected configuration
+ * @return
+ */
+ private List getPagesForConfig() {
+ List pages = null;
+ if ( element instanceof IProject) {
+// Make sure that something was selected
+ if (parent.getSelectedConfiguration() == null) {
+ return null;
+ }
+ pages = (List) configToPageListMap.get(parent.getSelectedConfiguration().getId());
+ } else if (element instanceof IFile) {
+ if ( resParent.getCurrentResourceConfig() == null ) {
+ return null;
+ }
+ pages = (List) configToPageListMap.get(resParent.getCurrentResourceConfig().getId());
+ }
+
+ if (pages == null) {
+ pages = new ArrayList();
+ if ( element instanceof IProject) {
+ configToPageListMap.put(parent.getSelectedConfiguration().getId(), pages);
+ } else if ( element instanceof IFile) {
+ configToPageListMap.put(resParent.getCurrentResourceConfig().getId(), pages);
+ }
+ }
+ return pages;
+ }
+
+ public IPreferenceStore getPreferenceStore() {
+ return settingsStore;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor method
+ *
+ * @return Returns the Map of configurations to preference stores.
+ */
+ protected Map getSettingsStoreMap() {
+ if (settingsStoreMap == null) {
+ settingsStoreMap = new HashMap();
+ }
+ return settingsStoreMap;
+ }
+
+ /**
+ * Sets the "dirty" state
+ */
+ public void setDirty(boolean b) {
+ // Set each settings page
+ List pages = getPagesForConfig();
+ // Make sure we have something to work on
+ if (pages == null) {
+ // Nothing to do
+ return;
+ }
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page == null) continue;
+ page.setDirty(b);
+ }
+ }
+
+ /**
+ * Returns the "dirty" state
+ */
+ public boolean isDirty() {
+ // Check each settings page
+ List pages = getPagesForConfig();
+ // Make sure we have something to work on
+ if (pages == null) {
+ // Nothing to do
+ return false;
+ }
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ if (page == null) continue;
+ if (page.isDirty()) return true;
+ }
+ return false;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
index b40376a977d..68c594dec43 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,9 +8,12 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
@@ -70,6 +71,16 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
selectorData.horizontalSpan = numColumns - 1;
selectorData.grabExcessHorizontalSpace = true;
optionSelector.setLayoutData(selectorData);
+ optionSelector.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ String oldValue = selected;
+ String name = optionSelector.getText();
+ int index = optionSelector.getSelectionIndex();
+ selected = index == -1 ? new String() : optionSelector.getItem(index);
+ setPresentsDefaultValue(false);
+ fireValueChanged(VALUE, oldValue, selected);
+ }
+ });
}
/* (non-Javadoc)
@@ -101,7 +112,7 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
protected void doStore() {
// Save the selected item in the store
int index = optionSelector.getSelectionIndex();
- String selected = index == -1 ? new String() : optionSelector.getItem(index);
+ selected = index == -1 ? new String() : optionSelector.getItem(index);
getPreferenceStore().setValue(getPreferenceName(), selected);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java
index 2603c2abb0b..3d5f40eb75f 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2003,2004 IBM Rational Software Corporation and others.
+ * Copyright (c) 2003,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,13 +8,19 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
-import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collection;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
@@ -24,15 +28,23 @@ import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.graphics.Point;
public class BuildOptionSettingsPage extends BuildSettingsPage {
- private ArrayList fieldsList = new ArrayList();
+ private Map fieldsMap = new HashMap();
private IOptionCategory category;
+ private boolean isItResourceConfigPage;
- BuildOptionSettingsPage(IConfiguration configuration, IOptionCategory category) {
+ public BuildOptionSettingsPage(IConfiguration configuration, IOptionCategory category) {
// Cache the configuration and option category this page is created for
super(configuration);
this.category = category;
+ isItResourceConfigPage = false;
}
+ public BuildOptionSettingsPage(IResourceConfiguration resConfig, IOptionCategory category) {
+ // Cache the configuration and option category this page is created for
+ super(resConfig);
+ this.category = category;
+ isItResourceConfigPage = true;
+ }
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#computeSize()
*/
@@ -48,60 +60,70 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
super.createFieldEditors();
// Iterate over the options in the category and create a field editor
// for each
- IOption[] options = category.getOptions(configuration);
+ Object[][] options;
+ if ( isItResourceConfigPage ) {
+ options = category.getOptions(resConfig);
+ } else {
+ options = category.getOptions(configuration);
+ }
+
for (int index = 0; index < options.length; ++index) {
// Get the option
- IOption opt = options[index];
- // Figure out which type the option is and add a proper field
- // editor for it
- switch (opt.getValueType()) {
- case IOption.STRING :
- StringFieldEditor stringField = new StringFieldEditor(opt
- .getId(), opt.getName(), getFieldEditorParent());
- addField(stringField);
- fieldsList.add(stringField);
- break;
- case IOption.BOOLEAN :
- BooleanFieldEditor booleanField = new BooleanFieldEditor(
- opt.getId(), opt.getName(), getFieldEditorParent());
- addField(booleanField);
- fieldsList.add(booleanField);
- break;
- case IOption.ENUMERATED :
- String selId;
- String sel;
- try {
- selId = opt.getSelectedEnum();
- sel = opt.getEnumName(selId);
- } catch (BuildException e) {
- // If we get this exception, then the option type is
- // wrong
+ ITool tool = (ITool)options[index][0];
+ if (tool == null) break; // The array may not be full
+ IOption opt = (IOption)options[index][1];
+ try {
+ // Figure out which type the option is and add a proper field
+ // editor for it
+ switch (opt.getValueType()) {
+ case IOption.STRING :
+ StringFieldEditor stringField = new StringFieldEditor(
+ opt.getId(), opt.getName(), getFieldEditorParent());
+ addField(stringField);
+ fieldsMap.put(opt.getId(), stringField);
break;
- }
- BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
- opt.getId(), opt.getName(), opt
- .getApplicableValues(), sel,
- getFieldEditorParent());
- addField(comboField);
- fieldsList.add(comboField);
- break;
- case IOption.INCLUDE_PATH :
- case IOption.STRING_LIST :
- case IOption.PREPROCESSOR_SYMBOLS :
- case IOption.LIBRARIES :
- case IOption.OBJECTS :
- FileListControlFieldEditor listField =
- new FileListControlFieldEditor(
- opt.getId(),
- opt.getName(),
- getFieldEditorParent(),
- opt.getBrowseType());
- addField(listField);
- fieldsList.add(listField);
- break;
- default :
- break;
- }
+ case IOption.BOOLEAN :
+ BooleanFieldEditor booleanField = new BooleanFieldEditor(
+ opt.getId(), opt.getName(), getFieldEditorParent());
+ addField(booleanField);
+ fieldsMap.put(opt.getId(),booleanField);
+ break;
+ case IOption.ENUMERATED :
+ String selId;
+ String sel;
+ try {
+ selId = opt.getSelectedEnum();
+ sel = opt.getEnumName(selId);
+ } catch (BuildException e) {
+ // If we get this exception, then the option type is
+ // wrong
+ break;
+ }
+ BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
+ opt.getId(), opt.getName(), opt
+ .getApplicableValues(), sel,
+ getFieldEditorParent());
+ addField(comboField);
+ fieldsMap.put(opt.getId(), comboField);
+ break;
+ case IOption.INCLUDE_PATH :
+ case IOption.STRING_LIST :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ FileListControlFieldEditor listField =
+ new FileListControlFieldEditor(
+ opt.getId(),
+ opt.getName(),
+ getFieldEditorParent(),
+ opt.getBrowseType());
+ addField(listField);
+ fieldsMap.put(opt.getId(), listField);
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {}
}
}
@@ -126,46 +148,92 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// Write the field editor contents out to the preference store
boolean ok = super.performOk();
// Write the preference store values back to the build model
- IOption[] options = category.getOptions(configuration);
+
+ Object[][] options;
+ if (isItResourceConfigPage){
+ options = category.getOptions(resConfig);
+ } else {
+ options = category.getOptions(configuration);
+ }
+
for (int i = 0; i < options.length; i++) {
- IOption option = options[i];
-
- // Transfer value from preference store to options
- switch (option.getValueType()) {
- case IOption.BOOLEAN :
- boolean boolVal = getPreferenceStore().getBoolean(
- option.getId());
- ManagedBuildManager.setOption(configuration, option,
- boolVal);
- break;
- case IOption.ENUMERATED :
- String enumVal = getPreferenceStore().getString(
- option.getId());
- String enumId = option.getEnumeratedId(enumVal);
- ManagedBuildManager.setOption(configuration, option,
- (enumId.length() > 0) ? enumId : enumVal);
- break;
- case IOption.STRING :
- String strVal = getPreferenceStore().getString(
- option.getId());
- ManagedBuildManager
- .setOption(configuration, option, strVal);
- break;
- case IOption.STRING_LIST :
- case IOption.INCLUDE_PATH :
- case IOption.PREPROCESSOR_SYMBOLS :
- case IOption.LIBRARIES :
- case IOption.OBJECTS :
- String listStr = getPreferenceStore().getString(
- option.getId());
- String[] listVal = BuildToolsSettingsStore
- .parseString(listStr);
- ManagedBuildManager.setOption(configuration, option,
- listVal);
- break;
- default :
- break;
- }
+ ITool tool = (ITool)options[i][0];
+ if (tool == null) break; // The array may not be full
+ IOption option = (IOption)options[i][1];
+ try {
+ // Transfer value from preference store to options
+ IOption setOption;
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = getToolSettingsPreferenceStore().getBoolean(option.getId());
+ if(isItResourceConfigPage) {
+ setOption = ManagedBuildManager.setOption(resConfig, tool, option, boolVal);
+ } else {
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, boolVal);
+ }
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
+ FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
+ fe.setPreferenceName(setOption.getId());
+ }
+ break;
+ case IOption.ENUMERATED :
+ String enumVal = getToolSettingsPreferenceStore().getString(option.getId());
+ String enumId = option.getEnumeratedId(enumVal);
+ if(isItResourceConfigPage) {
+ setOption = ManagedBuildManager.setOption(resConfig, tool, option,
+ (enumId != null && enumId.length() > 0) ? enumId : enumVal);
+ } else {
+ setOption = ManagedBuildManager.setOption(configuration, tool, option,
+ (enumId != null && enumId.length() > 0) ? enumId : enumVal);
+ }
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
+ FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
+ fe.setPreferenceName(setOption.getId());
+ }
+ break;
+ case IOption.STRING :
+ String strVal = getToolSettingsPreferenceStore().getString(option.getId());
+ if(isItResourceConfigPage){
+ setOption = ManagedBuildManager.setOption(resConfig, tool, option, strVal);
+ } else {
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, strVal);
+ }
+
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
+ FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
+ fe.setPreferenceName(setOption.getId());
+ }
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getToolSettingsPreferenceStore().getString(option.getId());
+ String[] listVal = BuildToolsSettingsStore.parseString(listStr);
+ if( isItResourceConfigPage){
+ setOption = ManagedBuildManager.setOption(resConfig, tool, option, listVal);
+ }else {
+ setOption = ManagedBuildManager.setOption(configuration, tool, option, listVal);
+ }
+
+ // Reset the preference store since the Id may have changed
+ if (setOption != option) {
+ getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
+ FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
+ fe.setPreferenceName(setOption.getId());
+ }
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {}
}
return ok;
}
@@ -174,9 +242,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
* Update field editors in this page when the page is loaded.
*/
public void updateFields() {
- for (int i = 0; i < fieldsList.size(); i++) {
- FieldEditor editor = (FieldEditor) fieldsList.get(i);
- editor.loadDefault();
+ Collection fieldsList = fieldsMap.values();
+ Iterator iter = fieldsList.iterator();
+ while (iter.hasNext()) {
+ FieldEditor editor = (FieldEditor) iter.next();
+ // TODO: Why was loadDefault called before load? It results in String fields
+ // setting the "dirty" flag
+ //editor.loadDefault();
editor.load();
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
index bcecbe7b6e7..9e4dfcff147 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
@@ -1,5 +1,3 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
* Copyright (c) 2002,2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
@@ -10,43 +8,36 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Random;
import java.util.Set;
import java.util.SortedMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferencePageContainer;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
@@ -59,137 +50,104 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.help.WorkbenchHelp;
-public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, IPreferencePageContainer {
+public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropertyPage,
+ IPreferencePageContainer, ICOptionContainer {
/*
* String constants
*/
private static final String PREFIX = "BuildPropertyPage"; //$NON-NLS-1$
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
- private static final String NAME_LABEL = LABEL + ".NameText"; //$NON-NLS-1$
- private static final String BUILD_TOOLS_LABEL = LABEL + ".BuildToolTree"; //$NON-NLS-1$
private static final String PLATFORM_LABEL = LABEL + ".Platform"; //$NON-NLS-1$
private static final String CONFIG_LABEL = LABEL + ".Configuration"; //$NON-NLS-1$
private static final String ALL_CONFS = PREFIX + ".selection.configuration.all"; //$NON-NLS-1$
private static final String ACTIVE_LABEL = LABEL + ".Active"; //$NON-NLS-1$
private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$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 ADD_CONF = LABEL + ".AddConfButton"; //$NON-NLS-1$
private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
private static final String PLAT_TIP = TIP + ".platform"; //$NON-NLS-1$
private static final String CONF_TIP = TIP + ".config"; //$NON-NLS-1$
private static final String ADD_TIP = TIP + ".addconf"; //$NON-NLS-1$
private static final String MANAGE_TITLE = PREFIX + ".manage.title"; //$NON-NLS-1$
- private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
+ private static final String MSG_CLOSEDPROJECT = "MngMakeProjectPropertyPage.closedproject"; //$NON-NLS-1$
/*
* Dialog widgets
*/
- private Combo targetSelector;
+ private Combo projectTypeSelector;
private Combo configSelector;
private Button manageConfigs;
- private TreeViewer optionList;
- private SashForm sashForm;
- private Group sashGroup;
- private Composite settingsPageContainer;
- private ScrolledComposite containerSC;
/*
* Bookeeping variables
*/
- private ITarget [] targets;
- private ITarget selectedTarget;
- private IConfiguration [] configurations;
+ private IProjectType[] projectTypes;
+ private IProjectType selectedProjectType;
+ private IConfiguration[] configurations;
private IConfiguration selectedConfiguration;
- private BuildSettingsPage currentSettingsPage;
- private Map configToPageListMap;
- private BuildToolsSettingsStore settingsStore;
- private Map settingsStoreMap;
- private IOptionCategory selectedCategory;
private Point lastShellSize;
- private ITool selectedTool;
-
- /**
- * The minimum page size; 200 by 200 by default.
- *
- * @see #setMinimumPageSize
- */
- private Point minimumPageSize = new Point(200, 200);
- private ToolListContentProvider provider;
-
- /**
- * Layout for the page container.
- *
- */
- private class PageLayout extends Layout {
- public void layout(Composite composite, boolean force) {
- Rectangle rect = composite.getClientArea();
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- children[i].setSize(rect.width, rect.height);
- }
- }
- public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
- return new Point(wHint, hHint);
- }
- int x = minimumPageSize.x;
- int y = minimumPageSize.y;
-
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
- x = Math.max(x, size.x);
- y = Math.max(y, size.y);
- }
- if (wHint != SWT.DEFAULT) {
- x = wHint;
- }
- if (hHint != SWT.DEFAULT) {
- y = hHint;
- }
- return new Point(x, y);
- }
- }
+ protected ManagedBuildOptionBlock fOptionBlock;
+ protected boolean displayedConfig = false;
/**
* Default constructor
*/
public BuildPropertyPage() {
- configToPageListMap = new HashMap();
+ super();
}
+ public void setContainer(IPreferencePageContainer preferencePageContainer) {
+ super.setContainer(preferencePageContainer);
+ if (fOptionBlock == null) {
+ fOptionBlock = new ManagedBuildOptionBlock(this);
+ }
+ }
+
protected Control createContents(Composite parent) {
// Create the container we return to the property page editor
Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
- composite.setLayout(new GridLayout(1, true));
+ GridLayout compositeLayout = new GridLayout();
+ compositeLayout.numColumns = 1;
+ compositeLayout.marginHeight = 0;
+ compositeLayout.marginWidth = 0;
+ composite.setLayout( compositeLayout );
+
+ IProject project = getProject();
+ if (!project.isOpen()) {
+ contentForClosedProject(composite);
+ } else {
+ contentForCProject(composite);
+ }
+
+ return composite;
+ }
+
+ private void contentForCProject(Composite parent) {
GridData gd;
// Initialize the key data
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
if (info.getVersion() == null) {
// Display a message page instead of the properties control
- final Label invalidInfo = new Label(composite, SWT.LEFT);
- invalidInfo.setFont(composite.getFont());
+ final Label invalidInfo = new Label(parent, SWT.LEFT);
+ invalidInfo.setFont(parent.getFont());
invalidInfo.setText(ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.error.version_low")); //$NON-NLS-1$
invalidInfo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_CENTER, true, true));
- return composite;
+ return;
}
- targets = ManagedBuildManager.getTargets(getProject());
- ITarget defaultTarget = info.getDefaultTarget();
-
+ projectTypes = ManagedBuildManager.getDefinedProjectTypes();
+ IProjectType defaultProjectType = info.getManagedProject().getProjectType();
// Add a config selection area
- Group configGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(ACTIVE_LABEL), 1);
+ Group configGroup = ControlFactory.createGroup(parent, ManagedBuilderUIMessages.getResourceString(ACTIVE_LABEL), 1);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.grabExcessHorizontalSpace = true;
configGroup.setLayoutData(gd);
@@ -200,13 +158,15 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
configGroup.setLayout(form);
Label platformLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(PLATFORM_LABEL));
- targetSelector = ControlFactory.createSelectCombo(configGroup, getPlatformNames(), defaultTarget.getName());
- targetSelector.addListener(SWT.Selection, new Listener () {
+ projectTypeSelector = ControlFactory.createSelectCombo(configGroup, getPlatformNames(), defaultProjectType.getName());
+ // Note: Changing the project type is not currently handled, so this widget is disabled
+ projectTypeSelector.setEnabled(false);
+ projectTypeSelector.addListener(SWT.Selection, new Listener () {
public void handleEvent(Event e) {
- handleTargetSelection();
+ handleProjectTypeSelection();
}
});
- targetSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(PLAT_TIP));
+ projectTypeSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(PLAT_TIP));
Label configLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(CONFIG_LABEL));
configSelector = new Combo(configGroup, SWT.READ_ONLY|SWT.DROP_DOWN);
configSelector.addListener(SWT.Selection, new Listener () {
@@ -225,7 +185,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// Now do the form layout for the widgets
FormData fd = new FormData();
// Anchor the labels in the centre of their respective combos
- fd.top = new FormAttachment(targetSelector, 0, SWT.CENTER);
+ fd.top = new FormAttachment(projectTypeSelector, 0, SWT.CENTER);
platformLabel.setLayoutData(fd);
fd = new FormData();
fd.top = new FormAttachment(configSelector, 0, SWT.CENTER);
@@ -234,7 +194,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
fd = new FormData();
fd.left = new FormAttachment(configSelector, 0, SWT.LEFT);
fd.right = new FormAttachment(100, 0);
- targetSelector.setLayoutData(fd);
+ projectTypeSelector.setLayoutData(fd);
// Anchor button right to combo and left to group
fd = new FormData();
fd.top = new FormAttachment(configSelector, 0, SWT.CENTER);
@@ -247,201 +207,105 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
fd.top = new FormAttachment(55,0);
fd.right = new FormAttachment(manageConfigs, -5 , SWT.LEFT);
configSelector.setLayoutData(fd);
-
- // Create the sash form
- sashGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL), 1);
- sashGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
- sashForm = new SashForm(sashGroup, SWT.NONE);
- sashForm.setOrientation(SWT.HORIZONTAL);
- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- sashForm.setLayout(layout);
- createSelectionArea(sashForm);
- createEditArea(sashForm);
- initializeSashForm();
+ // Create the Tools Settings, Build Settings, ... Tabbed pane
+ Group tabGroup = ControlFactory.createGroup(parent, ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL), 1);
+ gd = new GridData(GridData.FILL_BOTH);
+ tabGroup.setLayoutData(gd);
+ fOptionBlock.createContents(tabGroup, getElement());
// Do not call this until the widgets are constructed
- handleTargetSelection();
+ handleProjectTypeSelection();
- WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
- return composite;
+ WorkbenchHelp.setHelp(parent, ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
+ }
+
+ private void contentForClosedProject(Composite parent) {
+ Label label = new Label(parent, SWT.LEFT);
+ label.setText(ManagedBuilderUIMessages.getResourceString(MSG_CLOSEDPROJECT));
+ label.setFont(parent.getFont());
+
+ noDefaultAndApplyButton();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+
+ // 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);
+ }
+ };
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, true, op);
+ } catch (InvocationTargetException e) {
+ Throwable e1 = e.getTargetException();
+ ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
+ return false;
+ } catch (InterruptedException e) {
+ // cancelled
+ return false;
+ }
+
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
+ ManagedBuildManager.saveBuildInfo(getProject(), false);
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ fOptionBlock.performDefaults();
+ super.performDefaults();
}
+ private String [] getPlatformNames() {
+ String [] names = new String[projectTypes.length];
+ for (int index = 0; index < projectTypes.length; ++index) {
+ names[index] = projectTypes[index].getName();
+ }
+ return names;
+ }
+
/* (non-Javadoc)
- * Add the tabs relevant to the project to edit area tab folder.
+ * @return
*/
- protected void createEditArea(Composite parent) {
- containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- containerSC.setExpandHorizontal(true);
- containerSC.setExpandVertical(true);
-
- // Add a container for the build settings page
- settingsPageContainer = new Composite(containerSC, SWT.NULL);
- settingsPageContainer.setLayout(new PageLayout());
-
- containerSC.setContent(settingsPageContainer);
- containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- settingsPageContainer.layout();
+ public IProjectType getSelectedProjectType() {
+ return selectedProjectType;
}
-
- protected void createSelectionArea (Composite parent) {
- // Create a label and list viewer
- Composite composite = ControlFactory.createComposite(parent, 1);
- optionList = new TreeViewer(composite, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
- optionList.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- handleOptionSelection();
- }
- });
- optionList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- optionList.setLabelProvider(new ToolListLabelProvider());
+
+ private void populateConfigurations() {
+ // If the config select widget is not there yet, just stop
+ if (configSelector == null) return;
+
+ // Find the configurations defined for the platform
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ configurations = info.getManagedProject().getConfigurations();
+ if (configurations.length == 0) return;
+
+ // Clear and replace the contents of the selector widget
+ configSelector.removeAll();
+ configSelector.setItems(getConfigurationNames());
+
+ // Make sure the active configuration is selected
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ int index = configSelector.indexOf(defaultConfig.getName());
+ configSelector.select(index == -1 ? 0 : index);
+ handleConfigSelection();
}
/* (non-Javadoc)
- * Method displayOptionsForTool.
- * @param toolReference
- */
- private void displayOptionsForCategory(IOptionCategory category) {
- // Do nothing if the selected category is is unchanged
- if (category == selectedCategory) {
- return;
- }
- selectedTool = null;
- selectedCategory = category;
-
- // Cache the current build setting page
- BuildSettingsPage oldPage = currentSettingsPage;
- currentSettingsPage = null;
-
- // Create a new settings page if necessary
- List pages = getPagesForConfig();
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page instanceof BuildOptionSettingsPage &&
- ((BuildOptionSettingsPage)page).isForCategory(category)) {
- currentSettingsPage = page;
- break;
- }
- }
- if (currentSettingsPage == null) {
- currentSettingsPage = new BuildOptionSettingsPage(selectedConfiguration, category);
- pages.add(currentSettingsPage);
- currentSettingsPage.setContainer(this);
- if (currentSettingsPage.getControl() == null) {
- currentSettingsPage.createControl(settingsPageContainer);
- }
- }
-
- // Make all the other pages invisible
- Control[] children = settingsPageContainer.getChildren();
- Control currentControl = currentSettingsPage.getControl();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != currentControl)
- children[i].setVisible(false);
- }
- 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.
- if (oldPage != null){
- if(oldPage instanceof BuildOptionSettingsPage) {
- ((BuildOptionSettingsPage)oldPage).storeSettings();
- }
- else if(oldPage instanceof BuildToolSettingsPage) {
- ((BuildToolSettingsPage)oldPage).storeSettings();
- ((BuildToolSettingsPage)oldPage).parseAllOptions();
- }
- }
- //update the field editors in the current page
- if(currentSettingsPage instanceof BuildOptionSettingsPage)
- ((BuildOptionSettingsPage)currentSettingsPage).updateFields();
-
- if (oldPage != null)
- oldPage.setVisible(false);
-
- // Set the size of the scrolled area
- containerSC.setMinSize(currentSettingsPage.computeSize());
- settingsPageContainer.layout();
- }
-
- /* (non-Javadoc)
- * @param tool
- */
- private void displayOptionsForTool(ITool tool) {
- if (tool == selectedTool) {
- return;
- }
- // Unselect the category
- selectedCategory = null;
- // record that the tool selection has changed
- selectedTool = tool;
-
- // Cache the current build setting page
- BuildSettingsPage oldPage = currentSettingsPage;
- currentSettingsPage = null;
-
- // Create a new page if we need one
- List pages = getPagesForConfig();
- ListIterator iter = pages.listIterator();
- while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page instanceof BuildToolSettingsPage &&
- ((BuildToolSettingsPage)page).isForTool(tool)) {
- currentSettingsPage = page;
- break;
- }
- }
- if (currentSettingsPage == null) {
- currentSettingsPage = new BuildToolSettingsPage(selectedConfiguration, tool);
- pages.add(currentSettingsPage);
- currentSettingsPage.setContainer(this);
- if (currentSettingsPage.getControl() == null) {
- currentSettingsPage.createControl(settingsPageContainer);
- }
- }
- // Make all the other pages invisible
- Control[] children = settingsPageContainer.getChildren();
- Control currentControl = currentSettingsPage.getControl();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != currentControl)
- children[i].setVisible(false);
- }
-
- // 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.
- if (oldPage != null){
- if(oldPage instanceof BuildOptionSettingsPage) {
- ((BuildOptionSettingsPage)oldPage).storeSettings();
- }
- else if(oldPage instanceof BuildToolSettingsPage) {
- ((BuildToolSettingsPage)oldPage).storeSettings();
- ((BuildToolSettingsPage)oldPage).parseAllOptions();
- }
- }
- //update the field editor that displays all the build options
- if(currentSettingsPage instanceof BuildToolSettingsPage)
- ((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField();
-
- if (oldPage != null)
- oldPage.setVisible(false);
-
- // Set the size of the scrolled area
- containerSC.setMinSize(currentSettingsPage.computeSize());
- settingsPageContainer.layout();
- }
-
- /* (non-Javadoc)
- * @return an array of names for the configurations defined for the chosen target
+ * @return an array of names for the configurations defined for the chosen
*/
private String [] getConfigurationNames () {
String [] names = new String[configurations.length /*+ 1*/];
@@ -451,6 +315,17 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// names[names.length - 1] = ManagedBuilderUIPlugin.getResourceString(ALL_CONFS);
return names;
}
+
+ public void enableConfigSelection (boolean enable) {
+ configSelector.setEnabled(enable);
+ }
+
+ /* (non-Javadoc)
+ * @return
+ */
+ public IConfiguration getSelectedConfiguration() {
+ return selectedConfiguration;
+ }
/* (non-Javadoc)
* @return
@@ -464,462 +339,59 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
return lastShellSize;
}
- /* (non-Javadoc)
- * Answers the list of settings pages for the selected configuration
- * @return
- */
- private List getPagesForConfig() {
- // Make sure that something was selected
- if (selectedConfiguration == null) {
- return null;
- }
- List pages = (List) configToPageListMap.get(selectedConfiguration.getId());
- if (pages == null) {
- pages = new ArrayList();
- configToPageListMap.put(selectedConfiguration.getId(), pages);
- }
- return pages;
- }
-
- private String [] getPlatformNames() {
- String [] names = new String[targets.length];
- for (int index = 0; index < targets.length; ++index) {
- names[index] = targets[index].getName();
- }
- return names;
- }
-
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePageContainer#getPreferenceStore()
*/
public IPreferenceStore getPreferenceStore()
{
- return settingsStore;
+ return fOptionBlock.getPreferenceStore();
}
- private IProject getProject() {
+ /* (non-Javadoc)
+ * Return the IPreferenceStore of the Tool Settings block
+ */
+ public IPreferenceStore getToolSettingsPreferenceStore()
+ {
+ return fOptionBlock.getToolSettingsPreferenceStore();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialog.ICOptionContainer.getPreferences()
+ */
+ public Preferences getPreferences()
+ {
+ return null;
+ }
+
+ public IProject getProject() {
Object element= getElement();
if (element != null && element instanceof IProject) {
return (IProject)element;
}
return null;
}
-
- /* (non-Javadoc)
- * @return
- */
- public ITarget getSelectedTarget() {
- return selectedTarget;
- }
-
- /* (non-Javadoc)
- * @return
- */
- protected IConfiguration getSelectedConfiguration() {
- return selectedConfiguration;
- }
-
- /* (non-Javadoc)
- * Safe accessor method
- *
- * @return Returns the Map of configurations to preference stores.
- */
- protected Map getSettingsStoreMap() {
- if (settingsStoreMap == null) {
- settingsStoreMap = new HashMap();
- }
- return settingsStoreMap;
- }
- /*
- * Event Handlers
- */
- private void handleConfigSelection () {
- // If there is nothing in config selection widget just bail
- if (configSelector.getItemCount() == 0) return;
-
- // Check if the user has selected the "all" configuration
- int selectionIndex = configSelector.getSelectionIndex();
- if (selectionIndex == -1) return;
- String configName = configSelector.getItem(selectionIndex);
- if (configName.equals(ManagedBuilderUIMessages.getResourceString(ALL_CONFS))) {
- // This is the all config
- return;
- } else {
- // Cache the selected config
- selectedConfiguration = configurations[selectionIndex];
- }
-
- if (provider == null) {
- provider = new ToolListContentProvider();
- optionList.setContentProvider(provider);
- }
- optionList.setInput(selectedConfiguration);
- optionList.expandAll();
-
- // Create (or retrieve) the settings store for the configuration
- BuildToolsSettingsStore store = (BuildToolsSettingsStore) getSettingsStoreMap().get(selectedConfiguration.getId());
- if (store == null) {
- store = new BuildToolsSettingsStore(selectedConfiguration);
- getSettingsStoreMap().put(selectedConfiguration.getId(), store);
- }
- settingsStore = store;
-
- // Select the first tool in the list
- Object[] elements = provider.getElements(selectedConfiguration);
- Object primary = elements.length > 0 ? elements[0] : null;
-
-/* if (primary != null && primary instanceof ITool) {
- // set the tool as primary selection in the tree hence it displays all the build options.
- ITool tool = (ITool)primary;
- IOptionCategory top = tool.getTopOptionCategory();
- IOption[] topOpts = top.getOptions(selectedConfiguration);
- if (topOpts != null && topOpts.length == 0) {
- // Get the children categories and start looking
- IOptionCategory[] children = top.getChildCategories();
- for (int i = 0; i < children.length; i++) {
- IOptionCategory category = children[i];
- IOption[] catOpts = category.getOptions(selectedConfiguration);
- if (catOpts != null && catOpts.length > 0) {
- primary = category;
- break;
- }
- }
- }
- }
-*/
- if (primary != null) {
- optionList.setSelection(new StructuredSelection(primary));
- }
- }
-
- // Event handler for the manage configuration button event
- private void handleManageConfig () {
- ManageConfigDialog manageDialog = new ManageConfigDialog(getShell(), ManagedBuilderUIMessages.getResourceString(MANAGE_TITLE), selectedTarget);
- if (manageDialog.open() == ManageConfigDialog.OK) {
- boolean updateConfigs = false;
-
- // Get the build output name
- String newBuildOutput = manageDialog.getBuildArtifactName();
- if (!selectedTarget.getArtifactName().equals(newBuildOutput)) {
- selectedTarget.setArtifactName(newBuildOutput);
- }
- String newBuildExt = manageDialog.getBuildArtifaceExtension();
- if (!selectedTarget.getArtifactExtension().equals(newBuildExt)) {
- selectedTarget.setArtifactExtension(newBuildExt);
- }
-
- // Get the new make command
- if (manageDialog.useDefaultMakeCommand()) {
- // This is a cheap assignment to null so do it to be doubly sure
- selectedTarget.resetMakeCommand();
- } else {
- // Parse for command and arguments
- String rawCommand = manageDialog.getMakeCommand();
- String makeCommand = parseMakeCommand(rawCommand);
- selectedTarget.setMakeCommand(makeCommand);
- String makeArguments = parseMakeArgs(rawCommand);
- selectedTarget.setMakeArguments(makeArguments);
- }
-
- // Check to see if any configurations have to be deleted
- List deletedConfigs = manageDialog.getDeletedConfigIds();
- Iterator iter = deletedConfigs.listIterator();
- while (iter.hasNext()) {
- String id = (String)iter.next();
-
- // Remove the configurations from the target
- selectedTarget.removeConfiguration(id);
-
- // Remove any settings stores
- getSettingsStoreMap().remove(id);
-
- // Clean up the UI
- configurations = selectedTarget.getConfigurations();
- configSelector.removeAll();
- configSelector.setItems(getConfigurationNames());
- configSelector.select(0);
- updateConfigs = true;
- }
-
- // Check to see if any have to be added
- SortedMap newConfigs = manageDialog.getNewConfigs();
- Set keys = newConfigs.keySet();
- Iterator keyIter = keys.iterator();
- Random r = new Random();
- r.setSeed(System.currentTimeMillis());
- while (keyIter.hasNext()) {
- String name = (String) keyIter.next();
- IConfiguration parent = (IConfiguration) newConfigs.get(name);
- if (parent != null) {
- int id = r.nextInt();
- if (id < 0) {
- id *= -1;
- }
-
- // Create ID for the new component based on the parent ID and random component
- String newId = parent.getId();
- int index = newId.lastIndexOf(ID_SEPARATOR);
- if (index > 0) {
- String lastComponent = newId.substring(index + 1, newId.length());
- if (Character.isDigit(lastComponent.charAt(0))) {
- // Strip the last component
- newId = newId.substring(0, index);
- }
- }
- newId += ID_SEPARATOR + id;
- IConfiguration newConfig = selectedTarget.createConfiguration(parent, newId);
- newConfig.setName(name);
- // Update the config lists
- configurations = selectedTarget.getConfigurations();
- configSelector.removeAll();
- configSelector.setItems(getConfigurationNames());
- configSelector.select(configSelector.indexOf(name));
- updateConfigs = true;
- }
- }
- if (updateConfigs){
- handleConfigSelection();
- }
- }
- return;
- }
-
- private void handleOptionSelection() {
- // Get the selection from the tree list
- IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
- // Set the option page based on the selection
- Object element = selection.getFirstElement();
- if (element instanceof ITool) {
- displayOptionsForTool((ITool)element);
- } else if (element instanceof IOptionCategory) {
- displayOptionsForCategory((IOptionCategory)element);
- }
+ public void updateContainer() {
+ fOptionBlock.update();
+ setValid(fOptionBlock.isValid());
+ setErrorMessage(fOptionBlock.getErrorMessage());
}
- private void handleTargetSelection() {
- // Is there anything in the selector widget
- if (targetSelector.getItemCount() == 0) {
- manageConfigs.setEnabled(false);
- return;
- }
-
- // Enable the manage button
- manageConfigs.setEnabled(true);
-
- // Cache the platform at the selection index
- selectedTarget = targets[targetSelector.getSelectionIndex()];
- ManagedBuildManager.setSelectedTarget(getProject(), selectedTarget);
-
- // Update the contents of the configuration widget
- populateConfigurations();
+ public boolean isValid() {
+ updateContainer();
+ return super.isValid();
}
- /*
- * (non-javadoc)
- * Initialize the relative weights (widths) of the 2 sides of the sash.
+ /**
+ * @see DialogPage#setVisible(boolean)
*/
- protected void initializeSashForm() {
- sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
- }
-
- /* (non-Javadoc)
- * @param rawCommand
- * @return
- */
- private String parseMakeArgs(String rawCommand) {
- StringBuffer result = new StringBuffer();
-
- // Parse out the command
- String actualCommand = parseMakeCommand(rawCommand);
-
- // The flags and targets are anything not in the command
- String arguments = rawCommand.substring(actualCommand.length());
-
- // If there aren't any, we can stop
- if (arguments.length() == 0) {
- return result.toString().trim();
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ fOptionBlock.setVisible(visible);
+ if (visible) {
+ fOptionBlock.updateValues();
+ displayedConfig = true;
}
-
- String[] tokens = arguments.trim().split("\\s"); //$NON-NLS-1$
- /*
- * Cases to consider
- * --
IConfiguration
.
* The name is selected by the user and should be unique for the target
@@ -456,28 +276,18 @@ public class ManageConfigDialog extends Dialog {
}
/*
- * @return the IProject
associated with the target
+ * @return the IProject
associated with the managed project
*/
private IProject getProject() {
- return managedTarget.getOwner().getProject();
+ return (IProject)managedProject.getOwner();
}
/*
* Event handler for the add button
*/
protected void handleNewPressed() {
- // Find the defined target
- ITarget parentTarget = null;
- ITarget [] targets = ManagedBuildManager.getDefinedTargets(getProject());
- for (int i = 0; i < targets.length; i++) {
- ITarget target = targets[i];
- if (target.getId().equals(managedTarget.getParent().getId())) {
- parentTarget = target;
- break;
- }
- }
NewConfigurationDialog dialog = new NewConfigurationDialog(getShell(),
- managedTarget,
+ managedProject,
ManagedBuilderUIMessages.getResourceString(CONF_DLG));
if (dialog.open() == NewConfigurationDialog.OK) {
// Get the new name and configuration to base the new config on
@@ -535,7 +345,7 @@ public class ManageConfigDialog extends Dialog {
// If this was a new config (it won't be in the existing list) then add it back there
if (!getExistingConfigs().containsKey(selectedConfigName)) {
- IConfiguration restoredConfig = managedTarget.getConfiguration(selectedConfigId);
+ IConfiguration restoredConfig = managedProject.getConfiguration(selectedConfigId);
getNewConfigs().put(selectedConfigName, restoredConfig);
}
@@ -551,46 +361,10 @@ public class ManageConfigDialog extends Dialog {
}
}
- /* (non-Javadoc)
- * Event handler for the use default check box in the make command group
- */
- protected void handleUseDefaultPressed() {
- // If the state of the button is unchecked, then we want to enable the edit widget
- boolean checked = makeCommandDefault.getSelection();
- if (checked == true) {
- managedTarget.resetMakeCommand();
- setMakeCommand();
- makeCommandEntry.setText(makeCommand);
- makeCommandEntry.setEditable(false);
- } else {
- makeCommandEntry.setEditable(true);
- }
- }
-
- /*
- *
- */
- private void setMakeCommand() {
- // Figure out the make command
- makeCommand = managedTarget.getMakeCommand();
- String makeArgs = managedTarget.getMakeArguments();
- if (makeArgs.length() > 0) {
- makeCommand += " " + makeArgs; //$NON-NLS-1$
- }
- }
-
private void updateButtons() {
// Disable the remove button if there is only 1 configuration
removeBtn.setEnabled(currentConfigList.getItemCount() > 1);
// Enable the restore button if there is anything in the deleted list
restoreBtn.setEnabled(deletedConfigList.getItemCount() > 0);
}
-
- /**
- * Answers true
if the user has left the use default check box selected.
- * @return
- */
- public boolean useDefaultMakeCommand () {
- return useDefaultMake;
- }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManagedBuilderPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManagedBuilderPropertyPage.java
deleted file mode 100644
index a8d27fab4a6..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ManagedBuilderPropertyPage.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 Corporation - initial API and implementation
- * Intel Corp - use in Managed Make system
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedProjectOptionBlock;
-import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
-import org.eclipse.cdt.managedbuilder.internal.ui.ErrorParserBlock;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferencePageContainer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public class ManagedBuilderPropertyPage extends PropertyPage implements ICOptionContainer {
-
- protected ManagedProjectOptionBlock fOptionBlock;
- protected ITarget displayedTarget;
-
- private static final String MSG_CLOSEDPROJECT = "MngMakeProjectPropertyPage.closedproject"; //$NON-NLS-1$
-
- public ManagedBuilderPropertyPage() {
- super();
- }
-
- public void setContainer(IPreferencePageContainer preferencePageContainer) {
- super.setContainer(preferencePageContainer);
- if (fOptionBlock == null) {
- fOptionBlock = new ManagedProjectOptionBlock(this);
- }
- }
-
- protected Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new FillLayout());
-
- IProject project = getProject();
- if (!project.isOpen()) {
- contentForClosedProject(composite);
- } else {
- contentForCProject(composite);
- }
-
- return composite;
- }
-
- private void contentForCProject(Composite parent) {
- fOptionBlock.createContents(parent);
- // WorkbenchHelp.setHelp(parent, ICMakeHelpContextIds.PROJECT_PROPERTY_PAGE);
- }
-
- private void contentForClosedProject(Composite parent) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(ManagedBuilderUIMessages.getResourceString(MSG_CLOSEDPROJECT));
- label.setFont(parent.getFont());
-
- noDefaultAndApplyButton();
- }
-
- /**
- * @see PreferencePage#performOk
- */
- public boolean performOk() {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- fOptionBlock.performApply(monitor);
- }
- };
-
- // If the user did not come to this page when the current selected target
- // was the selected target, then there is nothing to do. The page was either
- // never visited, or was visited for another target.
- ITarget target = getSelectedTarget();
- if (target != displayedTarget) return true;
-
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
- try {
- new ProgressMonitorDialog(getShell()).run(false, true, op);
- } catch (InvocationTargetException e) {
- Throwable e1 = e.getTargetException();
- ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
- return false;
- } catch (InterruptedException e) {
- // cancelled
- return false;
- }
-
- // Write out the build model info
- IProject project = getProject();
- ManagedBuildManager.saveBuildInfo(project, false);
- return true;
- }
-
- public IProject getProject() {
- Object element = getElement();
- if (element instanceof IProject) {
- return (IProject) element;
- }
- return null;
- }
-
- /**
- * @see DialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- fOptionBlock.setVisible(visible);
- if (visible) {
- ErrorParserBlock errorParsers = fOptionBlock.getErrorParserBlock();
- errorParsers.updateValues();
- displayedTarget = getSelectedTarget();
- }
- }
-
- protected ITarget getSelectedTarget() {
- // If the selected target is not yet set, set it to the default target
- // The selected target is needed for saving error parser information
- IProject project = getProject();
- ITarget target = ManagedBuildManager.getSelectedTarget(project);
- if (target == null) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- target = info.getDefaultTarget();
- ManagedBuildManager.setSelectedTarget(project, target);
- }
- return target;
- }
-
- public void updateContainer() {
- fOptionBlock.update();
- setValid(fOptionBlock.isValid());
- setErrorMessage(fOptionBlock.getErrorMessage());
- }
-
- protected void performDefaults() {
- fOptionBlock.performDefaults();
- super.performDefaults();
- }
-
- public boolean isValid() {
- updateContainer();
- return super.isValid();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferences()
- */
- public Preferences getPreferences() {
- return null;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
index 082e15c71ea..0d15f977758 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2003,2004 IBM Rational Software Corporation and others.
+ * Copyright (c) 2003,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,9 +8,11 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -59,7 +59,7 @@ public class NewConfigurationDialog extends Dialog {
private IConfiguration[] defaultConfigs;
private IConfiguration[] definedConfigs;
private IConfiguration parentConfig;
- private ITarget target;
+ private IManagedProject managedProject;
private String newName;
private String title = ""; //$NON-NLS-1$
@@ -67,21 +67,21 @@ public class NewConfigurationDialog extends Dialog {
/**
* @param parentShell
*/
- protected NewConfigurationDialog(Shell parentShell, ITarget managedTarget, String title) {
+ protected NewConfigurationDialog(Shell parentShell, IManagedProject managedProject, String title) {
super(parentShell);
this.title = title;
setShellStyle(getShellStyle()|SWT.RESIZE);
newName = new String();
parentConfig = null;
- this.target = managedTarget;
+ this.managedProject = managedProject;
// The default behaviour is to clone the settings
clone = true;
// Populate the list of default and defined configurations
- definedConfigs = target.getConfigurations();
- ITarget grandparent = target.getParent();
- defaultConfigs = grandparent.getConfigurations();
+ definedConfigs = managedProject.getConfigurations();
+ IProjectType projectType = managedProject.getProjectType();
+ defaultConfigs = projectType.getConfigurations();
}
/* (non-Javadoc)
@@ -242,7 +242,7 @@ public class NewConfigurationDialog extends Dialog {
}
/*
- * Returns the array of configuration names defined for all targets
+ * Returns the array of configuration names defined for all projects
* of this type in the plugin manifest. This list will be used to
* populate the the configurations to copy default settings from.
*/
@@ -256,7 +256,7 @@ public class NewConfigurationDialog extends Dialog {
}
/*
- * Returns the array of configuration names defined for this target.
+ * Returns the array of configuration names defined for this managed project.
* This list will be used to populate the list of configurations to
* clone.
*/
@@ -285,11 +285,11 @@ public class NewConfigurationDialog extends Dialog {
* @return
*/
protected boolean isDuplicateName(String newName) {
- // Return true if there is already a config of that name defined on the target
- IConfiguration [] configs = target.getConfigurations();
+ // Return true if there is already a config of that name defined
+ IConfiguration [] configs = managedProject.getConfigurations();
for (int index = 0; index < configs.length; index++) {
IConfiguration configuration = configs[index];
- if (configuration.getName() == newName) {
+ if (configuration.getName().equals(newName)) {
return true;
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java
new file mode 100644
index 00000000000..1d52e20fd44
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java
@@ -0,0 +1,487 @@
+/**********************************************************************
+ * 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.managedbuilder.ui.properties;
+
+import java.lang.reflect.InvocationTargetException;
+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.internal.ui.ManagedBuildOptionBlock;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+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.IProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+
+public class ResourceBuildPropertyPage extends PropertyPage implements
+ IWorkbenchPropertyPage, IPreferencePageContainer, ICOptionContainer {
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "ResourceBuildPropertyPage"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String NAME_LABEL = LABEL + ".NameText"; //$NON-NLS-1$
+ private static final String CONFIG_LABEL = LABEL + ".Configuration"; //$NON-NLS-1$
+ private static final String ALL_CONFS = PREFIX + ".selection.configuration.all"; //$NON-NLS-1$
+ private static final String ACTIVE_RESOURCE_LABEL = LABEL + ".ActiveResource"; //$NON-NLS-1$
+ 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 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$
+ private static final String CONF_TIP = TIP + ".config"; //$NON-NLS-1$
+ private static final String EXCLUDE_TIP = TIP + ".excludecheck"; //$NON-NLS-1$
+ private static final String MANAGE_TITLE = PREFIX + ".manage.title"; //$NON-NLS-1$
+ private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
+ private static final String ID_SEPARATOR = "."; //$NON-NLS-1$
+
+ /*
+ * Dialog widgets
+ */
+
+ private Combo configSelector;
+
+// private Point lastShellSize;
+ private Button excludedCheckBox;
+ private boolean isExcluded = false;
+
+ /*
+ * Bookeeping variables
+ */
+
+
+ private IConfiguration[] configurations;
+ private IConfiguration selectedConfiguration;
+ private IResourceConfiguration currentResourceConfig;
+ private Point lastShellSize;
+ protected ManagedBuildOptionBlock fOptionBlock;
+ protected boolean displayedConfig = false;
+ /**
+ * Default constructor
+ */
+ public ResourceBuildPropertyPage() {
+ // super();
+ }
+
+ public void setContainer(IPreferencePageContainer preferencePageContainer) {
+ super.setContainer(preferencePageContainer);
+ if (fOptionBlock == null) {
+ fOptionBlock = new ManagedBuildOptionBlock(this);
+ }
+ }
+
+ 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());
+ GridLayout compositeLayout = new GridLayout();
+ compositeLayout.numColumns = 1;
+ compositeLayout.marginHeight = 0;
+ compositeLayout.marginWidth = 0;
+ composite.setLayout( compositeLayout );
+
+// Initialize the key data
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ if (info.getVersion() == null) {
+ // Display a message page instead of the properties control
+ final Label invalidInfo = new Label(composite, SWT.LEFT);
+ 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
+ Group configGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(ACTIVE_RESOURCE_LABEL), 1);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.grabExcessHorizontalSpace = true;
+ configGroup.setLayoutData(gd);
+ // Use the form layout inside the group composite
+ FormLayout form = new FormLayout();
+ form.marginHeight = 5;
+ form.marginWidth = 5;
+ configGroup.setLayout(form);
+
+ excludedCheckBox = ControlFactory.createCheckBox(configGroup, ManagedBuilderUIMessages.getResourceString(EXCLUDE_CHECKBOX));
+ excludedCheckBox.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ handleIsExcluded();
+ }
+ });
+ excludedCheckBox.setToolTipText(ManagedBuilderUIMessages.getResourceString(EXCLUDE_TIP));
+
+ FormData fd = new FormData();
+ fd = new FormData();
+ fd.left = new FormAttachment(excludedCheckBox, 0, SWT.CENTER);
+ excludedCheckBox.setLayoutData(fd);
+
+ Label configLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIMessages.getResourceString(CONFIG_LABEL));
+ configSelector = new Combo(configGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
+ configSelector.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ handleConfigSelection();
+ }
+ });
+ configSelector.setToolTipText(ManagedBuilderUIMessages.getResourceString(CONF_TIP));
+
+ // Now do the form layout for the widgets
+
+ fd = new FormData();
+ fd.top = new FormAttachment(excludedCheckBox, 15, SWT.DEFAULT);
+
+ configLabel.setLayoutData(fd);
+
+ fd = new FormData();
+ fd.top = new FormAttachment(excludedCheckBox, 15, SWT.DEFAULT);
+ fd.left = new FormAttachment(configLabel, 5, SWT.DEFAULT);
+ fd.right = new FormAttachment(80, -20);
+ configSelector.setLayoutData(fd);
+
+// Create the Tools Settings, Build Settings, ... Tabbed pane
+ Group tabGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(RESOURCE_SETTINGS_LABEL), 1);
+ gd = new GridData(GridData.FILL_BOTH);
+ tabGroup.setLayoutData(gd);
+ fOptionBlock.createContents(tabGroup, getElement());
+
+// Update the contents of the configuration widget
+ populateConfigurations();
+ WorkbenchHelp.setHelp(composite,ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
+ return composite;
+ }
+
+ private void handleIsExcluded() {
+
+ // Check whether the check box is selected or not.
+ boolean isSelected = excludedCheckBox.getSelection();
+ setExcluded(isSelected);
+ }
+
+ /*
+ * (non-Javadoc) @return an array of names for the configurations defined
+ * for the chosen
+ */
+ private String[] getConfigurationNames() {
+ String[] names = new String[configurations.length];
+ for (int index = 0; index < configurations.length; ++index) {
+ names[index] = configurations[index].getName();
+ }
+ return names;
+ }
+
+ protected Point getLastShellSize() {
+ if (lastShellSize == null) {
+ Shell shell = getShell();
+ if (shell != null)
+ lastShellSize = shell.getSize();
+ }
+ return lastShellSize;
+ }
+
+ public IProject getProject() {
+ Object element = getElement();
+ if (element != null && element instanceof IFile) {
+ IFile file = (IFile) element;
+ return (IProject) file.getProject();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc) @return
+ */
+ public IConfiguration getSelectedConfiguration() {
+ return selectedConfiguration;
+ }
+
+ /*
+ * Event Handlers
+ */
+ private void handleConfigSelection() {
+ // If there is nothing in config selection widget just bail
+ if (configSelector.getItemCount() == 0)
+ return;
+
+ // Check if the user has selected the "all" configuration
+ int selectionIndex = configSelector.getSelectionIndex();
+ if (selectionIndex == -1)
+ return;
+ String configName = configSelector.getItem(selectionIndex);
+ if (configName.equals(ManagedBuilderUIMessages
+ .getResourceString(ALL_CONFS))) {
+ // This is the all config
+ return;
+ } else {
+ IConfiguration newConfig = configurations[selectionIndex];
+ if (newConfig != selectedConfiguration) {
+ // If the user has changed values, and is now switching configurations, prompt for saving
+ if (selectedConfiguration != null) {
+ if (fOptionBlock.isDirty()) {
+ Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
+ boolean shouldApply = MessageDialog.openQuestion(shell,
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getFormattedString("BuildPropertyPage.changes.save.question", //$NON-NLS-1$
+ new String[] {selectedConfiguration.getName(), newConfig.getName()}));
+ if (shouldApply) {
+ if (performOk()) {
+ fOptionBlock.setDirty(false);
+ } else {
+ MessageDialog.openWarning(shell,
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.title"), //$NON-NLS-1$
+ ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.changes.save.error")); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ // Set the new selected configuration
+ selectedConfiguration = newConfig;
+ ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
+ // Set the current Resource Configuration
+ setCurrentResourceConfig(findCurrentResourceConfig());
+
+ isExcluded = getCurrentResourceConfig().isExcluded();
+ fOptionBlock.updateValues();
+ excludedCheckBox.setSelection(isExcluded);
+ }
+ }
+ return;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+
+
+ protected void performDefaults() {
+ fOptionBlock.performDefaults();
+ excludedCheckBox.setSelection(getCurrentResourceConfig().isExcluded());
+ super.performDefaults();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+
+ // 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);
+ }
+ };
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, true, op);
+ } catch (InvocationTargetException e) {
+ Throwable e1 = e.getTargetException();
+ ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
+ return false;
+ } catch (InterruptedException e) {
+ // cancelled
+ return false;
+ }
+
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
+ if ( getCurrentResourceConfig().isExcluded() != isExcluded() ) {
+ getCurrentResourceConfig().setExclude(isExcluded());
+ selectedConfiguration.setRebuildState(true);
+ }
+
+ ManagedBuildManager.saveBuildInfo(getProject(), false);
+ return true;
+ }
+
+ private void populateConfigurations() {
+
+ ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
+ // If the config select widget is not there yet, just stop
+ if (configSelector == null)
+ return;
+
+ // Find the configurations defined for the platform
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ configurations = info.getManagedProject().getConfigurations();
+ if (configurations.length == 0)
+ return;
+
+ // Clear and replace the contents of the selector widget
+ configSelector.removeAll();
+ configSelector.setItems(getConfigurationNames());
+
+ // Make sure the active configuration is selected
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ int index = configSelector.indexOf(defaultConfig.getName());
+ configSelector.select(index == -1 ? 0 : index);
+ handleConfigSelection();
+
+ }
+
+
+ /**
+ * @return Returns the currentResourceConfig.
+ */
+ public IResourceConfiguration getCurrentResourceConfig() {
+ return currentResourceConfig;
+ }
+
+ /**
+ * @param currentResourceConfig
+ * The currentResourceConfig to set.
+ */
+ public void setCurrentResourceConfig(
+ IResourceConfiguration currentResourceConfig) {
+ if (currentResourceConfig != null)
+ this.currentResourceConfig = currentResourceConfig;
+ else {
+ IFile file = (IFile) getElement();
+
+ // create a new resource configuration for this resource.
+ this.currentResourceConfig = selectedConfiguration.createResourceConfiguration(file);
+ }
+ }
+
+ // Check whether a resource configuration already exists for the current
+ // resource in selectedConfiguration.
+ // if so, return the resource configuration, otherwise return null.
+
+ public IResourceConfiguration findCurrentResourceConfig() {
+
+ IResourceConfiguration resConfigElement = null;
+
+ // Check if the selected configuration has any resourceConfigurations.
+ if (selectedConfiguration.getResourceConfigurations().length == 0)
+ return null;
+
+ IResourceConfiguration[] resourceConfigurations = selectedConfiguration
+ .getResourceConfigurations();
+ IFile file = (IFile) getElement();
+
+ // Check whether a resource configuration is already exists for the
+ // selected file.
+ for (int i = 0; i < resourceConfigurations.length; i++) {
+ resConfigElement = resourceConfigurations[i];
+ if (file.getFullPath().toString().equals(
+ resConfigElement.getResourcePath())) {
+ return resConfigElement;
+ }
+ }
+
+ return null;
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
+ */
+ public void updateButtons() {
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
+ */
+ public void updateMessage() {
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
+ */
+ public void updateTitle() {
+ }
+
+ public void updateContainer() {
+ fOptionBlock.update();
+ setValid(fOptionBlock.isValid());
+ setErrorMessage(fOptionBlock.getErrorMessage());
+ }
+
+ public boolean isValid() {
+ updateContainer();
+ return super.isValid();
+ }
+
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ fOptionBlock.setVisible(visible);
+ if (visible) {
+ fOptionBlock.updateValues();
+ displayedConfig = true;
+ }
+ }
+
+ public IPreferenceStore getPreferenceStore()
+ {
+ return fOptionBlock.getPreferenceStore();
+ }
+
+ /* (non-Javadoc)
+ * Return the IPreferenceStore of the Tool Settings block
+ */
+ public IPreferenceStore getToolSettingsPreferenceStore()
+ {
+ return fOptionBlock.getToolSettingsPreferenceStore();
+ }
+ public Preferences getPreferences()
+ {
+ return null;
+ }
+ public void enableConfigSelection (boolean enable) {
+ configSelector.setEnabled(enable);
+ }
+ /**
+ * @return Returns the isExcluded.
+ */
+ public boolean isExcluded() {
+ return isExcluded;
+ }
+ /**
+ * @param isExcluded The isExcluded to set.
+ */
+ public void setExcluded(boolean isExcluded) {
+ this.isExcluded = isExcluded;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java
index 88acea5bb02..f67a93c39e2 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,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 v0.5
* which accompanies this distribution, and is available at
@@ -11,16 +9,22 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Timesys - Initial API and implementation
* IBM Rational Software
* *********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
public class ToolListContentProvider implements ITreeContentProvider{
+ public static final int FILE = 0x1;
+ public static final int PROJECT = 0x4;
private static Object[] EMPTY_ARRAY = new Object[0];
- private IConfiguration root;
+ private IConfiguration configRoot;
+ private IResourceConfiguration resConfigRoot;
+ private int elementType;
/**
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
@@ -28,6 +32,9 @@ public class ToolListContentProvider implements ITreeContentProvider{
public void dispose() {
}
+ public ToolListContentProvider(int elementType) {
+ this.elementType = elementType;
+ }
/**
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
@@ -36,7 +43,11 @@ public class ToolListContentProvider implements ITreeContentProvider{
if (parentElement instanceof IConfiguration) {
IConfiguration config = (IConfiguration)parentElement;
// the categories are all accessed through the tools
- return config.getTools();
+ return config.getFilteredTools();
+ } else if( parentElement instanceof IResourceConfiguration) {
+ // If parent is a resource configuration, return a list of its tools
+ IResourceConfiguration resConfig = (IResourceConfiguration)parentElement;
+ return resConfig.getTools();
} else if (parentElement instanceof ITool) {
// If this is a tool, return the categories it contains
ITool tool = (ITool)parentElement;
@@ -67,7 +78,10 @@ public class ToolListContentProvider implements ITreeContentProvider{
IOptionCategory parent = cat.getOwner();
// Then we need to get the configuration we belong to
if (parent == null) {
- return root;
+ if(elementType == FILE)
+ return resConfigRoot;
+ else
+ return configRoot;
}
return parent;
}
@@ -85,7 +99,14 @@ public class ToolListContentProvider implements ITreeContentProvider{
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- root = (IConfiguration) newInput;
+ if(elementType == FILE) {
+ resConfigRoot = (IResourceConfiguration)newInput;
+ configRoot = null;
+ }
+ else if(elementType == PROJECT) {
+ configRoot = (IConfiguration) newInput;
+ resConfigRoot = null;
+ }
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java
index b2f85d94b27..e9d00a093d0 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.properties;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITool;
@@ -18,7 +17,7 @@ import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
-class ToolListLabelProvider extends LabelProvider {
+public class ToolListLabelProvider extends LabelProvider {
private final Image IMG_TOOL = ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_TOOL);
private final Image IMG_CAT = ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_CAT);
private static final String TREE_LABEL = "BuildPropertyPage.label.ToolTree"; //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
index 950908890d4..2f47bf7a7db 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,14 +8,16 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
@@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.help.WorkbenchHelp;
/**
- * Class that implements the target and configuration selection page in the new
+ * Class that implements the project type and configuration selection page in the new
* project wizard for managed builder projects.
*
* @since 1.2
@@ -65,11 +65,11 @@ public class CProjectPlatformPage extends WizardPage {
protected NewManagedProjectWizard parentWizard;
protected Combo platformSelection;
private ArrayList selectedConfigurations;
- protected ITarget selectedTarget;
+ protected IProjectType selectedProjectType;
protected Button showAll;
protected CheckboxTableViewer tableViewer;
- protected String[] targetNames;
- protected ArrayList targets;
+ protected String[] projectTypeNames;
+ protected ArrayList projectTypes;
/**
* Constructor.
@@ -79,7 +79,7 @@ public class CProjectPlatformPage extends WizardPage {
public CProjectPlatformPage(String pageName, NewManagedProjectWizard parentWizard) {
super(pageName);
setPageComplete(false);
- selectedTarget = null;
+ selectedProjectType = null;
selectedConfigurations = new ArrayList(0);
this.parentWizard = parentWizard;
}
@@ -141,14 +141,14 @@ public class CProjectPlatformPage extends WizardPage {
WorkbenchHelp.setHelp(composite, ManagedBuilderHelpContextIds.MAN_PROJ_PLATFORM_HELP);
// Create the widgets
- createTargetSelectGroup(composite);
+ createTypeSelectGroup(composite);
createConfigSelectionGroup(composite);
createShowAllGroup(composite);
- // Select the first target in the list
- populateTargets();
+ // Select the first project type in the list
+ populateTypes();
platformSelection.select(0);
- handleTargetSelection();
+ handleTypeSelection();
// Do the nasty
setErrorMessage(null);
@@ -168,9 +168,9 @@ public class CProjectPlatformPage extends WizardPage {
showAll.setText(ManagedBuilderUIMessages.getResourceString(SHOWALL_LABEL));
showAll.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
- populateTargets();
+ populateTypes();
platformSelection.select(0);
- handleTargetSelection();
+ handleTypeSelection();
}
});
showAll.addDisposeListener(new DisposeListener() {
@@ -180,7 +180,7 @@ public class CProjectPlatformPage extends WizardPage {
});
}
- private void createTargetSelectGroup(Composite parent) {
+ private void createTypeSelectGroup(Composite parent) {
// Create the group composite
Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
@@ -197,7 +197,7 @@ public class CProjectPlatformPage extends WizardPage {
platformSelection.setToolTipText(ManagedBuilderUIMessages.getResourceString(TARGET_TIP));
platformSelection.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
- handleTargetSelection();
+ handleTypeSelection();
}
});
platformSelection.addDisposeListener(new DisposeListener() {
@@ -227,13 +227,13 @@ public class CProjectPlatformPage extends WizardPage {
}
/**
- * Returns the name of the selected platform.
+ * Returns the selected project type.
*
- * @return String containing platform name or null
if an invalid selection
+ * @return IProjectType Selected type or null
if an invalid selection
* has been made.
*/
- public ITarget getSelectedTarget() {
- return selectedTarget;
+ public IProjectType getSelectedProjectType() {
+ return selectedProjectType;
}
private void handleConfigurationSelectionChange() {
@@ -250,16 +250,16 @@ public class CProjectPlatformPage extends WizardPage {
* @return true
if all controls are valid, and
* false
if at least one is invalid
*/
- protected void handleTargetSelection() {
+ protected void handleTypeSelection() {
/*
- * The index in the combo is the offset into the target list
+ * The index in the combo is the offset into the project type list
*/
int index;
if (platformSelection != null
&& (index = platformSelection.getSelectionIndex()) != -1) {
- if (selectedTarget != (ITarget) targets.get(index)) {
- selectedTarget = (ITarget) targets.get(index);
- parentWizard.updateTargetProperties();
+ if (selectedProjectType != (IProjectType) projectTypes.get(index)) {
+ selectedProjectType = (IProjectType) projectTypes.get(index);
+ parentWizard.updateProjectTypeProperties();
}
}
populateConfigurations();
@@ -271,59 +271,66 @@ public class CProjectPlatformPage extends WizardPage {
* By default, all the configurations are selected.
*/
private void populateConfigurations() {
- // Make the root of the content provider the new target
- tableViewer.setInput(selectedTarget);
+ // Make the root of the content provider the new project type
+ tableViewer.setInput(selectedProjectType);
tableViewer.setAllChecked(true);
handleConfigurationSelectionChange();
}
/* (non-Javadoc)
- * Extracts the names from the targets that are valid for the wizard
+ * Extracts the names from the project types that are valid for the wizard
* session and populates the combo widget with them.
*/
- private void populateTargetNames() {
- targetNames = new String[targets.size()];
- ListIterator iter = targets.listIterator();
+ private void populateTypeNames() {
+ projectTypeNames = new String[projectTypes.size()];
+ ListIterator iter = projectTypes.listIterator();
int index = 0;
while (iter.hasNext()) {
- targetNames[index++] = ((ITarget) iter.next()).getName();
+ projectTypeNames[index++] = ((IProjectType) iter.next()).getName();
}
// Now setup the combo
platformSelection.removeAll();
- platformSelection.setItems(targetNames);
+ platformSelection.setItems(projectTypeNames);
}
/* (non-Javadoc)
- * Collects all the valid targets for the platform Eclipse is running on
+ * Collects all the valid project types for the platform Eclipse is running on
*/
- private void populateTargets() {
+ private void populateTypes() {
// Get a list of platforms defined by plugins
- ITarget[] allTargets = ManagedBuildManager.getDefinedTargets(null);
- targets = new ArrayList();
+ IProjectType[] allProjectTypes = ManagedBuildManager.getDefinedProjectTypes();
+ projectTypes = new ArrayList();
String os = Platform.getOS();
String arch = Platform.getOSArch();
- // Add all of the concrete targets to the target list
- for (int index = 0; index < allTargets.length; ++index) {
- ITarget target = allTargets[index];
- if (!target.isAbstract() && !target.isTestTarget()) {
+ // Add all of the concrete project types to the list
+ for (int index = 0; index < allProjectTypes.length; ++index) {
+ IProjectType type = allProjectTypes[index];
+ if (!type.isAbstract() && !type.isTestProjectType()) {
// If the check box is selected show all the targets
if (showAll != null && showAll.getSelection() == true) {
- targets.add(target);
+ projectTypes.add(type);
} else {
// Apply the OS and ARCH filters to determine if the target should be shown
- List targetOSList = Arrays.asList(target.getTargetOSList());
- if (targetOSList.contains("all") || targetOSList.contains(os)) { //$NON-NLS-1$
- List targetArchList = Arrays.asList(target.getTargetArchList());
- if (targetArchList.contains("all") || targetArchList.contains(arch)) { //$NON-NLS-1$
- targets.add(target);
+ // Determine if the project type has any configuration with a tool-chain
+ // that supports this OS & Architecture.
+ IConfiguration[] configs = type.getConfigurations();
+ for (int j = 0; j < configs.length; ++j) {
+ IToolChain tc = configs[j].getToolChain();
+ List osList = Arrays.asList(tc.getOSList());
+ if (osList.contains("all") || osList.contains(os)) { //$NON-NLS-1$
+ List archList = Arrays.asList(tc.getArchList());
+ if (archList.contains("all") || archList.contains(arch)) { //$NON-NLS-1$
+ projectTypes.add(type);
+ break;
+ }
}
}
}
}
}
- targets.trimToSize();
- populateTargetNames();
+ projectTypes.trimToSize();
+ populateTypeNames();
}
/**
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java
index 27db61034bd..c800b9f43c1 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/ConfigurationContentProvider.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,9 +8,10 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
@@ -20,7 +19,7 @@ public class ConfigurationContentProvider implements IStructuredContentProvider
// The contents of the parent of the table is a list of configurations
public Object[] getElements(Object parent) {
// The content is a list of configurations
- IConfiguration[] configs = ((ITarget) parent).getConfigurations();
+ IConfiguration[] configs = ((IProjectType) parent).getConfigurations();
return (configs.length == 0) ? new Object[0] : configs;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
index c2198773196..35cc4d7397a 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,6 +8,7 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
import java.util.Iterator;
import java.util.List;
@@ -43,7 +42,7 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
parent = parentPage;
}
- public void updateTargetProperties() {
+ public void updateProjectTypeProperties() {
// Update the error parser list
if (errorParsers != null) {
errorParsers.updateValues();
@@ -55,8 +54,13 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
*/
protected void addTabs() {
addTab(new ReferenceBlock());
- errorParsers = new ErrorParserBlock();
- addTab(errorParsers);
+ // NOTE: The setting of error parsers is commented out here
+ // because they need to be set per-configuration.
+ // The other tabs on this page are per-project.
+ // Error parsers can be selected per configuration in the
+ // project properties
+ //errorParsers = new ErrorParserBlock();
+ //addTab(errorParsers);
addTab(indexBlock = new IndexerBlock());
}
@@ -112,9 +116,9 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
return ManagedBuilderUIPlugin.getDefault().getPluginPreferences();
}
- public void updateTargetProperties() {
+ public void updateProjectTypeProperties() {
// Update the error parser list
- optionBlock.updateTargetProperties();
+ optionBlock.updateProjectTypeProperties();
}
public void setupHelpContextIds(){
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
index 2fa2b165860..3ca45f48be2 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
@@ -1,7 +1,5 @@
-package org.eclipse.cdt.managedbuilder.ui.wizards;
-
/**********************************************************************
- * Copyright (c) 2002,2004 Rational Software Corporation and others.
+ * Copyright (c) 2002,2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -10,14 +8,16 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
-
-import java.util.Random;
+package org.eclipse.cdt.managedbuilder.ui.wizards;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
@@ -55,7 +55,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
protected static final String SETTINGS_DESC = "MngMakeWizardSettings.description"; //$NON-NLS-1$
// Wizard pages
- protected CProjectPlatformPage targetConfigurationPage;
+ protected CProjectPlatformPage projectConfigurationPage;
protected NewManagedProjectOptionPage optionPage;
public NewManagedProjectWizard() {
@@ -71,10 +71,10 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
super.addPages();
// Add the configuration selection page
- targetConfigurationPage = new CProjectPlatformPage(PREFIX, this);
- targetConfigurationPage.setTitle(ManagedBuilderUIMessages.getResourceString(CONF_TITLE));
- targetConfigurationPage.setDescription(ManagedBuilderUIMessages.getResourceString(CONF_DESC));
- addPage(targetConfigurationPage);
+ projectConfigurationPage = new CProjectPlatformPage(PREFIX, this);
+ projectConfigurationPage.setTitle(ManagedBuilderUIMessages.getResourceString(CONF_TITLE));
+ projectConfigurationPage.setDescription(ManagedBuilderUIMessages.getResourceString(CONF_DESC));
+ addPage(projectConfigurationPage);
// Add the options (tabbed) page
optionPage = new NewManagedProjectOptionPage(PREFIX, this);
@@ -97,9 +97,9 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
optionPage.setupHelpContextIds();
}
}
- public void updateTargetProperties() {
+ public void updateProjectTypeProperties() {
// Update the error parser list
- optionPage.updateTargetProperties();
+ optionPage.updateProjectTypeProperties();
}
protected void doRun(IProgressMonitor monitor) throws CoreException {
@@ -120,40 +120,42 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
ManagedBuilderUIPlugin.log(e);
}
- // Add the target to the project
- ITarget newTarget = null;
+ // Add the ManagedProject to the project
+ IManagedProject newManagedProject = null;
try {
ManagedBuildManager.createBuildInfo(newProject);
- ITarget parent = targetConfigurationPage.getSelectedTarget();
- newTarget = ManagedBuildManager.createTarget(newProject, parent);
- if (newTarget != null) {
+ IProjectType parent = projectConfigurationPage.getSelectedProjectType();
+ newManagedProject = ManagedBuildManager.createManagedProject(newProject, parent);
+ if (newManagedProject != null) {
+ IConfiguration [] selectedConfigs = projectConfigurationPage.getSelectedConfigurations();
+ for (int i = 0; i < selectedConfigs.length; i++) {
+ IConfiguration config = selectedConfigs[i];
+ int id = ManagedBuildManager.getRandomNumber();
+ IConfiguration newConfig = newManagedProject.createConfiguration(config, config.getId() + "." + id); //$NON-NLS-1$
+ newConfig.setArtifactName(newManagedProject.getDefaultArtifactName());
+ }
+ // Now add the first config in the list as the default
+ IConfiguration[] newConfigs = newManagedProject.getConfigurations();
+ if (newConfigs.length > 0) {
+ ManagedBuildManager.setDefaultConfiguration(newProject, newConfigs[0]);
+ ManagedBuildManager.setSelectedConfiguration(newProject, newConfigs[0]);
+ }
+ ManagedBuildManager.setNewProjectVersion(newProject);
ICDescriptor desc = null;
try {
desc = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
- desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, newTarget.getBinaryParserId());
+ // TODO: The binary parser setting is currently per-project in the rest of CDT.
+ // In the MBS, it is per-coonfiguration. For now, select the binary parser of the
+ // first configuration.
+ if (newConfigs.length > 0) {
+ IToolChain tc = newConfigs[0].getToolChain();
+ ITargetPlatform targetPlatform = tc.getTargetPlatform();
+ desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, targetPlatform.getBinaryParserId());
+ }
} catch (CoreException e) {
ManagedBuilderUIPlugin.log(e);
}
- newTarget.setArtifactName(getBuildGoalName());
- IConfiguration [] selectedConfigs = targetConfigurationPage.getSelectedConfigurations();
- Random r = new Random();
- r.setSeed(System.currentTimeMillis());
- for (int i = 0; i < selectedConfigs.length; i++) {
- IConfiguration config = selectedConfigs[i];
- int id = r.nextInt();
- if (id < 0) {
- id *= -1;
- }
- newTarget.createConfiguration(config, config.getId() + "." + id); //$NON-NLS-1$
- }
- // Now add the first config in the list as the default
- IConfiguration[] newConfigs = newTarget.getConfigurations();
- if (newConfigs.length > 0) {
- ManagedBuildManager.setDefaultConfiguration(newProject, newConfigs[0]);
- }
- ManagedBuildManager.setSelectedTarget(newProject, newTarget);
- ManagedBuildManager.setNewProjectVersion(newProject);
}
} catch (BuildException e) {
ManagedBuilderUIPlugin.log(e);
@@ -170,19 +172,6 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
monitor.done();
}
- /**
- * @return
- */
- private String getBuildGoalName() {
- String name = new String();
- // Check for spaces
- String[] tokens = newProject.getName().split("\\s"); //$NON-NLS-1$
- for (int index = 0; index < tokens.length; ++index) {
- name += tokens[index];
- }
- return name;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor)
*/
@@ -211,8 +200,8 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID;
}
- public ITarget getSelectedTarget() {
- return targetConfigurationPage.getSelectedTarget();
+ public IProjectType getSelectedProjectType() {
+ return projectConfigurationPage.getSelectedProjectType();
}
}