[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Patches for Bugzilla 88150 - setting multiple binary parsers in project type
|
Hello
all,
im am suggesting a
set of patches to the managed build system for versions 3.0.0 (M6 candidate from
yesterday) and 2.1.1.
The patch aims to
allow setting multiple binary parsers in a project type as a comma-separated
list, analogous to the list of operating systems for target platform.
Regards,
Norbert
Ploett
Index: D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java
===================================================================
--- D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java (revision 28)
+++ D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java (working copy)
@@ -91,18 +91,18 @@
public void setArchList(String[] archs);
/**
- * Returns the unique ID of the binary parser associated with the target platform.
+ * Returns the unique IDs of the binary parsers associated with the target platform.
*
* @return String
*/
- public String getBinaryParserId();
+ public String[] getBinaryParserList();
/**
- * Sets the string id of the binary parser for this target platform.
+ * Sets the string ids of the binary parsers for this target platform.
*
* @param id
*/
- public void setBinaryParserId(String id);
+ public void setBinaryParserList(String[] ids);
/**
* Returns <code>true</code> if this element has changes that need to
Index: D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/Target.java
===================================================================
--- D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/Target.java (revision 28)
+++ D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/Target.java (working copy)
@@ -1034,7 +1034,7 @@
targetPlatform.setIsAbstract(isAbstract);
targetPlatform.setOSList(getTargetOSList());
targetPlatform.setArchList(getTargetArchList());
- targetPlatform.setBinaryParserId(getBinaryParserId());
+ targetPlatform.setBinaryParserList(new String[]{getBinaryParserId()}); // Older projects will always have only one binary parser set.
// Handle ConfigurationV2 children (ToolReference)
// The tools references fetched here are strictly local to the configuration,
Index: D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java
===================================================================
--- D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java (revision 28)
+++ D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java (working copy)
@@ -38,7 +38,7 @@
private Boolean isAbstract;
private List osList;
private List archList;
- private String binaryParserId;
+ private List binaryParserList;
// Miscellaneous
private boolean isExtensionTargetPlatform = false;
private boolean isDirty = false;
@@ -146,8 +146,8 @@
if (targetPlatform.archList != null) {
archList = new ArrayList(targetPlatform.archList);
}
- if (targetPlatform.binaryParserId != null) {
- binaryParserId = new String(targetPlatform.binaryParserId);
+ if (targetPlatform.binaryParserList != null) {
+ binaryParserList = new ArrayList(targetPlatform.binaryParserList);
}
setDirty(true);
@@ -204,8 +204,15 @@
}
}
- // Get the ID of the binary parser
- binaryParserId = element.getAttribute(BINARY_PARSER);
+ // Get the IDs of the binary parsers from a comma-separated list.
+ String bpars = element.getAttribute(BINARY_PARSER);
+ if (bpars != null) {
+ binaryParserList = new ArrayList();
+ String[] bparsTokens = bpars.split(","); //$NON-NLS-1$
+ for (int j = 0; j < bparsTokens.length; ++j) {
+ binaryParserList.add(bparsTokens[j].trim());
+ }
+ }
}
/* (non-Javadoc)
@@ -270,9 +277,16 @@
}
}
- // binaryParserId
+ // Get the comma-separated list of binaryParserIds
if (element.hasAttribute(BINARY_PARSER)) {
- binaryParserId = element.getAttribute(BINARY_PARSER);
+ String bpars = element.getAttribute(BINARY_PARSER);
+ if (bpars != null) {
+ binaryParserList = new ArrayList();
+ String[] bparsTokens = bpars.split(","); //$NON-NLS-1$
+ for (int j = 0; j < bparsTokens.length; ++j) {
+ binaryParserList.add(bparsTokens[j].trim());
+ }
+ }
}
}
@@ -301,8 +315,17 @@
element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
}
- if (binaryParserId != null) {
- element.setAttribute(BINARY_PARSER, binaryParserId);
+ if (binaryParserList != null) {
+ Iterator bparsIter = binaryParserList.listIterator();
+ String listValue = EMPTY_STRING;
+ while (bparsIter.hasNext()) {
+ String current = (String) bparsIter.next();
+ listValue += current;
+ if ((bparsIter.hasNext())) {
+ listValue += ","; //$NON-NLS-1$
+ }
+ }
+ element.setAttribute(BINARY_PARSER, binaryParserList.toString());
}
if (osList != null) {
@@ -388,16 +411,16 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITargetPlatform#getBinaryParserI()
*/
- public String getBinaryParserId() {
- if (binaryParserId == null) {
+ public String[] getBinaryParserList() {
+ if (binaryParserList == null) {
// If I have a superClass, ask it
if (superClass != null) {
- return superClass.getBinaryParserId();
+ return superClass.getBinaryParserList();
} else {
- return EMPTY_STRING;
+ return new String[0];
}
}
- return binaryParserId;
+ return (String[]) binaryParserList.toArray(new String[binaryParserList.size()]);
}
/* (non-Javadoc)
@@ -435,12 +458,16 @@
/* (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);
+ public void setBinaryParserList(String[] ids) {
+ if (binaryParserList == null) {
+ binaryParserList = new ArrayList();
+ } else {
+ binaryParserList.clear();
}
+ for (int i = 0; i < ids.length; i++) {
+ binaryParserList.add(ids[i]);
+ }
+ setDirty(true);
}
/* (non-Javadoc)
Index: D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java
===================================================================
--- D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java (revision 28)
+++ D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java (working copy)
@@ -244,7 +244,7 @@
String builderName = targetPlatform.getName() + "." + newConfig.getName(); //$NON-NLS-1$
toolChain.createTargetPlatform(targetPlatform,subId,builderName,false);
}
- targetPlatform.setBinaryParserId(binaryParser);
+ targetPlatform.setBinaryParserList(new String[]{binaryParser}); // Older projects have only a single binary parser.
}
if(targetEl.hasAttribute(ITarget.MAKE_COMMAND)){
Index: D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.ui/src-mgdbuildui/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
===================================================================
--- D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.ui/src-mgdbuildui/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java (revision 28)
+++ D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.ui/src-mgdbuildui/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java (working copy)
@@ -155,12 +155,16 @@
desc = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
// 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
+ // In the MBS, it is per-coonfiguration. For now, select the binary parsers 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());
+ // Create entries for all binary parsers
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ for (int i=0; i<binaryParsers.length; i++) {
+ desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, binaryParsers[i]);
+ }
}
} catch (CoreException e) {
ManagedBuilderUIPlugin.log(e);
Index: D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java
===================================================================
--- D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java (revision 28)
+++ D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java (working copy)
@@ -146,8 +146,10 @@
expectedOSListarr.add(expectedOSListTokens[i].trim());
}
assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
- assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
- assertEquals(platform.getBinaryParserId(), expectedBinaryParser);
+ assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
+ String[] binaryParsers = platform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 2);
+ assertEquals(binaryParsers[0], expectedBinaryParser);
assertEquals(platform.getName(), expectedPlatformName[iconfig]);
// Fetch and check builder
@@ -339,7 +341,9 @@
ITargetPlatform platform = toolChain.getTargetPlatform();
assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
- assertEquals(platform.getBinaryParserId(), expectedBinaryParser);
+ String[] binaryParsers = platform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedBinaryParser);
assertEquals(platform.getName(), expectedPlatformName[iconfig]);
// Fetch and check builder
@@ -536,7 +540,9 @@
ITargetPlatform platform = toolChain.getTargetPlatform();
assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
- assertEquals(platform.getBinaryParserId(), expectedBinaryParser);
+ String[] binaryParsers = platform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedBinaryParser);
assertEquals(platform.getName(), expectedPlatformName[iconfig]);
// Fetch and check builder
Index: D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests20.java
===================================================================
--- D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests20.java (revision 28)
+++ D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests20.java (working copy)
@@ -890,7 +890,9 @@
assertEquals("make", configs[0].getBuildCommand());
IToolChain toolChain = configs[0].getToolChain();
ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals(expectedParserId, targetPlatform.getBinaryParserId());
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedParserId);
assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
// This configuration defines no errors parsers.
@@ -1114,7 +1116,9 @@
assertEquals("make", configs[0].getBuildCommand());
IToolChain toolChain = configs[0].getToolChain();
ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals(expectedParserId, targetPlatform.getBinaryParserId());
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedParserId);
assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
// This configuration defines no errors parsers.
@@ -1382,7 +1386,7 @@
// Make sure we get the proper binary parser
IToolChain toolChain = configs[0].getToolChain();
ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals("org.eclipse.cdt.core.ELF", targetPlatform.getBinaryParserId());
+ assertEquals("org.eclipse.cdt.core.ELF", targetPlatform.getBinaryParserList()[0]);
// Make sure the os list is inherited
String[] expectedOSList = {"win32","linux","solaris"};
assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
@@ -1536,7 +1540,7 @@
// Make sure the binary parser is hard-coded and available
IToolChain toolChain = configs[0].getToolChain();
ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals("org.eclipse.cdt.core.PE", targetPlatform.getBinaryParserId());
+ assertEquals("org.eclipse.cdt.core.PE", targetPlatform.getBinaryParserList()[0]);
String[] expectedOSList = {"win32","linux","solaris"};
assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
// Make sure the list is overridden
@@ -1833,7 +1837,7 @@
IConfiguration[] configs = proj.getConfigurations();
IToolChain toolChain = configs[0].getToolChain();
ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals(expectedBinParserId, targetPlatform.getBinaryParserId());
+ assertEquals(expectedBinParserId, targetPlatform.getBinaryParserList()[0]);
// This target defines errors parsers. Check that the error parsers
// have been assigned.
assertEquals("org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser", configs[0].getErrorParserIds());
Index: D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
===================================================================
--- D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml (revision 28)
+++ D:/Projekt/RTP/Work.CDT3.0.0/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml (working copy)
@@ -1219,7 +1219,7 @@
<targetPlatform
id="cdt.managedbuild.target.testgnu.platform.exe.debug"
name="Dbg Platform"
- binaryParser="org.eclipse.cdt.core.ELF"
+ binaryParser="org.eclipse.cdt.core.ELF,org.eclipse.cdt.core.PE"
osList="solaris,linux,hpux,aix,qnx"
archList="all">
</targetPlatform>
@@ -1286,7 +1286,7 @@
<targetPlatform
id="cdt.managedbuild.target.testgnu.platform.exe.release"
name="Rel Platform"
- binaryParser="org.eclipse.cdt.core.ELF"
+ binaryParser="org.eclipse.cdt.core.ELF,org.eclipse.cdt.core.PE"
osList="solaris,linux,hpux,aix,qnx"
archList="all">
</targetPlatform>
Index: D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.ui/src-mgdbuildui/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
===================================================================
--- D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.ui/src-mgdbuildui/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java (revision 11)
+++ D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.ui/src-mgdbuildui/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java (working copy)
@@ -1,219 +1,223 @@
-/**********************************************************************
- * Copyright (c) 2002,2005 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:
- * IBM Rational Software - Initial API and implementation
- * **********************************************************************/
-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.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
-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.wizards.NewCProjectWizard;
-import org.eclipse.cdt.ui.wizards.NewCProjectWizardPage;
-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.SubProgressMonitor;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-
-public class NewManagedProjectWizard extends NewCProjectWizard {
-
- /* (non-Javadoc)
- * String constants
- */
- protected static final String PREFIX = "MngMakeProjectWizard"; //$NON-NLS-1$
- protected static final String OP_ERROR = PREFIX + ".op_error"; //$NON-NLS-1$
- protected static final String WZ_TITLE = PREFIX + ".title"; //$NON-NLS-1$
- protected static final String WZ_DESC = PREFIX + ".description"; //$NON-NLS-1$
- protected static final String CONF_TITLE = PREFIX + ".config.title"; //$NON-NLS-1$
- protected static final String CONF_DESC = PREFIX + ".config.desc"; //$NON-NLS-1$
- protected static final String OPTIONS_TITLE = PREFIX + ".options.title"; //$NON-NLS-1$
- protected static final String OPTIONS_DESC = PREFIX + ".options.desc"; //$NON-NLS-1$
- protected static final String MSG_ADD_NATURE = PREFIX + ".message.add_nature"; //$NON-NLS-1$
- protected static final String MSG_ADD_BUILDER = PREFIX + ".message.add_builder"; //$NON-NLS-1$
- protected static final String MSG_SAVE = PREFIX + ".message.save"; //$NON-NLS-1$
- protected static final String SETTINGS_TITLE = "MngMakeWizardSettings.title"; //$NON-NLS-1$
- protected static final String SETTINGS_DESC = "MngMakeWizardSettings.description"; //$NON-NLS-1$
-
- // Wizard pages
- protected CProjectPlatformPage projectConfigurationPage;
- protected NewManagedProjectOptionPage optionPage;
-
- public NewManagedProjectWizard() {
- this(ManagedBuilderUIMessages.getResourceString(WZ_TITLE), ManagedBuilderUIMessages.getResourceString(WZ_DESC));
- }
-
- public NewManagedProjectWizard(String title, String description) {
- super(title, description);
- }
-
- public void addPages() {
- // Add the default page for all new projects
- super.addPages();
-
- // Add the configuration selection page
- 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);
- optionPage.setTitle(ManagedBuilderUIMessages.getResourceString(OPTIONS_TITLE));
- optionPage.setDescription(ManagedBuilderUIMessages.getResourceString(OPTIONS_DESC));
- addPage(optionPage);
- }
-
- public void createPageControls(Composite pageContainer) {
- super.createPageControls( pageContainer );
-
- IWizardPage [] pages = getPages();
-
- if (pages != null) {
- for (int i = 0; i < pages.length; i++) {
- IWizardPage page = pages[i];
- if (page instanceof NewCProjectWizardPage) {
- WorkbenchHelp.setHelp(page.getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_WIZ_NAME_PAGE);
- }
- else if (page instanceof NewManagedProjectOptionPage) {
- NewManagedProjectOptionPage optionPage = (NewManagedProjectOptionPage) page;
- optionPage.setupHelpContextIds();
- }
- // The other built-in page is the CProjectPlatformPage which already has a help id.
- }
- }
- }
-
- public void updateProjectTypeProperties() {
- // Update the error parser list
- optionPage.updateProjectTypeProperties();
- }
-
- protected void doRun(IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- // super.doRun() just creates the project and does not assign a builder to it.
- super.doRun(new SubProgressMonitor(monitor, 5));
-
- // Add the managed build nature and builder
- try {
- monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_NATURE));
- ManagedCProjectNature.addManagedNature(newProject, new SubProgressMonitor(monitor, 1));
- monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_BUILDER));
- ManagedCProjectNature.addManagedBuilder(newProject, new SubProgressMonitor(monitor, 1));
- } catch (CoreException e) {
- ManagedBuilderUIPlugin.log(e);
- }
-
- // Add the ManagedProject to the project
- IManagedProject newManagedProject = null;
- IManagedBuildInfo info = null;
- try {
- info = ManagedBuildManager.createBuildInfo(newProject);
- 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);
- // 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);
- }
- }
- } catch (BuildException e) {
- ManagedBuilderUIPlugin.log(e);
- }
-
- // Modify the project settings
- if (newProject != null) {
- optionPage.performApply(new SubProgressMonitor(monitor, 2));
- }
-
- // Save the build options
- monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_SAVE));
- if (info != null) {
- info.setValid(true);
- ManagedBuildManager.saveBuildInfo(newProject, true);
- }
- monitor.done();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void doRunPrologue(IProgressMonitor monitor) {
- // Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void doRunEpilogue(IProgressMonitor monitor) {
- // Get my initializer to run
- IStatus initResult = ManagedBuildManager.initBuildInfoContainer(newProject);
- if (initResult.getCode() != IStatus.OK) {
- // At this point, I can live with a failure
- ManagedBuilderUIPlugin.log(initResult);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#getProjectID()
- */
- public String getProjectID() {
-// return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$
- return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID;
- }
-
- public IProjectType getSelectedProjectType() {
- return projectConfigurationPage.getSelectedProjectType();
- }
-
-}
+/**********************************************************************
+ * Copyright (c) 2002,2005 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:
+ * IBM Rational Software - Initial API and implementation
+ * **********************************************************************/
+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.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
+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.wizards.NewCProjectWizard;
+import org.eclipse.cdt.ui.wizards.NewCProjectWizardPage;
+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.SubProgressMonitor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+
+public class NewManagedProjectWizard extends NewCProjectWizard {
+
+ /* (non-Javadoc)
+ * String constants
+ */
+ protected static final String PREFIX = "MngMakeProjectWizard"; //$NON-NLS-1$
+ protected static final String OP_ERROR = PREFIX + ".op_error"; //$NON-NLS-1$
+ protected static final String WZ_TITLE = PREFIX + ".title"; //$NON-NLS-1$
+ protected static final String WZ_DESC = PREFIX + ".description"; //$NON-NLS-1$
+ protected static final String CONF_TITLE = PREFIX + ".config.title"; //$NON-NLS-1$
+ protected static final String CONF_DESC = PREFIX + ".config.desc"; //$NON-NLS-1$
+ protected static final String OPTIONS_TITLE = PREFIX + ".options.title"; //$NON-NLS-1$
+ protected static final String OPTIONS_DESC = PREFIX + ".options.desc"; //$NON-NLS-1$
+ protected static final String MSG_ADD_NATURE = PREFIX + ".message.add_nature"; //$NON-NLS-1$
+ protected static final String MSG_ADD_BUILDER = PREFIX + ".message.add_builder"; //$NON-NLS-1$
+ protected static final String MSG_SAVE = PREFIX + ".message.save"; //$NON-NLS-1$
+ protected static final String SETTINGS_TITLE = "MngMakeWizardSettings.title"; //$NON-NLS-1$
+ protected static final String SETTINGS_DESC = "MngMakeWizardSettings.description"; //$NON-NLS-1$
+
+ // Wizard pages
+ protected CProjectPlatformPage projectConfigurationPage;
+ protected NewManagedProjectOptionPage optionPage;
+
+ public NewManagedProjectWizard() {
+ this(ManagedBuilderUIMessages.getResourceString(WZ_TITLE), ManagedBuilderUIMessages.getResourceString(WZ_DESC));
+ }
+
+ public NewManagedProjectWizard(String title, String description) {
+ super(title, description);
+ }
+
+ public void addPages() {
+ // Add the default page for all new projects
+ super.addPages();
+
+ // Add the configuration selection page
+ 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);
+ optionPage.setTitle(ManagedBuilderUIMessages.getResourceString(OPTIONS_TITLE));
+ optionPage.setDescription(ManagedBuilderUIMessages.getResourceString(OPTIONS_DESC));
+ addPage(optionPage);
+ }
+
+ public void createPageControls(Composite pageContainer) {
+ super.createPageControls( pageContainer );
+
+ IWizardPage [] pages = getPages();
+
+ if (pages != null) {
+ for (int i = 0; i < pages.length; i++) {
+ IWizardPage page = pages[i];
+ if (page instanceof NewCProjectWizardPage) {
+ WorkbenchHelp.setHelp(page.getControl(), ManagedBuilderHelpContextIds.MAN_PROJ_WIZ_NAME_PAGE);
+ }
+ else if (page instanceof NewManagedProjectOptionPage) {
+ NewManagedProjectOptionPage optionPage = (NewManagedProjectOptionPage) page;
+ optionPage.setupHelpContextIds();
+ }
+ // The other built-in page is the CProjectPlatformPage which already has a help id.
+ }
+ }
+ }
+
+ public void updateProjectTypeProperties() {
+ // Update the error parser list
+ optionPage.updateProjectTypeProperties();
+ }
+
+ protected void doRun(IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ // super.doRun() just creates the project and does not assign a builder to it.
+ super.doRun(new SubProgressMonitor(monitor, 5));
+
+ // Add the managed build nature and builder
+ try {
+ monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_NATURE));
+ ManagedCProjectNature.addManagedNature(newProject, new SubProgressMonitor(monitor, 1));
+ monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_BUILDER));
+ ManagedCProjectNature.addManagedBuilder(newProject, new SubProgressMonitor(monitor, 1));
+ } catch (CoreException e) {
+ ManagedBuilderUIPlugin.log(e);
+ }
+
+ // Add the ManagedProject to the project
+ IManagedProject newManagedProject = null;
+ IManagedBuildInfo info = null;
+ try {
+ info = ManagedBuildManager.createBuildInfo(newProject);
+ 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);
+ // 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();
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ // Create binary parser entries for all pre-selected binary parsers (semicolon-separated list).
+ for (int i=0; i<binaryParsers.length; i++) {
+ desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, binaryParsers[i]);
+ }
+ }
+ } catch (CoreException e) {
+ ManagedBuilderUIPlugin.log(e);
+ }
+ }
+ } catch (BuildException e) {
+ ManagedBuilderUIPlugin.log(e);
+ }
+
+ // Modify the project settings
+ if (newProject != null) {
+ optionPage.performApply(new SubProgressMonitor(monitor, 2));
+ }
+
+ // Save the build options
+ monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_SAVE));
+ if (info != null) {
+ info.setValid(true);
+ ManagedBuildManager.saveBuildInfo(newProject, true);
+ }
+ monitor.done();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void doRunPrologue(IProgressMonitor monitor) {
+ // Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void doRunEpilogue(IProgressMonitor monitor) {
+ // Get my initializer to run
+ IStatus initResult = ManagedBuildManager.initBuildInfoContainer(newProject);
+ if (initResult.getCode() != IStatus.OK) {
+ // At this point, I can live with a failure
+ ManagedBuilderUIPlugin.log(initResult);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#getProjectID()
+ */
+ public String getProjectID() {
+// return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$
+ return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID;
+ }
+
+ public IProjectType getSelectedProjectType() {
+ return projectConfigurationPage.getSelectedProjectType();
+ }
+
+}
Index: D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java
===================================================================
--- D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java (revision 13)
+++ D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests.java (working copy)
@@ -1,636 +1,647 @@
-/**********************************************************************
- * Copyright (c) 2004 Intel Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Intel Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.managedbuild.core.tests;
-
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-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.ITargetPlatform;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-
-
-public class ManagedBuildCoreTests extends TestCase {
- private static final boolean boolVal = true;
- private static IProjectType exeType;
- private static IProjectType libType;
- private static IProjectType dllType;
-
- public ManagedBuildCoreTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ManagedBuildCoreTests.class.getName());
- suite.addTest(new ManagedBuildCoreTests("testLoadManifest"));
- return suite;
- }
-
- /**
- * Navigates through a CDT 2.1 manifest file and verifies that the
- * definitions are loaded correctly.
- */
- public void testLoadManifest() throws Exception {
- IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes();
- exeType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.exe");
- checkExeProjectType(exeType);
- dllType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.so");
- checkSoProjectType(dllType);
- libType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.lib");
- checkLibProjectType(libType);
- }
-
-
- /*
- * Do a sanity check on the testgnu exe project type.
- */
- private void checkExeProjectType(IProjectType ptype) throws BuildException {
- int i;
- int expecectedNumConfigs = 2;
- String[] expectedConfigName = {"Dbg", "Rel"};
- String expectedCleanCmd = "rm -rf";
- String expectedParserId = "org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser";
- String expectedOSList = "solaris,linux,hpux,aix,qnx";
- int expectedSizeOSList = 5;
- String[] expectedArchList = {"all"};
- String expectedBinaryParser = "org.eclipse.cdt.core.ELF";
- String[] expectedPlatformName = {"Dbg Platform",
- "Rel Platform"};
- String expectedCommand = "make";
- String expectedArguments = "-k";
- String[] expectedBuilderName = {"Dbg Builder",
- "Rel Builder"};
- String expectedBuilderInfo = "org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator";
- String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.c.compiler.exe.debug",
- "cdt.managedbuild.tool.testgnu.c.compiler.exe.release"};
- String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.c.compiler";
- String expectedSuperOutputFlag1 = "-o";
- String expectedSuperGetToolCommand1 = "gcc";
- String expectedSuperInputExt1 = "c";
- String expectedSuperToolInterfaceExt1 = "h";
- String[] expectedSuperToolOutputExt1 = {"o"};
- String expectedOptionCategory1 = "testgnu.c.compiler.category.preprocessor";
- String[] OptionId1 = {"testgnu.c.compiler.exe.debug.option.optimization.level",
- "testgnu.c.compiler.exe.release.option.optimization.level"};
- String[] expectedOptionIdValue1 = {"testgnu.c.optimization.level.none",
- "testgnu.c.optimization.level.most"};
- String expectedEnumList1 = "Posix.Optimize.None, Posix.Optimize.Optimize, Posix.Optimize.More, Posix.Optimize.Most";
- int expectedSizeEnumList1 = 4;
- String[] expectedOptionEnumCmd1arr = {"-O0", "-O3"};
- String OptionId2 = "testgnu.c.compiler.option.debugging.other";
- String expectedOptionIdName2 = "Posix.Debug.Other";
- String OptionId3 = "testgnu.c.compiler.option.debugging.gprof";
- String expectedOptionIdName3 = "Posix.Debug.gprof";
- String expectedOptionIdCmd3 = "-pg";
- boolean expectedOptionIdValue3 = false;
- int expecectedNumTools = 5;
- int numOrderCCompilerTool = 0;
- int expecectedCNature = ITool.FILTER_C;
- int expecectedCCNature = ITool.FILTER_CC;
-
- // Check project attributes
- //
- assertNotNull(ptype);
- assertTrue(ptype.isTestProjectType());
- assertFalse(ptype.isAbstract());
-
- // Check project configurations
- //
- IConfiguration[] configs = ptype.getConfigurations();
- assertNotNull(configs);
- assertEquals(expecectedNumConfigs, configs.length);
-
- // Loop over configurations
- //
- for (int iconfig=0; iconfig < configs.length; iconfig++) {
-
- // Verify configuration attributes
- //
- assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
- assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
- assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
-
- // Fetch toolchain
- //
- IToolChain toolChain = configs[iconfig].getToolChain();
-
- // Fetch and check platform
- //
- ITargetPlatform platform = toolChain.getTargetPlatform();
-
- List expectedOSListarr = new ArrayList();
- String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedOSListTokens.length; ++i) {
- expectedOSListarr.add(expectedOSListTokens[i].trim());
- }
- assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
- assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
- assertEquals(platform.getBinaryParserId(), expectedBinaryParser);
- assertEquals(platform.getName(), expectedPlatformName[iconfig]);
-
- // Fetch and check builder
- //
- IBuilder builder = toolChain.getBuilder();
- assertEquals(builder.getCommand(), expectedCommand);
- assertEquals(builder.getArguments(), expectedArguments);
- assertEquals(builder.getName(), expectedBuilderName[iconfig]);
- IConfigurationElement element = builder.getBuildFileGeneratorElement();
- if (element != null) {
- assertEquals(element.getAttribute(IBuilder.BUILDFILEGEN_ID), expectedBuilderInfo);
- }
-
- // Fetch and check tools list
- //
- ITool[] tools = toolChain.getTools();
- assertEquals(tools.length, expecectedNumTools);
-
- // Fetch and check the gnu C compiler tool
- //
- ITool tool;
- ITool superTool;
-
- tool = tools[numOrderCCompilerTool];
- superTool = tool.getSuperClass();
- assertEquals(tool.getId(), expectedToolId1[iconfig]);
- assertEquals(superTool.getId(), expectedSuperToolId1);
- assertEquals(tool.getNatureFilter(), expecectedCNature);
- List expectedSuperInputExt1List = new ArrayList();
- String[] expectedSuperInputExt1Tokens = expectedSuperInputExt1.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedSuperInputExt1Tokens.length; ++i) {
- expectedSuperInputExt1List.add(expectedSuperInputExt1Tokens[i].trim());
- }
- assertEquals(superTool.getInputExtensions(), expectedSuperInputExt1List);
- assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
- assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
- assertTrue(Arrays.equals(superTool.getOutputExtensions(), expectedSuperToolOutputExt1));
- List expectedSuperInterfaceExt1List = new ArrayList();
- String[] expectedSuperInterfaceExt1Tokens = expectedSuperToolInterfaceExt1.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedSuperInterfaceExt1Tokens.length; ++i) {
- expectedSuperInterfaceExt1List.add(expectedSuperInterfaceExt1Tokens[i].trim());
- }
- assertEquals(superTool.getInterfaceExtensions(), expectedSuperInterfaceExt1List);
-
- assertTrue(superTool.isAbstract());
-
- // Fetch and check an option category
- //
- IOptionCategory[] optionCats = superTool.getChildCategories();
- assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
-
- // Fetch and check options customized for this tool
- //
- IOption option;
-
- // Fetch the optimization level option and verify that it has the proper
- // default value, which should overwrite the value set in the abstract
- // project that its containing project is derived from
- //
- option = tool.getOptionById(OptionId1[iconfig]);
- assertTrue(option.isExtensionElement());
- String optionDefaultValue = (String)option.getDefaultValue();
- assertEquals(option.getValueType(), (IOption.ENUMERATED));
- assertEquals(optionDefaultValue, (expectedOptionIdValue1[iconfig]));
- String optionEnumCmd1 = option.getEnumCommand(optionDefaultValue);
- assertEquals(optionEnumCmd1, (expectedOptionEnumCmd1arr[iconfig]));
- List expectedEnumList1arr = new ArrayList();
- String enumValues[] = option.getApplicableValues();
- String[] expectedEnumList1Tokens = expectedEnumList1.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedEnumList1Tokens.length; ++i) {
- expectedEnumList1arr.add(expectedEnumList1Tokens[i].trim());
- }
- assertTrue(Arrays.equals(option.getApplicableValues(), (String[]) expectedEnumList1arr.toArray(new String[expectedSizeEnumList1])));
-
- // Fetch the debug other option and verify
- //
- option = tool.getOptionById(OptionId2);
- assertTrue(option.isExtensionElement());
- assertEquals(option.getValueType(), (IOption.STRING));
- assertEquals(option.getName(), (expectedOptionIdName2));
-
- // Fetch the debug gprof option and verify
- //
- option = tool.getOptionById(OptionId3);
- assertTrue(option.isExtensionElement());
- assertEquals(option.getValueType(), (IOption.BOOLEAN));
- boolean optionDefaultValueb = option.getBooleanValue();
- assertEquals(optionDefaultValueb, (expectedOptionIdValue3));
- assertEquals(option.getName(), (expectedOptionIdName3));
- assertEquals(option.getCommand(), (expectedOptionIdCmd3));
-
- } // end for
- } // end routine
-
- /*
- * Do a sanity check on the testgnu so project type.
- */
- private void checkSoProjectType(IProjectType ptype) throws BuildException {
- int i;
- int expecectedNumConfigs = 2;
- String[] expectedConfigName = {"Debug", "Release"};
- String expectedCleanCmd = "rm -rf";
- String expectedParserId = "org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser";
- String expectedArtifactExtension = "so";
- String expectedOSList = "solaris,linux,hpux,aix,qnx";
- int expectedSizeOSList = 5;
- String[] expectedArchList = {"all"};
- String expectedBinaryParser = "org.eclipse.cdt.core.ELF";
- String[] expectedPlatformName = {"so Debug Platform",
- "so Release Platform"};
- String expectedCommand = "make";
- String expectedArguments = "-k";
- String[] expectedBuilderName = {"so Debug Builder",
- "so Release Builder"};
- String expectedScannerInfo = "org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector";
- String[] expectedToolChainName = {"so Debug ToolChain",
- "so Release ToolChain"};
- String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.c.linker.so.debug",
- "cdt.managedbuild.tool.testgnu.c.linker.so.release"};
- String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.c.linker";
- String expectedToolOutputPrefix = "lib";
- String[] expectedToolOutput = {""};
- String expectedSuperOutputFlag1 = "-o";
- String expectedSuperGetToolCommand1 = "gcc";
- String expectedSuperInputExt1 = "o";
- String[] expectedSuperToolOutputExt1 = {""};
- String expectedOptionCategory1 = "testgnu.c.link.category.general";
- String OptionId1A = "testgnu.c.link.option.libs";
- String OptionId1B = "testgnu.c.link.option.paths";
- String OptionId1C = "testgnu.c.link.option.userobjs";
- String expectedOptionCmd1Aarr = "-l";
- String expectedOptionCmd1Barr = "-L";
- String OptionId2 = "testgnu.c.link.option.defname";
- String expectedOptionIdName2 = "Posix.Linker.Defname";
- String expectedOptionIdCmd2 = "-Wl,--output-def=";
- String OptionId3 = "testgnu.c.link.option.nostart";
- String expectedOptionIdName3 = "Posix.Linker.NoStartFiles";
- String expectedOptionIdCmd3 = "-nostartfiles";
- boolean expectedOptionIdValue3 = false;
- String OptionId4 = "testgnu.c.link.option.shared";
- String expectedOptionIdName4 = "Posix.Linker.Shared";
- String expectedOptionIdCmd4 = "-shared";
- boolean expectedOptionIdValue4 = false;
- int expecectedNumTools = 5;
- int numOrderCLinkerTool = 2;
- int expecectedCNature = ITool.FILTER_C;
- int expecectedCCNature = ITool.FILTER_CC;
-
- // Check project attributes
- //
- assertNotNull(ptype);
- assertTrue(ptype.isTestProjectType());
- assertFalse(ptype.isAbstract());
-
- // Check project configurations
- //
- IConfiguration[] configs = ptype.getConfigurations();
- assertNotNull(configs);
- assertEquals(expecectedNumConfigs, configs.length);
-
- // Loop over configurations
- //
- for (int iconfig=0; iconfig < configs.length; iconfig++) {
-
- // Verify configuration attributes
- //
- assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
- assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
- assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
- assertEquals(configs[iconfig].getArtifactExtension(), (expectedArtifactExtension));
-
- // Fetch toolchain and verify
- //
- IToolChain toolChain = configs[iconfig].getToolChain();
- assertEquals(toolChain.getName(), (expectedToolChainName[iconfig]));
-
- List expectedOSListarr = new ArrayList();
- String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedOSListTokens.length; ++i) {
- expectedOSListarr.add(expectedOSListTokens[i].trim());
- }
- assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
- assertTrue(Arrays.equals(toolChain.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
- assertTrue(Arrays.equals(toolChain.getArchList(), expectedArchList));
- IConfigurationElement element = toolChain.getScannerInfoCollectorElement();
- if (element != null) {
- assertEquals(element.getAttribute(IToolChain.SCANNER_INFO_ID), expectedScannerInfo);
- }
-
- // Fetch and check platform
- //
- ITargetPlatform platform = toolChain.getTargetPlatform();
- assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
- assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
- assertEquals(platform.getBinaryParserId(), expectedBinaryParser);
- assertEquals(platform.getName(), expectedPlatformName[iconfig]);
-
- // Fetch and check builder
- //
- IBuilder builder = toolChain.getBuilder();
- assertEquals(builder.getCommand(), expectedCommand);
- assertEquals(builder.getArguments(), expectedArguments);
- assertEquals(builder.getName(), expectedBuilderName[iconfig]);
-
- // Fetch and check tools list
- //
- ITool[] tools = toolChain.getTools();
- assertEquals(tools.length, expecectedNumTools);
-
- // Fetch and check the gnu C linker tool
- //
- ITool tool;
- ITool superTool;
-
- tool = tools[numOrderCLinkerTool];
- superTool = tool.getSuperClass();
- assertEquals(tool.getId(), expectedToolId1[iconfig]);
- assertEquals(superTool.getId(), expectedSuperToolId1);
- assertEquals(tool.getNatureFilter(), expecectedCNature);
- assertEquals(tool.getOutputPrefix(), expectedToolOutputPrefix);
- assertTrue(Arrays.equals(superTool.getOutputExtensions(), expectedToolOutput));
- List expectedSuperInputExt1List = new ArrayList();
- String[] expectedSuperInputExt1Tokens = expectedSuperInputExt1.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedSuperInputExt1Tokens.length; ++i) {
- expectedSuperInputExt1List.add(expectedSuperInputExt1Tokens[i].trim());
- }
- assertEquals(superTool.getInputExtensions(), expectedSuperInputExt1List);
- assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
- assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
- assertTrue(Arrays.equals(superTool.getOutputExtensions(), expectedSuperToolOutputExt1));
-
- // Fetch and check an option category
- //
- IOptionCategory[] optionCats = superTool.getChildCategories();
- assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
-
- // Fetch and check options customized for this tool
- //
- IOption option;
-
- // Fetch the libs option and verify
- //
- option = tool.getOptionById(OptionId1A);
- assertTrue(option.isExtensionElement());
- String optionDefaultValue = (String)option.getDefaultValue();
- assertEquals(option.getValueType(), (IOption.LIBRARIES));
- assertEquals(option.getCommand(), (expectedOptionCmd1Aarr));
- assertEquals(option.getBrowseType(), (IOption.BROWSE_FILE));
-
- // Fetch the libsearch option and verify
- //
- option = tool.getOptionById(OptionId1B);
- assertTrue(option.isExtensionElement());
- optionDefaultValue = (String)option.getDefaultValue();
- assertEquals(option.getValueType(), (IOption.STRING_LIST));
- assertEquals(option.getCommand(), (expectedOptionCmd1Barr));
- assertEquals(option.getBrowseType(), (IOption.BROWSE_DIR));
-
- // Fetch the user objs option and verify
- //
- option = tool.getOptionById(OptionId1C);
- assertTrue(option.isExtensionElement());
- optionDefaultValue = (String)option.getDefaultValue();
- assertEquals(option.getValueType(), (IOption.OBJECTS));
- assertEquals(option.getBrowseType(), (IOption.BROWSE_FILE));
-
- // Fetch the defname option and verify
- //
- option = tool.getOptionById(OptionId2);
- assertTrue(option.isExtensionElement());
- assertEquals(option.getValueType(), (IOption.STRING));
- assertEquals(option.getName(), (expectedOptionIdName2));
- assertEquals(option.getCommand(), (expectedOptionIdCmd2));
-
- // Fetch the nostartfiles option and verify
- //
- option = tool.getOptionById(OptionId3);
- assertTrue(option.isExtensionElement());
- assertEquals(option.getValueType(), (IOption.BOOLEAN));
- boolean optionDefaultValueb1 = option.getBooleanValue();
- assertEquals(optionDefaultValueb1, (expectedOptionIdValue3));
- assertEquals(option.getName(), (expectedOptionIdName3));
- assertEquals(option.getCommand(), (expectedOptionIdCmd3));
-
- // Fetch the shared option and verify that it has the proper
- // default value, which should overwrite the value set in the abstract
- // project that its containing project is derived from
- //
- option = tool.getOptionById(OptionId4);
- assertTrue(option.isExtensionElement());
- assertEquals(option.getValueType(), (IOption.BOOLEAN));
- boolean optionDefaultValueb2 = option.getBooleanValue();
- assertEquals(optionDefaultValueb2, (expectedOptionIdValue4));
- assertEquals(option.getName(), (expectedOptionIdName4));
- assertEquals(option.getCommand(), (expectedOptionIdCmd4));
-
- } // end for
- } //end routine
-
- /*
- * Do a sanity check on the testgnu lib project type.
- */
- private void checkLibProjectType(IProjectType ptype) throws BuildException {
- int i;
- int expecectedNumConfigs = 2;
- String[] expectedConfigName = {"Dbg", "Rel"};
- String expectedCleanCmd = "rm -rf";
- String expectedParserId = "org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser";
- String expectedArtifactExtension = "a";
- String expectedOSList = "solaris,linux,hpux,aix,qnx";
- int expectedSizeOSList = 5;
- String[] expectedArchList = {"all"};
- String expectedBinaryParser = "org.eclipse.cdt.core.ELF";
- String[] expectedPlatformName = {"Dbg P",
- "Rel P"};
- String expectedCommand = "make";
- String expectedArguments = "-k";
- String[] expectedBuilderName = {"Dbg B",
- "Rel B"};
- String expectedScannerInfo = "org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector";
- String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.cpp.compiler.lib.debug",
- "cdt.managedbuild.tool.testgnu.cpp.compiler.lib.release"};
- String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.cpp.compiler";
- String expectedSuperOutputFlag1 = "-o";
- String expectedSuperGetToolCommand1 = "g++";
- String expectedSuperInputExt1 = "c,C,cc,cxx,cpp";
- String expectedSuperToolInterfaceExt1 = "h,H,hpp";
- String[] expectedSuperToolOutputExt1 = {"o"};
- String expectedOptionCategory1 = "testgnu.cpp.compiler.category.preprocessor";
- String[] OptionId1 = {"testgnu.cpp.compiler.lib.debug.option.optimization.level",
- "testgnu.cpp.compiler.lib.release.option.optimization.level"};
- String[] expectedOptionIdValue1 = {"testgnu.cpp.compiler.optimization.level.none",
- "testgnu.cpp.compiler.optimization.level.most"};
- String expectedEnumList1 = "Posix.Optimize.None, Posix.Optimize.Optimize, Posix.Optimize.More, Posix.Optimize.Most";
- int expectedSizeEnumList1 = 4;
- String[] expectedOptionEnumCmd1arr = {"-O0", "-O3"};
-
- String OptionId2 = "testgnu.cpp.compiler.option.other.other";
- String expectedOptionIdName2 = "OtherFlags";
-
- String OptionId3 = "testgnu.cpp.compiler.option.other.verbose";
- String expectedOptionIdName3 = "Posix.Verbose";
- String expectedOptionIdCmd3 = "-v";
- boolean expectedOptionIdValue3 = false;
- int expecectedNumTools = 4;
- int numOrderCppCompilerTool = 1;
- int expecectedCNature = ITool.FILTER_C;
- int expecectedCCNature = ITool.FILTER_CC;
-
- // Check project attributes
- //
- assertNotNull(ptype);
- assertTrue(ptype.isTestProjectType());
- assertFalse(ptype.isAbstract());
-
- // Check project configurations
- //
- IConfiguration[] configs = ptype.getConfigurations();
- assertNotNull(configs);
- assertEquals(expecectedNumConfigs, configs.length);
-
- // Loop over configurations
- //
- for (int iconfig=0; iconfig < configs.length; iconfig++) {
-
- // Verify configuration attributes
- //
- assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
- assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
- assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
- assertEquals(configs[iconfig].getArtifactExtension(), (expectedArtifactExtension));
-
- // Fetch toolchain and verify
- //
- IToolChain toolChain = configs[iconfig].getToolChain();
-
- List expectedOSListarr = new ArrayList();
- String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedOSListTokens.length; ++i) {
- expectedOSListarr.add(expectedOSListTokens[i].trim());
- }
- assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
- assertTrue(Arrays.equals(toolChain.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
- assertTrue(Arrays.equals(toolChain.getArchList(), expectedArchList));
- IConfigurationElement element = toolChain.getScannerInfoCollectorElement();
- if (element != null) {
- assertEquals(element.getAttribute(IToolChain.SCANNER_INFO_ID), expectedScannerInfo);
- }
-
- // Fetch and check platform
- //
- ITargetPlatform platform = toolChain.getTargetPlatform();
- assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
- assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
- assertEquals(platform.getBinaryParserId(), expectedBinaryParser);
- assertEquals(platform.getName(), expectedPlatformName[iconfig]);
-
- // Fetch and check builder
- //
- IBuilder builder = toolChain.getBuilder();
- assertEquals(builder.getCommand(), expectedCommand);
- assertEquals(builder.getArguments(), expectedArguments);
- assertEquals(builder.getName(), expectedBuilderName[iconfig]);
-
- // Fetch and check tools list
- //
- ITool[] tools = toolChain.getTools();
- assertEquals(tools.length, expecectedNumTools);
-
- // Fetch and check the gnu Cpp compiler tool
- //
- ITool tool;
- ITool superTool;
-
- tool = tools[numOrderCppCompilerTool];
- superTool = tool.getSuperClass();
- assertEquals(tool.getId(), expectedToolId1[iconfig]);
- assertEquals(superTool.getId(), expectedSuperToolId1);
- assertEquals(tool.getNatureFilter(), expecectedCCNature);
-
- List expectedSuperInputExt1List = new ArrayList();
- String[] expectedSuperInputExt1Tokens = expectedSuperInputExt1.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedSuperInputExt1Tokens.length; ++i) {
- expectedSuperInputExt1List.add(expectedSuperInputExt1Tokens[i].trim());
- }
- assertEquals(superTool.getInputExtensions(), expectedSuperInputExt1List);
- assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
- assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
- List expectedSuperInterfaceExt1List = new ArrayList();
- String[] expectedSuperInterfaceExt1Tokens = expectedSuperToolInterfaceExt1.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedSuperInterfaceExt1Tokens.length; ++i) {
- expectedSuperInterfaceExt1List.add(expectedSuperInterfaceExt1Tokens[i].trim());
- }
- assertEquals(superTool.getInterfaceExtensions(), expectedSuperInterfaceExt1List);
- assertTrue(Arrays.equals(superTool.getOutputExtensions(), expectedSuperToolOutputExt1));
-
- // Fetch and check an option category
- //
- IOptionCategory[] optionCats = superTool.getChildCategories();
- assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
-
- // Fetch and check options customized for this tool
- //
- IOption option;
-
- // Fetch the optimization level option and verify that it has the proper
- // default value, which should overwrite the value set in the abstract
- // project that its containing project is derived from
- //
- option = tool.getOptionById(OptionId1[iconfig]);
- assertTrue(option.isExtensionElement());
- String optionDefaultValue = (String)option.getDefaultValue();
- assertEquals(option.getValueType(), (IOption.ENUMERATED));
- assertEquals(optionDefaultValue, (expectedOptionIdValue1[iconfig]));
- String optionEnumCmd1 = option.getEnumCommand(optionDefaultValue);
- assertEquals(optionEnumCmd1, (expectedOptionEnumCmd1arr[iconfig]));
-
- List expectedEnumList1arr = new ArrayList();
- String enumValues[] = option.getApplicableValues();
- String[] expectedEnumList1Tokens = expectedEnumList1.split(","); //$NON-NLS-1$
- for (i = 0; i < expectedEnumList1Tokens.length; ++i) {
- expectedEnumList1arr.add(expectedEnumList1Tokens[i].trim());
- }
- assertTrue(Arrays.equals(option.getApplicableValues(), (String[]) expectedEnumList1arr.toArray(new String[expectedSizeEnumList1])));
-
- // Fetch the other flags option and verify
- //
- option = tool.getOptionById(OptionId2);
- assertTrue(option.isExtensionElement());
- assertEquals(option.getValueType(), (IOption.STRING));
- assertEquals(option.getName(), (expectedOptionIdName2));
-
- // Fetch the verbose option and verify
- //
- option = tool.getOptionById(OptionId3);
- assertTrue(option.isExtensionElement());
- assertEquals(option.getValueType(), (IOption.BOOLEAN));
- boolean optionDefaultValueb = option.getBooleanValue();
- assertEquals(optionDefaultValueb, (expectedOptionIdValue3));
- assertEquals(option.getName(), (expectedOptionIdName3));
- assertEquals(option.getCommand(), (expectedOptionIdCmd3));
-
- } // end for
- } // end routine
-} // end class
-
+/**********************************************************************
+ * Copyright (c) 2004 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.managedbuild.core.tests;
+
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+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.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+
+public class ManagedBuildCoreTests extends TestCase {
+ private static final boolean boolVal = true;
+ private static IProjectType exeType;
+ private static IProjectType libType;
+ private static IProjectType dllType;
+
+ public ManagedBuildCoreTests(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(ManagedBuildCoreTests.class.getName());
+ suite.addTest(new ManagedBuildCoreTests("testLoadManifest"));
+ return suite;
+ }
+
+ /**
+ * Navigates through a CDT 2.1 manifest file and verifies that the
+ * definitions are loaded correctly.
+ */
+ public void testLoadManifest() throws Exception {
+ IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes();
+ exeType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.exe");
+ checkExeProjectType(exeType);
+ dllType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.so");
+ checkSoProjectType(dllType);
+ libType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.lib");
+ checkLibProjectType(libType);
+ }
+
+
+ /*
+ * Do a sanity check on the testgnu exe project type.
+ */
+ private void checkExeProjectType(IProjectType ptype) throws BuildException {
+ int i;
+ int expecectedNumConfigs = 2;
+ String[] expectedConfigName = {"Dbg", "Rel"};
+ String expectedCleanCmd = "rm -rf";
+ String expectedParserId = "org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser";
+ String expectedOSList = "solaris,linux,hpux,aix,qnx";
+ int expectedSizeOSList = 5;
+ String[] expectedArchList = {"all"};
+ String expectedBinaryParserELF = "org.eclipse.cdt.core.ELF";
+ String expectedBinaryParserPE = "org.eclipse.cdt.core.PE";
+ String[] expectedPlatformName = {"Dbg Platform",
+ "Rel Platform"};
+ String expectedCommand = "make";
+ String expectedArguments = "-k";
+ String[] expectedBuilderName = {"Dbg Builder",
+ "Rel Builder"};
+ String expectedBuilderInfo = "org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator";
+ String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.c.compiler.exe.debug",
+ "cdt.managedbuild.tool.testgnu.c.compiler.exe.release"};
+ String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.c.compiler";
+ String expectedSuperOutputFlag1 = "-o";
+ String expectedSuperGetToolCommand1 = "gcc";
+ String expectedSuperInputExt1 = "c";
+ String expectedSuperToolInterfaceExt1 = "h";
+ String[] expectedSuperToolOutputExt1 = {"o"};
+ String expectedOptionCategory1 = "testgnu.c.compiler.category.preprocessor";
+ String[] OptionId1 = {"testgnu.c.compiler.exe.debug.option.optimization.level",
+ "testgnu.c.compiler.exe.release.option.optimization.level"};
+ String[] expectedOptionIdValue1 = {"testgnu.c.optimization.level.none",
+ "testgnu.c.optimization.level.most"};
+ String expectedEnumList1 = "Posix.Optimize.None, Posix.Optimize.Optimize, Posix.Optimize.More, Posix.Optimize.Most";
+ int expectedSizeEnumList1 = 4;
+ String[] expectedOptionEnumCmd1arr = {"-O0", "-O3"};
+ String OptionId2 = "testgnu.c.compiler.option.debugging.other";
+ String expectedOptionIdName2 = "Posix.Debug.Other";
+ String OptionId3 = "testgnu.c.compiler.option.debugging.gprof";
+ String expectedOptionIdName3 = "Posix.Debug.gprof";
+ String expectedOptionIdCmd3 = "-pg";
+ boolean expectedOptionIdValue3 = false;
+ int expecectedNumTools = 5;
+ int numOrderCCompilerTool = 0;
+ int expecectedCNature = ITool.FILTER_C;
+ int expecectedCCNature = ITool.FILTER_CC;
+
+ // Check project attributes
+ //
+ assertNotNull(ptype);
+ assertTrue(ptype.isTestProjectType());
+ assertFalse(ptype.isAbstract());
+
+ // Check project configurations
+ //
+ IConfiguration[] configs = ptype.getConfigurations();
+ assertNotNull(configs);
+ assertEquals(expecectedNumConfigs, configs.length);
+
+ // Loop over configurations
+ //
+ for (int iconfig=0; iconfig < configs.length; iconfig++) {
+
+ // Verify configuration attributes
+ //
+ assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
+ assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
+ assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
+
+ // Fetch toolchain
+ //
+ IToolChain toolChain = configs[iconfig].getToolChain();
+
+ // Fetch and check platform
+ //
+ ITargetPlatform platform = toolChain.getTargetPlatform();
+
+ List expectedOSListarr = new ArrayList();
+ String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedOSListTokens.length; ++i) {
+ expectedOSListarr.add(expectedOSListTokens[i].trim());
+ }
+ assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
+ assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
+ // Target platform may have several binary parsers.
+ String[] binaryParsers = platform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 2);
+ assertEquals(binaryParsers[0], expectedBinaryParserELF);
+ assertEquals(binaryParsers[1], expectedBinaryParserPE);
+ assertEquals(platform.getName(), expectedPlatformName[iconfig]);
+
+ // Fetch and check builder
+ //
+ IBuilder builder = toolChain.getBuilder();
+ assertEquals(builder.getCommand(), expectedCommand);
+ assertEquals(builder.getArguments(), expectedArguments);
+ assertEquals(builder.getName(), expectedBuilderName[iconfig]);
+ IConfigurationElement element = builder.getBuildFileGeneratorElement();
+ if (element != null) {
+ assertEquals(element.getAttribute(IBuilder.BUILDFILEGEN_ID), expectedBuilderInfo);
+ }
+
+ // Fetch and check tools list
+ //
+ ITool[] tools = toolChain.getTools();
+ assertEquals(tools.length, expecectedNumTools);
+
+ // Fetch and check the gnu C compiler tool
+ //
+ ITool tool;
+ ITool superTool;
+
+ tool = tools[numOrderCCompilerTool];
+ superTool = tool.getSuperClass();
+ assertEquals(tool.getId(), expectedToolId1[iconfig]);
+ assertEquals(superTool.getId(), expectedSuperToolId1);
+ assertEquals(tool.getNatureFilter(), expecectedCNature);
+ List expectedSuperInputExt1List = new ArrayList();
+ String[] expectedSuperInputExt1Tokens = expectedSuperInputExt1.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedSuperInputExt1Tokens.length; ++i) {
+ expectedSuperInputExt1List.add(expectedSuperInputExt1Tokens[i].trim());
+ }
+ assertEquals(superTool.getInputExtensions(), expectedSuperInputExt1List);
+ assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
+ assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
+ assertTrue(Arrays.equals(superTool.getOutputExtensions(), expectedSuperToolOutputExt1));
+ List expectedSuperInterfaceExt1List = new ArrayList();
+ String[] expectedSuperInterfaceExt1Tokens = expectedSuperToolInterfaceExt1.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedSuperInterfaceExt1Tokens.length; ++i) {
+ expectedSuperInterfaceExt1List.add(expectedSuperInterfaceExt1Tokens[i].trim());
+ }
+ assertEquals(superTool.getInterfaceExtensions(), expectedSuperInterfaceExt1List);
+
+ assertTrue(superTool.isAbstract());
+
+ // Fetch and check an option category
+ //
+ IOptionCategory[] optionCats = superTool.getChildCategories();
+ assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
+
+ // Fetch and check options customized for this tool
+ //
+ IOption option;
+
+ // Fetch the optimization level option and verify that it has the proper
+ // default value, which should overwrite the value set in the abstract
+ // project that its containing project is derived from
+ //
+ option = tool.getOptionById(OptionId1[iconfig]);
+ assertTrue(option.isExtensionElement());
+ String optionDefaultValue = (String)option.getDefaultValue();
+ assertEquals(option.getValueType(), (IOption.ENUMERATED));
+ assertEquals(optionDefaultValue, (expectedOptionIdValue1[iconfig]));
+ String optionEnumCmd1 = option.getEnumCommand(optionDefaultValue);
+ assertEquals(optionEnumCmd1, (expectedOptionEnumCmd1arr[iconfig]));
+ List expectedEnumList1arr = new ArrayList();
+ String enumValues[] = option.getApplicableValues();
+ String[] expectedEnumList1Tokens = expectedEnumList1.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedEnumList1Tokens.length; ++i) {
+ expectedEnumList1arr.add(expectedEnumList1Tokens[i].trim());
+ }
+ assertTrue(Arrays.equals(option.getApplicableValues(), (String[]) expectedEnumList1arr.toArray(new String[expectedSizeEnumList1])));
+
+ // Fetch the debug other option and verify
+ //
+ option = tool.getOptionById(OptionId2);
+ assertTrue(option.isExtensionElement());
+ assertEquals(option.getValueType(), (IOption.STRING));
+ assertEquals(option.getName(), (expectedOptionIdName2));
+
+ // Fetch the debug gprof option and verify
+ //
+ option = tool.getOptionById(OptionId3);
+ assertTrue(option.isExtensionElement());
+ assertEquals(option.getValueType(), (IOption.BOOLEAN));
+ boolean optionDefaultValueb = option.getBooleanValue();
+ assertEquals(optionDefaultValueb, (expectedOptionIdValue3));
+ assertEquals(option.getName(), (expectedOptionIdName3));
+ assertEquals(option.getCommand(), (expectedOptionIdCmd3));
+
+ } // end for
+ } // end routine
+
+ /*
+ * Do a sanity check on the testgnu so project type.
+ */
+ private void checkSoProjectType(IProjectType ptype) throws BuildException {
+ int i;
+ int expecectedNumConfigs = 2;
+ String[] expectedConfigName = {"Debug", "Release"};
+ String expectedCleanCmd = "rm -rf";
+ String expectedParserId = "org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser";
+ String expectedArtifactExtension = "so";
+ String expectedOSList = "solaris,linux,hpux,aix,qnx";
+ int expectedSizeOSList = 5;
+ String[] expectedArchList = {"all"};
+ String expectedBinaryParser = "org.eclipse.cdt.core.ELF";
+ String[] expectedPlatformName = {"so Debug Platform",
+ "so Release Platform"};
+ String expectedCommand = "make";
+ String expectedArguments = "-k";
+ String[] expectedBuilderName = {"so Debug Builder",
+ "so Release Builder"};
+ String expectedScannerInfo = "org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector";
+ String[] expectedToolChainName = {"so Debug ToolChain",
+ "so Release ToolChain"};
+ String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.c.linker.so.debug",
+ "cdt.managedbuild.tool.testgnu.c.linker.so.release"};
+ String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.c.linker";
+ String expectedToolOutputPrefix = "lib";
+ String[] expectedToolOutput = {""};
+ String expectedSuperOutputFlag1 = "-o";
+ String expectedSuperGetToolCommand1 = "gcc";
+ String expectedSuperInputExt1 = "o";
+ String[] expectedSuperToolOutputExt1 = {""};
+ String expectedOptionCategory1 = "testgnu.c.link.category.general";
+ String OptionId1A = "testgnu.c.link.option.libs";
+ String OptionId1B = "testgnu.c.link.option.paths";
+ String OptionId1C = "testgnu.c.link.option.userobjs";
+ String expectedOptionCmd1Aarr = "-l";
+ String expectedOptionCmd1Barr = "-L";
+ String OptionId2 = "testgnu.c.link.option.defname";
+ String expectedOptionIdName2 = "Posix.Linker.Defname";
+ String expectedOptionIdCmd2 = "-Wl,--output-def=";
+ String OptionId3 = "testgnu.c.link.option.nostart";
+ String expectedOptionIdName3 = "Posix.Linker.NoStartFiles";
+ String expectedOptionIdCmd3 = "-nostartfiles";
+ boolean expectedOptionIdValue3 = false;
+ String OptionId4 = "testgnu.c.link.option.shared";
+ String expectedOptionIdName4 = "Posix.Linker.Shared";
+ String expectedOptionIdCmd4 = "-shared";
+ boolean expectedOptionIdValue4 = false;
+ int expecectedNumTools = 5;
+ int numOrderCLinkerTool = 2;
+ int expecectedCNature = ITool.FILTER_C;
+ int expecectedCCNature = ITool.FILTER_CC;
+
+ // Check project attributes
+ //
+ assertNotNull(ptype);
+ assertTrue(ptype.isTestProjectType());
+ assertFalse(ptype.isAbstract());
+
+ // Check project configurations
+ //
+ IConfiguration[] configs = ptype.getConfigurations();
+ assertNotNull(configs);
+ assertEquals(expecectedNumConfigs, configs.length);
+
+ // Loop over configurations
+ //
+ for (int iconfig=0; iconfig < configs.length; iconfig++) {
+
+ // Verify configuration attributes
+ //
+ assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
+ assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
+ assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
+ assertEquals(configs[iconfig].getArtifactExtension(), (expectedArtifactExtension));
+
+ // Fetch toolchain and verify
+ //
+ IToolChain toolChain = configs[iconfig].getToolChain();
+ assertEquals(toolChain.getName(), (expectedToolChainName[iconfig]));
+
+ List expectedOSListarr = new ArrayList();
+ String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedOSListTokens.length; ++i) {
+ expectedOSListarr.add(expectedOSListTokens[i].trim());
+ }
+ assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
+ assertTrue(Arrays.equals(toolChain.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
+ assertTrue(Arrays.equals(toolChain.getArchList(), expectedArchList));
+ IConfigurationElement element = toolChain.getScannerInfoCollectorElement();
+ if (element != null) {
+ assertEquals(element.getAttribute(IToolChain.SCANNER_INFO_ID), expectedScannerInfo);
+ }
+
+ // Fetch and check platform
+ //
+ ITargetPlatform platform = toolChain.getTargetPlatform();
+ assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
+ assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
+ // Make the test work as before after introducing multiple binary parsers
+ String[] binaryParsers = platform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedBinaryParser);
+ assertEquals(platform.getName(), expectedPlatformName[iconfig]);
+
+ // Fetch and check builder
+ //
+ IBuilder builder = toolChain.getBuilder();
+ assertEquals(builder.getCommand(), expectedCommand);
+ assertEquals(builder.getArguments(), expectedArguments);
+ assertEquals(builder.getName(), expectedBuilderName[iconfig]);
+
+ // Fetch and check tools list
+ //
+ ITool[] tools = toolChain.getTools();
+ assertEquals(tools.length, expecectedNumTools);
+
+ // Fetch and check the gnu C linker tool
+ //
+ ITool tool;
+ ITool superTool;
+
+ tool = tools[numOrderCLinkerTool];
+ superTool = tool.getSuperClass();
+ assertEquals(tool.getId(), expectedToolId1[iconfig]);
+ assertEquals(superTool.getId(), expectedSuperToolId1);
+ assertEquals(tool.getNatureFilter(), expecectedCNature);
+ assertEquals(tool.getOutputPrefix(), expectedToolOutputPrefix);
+ assertTrue(Arrays.equals(superTool.getOutputExtensions(), expectedToolOutput));
+ List expectedSuperInputExt1List = new ArrayList();
+ String[] expectedSuperInputExt1Tokens = expectedSuperInputExt1.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedSuperInputExt1Tokens.length; ++i) {
+ expectedSuperInputExt1List.add(expectedSuperInputExt1Tokens[i].trim());
+ }
+ assertEquals(superTool.getInputExtensions(), expectedSuperInputExt1List);
+ assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
+ assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
+ assertTrue(Arrays.equals(superTool.getOutputExtensions(), expectedSuperToolOutputExt1));
+
+ // Fetch and check an option category
+ //
+ IOptionCategory[] optionCats = superTool.getChildCategories();
+ assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
+
+ // Fetch and check options customized for this tool
+ //
+ IOption option;
+
+ // Fetch the libs option and verify
+ //
+ option = tool.getOptionById(OptionId1A);
+ assertTrue(option.isExtensionElement());
+ String optionDefaultValue = (String)option.getDefaultValue();
+ assertEquals(option.getValueType(), (IOption.LIBRARIES));
+ assertEquals(option.getCommand(), (expectedOptionCmd1Aarr));
+ assertEquals(option.getBrowseType(), (IOption.BROWSE_FILE));
+
+ // Fetch the libsearch option and verify
+ //
+ option = tool.getOptionById(OptionId1B);
+ assertTrue(option.isExtensionElement());
+ optionDefaultValue = (String)option.getDefaultValue();
+ assertEquals(option.getValueType(), (IOption.STRING_LIST));
+ assertEquals(option.getCommand(), (expectedOptionCmd1Barr));
+ assertEquals(option.getBrowseType(), (IOption.BROWSE_DIR));
+
+ // Fetch the user objs option and verify
+ //
+ option = tool.getOptionById(OptionId1C);
+ assertTrue(option.isExtensionElement());
+ optionDefaultValue = (String)option.getDefaultValue();
+ assertEquals(option.getValueType(), (IOption.OBJECTS));
+ assertEquals(option.getBrowseType(), (IOption.BROWSE_FILE));
+
+ // Fetch the defname option and verify
+ //
+ option = tool.getOptionById(OptionId2);
+ assertTrue(option.isExtensionElement());
+ assertEquals(option.getValueType(), (IOption.STRING));
+ assertEquals(option.getName(), (expectedOptionIdName2));
+ assertEquals(option.getCommand(), (expectedOptionIdCmd2));
+
+ // Fetch the nostartfiles option and verify
+ //
+ option = tool.getOptionById(OptionId3);
+ assertTrue(option.isExtensionElement());
+ assertEquals(option.getValueType(), (IOption.BOOLEAN));
+ boolean optionDefaultValueb1 = option.getBooleanValue();
+ assertEquals(optionDefaultValueb1, (expectedOptionIdValue3));
+ assertEquals(option.getName(), (expectedOptionIdName3));
+ assertEquals(option.getCommand(), (expectedOptionIdCmd3));
+
+ // Fetch the shared option and verify that it has the proper
+ // default value, which should overwrite the value set in the abstract
+ // project that its containing project is derived from
+ //
+ option = tool.getOptionById(OptionId4);
+ assertTrue(option.isExtensionElement());
+ assertEquals(option.getValueType(), (IOption.BOOLEAN));
+ boolean optionDefaultValueb2 = option.getBooleanValue();
+ assertEquals(optionDefaultValueb2, (expectedOptionIdValue4));
+ assertEquals(option.getName(), (expectedOptionIdName4));
+ assertEquals(option.getCommand(), (expectedOptionIdCmd4));
+
+ } // end for
+ } //end routine
+
+ /*
+ * Do a sanity check on the testgnu lib project type.
+ */
+ private void checkLibProjectType(IProjectType ptype) throws BuildException {
+ int i;
+ int expecectedNumConfigs = 2;
+ String[] expectedConfigName = {"Dbg", "Rel"};
+ String expectedCleanCmd = "rm -rf";
+ String expectedParserId = "org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser";
+ String expectedArtifactExtension = "a";
+ String expectedOSList = "solaris,linux,hpux,aix,qnx";
+ int expectedSizeOSList = 5;
+ String[] expectedArchList = {"all"};
+ String expectedBinaryParser = "org.eclipse.cdt.core.ELF";
+ String[] expectedPlatformName = {"Dbg P",
+ "Rel P"};
+ String expectedCommand = "make";
+ String expectedArguments = "-k";
+ String[] expectedBuilderName = {"Dbg B",
+ "Rel B"};
+ String expectedScannerInfo = "org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector";
+ String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.cpp.compiler.lib.debug",
+ "cdt.managedbuild.tool.testgnu.cpp.compiler.lib.release"};
+ String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.cpp.compiler";
+ String expectedSuperOutputFlag1 = "-o";
+ String expectedSuperGetToolCommand1 = "g++";
+ String expectedSuperInputExt1 = "c,C,cc,cxx,cpp";
+ String expectedSuperToolInterfaceExt1 = "h,H,hpp";
+ String[] expectedSuperToolOutputExt1 = {"o"};
+ String expectedOptionCategory1 = "testgnu.cpp.compiler.category.preprocessor";
+ String[] OptionId1 = {"testgnu.cpp.compiler.lib.debug.option.optimization.level",
+ "testgnu.cpp.compiler.lib.release.option.optimization.level"};
+ String[] expectedOptionIdValue1 = {"testgnu.cpp.compiler.optimization.level.none",
+ "testgnu.cpp.compiler.optimization.level.most"};
+ String expectedEnumList1 = "Posix.Optimize.None, Posix.Optimize.Optimize, Posix.Optimize.More, Posix.Optimize.Most";
+ int expectedSizeEnumList1 = 4;
+ String[] expectedOptionEnumCmd1arr = {"-O0", "-O3"};
+
+ String OptionId2 = "testgnu.cpp.compiler.option.other.other";
+ String expectedOptionIdName2 = "OtherFlags";
+
+ String OptionId3 = "testgnu.cpp.compiler.option.other.verbose";
+ String expectedOptionIdName3 = "Posix.Verbose";
+ String expectedOptionIdCmd3 = "-v";
+ boolean expectedOptionIdValue3 = false;
+ int expecectedNumTools = 4;
+ int numOrderCppCompilerTool = 1;
+ int expecectedCNature = ITool.FILTER_C;
+ int expecectedCCNature = ITool.FILTER_CC;
+
+ // Check project attributes
+ //
+ assertNotNull(ptype);
+ assertTrue(ptype.isTestProjectType());
+ assertFalse(ptype.isAbstract());
+
+ // Check project configurations
+ //
+ IConfiguration[] configs = ptype.getConfigurations();
+ assertNotNull(configs);
+ assertEquals(expecectedNumConfigs, configs.length);
+
+ // Loop over configurations
+ //
+ for (int iconfig=0; iconfig < configs.length; iconfig++) {
+
+ // Verify configuration attributes
+ //
+ assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
+ assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
+ assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
+ assertEquals(configs[iconfig].getArtifactExtension(), (expectedArtifactExtension));
+
+ // Fetch toolchain and verify
+ //
+ IToolChain toolChain = configs[iconfig].getToolChain();
+
+ List expectedOSListarr = new ArrayList();
+ String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedOSListTokens.length; ++i) {
+ expectedOSListarr.add(expectedOSListTokens[i].trim());
+ }
+ assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
+ assertTrue(Arrays.equals(toolChain.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
+ assertTrue(Arrays.equals(toolChain.getArchList(), expectedArchList));
+ IConfigurationElement element = toolChain.getScannerInfoCollectorElement();
+ if (element != null) {
+ assertEquals(element.getAttribute(IToolChain.SCANNER_INFO_ID), expectedScannerInfo);
+ }
+
+ // Fetch and check platform
+ //
+ ITargetPlatform platform = toolChain.getTargetPlatform();
+ assertTrue(Arrays.equals(platform.getOSList(), (String[]) expectedOSListarr.toArray(new String[expectedSizeOSList])));
+ assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
+ // Make the test work as before after introducing multiple binary parsers
+ String[] binaryParsers = platform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedBinaryParser);
+ assertEquals(platform.getName(), expectedPlatformName[iconfig]);
+
+ // Fetch and check builder
+ //
+ IBuilder builder = toolChain.getBuilder();
+ assertEquals(builder.getCommand(), expectedCommand);
+ assertEquals(builder.getArguments(), expectedArguments);
+ assertEquals(builder.getName(), expectedBuilderName[iconfig]);
+
+ // Fetch and check tools list
+ //
+ ITool[] tools = toolChain.getTools();
+ assertEquals(tools.length, expecectedNumTools);
+
+ // Fetch and check the gnu Cpp compiler tool
+ //
+ ITool tool;
+ ITool superTool;
+
+ tool = tools[numOrderCppCompilerTool];
+ superTool = tool.getSuperClass();
+ assertEquals(tool.getId(), expectedToolId1[iconfig]);
+ assertEquals(superTool.getId(), expectedSuperToolId1);
+ assertEquals(tool.getNatureFilter(), expecectedCCNature);
+
+ List expectedSuperInputExt1List = new ArrayList();
+ String[] expectedSuperInputExt1Tokens = expectedSuperInputExt1.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedSuperInputExt1Tokens.length; ++i) {
+ expectedSuperInputExt1List.add(expectedSuperInputExt1Tokens[i].trim());
+ }
+ assertEquals(superTool.getInputExtensions(), expectedSuperInputExt1List);
+ assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
+ assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
+ List expectedSuperInterfaceExt1List = new ArrayList();
+ String[] expectedSuperInterfaceExt1Tokens = expectedSuperToolInterfaceExt1.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedSuperInterfaceExt1Tokens.length; ++i) {
+ expectedSuperInterfaceExt1List.add(expectedSuperInterfaceExt1Tokens[i].trim());
+ }
+ assertEquals(superTool.getInterfaceExtensions(), expectedSuperInterfaceExt1List);
+ assertTrue(Arrays.equals(superTool.getOutputExtensions(), expectedSuperToolOutputExt1));
+
+ // Fetch and check an option category
+ //
+ IOptionCategory[] optionCats = superTool.getChildCategories();
+ assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
+
+ // Fetch and check options customized for this tool
+ //
+ IOption option;
+
+ // Fetch the optimization level option and verify that it has the proper
+ // default value, which should overwrite the value set in the abstract
+ // project that its containing project is derived from
+ //
+ option = tool.getOptionById(OptionId1[iconfig]);
+ assertTrue(option.isExtensionElement());
+ String optionDefaultValue = (String)option.getDefaultValue();
+ assertEquals(option.getValueType(), (IOption.ENUMERATED));
+ assertEquals(optionDefaultValue, (expectedOptionIdValue1[iconfig]));
+ String optionEnumCmd1 = option.getEnumCommand(optionDefaultValue);
+ assertEquals(optionEnumCmd1, (expectedOptionEnumCmd1arr[iconfig]));
+
+ List expectedEnumList1arr = new ArrayList();
+ String enumValues[] = option.getApplicableValues();
+ String[] expectedEnumList1Tokens = expectedEnumList1.split(","); //$NON-NLS-1$
+ for (i = 0; i < expectedEnumList1Tokens.length; ++i) {
+ expectedEnumList1arr.add(expectedEnumList1Tokens[i].trim());
+ }
+ assertTrue(Arrays.equals(option.getApplicableValues(), (String[]) expectedEnumList1arr.toArray(new String[expectedSizeEnumList1])));
+
+ // Fetch the other flags option and verify
+ //
+ option = tool.getOptionById(OptionId2);
+ assertTrue(option.isExtensionElement());
+ assertEquals(option.getValueType(), (IOption.STRING));
+ assertEquals(option.getName(), (expectedOptionIdName2));
+
+ // Fetch the verbose option and verify
+ //
+ option = tool.getOptionById(OptionId3);
+ assertTrue(option.isExtensionElement());
+ assertEquals(option.getValueType(), (IOption.BOOLEAN));
+ boolean optionDefaultValueb = option.getBooleanValue();
+ assertEquals(optionDefaultValueb, (expectedOptionIdValue3));
+ assertEquals(option.getName(), (expectedOptionIdName3));
+ assertEquals(option.getCommand(), (expectedOptionIdCmd3));
+
+ } // end for
+ } // end routine
+} // end class
+
Index: D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests20.java
===================================================================
--- D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests20.java (revision 13)
+++ D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedBuildCoreTests20.java (working copy)
@@ -1,1921 +1,1936 @@
-/**********************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.cdt.managedbuild.core.tests;
-
-import java.io.ByteArrayInputStream;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.parser.CodeReader;
-import org.eclipse.cdt.core.parser.IParser;
-import org.eclipse.cdt.core.parser.IScanner;
-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.core.parser.ISourceElementRequestor;
-import org.eclipse.cdt.core.parser.NullLogService;
-import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
-import org.eclipse.cdt.core.parser.ParserFactory;
-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.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.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.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-/*
- * These tests exercise CDT 2.0 manifest file functionality
- */
-public class ManagedBuildCoreTests20 extends TestCase {
- private static final boolean boolVal = true;
- private static final String testConfigId = "test.config.override";
- private static final String testConfigName = "Tester";
- private static final String enumVal = "Another Enum";
- private static final String[] listVal = {"_DEBUG", "/usr/include", "libglade.a"};
- private static final String newExt = "wen";
- private static final String projectName = "ManagedBuildTest";
- private static final String projectName2 = "ManagedBuildTest2";
- private static final String projectRename = "ManagedBuildRedux";
- private static final String rootExt = "toor";
- private static final String stringVal = "-c -Wall";
- private static final String anotherStringVal = "thevalue";
- private static final String subExt = "bus";
-
- public ManagedBuildCoreTests20(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ManagedBuildCoreTests20.class.getName());
-
- suite.addTest(new ManagedBuildCoreTests20("testExtensions"));
- suite.addTest(new ManagedBuildCoreTests20("testProjectCreation"));
- suite.addTest(new ManagedBuildCoreTests20("testConfigurations"));
- suite.addTest(new ManagedBuildCoreTests20("testConfigurationReset"));
- suite.addTest(new ManagedBuildCoreTests20("testConfigBuildArtifact"));
- suite.addTest(new ManagedBuildCoreTests20("testMakeCommandManipulation"));
- suite.addTest(new ManagedBuildCoreTests20("testScannerInfoInterface"));
- suite.addTest(new ManagedBuildCoreTests20("testBug43450"));
- suite.addTest(new ManagedBuildCoreTests20("testProjectRename"));
- suite.addTest(new ManagedBuildCoreTests20("testErrorParsers"));
- suite.addTest(new ManagedBuildCoreTests20("cleanup"));
-
- return suite;
- }
-
- /**
- * Navigates through the build info as defined in the extensions
- * defined in this plugin
- */
- public void testExtensions() throws Exception {
- 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
- IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes();
-
- for (int i = 0; i < projTypes.length; ++i) {
- IProjectType type = projTypes[i];
-
- 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);
- checkForwardProjectTypes(testForwardParent, testForwardChild, testForwardGrandchild);
-
- // check that the proper number of projectTypes were dynamically provided
- assertEquals(3, numTypes);
-
- // All these project types are defines in the plugin files, so none
- // of them should be null at this point
- assertNotNull(testRoot);
- assertNotNull(testSub);
- assertNotNull(testSubSub);
- }
-
- /**
- * This test exercises the interface the <code>IConfiguration</code> exposes to manipulate
- * its make command.
- */
- public void testMakeCommandManipulation () {
- String oldMakeCmd = "make";
- String newMakeCmd = "Ant";
-
- // Open the test project
- IProject project = null;
- try {
- project = createProject(projectName);
- IProjectDescription description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
- } catch (CoreException e) {
- fail("Failed to open project in 'testMakeCommandManipulation': " + e.getLocalizedMessage());
- }
- assertNotNull(project);
-
- // 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 build command
- assertFalse(defaultConfig.hasOverriddenBuildCommand());
- assertEquals(oldMakeCmd, defaultConfig.getBuildCommand());
-
- // Change it
- defaultConfig.setBuildCommand(newMakeCmd);
- assertEquals(newMakeCmd, defaultConfig.getBuildCommand());
- assertTrue(defaultConfig.hasOverriddenBuildCommand());
-
- // Reset it
- defaultConfig.setBuildCommand(null);
- assertFalse(defaultConfig.hasOverriddenBuildCommand());
- assertEquals(oldMakeCmd, defaultConfig.getBuildCommand());
-
- ManagedBuildManager.saveBuildInfo(project, false);
- }
-
-
- /**
- * The purpose of this test is to exercise the build path info interface.
- * To get to that point, a new project/config has to be created in the test
- * project and the default configuration changed.
- *
- * @throws CoreException
- */
- public void testScannerInfoInterface(){
- // Open the test project
- IProject project = null;
- try {
- project = createProject(projectName);
- IProjectDescription description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
- } catch (CoreException e) {
- fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage());
- }
-
- //These are the expected path settings
- final String[] expectedPaths = new String[5];
-
- // This first path is a built-in, so it will not be manipulated by build manager
- expectedPaths[0] = "/usr/gnu/include";
- expectedPaths[1] = (new Path("/usr/include")).toOSString();
- expectedPaths[2] = (new Path("/opt/gnome/include")).toOSString();
- expectedPaths[3] = (new Path("C:\\home\\tester/include")).toOSString();
- expectedPaths[4] = project.getLocation().append( "Sub Config\\\"..\\includes\"" ).toOSString();
-
- // 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 = projType.getConfigurations();
- for (int i = 0; i < baseConfigs.length; ++i) {
- newProject.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
- }
-
- // Change the default configuration to the sub config
- IConfiguration[] configs = newProject.getConfigurations();
- assertEquals(4, configs.length);
- IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
- buildInfo.setDefaultConfiguration(newProject.getConfiguration(configs[0].getId()));
-
- // 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");
- if (extensionPoint == null) {
- fail("Failed to retrieve the extension point ScannerInfoProvider.");
- }
-
- // Find the first IScannerInfoProvider that supplies build info for the project
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
- assertNotNull(provider);
-
- // Now subscribe (note that the method will be called after a change
- provider.subscribe(project, new IScannerInfoChangeListener () {
- public void changeNotification(IResource project, IScannerInfo info) {
- // Test the symbols: expect "BUILTIN" from the manifest, and "DEBUG" and "GNOME=ME"
- // from the overidden settings
- Map definedSymbols = info.getDefinedSymbols();
- assertTrue(definedSymbols.containsKey("BUILTIN"));
- assertTrue(definedSymbols.containsKey("DEBUG"));
- assertTrue(definedSymbols.containsKey("GNOME"));
- assertTrue(definedSymbols.containsValue("ME"));
- assertEquals((String)definedSymbols.get("BUILTIN"), "");
- assertEquals((String)definedSymbols.get("DEBUG"), "");
- assertEquals((String)definedSymbols.get("GNOME"), "ME");
- // Test the includes path
- String[] actualPaths = info.getIncludePaths();
- assertTrue(Arrays.equals(expectedPaths, actualPaths));
- }
- });
-
- // Check the build information before we change it
- IScannerInfo currentSettings = provider.getScannerInformation(project);
-
- Map currentSymbols = currentSettings.getDefinedSymbols();
- // It should simply contain the built-in
- assertTrue(currentSymbols.containsKey("BUILTIN"));
- assertEquals((String)currentSymbols.get("BUILTIN"), "");
- String[] currentPaths = currentSettings.getIncludePaths();
- assertTrue(Arrays.equals(expectedPaths, currentPaths));
-
- // Add some defined symbols programmatically
- String[] expectedSymbols = {"DEBUG", "GNOME = ME "};
- 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.getSuperClass().getId())) {
- subTool = tool;
- break;
- }
- }
- assertNotNull(subTool);
- IOption symbolOpt = null;
- IOption[] opts = subTool.getOptions();
- for (int i = 0; i < opts.length; i++) {
- IOption option = opts[i];
- 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, subTool, symbolOpt, expectedSymbols);
- assertTrue(info.isDirty());
- info.setDirty(false);
- assertFalse(info.isDirty());
- }
-
- /**
- * Create a new configuration based on one defined in the plugin file.
- * Overrides all of the configuration settings. Saves, closes, and reopens
- * the project. Then calls a method to check the overridden options.
- *
- * Tests creating a new configuration.
- * Tests setting options.
- * Tests persisting overridden options between project sessions.
- *
- */
- public void testConfigurations() throws CoreException, BuildException {
- final String rootName = "Root Config";
- final String overrideName = "Root Override Config";
- final String completeOverrideName = "Complete Override Config";
- final String toolCmd = "doIt";
- final String newCmd = "never";
-
- // Open the test project
- IProject project = createProject(projectName);
- IProjectDescription description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
-
- // 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);
- assertEquals(definedConfigs[1].getName(), overrideName);
- assertEquals(definedConfigs[2].getName(), completeOverrideName);
-
- // Create a new configuration and test the rename function
- IConfiguration newConfig = managedProj.createConfigurationClone(baseConfig, testConfigId);
- assertEquals(4, managedProj.getConfigurations().length);
- newConfig.setName(testConfigName);
- assertEquals(newConfig.getId(), testConfigId);
- assertEquals(newConfig.getName(), testConfigName);
-
- // There is only one tool
- ITool[] definedTools = newConfig.getTools();
- assertEquals(1, definedTools.length);
- ITool rootTool = definedTools[0];
-
- // Test changing its command
- assertEquals(rootTool.getToolCommand(), toolCmd);
- newConfig.setToolCommand(rootTool, newCmd);
- assertEquals(rootTool.getToolCommand(), newCmd);
-
- // Override options in the new configuration
- IOptionCategory topCategory = rootTool.getTopOptionCategory();
- assertEquals("Root Tool", topCategory.getName());
- Object[][] options = topCategory.getOptions(newConfig);
- int i;
- for (i=0; i<options.length; i++)
- if (options[i][0] == null) break;
- assertEquals(2, i);
- ITool tool = (ITool)options[0][0];
- IOption option = (IOption)options[0][1];
- ManagedBuildManager.setOption(newConfig, tool, option, listVal);
- option = (IOption)options[1][1];
- ManagedBuildManager.setOption(newConfig, tool, option, boolVal);
-
- IOptionCategory[] categories = topCategory.getChildCategories();
- assertEquals(1, categories.length);
- options = categories[0].getOptions(newConfig);
- for (i=0; i<options.length; i++)
- if (options[i][0] == null) break;
- assertEquals(4, i);
- tool = (ITool)options[0][0];
- option = (IOption)options[0][1];
- ManagedBuildManager.setOption(newConfig, tool, option, stringVal);
- option = (IOption)options[1][1];
- ManagedBuildManager.setOption(newConfig, tool, option, anotherStringVal);
- option = (IOption)options[2][1];
- ManagedBuildManager.setOption(newConfig, tool, option, enumVal);
- option = (IOption)options[3][1];
- ManagedBuildManager.setOption(newConfig, tool, option, "False");
-
- // Save, close, reopen and test again
- ManagedBuildManager.saveBuildInfo(project, false);
- ManagedBuildManager.removeBuildInfo(project);
- project.close(null);
- project.open(null);
-
- // Test the values in the new configuration
- checkOptionReferences(project);
-
- // Now delete the new configuration and test the managed project
- info = ManagedBuildManager.getBuildInfo(project);
- managedProj = info.getManagedProject();
- definedConfigs = managedProj.getConfigurations();
- assertEquals(4, definedConfigs.length);
- managedProj.removeConfiguration(testConfigId);
- definedConfigs = managedProj.getConfigurations();
- assertEquals(3, definedConfigs.length);
- assertEquals(definedConfigs[0].getName(), rootName);
- assertEquals(definedConfigs[1].getName(), overrideName);
- ManagedBuildManager.saveBuildInfo(project, false);
- }
-
- public void testConfigurationReset() {
- // Open the test project
- IProject project = null;
- try {
- project = createProject(projectName);
- IProjectDescription description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
- } catch (CoreException e) {
- fail("Failed to open project: " + e.getLocalizedMessage());
- }
-
- // Get the default configuration
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- assertNotNull(info);
- IManagedProject managedProj = info.getManagedProject();
- assertNotNull(managedProj);
- IConfiguration defaultConfig = info.getDefaultConfiguration();
- assertNotNull(defaultConfig);
-
- // See if it still contains the overridden values (see testProjectCreation())
- try {
- checkRootManagedProject(managedProj, "z");
- } catch (BuildException e1) {
- fail("Overridden root managed project check failed: " + e1.getLocalizedMessage());
- }
-
- // Reset the config and retest
- ManagedBuildManager.resetConfiguration(project, defaultConfig);
- ManagedBuildManager.saveBuildInfo(project, false);
- try {
- checkRootManagedProject(managedProj, "x");
- } catch (BuildException e2) {
- fail("Reset root managed project check failed: " + e2.getLocalizedMessage());
- }
- }
-
- /**
- * @throws CoreException
- * @throws BuildException
- */
- public void testProjectCreation() throws BuildException {
- // Create new project
- IProject project = null;
- try {
- project = createProject(projectName);
- // Now associate the builder with the project
- addManagedBuildNature(project);
- IProjectDescription description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
-
- } catch (CoreException e) {
- fail("Test failed on project creation: " + e.getLocalizedMessage());
- }
-
- // Find the base project type definition
- IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.root");
- assertNotNull(projType);
-
- // Create the managed-project (.cdtbuild) for our project that builds a dummy executable
- IManagedProject newProject = ManagedBuildManager.createManagedProject(project, projType);
- assertEquals(newProject.getName(), projType.getName());
- assertFalse(newProject.equals(projType));
- ManagedBuildManager.setNewProjectVersion(project);
-
- // Copy over the configs
- IConfiguration defaultConfig = null;
- IConfiguration[] configs = projType.getConfigurations();
- for (int i = 0; i < configs.length; ++i) {
- // Make the first configuration the default
- if (i == 0) {
- defaultConfig = newProject.createConfiguration(configs[i], projType.getId() + "." + i);
- } else {
- newProject.createConfiguration(configs[i], projType.getId() + "." + i);
- }
- }
- ManagedBuildManager.setDefaultConfiguration(project, defaultConfig);
-
- String buildArtifactName = projectName;
- defaultConfig.setArtifactName(buildArtifactName);
- defaultConfig.setArtifactExtension(newExt);
-
- // Initialize the path entry container
- IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project);
- if (initResult.getCode() != IStatus.OK) {
- fail("Initializing build information failed for: " + project.getName() + " because: " + initResult.getMessage());
- }
-
- // Now test the results out
- checkRootManagedProject(newProject, "x");
-
- // Override the "String Option in Category" option value
- configs = newProject.getConfigurations();
- ITool[] tools = configs[0].getTools();
- IOptionCategory topCategory = tools[0].getTopOptionCategory();
- IOptionCategory[] categories = topCategory.getChildCategories();
- Object[][] options = categories[0].getOptions(configs[0]);
- ITool tool = (ITool)options[0][0];
- IOption option = (IOption)options[0][1];
- configs[0].setOption(tool, option, "z");
- options = categories[0].getOptions((IConfiguration)null);
- tool = (ITool)options[0][0];
- option = (IOption)options[0][1];
- assertEquals("x", option.getStringValue());
- options = categories[0].getOptions(configs[0]);
- tool = (ITool)options[0][0];
- option = (IOption)options[0][1];
- assertEquals("z", option.getStringValue());
-
- // Save, close, reopen and test again
- 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());
- }
-
- // Test that the default config was remembered
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- assertEquals(defaultConfig.getId(), info.getDefaultConfiguration().getId());
-
- // Check the rest of the default information
- checkRootManagedProject(newProject, "z");
-
- // Now test the information the makefile builder needs
- checkBuildTestSettings(info);
- ManagedBuildManager.removeBuildInfo(project);
- }
-
- /**
- * Tests that bugzilla 44159 has been addressed. After a project was renamed, the
- * build information mistakenly referred to the old project as its owner. This
- * caused a number of searches on the information to fail. In this bug, it was the
- * list of tools that could not be determined. In other cases, the information
- * retrieval caused NPEs because the old owner no longer existed.
- */
- public void testProjectRename() {
- // Open the test project
- IProject project = null;
- try {
- project = createProject(projectName);
- IProjectDescription description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
- } catch (CoreException e) {
- fail("Failed to open project: " + e.getLocalizedMessage());
- }
-
- // Rename the project
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IResource newResource = workspaceRoot.findMember(projectRename);
- if (newResource != null) {
- try {
- newResource.delete(IResource.KEEP_HISTORY, new NullProgressMonitor());
- } catch (CoreException e) {
- fail("Failed to delete old project " + projectRename + ": " + e.getLocalizedMessage());
- }
- }
- IProjectDescription description = null;
- try {
- description = project.getDescription();
- } catch (CoreException e) {
- fail("Failed to find project descriptor for " + projectName + ": " + e.getLocalizedMessage());
- }
- description.setName(projectRename);
- try {
- project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
- } catch (CoreException e) {
- fail("Failed to rename project: " + e.getLocalizedMessage());
- }
- try {
- project = createProject(projectRename);
- description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
- } catch (CoreException e) {
- fail("Failed to open renamed project: " + e.getLocalizedMessage());
- }
-
- // By now the project should have 3 configs
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- IManagedProject managedProj = info.getManagedProject();
- IConfiguration[] definedConfigs = managedProj.getConfigurations();
- assertEquals(4, definedConfigs.length);
- IConfiguration baseConfig = definedConfigs[1];
-
- // There is only one tool
- ITool[] definedTools = baseConfig.getTools();
- assertEquals(1, definedTools.length);
- ITool rootTool = definedTools[0];
-
- // Get the options (2) in top category and (4) in its child
- IOptionCategory topCategory = rootTool.getTopOptionCategory();
- assertEquals("Root Tool", topCategory.getName());
- Object[][] options = topCategory.getOptions(baseConfig);
- int i;
- for (i=0; i<options.length; i++)
- if (options[i][0] == null) break;
- assertEquals(2, i);
- IOptionCategory[] categories = topCategory.getChildCategories();
- assertEquals(1, categories.length);
- options = categories[0].getOptions(baseConfig);
- for (i=0; i<options.length; i++)
- if (options[i][0] == null) break;
- assertEquals(4, i);
-
- // Set the name back
- newResource = workspaceRoot.findMember(projectName);
- if (newResource != null) {
- try {
- newResource.delete(IResource.KEEP_HISTORY, new NullProgressMonitor());
- } catch (CoreException e) {
- fail("Failed to delete old project " + projectName + ": " + e.getLocalizedMessage());
- }
- }
- try {
- description = project.getDescription();
- } catch (CoreException e) {
- fail("Failed to find project descriptor for " + projectRename + ": " + e.getLocalizedMessage());
- }
- description.setName(projectName);
- try {
- project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
- } catch (CoreException e) {
- fail("Failed to re-rename project: " + e.getLocalizedMessage());
- }
- try {
- project = createProject(projectName);
- description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
- } catch (CoreException e) {
- fail("Failed to open re-renamed project: " + e.getLocalizedMessage());
- }
-
- // Do it all again
- info = ManagedBuildManager.getBuildInfo(project);
- managedProj = info.getManagedProject();
- definedConfigs = managedProj.getConfigurations();
- assertEquals(4, definedConfigs.length);
- baseConfig = definedConfigs[1];
- definedTools = baseConfig.getTools();
- assertEquals(1, definedTools.length);
- rootTool = definedTools[0];
- topCategory = rootTool.getTopOptionCategory();
- assertEquals("Root Tool", topCategory.getName());
- options = topCategory.getOptions(baseConfig);
- for (i=0; i<options.length; i++)
- if (options[i][0] == null) break;
- assertEquals(2, i);
- categories = topCategory.getChildCategories();
- assertEquals(1, categories.length);
- options = categories[0].getOptions(baseConfig);
- for (i=0; i<options.length; i++)
- if (options[i][0] == null) break;
- assertEquals(4, i);
- }
-
- private void addManagedBuildNature (IProject project) {
- // Create the buildinformation object for the project
- IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
- info.setValid(true);
-
- // Add the managed build nature
- try {
- ManagedCProjectNature.addManagedNature(project, new NullProgressMonitor());
- ManagedCProjectNature.addManagedBuilder(project, new NullProgressMonitor());
- } catch (CoreException e) {
- fail("Test failed on adding managed build nature or builder: " + e.getLocalizedMessage());
- }
-
- // Associate the project with the managed builder so the clients can get proper information
- ICDescriptor desc = null;
- try {
- desc = CCorePlugin.getDefault().getCProjectDescription(project, true);
- desc.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
- desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
- } catch (CoreException e) {
- fail("Test failed on adding managed builder as scanner info provider: " + e.getLocalizedMessage());
- }
- try {
- desc.saveProjectData();
- } catch (CoreException e) {
- fail("Test failed on saving the ICDescriptor data: " + e.getLocalizedMessage()); }
- }
-
- /**
- * Tests the tool settings through the interface the makefile generator
- * uses.
- *
- * @param project
- */
- private void checkBuildTestSettings(IManagedBuildInfo info) {
- String ext1 = "foo";
- String ext2 = "bar";
- String badExt = "cpp";
- String expectedOutput = "toor";
- String expectedCmd = "doIt";
-
- assertNotNull(info);
- assertEquals(info.getBuildArtifactName(), projectName);
-
- // There should be a default configuration defined for the project
- IManagedProject managedProj = info.getManagedProject();
- assertNotNull(managedProj);
- IConfiguration buildConfig = info.getDefaultConfiguration();
- assertNotNull(buildConfig);
-
- // Check that tool handles resources with extensions foo and bar by building a baz
- assertEquals(info.getOutputExtension(ext1), expectedOutput);
- assertEquals(info.getOutputExtension(ext2), expectedOutput);
-
- // Check that it ignores others based on filename extensions
- assertNull(info.getOutputExtension(badExt));
-
- // Now see what the tool command line invocation is for foo and bar
- assertEquals(info.getToolForSource(ext1), expectedCmd);
- assertEquals(info.getToolForSource(ext2), expectedCmd);
- // Make sure that there is no tool to build files of type foo and bar
- assertNull(info.getToolForConfiguration(ext1));
- assertNull(info.getToolForConfiguration(ext2));
-
- // There is no tool that builds toor
- assertNull(info.getToolForSource(expectedOutput));
- // but there is one that produces it
- assertEquals(info.getToolForConfiguration(expectedOutput), expectedCmd);
-
- // Now check the build flags
- assertEquals(info.getFlagsForSource(ext1), "-La -Lb z -e1 -nob");
- assertEquals(info.getFlagsForSource(ext1), info.getFlagsForSource(ext2));
-
- }
-
- /**
- * Tests that overridden options are properly read into build model.
- * Test that option values that are not overridden remain the same.
- *
- * @param project The project to get build model information for.
- * @throws BuildException
- */
- private void checkOptionReferences(IProject project) throws BuildException {
- // Get the configs
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- IManagedProject managedProj = info.getManagedProject();
- IConfiguration[] definedConfigs = managedProj.getConfigurations();
- assertEquals(4, definedConfigs.length);
- IConfiguration newConfig = managedProj.getConfiguration(testConfigId);
- assertNotNull(newConfig);
-
- // Now get the tool options and make sure the values are correct
- ITool[] definedTools = newConfig.getTools();
- assertEquals(1, definedTools.length);
- ITool rootTool = definedTools[0];
-
- // Check that the options in the new config contain overridden values
- IOption[] rootOptions = rootTool.getOptions();
- assertEquals(6, rootOptions.length);
- // First is the new list
- assertEquals("List Option in Top", rootOptions[0].getName());
- assertEquals(IOption.STRING_LIST, rootOptions[0].getValueType());
- String[] list = rootOptions[0].getStringListValue();
- assertEquals(3, list.length);
- assertTrue(Arrays.equals(listVal, list));
- assertEquals(rootOptions[0].getCommand(), "-L");
- // Next option is a boolean in top
- assertEquals("Boolean Option in Top", rootOptions[1].getName());
- assertEquals(IOption.BOOLEAN, rootOptions[1].getValueType());
- assertEquals(boolVal, rootOptions[1].getBooleanValue());
- assertEquals("-b", rootOptions[1].getCommand());
- // Next option is a string in category
- assertEquals("String Option in Category", rootOptions[2].getName());
- assertEquals(IOption.STRING, rootOptions[2].getValueType());
- assertEquals(stringVal, rootOptions[2].getStringValue());
- // Next option is a another string in category
- assertEquals("Another String Option in Category", rootOptions[3].getName());
- assertEquals(IOption.STRING, rootOptions[3].getValueType());
- assertEquals(anotherStringVal, rootOptions[3].getStringValue());
- assertEquals("-str", rootOptions[3].getCommand());
- // Next option is an enumerated in category
- assertEquals("Enumerated Option in Category", rootOptions[4].getName());
- assertEquals(IOption.ENUMERATED, rootOptions[4].getValueType());
- String selEnum = rootOptions[4].getSelectedEnum();
- assertEquals(enumVal, selEnum);
- String[] enums = rootOptions[4].getApplicableValues();
- assertEquals(2, enums.length);
- assertEquals("Default Enum", enums[0]);
- assertEquals("Another Enum", enums[1]);
- assertEquals("-e1", rootOptions[4].getEnumCommand(enums[0]));
- assertEquals("-e2", rootOptions[4].getEnumCommand(enums[1]));
- assertEquals("-e2", rootOptions[4].getEnumCommand(selEnum));
- // Final option is a boolean in Category
- assertEquals("Boolean Option in Category", rootOptions[5].getName());
- assertEquals(IOption.BOOLEAN, rootOptions[5].getValueType());
- assertEquals(false, rootOptions[5].getBooleanValue());
- assertEquals("-nob", rootOptions[5].getCommandFalse());
- }
-
- /*
- * Do a full sanity check on the root project type.
- */
- private void checkRootProjectType(IProjectType type) throws BuildException {
- // Project stuff
- String expectedCleanCmd = "del /myworld";
- String expectedParserId = "org.eclipse.cdt.core.PE";
- String[] expectedOSList = {"win32"};
- String[] expectedArchList = {"all"};
- assertTrue(type.isTestProjectType());
- IConfiguration[] configs = type.getConfigurations();
- if (configs[0].getArtifactName().equals("ManagedBuildTest")) {
- assertEquals(configs[0].getArtifactExtension(), newExt);
- } else {
- assertEquals(configs[0].getArtifactExtension(), rootExt);
- }
- assertEquals(expectedCleanCmd, configs[0].getCleanCommand());
- assertEquals("make", configs[0].getBuildCommand());
- IToolChain toolChain = configs[0].getToolChain();
- ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals(expectedParserId, targetPlatform.getBinaryParserId());
- assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
- assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
- // This configuration defines no errors parsers.
- assertNull(configs[0].getErrorParserIds());
- assertTrue(Arrays.equals(configs[0].getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs()));
-
- // Tools
- ITool[] tools = toolChain.getTools();
- // Root Tool
- ITool rootTool = tools[0];
- assertEquals("Root Tool", rootTool.getName());
- // 6 Options are defined in the root tool
- IOption[] options = rootTool.getOptions();
- assertEquals(6, options.length);
- // First option is a 3-element list with 1 built-in
- assertEquals("List Option in Top", options[0].getName());
- assertEquals(IOption.STRING_LIST, options[0].getValueType());
- String[] valueList = options[0].getStringListValue();
- assertEquals(2, valueList.length);
- assertEquals("a", valueList[0]);
- assertEquals("b", valueList[1]);
- String[] builtInList = options[0].getBuiltIns();
- assertEquals(1, builtInList.length);
- assertEquals("c", builtInList[0]);
- assertEquals(options[0].getCommand(), "-L");
- // Next option is a boolean in top
- assertEquals("Boolean Option in Top", options[1].getName());
- assertEquals(IOption.BOOLEAN, options[1].getValueType());
- assertEquals(false, options[1].getBooleanValue());
- assertEquals("-b", options[1].getCommand());
- // Next option is a string category
- assertEquals("String Option in Category", options[2].getName());
- assertEquals(IOption.STRING, options[2].getValueType());
- assertEquals("x", options[2].getStringValue());
- // Next option is another string category
- assertEquals("Another String Option in Category", options[3].getName());
- assertEquals(IOption.STRING, options[3].getValueType());
- assertEquals("", options[3].getStringValue());
- assertEquals("-str", options[3].getCommand());
- // Next option is an enumerated
- assertEquals("Enumerated Option in Category", options[4].getName());
- assertEquals(IOption.ENUMERATED, options[4].getValueType());
- // Post-2.0 enums store the ID, not the string value
- assertEquals("default.enum.option", options[4].getSelectedEnum());
- assertEquals("-e1", options[4].getEnumCommand("default.enum.option"));
- // Need this methof to populate the UI selection widget
- valueList = options[4].getApplicableValues();
- assertEquals(2, valueList.length);
- assertEquals("Default Enum", valueList[0]);
- assertEquals("Another Enum", valueList[1]);
- // Test compatability with 1.2 scheme of getting the command from the name
- assertEquals("-e1", options[4].getEnumCommand(valueList[0]));
- assertEquals("-e2", options[4].getEnumCommand(valueList[1]));
- // Final option is another boolean
- assertEquals("Boolean Option in Category", options[5].getName());
- assertEquals(IOption.BOOLEAN, options[5].getValueType());
- assertEquals(false, options[5].getBooleanValue());
- assertEquals("", options[5].getCommand());
- assertEquals("-nob", options[5].getCommandFalse());
-
- // Option Categories
- IOptionCategory topCategory = rootTool.getTopOptionCategory();
- assertEquals("Root Tool", topCategory.getName());
- Object[][] catoptions = topCategory.getOptions(configs[0]);
- int i;
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(2, i);
- assertEquals("List Option in Top", ((IOption)catoptions[0][1]).getName());
- assertEquals("Boolean Option in Top", ((IOption)catoptions[1][1]).getName());
- IOptionCategory[] categories = topCategory.getChildCategories();
- assertEquals(1, categories.length);
- assertEquals("Category", categories[0].getName());
- catoptions = categories[0].getOptions(configs[0]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(4, i);
- assertEquals("String Option in Category", ((IOption)catoptions[0][1]).getName());
- assertEquals("Another String Option in Category", ((IOption)catoptions[1][1]).getName());
- assertEquals("Enumerated Option in Category", ((IOption)catoptions[2][1]).getName());
- assertEquals("Boolean Option in Category", ((IOption)catoptions[3][1]).getName());
-
- // There should be 3 defined configs
- configs = type.getConfigurations();
- assertEquals(3, configs.length);
-
- // Root Config
- IConfiguration rootConfig = configs[0];
- assertEquals("Root Config", rootConfig.getName());
-
- // Tool elements
- tools = rootConfig.getTools();
- assertEquals(1, tools.length);
- assertEquals("Root Tool", tools[0].getName());
- assertEquals("-r", tools[0].getOutputFlag());
- assertTrue(tools[0].buildsFileType("foo"));
- assertTrue(tools[0].buildsFileType("bar"));
- assertTrue(tools[0].producesFileType("toor"));
- assertEquals("doIt", tools[0].getToolCommand());
- assertEquals("", tools[0].getOutputPrefix());
- // The root tool defines one valid header file extension
- assertTrue(rootTool.isHeaderFile("baz"));
- assertTrue(tools[0].isHeaderFile("baz"));
- assertEquals(ITool.FILTER_C, rootTool.getNatureFilter());
-
- // Partially Overriden Configuration
- assertEquals("Root Override Config", configs[1].getName());
- tools = configs[1].getTools();
- assertEquals(1, tools.length);
- assertEquals("Root Tool", tools[0].getName());
- topCategory = tools[0].getTopOptionCategory();
- catoptions = topCategory.getOptions(configs[1]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(2, i);
- assertEquals("List Option in Top", ((IOption)catoptions[0][1]).getName());
- valueList = ((IOption)catoptions[0][1]).getStringListValue();
- assertEquals("a", valueList[0]);
- assertEquals("b", valueList[1]);
- assertEquals("Boolean Option in Top", ((IOption)catoptions[1][1]).getName());
- assertEquals(true, ((IOption)catoptions[1][1]).getBooleanValue());
- assertEquals("-b", ((IOption)catoptions[1][1]).getCommand());
- categories = topCategory.getChildCategories();
- catoptions = categories[0].getOptions(configs[1]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(4, i);
- assertEquals("String Option in Category", ((IOption)catoptions[0][1]).getName());
- assertEquals("y", ((IOption)catoptions[0][1]).getStringValue());
- assertEquals("Another String Option in Category", ((IOption)catoptions[1][1]).getName());
- assertEquals("", ((IOption)catoptions[1][1]).getStringValue());
- assertEquals("Enumerated Option in Category", ((IOption)catoptions[2][1]).getName());
- valueList = ((IOption)catoptions[2][1]).getApplicableValues();
- assertEquals(2, valueList.length);
- assertEquals("Default Enum", valueList[0]);
- assertEquals("Another Enum", valueList[1]);
- assertEquals("-e1", ((IOption)catoptions[2][1]).getEnumCommand(valueList[0]));
- assertEquals("-e2", ((IOption)catoptions[2][1]).getEnumCommand(valueList[1]));
- assertEquals(1, tools.length);
- assertEquals("Boolean Option in Category", ((IOption)catoptions[3][1]).getName());
- assertEquals(false, ((IOption)catoptions[3][1]).getBooleanValue());
- assertEquals("", ((IOption)catoptions[3][1]).getCommand());
- assertEquals("-nob", ((IOption)catoptions[3][1]).getCommandFalse());
- assertEquals(1, tools.length);
- ITool tool = tools[0];
- assertNotNull(tool);
- assertEquals("Root Tool", tool.getName());
- assertEquals("-r", tool.getOutputFlag());
- assertTrue(tool.buildsFileType("foo"));
- assertTrue(tool.buildsFileType("bar"));
- assertTrue(tool.producesFileType("toor"));
- assertTrue(tool.isHeaderFile("baz"));
- assertEquals("doIt", tool.getToolCommand());
- assertEquals("-La -Lb -b y -e1 -nob", tool.getToolFlags());
-
- // Completely Overridden configuration
- assertEquals("Complete Override Config", configs[2].getName());
- tools = configs[2].getTools();
- assertEquals(1, tools.length);
- assertEquals("Root Tool", tools[0].getName());
- topCategory = tools[0].getTopOptionCategory();
- catoptions = topCategory.getOptions(configs[2]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(2, i);
- // Check that there's an string list with totally new values
- assertEquals("List Option in Top", ((IOption)catoptions[0][1]).getName());
- assertEquals(IOption.STRING_LIST, ((IOption)catoptions[0][1]).getValueType());
- valueList = ((IOption)catoptions[0][1]).getStringListValue();
- assertTrue(valueList.length == 3);
- assertEquals("d", valueList[0]);
- assertEquals("e", valueList[1]);
- assertEquals("f", valueList[2]);
- assertEquals("-L", ((IOption)catoptions[0][1]).getCommand());
- // and a true boolean (commands should not have changed)
- assertEquals("Boolean Option in Top", ((IOption)catoptions[1][1]).getName());
- assertEquals(IOption.BOOLEAN, ((IOption)catoptions[1][1]).getValueType());
- assertEquals(true, ((IOption)catoptions[1][1]).getBooleanValue());
- assertEquals("-b", ((IOption)catoptions[1][1]).getCommand());
- // Check that there's an overridden enumeration and string
- categories = topCategory.getChildCategories();
- catoptions = categories[0].getOptions(configs[2]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(4, i);
- assertEquals("String Option in Category", ((IOption)catoptions[0][1]).getName());
- assertEquals(IOption.STRING, ((IOption)catoptions[0][1]).getValueType());
- assertEquals("overridden", ((IOption)catoptions[0][1]).getStringValue());
- assertEquals("Another String Option in Category", ((IOption)catoptions[1][1]).getName());
- assertEquals(IOption.STRING, ((IOption)catoptions[1][1]).getValueType());
- assertEquals("alsooverridden", ((IOption)catoptions[1][1]).getStringValue());
- assertEquals("Enumerated Option in Category", ((IOption)catoptions[2][1]).getName());
- assertEquals(IOption.ENUMERATED, ((IOption)catoptions[2][1]).getValueType());
- assertEquals("another.enum.option", ((IOption)catoptions[2][1]).getSelectedEnum());
- assertEquals("Boolean Option in Category", ((IOption)catoptions[3][1]).getName());
- assertEquals(IOption.BOOLEAN, ((IOption)catoptions[3][1]).getValueType());
- assertEquals(true, ((IOption)catoptions[3][1]).getBooleanValue());
- tool = tools[0];
- assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags());
-
- // Make sure that the build manager returns the default makefile generator (not null)
- assertNotNull(ManagedBuildManager.getBuildfileGenerator(configs[0]));
- }
-
- /*
- * Do a full sanity check on the root managed project.
- */
- private void checkRootManagedProject(IManagedProject managedProj, String testValue) throws BuildException {
- String expectedCleanCmd = "del /myworld";
- String expectedParserId = "org.eclipse.cdt.core.PE";
- String[] expectedOSList = {"win32"};
- String[] expectedArchList = {"all"};
- assertTrue(managedProj.getProjectType().isTestProjectType());
- IConfiguration[] configs = managedProj.getConfigurations();
- if (configs[0].getArtifactName().equals("ManagedBuildTest")) {
- assertEquals(configs[0].getArtifactExtension(), newExt);
- } else {
- assertEquals(configs[0].getArtifactExtension(), rootExt);
- }
- assertEquals(expectedCleanCmd, configs[0].getCleanCommand());
- assertEquals("make", configs[0].getBuildCommand());
- IToolChain toolChain = configs[0].getToolChain();
- ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals(expectedParserId, targetPlatform.getBinaryParserId());
- assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
- assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
- // This configuration defines no errors parsers.
- assertNull(configs[0].getErrorParserIds());
- assertTrue(Arrays.equals(configs[0].getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs()));
-
- // Tools
- ITool[] tools = configs[0].getTools();
- // Root Tool
- ITool rootTool = tools[0];
- assertEquals("Root Tool", rootTool.getName());
- // 6 Options are defined in the root tool
- IOption[] options = rootTool.getOptions();
- assertEquals(6, options.length);
- // First option is a 3-element list with 1 built-in
- assertEquals("List Option in Top", options[0].getName());
- assertEquals(IOption.STRING_LIST, options[0].getValueType());
- String[] valueList = options[0].getStringListValue();
- assertEquals(2, valueList.length);
- assertEquals("a", valueList[0]);
- assertEquals("b", valueList[1]);
- String[] builtInList = options[0].getBuiltIns();
- assertEquals(1, builtInList.length);
- assertEquals("c", builtInList[0]);
- assertEquals(options[0].getCommand(), "-L");
- // Next option is a boolean in top
- assertEquals("Boolean Option in Top", options[1].getName());
- assertEquals(IOption.BOOLEAN, options[1].getValueType());
- assertEquals(false, options[1].getBooleanValue());
- assertEquals("-b", options[1].getCommand());
- // Next option is a string category
- assertEquals("String Option in Category", options[2].getName());
- assertEquals(IOption.STRING, options[2].getValueType());
- assertEquals(testValue, options[2].getStringValue());
- // Next option is another string category
- assertEquals("Another String Option in Category", options[3].getName());
- assertEquals(IOption.STRING, options[3].getValueType());
- assertEquals("", options[3].getStringValue());
- assertEquals("-str", options[3].getCommand());
- // Next option is an enumerated
- assertEquals("Enumerated Option in Category", options[4].getName());
- assertEquals(IOption.ENUMERATED, options[4].getValueType());
- // Post-2.0 enums store the ID, not the string value
- assertEquals("default.enum.option", options[4].getSelectedEnum());
- assertEquals("-e1", options[4].getEnumCommand("default.enum.option"));
- // Need this methof to populate the UI selection widget
- valueList = options[4].getApplicableValues();
- assertEquals(2, valueList.length);
- assertEquals("Default Enum", valueList[0]);
- assertEquals("Another Enum", valueList[1]);
- // Test compatability with 1.2 scheme of getting the command from the name
- assertEquals("-e1", options[4].getEnumCommand(valueList[0]));
- assertEquals("-e2", options[4].getEnumCommand(valueList[1]));
- // Final option is another boolean
- assertEquals("Boolean Option in Category", options[5].getName());
- assertEquals(IOption.BOOLEAN, options[5].getValueType());
- assertEquals(false, options[5].getBooleanValue());
- assertEquals("", options[5].getCommand());
- assertEquals("-nob", options[5].getCommandFalse());
-
- // Option Categories
- IOptionCategory topCategory = rootTool.getTopOptionCategory();
- assertEquals("Root Tool", topCategory.getName());
- Object[][] catoptions = topCategory.getOptions(configs[0]);
- int i;
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(2, i);
- IOption catOption = (IOption)catoptions[0][1];
- assertEquals("List Option in Top", catOption.getName());
- catOption = (IOption)catoptions[1][1];
- assertEquals("Boolean Option in Top", catOption.getName());
- IOptionCategory[] categories = topCategory.getChildCategories();
- assertEquals(1, categories.length);
- assertEquals("Category", categories[0].getName());
- catoptions = categories[0].getOptions(configs[0]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(4, i);
- catOption = (IOption)catoptions[0][1];
- assertEquals("String Option in Category", catOption.getName());
- catOption = (IOption)catoptions[1][1];
- assertEquals("Another String Option in Category", catOption.getName());
- catOption = (IOption)catoptions[2][1];
- assertEquals("Enumerated Option in Category", catOption.getName());
- catOption = (IOption)catoptions[3][1];
- assertEquals("Boolean Option in Category", catOption.getName());
-
- // There should be 3 defined configs
- assertEquals(3, configs.length);
-
- // Root Config
- IConfiguration rootConfig = configs[0];
- assertEquals("Root Config", rootConfig.getName());
-
- // Tool elements
- tools = rootConfig.getTools();
- assertEquals(1, tools.length);
- assertEquals("Root Tool", tools[0].getName());
- assertEquals("-r", tools[0].getOutputFlag());
- assertTrue(tools[0].buildsFileType("foo"));
- assertTrue(tools[0].buildsFileType("bar"));
- assertTrue(tools[0].producesFileType("toor"));
- assertEquals("doIt", tools[0].getToolCommand());
- assertEquals("", tools[0].getOutputPrefix());
- // The root tool defines one valid header file extension
- assertTrue(rootTool.isHeaderFile("baz"));
- assertTrue(tools[0].isHeaderFile("baz"));
- assertEquals(ITool.FILTER_C, rootTool.getNatureFilter());
-
- // Partially Overriden Configuration
- assertEquals("Root Override Config", configs[1].getName());
- tools = configs[1].getTools();
- assertEquals(1, tools.length);
- assertEquals("Root Tool", tools[0].getName());
- topCategory = tools[0].getTopOptionCategory();
- catoptions = topCategory.getOptions(configs[1]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(2, i);
- catOption = (IOption)catoptions[0][1];
- assertEquals("List Option in Top", catOption.getName());
- valueList = catOption.getStringListValue();
- assertEquals("a", valueList[0]);
- assertEquals("b", valueList[1]);
- catOption = (IOption)catoptions[1][1];
- assertEquals("Boolean Option in Top", catOption.getName());
- assertEquals(true, catOption.getBooleanValue());
- assertEquals("-b", catOption.getCommand());
- categories = topCategory.getChildCategories();
- catoptions = categories[0].getOptions(configs[1]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(4, i);
- catOption = (IOption)catoptions[0][1];
- assertEquals("String Option in Category", catOption.getName());
- assertEquals("y", catOption.getStringValue());
- catOption = (IOption)catoptions[1][1];
- assertEquals("Another String Option in Category", catOption.getName());
- assertEquals("", catOption.getStringValue());
- catOption = (IOption)catoptions[2][1];
- assertEquals("Enumerated Option in Category", catOption.getName());
- valueList = catOption.getApplicableValues();
- assertEquals(2, valueList.length);
- assertEquals("Default Enum", valueList[0]);
- assertEquals("Another Enum", valueList[1]);
- catOption = (IOption)catoptions[2][1];
- assertEquals("-e1", catOption.getEnumCommand(valueList[0]));
- assertEquals("-e2", catOption.getEnumCommand(valueList[1]));
- assertEquals(1, tools.length);
- catOption = (IOption)catoptions[3][1];
- assertEquals("Boolean Option in Category", catOption.getName());
- assertEquals(false, catOption.getBooleanValue());
- assertEquals("", catOption.getCommand());
- assertEquals("-nob", catOption.getCommandFalse());
- assertEquals(1, tools.length);
- ITool tool = tools[0];
- assertNotNull(tool);
- assertEquals("Root Tool", tool.getName());
- assertEquals("-r", tool.getOutputFlag());
- assertTrue(tool.buildsFileType("foo"));
- assertTrue(tool.buildsFileType("bar"));
- assertTrue(tool.producesFileType("toor"));
- assertTrue(tool.isHeaderFile("baz"));
- assertEquals("doIt", tool.getToolCommand());
- assertEquals("-La -Lb -b y -e1 -nob", tool.getToolFlags());
-
- // Completely Overridden configuration
- assertEquals("Complete Override Config", configs[2].getName());
- tools = configs[2].getTools();
- assertEquals(1, tools.length);
- assertEquals("Root Tool", tools[0].getName());
- topCategory = tools[0].getTopOptionCategory();
- catoptions = topCategory.getOptions(configs[2]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(2, i);
- // Check that there's an string list with totally new values
- catOption = (IOption)catoptions[0][1];
- assertEquals("List Option in Top", catOption.getName());
- assertEquals(IOption.STRING_LIST, catOption.getValueType());
- valueList = catOption.getStringListValue();
- assertTrue(valueList.length == 3);
- assertEquals("d", valueList[0]);
- assertEquals("e", valueList[1]);
- assertEquals("f", valueList[2]);
- assertEquals("-L", catOption.getCommand());
- // and a true boolean (commands should not have changed)
- catOption = (IOption)catoptions[1][1];
- assertEquals("Boolean Option in Top", catOption.getName());
- assertEquals(IOption.BOOLEAN, catOption.getValueType());
- assertEquals(true, catOption.getBooleanValue());
- assertEquals("-b", catOption.getCommand());
- // Check that there's an overridden enumeration and string
- categories = topCategory.getChildCategories();
- catoptions = categories[0].getOptions(configs[2]);
- for (i=0; i<catoptions.length; i++)
- if (catoptions[i][0] == null) break;
- assertEquals(4, i);
- catOption = (IOption)catoptions[0][1];
- assertEquals("String Option in Category", catOption.getName());
- assertEquals(IOption.STRING, catOption.getValueType());
- assertEquals("overridden", catOption.getStringValue());
- catOption = (IOption)catoptions[1][1];
- assertEquals("Another String Option in Category", catOption.getName());
- assertEquals(IOption.STRING, catOption.getValueType());
- assertEquals("alsooverridden", catOption.getStringValue());
- catOption = (IOption)catoptions[2][1];
- assertEquals("Enumerated Option in Category", catOption.getName());
- assertEquals(IOption.ENUMERATED, catOption.getValueType());
- assertEquals("another.enum.option", catOption.getSelectedEnum());
- catOption = (IOption)catoptions[3][1];
- assertEquals("Boolean Option in Category", catOption.getName());
- assertEquals(IOption.BOOLEAN, catOption.getValueType());
- assertEquals(true, catOption.getBooleanValue());
- tool = tools[0];
- assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags());
-
- // Make sure that the build manager returns the default makefile generator (not null)
- assertNotNull(ManagedBuildManager.getBuildfileGenerator(configs[0]));
- }
-
- /*
- * The Sub Sub project type has a reference to a tool that is defined
- * independently from the project type itself. This is a common pattern
- * for tools that are shared between many project types.
- *
- * The tool itself is defined as having two option categories, with
- * one option in each category. To test that the reference is properly
- * inheritted, the project type overrides the default value of the boolean
- * option.
- *
- * The test confirms that the basic settings are inheritted through the
- * reference, and that the overridden value is used instead of the
- * default. It also tests that the command can be overidden through a
- * tool reference.
- *
- * Finally, the string option in the configuration is overridden and the
- * test confirms that it contains both the overridden boolean that the
- * project type provides, and the overridden string that it provides.
- *
- * @param testSubSub
- */
- private void checkSubSubProjectType(IProjectType projType) {
- final String indyToolName = "Target Independent Tool";
- final String indyToolCommand = "RC.EXE";
- final String indyToolInputExt = "rc";
- final String indyToolOutputExt = "free";
- final String indyToolOutFlag = "/fo";
- final String indyToolHeader = "h";
- final String indyToolHeaderNot = "j";
- final String indyCatOne = "Free";
- final String indyCatTwo = "Chained";
- final String freeOptName = "String in Free";
- final String chainedOptName = "Boolean in Chained";
- final String freeOptValue = "Live free or die";
- final String newCmd = "Let the Wookie win";
- final String stringOverride = "The future language of slaves";
-
- IConfiguration[] configs = projType.getConfigurations();
- // Check the inherited clean command
- assertEquals("rm -yourworld", configs[0].getCleanCommand());
- // Check that the make command is overridden from parent
- assertEquals("nmake", configs[0].getBuildCommand());
- // Make sure we get the proper binary parser
- IToolChain toolChain = configs[0].getToolChain();
- ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals("org.eclipse.cdt.core.ELF", targetPlatform.getBinaryParserId());
- // Make sure the os list is inherited
- String[] expectedOSList = {"win32","linux","solaris"};
- assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
- // Make sure the arch list is inherited
- String[] expectedArchList = {"x86", "ppc"};
- assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
-
- // Get the 5 configurations (3 from test, 1 from test sub and 1 from this)
- assertEquals(5, configs.length);
-
- // Check the tools. We should have 3 (1 from each parent and the one referenced).
- ITool[] tools = configs[0].getTools();
- assertEquals(3, tools.length);
- ITool toolRef = tools[0];
-
- // Make sure we get all the tool settings
- assertEquals(toolRef.getName(), indyToolName);
- assertEquals(toolRef.getToolCommand(), indyToolCommand);
- assertTrue(toolRef.buildsFileType(indyToolInputExt));
- assertEquals(toolRef.getOutputExtension(indyToolInputExt), indyToolOutputExt);
- assertEquals(toolRef.getOutputFlag(), indyToolOutFlag);
- assertTrue(toolRef.isHeaderFile(indyToolHeader));
- assertFalse(toolRef.isHeaderFile(indyToolHeaderNot));
- assertEquals(toolRef.getNatureFilter(), ITool.FILTER_BOTH);
- // Check out the referenced tool and make sure we get all option categories
- IOptionCategory topCategory = toolRef.getTopOptionCategory();
- IOptionCategory[] categories = topCategory.getChildCategories();
- assertEquals(1, categories.length);
- assertEquals(categories[0].getName(), indyCatOne);
- IOptionCategory[] subCategories = categories[0].getChildCategories();
- // Is the chained category a subcategory
- assertEquals(1, subCategories.length);
- assertEquals(subCategories[0].getName(), indyCatTwo);
- // Make sure the option in the top category is correct
- Object[][] optsInCat = categories[0].getOptions(configs[0]);
- int i;
- for (i=0; i<optsInCat.length; i++)
- if (optsInCat[i][0] == null) break;
- assertEquals(1, i);
- IOption optCat = (IOption)optsInCat[0][1];
- assertEquals(freeOptName, optCat.getName());
- try {
- // We get the option categories and options from the tool itself, but the
- // tool reference will have a set of 0 to n option references that contain
- // overridden settings. In this case, the string is inheritted and should
- // not be reference
- assertEquals(IOption.STRING, optCat.getValueType());
- IOption stringOpt = toolRef.getOptionById(optCat.getId());
- assertTrue(stringOpt instanceof Option);
- assertEquals(freeOptValue, stringOpt.getStringValue());
- } catch (BuildException e1) {
- fail("Failed getting string value in subsub :" + e1.getLocalizedMessage());
- }
-
- // Do the same for the options in the child cat
- Object[][] optsInSubCat = subCategories[0].getOptions(configs[0]);
- for (i=0; i<optsInSubCat.length; i++)
- if (optsInSubCat[i][0] == null) break;
- assertEquals(1, i);
- IOption booleanRef = toolRef.getOptionById(((IOption)optsInSubCat[0][1]).getId());
- assertEquals(chainedOptName, booleanRef.getName());
- try {
- assertEquals(IOption.BOOLEAN, booleanRef.getValueType());
- assertTrue(booleanRef.getBooleanValue());
- } catch (BuildException e) {
- fail("Failure getting boolean value in subsub: " + e.getLocalizedMessage());
- }
-
- // Test that the tool command can be changed through the reference
- toolRef.setToolCommand(newCmd);
- assertEquals(toolRef.getToolCommand(), newCmd);
-
- // Muck about with the options in the local config
- IConfiguration subSubConfig = projType.getConfiguration("sub.sub.config");
- assertNotNull(subSubConfig);
- ITool[] configTools = subSubConfig.getTools();
- // This tool ref is inherited from parent, so it does not belong to the config
- ITool configToolRef = configTools[0];
- assertNotNull(configToolRef);
- optCat = (IOption)optsInCat[0][1];
- IOption configStringOpt = configToolRef.getOptionById(optCat.getId());
- assertNotNull(configStringOpt);
- // Override the string option
- try {
- subSubConfig.setOption(configToolRef, configStringOpt, stringOverride);
- } catch (BuildException e) {
- fail("Failure setting string value in subsubconfiguration: " + e.getLocalizedMessage());
- }
- // Now the config should have a tool ref to the independent tool
- configTools = subSubConfig.getTools();
- configToolRef = configTools[0];
- assertNotNull(configToolRef);
-
- // Test that the string option is overridden in the configuration
- optsInCat = categories[0].getOptions(configs[0]);
- for (i=0; i<optsInCat.length; i++)
- if (optsInCat[i][0] == null) break;
- assertEquals(1, i);
- optCat = (IOption)optsInCat[0][1];
- assertEquals(freeOptName, optCat.getName());
- configStringOpt = configToolRef.getOptionById(optCat.getId());
- try {
- assertEquals(stringOverride, configStringOpt.getStringValue());
- } catch (BuildException e) {
- fail("Failure getting string value in subsubconfiguration: " + e.getLocalizedMessage());
- }
- // The tool should also contain the boolean option set to true
- IOption optSubCat = (IOption)optsInSubCat[0][1];
- IOption configBoolOpt = configToolRef.getOptionById(optSubCat.getId());
- assertNotNull(configBoolOpt);
- try {
- assertTrue(configBoolOpt.getBooleanValue());
- } catch (BuildException e) {
- fail("Failure getting boolean value in subsubconfiguration: " + e.getLocalizedMessage());
- }
-
- // Override it in config and retest
- try {
- subSubConfig.setOption(configToolRef, configBoolOpt, false);
- } catch (BuildException e) {
- fail("Failure setting boolean value in subsubconfiguration: " + e.getLocalizedMessage());
- }
- optsInSubCat = subCategories[0].getOptions(configs[0]);
- for (i=0; i<optsInSubCat.length; i++)
- if (optsInSubCat[i][0] == null) break;
- assertEquals(1, i);
- configBoolOpt = configToolRef.getOptionById(((IOption)optsInSubCat[0][1]).getId());
- assertEquals(chainedOptName, booleanRef.getName());
- try {
- assertFalse(configBoolOpt.getBooleanValue());
- } catch (BuildException e) {
- fail("Failure getting boolean value in subsubconfiguration: " + e.getLocalizedMessage());
- }
- }
-
- /*
- * Do a sanity check on the values in the sub-project type. Most of the
- * sanity on the how build model entries are read is performed in
- * the root project type check, so these tests just verify that the the sub
- * project type properly inherits from its parent. For the new options
- * in the sub project type, the test does a sanity check just to be complete.
- */
- private void checkSubProjectType(IProjectType projType) throws BuildException {
- final String expectedFlags = "-I/usr/include -I/opt/gnome/include -IC:\\home\\tester/include -I\"../includes\" x y z";
-
- IConfiguration[] configs = projType.getConfigurations();
- // Check the overridden clean command
- assertEquals("rm -yourworld", configs[0].getCleanCommand());
- // Make sure the projType inherits the make command
- assertEquals("make", configs[0].getBuildCommand());
- // Make sure the binary parser is hard-coded and available
- IToolChain toolChain = configs[0].getToolChain();
- ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals("org.eclipse.cdt.core.PE", targetPlatform.getBinaryParserId());
- String[] expectedOSList = {"win32","linux","solaris"};
- assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
- // Make sure the list is overridden
- String[] expectedArchList = {"x86", "ppc"};
- assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
-
- // Make sure this is a test projType
- assertTrue(projType.isTestProjectType());
- // Make sure the build artifact extension is there
- assertEquals(configs[0].getArtifactExtension(), subExt);
-
- // Get the tools for this projType
- ITool[] tools = configs[0].getTools();
- // Do we inherit properly from parent
- ITool rootTool = tools[0];
- assertEquals("Root Tool", rootTool.getName());
- // Now get the tool defined for this projType
- ITool subTool = tools[1];
- assertEquals("Sub Tool", subTool.getName());
- // Confirm that it has four options
- IOption[] subOpts = subTool.getOptions();
- assertEquals(5, subOpts.length);
- assertEquals("", subTool.getOutputFlag());
- assertTrue(subTool.buildsFileType("yarf"));
- assertTrue(subTool.producesFileType("bus"));
- assertEquals("", subTool.getToolCommand());
- assertEquals("lib", subTool.getOutputPrefix());
- assertTrue(subTool.isHeaderFile("arf"));
- assertTrue(subTool.isHeaderFile("barf"));
- assertEquals(ITool.FILTER_BOTH, subTool.getNatureFilter());
-
- // Do a sanity check on the options
- assertEquals("Include Paths", subOpts[0].getName());
- assertEquals(IOption.INCLUDE_PATH, subOpts[0].getValueType());
- String[] incPath = subOpts[0].getIncludePaths();
- assertEquals(2, incPath.length);
- assertEquals("/usr/include", incPath[0]);
- assertEquals("/opt/gnome/include", incPath[1]);
- String[] builtInPaths = subOpts[0].getBuiltIns();
- assertEquals(1, builtInPaths.length);
- assertEquals("/usr/gnu/include", builtInPaths[0]);
- assertEquals("-I", subOpts[0].getCommand());
- assertEquals(IOption.BROWSE_DIR, subOpts[0].getBrowseType());
-
- // There are no user-defined preprocessor symbols
- assertEquals("Defined Symbols", subOpts[1].getName());
- assertEquals(IOption.PREPROCESSOR_SYMBOLS, subOpts[1].getValueType());
- String[] defdSymbols = subOpts[1].getDefinedSymbols();
- assertEquals(0, defdSymbols.length);
- assertEquals("-D", subOpts[1].getCommand());
- // But there is a builtin
- String[] builtInSymbols = subOpts[1].getBuiltIns();
- assertEquals(1, builtInSymbols.length);
- assertEquals("BUILTIN", builtInSymbols[0]);
- // Broswe type should be none
- assertEquals(IOption.BROWSE_NONE, subOpts[1].getBrowseType());
-
- assertEquals("More Includes", subOpts[2].getName());
- assertEquals(IOption.INCLUDE_PATH, subOpts[2].getValueType());
- String[] moreIncPath = subOpts[2].getIncludePaths();
- assertEquals(2, moreIncPath.length);
- assertEquals("C:\\home\\tester/include", moreIncPath[0]);
- assertEquals("-I", subOpts[2].getCommand());
- assertEquals(IOption.BROWSE_DIR, subOpts[2].getBrowseType());
-
- // Check the user object option
- assertEquals("User Objects", subOpts[3].getName());
- assertEquals(IOption.OBJECTS, subOpts[3].getValueType());
- String[] objs = subOpts[3].getUserObjects();
- assertEquals(2, objs.length);
- assertEquals("obj1.o", objs[0]);
- assertEquals("obj2.o", objs[1]);
- assertEquals(IOption.BROWSE_FILE, subOpts[3].getBrowseType());
- assertEquals("", subOpts[3].getCommand());
-
- // There should be a string list with no command
- assertEquals("No Command StringList", subOpts[4].getName());
- assertEquals(IOption.STRING_LIST, subOpts[4].getValueType());
-
- // Make sure the tool flags look right
- assertEquals(subTool.getToolFlags(), expectedFlags);
-
- // Get the configs for this projType; it should inherit all the configs defined for the parent
- assertEquals(4, configs.length);
- assertEquals("Sub Config", configs[0].getName());
- assertEquals("Root Config", configs[1].getName());
- assertEquals("Root Override Config", configs[2].getName());
- assertEquals("Complete Override Config", configs[3].getName());
- }
-
- private void checkForwardProjectTypes(IProjectType parent, IProjectType child, IProjectType grandchild) {
- // check that the projType parent reference has been resolved.
- assertEquals(parent, child.getSuperClass());
- assertEquals(child, grandchild.getSuperClass());
-
- // get the parent tool
- IConfiguration[] parentConfigs = parent.getConfigurations();
- ITool[] parentTools = parentConfigs[0].getTools();
- assertEquals(1, parentTools.length);
- ITool parentTool = parentTools[0];
- assertNotNull(parentTool);
-
- // check option categories
- IOption option = parentTool.getOptionById("test.forward.option");
- assertNotNull(option);
- IOptionCategory[] firstLevel = parentTool.getTopOptionCategory()
- .getChildCategories();
- assertEquals(1, firstLevel.length);
- IOptionCategory[] secondLevel = firstLevel[0].getChildCategories();
- assertEquals(1, secondLevel.length);
- assertEquals(0, secondLevel[0].getChildCategories().length);
- Object[][] optList = secondLevel[0].getOptions(parentConfigs[0]);
- int i;
- for (i=0; i<optList.length; i++)
- if (optList[i][0] == null) break;
- assertEquals(1, i);
- assertEquals(option, optList[0][1]);
-
- // get the tool reference from the child
- IConfiguration[] childConfigs = child.getConfigurations();
- ITool[] childTools = childConfigs[0].getTools();
- assertEquals(1, childTools.length);
- ITool childToolRef = childTools[0];
- assertEquals(parentTool.getSuperClass(), childToolRef.getSuperClass());
-
- // get and check the option reference
- IOption optRef = childToolRef.getOptionById("test.forward.option");
- assertEquals(option, optRef);
-
- // get the tool reference from the grandchild
- IConfiguration[] grandConfigs = grandchild.getConfigurations();
- ITool[] grandTools = grandConfigs[0].getTools();
- assertEquals(1, grandTools.length);
- ITool grandToolRef = grandTools[0];
- assertEquals(parentTool.getSuperClass(), grandToolRef.getSuperClass());
-
- }
-
- public void checkProviderProjectType(IProjectType projType) throws Exception {
- Properties props = new Properties();
- props.load(getClass().getResourceAsStream("test_commands"));
-
- // check that this projType is in the file
- String command = props.getProperty(projType.getId());
- assertNotNull(command);
-
- IProjectType parent = projType.getSuperClass();
- assertNotNull(parent);
- assertEquals("test.forward.parent.target", parent.getId());
-
- IConfiguration[] configs = projType.getConfigurations();
- ITool toolRef = configs[0].getFilteredTools()[0];
- assertEquals(command, toolRef.getToolCommand());
- }
-
- /**
- * Remove all the project information associated with the project used during test.
- */
- public void cleanup() {
- removeProject(projectName);
- removeProject(projectName2);
- }
-
- /* (non-Javadoc)
- * Create a new project named <code>name</code> 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
- */
- private 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 <code>IProject</code> with the name specified in the argument from the
- * receiver's workspace.
- *
- * @param name
- */
- private 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) {
- assertTrue(false);
- }
- }
- }
- }
- /**
- * @throws CoreException
- * @throws BuildException
- */
- public void testErrorParsers() throws BuildException {
- // Create new project
- IProject project = null;
- try {
- project = createProject(projectName2);
- // Now associate the builder with the project
- addManagedBuildNature(project);
- IProjectDescription description = project.getDescription();
- // Make sure it has a managed nature
- if (description != null) {
- assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
- }
- } catch (CoreException e) {
- fail("Test failed on error parser project creation: " + e.getLocalizedMessage());
- }
-
- // Find the base project Type definition
- IProjectType projType = ManagedBuildManager.getProjectType("test.error.parsers");
- assertNotNull(projType);
-
- // Create the target for our project that builds a dummy executable
- IManagedProject newProj = ManagedBuildManager.createManagedProject(project, projType);
- assertEquals(newProj.getName(), projType.getName());
- ManagedBuildManager.setNewProjectVersion(project);
-
- // Initialize the path entry container
- IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project);
- if (initResult.getCode() != IStatus.OK) {
- fail("Initializing build information failed for: " + project.getName() + " because: " + initResult.getMessage());
- }
-
- // Copy over the configs
- IConfiguration[] baseConfigs = projType.getConfigurations();
- for (int i = 0; i < baseConfigs.length; ++i) {
- newProj.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
- }
-
- // Test this out
- checkErrorParsersProject(newProj);
-
- // Save, close, reopen and test again
- ManagedBuildManager.saveBuildInfo(project, true);
- ManagedBuildManager.removeBuildInfo(project);
- try {
- project.close(null);
- } catch (CoreException e) {
- fail("Failed on error parser project close: " + e.getLocalizedMessage());
- }
- try {
- project.open(null);
- } catch (CoreException e) {
- fail("Failed on error parser project open: " + e.getLocalizedMessage());
- }
-
- // Test that the default config was remembered
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
-
- // Check the rest of the default information
- checkErrorParsersProject(info.getManagedProject());
- ManagedBuildManager.removeBuildInfo(project);
- }
-
- /*
- * Do a sanity check on the error parsers target.
- */
- private void checkErrorParsersProject(IManagedProject proj) throws BuildException {
- // Target stuff
- String expectedBinParserId = "org.eclipse.cdt.core.PE";
- IConfiguration[] configs = proj.getConfigurations();
- IToolChain toolChain = configs[0].getToolChain();
- ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
- assertEquals(expectedBinParserId, targetPlatform.getBinaryParserId());
- // This target defines errors parsers. Check that the error parsers
- // have been assigned.
- assertEquals("org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser", configs[0].getErrorParserIds());
-
- // Tool
- ITool[] tools = configs[0].getTools();
- ITool rootTool = tools[0];
- assertEquals(1, tools.length);
- assertEquals("EP Tool", tools[0].getName());
- assertEquals("-o", tools[0].getOutputFlag());
- assertTrue(tools[0].buildsFileType("y"));
- assertTrue(tools[0].buildsFileType("x"));
- assertTrue(tools[0].producesFileType("xy"));
- assertEquals("EP", tools[0].getToolCommand());
- assertEquals(ITool.FILTER_C, rootTool.getNatureFilter());
-
- // There should be one defined configs
- assertEquals(1, configs.length);
- }
-
- /**
- * Test that the build artifact of a <code>ITarget</code> can be modified
- * programmatically.
- */
- public void testConfigBuildArtifact () throws CoreException {
- // Open the test project
- IProject project = createProject(projectName);
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- assertNotNull(info);
- IManagedProject managedProj = info.getManagedProject();
- assertNotNull(managedProj);
- IConfiguration defaultConfig = info.getDefaultConfiguration();
- assertNotNull(defaultConfig);
-
- // Set the build artifact of the configuration
- String ext = defaultConfig.getArtifactExtension();
- String name = project.getName() + "." + ext;
- defaultConfig.setArtifactName(name);
-
- // Save, close, reopen and test again
- ManagedBuildManager.saveBuildInfo(project, false);
- ManagedBuildManager.removeBuildInfo(project);
- project.close(null);
- project.open(null);
-
- // Check the artifact name
- info = ManagedBuildManager.getBuildInfo(project);
- assertNotNull(info);
- managedProj = info.getManagedProject();
- assertNotNull(managedProj);
- defaultConfig = info.getDefaultConfiguration();
- assertNotNull(defaultConfig);
- assertEquals(name, defaultConfig.getArtifactName());
- }
-
- public void testThatAlwaysFails() {
- assertTrue(false);
- }
-
- public void testBug43450 () throws Exception{
- IProject project = createProject( projectName );
-
- IFolder folder = project.getProject().getFolder( "includes" );
- if( !folder.exists() ){
- folder.create( false, true, null );
- }
-
- IFile file = project.getProject().getFile( "includes/header.h" );
- if( !file.exists() ){
- file.create( new ByteArrayInputStream( "class A { public : static int i; };".getBytes() ), false, null );
- }
-
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
- IScannerInfo info = provider.getScannerInformation( project );
- ISourceElementRequestor callback = new NullSourceElementRequestor();
-
- IScanner scanner = ParserFactory.createScanner( new CodeReader( "#include <header.h>\n int A::i = 1;".toCharArray() ),
- info, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback, new NullLogService(), null);
-
- IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, null );
- assertTrue( parser.parse() );
- }
-
-}
-
+/**********************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.managedbuild.core.tests;
+
+import java.io.ByteArrayInputStream;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.parser.CodeReader;
+import org.eclipse.cdt.core.parser.IParser;
+import org.eclipse.cdt.core.parser.IScanner;
+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.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.NullLogService;
+import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
+import org.eclipse.cdt.core.parser.ParserFactory;
+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.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.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.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+/*
+ * These tests exercise CDT 2.0 manifest file functionality
+ */
+public class ManagedBuildCoreTests20 extends TestCase {
+ private static final boolean boolVal = true;
+ private static final String testConfigId = "test.config.override";
+ private static final String testConfigName = "Tester";
+ private static final String enumVal = "Another Enum";
+ private static final String[] listVal = {"_DEBUG", "/usr/include", "libglade.a"};
+ private static final String newExt = "wen";
+ private static final String projectName = "ManagedBuildTest";
+ private static final String projectName2 = "ManagedBuildTest2";
+ private static final String projectRename = "ManagedBuildRedux";
+ private static final String rootExt = "toor";
+ private static final String stringVal = "-c -Wall";
+ private static final String anotherStringVal = "thevalue";
+ private static final String subExt = "bus";
+
+ public ManagedBuildCoreTests20(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(ManagedBuildCoreTests20.class.getName());
+
+ suite.addTest(new ManagedBuildCoreTests20("testExtensions"));
+ suite.addTest(new ManagedBuildCoreTests20("testProjectCreation"));
+ suite.addTest(new ManagedBuildCoreTests20("testConfigurations"));
+ suite.addTest(new ManagedBuildCoreTests20("testConfigurationReset"));
+ suite.addTest(new ManagedBuildCoreTests20("testConfigBuildArtifact"));
+ suite.addTest(new ManagedBuildCoreTests20("testMakeCommandManipulation"));
+ suite.addTest(new ManagedBuildCoreTests20("testScannerInfoInterface"));
+ suite.addTest(new ManagedBuildCoreTests20("testBug43450"));
+ suite.addTest(new ManagedBuildCoreTests20("testProjectRename"));
+ suite.addTest(new ManagedBuildCoreTests20("testErrorParsers"));
+ suite.addTest(new ManagedBuildCoreTests20("cleanup"));
+
+ return suite;
+ }
+
+ /**
+ * Navigates through the build info as defined in the extensions
+ * defined in this plugin
+ */
+ public void testExtensions() throws Exception {
+ 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
+ IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes();
+
+ for (int i = 0; i < projTypes.length; ++i) {
+ IProjectType type = projTypes[i];
+
+ 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);
+ checkForwardProjectTypes(testForwardParent, testForwardChild, testForwardGrandchild);
+
+ // check that the proper number of projectTypes were dynamically provided
+ assertEquals(3, numTypes);
+
+ // All these project types are defines in the plugin files, so none
+ // of them should be null at this point
+ assertNotNull(testRoot);
+ assertNotNull(testSub);
+ assertNotNull(testSubSub);
+ }
+
+ /**
+ * This test exercises the interface the <code>IConfiguration</code> exposes to manipulate
+ * its make command.
+ */
+ public void testMakeCommandManipulation () {
+ String oldMakeCmd = "make";
+ String newMakeCmd = "Ant";
+
+ // Open the test project
+ IProject project = null;
+ try {
+ project = createProject(projectName);
+ IProjectDescription description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+ } catch (CoreException e) {
+ fail("Failed to open project in 'testMakeCommandManipulation': " + e.getLocalizedMessage());
+ }
+ assertNotNull(project);
+
+ // 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 build command
+ assertFalse(defaultConfig.hasOverriddenBuildCommand());
+ assertEquals(oldMakeCmd, defaultConfig.getBuildCommand());
+
+ // Change it
+ defaultConfig.setBuildCommand(newMakeCmd);
+ assertEquals(newMakeCmd, defaultConfig.getBuildCommand());
+ assertTrue(defaultConfig.hasOverriddenBuildCommand());
+
+ // Reset it
+ defaultConfig.setBuildCommand(null);
+ assertFalse(defaultConfig.hasOverriddenBuildCommand());
+ assertEquals(oldMakeCmd, defaultConfig.getBuildCommand());
+
+ ManagedBuildManager.saveBuildInfo(project, false);
+ }
+
+
+ /**
+ * The purpose of this test is to exercise the build path info interface.
+ * To get to that point, a new project/config has to be created in the test
+ * project and the default configuration changed.
+ *
+ * @throws CoreException
+ */
+ public void testScannerInfoInterface(){
+ // Open the test project
+ IProject project = null;
+ try {
+ project = createProject(projectName);
+ IProjectDescription description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+ } catch (CoreException e) {
+ fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage());
+ }
+
+ //These are the expected path settings
+ final String[] expectedPaths = new String[5];
+
+ // This first path is a built-in, so it will not be manipulated by build manager
+ expectedPaths[0] = "/usr/gnu/include";
+ expectedPaths[1] = (new Path("/usr/include")).toOSString();
+ expectedPaths[2] = (new Path("/opt/gnome/include")).toOSString();
+ expectedPaths[3] = (new Path("C:\\home\\tester/include")).toOSString();
+ expectedPaths[4] = project.getLocation().append( "Sub Config\\\"..\\includes\"" ).toOSString();
+
+ // 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 = projType.getConfigurations();
+ for (int i = 0; i < baseConfigs.length; ++i) {
+ newProject.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
+ }
+
+ // Change the default configuration to the sub config
+ IConfiguration[] configs = newProject.getConfigurations();
+ assertEquals(4, configs.length);
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
+ buildInfo.setDefaultConfiguration(newProject.getConfiguration(configs[0].getId()));
+
+ // 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");
+ if (extensionPoint == null) {
+ fail("Failed to retrieve the extension point ScannerInfoProvider.");
+ }
+
+ // Find the first IScannerInfoProvider that supplies build info for the project
+ IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
+ assertNotNull(provider);
+
+ // Now subscribe (note that the method will be called after a change
+ provider.subscribe(project, new IScannerInfoChangeListener () {
+ public void changeNotification(IResource project, IScannerInfo info) {
+ // Test the symbols: expect "BUILTIN" from the manifest, and "DEBUG" and "GNOME=ME"
+ // from the overidden settings
+ Map definedSymbols = info.getDefinedSymbols();
+ assertTrue(definedSymbols.containsKey("BUILTIN"));
+ assertTrue(definedSymbols.containsKey("DEBUG"));
+ assertTrue(definedSymbols.containsKey("GNOME"));
+ assertTrue(definedSymbols.containsValue("ME"));
+ assertEquals((String)definedSymbols.get("BUILTIN"), "");
+ assertEquals((String)definedSymbols.get("DEBUG"), "");
+ assertEquals((String)definedSymbols.get("GNOME"), "ME");
+ // Test the includes path
+ String[] actualPaths = info.getIncludePaths();
+ assertTrue(Arrays.equals(expectedPaths, actualPaths));
+ }
+ });
+
+ // Check the build information before we change it
+ IScannerInfo currentSettings = provider.getScannerInformation(project);
+
+ Map currentSymbols = currentSettings.getDefinedSymbols();
+ // It should simply contain the built-in
+ assertTrue(currentSymbols.containsKey("BUILTIN"));
+ assertEquals((String)currentSymbols.get("BUILTIN"), "");
+ String[] currentPaths = currentSettings.getIncludePaths();
+ assertTrue(Arrays.equals(expectedPaths, currentPaths));
+
+ // Add some defined symbols programmatically
+ String[] expectedSymbols = {"DEBUG", "GNOME = ME "};
+ 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.getSuperClass().getId())) {
+ subTool = tool;
+ break;
+ }
+ }
+ assertNotNull(subTool);
+ IOption symbolOpt = null;
+ IOption[] opts = subTool.getOptions();
+ for (int i = 0; i < opts.length; i++) {
+ IOption option = opts[i];
+ 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, subTool, symbolOpt, expectedSymbols);
+ assertTrue(info.isDirty());
+ info.setDirty(false);
+ assertFalse(info.isDirty());
+ }
+
+ /**
+ * Create a new configuration based on one defined in the plugin file.
+ * Overrides all of the configuration settings. Saves, closes, and reopens
+ * the project. Then calls a method to check the overridden options.
+ *
+ * Tests creating a new configuration.
+ * Tests setting options.
+ * Tests persisting overridden options between project sessions.
+ *
+ */
+ public void testConfigurations() throws CoreException, BuildException {
+ final String rootName = "Root Config";
+ final String overrideName = "Root Override Config";
+ final String completeOverrideName = "Complete Override Config";
+ final String toolCmd = "doIt";
+ final String newCmd = "never";
+
+ // Open the test project
+ IProject project = createProject(projectName);
+ IProjectDescription description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+
+ // 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);
+ assertEquals(definedConfigs[1].getName(), overrideName);
+ assertEquals(definedConfigs[2].getName(), completeOverrideName);
+
+ // Create a new configuration and test the rename function
+ IConfiguration newConfig = managedProj.createConfigurationClone(baseConfig, testConfigId);
+ assertEquals(4, managedProj.getConfigurations().length);
+ newConfig.setName(testConfigName);
+ assertEquals(newConfig.getId(), testConfigId);
+ assertEquals(newConfig.getName(), testConfigName);
+
+ // There is only one tool
+ ITool[] definedTools = newConfig.getTools();
+ assertEquals(1, definedTools.length);
+ ITool rootTool = definedTools[0];
+
+ // Test changing its command
+ assertEquals(rootTool.getToolCommand(), toolCmd);
+ newConfig.setToolCommand(rootTool, newCmd);
+ assertEquals(rootTool.getToolCommand(), newCmd);
+
+ // Override options in the new configuration
+ IOptionCategory topCategory = rootTool.getTopOptionCategory();
+ assertEquals("Root Tool", topCategory.getName());
+ Object[][] options = topCategory.getOptions(newConfig);
+ int i;
+ for (i=0; i<options.length; i++)
+ if (options[i][0] == null) break;
+ assertEquals(2, i);
+ ITool tool = (ITool)options[0][0];
+ IOption option = (IOption)options[0][1];
+ ManagedBuildManager.setOption(newConfig, tool, option, listVal);
+ option = (IOption)options[1][1];
+ ManagedBuildManager.setOption(newConfig, tool, option, boolVal);
+
+ IOptionCategory[] categories = topCategory.getChildCategories();
+ assertEquals(1, categories.length);
+ options = categories[0].getOptions(newConfig);
+ for (i=0; i<options.length; i++)
+ if (options[i][0] == null) break;
+ assertEquals(4, i);
+ tool = (ITool)options[0][0];
+ option = (IOption)options[0][1];
+ ManagedBuildManager.setOption(newConfig, tool, option, stringVal);
+ option = (IOption)options[1][1];
+ ManagedBuildManager.setOption(newConfig, tool, option, anotherStringVal);
+ option = (IOption)options[2][1];
+ ManagedBuildManager.setOption(newConfig, tool, option, enumVal);
+ option = (IOption)options[3][1];
+ ManagedBuildManager.setOption(newConfig, tool, option, "False");
+
+ // Save, close, reopen and test again
+ ManagedBuildManager.saveBuildInfo(project, false);
+ ManagedBuildManager.removeBuildInfo(project);
+ project.close(null);
+ project.open(null);
+
+ // Test the values in the new configuration
+ checkOptionReferences(project);
+
+ // Now delete the new configuration and test the managed project
+ info = ManagedBuildManager.getBuildInfo(project);
+ managedProj = info.getManagedProject();
+ definedConfigs = managedProj.getConfigurations();
+ assertEquals(4, definedConfigs.length);
+ managedProj.removeConfiguration(testConfigId);
+ definedConfigs = managedProj.getConfigurations();
+ assertEquals(3, definedConfigs.length);
+ assertEquals(definedConfigs[0].getName(), rootName);
+ assertEquals(definedConfigs[1].getName(), overrideName);
+ ManagedBuildManager.saveBuildInfo(project, false);
+ }
+
+ public void testConfigurationReset() {
+ // Open the test project
+ IProject project = null;
+ try {
+ project = createProject(projectName);
+ IProjectDescription description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+ } catch (CoreException e) {
+ fail("Failed to open project: " + e.getLocalizedMessage());
+ }
+
+ // Get the default configuration
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ assertNotNull(info);
+ IManagedProject managedProj = info.getManagedProject();
+ assertNotNull(managedProj);
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ assertNotNull(defaultConfig);
+
+ // See if it still contains the overridden values (see testProjectCreation())
+ try {
+ checkRootManagedProject(managedProj, "z");
+ } catch (BuildException e1) {
+ fail("Overridden root managed project check failed: " + e1.getLocalizedMessage());
+ }
+
+ // Reset the config and retest
+ ManagedBuildManager.resetConfiguration(project, defaultConfig);
+ ManagedBuildManager.saveBuildInfo(project, false);
+ try {
+ checkRootManagedProject(managedProj, "x");
+ } catch (BuildException e2) {
+ fail("Reset root managed project check failed: " + e2.getLocalizedMessage());
+ }
+ }
+
+ /**
+ * @throws CoreException
+ * @throws BuildException
+ */
+ public void testProjectCreation() throws BuildException {
+ // Create new project
+ IProject project = null;
+ try {
+ project = createProject(projectName);
+ // Now associate the builder with the project
+ addManagedBuildNature(project);
+ IProjectDescription description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+
+ } catch (CoreException e) {
+ fail("Test failed on project creation: " + e.getLocalizedMessage());
+ }
+
+ // Find the base project type definition
+ IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.root");
+ assertNotNull(projType);
+
+ // Create the managed-project (.cdtbuild) for our project that builds a dummy executable
+ IManagedProject newProject = ManagedBuildManager.createManagedProject(project, projType);
+ assertEquals(newProject.getName(), projType.getName());
+ assertFalse(newProject.equals(projType));
+ ManagedBuildManager.setNewProjectVersion(project);
+
+ // Copy over the configs
+ IConfiguration defaultConfig = null;
+ IConfiguration[] configs = projType.getConfigurations();
+ for (int i = 0; i < configs.length; ++i) {
+ // Make the first configuration the default
+ if (i == 0) {
+ defaultConfig = newProject.createConfiguration(configs[i], projType.getId() + "." + i);
+ } else {
+ newProject.createConfiguration(configs[i], projType.getId() + "." + i);
+ }
+ }
+ ManagedBuildManager.setDefaultConfiguration(project, defaultConfig);
+
+ String buildArtifactName = projectName;
+ defaultConfig.setArtifactName(buildArtifactName);
+ defaultConfig.setArtifactExtension(newExt);
+
+ // Initialize the path entry container
+ IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project);
+ if (initResult.getCode() != IStatus.OK) {
+ fail("Initializing build information failed for: " + project.getName() + " because: " + initResult.getMessage());
+ }
+
+ // Now test the results out
+ checkRootManagedProject(newProject, "x");
+
+ // Override the "String Option in Category" option value
+ configs = newProject.getConfigurations();
+ ITool[] tools = configs[0].getTools();
+ IOptionCategory topCategory = tools[0].getTopOptionCategory();
+ IOptionCategory[] categories = topCategory.getChildCategories();
+ Object[][] options = categories[0].getOptions(configs[0]);
+ ITool tool = (ITool)options[0][0];
+ IOption option = (IOption)options[0][1];
+ configs[0].setOption(tool, option, "z");
+ options = categories[0].getOptions((IConfiguration)null);
+ tool = (ITool)options[0][0];
+ option = (IOption)options[0][1];
+ assertEquals("x", option.getStringValue());
+ options = categories[0].getOptions(configs[0]);
+ tool = (ITool)options[0][0];
+ option = (IOption)options[0][1];
+ assertEquals("z", option.getStringValue());
+
+ // Save, close, reopen and test again
+ 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());
+ }
+
+ // Test that the default config was remembered
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ assertEquals(defaultConfig.getId(), info.getDefaultConfiguration().getId());
+
+ // Check the rest of the default information
+ checkRootManagedProject(newProject, "z");
+
+ // Now test the information the makefile builder needs
+ checkBuildTestSettings(info);
+ ManagedBuildManager.removeBuildInfo(project);
+ }
+
+ /**
+ * Tests that bugzilla 44159 has been addressed. After a project was renamed, the
+ * build information mistakenly referred to the old project as its owner. This
+ * caused a number of searches on the information to fail. In this bug, it was the
+ * list of tools that could not be determined. In other cases, the information
+ * retrieval caused NPEs because the old owner no longer existed.
+ */
+ public void testProjectRename() {
+ // Open the test project
+ IProject project = null;
+ try {
+ project = createProject(projectName);
+ IProjectDescription description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+ } catch (CoreException e) {
+ fail("Failed to open project: " + e.getLocalizedMessage());
+ }
+
+ // Rename the project
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IResource newResource = workspaceRoot.findMember(projectRename);
+ if (newResource != null) {
+ try {
+ newResource.delete(IResource.KEEP_HISTORY, new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("Failed to delete old project " + projectRename + ": " + e.getLocalizedMessage());
+ }
+ }
+ IProjectDescription description = null;
+ try {
+ description = project.getDescription();
+ } catch (CoreException e) {
+ fail("Failed to find project descriptor for " + projectName + ": " + e.getLocalizedMessage());
+ }
+ description.setName(projectRename);
+ try {
+ project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("Failed to rename project: " + e.getLocalizedMessage());
+ }
+ try {
+ project = createProject(projectRename);
+ description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+ } catch (CoreException e) {
+ fail("Failed to open renamed project: " + e.getLocalizedMessage());
+ }
+
+ // By now the project should have 3 configs
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IManagedProject managedProj = info.getManagedProject();
+ IConfiguration[] definedConfigs = managedProj.getConfigurations();
+ assertEquals(4, definedConfigs.length);
+ IConfiguration baseConfig = definedConfigs[1];
+
+ // There is only one tool
+ ITool[] definedTools = baseConfig.getTools();
+ assertEquals(1, definedTools.length);
+ ITool rootTool = definedTools[0];
+
+ // Get the options (2) in top category and (4) in its child
+ IOptionCategory topCategory = rootTool.getTopOptionCategory();
+ assertEquals("Root Tool", topCategory.getName());
+ Object[][] options = topCategory.getOptions(baseConfig);
+ int i;
+ for (i=0; i<options.length; i++)
+ if (options[i][0] == null) break;
+ assertEquals(2, i);
+ IOptionCategory[] categories = topCategory.getChildCategories();
+ assertEquals(1, categories.length);
+ options = categories[0].getOptions(baseConfig);
+ for (i=0; i<options.length; i++)
+ if (options[i][0] == null) break;
+ assertEquals(4, i);
+
+ // Set the name back
+ newResource = workspaceRoot.findMember(projectName);
+ if (newResource != null) {
+ try {
+ newResource.delete(IResource.KEEP_HISTORY, new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("Failed to delete old project " + projectName + ": " + e.getLocalizedMessage());
+ }
+ }
+ try {
+ description = project.getDescription();
+ } catch (CoreException e) {
+ fail("Failed to find project descriptor for " + projectRename + ": " + e.getLocalizedMessage());
+ }
+ description.setName(projectName);
+ try {
+ project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("Failed to re-rename project: " + e.getLocalizedMessage());
+ }
+ try {
+ project = createProject(projectName);
+ description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+ } catch (CoreException e) {
+ fail("Failed to open re-renamed project: " + e.getLocalizedMessage());
+ }
+
+ // Do it all again
+ info = ManagedBuildManager.getBuildInfo(project);
+ managedProj = info.getManagedProject();
+ definedConfigs = managedProj.getConfigurations();
+ assertEquals(4, definedConfigs.length);
+ baseConfig = definedConfigs[1];
+ definedTools = baseConfig.getTools();
+ assertEquals(1, definedTools.length);
+ rootTool = definedTools[0];
+ topCategory = rootTool.getTopOptionCategory();
+ assertEquals("Root Tool", topCategory.getName());
+ options = topCategory.getOptions(baseConfig);
+ for (i=0; i<options.length; i++)
+ if (options[i][0] == null) break;
+ assertEquals(2, i);
+ categories = topCategory.getChildCategories();
+ assertEquals(1, categories.length);
+ options = categories[0].getOptions(baseConfig);
+ for (i=0; i<options.length; i++)
+ if (options[i][0] == null) break;
+ assertEquals(4, i);
+ }
+
+ private void addManagedBuildNature (IProject project) {
+ // Create the buildinformation object for the project
+ IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+ info.setValid(true);
+
+ // Add the managed build nature
+ try {
+ ManagedCProjectNature.addManagedNature(project, new NullProgressMonitor());
+ ManagedCProjectNature.addManagedBuilder(project, new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("Test failed on adding managed build nature or builder: " + e.getLocalizedMessage());
+ }
+
+ // Associate the project with the managed builder so the clients can get proper information
+ ICDescriptor desc = null;
+ try {
+ desc = CCorePlugin.getDefault().getCProjectDescription(project, true);
+ desc.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
+ desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
+ } catch (CoreException e) {
+ fail("Test failed on adding managed builder as scanner info provider: " + e.getLocalizedMessage());
+ }
+ try {
+ desc.saveProjectData();
+ } catch (CoreException e) {
+ fail("Test failed on saving the ICDescriptor data: " + e.getLocalizedMessage()); }
+ }
+
+ /**
+ * Tests the tool settings through the interface the makefile generator
+ * uses.
+ *
+ * @param project
+ */
+ private void checkBuildTestSettings(IManagedBuildInfo info) {
+ String ext1 = "foo";
+ String ext2 = "bar";
+ String badExt = "cpp";
+ String expectedOutput = "toor";
+ String expectedCmd = "doIt";
+
+ assertNotNull(info);
+ assertEquals(info.getBuildArtifactName(), projectName);
+
+ // There should be a default configuration defined for the project
+ IManagedProject managedProj = info.getManagedProject();
+ assertNotNull(managedProj);
+ IConfiguration buildConfig = info.getDefaultConfiguration();
+ assertNotNull(buildConfig);
+
+ // Check that tool handles resources with extensions foo and bar by building a baz
+ assertEquals(info.getOutputExtension(ext1), expectedOutput);
+ assertEquals(info.getOutputExtension(ext2), expectedOutput);
+
+ // Check that it ignores others based on filename extensions
+ assertNull(info.getOutputExtension(badExt));
+
+ // Now see what the tool command line invocation is for foo and bar
+ assertEquals(info.getToolForSource(ext1), expectedCmd);
+ assertEquals(info.getToolForSource(ext2), expectedCmd);
+ // Make sure that there is no tool to build files of type foo and bar
+ assertNull(info.getToolForConfiguration(ext1));
+ assertNull(info.getToolForConfiguration(ext2));
+
+ // There is no tool that builds toor
+ assertNull(info.getToolForSource(expectedOutput));
+ // but there is one that produces it
+ assertEquals(info.getToolForConfiguration(expectedOutput), expectedCmd);
+
+ // Now check the build flags
+ assertEquals(info.getFlagsForSource(ext1), "-La -Lb z -e1 -nob");
+ assertEquals(info.getFlagsForSource(ext1), info.getFlagsForSource(ext2));
+
+ }
+
+ /**
+ * Tests that overridden options are properly read into build model.
+ * Test that option values that are not overridden remain the same.
+ *
+ * @param project The project to get build model information for.
+ * @throws BuildException
+ */
+ private void checkOptionReferences(IProject project) throws BuildException {
+ // Get the configs
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IManagedProject managedProj = info.getManagedProject();
+ IConfiguration[] definedConfigs = managedProj.getConfigurations();
+ assertEquals(4, definedConfigs.length);
+ IConfiguration newConfig = managedProj.getConfiguration(testConfigId);
+ assertNotNull(newConfig);
+
+ // Now get the tool options and make sure the values are correct
+ ITool[] definedTools = newConfig.getTools();
+ assertEquals(1, definedTools.length);
+ ITool rootTool = definedTools[0];
+
+ // Check that the options in the new config contain overridden values
+ IOption[] rootOptions = rootTool.getOptions();
+ assertEquals(6, rootOptions.length);
+ // First is the new list
+ assertEquals("List Option in Top", rootOptions[0].getName());
+ assertEquals(IOption.STRING_LIST, rootOptions[0].getValueType());
+ String[] list = rootOptions[0].getStringListValue();
+ assertEquals(3, list.length);
+ assertTrue(Arrays.equals(listVal, list));
+ assertEquals(rootOptions[0].getCommand(), "-L");
+ // Next option is a boolean in top
+ assertEquals("Boolean Option in Top", rootOptions[1].getName());
+ assertEquals(IOption.BOOLEAN, rootOptions[1].getValueType());
+ assertEquals(boolVal, rootOptions[1].getBooleanValue());
+ assertEquals("-b", rootOptions[1].getCommand());
+ // Next option is a string in category
+ assertEquals("String Option in Category", rootOptions[2].getName());
+ assertEquals(IOption.STRING, rootOptions[2].getValueType());
+ assertEquals(stringVal, rootOptions[2].getStringValue());
+ // Next option is a another string in category
+ assertEquals("Another String Option in Category", rootOptions[3].getName());
+ assertEquals(IOption.STRING, rootOptions[3].getValueType());
+ assertEquals(anotherStringVal, rootOptions[3].getStringValue());
+ assertEquals("-str", rootOptions[3].getCommand());
+ // Next option is an enumerated in category
+ assertEquals("Enumerated Option in Category", rootOptions[4].getName());
+ assertEquals(IOption.ENUMERATED, rootOptions[4].getValueType());
+ String selEnum = rootOptions[4].getSelectedEnum();
+ assertEquals(enumVal, selEnum);
+ String[] enums = rootOptions[4].getApplicableValues();
+ assertEquals(2, enums.length);
+ assertEquals("Default Enum", enums[0]);
+ assertEquals("Another Enum", enums[1]);
+ assertEquals("-e1", rootOptions[4].getEnumCommand(enums[0]));
+ assertEquals("-e2", rootOptions[4].getEnumCommand(enums[1]));
+ assertEquals("-e2", rootOptions[4].getEnumCommand(selEnum));
+ // Final option is a boolean in Category
+ assertEquals("Boolean Option in Category", rootOptions[5].getName());
+ assertEquals(IOption.BOOLEAN, rootOptions[5].getValueType());
+ assertEquals(false, rootOptions[5].getBooleanValue());
+ assertEquals("-nob", rootOptions[5].getCommandFalse());
+ }
+
+ /*
+ * Do a full sanity check on the root project type.
+ */
+ private void checkRootProjectType(IProjectType type) throws BuildException {
+ // Project stuff
+ String expectedCleanCmd = "del /myworld";
+ String expectedParserId = "org.eclipse.cdt.core.PE";
+ String[] expectedOSList = {"win32"};
+ String[] expectedArchList = {"all"};
+ assertTrue(type.isTestProjectType());
+ IConfiguration[] configs = type.getConfigurations();
+ if (configs[0].getArtifactName().equals("ManagedBuildTest")) {
+ assertEquals(configs[0].getArtifactExtension(), newExt);
+ } else {
+ assertEquals(configs[0].getArtifactExtension(), rootExt);
+ }
+ assertEquals(expectedCleanCmd, configs[0].getCleanCommand());
+ assertEquals("make", configs[0].getBuildCommand());
+ IToolChain toolChain = configs[0].getToolChain();
+ ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
+ // Make the test work as before after introducing multiple binary parsers
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedParserId);
+ assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
+ assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
+ // This configuration defines no errors parsers.
+ assertNull(configs[0].getErrorParserIds());
+ assertTrue(Arrays.equals(configs[0].getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs()));
+
+ // Tools
+ ITool[] tools = toolChain.getTools();
+ // Root Tool
+ ITool rootTool = tools[0];
+ assertEquals("Root Tool", rootTool.getName());
+ // 6 Options are defined in the root tool
+ IOption[] options = rootTool.getOptions();
+ assertEquals(6, options.length);
+ // First option is a 3-element list with 1 built-in
+ assertEquals("List Option in Top", options[0].getName());
+ assertEquals(IOption.STRING_LIST, options[0].getValueType());
+ String[] valueList = options[0].getStringListValue();
+ assertEquals(2, valueList.length);
+ assertEquals("a", valueList[0]);
+ assertEquals("b", valueList[1]);
+ String[] builtInList = options[0].getBuiltIns();
+ assertEquals(1, builtInList.length);
+ assertEquals("c", builtInList[0]);
+ assertEquals(options[0].getCommand(), "-L");
+ // Next option is a boolean in top
+ assertEquals("Boolean Option in Top", options[1].getName());
+ assertEquals(IOption.BOOLEAN, options[1].getValueType());
+ assertEquals(false, options[1].getBooleanValue());
+ assertEquals("-b", options[1].getCommand());
+ // Next option is a string category
+ assertEquals("String Option in Category", options[2].getName());
+ assertEquals(IOption.STRING, options[2].getValueType());
+ assertEquals("x", options[2].getStringValue());
+ // Next option is another string category
+ assertEquals("Another String Option in Category", options[3].getName());
+ assertEquals(IOption.STRING, options[3].getValueType());
+ assertEquals("", options[3].getStringValue());
+ assertEquals("-str", options[3].getCommand());
+ // Next option is an enumerated
+ assertEquals("Enumerated Option in Category", options[4].getName());
+ assertEquals(IOption.ENUMERATED, options[4].getValueType());
+ // Post-2.0 enums store the ID, not the string value
+ assertEquals("default.enum.option", options[4].getSelectedEnum());
+ assertEquals("-e1", options[4].getEnumCommand("default.enum.option"));
+ // Need this methof to populate the UI selection widget
+ valueList = options[4].getApplicableValues();
+ assertEquals(2, valueList.length);
+ assertEquals("Default Enum", valueList[0]);
+ assertEquals("Another Enum", valueList[1]);
+ // Test compatability with 1.2 scheme of getting the command from the name
+ assertEquals("-e1", options[4].getEnumCommand(valueList[0]));
+ assertEquals("-e2", options[4].getEnumCommand(valueList[1]));
+ // Final option is another boolean
+ assertEquals("Boolean Option in Category", options[5].getName());
+ assertEquals(IOption.BOOLEAN, options[5].getValueType());
+ assertEquals(false, options[5].getBooleanValue());
+ assertEquals("", options[5].getCommand());
+ assertEquals("-nob", options[5].getCommandFalse());
+
+ // Option Categories
+ IOptionCategory topCategory = rootTool.getTopOptionCategory();
+ assertEquals("Root Tool", topCategory.getName());
+ Object[][] catoptions = topCategory.getOptions(configs[0]);
+ int i;
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(2, i);
+ assertEquals("List Option in Top", ((IOption)catoptions[0][1]).getName());
+ assertEquals("Boolean Option in Top", ((IOption)catoptions[1][1]).getName());
+ IOptionCategory[] categories = topCategory.getChildCategories();
+ assertEquals(1, categories.length);
+ assertEquals("Category", categories[0].getName());
+ catoptions = categories[0].getOptions(configs[0]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(4, i);
+ assertEquals("String Option in Category", ((IOption)catoptions[0][1]).getName());
+ assertEquals("Another String Option in Category", ((IOption)catoptions[1][1]).getName());
+ assertEquals("Enumerated Option in Category", ((IOption)catoptions[2][1]).getName());
+ assertEquals("Boolean Option in Category", ((IOption)catoptions[3][1]).getName());
+
+ // There should be 3 defined configs
+ configs = type.getConfigurations();
+ assertEquals(3, configs.length);
+
+ // Root Config
+ IConfiguration rootConfig = configs[0];
+ assertEquals("Root Config", rootConfig.getName());
+
+ // Tool elements
+ tools = rootConfig.getTools();
+ assertEquals(1, tools.length);
+ assertEquals("Root Tool", tools[0].getName());
+ assertEquals("-r", tools[0].getOutputFlag());
+ assertTrue(tools[0].buildsFileType("foo"));
+ assertTrue(tools[0].buildsFileType("bar"));
+ assertTrue(tools[0].producesFileType("toor"));
+ assertEquals("doIt", tools[0].getToolCommand());
+ assertEquals("", tools[0].getOutputPrefix());
+ // The root tool defines one valid header file extension
+ assertTrue(rootTool.isHeaderFile("baz"));
+ assertTrue(tools[0].isHeaderFile("baz"));
+ assertEquals(ITool.FILTER_C, rootTool.getNatureFilter());
+
+ // Partially Overriden Configuration
+ assertEquals("Root Override Config", configs[1].getName());
+ tools = configs[1].getTools();
+ assertEquals(1, tools.length);
+ assertEquals("Root Tool", tools[0].getName());
+ topCategory = tools[0].getTopOptionCategory();
+ catoptions = topCategory.getOptions(configs[1]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(2, i);
+ assertEquals("List Option in Top", ((IOption)catoptions[0][1]).getName());
+ valueList = ((IOption)catoptions[0][1]).getStringListValue();
+ assertEquals("a", valueList[0]);
+ assertEquals("b", valueList[1]);
+ assertEquals("Boolean Option in Top", ((IOption)catoptions[1][1]).getName());
+ assertEquals(true, ((IOption)catoptions[1][1]).getBooleanValue());
+ assertEquals("-b", ((IOption)catoptions[1][1]).getCommand());
+ categories = topCategory.getChildCategories();
+ catoptions = categories[0].getOptions(configs[1]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(4, i);
+ assertEquals("String Option in Category", ((IOption)catoptions[0][1]).getName());
+ assertEquals("y", ((IOption)catoptions[0][1]).getStringValue());
+ assertEquals("Another String Option in Category", ((IOption)catoptions[1][1]).getName());
+ assertEquals("", ((IOption)catoptions[1][1]).getStringValue());
+ assertEquals("Enumerated Option in Category", ((IOption)catoptions[2][1]).getName());
+ valueList = ((IOption)catoptions[2][1]).getApplicableValues();
+ assertEquals(2, valueList.length);
+ assertEquals("Default Enum", valueList[0]);
+ assertEquals("Another Enum", valueList[1]);
+ assertEquals("-e1", ((IOption)catoptions[2][1]).getEnumCommand(valueList[0]));
+ assertEquals("-e2", ((IOption)catoptions[2][1]).getEnumCommand(valueList[1]));
+ assertEquals(1, tools.length);
+ assertEquals("Boolean Option in Category", ((IOption)catoptions[3][1]).getName());
+ assertEquals(false, ((IOption)catoptions[3][1]).getBooleanValue());
+ assertEquals("", ((IOption)catoptions[3][1]).getCommand());
+ assertEquals("-nob", ((IOption)catoptions[3][1]).getCommandFalse());
+ assertEquals(1, tools.length);
+ ITool tool = tools[0];
+ assertNotNull(tool);
+ assertEquals("Root Tool", tool.getName());
+ assertEquals("-r", tool.getOutputFlag());
+ assertTrue(tool.buildsFileType("foo"));
+ assertTrue(tool.buildsFileType("bar"));
+ assertTrue(tool.producesFileType("toor"));
+ assertTrue(tool.isHeaderFile("baz"));
+ assertEquals("doIt", tool.getToolCommand());
+ assertEquals("-La -Lb -b y -e1 -nob", tool.getToolFlags());
+
+ // Completely Overridden configuration
+ assertEquals("Complete Override Config", configs[2].getName());
+ tools = configs[2].getTools();
+ assertEquals(1, tools.length);
+ assertEquals("Root Tool", tools[0].getName());
+ topCategory = tools[0].getTopOptionCategory();
+ catoptions = topCategory.getOptions(configs[2]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(2, i);
+ // Check that there's an string list with totally new values
+ assertEquals("List Option in Top", ((IOption)catoptions[0][1]).getName());
+ assertEquals(IOption.STRING_LIST, ((IOption)catoptions[0][1]).getValueType());
+ valueList = ((IOption)catoptions[0][1]).getStringListValue();
+ assertTrue(valueList.length == 3);
+ assertEquals("d", valueList[0]);
+ assertEquals("e", valueList[1]);
+ assertEquals("f", valueList[2]);
+ assertEquals("-L", ((IOption)catoptions[0][1]).getCommand());
+ // and a true boolean (commands should not have changed)
+ assertEquals("Boolean Option in Top", ((IOption)catoptions[1][1]).getName());
+ assertEquals(IOption.BOOLEAN, ((IOption)catoptions[1][1]).getValueType());
+ assertEquals(true, ((IOption)catoptions[1][1]).getBooleanValue());
+ assertEquals("-b", ((IOption)catoptions[1][1]).getCommand());
+ // Check that there's an overridden enumeration and string
+ categories = topCategory.getChildCategories();
+ catoptions = categories[0].getOptions(configs[2]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(4, i);
+ assertEquals("String Option in Category", ((IOption)catoptions[0][1]).getName());
+ assertEquals(IOption.STRING, ((IOption)catoptions[0][1]).getValueType());
+ assertEquals("overridden", ((IOption)catoptions[0][1]).getStringValue());
+ assertEquals("Another String Option in Category", ((IOption)catoptions[1][1]).getName());
+ assertEquals(IOption.STRING, ((IOption)catoptions[1][1]).getValueType());
+ assertEquals("alsooverridden", ((IOption)catoptions[1][1]).getStringValue());
+ assertEquals("Enumerated Option in Category", ((IOption)catoptions[2][1]).getName());
+ assertEquals(IOption.ENUMERATED, ((IOption)catoptions[2][1]).getValueType());
+ assertEquals("another.enum.option", ((IOption)catoptions[2][1]).getSelectedEnum());
+ assertEquals("Boolean Option in Category", ((IOption)catoptions[3][1]).getName());
+ assertEquals(IOption.BOOLEAN, ((IOption)catoptions[3][1]).getValueType());
+ assertEquals(true, ((IOption)catoptions[3][1]).getBooleanValue());
+ tool = tools[0];
+ assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags());
+
+ // Make sure that the build manager returns the default makefile generator (not null)
+ assertNotNull(ManagedBuildManager.getBuildfileGenerator(configs[0]));
+ }
+
+ /*
+ * Do a full sanity check on the root managed project.
+ */
+ private void checkRootManagedProject(IManagedProject managedProj, String testValue) throws BuildException {
+ String expectedCleanCmd = "del /myworld";
+ String expectedParserId = "org.eclipse.cdt.core.PE";
+ String[] expectedOSList = {"win32"};
+ String[] expectedArchList = {"all"};
+ assertTrue(managedProj.getProjectType().isTestProjectType());
+ IConfiguration[] configs = managedProj.getConfigurations();
+ if (configs[0].getArtifactName().equals("ManagedBuildTest")) {
+ assertEquals(configs[0].getArtifactExtension(), newExt);
+ } else {
+ assertEquals(configs[0].getArtifactExtension(), rootExt);
+ }
+ assertEquals(expectedCleanCmd, configs[0].getCleanCommand());
+ assertEquals("make", configs[0].getBuildCommand());
+ IToolChain toolChain = configs[0].getToolChain();
+ ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
+ // Make the test work as before after introducing multiple binary parsers
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedParserId);
+ assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
+ assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
+ // This configuration defines no errors parsers.
+ assertNull(configs[0].getErrorParserIds());
+ assertTrue(Arrays.equals(configs[0].getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs()));
+
+ // Tools
+ ITool[] tools = configs[0].getTools();
+ // Root Tool
+ ITool rootTool = tools[0];
+ assertEquals("Root Tool", rootTool.getName());
+ // 6 Options are defined in the root tool
+ IOption[] options = rootTool.getOptions();
+ assertEquals(6, options.length);
+ // First option is a 3-element list with 1 built-in
+ assertEquals("List Option in Top", options[0].getName());
+ assertEquals(IOption.STRING_LIST, options[0].getValueType());
+ String[] valueList = options[0].getStringListValue();
+ assertEquals(2, valueList.length);
+ assertEquals("a", valueList[0]);
+ assertEquals("b", valueList[1]);
+ String[] builtInList = options[0].getBuiltIns();
+ assertEquals(1, builtInList.length);
+ assertEquals("c", builtInList[0]);
+ assertEquals(options[0].getCommand(), "-L");
+ // Next option is a boolean in top
+ assertEquals("Boolean Option in Top", options[1].getName());
+ assertEquals(IOption.BOOLEAN, options[1].getValueType());
+ assertEquals(false, options[1].getBooleanValue());
+ assertEquals("-b", options[1].getCommand());
+ // Next option is a string category
+ assertEquals("String Option in Category", options[2].getName());
+ assertEquals(IOption.STRING, options[2].getValueType());
+ assertEquals(testValue, options[2].getStringValue());
+ // Next option is another string category
+ assertEquals("Another String Option in Category", options[3].getName());
+ assertEquals(IOption.STRING, options[3].getValueType());
+ assertEquals("", options[3].getStringValue());
+ assertEquals("-str", options[3].getCommand());
+ // Next option is an enumerated
+ assertEquals("Enumerated Option in Category", options[4].getName());
+ assertEquals(IOption.ENUMERATED, options[4].getValueType());
+ // Post-2.0 enums store the ID, not the string value
+ assertEquals("default.enum.option", options[4].getSelectedEnum());
+ assertEquals("-e1", options[4].getEnumCommand("default.enum.option"));
+ // Need this methof to populate the UI selection widget
+ valueList = options[4].getApplicableValues();
+ assertEquals(2, valueList.length);
+ assertEquals("Default Enum", valueList[0]);
+ assertEquals("Another Enum", valueList[1]);
+ // Test compatability with 1.2 scheme of getting the command from the name
+ assertEquals("-e1", options[4].getEnumCommand(valueList[0]));
+ assertEquals("-e2", options[4].getEnumCommand(valueList[1]));
+ // Final option is another boolean
+ assertEquals("Boolean Option in Category", options[5].getName());
+ assertEquals(IOption.BOOLEAN, options[5].getValueType());
+ assertEquals(false, options[5].getBooleanValue());
+ assertEquals("", options[5].getCommand());
+ assertEquals("-nob", options[5].getCommandFalse());
+
+ // Option Categories
+ IOptionCategory topCategory = rootTool.getTopOptionCategory();
+ assertEquals("Root Tool", topCategory.getName());
+ Object[][] catoptions = topCategory.getOptions(configs[0]);
+ int i;
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(2, i);
+ IOption catOption = (IOption)catoptions[0][1];
+ assertEquals("List Option in Top", catOption.getName());
+ catOption = (IOption)catoptions[1][1];
+ assertEquals("Boolean Option in Top", catOption.getName());
+ IOptionCategory[] categories = topCategory.getChildCategories();
+ assertEquals(1, categories.length);
+ assertEquals("Category", categories[0].getName());
+ catoptions = categories[0].getOptions(configs[0]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(4, i);
+ catOption = (IOption)catoptions[0][1];
+ assertEquals("String Option in Category", catOption.getName());
+ catOption = (IOption)catoptions[1][1];
+ assertEquals("Another String Option in Category", catOption.getName());
+ catOption = (IOption)catoptions[2][1];
+ assertEquals("Enumerated Option in Category", catOption.getName());
+ catOption = (IOption)catoptions[3][1];
+ assertEquals("Boolean Option in Category", catOption.getName());
+
+ // There should be 3 defined configs
+ assertEquals(3, configs.length);
+
+ // Root Config
+ IConfiguration rootConfig = configs[0];
+ assertEquals("Root Config", rootConfig.getName());
+
+ // Tool elements
+ tools = rootConfig.getTools();
+ assertEquals(1, tools.length);
+ assertEquals("Root Tool", tools[0].getName());
+ assertEquals("-r", tools[0].getOutputFlag());
+ assertTrue(tools[0].buildsFileType("foo"));
+ assertTrue(tools[0].buildsFileType("bar"));
+ assertTrue(tools[0].producesFileType("toor"));
+ assertEquals("doIt", tools[0].getToolCommand());
+ assertEquals("", tools[0].getOutputPrefix());
+ // The root tool defines one valid header file extension
+ assertTrue(rootTool.isHeaderFile("baz"));
+ assertTrue(tools[0].isHeaderFile("baz"));
+ assertEquals(ITool.FILTER_C, rootTool.getNatureFilter());
+
+ // Partially Overriden Configuration
+ assertEquals("Root Override Config", configs[1].getName());
+ tools = configs[1].getTools();
+ assertEquals(1, tools.length);
+ assertEquals("Root Tool", tools[0].getName());
+ topCategory = tools[0].getTopOptionCategory();
+ catoptions = topCategory.getOptions(configs[1]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(2, i);
+ catOption = (IOption)catoptions[0][1];
+ assertEquals("List Option in Top", catOption.getName());
+ valueList = catOption.getStringListValue();
+ assertEquals("a", valueList[0]);
+ assertEquals("b", valueList[1]);
+ catOption = (IOption)catoptions[1][1];
+ assertEquals("Boolean Option in Top", catOption.getName());
+ assertEquals(true, catOption.getBooleanValue());
+ assertEquals("-b", catOption.getCommand());
+ categories = topCategory.getChildCategories();
+ catoptions = categories[0].getOptions(configs[1]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(4, i);
+ catOption = (IOption)catoptions[0][1];
+ assertEquals("String Option in Category", catOption.getName());
+ assertEquals("y", catOption.getStringValue());
+ catOption = (IOption)catoptions[1][1];
+ assertEquals("Another String Option in Category", catOption.getName());
+ assertEquals("", catOption.getStringValue());
+ catOption = (IOption)catoptions[2][1];
+ assertEquals("Enumerated Option in Category", catOption.getName());
+ valueList = catOption.getApplicableValues();
+ assertEquals(2, valueList.length);
+ assertEquals("Default Enum", valueList[0]);
+ assertEquals("Another Enum", valueList[1]);
+ catOption = (IOption)catoptions[2][1];
+ assertEquals("-e1", catOption.getEnumCommand(valueList[0]));
+ assertEquals("-e2", catOption.getEnumCommand(valueList[1]));
+ assertEquals(1, tools.length);
+ catOption = (IOption)catoptions[3][1];
+ assertEquals("Boolean Option in Category", catOption.getName());
+ assertEquals(false, catOption.getBooleanValue());
+ assertEquals("", catOption.getCommand());
+ assertEquals("-nob", catOption.getCommandFalse());
+ assertEquals(1, tools.length);
+ ITool tool = tools[0];
+ assertNotNull(tool);
+ assertEquals("Root Tool", tool.getName());
+ assertEquals("-r", tool.getOutputFlag());
+ assertTrue(tool.buildsFileType("foo"));
+ assertTrue(tool.buildsFileType("bar"));
+ assertTrue(tool.producesFileType("toor"));
+ assertTrue(tool.isHeaderFile("baz"));
+ assertEquals("doIt", tool.getToolCommand());
+ assertEquals("-La -Lb -b y -e1 -nob", tool.getToolFlags());
+
+ // Completely Overridden configuration
+ assertEquals("Complete Override Config", configs[2].getName());
+ tools = configs[2].getTools();
+ assertEquals(1, tools.length);
+ assertEquals("Root Tool", tools[0].getName());
+ topCategory = tools[0].getTopOptionCategory();
+ catoptions = topCategory.getOptions(configs[2]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(2, i);
+ // Check that there's an string list with totally new values
+ catOption = (IOption)catoptions[0][1];
+ assertEquals("List Option in Top", catOption.getName());
+ assertEquals(IOption.STRING_LIST, catOption.getValueType());
+ valueList = catOption.getStringListValue();
+ assertTrue(valueList.length == 3);
+ assertEquals("d", valueList[0]);
+ assertEquals("e", valueList[1]);
+ assertEquals("f", valueList[2]);
+ assertEquals("-L", catOption.getCommand());
+ // and a true boolean (commands should not have changed)
+ catOption = (IOption)catoptions[1][1];
+ assertEquals("Boolean Option in Top", catOption.getName());
+ assertEquals(IOption.BOOLEAN, catOption.getValueType());
+ assertEquals(true, catOption.getBooleanValue());
+ assertEquals("-b", catOption.getCommand());
+ // Check that there's an overridden enumeration and string
+ categories = topCategory.getChildCategories();
+ catoptions = categories[0].getOptions(configs[2]);
+ for (i=0; i<catoptions.length; i++)
+ if (catoptions[i][0] == null) break;
+ assertEquals(4, i);
+ catOption = (IOption)catoptions[0][1];
+ assertEquals("String Option in Category", catOption.getName());
+ assertEquals(IOption.STRING, catOption.getValueType());
+ assertEquals("overridden", catOption.getStringValue());
+ catOption = (IOption)catoptions[1][1];
+ assertEquals("Another String Option in Category", catOption.getName());
+ assertEquals(IOption.STRING, catOption.getValueType());
+ assertEquals("alsooverridden", catOption.getStringValue());
+ catOption = (IOption)catoptions[2][1];
+ assertEquals("Enumerated Option in Category", catOption.getName());
+ assertEquals(IOption.ENUMERATED, catOption.getValueType());
+ assertEquals("another.enum.option", catOption.getSelectedEnum());
+ catOption = (IOption)catoptions[3][1];
+ assertEquals("Boolean Option in Category", catOption.getName());
+ assertEquals(IOption.BOOLEAN, catOption.getValueType());
+ assertEquals(true, catOption.getBooleanValue());
+ tool = tools[0];
+ assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags());
+
+ // Make sure that the build manager returns the default makefile generator (not null)
+ assertNotNull(ManagedBuildManager.getBuildfileGenerator(configs[0]));
+ }
+
+ /*
+ * The Sub Sub project type has a reference to a tool that is defined
+ * independently from the project type itself. This is a common pattern
+ * for tools that are shared between many project types.
+ *
+ * The tool itself is defined as having two option categories, with
+ * one option in each category. To test that the reference is properly
+ * inheritted, the project type overrides the default value of the boolean
+ * option.
+ *
+ * The test confirms that the basic settings are inheritted through the
+ * reference, and that the overridden value is used instead of the
+ * default. It also tests that the command can be overidden through a
+ * tool reference.
+ *
+ * Finally, the string option in the configuration is overridden and the
+ * test confirms that it contains both the overridden boolean that the
+ * project type provides, and the overridden string that it provides.
+ *
+ * @param testSubSub
+ */
+ private void checkSubSubProjectType(IProjectType projType) {
+ final String indyToolName = "Target Independent Tool";
+ final String indyToolCommand = "RC.EXE";
+ final String indyToolInputExt = "rc";
+ final String indyToolOutputExt = "free";
+ final String indyToolOutFlag = "/fo";
+ final String indyToolHeader = "h";
+ final String indyToolHeaderNot = "j";
+ final String indyCatOne = "Free";
+ final String indyCatTwo = "Chained";
+ final String freeOptName = "String in Free";
+ final String chainedOptName = "Boolean in Chained";
+ final String freeOptValue = "Live free or die";
+ final String newCmd = "Let the Wookie win";
+ final String stringOverride = "The future language of slaves";
+
+ IConfiguration[] configs = projType.getConfigurations();
+ // Check the inherited clean command
+ assertEquals("rm -yourworld", configs[0].getCleanCommand());
+ // Check that the make command is overridden from parent
+ assertEquals("nmake", configs[0].getBuildCommand());
+ // Make sure we get the proper binary parser
+ IToolChain toolChain = configs[0].getToolChain();
+ ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
+ // Make the test work as before after introducing multiple binary parsers
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals("org.eclipse.cdt.core.ELF", binaryParsers[0]);
+ // Make sure the os list is inherited
+ String[] expectedOSList = {"win32","linux","solaris"};
+ assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
+ // Make sure the arch list is inherited
+ String[] expectedArchList = {"x86", "ppc"};
+ assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
+
+ // Get the 5 configurations (3 from test, 1 from test sub and 1 from this)
+ assertEquals(5, configs.length);
+
+ // Check the tools. We should have 3 (1 from each parent and the one referenced).
+ ITool[] tools = configs[0].getTools();
+ assertEquals(3, tools.length);
+ ITool toolRef = tools[0];
+
+ // Make sure we get all the tool settings
+ assertEquals(toolRef.getName(), indyToolName);
+ assertEquals(toolRef.getToolCommand(), indyToolCommand);
+ assertTrue(toolRef.buildsFileType(indyToolInputExt));
+ assertEquals(toolRef.getOutputExtension(indyToolInputExt), indyToolOutputExt);
+ assertEquals(toolRef.getOutputFlag(), indyToolOutFlag);
+ assertTrue(toolRef.isHeaderFile(indyToolHeader));
+ assertFalse(toolRef.isHeaderFile(indyToolHeaderNot));
+ assertEquals(toolRef.getNatureFilter(), ITool.FILTER_BOTH);
+ // Check out the referenced tool and make sure we get all option categories
+ IOptionCategory topCategory = toolRef.getTopOptionCategory();
+ IOptionCategory[] categories = topCategory.getChildCategories();
+ assertEquals(1, categories.length);
+ assertEquals(categories[0].getName(), indyCatOne);
+ IOptionCategory[] subCategories = categories[0].getChildCategories();
+ // Is the chained category a subcategory
+ assertEquals(1, subCategories.length);
+ assertEquals(subCategories[0].getName(), indyCatTwo);
+ // Make sure the option in the top category is correct
+ Object[][] optsInCat = categories[0].getOptions(configs[0]);
+ int i;
+ for (i=0; i<optsInCat.length; i++)
+ if (optsInCat[i][0] == null) break;
+ assertEquals(1, i);
+ IOption optCat = (IOption)optsInCat[0][1];
+ assertEquals(freeOptName, optCat.getName());
+ try {
+ // We get the option categories and options from the tool itself, but the
+ // tool reference will have a set of 0 to n option references that contain
+ // overridden settings. In this case, the string is inheritted and should
+ // not be reference
+ assertEquals(IOption.STRING, optCat.getValueType());
+ IOption stringOpt = toolRef.getOptionById(optCat.getId());
+ assertTrue(stringOpt instanceof Option);
+ assertEquals(freeOptValue, stringOpt.getStringValue());
+ } catch (BuildException e1) {
+ fail("Failed getting string value in subsub :" + e1.getLocalizedMessage());
+ }
+
+ // Do the same for the options in the child cat
+ Object[][] optsInSubCat = subCategories[0].getOptions(configs[0]);
+ for (i=0; i<optsInSubCat.length; i++)
+ if (optsInSubCat[i][0] == null) break;
+ assertEquals(1, i);
+ IOption booleanRef = toolRef.getOptionById(((IOption)optsInSubCat[0][1]).getId());
+ assertEquals(chainedOptName, booleanRef.getName());
+ try {
+ assertEquals(IOption.BOOLEAN, booleanRef.getValueType());
+ assertTrue(booleanRef.getBooleanValue());
+ } catch (BuildException e) {
+ fail("Failure getting boolean value in subsub: " + e.getLocalizedMessage());
+ }
+
+ // Test that the tool command can be changed through the reference
+ toolRef.setToolCommand(newCmd);
+ assertEquals(toolRef.getToolCommand(), newCmd);
+
+ // Muck about with the options in the local config
+ IConfiguration subSubConfig = projType.getConfiguration("sub.sub.config");
+ assertNotNull(subSubConfig);
+ ITool[] configTools = subSubConfig.getTools();
+ // This tool ref is inherited from parent, so it does not belong to the config
+ ITool configToolRef = configTools[0];
+ assertNotNull(configToolRef);
+ optCat = (IOption)optsInCat[0][1];
+ IOption configStringOpt = configToolRef.getOptionById(optCat.getId());
+ assertNotNull(configStringOpt);
+ // Override the string option
+ try {
+ subSubConfig.setOption(configToolRef, configStringOpt, stringOverride);
+ } catch (BuildException e) {
+ fail("Failure setting string value in subsubconfiguration: " + e.getLocalizedMessage());
+ }
+ // Now the config should have a tool ref to the independent tool
+ configTools = subSubConfig.getTools();
+ configToolRef = configTools[0];
+ assertNotNull(configToolRef);
+
+ // Test that the string option is overridden in the configuration
+ optsInCat = categories[0].getOptions(configs[0]);
+ for (i=0; i<optsInCat.length; i++)
+ if (optsInCat[i][0] == null) break;
+ assertEquals(1, i);
+ optCat = (IOption)optsInCat[0][1];
+ assertEquals(freeOptName, optCat.getName());
+ configStringOpt = configToolRef.getOptionById(optCat.getId());
+ try {
+ assertEquals(stringOverride, configStringOpt.getStringValue());
+ } catch (BuildException e) {
+ fail("Failure getting string value in subsubconfiguration: " + e.getLocalizedMessage());
+ }
+ // The tool should also contain the boolean option set to true
+ IOption optSubCat = (IOption)optsInSubCat[0][1];
+ IOption configBoolOpt = configToolRef.getOptionById(optSubCat.getId());
+ assertNotNull(configBoolOpt);
+ try {
+ assertTrue(configBoolOpt.getBooleanValue());
+ } catch (BuildException e) {
+ fail("Failure getting boolean value in subsubconfiguration: " + e.getLocalizedMessage());
+ }
+
+ // Override it in config and retest
+ try {
+ subSubConfig.setOption(configToolRef, configBoolOpt, false);
+ } catch (BuildException e) {
+ fail("Failure setting boolean value in subsubconfiguration: " + e.getLocalizedMessage());
+ }
+ optsInSubCat = subCategories[0].getOptions(configs[0]);
+ for (i=0; i<optsInSubCat.length; i++)
+ if (optsInSubCat[i][0] == null) break;
+ assertEquals(1, i);
+ configBoolOpt = configToolRef.getOptionById(((IOption)optsInSubCat[0][1]).getId());
+ assertEquals(chainedOptName, booleanRef.getName());
+ try {
+ assertFalse(configBoolOpt.getBooleanValue());
+ } catch (BuildException e) {
+ fail("Failure getting boolean value in subsubconfiguration: " + e.getLocalizedMessage());
+ }
+ }
+
+ /*
+ * Do a sanity check on the values in the sub-project type. Most of the
+ * sanity on the how build model entries are read is performed in
+ * the root project type check, so these tests just verify that the the sub
+ * project type properly inherits from its parent. For the new options
+ * in the sub project type, the test does a sanity check just to be complete.
+ */
+ private void checkSubProjectType(IProjectType projType) throws BuildException {
+ final String expectedFlags = "-I/usr/include -I/opt/gnome/include -IC:\\home\\tester/include -I\"../includes\" x y z";
+
+ IConfiguration[] configs = projType.getConfigurations();
+ // Check the overridden clean command
+ assertEquals("rm -yourworld", configs[0].getCleanCommand());
+ // Make sure the projType inherits the make command
+ assertEquals("make", configs[0].getBuildCommand());
+ // Make sure the binary parser is hard-coded and available
+ IToolChain toolChain = configs[0].getToolChain();
+ ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
+ // Make the test work as before after introducing multiple binary parsers
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals("org.eclipse.cdt.core.PE", binaryParsers[0]);
+ String[] expectedOSList = {"win32","linux","solaris"};
+ assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList()));
+ // Make sure the list is overridden
+ String[] expectedArchList = {"x86", "ppc"};
+ assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList()));
+
+ // Make sure this is a test projType
+ assertTrue(projType.isTestProjectType());
+ // Make sure the build artifact extension is there
+ assertEquals(configs[0].getArtifactExtension(), subExt);
+
+ // Get the tools for this projType
+ ITool[] tools = configs[0].getTools();
+ // Do we inherit properly from parent
+ ITool rootTool = tools[0];
+ assertEquals("Root Tool", rootTool.getName());
+ // Now get the tool defined for this projType
+ ITool subTool = tools[1];
+ assertEquals("Sub Tool", subTool.getName());
+ // Confirm that it has four options
+ IOption[] subOpts = subTool.getOptions();
+ assertEquals(5, subOpts.length);
+ assertEquals("", subTool.getOutputFlag());
+ assertTrue(subTool.buildsFileType("yarf"));
+ assertTrue(subTool.producesFileType("bus"));
+ assertEquals("", subTool.getToolCommand());
+ assertEquals("lib", subTool.getOutputPrefix());
+ assertTrue(subTool.isHeaderFile("arf"));
+ assertTrue(subTool.isHeaderFile("barf"));
+ assertEquals(ITool.FILTER_BOTH, subTool.getNatureFilter());
+
+ // Do a sanity check on the options
+ assertEquals("Include Paths", subOpts[0].getName());
+ assertEquals(IOption.INCLUDE_PATH, subOpts[0].getValueType());
+ String[] incPath = subOpts[0].getIncludePaths();
+ assertEquals(2, incPath.length);
+ assertEquals("/usr/include", incPath[0]);
+ assertEquals("/opt/gnome/include", incPath[1]);
+ String[] builtInPaths = subOpts[0].getBuiltIns();
+ assertEquals(1, builtInPaths.length);
+ assertEquals("/usr/gnu/include", builtInPaths[0]);
+ assertEquals("-I", subOpts[0].getCommand());
+ assertEquals(IOption.BROWSE_DIR, subOpts[0].getBrowseType());
+
+ // There are no user-defined preprocessor symbols
+ assertEquals("Defined Symbols", subOpts[1].getName());
+ assertEquals(IOption.PREPROCESSOR_SYMBOLS, subOpts[1].getValueType());
+ String[] defdSymbols = subOpts[1].getDefinedSymbols();
+ assertEquals(0, defdSymbols.length);
+ assertEquals("-D", subOpts[1].getCommand());
+ // But there is a builtin
+ String[] builtInSymbols = subOpts[1].getBuiltIns();
+ assertEquals(1, builtInSymbols.length);
+ assertEquals("BUILTIN", builtInSymbols[0]);
+ // Broswe type should be none
+ assertEquals(IOption.BROWSE_NONE, subOpts[1].getBrowseType());
+
+ assertEquals("More Includes", subOpts[2].getName());
+ assertEquals(IOption.INCLUDE_PATH, subOpts[2].getValueType());
+ String[] moreIncPath = subOpts[2].getIncludePaths();
+ assertEquals(2, moreIncPath.length);
+ assertEquals("C:\\home\\tester/include", moreIncPath[0]);
+ assertEquals("-I", subOpts[2].getCommand());
+ assertEquals(IOption.BROWSE_DIR, subOpts[2].getBrowseType());
+
+ // Check the user object option
+ assertEquals("User Objects", subOpts[3].getName());
+ assertEquals(IOption.OBJECTS, subOpts[3].getValueType());
+ String[] objs = subOpts[3].getUserObjects();
+ assertEquals(2, objs.length);
+ assertEquals("obj1.o", objs[0]);
+ assertEquals("obj2.o", objs[1]);
+ assertEquals(IOption.BROWSE_FILE, subOpts[3].getBrowseType());
+ assertEquals("", subOpts[3].getCommand());
+
+ // There should be a string list with no command
+ assertEquals("No Command StringList", subOpts[4].getName());
+ assertEquals(IOption.STRING_LIST, subOpts[4].getValueType());
+
+ // Make sure the tool flags look right
+ assertEquals(subTool.getToolFlags(), expectedFlags);
+
+ // Get the configs for this projType; it should inherit all the configs defined for the parent
+ assertEquals(4, configs.length);
+ assertEquals("Sub Config", configs[0].getName());
+ assertEquals("Root Config", configs[1].getName());
+ assertEquals("Root Override Config", configs[2].getName());
+ assertEquals("Complete Override Config", configs[3].getName());
+ }
+
+ private void checkForwardProjectTypes(IProjectType parent, IProjectType child, IProjectType grandchild) {
+ // check that the projType parent reference has been resolved.
+ assertEquals(parent, child.getSuperClass());
+ assertEquals(child, grandchild.getSuperClass());
+
+ // get the parent tool
+ IConfiguration[] parentConfigs = parent.getConfigurations();
+ ITool[] parentTools = parentConfigs[0].getTools();
+ assertEquals(1, parentTools.length);
+ ITool parentTool = parentTools[0];
+ assertNotNull(parentTool);
+
+ // check option categories
+ IOption option = parentTool.getOptionById("test.forward.option");
+ assertNotNull(option);
+ IOptionCategory[] firstLevel = parentTool.getTopOptionCategory()
+ .getChildCategories();
+ assertEquals(1, firstLevel.length);
+ IOptionCategory[] secondLevel = firstLevel[0].getChildCategories();
+ assertEquals(1, secondLevel.length);
+ assertEquals(0, secondLevel[0].getChildCategories().length);
+ Object[][] optList = secondLevel[0].getOptions(parentConfigs[0]);
+ int i;
+ for (i=0; i<optList.length; i++)
+ if (optList[i][0] == null) break;
+ assertEquals(1, i);
+ assertEquals(option, optList[0][1]);
+
+ // get the tool reference from the child
+ IConfiguration[] childConfigs = child.getConfigurations();
+ ITool[] childTools = childConfigs[0].getTools();
+ assertEquals(1, childTools.length);
+ ITool childToolRef = childTools[0];
+ assertEquals(parentTool.getSuperClass(), childToolRef.getSuperClass());
+
+ // get and check the option reference
+ IOption optRef = childToolRef.getOptionById("test.forward.option");
+ assertEquals(option, optRef);
+
+ // get the tool reference from the grandchild
+ IConfiguration[] grandConfigs = grandchild.getConfigurations();
+ ITool[] grandTools = grandConfigs[0].getTools();
+ assertEquals(1, grandTools.length);
+ ITool grandToolRef = grandTools[0];
+ assertEquals(parentTool.getSuperClass(), grandToolRef.getSuperClass());
+
+ }
+
+ public void checkProviderProjectType(IProjectType projType) throws Exception {
+ Properties props = new Properties();
+ props.load(getClass().getResourceAsStream("test_commands"));
+
+ // check that this projType is in the file
+ String command = props.getProperty(projType.getId());
+ assertNotNull(command);
+
+ IProjectType parent = projType.getSuperClass();
+ assertNotNull(parent);
+ assertEquals("test.forward.parent.target", parent.getId());
+
+ IConfiguration[] configs = projType.getConfigurations();
+ ITool toolRef = configs[0].getFilteredTools()[0];
+ assertEquals(command, toolRef.getToolCommand());
+ }
+
+ /**
+ * Remove all the project information associated with the project used during test.
+ */
+ public void cleanup() {
+ removeProject(projectName);
+ removeProject(projectName2);
+ }
+
+ /* (non-Javadoc)
+ * Create a new project named <code>name</code> 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
+ */
+ private 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 <code>IProject</code> with the name specified in the argument from the
+ * receiver's workspace.
+ *
+ * @param name
+ */
+ private 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) {
+ assertTrue(false);
+ }
+ }
+ }
+ }
+ /**
+ * @throws CoreException
+ * @throws BuildException
+ */
+ public void testErrorParsers() throws BuildException {
+ // Create new project
+ IProject project = null;
+ try {
+ project = createProject(projectName2);
+ // Now associate the builder with the project
+ addManagedBuildNature(project);
+ IProjectDescription description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+ } catch (CoreException e) {
+ fail("Test failed on error parser project creation: " + e.getLocalizedMessage());
+ }
+
+ // Find the base project Type definition
+ IProjectType projType = ManagedBuildManager.getProjectType("test.error.parsers");
+ assertNotNull(projType);
+
+ // Create the target for our project that builds a dummy executable
+ IManagedProject newProj = ManagedBuildManager.createManagedProject(project, projType);
+ assertEquals(newProj.getName(), projType.getName());
+ ManagedBuildManager.setNewProjectVersion(project);
+
+ // Initialize the path entry container
+ IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project);
+ if (initResult.getCode() != IStatus.OK) {
+ fail("Initializing build information failed for: " + project.getName() + " because: " + initResult.getMessage());
+ }
+
+ // Copy over the configs
+ IConfiguration[] baseConfigs = projType.getConfigurations();
+ for (int i = 0; i < baseConfigs.length; ++i) {
+ newProj.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
+ }
+
+ // Test this out
+ checkErrorParsersProject(newProj);
+
+ // Save, close, reopen and test again
+ ManagedBuildManager.saveBuildInfo(project, true);
+ ManagedBuildManager.removeBuildInfo(project);
+ try {
+ project.close(null);
+ } catch (CoreException e) {
+ fail("Failed on error parser project close: " + e.getLocalizedMessage());
+ }
+ try {
+ project.open(null);
+ } catch (CoreException e) {
+ fail("Failed on error parser project open: " + e.getLocalizedMessage());
+ }
+
+ // Test that the default config was remembered
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+
+ // Check the rest of the default information
+ checkErrorParsersProject(info.getManagedProject());
+ ManagedBuildManager.removeBuildInfo(project);
+ }
+
+ /*
+ * Do a sanity check on the error parsers target.
+ */
+ private void checkErrorParsersProject(IManagedProject proj) throws BuildException {
+ // Target stuff
+ String expectedBinParserId = "org.eclipse.cdt.core.PE";
+ IConfiguration[] configs = proj.getConfigurations();
+ IToolChain toolChain = configs[0].getToolChain();
+ ITargetPlatform targetPlatform = toolChain.getTargetPlatform();
+ // Make the test work as before after introducing multiple binary parsers
+ String[] binaryParsers = targetPlatform.getBinaryParserList();
+ assertEquals(binaryParsers.length, 1);
+ assertEquals(binaryParsers[0], expectedBinParserId);
+ // This target defines errors parsers. Check that the error parsers
+ // have been assigned.
+ assertEquals("org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser", configs[0].getErrorParserIds());
+
+ // Tool
+ ITool[] tools = configs[0].getTools();
+ ITool rootTool = tools[0];
+ assertEquals(1, tools.length);
+ assertEquals("EP Tool", tools[0].getName());
+ assertEquals("-o", tools[0].getOutputFlag());
+ assertTrue(tools[0].buildsFileType("y"));
+ assertTrue(tools[0].buildsFileType("x"));
+ assertTrue(tools[0].producesFileType("xy"));
+ assertEquals("EP", tools[0].getToolCommand());
+ assertEquals(ITool.FILTER_C, rootTool.getNatureFilter());
+
+ // There should be one defined configs
+ assertEquals(1, configs.length);
+ }
+
+ /**
+ * Test that the build artifact of a <code>ITarget</code> can be modified
+ * programmatically.
+ */
+ public void testConfigBuildArtifact () throws CoreException {
+ // Open the test project
+ IProject project = createProject(projectName);
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ assertNotNull(info);
+ IManagedProject managedProj = info.getManagedProject();
+ assertNotNull(managedProj);
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ assertNotNull(defaultConfig);
+
+ // Set the build artifact of the configuration
+ String ext = defaultConfig.getArtifactExtension();
+ String name = project.getName() + "." + ext;
+ defaultConfig.setArtifactName(name);
+
+ // Save, close, reopen and test again
+ ManagedBuildManager.saveBuildInfo(project, false);
+ ManagedBuildManager.removeBuildInfo(project);
+ project.close(null);
+ project.open(null);
+
+ // Check the artifact name
+ info = ManagedBuildManager.getBuildInfo(project);
+ assertNotNull(info);
+ managedProj = info.getManagedProject();
+ assertNotNull(managedProj);
+ defaultConfig = info.getDefaultConfiguration();
+ assertNotNull(defaultConfig);
+ assertEquals(name, defaultConfig.getArtifactName());
+ }
+
+ public void testThatAlwaysFails() {
+ assertTrue(false);
+ }
+
+ public void testBug43450 () throws Exception{
+ IProject project = createProject( projectName );
+
+ IFolder folder = project.getProject().getFolder( "includes" );
+ if( !folder.exists() ){
+ folder.create( false, true, null );
+ }
+
+ IFile file = project.getProject().getFile( "includes/header.h" );
+ if( !file.exists() ){
+ file.create( new ByteArrayInputStream( "class A { public : static int i; };".getBytes() ), false, null );
+ }
+
+ IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
+ IScannerInfo info = provider.getScannerInformation( project );
+ ISourceElementRequestor callback = new NullSourceElementRequestor();
+
+ IScanner scanner = ParserFactory.createScanner( new CodeReader( "#include <header.h>\n int A::i = 1;".toCharArray() ),
+ info, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback, new NullLogService(), null);
+
+ IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, null );
+ assertTrue( parser.parse() );
+ }
+
+}
+
Index: D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
===================================================================
--- D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml (revision 13)
+++ D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml (working copy)
@@ -1,1690 +1,1690 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.cdt.managedbuilder.core.tests"
- name="Tests"
- version="2.1.1"
- provider-name="Eclipse.org"
- class="org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin">
-
- <requires>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.junit"/>
- <import plugin="org.eclipse.cdt.managedbuilder.core"/>
- <import plugin="org.eclipse.cdt.core"/>
- <import plugin="org.eclipse.cdt.make.core"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.ui.ide"/>
- </requires>
-
-<!-- Managed Make Builder Tool Specifications - CDT 2.0 format -->
-
- <extension
- id="buildTest"
- name="Tools for Build Test"
- point="org.eclipse.cdt.managedbuilder.core.ManagedBuildInfo">
- <tool
- natureFilter="both"
- name="Target Independent Tool"
- sources="rc"
- headerExtensions="h"
- outputFlag="/fo"
- command="RC.EXE"
- outputs="free"
- id="target.independent.tool">
- <optionCategory
- owner="target.independent.tool"
- name="Free"
- id="indy.cat.free">
- </optionCategory>
- <option
- defaultValue="Live free or die"
- name="String in Free"
- category="indy.cat.free"
- valueType="string"
- id="indy.cat.free.string">
- </option>
- <optionCategory
- owner="indy.cat.free"
- name="Chained"
- id="indy.cat.chained">
- </optionCategory>
- <option
- defaultValue="false"
- name="Boolean in Chained"
- category="indy.cat.chained"
- valueType="boolean"
- id="indy.cat.chained.boolean">
- </option>
- </tool>
- <target
- name="Test Root"
- id="test.root"
- cleanCommand="del /myworld"
- isTest="true"
- defaultExtension="toor"
- isAbstract="false"
- makeCommand="make"
- binaryParser="org.eclipse.cdt.core.PE"
- makeArguments="-k"
- osList="win32">
- <tool
- natureFilter="cnature"
- sources="foo,bar"
- name="Root Tool"
- headerExtensions="baz"
- outputFlag="-r"
- outputs="toor"
- command="doIt"
- id="root.tool">
- <optionCategory
- owner="root.tool"
- name="Category"
- id="category">
- </optionCategory>
- <option
- name="List Option in Top"
- command="-L"
- valueType="stringList"
- id="list.option">
- <listOptionValue
- value="a">
- </listOptionValue>
- <listOptionValue
- value="b"
- builtIn="false">
- </listOptionValue>
- <listOptionValue
- value="c"
- builtIn="true">
- </listOptionValue>
- </option>
- <option
- defaultValue="false"
- name="Boolean Option in Top"
- command="-b"
- valueType="boolean"
- id="boolean.option">
- </option>
- <option
- defaultValue="x"
- name="String Option in Category"
- category="category"
- valueType="string"
- id="string.option">
- </option>
- <option
- defaultValue=""
- name="Another String Option in Category"
- category="category"
- command="-str"
- id="another.string.option"
- valueType="string">
- </option>
- <option
- name="Enumerated Option in Category"
- category="category"
- valueType="enumerated"
- id="enumerated.option">
- <enumeratedOptionValue
- name="Default Enum"
- isDefault="true"
- command="-e1"
- id="default.enum.option">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Another Enum"
- command="-e2"
- id="another.enum.option">
- </enumeratedOptionValue>
- </option>
- <option
- commandFalse="-nob"
- name="Boolean Option in Category"
- category="category"
- id="boolean.false.option"
- valueType="boolean">
- </option>
- </tool>
- <configuration
- name="Root Config"
- id="root.config">
- </configuration>
- <configuration
- name="Root Override Config"
- id="root.override.config">
- <toolReference
- id="root.tool">
- <optionReference
- defaultValue="y"
- id="string.option">
- </optionReference>
- <optionReference
- defaultValue="true"
- id="boolean.option">
- </optionReference>
- </toolReference>
- </configuration>
- <configuration
- name="Complete Override Config"
- id="complete.override.config">
- <toolReference
- id="root.tool">
- <optionReference
- defaultValue="overridden"
- id="string.option">
- </optionReference>
- <optionReference
- defaultValue="alsooverridden"
- id="another.string.option">
- </optionReference>
- <optionReference
- defaultValue="true"
- id="boolean.option">
- </optionReference>
- <optionReference
- defaultValue="true"
- id="boolean.false.option">
- </optionReference>
- <optionReference
- defaultValue="another.enum.option"
- id="enumerated.option">
- </optionReference>
- <optionReference
- id="list.option">
- <listOptionValue
- value="d">
- </listOptionValue>
- <listOptionValue
- value="e">
- </listOptionValue>
- <listOptionValue
- value="f">
- </listOptionValue>
- </optionReference>
- </toolReference>
- </configuration>
- </target>
- <target
- name="Test Sub"
- id="test.sub"
- cleanCommand="rm -yourworld"
- isTest="true"
- defaultExtension="bus"
- isAbstract="false"
- binaryParser="org.eclipse.cdt.core.PE"
- archList="x86,ppc"
- parent="test.root"
- makeArguments="-d"
- osList="win32,linux,solaris">
- <configuration
- name="Sub Config"
- id="sub.config">
- </configuration>
- <tool
- natureFilter="both"
- sources="yarf"
- name="Sub Tool"
- headerExtensions="arf,barf"
- outputs="bus"
- outputPrefix="lib"
- id="tool.sub">
- <option
- name="Include Paths"
- command="-I"
- browseType="directory"
- valueType="includePath"
- id="sub.tool.opt.inc.paths">
- <listOptionValue
- value="/usr/include">
- </listOptionValue>
- <listOptionValue
- value="/opt/gnome/include">
- </listOptionValue>
- <listOptionValue
- value="/usr/gnu/include"
- builtIn="true">
- </listOptionValue>
- </option>
- <option
- name="Defined Symbols"
- command="-D"
- valueType="definedSymbols"
- id="sub.tool.opt.def.symbols">
- <listOptionValue
- value="BUILTIN"
- builtIn="true">
- </listOptionValue>
- </option>
- <option
- name="More Includes"
- command="-I"
- browseType="directory"
- valueType="includePath"
- id="sub.tool.opts.inc.paths.more">
- <listOptionValue
- value="C:\home\tester/include"
- builtIn="false">
- </listOptionValue>
- <listOptionValue
- value=""../includes""
- builtIn="false">
- </listOptionValue>
- </option>
- <option
- name="User Objects"
- browseType="file"
- valueType="userObjs"
- id="sub.tool.opt.objs">
- <listOptionValue
- value="obj1.o"
- builtIn="false">
- </listOptionValue>
- <listOptionValue
- value="obj2.o"
- builtIn="false">
- </listOptionValue>
- </option>
- <option
- valueType="stringList"
- name="No Command StringList"
- id="sub.tool.string.list">
- <listOptionValue value="x"/>
- <listOptionValue value="y"/>
- <listOptionValue value="z"/>
- </option>
- </tool>
- </target>
- <target
- isTest="true"
- name="Test Sub Sub"
- parent="test.sub"
- binaryParser="org.eclipse.cdt.core.ELF"
- defaultExtension="tss"
- makeCommand="nmake"
- id="test.sub.sub">
- <toolReference
- id="target.independent.tool">
- <optionReference
- defaultValue="true"
- id="indy.cat.chained.boolean"/>
- </toolReference>
- <configuration
- name="Sub Sub Config"
- id="sub.sub.config"/>
- </target>
- <dynamicElementProvider
- name="Test Target Provider"
- class="org.eclipse.cdt.managedbuild.core.tests.TestManagedConfigProvider">
- </dynamicElementProvider>
- <target
- isTest="true"
- name="Forward Grandchild"
- parent="test.forward.child.target"
- binaryParser="org.eclipse.cdt.core.tests.target1"
- id="test.forward.grandchild.target">
- <toolReference
- command="newcommand"
- id="test.forward.tool">
- </toolReference>
- </target>
- <target
- isTest="true"
- osList="win32,solaris,linux"
- name="Forward Child"
- binaryParser="org.eclipse.cdt.core.tests.target2"
- parent="test.forward.parent.target"
- id="test.forward.child.target">
- <toolReference
- id="test.forward.tool">
- <optionReference
- id="test.forward.option">
- </optionReference>
- </toolReference>
- </target>
- <target
- isTest="true"
- name="Forward Parent"
- binaryParser="org.eclipse.cdt.core.tests.target3"
- id="test.forward.parent.target">
- <tool
- natureFilter="both"
- name="Forward Parent Tool"
- id="test.forward.tool">
- <option
- name="Test Forward Option"
- category="test.forward.child.category"
- valueType="boolean"
- id="test.forward.option">
- </option>
- <optionCategory
- owner="test.forward.parent.category"
- name="Forward Child Category"
- id="test.forward.child.category">
- </optionCategory>
- <optionCategory
- owner="test.forward.tool"
- name="Forward Parent Category"
- id="test.forward.parent.category">
- </optionCategory>
- </tool>
- <configuration
- name="Who Cares"
- id="test.forward.parent.config">
- <toolReference
- id="test.forward.tool"/>
- </configuration>
- </target>
- <target
- isTest="true"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser"
- name="Test Error Parsers"
- binaryParser="org.eclipse.cdt.core.PE"
- isAbstract="false"
- id="test.error.parsers">
- <tool
- natureFilter="cnature"
- sources="x,y"
- name="EP Tool"
- outputFlag="-o"
- outputs="xy"
- command="EP"
- id="error.parsers.tool">
- </tool>
- <configuration
- name="EP Config"
- id="ep.config"/>
- </target>
- </extension>
-
-<!-- Managed Make Builder Tool Specifications - CDT 2.1 format -->
- <extension
- id="build.test.2.1"
- name="Managed Build Tools Test Description"
- point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
- <managedBuildRevision
- fileVersion="2.1.0">
- </managedBuildRevision>
- <tool
- natureFilter="cnature"
- sources="o"
- outputs=""
- name="linker.gnu.c"
- outputFlag="-o"
- command="gcc"
- dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
- id="cdt.managedbuild.tool.testgnu.c.linker">
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.linker"
- name="General"
- id="testgnu.c.link.category.general">
- </optionCategory>
- <option
- defaultValue="false"
- name="Posix.Linker.NoStartFiles"
- category="testgnu.c.link.category.general"
- command="-nostartfiles"
- id="testgnu.c.link.option.nostart"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Linker.NoDefLibs"
- category="testgnu.c.link.category.general"
- command="-nodefaultlibs"
- id="testgnu.c.link.option.nodeflibs"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Linker.NoStdLibs"
- category="testgnu.c.link.category.general"
- command="-nostdlib"
- id="testgnu.c.link.option.nostdlibs"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Linker.Strip"
- category="testgnu.c.link.category.general"
- command="--strip-all"
- id="testgnu.c.link.option.strip"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Linker.Static"
- category="testgnu.c.link.category.general"
- command="-static"
- id="testgnu.c.link.option.noshared"
- valueType="boolean">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.linker"
- name="Libs"
- id="testgnu.c.link.category.libs">
- </optionCategory>
- <option
- name="Posix.Libs"
- category="testgnu.c.link.category.libs"
- command="-l"
- id="testgnu.c.link.option.libs"
- browseType="file"
- valueType="libs">
- </option>
- <option
- name="Posix.Libsearch"
- category="testgnu.c.link.category.libs"
- command="-L"
- id="testgnu.c.link.option.paths"
- browseType="directory"
- valueType="stringList">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.linker"
- name="Misc"
- id="testgnu.c.link.category.other">
- </optionCategory>
- <option
- name="Posix.Linker.Flags"
- category="testgnu.c.link.category.other"
- valueType="string"
- id="testgnu.c.link.option.ldflags">
- </option>
- <option
- name="Posix.Linker.XLinker"
- category="testgnu.c.link.category.other"
- command="-Xlinker,"
- valueType="stringList"
- id="testgnu.c.link.option.other">
- </option>
- <option
- name="Posix.UserObjs"
- category="testgnu.c.link.category.other"
- browseType="file"
- valueType="userObjs"
- id="testgnu.c.link.option.userobjs">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.linker"
- name="Shared.Settings"
- id="testgnu.c.link.category.shared">
- </optionCategory>
- <option
- defaultValue="false"
- name="Posix.Linker.Shared"
- category="testgnu.c.link.category.shared"
- command="-shared"
- id="testgnu.c.link.option.shared"
- valueType="boolean">
- </option>
- <option
- name="Posix.Linker.SOName"
- category="testgnu.c.link.category.shared"
- command="-Wl,-soname="
- id="testgnu.c.link.option.soname"
- valueType="string">
- </option>
- <option
- name="Posix.Linker.Implib"
- category="testgnu.c.link.category.shared"
- command="-Wl,--out-implib="
- id="testgnu.c.link.option.implname"
- valueType="string">
- </option>
- <option
- name="Posix.Linker.Defname"
- category="testgnu.c.link.category.shared"
- command="-Wl,--output-def="
- id="testgnu.c.link.option.defname"
- valueType="string">
- </option>
- </tool>
- <tool
- natureFilter="ccnature"
- sources="o"
- outputs=""
- name="linker.gnu.cpp"
- outputFlag="-o"
- command="g++"
- dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
- id="cdt.managedbuild.tool.testgnu.cpp.linker">
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.linker"
- name="General"
- id="testgnu.cpp.link.category.options">
- </optionCategory>
- <option
- defaultValue="false"
- name="Posix.Linker.NoStartFiles"
- category="testgnu.cpp.link.category.options"
- command="-nostartfiles"
- id="testgnu.cpp.link.option.nostart"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Linker.NoDefLibs"
- category="testgnu.cpp.link.category.options"
- command="-nodefaultlibs"
- id="testgnu.cpp.link.option.nodeflibs"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Linker.NoStdLibs"
- category="testgnu.cpp.link.category.options"
- command="-nostdlib"
- id="testgnu.cpp.link.option.nostdlibs"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Linker.Strip"
- category="testgnu.cpp.link.category.options"
- command="--strip-all"
- id="testgnu.cpp.link.option.strip"
- valueType="boolean">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.linker"
- name="Libs"
- id="testgnu.cpp.link.category.libs">
- </optionCategory>
- <option
- name="Posix.Libs"
- category="testgnu.cpp.link.category.libs"
- command="-l"
- id="testgnu.cpp.link.option.libs"
- browseType="file"
- valueType="libs">
- </option>
- <option
- name="Posix.Libsearch"
- category="testgnu.cpp.link.category.libs"
- command="-L"
- id="testgnu.cpp.link.option.paths"
- browseType="directory"
- valueType="stringList">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.linker"
- name="Misc"
- id="testgnu.cpp.link.category.other">
- </optionCategory>
- <option
- name="Posix.Linker.Flags"
- category="testgnu.cpp.link.category.other"
- valueType="string"
- id="testgnu.cpp.link.option.flags">
- </option>
- <option
- name="Posix.Linker.XLinker"
- category="testgnu.cpp.link.category.other"
- command="-Xlinker "
- valueType="stringList"
- id="testgnu.cpp.link.option.other">
- </option>
- <option
- name="Posix.UserObjs"
- category="testgnu.cpp.link.category.other"
- browseType="file"
- valueType="userObjs"
- id="testgnu.cpp.link.option.userobjs">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.linker"
- name="Shared.Settings"
- id="testgnu.cpp.link.category.shared">
- </optionCategory>
- <option
- defaultValue="false"
- name="Posix.Linker.Shared"
- category="testgnu.cpp.link.category.shared"
- command="-shared"
- valueType="boolean"
- id="testgnu.cpp.link.option.shared">
- </option>
- <option
- name="Posix.Linker.SOName"
- category="testgnu.cpp.link.category.shared"
- command="-Wl,-soname="
- valueType="string"
- id="testgnu.cpp.link.option.soname">
- </option>
- <option
- name="Posix.Linker.Implib"
- category="testgnu.cpp.link.category.shared"
- command="-Wl,--out-implib="
- valueType="string"
- id="testgnu.cpp.link.option.implname">
- </option>
- <option
- name="Posix.Linker.Defname"
- category="testgnu.cpp.link.category.shared"
- command="-Wl,--output-def="
- valueType="string"
- id="testgnu.cpp.link.option.defname">
- </option>
- </tool>
- <tool
- natureFilter="both"
- isAbstract="true"
- sources="o"
- name="archiver.gnu"
- outputs="a"
- command="ar"
- outputPrefix="lib"
- dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
- id="cdt.managedbuild.tool.testgnu.archiver">
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.archiver"
- name="General"
- id="testgnu.lib.category.general">
- </optionCategory>
- <option
- defaultValue="-r"
- name="Posix.Archiver.Flags"
- category="testgnu.lib.category.general"
- valueType="string"
- id="testgnu.both.lib.option.flags">
- </option>
- </tool>
- <tool
- command="as"
- sources="s,S"
- outputs="o"
- name="assembler.gnu"
- outputFlag="-o"
- id="cdt.managedbuild.tool.testgnu.assembler"
- natureFilter="both">
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.assembler"
- name="General"
- id="testgnu.asm.category.general">
- </optionCategory>
- <option
- name="Gnu.Assembler.Flags"
- category="testgnu.asm.category.general"
- valueType="string"
- id="testgnu.both.asm.option.flags">
- </option>
- <option
- command="-I"
- valueType="includePath"
- category="testgnu.asm.category.general"
- browseType="directory"
- name="Posix.InclPaths"
- id="testgnu.both.asm.option.include.paths"/>
- <option
- command="-W"
- defaultValue="false"
- valueType="boolean"
- category="testgnu.asm.category.general"
- name="Gnu.Assembler.warn.suppress"
- id="testgnu.both.asm.option.warnings.nowarn"/>
- <option
- command="-v"
- defaultValue="false"
- valueType="boolean"
- category="testgnu.asm.category.general"
- name="Gnu.Assembler.version"
- id="testgnu.both.asm.option.version"/>
- </tool>
-
- <tool
- name="compiler.gnu.c"
- id="cdt.managedbuild.tool.testgnu.c.compiler"
- isAbstract="true"
- sources="c"
- command="gcc"
- dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator"
- headerExtensions="h"
- natureFilter="cnature"
- outputs="o"
- outputFlag="-o">
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.compiler"
- name="Preproc"
- id="testgnu.c.compiler.category.preprocessor">
- </optionCategory>
- <option
- defaultValue="false"
- name="Posix.Nostdinc"
- category="testgnu.c.compiler.category.preprocessor"
- command="-nostdinc"
- id="testgnu.c.compiler.option.preprocessor.nostdinc"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.PreprocOnly"
- category="testgnu.c.compiler.category.preprocessor"
- command="-E"
- id="testgnu.c.compiler.option.preprocessor.preprocess"
- valueType="boolean">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.compiler"
- name="Symbols"
- id="testgnu.c.compiler.category.symbols">
- </optionCategory>
- <option
- name="Posix.DefSym"
- category="testgnu.c.compiler.category.symbols"
- command="-D"
- id="testgnu.c.compiler.option.preprocessor.def.symbols"
- valueType="definedSymbols">
- </option>
- <option
- name="Posix.UndefSym"
- category="testgnu.c.compiler.category.symbols"
- command="-U"
- id="testgnu.c.compiler.option.preprocessor.undef.symbol"
- valueType="stringList">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.compiler"
- name="Dirs"
- id="testgnu.c.compiler.category.dirs">
- </optionCategory>
- <option
- name="Posix.InclPaths"
- category="testgnu.c.compiler.category.dirs"
- command="-I"
- id="testgnu.c.compiler.option.include.paths"
- valueType="includePath"
- browseType="directory">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.compiler"
- name="Optimize"
- id="testgnu.c.compiler.category.optimization">
- </optionCategory>
- <option
- name="Posix.OptLevel"
- category="testgnu.c.compiler.category.optimization"
- id="testgnu.c.compiler.option.optimization.level"
- valueType="enumerated">
- <enumeratedOptionValue
- name="Posix.Optimize.None"
- isDefault="false"
- command="-O0"
- id="testgnu.c.optimization.level.none">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Optimize.Optimize"
- command="-O1"
- id="testgnu.c.optimization.level.optimize">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Optimize.More"
- isDefault="true"
- command="-O2"
- id="testgnu.c.optimization.level.more">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Optimize.Most"
- command="-O3"
- id="testgnu.c.optimization.level.most">
- </enumeratedOptionValue>
- </option>
- <option
- name="Posix.Optimize.Flags"
- category="testgnu.c.compiler.category.optimization"
- id="testgnu.c.compiler.option.optimization.flags"
- valueType="string">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.compiler"
- name="Debug"
- id="testgnu.c.compiler.category.debug">
- </optionCategory>
- <option
- name="Posix.DebugLevel"
- category="testgnu.c.compiler.category.debug"
- id="testgnu.c.compiler.option.debugging.level"
- valueType="enumerated">
- <enumeratedOptionValue
- name="Posix.Debug.None"
- isDefault="false"
- id="testgnu.c.debugging.level.none">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Debug.Min"
- command="-g1"
- id="testgnu.c.debugging.level.minimal">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Debug.Def"
- isDefault="true"
- command="-g"
- id="testgnu.c.debugging.level.default">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Debug.Max"
- isDefault="false"
- command="-g3"
- id="testgnu.c.debugging.level.max">
- </enumeratedOptionValue>
- </option>
- <option
- name="Posix.Debug.Other"
- category="testgnu.c.compiler.category.debug"
- id="testgnu.c.compiler.option.debugging.other"
- valueType="string">
- </option>
- <option
- defaultValue="false"
- name="Posix.Debug.gprof"
- category="testgnu.c.compiler.category.debug"
- command="-pg"
- id="testgnu.c.compiler.option.debugging.gprof"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Debug.prof"
- category="testgnu.c.compiler.category.debug"
- command="-p"
- id="testgnu.c.compiler.option.debugging.prof"
- valueType="boolean">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.compiler"
- name="Warn"
- id="testgnu.c.compiler.category.warnings">
- </optionCategory>
- <option
- defaultValue="false"
- name="Posix.Warn.Syntax"
- category="testgnu.c.compiler.category.warnings"
- command="-fsyntax-only"
- id="testgnu.c.compiler.option.warnings.syntax"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Warn.Pedandic"
- category="testgnu.c.compiler.category.warnings"
- command="-pedantic"
- id="testgnu.c.compiler.option.warnings.pedantic"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Warn.PedErrors"
- category="testgnu.c.compiler.category.warnings"
- command="-pedantic-errors"
- id="testgnu.c.compiler.option.warnings.pedantic.error"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Warn.nowarn"
- category="testgnu.c.compiler.category.warnings"
- command="-w"
- id="testgnu.c.compiler.option.warnings.nowarn"
- valueType="boolean">
- </option>
- <option
- defaultValue="true"
- name="Posix.Warn.allwarn"
- category="testgnu.c.compiler.category.warnings"
- command="-Wall"
- id="testgnu.c.compiler.option.warnings.allwarn"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Warn.toerrs"
- category="testgnu.c.compiler.category.warnings"
- command="-Werror"
- id="testgnu.c.compiler.option.warnings.toerrors"
- valueType="boolean">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.c.compiler"
- name="Misc"
- id="testgnu.c.compiler.category.other">
- </optionCategory>
- <option
- defaultValue="-c -fmessage-length=0"
- name="OtherFlags"
- category="testgnu.c.compiler.category.other"
- id="testgnu.c.compiler.option.misc.other"
- valueType="string">
- </option>
- <option
- defaultValue="false"
- name="Posix.Verbose"
- category="testgnu.c.compiler.category.other"
- command="-v"
- id="testgnu.c.compiler.option.misc.verbose"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Ansi"
- category="testgnu.c.compiler.category.other"
- command="-ansi"
- id="testgnu.c.compiler.option.misc.ansi"
- valueType="boolean">
- </option>
- </tool>
- <tool
- name="compiler.gnu.cpp"
- id="cdt.managedbuild.tool.testgnu.cpp.compiler"
- isAbstract="true"
- sources="c,C,cc,cxx,cpp"
- command="g++"
- dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator"
- headerExtensions="h,H,hpp"
- natureFilter="ccnature"
- outputs="o"
- outputFlag="-o">
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
- name="Preproc"
- id="testgnu.cpp.compiler.category.preprocessor">
- </optionCategory>
- <option
- defaultValue="false"
- name="Posix.Nostdinc"
- category="testgnu.cpp.compiler.category.preprocessor"
- command="-nostdinc"
- id="testgnu.cpp.compiler.option.preprocessor.nostdinc"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.PreprocOnly"
- category="testgnu.cpp.compiler.category.preprocessor"
- command="-E"
- id="testgnu.cpp.compiler.option.preprocessor.preprocess"
- valueType="boolean">
- </option>
- <option
- name="Posix.DefSym"
- category="testgnu.cpp.compiler.category.preprocessor"
- command="-D"
- id="testgnu.cpp.compiler.option.preprocessor.def"
- valueType="definedSymbols">
- </option>
- <option
- name="Posix.UndefSym"
- category="testgnu.cpp.compiler.category.preprocessor"
- command="-U"
- id="testgnu.cpp.compiler.option.preprocessor.undef"
- valueType="stringList">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
- name="Dirs"
- id="testgnu.cpp.compiler.category.dirs">
- </optionCategory>
- <option
- name="Posix.InclPaths"
- category="testgnu.cpp.compiler.category.dirs"
- command="-I"
- id="testgnu.cpp.compiler.option.include.paths"
- valueType="includePath"
- browseType="directory">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
- name="Optimize"
- id="testgnu.cpp.compiler.category.optimization">
- </optionCategory>
- <option
- name="Posix.OptLevel"
- category="testgnu.cpp.compiler.category.optimization"
- id="testgnu.cpp.compiler.option.optimization.level"
- valueType="enumerated">
- <enumeratedOptionValue
- name="Posix.Optimize.None"
- command="-O0"
- id="testgnu.cpp.compiler.optimization.level.none">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Optimize.Optimize"
- command="-O1"
- id="testgnu.cpp.compiler.optimization.level.optimize">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Optimize.More"
- isDefault="true"
- command="-O2"
- id="testgnu.cpp.compiler.optimization.level.more">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Optimize.Most"
- command="-O3"
- id="testgnu.cpp.compiler.optimization.level.most">
- </enumeratedOptionValue>
- </option>
- <option
- name="Posix.Optimize.Flags"
- category="testgnu.cpp.compiler.category.optimization"
- id="testgnu.cpp.compiler.option.optimization.flags"
- valueType="string">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
- name="Debug"
- id="testgnu.cpp.compiler.category.debug">
- </optionCategory>
- <option
- name="Posix.DebugLevel"
- category="testgnu.cpp.compiler.category.debug"
- id="testgnu.cpp.compiler.option.debugging.level"
- valueType="enumerated">
- <enumeratedOptionValue
- name="Posix.Debug.None"
- isDefault="false"
- id="testgnu.cpp.compiler.debugging.level.none">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Debug.Min"
- command="-g1"
- id="testgnu.cpp.compiler.debugging.level.minimal">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Debug.Def"
- isDefault="true"
- command="-g"
- id="testgnu.cpp.compiler.debugging.level.default">
- </enumeratedOptionValue>
- <enumeratedOptionValue
- name="Posix.Debug.Max"
- isDefault="false"
- command="-g3"
- id="testgnu.cpp.compiler.debugging.level.max">
- </enumeratedOptionValue>
- </option>
- <option
- name="Posix.Debug.Other"
- category="testgnu.cpp.compiler.category.debug"
- id="testgnu.cpp.compiler.option.debugging.other"
- valueType="string">
- </option>
- <option
- defaultValue="false"
- name="Posix.Debug.prof"
- category="testgnu.cpp.compiler.category.debug"
- command="-p"
- id="testgnu.cpp.compiler.option.debugging.prof"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Debug.gprof"
- category="testgnu.cpp.compiler.category.debug"
- command="-pg"
- id="testgnu.cpp.compiler.option.debugging.gprof"
- valueType="boolean">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
- name="Warn"
- id="testgnu.cpp.compiler.category.warnings">
- </optionCategory>
- <option
- defaultValue="false"
- name="Posix.Warn.Syntax"
- category="testgnu.cpp.compiler.category.warnings"
- command="-fsyntax-only"
- id="testgnu.cpp.compiler.option.warnings.syntax"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Warn.Pedandic"
- category="testgnu.cpp.compiler.category.warnings"
- command="-pedantic"
- id="testgnu.cpp.compiler.option.warnings.pedantic"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Warn.PedErrors"
- category="testgnu.cpp.compiler.category.warnings"
- command="-pedantic-errors"
- id="testgnu.cpp.compiler.option.warnings.pedantic.error"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Warn.nowarn"
- category="testgnu.cpp.compiler.category.warnings"
- command="-w"
- id="testgnu.cpp.compiler.option.warnings.nowarn"
- valueType="boolean">
- </option>
- <option
- defaultValue="true"
- name="Posix.Warn.allwarn"
- category="testgnu.cpp.compiler.category.warnings"
- command="-Wall"
- id="testgnu.cpp.compiler.option.warnings.allwarn"
- valueType="boolean">
- </option>
- <option
- defaultValue="false"
- name="Posix.Warn.toerrs"
- category="testgnu.cpp.compiler.category.warnings"
- command="-Werror"
- id="testgnu.cpp.compiler.option.warnings.toerrors"
- valueType="boolean">
- </option>
- <optionCategory
- owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
- name="Misc"
- id="testgnu.cpp.compiler.category.other">
- </optionCategory>
- <option
- defaultValue="-c -fmessage-length=0"
- name="OtherFlags"
- category="testgnu.cpp.compiler.category.other"
- id="testgnu.cpp.compiler.option.other.other"
- valueType="string">
- </option>
- <option
- defaultValue="false"
- name="Posix.Verbose"
- category="testgnu.cpp.compiler.category.other"
- command="-v"
- id="testgnu.cpp.compiler.option.other.verbose"
- valueType="boolean">
- </option>
- </tool>
-
- <projectType
- isAbstract="false"
- isTest="true"
- name="testgnu.exe"
- id="cdt.managedbuild.target.testgnu.exe">
- <configuration
- name="Dbg"
- id="cdt.managedbuild.config.testgnu.exe.debug"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
- id="cdt.managedbuild.toolchain.testgnu.exe.debug"
- name="Dbg ToolChain"
- scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- <targetPlatform
- id="cdt.managedbuild.target.testgnu.platform.exe.debug"
- name="Dbg Platform"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- </targetPlatform>
- <builder
- id="cdt.managedbuild.target.testgnu.builder.exe.debug"
- name="Dbg Builder"
- command="make"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
- </builder>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.compiler.exe.debug"
- superClass="cdt.managedbuild.tool.testgnu.c.compiler">
- <option
- id="testgnu.c.compiler.exe.debug.option.optimization.level"
- defaultValue="testgnu.c.optimization.level.none"
- superClass="testgnu.c.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.c.compiler.exe.debug.option.debugging.level"
- defaultValue="testgnu.c.debugging.level.max"
- superClass="testgnu.c.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.compiler.exe.debug"
- superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
- <option
- id="testgnu.cpp.compiler.exe.debug.option.optimization.level"
- defaultValue="testgnu.cpp.compiler.optimization.level.none"
- superClass="testgnu.cpp.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.cpp.compiler.exe.debug.option.debugging.level"
- defaultValue="testgnu.cpp.compiler.debugging.level.max"
- superClass="testgnu.cpp.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.linker.exe.debug"
- superClass="cdt.managedbuild.tool.testgnu.c.linker">
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.linker.exe.debug"
- superClass="cdt.managedbuild.tool.testgnu.cpp.linker">
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.assembler.exe.debug"
- superClass="cdt.managedbuild.tool.testgnu.assembler">
- </tool>
- </toolChain>
- </configuration>
- <configuration
- name="Rel"
- id="cdt.managedbuild.config.testgnu.exe.release"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
- <toolChain
- id="cdt.managedbuild.toolchain.testgnu.exe.release"
- name="Rel ToolChain"
- scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- <targetPlatform
- id="cdt.managedbuild.target.testgnu.platform.exe.release"
- name="Rel Platform"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- </targetPlatform>
- <builder
- id="cdt.managedbuild.target.testgnu.builder.exe.release"
- name="Rel Builder"
- command="make"
- arguments="-k">
- </builder>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.compiler.exe.release"
- superClass="cdt.managedbuild.tool.testgnu.c.compiler">
- <option
- id="testgnu.c.compiler.exe.release.option.optimization.level"
- defaultValue="testgnu.c.optimization.level.most"
- superClass="testgnu.c.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.c.compiler.exe.release.option.debugging.level"
- defaultValue="testgnu.c.debugging.level.none"
- superClass="testgnu.c.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.compiler.exe.release"
- superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
- <option
- id="testgnu.cpp.compiler.exe.release.option.optimization.level"
- defaultValue="testgnu.cpp.compiler.optimization.level.most"
- superClass="testgnu.cpp.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.cpp.compiler.exe.release.option.debugging.level"
- defaultValue="testgnu.cpp.compiler.debugging.level.none"
- superClass="testgnu.cpp.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.linker.exe.release"
- superClass="cdt.managedbuild.tool.testgnu.c.linker">
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.linker.exe.release"
- superClass="cdt.managedbuild.tool.testgnu.cpp.linker">
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.assembler.exe.release"
- superClass="cdt.managedbuild.tool.testgnu.assembler">
- </tool>
- </toolChain>
- </configuration>
- </projectType>
-
- <projectType
- isAbstract="false"
- isTest="true"
- name="testgnu.so"
- id="cdt.managedbuild.target.testgnu.so">
- <configuration
- name="Debug"
- cleanCommand="rm -rf"
- artifactExtension="so"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
- id="cdt.managedbuild.config.testgnu.so.debug">
- <toolChain
- id="cdt.managedbuild.toolchain.testgnu.so.debug"
- name="so Debug ToolChain"
- scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- <targetPlatform
- id="cdt.managedbuild.target.testgnu.platform.so.debug"
- name="so Debug Platform"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- </targetPlatform>
- <builder
- id="cdt.managedbuild.target.testgnu.builder.so.debug"
- name="so Debug Builder"
- command="make"
- arguments="-k">
- </builder>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.compiler.so.debug"
- superClass="cdt.managedbuild.tool.testgnu.c.compiler">
- <option
- id="testgnu.c.compiler.so.debug.option.optimization.level"
- defaultValue="testgnu.c.optimization.level.none"
- superClass="testgnu.c.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.c.compiler.so.debug.option.debugging.level"
- defaultValue="testgnu.c.debugging.level.max"
- superClass="testgnu.c.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.compiler.so.debug"
- superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
- <option
- id="testgnu.cpp.compiler.so.debug.option.optimization.level"
- defaultValue="testgnu.cpp.compiler.optimization.level.none"
- superClass="testgnu.cpp.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.cpp.compiler.so.debug.option.debugging.level"
- defaultValue="testgnu.cpp.compiler.debugging.level.max"
- superClass="testgnu.cpp.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.linker.so.debug"
- outputs="so"
- outputPrefix="lib"
- superClass="cdt.managedbuild.tool.testgnu.c.linker">
- <option
- id="testgnu.c.link.so.debug.option.shared"
- defaultValue="true"
- superClass="testgnu.c.link.option.shared">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.linker.so.debug"
- outputs="so"
- outputPrefix="lib"
- superClass="cdt.managedbuild.tool.testgnu.cpp.linker">
- <option
- id="testgnu.cpp.link.so.debug.option.shared"
- defaultValue="true"
- superClass="testgnu.cpp.link.option.shared">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.assembler.so.debug"
- superClass="cdt.managedbuild.tool.testgnu.assembler">
- </tool>
- </toolChain>
- </configuration>
- <configuration
- name="Release"
- cleanCommand="rm -rf"
- artifactExtension="so"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
- id="cdt.managedbuild.config.testgnu.so.release">
- <toolChain
- id="cdt.managedbuild.toolchain.testgnu.so.release"
- name="so Release ToolChain"
- scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- <targetPlatform
- id="cdt.managedbuild.target.testgnu.platform.so.release"
- name="so Release Platform"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- </targetPlatform>
- <builder
- id="cdt.managedbuild.target.testgnu.builder.so.release"
- name="so Release Builder"
- command="make"
- arguments="-k">
- </builder>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.compiler.so.release"
- superClass="cdt.managedbuild.tool.testgnu.c.compiler">
- <option
- id="testgnu.c.compiler.so.release.option.optimization.level"
- defaultValue="testgnu.c.optimization.level.most"
- superClass="testgnu.c.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.c.compiler.so.release.option.debugging.level"
- defaultValue="testgnu.c.debugging.level.none"
- superClass="testgnu.c.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.compiler.so.release"
- superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
- <option
- id="testgnu.cpp.compiler.so.release.option.optimization.level"
- defaultValue="testgnu.cpp.compiler.optimization.level.most"
- superClass="testgnu.cpp.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.cpp.compiler.so.release.option.debugging.level"
- defaultValue="testgnu.cpp.compiler.debugging.level.none"
- superClass="testgnu.cpp.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.linker.so.release"
- outputs="so"
- outputPrefix="lib"
- superClass="cdt.managedbuild.tool.testgnu.c.linker">
- <option
- id="testgnu.c.link.so.release.option.shared"
- defaultValue="true"
- superClass="testgnu.c.link.option.shared">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.linker.so.release"
- outputs="so"
- outputPrefix="lib"
- superClass="cdt.managedbuild.tool.testgnu.cpp.linker">
- <option
- id="testgnu.cpp.link.so.release.option.shared"
- defaultValue="true"
- superClass="testgnu.cpp.link.option.shared">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.assembler.so.release"
- superClass="cdt.managedbuild.tool.testgnu.assembler">
- </tool>
- </toolChain>
- </configuration>
- </projectType>
-
- <projectType
- isTest="true"
- name="testgnu.lib"
- isAbstract="false"
- id="cdt.managedbuild.target.testgnu.lib">
- <configuration
- name="Dbg"
- artifactExtension="a"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
- id="cdt.managedbuild.config.testgnu.lib.debug">
- <toolChain
- id="cdt.managedbuild.toolchain.testgnu.lib.debug"
- name="Dbg TC"
- scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- <targetPlatform
- id="cdt.managedbuild.target.testgnu.platform.lib.debug"
- name="Dbg P"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- </targetPlatform>
- <builder
- id="cdt.managedbuild.target.testgnu.builder.lib.debug"
- name="Dbg B"
- command="make"
- arguments="-k">
- </builder>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.compiler.lib.debug"
- superClass="cdt.managedbuild.tool.testgnu.c.compiler">
- <option
- id="testgnu.c.compiler.lib.debug.option.optimization.level"
- defaultValue="testgnu.c.optimization.level.none"
- superClass="testgnu.c.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.c.compiler.lib.debug.option.debugging.level"
- defaultValue="testgnu.c.debugging.level.max"
- superClass="testgnu.c.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.compiler.lib.debug"
- superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
- <option
- id="testgnu.cpp.compiler.lib.debug.option.optimization.level"
- defaultValue="testgnu.cpp.compiler.optimization.level.none"
- superClass="testgnu.cpp.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.cpp.compiler.lib.debug.option.debugging.level"
- defaultValue="testgnu.cpp.compiler.debugging.level.max"
- superClass="testgnu.cpp.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.archiver.lib.debug"
- outputs="a"
- outputPrefix="lib"
- superClass="cdt.managedbuild.tool.testgnu.archiver">
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.assembler.lib.debug"
- superClass="cdt.managedbuild.tool.testgnu.assembler">
- </tool>
- </toolChain>
- </configuration>
- <configuration
- name="Rel"
- artifactExtension="a"
- cleanCommand="rm -rf"
- errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
- id="cdt.managedbuild.config.testgnu.lib.release">
- <toolChain
- id="cdt.managedbuild.toolchain.testgnu.lib.release"
- name="Rel TC"
- scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- <targetPlatform
- id="cdt.managedbuild.target.testgnu.platform.lib.release"
- name="Rel P"
- binaryParser="org.eclipse.cdt.core.ELF"
- osList="solaris,linux,hpux,aix,qnx"
- archList="all">
- </targetPlatform>
- <builder
- id="cdt.managedbuild.target.testgnu.builder.lib.release"
- name="Rel B"
- command="make"
- arguments="-k">
- </builder>
- <tool
- id="cdt.managedbuild.tool.testgnu.c.compiler.lib.release"
- superClass="cdt.managedbuild.tool.testgnu.c.compiler">
- <option
- id="testgnu.c.compiler.lib.release.option.optimization.level"
- defaultValue="testgnu.c.optimization.level.most"
- superClass="testgnu.c.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.c.compiler.lib.release.option.debugging.level"
- defaultValue="testgnu.c.debugging.level.none"
- superClass="testgnu.c.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.cpp.compiler.lib.release"
- superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
- <option
- id="testgnu.cpp.compiler.lib.release.option.optimization.level"
- defaultValue="testgnu.cpp.compiler.optimization.level.most"
- superClass="testgnu.cpp.compiler.option.optimization.level">
- </option>
- <option
- id="testgnu.cpp.compiler.lib.release.option.debugging.level"
- defaultValue="testgnu.cpp.compiler.debugging.level.none"
- superClass="testgnu.cpp.compiler.option.debugging.level">
- </option>
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.archiver.lib.release"
- outputs="a"
- outputPrefix="lib"
- superClass="cdt.managedbuild.tool.testgnu.archiver">
- </tool>
- <tool
- id="cdt.managedbuild.tool.testgnu.assembler.lib.release"
- superClass="cdt.managedbuild.tool.testgnu.assembler">
- </tool>
- </toolChain>
- </configuration>
- </projectType>
-
- <projectType
- isTest="true"
- name="Test Java Attributes"
- isAbstract="false"
- id="cdt.managedbuild.test.java.attrs">
- <configuration
- name="The One and Only"
- artifactName="Testme"
- artifactExtension="xyz"
- id="cdt.managedbuild.test.java.attrs.config">
- <toolChain
- id="cdt.managedbuild.test.java.attrs.toolchain"
- name="The Tool-Chain">
- <tool
- id="cdt.managedbuild.test.java.attrs.tool"
- superClass="cdt.managedbuild.tool.testgnu.c.compiler"
- commandLineGenerator="org.eclipse.cdt.managedbuild.core.tests.ManagedBuildCommandLineGenerator">
- <option
- id="testgnu.c.compiler.option.preprocessor.def.symbols.test"
- superClass="testgnu.c.compiler.option.preprocessor.def.symbols">
- <listOptionValue
- value="foo">
- </listOptionValue>
- <listOptionValue
- value="bar">
- </listOptionValue>
- </option>
- </tool>
- <builder
- id="cdt.managedbuild.test.java.attrs.builder"
- name="Test Builder"
- command="makeMe"
- arguments="-k"
- buildfileGenerator="org.eclipse.cdt.managedbuild.core.tests.BuildFileGenerator">
- </builder>
- </toolChain>
- </configuration>
- </projectType>
-
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin
+ id="org.eclipse.cdt.managedbuilder.core.tests"
+ name="Tests"
+ version="2.1.1"
+ provider-name="Eclipse.org"
+ class="org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin">
+
+ <requires>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.junit"/>
+ <import plugin="org.eclipse.cdt.managedbuilder.core"/>
+ <import plugin="org.eclipse.cdt.core"/>
+ <import plugin="org.eclipse.cdt.make.core"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.ui.ide"/>
+ </requires>
+
+<!-- Managed Make Builder Tool Specifications - CDT 2.0 format -->
+
+ <extension
+ id="buildTest"
+ name="Tools for Build Test"
+ point="org.eclipse.cdt.managedbuilder.core.ManagedBuildInfo">
+ <tool
+ natureFilter="both"
+ name="Target Independent Tool"
+ sources="rc"
+ headerExtensions="h"
+ outputFlag="/fo"
+ command="RC.EXE"
+ outputs="free"
+ id="target.independent.tool">
+ <optionCategory
+ owner="target.independent.tool"
+ name="Free"
+ id="indy.cat.free">
+ </optionCategory>
+ <option
+ defaultValue="Live free or die"
+ name="String in Free"
+ category="indy.cat.free"
+ valueType="string"
+ id="indy.cat.free.string">
+ </option>
+ <optionCategory
+ owner="indy.cat.free"
+ name="Chained"
+ id="indy.cat.chained">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Boolean in Chained"
+ category="indy.cat.chained"
+ valueType="boolean"
+ id="indy.cat.chained.boolean">
+ </option>
+ </tool>
+ <target
+ name="Test Root"
+ id="test.root"
+ cleanCommand="del /myworld"
+ isTest="true"
+ defaultExtension="toor"
+ isAbstract="false"
+ makeCommand="make"
+ binaryParser="org.eclipse.cdt.core.PE"
+ makeArguments="-k"
+ osList="win32">
+ <tool
+ natureFilter="cnature"
+ sources="foo,bar"
+ name="Root Tool"
+ headerExtensions="baz"
+ outputFlag="-r"
+ outputs="toor"
+ command="doIt"
+ id="root.tool">
+ <optionCategory
+ owner="root.tool"
+ name="Category"
+ id="category">
+ </optionCategory>
+ <option
+ name="List Option in Top"
+ command="-L"
+ valueType="stringList"
+ id="list.option">
+ <listOptionValue
+ value="a">
+ </listOptionValue>
+ <listOptionValue
+ value="b"
+ builtIn="false">
+ </listOptionValue>
+ <listOptionValue
+ value="c"
+ builtIn="true">
+ </listOptionValue>
+ </option>
+ <option
+ defaultValue="false"
+ name="Boolean Option in Top"
+ command="-b"
+ valueType="boolean"
+ id="boolean.option">
+ </option>
+ <option
+ defaultValue="x"
+ name="String Option in Category"
+ category="category"
+ valueType="string"
+ id="string.option">
+ </option>
+ <option
+ defaultValue=""
+ name="Another String Option in Category"
+ category="category"
+ command="-str"
+ id="another.string.option"
+ valueType="string">
+ </option>
+ <option
+ name="Enumerated Option in Category"
+ category="category"
+ valueType="enumerated"
+ id="enumerated.option">
+ <enumeratedOptionValue
+ name="Default Enum"
+ isDefault="true"
+ command="-e1"
+ id="default.enum.option">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Another Enum"
+ command="-e2"
+ id="another.enum.option">
+ </enumeratedOptionValue>
+ </option>
+ <option
+ commandFalse="-nob"
+ name="Boolean Option in Category"
+ category="category"
+ id="boolean.false.option"
+ valueType="boolean">
+ </option>
+ </tool>
+ <configuration
+ name="Root Config"
+ id="root.config">
+ </configuration>
+ <configuration
+ name="Root Override Config"
+ id="root.override.config">
+ <toolReference
+ id="root.tool">
+ <optionReference
+ defaultValue="y"
+ id="string.option">
+ </optionReference>
+ <optionReference
+ defaultValue="true"
+ id="boolean.option">
+ </optionReference>
+ </toolReference>
+ </configuration>
+ <configuration
+ name="Complete Override Config"
+ id="complete.override.config">
+ <toolReference
+ id="root.tool">
+ <optionReference
+ defaultValue="overridden"
+ id="string.option">
+ </optionReference>
+ <optionReference
+ defaultValue="alsooverridden"
+ id="another.string.option">
+ </optionReference>
+ <optionReference
+ defaultValue="true"
+ id="boolean.option">
+ </optionReference>
+ <optionReference
+ defaultValue="true"
+ id="boolean.false.option">
+ </optionReference>
+ <optionReference
+ defaultValue="another.enum.option"
+ id="enumerated.option">
+ </optionReference>
+ <optionReference
+ id="list.option">
+ <listOptionValue
+ value="d">
+ </listOptionValue>
+ <listOptionValue
+ value="e">
+ </listOptionValue>
+ <listOptionValue
+ value="f">
+ </listOptionValue>
+ </optionReference>
+ </toolReference>
+ </configuration>
+ </target>
+ <target
+ name="Test Sub"
+ id="test.sub"
+ cleanCommand="rm -yourworld"
+ isTest="true"
+ defaultExtension="bus"
+ isAbstract="false"
+ binaryParser="org.eclipse.cdt.core.PE"
+ archList="x86,ppc"
+ parent="test.root"
+ makeArguments="-d"
+ osList="win32,linux,solaris">
+ <configuration
+ name="Sub Config"
+ id="sub.config">
+ </configuration>
+ <tool
+ natureFilter="both"
+ sources="yarf"
+ name="Sub Tool"
+ headerExtensions="arf,barf"
+ outputs="bus"
+ outputPrefix="lib"
+ id="tool.sub">
+ <option
+ name="Include Paths"
+ command="-I"
+ browseType="directory"
+ valueType="includePath"
+ id="sub.tool.opt.inc.paths">
+ <listOptionValue
+ value="/usr/include">
+ </listOptionValue>
+ <listOptionValue
+ value="/opt/gnome/include">
+ </listOptionValue>
+ <listOptionValue
+ value="/usr/gnu/include"
+ builtIn="true">
+ </listOptionValue>
+ </option>
+ <option
+ name="Defined Symbols"
+ command="-D"
+ valueType="definedSymbols"
+ id="sub.tool.opt.def.symbols">
+ <listOptionValue
+ value="BUILTIN"
+ builtIn="true">
+ </listOptionValue>
+ </option>
+ <option
+ name="More Includes"
+ command="-I"
+ browseType="directory"
+ valueType="includePath"
+ id="sub.tool.opts.inc.paths.more">
+ <listOptionValue
+ value="C:\home\tester/include"
+ builtIn="false">
+ </listOptionValue>
+ <listOptionValue
+ value=""../includes""
+ builtIn="false">
+ </listOptionValue>
+ </option>
+ <option
+ name="User Objects"
+ browseType="file"
+ valueType="userObjs"
+ id="sub.tool.opt.objs">
+ <listOptionValue
+ value="obj1.o"
+ builtIn="false">
+ </listOptionValue>
+ <listOptionValue
+ value="obj2.o"
+ builtIn="false">
+ </listOptionValue>
+ </option>
+ <option
+ valueType="stringList"
+ name="No Command StringList"
+ id="sub.tool.string.list">
+ <listOptionValue value="x"/>
+ <listOptionValue value="y"/>
+ <listOptionValue value="z"/>
+ </option>
+ </tool>
+ </target>
+ <target
+ isTest="true"
+ name="Test Sub Sub"
+ parent="test.sub"
+ binaryParser="org.eclipse.cdt.core.ELF"
+ defaultExtension="tss"
+ makeCommand="nmake"
+ id="test.sub.sub">
+ <toolReference
+ id="target.independent.tool">
+ <optionReference
+ defaultValue="true"
+ id="indy.cat.chained.boolean"/>
+ </toolReference>
+ <configuration
+ name="Sub Sub Config"
+ id="sub.sub.config"/>
+ </target>
+ <dynamicElementProvider
+ name="Test Target Provider"
+ class="org.eclipse.cdt.managedbuild.core.tests.TestManagedConfigProvider">
+ </dynamicElementProvider>
+ <target
+ isTest="true"
+ name="Forward Grandchild"
+ parent="test.forward.child.target"
+ binaryParser="org.eclipse.cdt.core.tests.target1"
+ id="test.forward.grandchild.target">
+ <toolReference
+ command="newcommand"
+ id="test.forward.tool">
+ </toolReference>
+ </target>
+ <target
+ isTest="true"
+ osList="win32,solaris,linux"
+ name="Forward Child"
+ binaryParser="org.eclipse.cdt.core.tests.target2"
+ parent="test.forward.parent.target"
+ id="test.forward.child.target">
+ <toolReference
+ id="test.forward.tool">
+ <optionReference
+ id="test.forward.option">
+ </optionReference>
+ </toolReference>
+ </target>
+ <target
+ isTest="true"
+ name="Forward Parent"
+ binaryParser="org.eclipse.cdt.core.tests.target3"
+ id="test.forward.parent.target">
+ <tool
+ natureFilter="both"
+ name="Forward Parent Tool"
+ id="test.forward.tool">
+ <option
+ name="Test Forward Option"
+ category="test.forward.child.category"
+ valueType="boolean"
+ id="test.forward.option">
+ </option>
+ <optionCategory
+ owner="test.forward.parent.category"
+ name="Forward Child Category"
+ id="test.forward.child.category">
+ </optionCategory>
+ <optionCategory
+ owner="test.forward.tool"
+ name="Forward Parent Category"
+ id="test.forward.parent.category">
+ </optionCategory>
+ </tool>
+ <configuration
+ name="Who Cares"
+ id="test.forward.parent.config">
+ <toolReference
+ id="test.forward.tool"/>
+ </configuration>
+ </target>
+ <target
+ isTest="true"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser"
+ name="Test Error Parsers"
+ binaryParser="org.eclipse.cdt.core.PE"
+ isAbstract="false"
+ id="test.error.parsers">
+ <tool
+ natureFilter="cnature"
+ sources="x,y"
+ name="EP Tool"
+ outputFlag="-o"
+ outputs="xy"
+ command="EP"
+ id="error.parsers.tool">
+ </tool>
+ <configuration
+ name="EP Config"
+ id="ep.config"/>
+ </target>
+ </extension>
+
+<!-- Managed Make Builder Tool Specifications - CDT 2.1 format -->
+ <extension
+ id="build.test.2.1"
+ name="Managed Build Tools Test Description"
+ point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
+ <managedBuildRevision
+ fileVersion="2.1.0">
+ </managedBuildRevision>
+ <tool
+ natureFilter="cnature"
+ sources="o"
+ outputs=""
+ name="linker.gnu.c"
+ outputFlag="-o"
+ command="gcc"
+ dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
+ id="cdt.managedbuild.tool.testgnu.c.linker">
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.linker"
+ name="General"
+ id="testgnu.c.link.category.general">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.NoStartFiles"
+ category="testgnu.c.link.category.general"
+ command="-nostartfiles"
+ id="testgnu.c.link.option.nostart"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.NoDefLibs"
+ category="testgnu.c.link.category.general"
+ command="-nodefaultlibs"
+ id="testgnu.c.link.option.nodeflibs"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.NoStdLibs"
+ category="testgnu.c.link.category.general"
+ command="-nostdlib"
+ id="testgnu.c.link.option.nostdlibs"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.Strip"
+ category="testgnu.c.link.category.general"
+ command="--strip-all"
+ id="testgnu.c.link.option.strip"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.Static"
+ category="testgnu.c.link.category.general"
+ command="-static"
+ id="testgnu.c.link.option.noshared"
+ valueType="boolean">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.linker"
+ name="Libs"
+ id="testgnu.c.link.category.libs">
+ </optionCategory>
+ <option
+ name="Posix.Libs"
+ category="testgnu.c.link.category.libs"
+ command="-l"
+ id="testgnu.c.link.option.libs"
+ browseType="file"
+ valueType="libs">
+ </option>
+ <option
+ name="Posix.Libsearch"
+ category="testgnu.c.link.category.libs"
+ command="-L"
+ id="testgnu.c.link.option.paths"
+ browseType="directory"
+ valueType="stringList">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.linker"
+ name="Misc"
+ id="testgnu.c.link.category.other">
+ </optionCategory>
+ <option
+ name="Posix.Linker.Flags"
+ category="testgnu.c.link.category.other"
+ valueType="string"
+ id="testgnu.c.link.option.ldflags">
+ </option>
+ <option
+ name="Posix.Linker.XLinker"
+ category="testgnu.c.link.category.other"
+ command="-Xlinker,"
+ valueType="stringList"
+ id="testgnu.c.link.option.other">
+ </option>
+ <option
+ name="Posix.UserObjs"
+ category="testgnu.c.link.category.other"
+ browseType="file"
+ valueType="userObjs"
+ id="testgnu.c.link.option.userobjs">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.linker"
+ name="Shared.Settings"
+ id="testgnu.c.link.category.shared">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.Shared"
+ category="testgnu.c.link.category.shared"
+ command="-shared"
+ id="testgnu.c.link.option.shared"
+ valueType="boolean">
+ </option>
+ <option
+ name="Posix.Linker.SOName"
+ category="testgnu.c.link.category.shared"
+ command="-Wl,-soname="
+ id="testgnu.c.link.option.soname"
+ valueType="string">
+ </option>
+ <option
+ name="Posix.Linker.Implib"
+ category="testgnu.c.link.category.shared"
+ command="-Wl,--out-implib="
+ id="testgnu.c.link.option.implname"
+ valueType="string">
+ </option>
+ <option
+ name="Posix.Linker.Defname"
+ category="testgnu.c.link.category.shared"
+ command="-Wl,--output-def="
+ id="testgnu.c.link.option.defname"
+ valueType="string">
+ </option>
+ </tool>
+ <tool
+ natureFilter="ccnature"
+ sources="o"
+ outputs=""
+ name="linker.gnu.cpp"
+ outputFlag="-o"
+ command="g++"
+ dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
+ id="cdt.managedbuild.tool.testgnu.cpp.linker">
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.linker"
+ name="General"
+ id="testgnu.cpp.link.category.options">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.NoStartFiles"
+ category="testgnu.cpp.link.category.options"
+ command="-nostartfiles"
+ id="testgnu.cpp.link.option.nostart"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.NoDefLibs"
+ category="testgnu.cpp.link.category.options"
+ command="-nodefaultlibs"
+ id="testgnu.cpp.link.option.nodeflibs"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.NoStdLibs"
+ category="testgnu.cpp.link.category.options"
+ command="-nostdlib"
+ id="testgnu.cpp.link.option.nostdlibs"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.Strip"
+ category="testgnu.cpp.link.category.options"
+ command="--strip-all"
+ id="testgnu.cpp.link.option.strip"
+ valueType="boolean">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.linker"
+ name="Libs"
+ id="testgnu.cpp.link.category.libs">
+ </optionCategory>
+ <option
+ name="Posix.Libs"
+ category="testgnu.cpp.link.category.libs"
+ command="-l"
+ id="testgnu.cpp.link.option.libs"
+ browseType="file"
+ valueType="libs">
+ </option>
+ <option
+ name="Posix.Libsearch"
+ category="testgnu.cpp.link.category.libs"
+ command="-L"
+ id="testgnu.cpp.link.option.paths"
+ browseType="directory"
+ valueType="stringList">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.linker"
+ name="Misc"
+ id="testgnu.cpp.link.category.other">
+ </optionCategory>
+ <option
+ name="Posix.Linker.Flags"
+ category="testgnu.cpp.link.category.other"
+ valueType="string"
+ id="testgnu.cpp.link.option.flags">
+ </option>
+ <option
+ name="Posix.Linker.XLinker"
+ category="testgnu.cpp.link.category.other"
+ command="-Xlinker "
+ valueType="stringList"
+ id="testgnu.cpp.link.option.other">
+ </option>
+ <option
+ name="Posix.UserObjs"
+ category="testgnu.cpp.link.category.other"
+ browseType="file"
+ valueType="userObjs"
+ id="testgnu.cpp.link.option.userobjs">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.linker"
+ name="Shared.Settings"
+ id="testgnu.cpp.link.category.shared">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Posix.Linker.Shared"
+ category="testgnu.cpp.link.category.shared"
+ command="-shared"
+ valueType="boolean"
+ id="testgnu.cpp.link.option.shared">
+ </option>
+ <option
+ name="Posix.Linker.SOName"
+ category="testgnu.cpp.link.category.shared"
+ command="-Wl,-soname="
+ valueType="string"
+ id="testgnu.cpp.link.option.soname">
+ </option>
+ <option
+ name="Posix.Linker.Implib"
+ category="testgnu.cpp.link.category.shared"
+ command="-Wl,--out-implib="
+ valueType="string"
+ id="testgnu.cpp.link.option.implname">
+ </option>
+ <option
+ name="Posix.Linker.Defname"
+ category="testgnu.cpp.link.category.shared"
+ command="-Wl,--output-def="
+ valueType="string"
+ id="testgnu.cpp.link.option.defname">
+ </option>
+ </tool>
+ <tool
+ natureFilter="both"
+ isAbstract="true"
+ sources="o"
+ name="archiver.gnu"
+ outputs="a"
+ command="ar"
+ outputPrefix="lib"
+ dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
+ id="cdt.managedbuild.tool.testgnu.archiver">
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.archiver"
+ name="General"
+ id="testgnu.lib.category.general">
+ </optionCategory>
+ <option
+ defaultValue="-r"
+ name="Posix.Archiver.Flags"
+ category="testgnu.lib.category.general"
+ valueType="string"
+ id="testgnu.both.lib.option.flags">
+ </option>
+ </tool>
+ <tool
+ command="as"
+ sources="s,S"
+ outputs="o"
+ name="assembler.gnu"
+ outputFlag="-o"
+ id="cdt.managedbuild.tool.testgnu.assembler"
+ natureFilter="both">
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.assembler"
+ name="General"
+ id="testgnu.asm.category.general">
+ </optionCategory>
+ <option
+ name="Gnu.Assembler.Flags"
+ category="testgnu.asm.category.general"
+ valueType="string"
+ id="testgnu.both.asm.option.flags">
+ </option>
+ <option
+ command="-I"
+ valueType="includePath"
+ category="testgnu.asm.category.general"
+ browseType="directory"
+ name="Posix.InclPaths"
+ id="testgnu.both.asm.option.include.paths"/>
+ <option
+ command="-W"
+ defaultValue="false"
+ valueType="boolean"
+ category="testgnu.asm.category.general"
+ name="Gnu.Assembler.warn.suppress"
+ id="testgnu.both.asm.option.warnings.nowarn"/>
+ <option
+ command="-v"
+ defaultValue="false"
+ valueType="boolean"
+ category="testgnu.asm.category.general"
+ name="Gnu.Assembler.version"
+ id="testgnu.both.asm.option.version"/>
+ </tool>
+
+ <tool
+ name="compiler.gnu.c"
+ id="cdt.managedbuild.tool.testgnu.c.compiler"
+ isAbstract="true"
+ sources="c"
+ command="gcc"
+ dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator"
+ headerExtensions="h"
+ natureFilter="cnature"
+ outputs="o"
+ outputFlag="-o">
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.compiler"
+ name="Preproc"
+ id="testgnu.c.compiler.category.preprocessor">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Posix.Nostdinc"
+ category="testgnu.c.compiler.category.preprocessor"
+ command="-nostdinc"
+ id="testgnu.c.compiler.option.preprocessor.nostdinc"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.PreprocOnly"
+ category="testgnu.c.compiler.category.preprocessor"
+ command="-E"
+ id="testgnu.c.compiler.option.preprocessor.preprocess"
+ valueType="boolean">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.compiler"
+ name="Symbols"
+ id="testgnu.c.compiler.category.symbols">
+ </optionCategory>
+ <option
+ name="Posix.DefSym"
+ category="testgnu.c.compiler.category.symbols"
+ command="-D"
+ id="testgnu.c.compiler.option.preprocessor.def.symbols"
+ valueType="definedSymbols">
+ </option>
+ <option
+ name="Posix.UndefSym"
+ category="testgnu.c.compiler.category.symbols"
+ command="-U"
+ id="testgnu.c.compiler.option.preprocessor.undef.symbol"
+ valueType="stringList">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.compiler"
+ name="Dirs"
+ id="testgnu.c.compiler.category.dirs">
+ </optionCategory>
+ <option
+ name="Posix.InclPaths"
+ category="testgnu.c.compiler.category.dirs"
+ command="-I"
+ id="testgnu.c.compiler.option.include.paths"
+ valueType="includePath"
+ browseType="directory">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.compiler"
+ name="Optimize"
+ id="testgnu.c.compiler.category.optimization">
+ </optionCategory>
+ <option
+ name="Posix.OptLevel"
+ category="testgnu.c.compiler.category.optimization"
+ id="testgnu.c.compiler.option.optimization.level"
+ valueType="enumerated">
+ <enumeratedOptionValue
+ name="Posix.Optimize.None"
+ isDefault="false"
+ command="-O0"
+ id="testgnu.c.optimization.level.none">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Optimize.Optimize"
+ command="-O1"
+ id="testgnu.c.optimization.level.optimize">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Optimize.More"
+ isDefault="true"
+ command="-O2"
+ id="testgnu.c.optimization.level.more">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Optimize.Most"
+ command="-O3"
+ id="testgnu.c.optimization.level.most">
+ </enumeratedOptionValue>
+ </option>
+ <option
+ name="Posix.Optimize.Flags"
+ category="testgnu.c.compiler.category.optimization"
+ id="testgnu.c.compiler.option.optimization.flags"
+ valueType="string">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.compiler"
+ name="Debug"
+ id="testgnu.c.compiler.category.debug">
+ </optionCategory>
+ <option
+ name="Posix.DebugLevel"
+ category="testgnu.c.compiler.category.debug"
+ id="testgnu.c.compiler.option.debugging.level"
+ valueType="enumerated">
+ <enumeratedOptionValue
+ name="Posix.Debug.None"
+ isDefault="false"
+ id="testgnu.c.debugging.level.none">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Debug.Min"
+ command="-g1"
+ id="testgnu.c.debugging.level.minimal">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Debug.Def"
+ isDefault="true"
+ command="-g"
+ id="testgnu.c.debugging.level.default">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Debug.Max"
+ isDefault="false"
+ command="-g3"
+ id="testgnu.c.debugging.level.max">
+ </enumeratedOptionValue>
+ </option>
+ <option
+ name="Posix.Debug.Other"
+ category="testgnu.c.compiler.category.debug"
+ id="testgnu.c.compiler.option.debugging.other"
+ valueType="string">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Debug.gprof"
+ category="testgnu.c.compiler.category.debug"
+ command="-pg"
+ id="testgnu.c.compiler.option.debugging.gprof"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Debug.prof"
+ category="testgnu.c.compiler.category.debug"
+ command="-p"
+ id="testgnu.c.compiler.option.debugging.prof"
+ valueType="boolean">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.compiler"
+ name="Warn"
+ id="testgnu.c.compiler.category.warnings">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.Syntax"
+ category="testgnu.c.compiler.category.warnings"
+ command="-fsyntax-only"
+ id="testgnu.c.compiler.option.warnings.syntax"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.Pedandic"
+ category="testgnu.c.compiler.category.warnings"
+ command="-pedantic"
+ id="testgnu.c.compiler.option.warnings.pedantic"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.PedErrors"
+ category="testgnu.c.compiler.category.warnings"
+ command="-pedantic-errors"
+ id="testgnu.c.compiler.option.warnings.pedantic.error"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.nowarn"
+ category="testgnu.c.compiler.category.warnings"
+ command="-w"
+ id="testgnu.c.compiler.option.warnings.nowarn"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="true"
+ name="Posix.Warn.allwarn"
+ category="testgnu.c.compiler.category.warnings"
+ command="-Wall"
+ id="testgnu.c.compiler.option.warnings.allwarn"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.toerrs"
+ category="testgnu.c.compiler.category.warnings"
+ command="-Werror"
+ id="testgnu.c.compiler.option.warnings.toerrors"
+ valueType="boolean">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.c.compiler"
+ name="Misc"
+ id="testgnu.c.compiler.category.other">
+ </optionCategory>
+ <option
+ defaultValue="-c -fmessage-length=0"
+ name="OtherFlags"
+ category="testgnu.c.compiler.category.other"
+ id="testgnu.c.compiler.option.misc.other"
+ valueType="string">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Verbose"
+ category="testgnu.c.compiler.category.other"
+ command="-v"
+ id="testgnu.c.compiler.option.misc.verbose"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Ansi"
+ category="testgnu.c.compiler.category.other"
+ command="-ansi"
+ id="testgnu.c.compiler.option.misc.ansi"
+ valueType="boolean">
+ </option>
+ </tool>
+ <tool
+ name="compiler.gnu.cpp"
+ id="cdt.managedbuild.tool.testgnu.cpp.compiler"
+ isAbstract="true"
+ sources="c,C,cc,cxx,cpp"
+ command="g++"
+ dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator"
+ headerExtensions="h,H,hpp"
+ natureFilter="ccnature"
+ outputs="o"
+ outputFlag="-o">
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
+ name="Preproc"
+ id="testgnu.cpp.compiler.category.preprocessor">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Posix.Nostdinc"
+ category="testgnu.cpp.compiler.category.preprocessor"
+ command="-nostdinc"
+ id="testgnu.cpp.compiler.option.preprocessor.nostdinc"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.PreprocOnly"
+ category="testgnu.cpp.compiler.category.preprocessor"
+ command="-E"
+ id="testgnu.cpp.compiler.option.preprocessor.preprocess"
+ valueType="boolean">
+ </option>
+ <option
+ name="Posix.DefSym"
+ category="testgnu.cpp.compiler.category.preprocessor"
+ command="-D"
+ id="testgnu.cpp.compiler.option.preprocessor.def"
+ valueType="definedSymbols">
+ </option>
+ <option
+ name="Posix.UndefSym"
+ category="testgnu.cpp.compiler.category.preprocessor"
+ command="-U"
+ id="testgnu.cpp.compiler.option.preprocessor.undef"
+ valueType="stringList">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
+ name="Dirs"
+ id="testgnu.cpp.compiler.category.dirs">
+ </optionCategory>
+ <option
+ name="Posix.InclPaths"
+ category="testgnu.cpp.compiler.category.dirs"
+ command="-I"
+ id="testgnu.cpp.compiler.option.include.paths"
+ valueType="includePath"
+ browseType="directory">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
+ name="Optimize"
+ id="testgnu.cpp.compiler.category.optimization">
+ </optionCategory>
+ <option
+ name="Posix.OptLevel"
+ category="testgnu.cpp.compiler.category.optimization"
+ id="testgnu.cpp.compiler.option.optimization.level"
+ valueType="enumerated">
+ <enumeratedOptionValue
+ name="Posix.Optimize.None"
+ command="-O0"
+ id="testgnu.cpp.compiler.optimization.level.none">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Optimize.Optimize"
+ command="-O1"
+ id="testgnu.cpp.compiler.optimization.level.optimize">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Optimize.More"
+ isDefault="true"
+ command="-O2"
+ id="testgnu.cpp.compiler.optimization.level.more">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Optimize.Most"
+ command="-O3"
+ id="testgnu.cpp.compiler.optimization.level.most">
+ </enumeratedOptionValue>
+ </option>
+ <option
+ name="Posix.Optimize.Flags"
+ category="testgnu.cpp.compiler.category.optimization"
+ id="testgnu.cpp.compiler.option.optimization.flags"
+ valueType="string">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
+ name="Debug"
+ id="testgnu.cpp.compiler.category.debug">
+ </optionCategory>
+ <option
+ name="Posix.DebugLevel"
+ category="testgnu.cpp.compiler.category.debug"
+ id="testgnu.cpp.compiler.option.debugging.level"
+ valueType="enumerated">
+ <enumeratedOptionValue
+ name="Posix.Debug.None"
+ isDefault="false"
+ id="testgnu.cpp.compiler.debugging.level.none">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Debug.Min"
+ command="-g1"
+ id="testgnu.cpp.compiler.debugging.level.minimal">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Debug.Def"
+ isDefault="true"
+ command="-g"
+ id="testgnu.cpp.compiler.debugging.level.default">
+ </enumeratedOptionValue>
+ <enumeratedOptionValue
+ name="Posix.Debug.Max"
+ isDefault="false"
+ command="-g3"
+ id="testgnu.cpp.compiler.debugging.level.max">
+ </enumeratedOptionValue>
+ </option>
+ <option
+ name="Posix.Debug.Other"
+ category="testgnu.cpp.compiler.category.debug"
+ id="testgnu.cpp.compiler.option.debugging.other"
+ valueType="string">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Debug.prof"
+ category="testgnu.cpp.compiler.category.debug"
+ command="-p"
+ id="testgnu.cpp.compiler.option.debugging.prof"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Debug.gprof"
+ category="testgnu.cpp.compiler.category.debug"
+ command="-pg"
+ id="testgnu.cpp.compiler.option.debugging.gprof"
+ valueType="boolean">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
+ name="Warn"
+ id="testgnu.cpp.compiler.category.warnings">
+ </optionCategory>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.Syntax"
+ category="testgnu.cpp.compiler.category.warnings"
+ command="-fsyntax-only"
+ id="testgnu.cpp.compiler.option.warnings.syntax"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.Pedandic"
+ category="testgnu.cpp.compiler.category.warnings"
+ command="-pedantic"
+ id="testgnu.cpp.compiler.option.warnings.pedantic"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.PedErrors"
+ category="testgnu.cpp.compiler.category.warnings"
+ command="-pedantic-errors"
+ id="testgnu.cpp.compiler.option.warnings.pedantic.error"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.nowarn"
+ category="testgnu.cpp.compiler.category.warnings"
+ command="-w"
+ id="testgnu.cpp.compiler.option.warnings.nowarn"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="true"
+ name="Posix.Warn.allwarn"
+ category="testgnu.cpp.compiler.category.warnings"
+ command="-Wall"
+ id="testgnu.cpp.compiler.option.warnings.allwarn"
+ valueType="boolean">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Warn.toerrs"
+ category="testgnu.cpp.compiler.category.warnings"
+ command="-Werror"
+ id="testgnu.cpp.compiler.option.warnings.toerrors"
+ valueType="boolean">
+ </option>
+ <optionCategory
+ owner="cdt.managedbuild.tool.testgnu.cpp.compiler"
+ name="Misc"
+ id="testgnu.cpp.compiler.category.other">
+ </optionCategory>
+ <option
+ defaultValue="-c -fmessage-length=0"
+ name="OtherFlags"
+ category="testgnu.cpp.compiler.category.other"
+ id="testgnu.cpp.compiler.option.other.other"
+ valueType="string">
+ </option>
+ <option
+ defaultValue="false"
+ name="Posix.Verbose"
+ category="testgnu.cpp.compiler.category.other"
+ command="-v"
+ id="testgnu.cpp.compiler.option.other.verbose"
+ valueType="boolean">
+ </option>
+ </tool>
+
+ <projectType
+ isAbstract="false"
+ isTest="true"
+ name="testgnu.exe"
+ id="cdt.managedbuild.target.testgnu.exe">
+ <configuration
+ name="Dbg"
+ id="cdt.managedbuild.config.testgnu.exe.debug"
+ cleanCommand="rm -rf"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
+ <toolChain
+ id="cdt.managedbuild.toolchain.testgnu.exe.debug"
+ name="Dbg ToolChain"
+ scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ <targetPlatform
+ id="cdt.managedbuild.target.testgnu.platform.exe.debug"
+ name="Dbg Platform"
+ binaryParser="org.eclipse.cdt.core.ELF,org.eclipse.cdt.core.PE"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ </targetPlatform>
+ <builder
+ id="cdt.managedbuild.target.testgnu.builder.exe.debug"
+ name="Dbg Builder"
+ command="make"
+ arguments="-k"
+ buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
+ </builder>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.compiler.exe.debug"
+ superClass="cdt.managedbuild.tool.testgnu.c.compiler">
+ <option
+ id="testgnu.c.compiler.exe.debug.option.optimization.level"
+ defaultValue="testgnu.c.optimization.level.none"
+ superClass="testgnu.c.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.c.compiler.exe.debug.option.debugging.level"
+ defaultValue="testgnu.c.debugging.level.max"
+ superClass="testgnu.c.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.compiler.exe.debug"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
+ <option
+ id="testgnu.cpp.compiler.exe.debug.option.optimization.level"
+ defaultValue="testgnu.cpp.compiler.optimization.level.none"
+ superClass="testgnu.cpp.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.cpp.compiler.exe.debug.option.debugging.level"
+ defaultValue="testgnu.cpp.compiler.debugging.level.max"
+ superClass="testgnu.cpp.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.linker.exe.debug"
+ superClass="cdt.managedbuild.tool.testgnu.c.linker">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.linker.exe.debug"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.linker">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.assembler.exe.debug"
+ superClass="cdt.managedbuild.tool.testgnu.assembler">
+ </tool>
+ </toolChain>
+ </configuration>
+ <configuration
+ name="Rel"
+ id="cdt.managedbuild.config.testgnu.exe.release"
+ cleanCommand="rm -rf"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
+ <toolChain
+ id="cdt.managedbuild.toolchain.testgnu.exe.release"
+ name="Rel ToolChain"
+ scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ <targetPlatform
+ id="cdt.managedbuild.target.testgnu.platform.exe.release"
+ name="Rel Platform"
+ binaryParser="org.eclipse.cdt.core.ELF,org.eclipse.cdt.core.PE"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ </targetPlatform>
+ <builder
+ id="cdt.managedbuild.target.testgnu.builder.exe.release"
+ name="Rel Builder"
+ command="make"
+ arguments="-k">
+ </builder>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.compiler.exe.release"
+ superClass="cdt.managedbuild.tool.testgnu.c.compiler">
+ <option
+ id="testgnu.c.compiler.exe.release.option.optimization.level"
+ defaultValue="testgnu.c.optimization.level.most"
+ superClass="testgnu.c.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.c.compiler.exe.release.option.debugging.level"
+ defaultValue="testgnu.c.debugging.level.none"
+ superClass="testgnu.c.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.compiler.exe.release"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
+ <option
+ id="testgnu.cpp.compiler.exe.release.option.optimization.level"
+ defaultValue="testgnu.cpp.compiler.optimization.level.most"
+ superClass="testgnu.cpp.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.cpp.compiler.exe.release.option.debugging.level"
+ defaultValue="testgnu.cpp.compiler.debugging.level.none"
+ superClass="testgnu.cpp.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.linker.exe.release"
+ superClass="cdt.managedbuild.tool.testgnu.c.linker">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.linker.exe.release"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.linker">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.assembler.exe.release"
+ superClass="cdt.managedbuild.tool.testgnu.assembler">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+ <projectType
+ isAbstract="false"
+ isTest="true"
+ name="testgnu.so"
+ id="cdt.managedbuild.target.testgnu.so">
+ <configuration
+ name="Debug"
+ cleanCommand="rm -rf"
+ artifactExtension="so"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ id="cdt.managedbuild.config.testgnu.so.debug">
+ <toolChain
+ id="cdt.managedbuild.toolchain.testgnu.so.debug"
+ name="so Debug ToolChain"
+ scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ <targetPlatform
+ id="cdt.managedbuild.target.testgnu.platform.so.debug"
+ name="so Debug Platform"
+ binaryParser="org.eclipse.cdt.core.ELF"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ </targetPlatform>
+ <builder
+ id="cdt.managedbuild.target.testgnu.builder.so.debug"
+ name="so Debug Builder"
+ command="make"
+ arguments="-k">
+ </builder>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.compiler.so.debug"
+ superClass="cdt.managedbuild.tool.testgnu.c.compiler">
+ <option
+ id="testgnu.c.compiler.so.debug.option.optimization.level"
+ defaultValue="testgnu.c.optimization.level.none"
+ superClass="testgnu.c.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.c.compiler.so.debug.option.debugging.level"
+ defaultValue="testgnu.c.debugging.level.max"
+ superClass="testgnu.c.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.compiler.so.debug"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
+ <option
+ id="testgnu.cpp.compiler.so.debug.option.optimization.level"
+ defaultValue="testgnu.cpp.compiler.optimization.level.none"
+ superClass="testgnu.cpp.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.cpp.compiler.so.debug.option.debugging.level"
+ defaultValue="testgnu.cpp.compiler.debugging.level.max"
+ superClass="testgnu.cpp.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.linker.so.debug"
+ outputs="so"
+ outputPrefix="lib"
+ superClass="cdt.managedbuild.tool.testgnu.c.linker">
+ <option
+ id="testgnu.c.link.so.debug.option.shared"
+ defaultValue="true"
+ superClass="testgnu.c.link.option.shared">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.linker.so.debug"
+ outputs="so"
+ outputPrefix="lib"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.linker">
+ <option
+ id="testgnu.cpp.link.so.debug.option.shared"
+ defaultValue="true"
+ superClass="testgnu.cpp.link.option.shared">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.assembler.so.debug"
+ superClass="cdt.managedbuild.tool.testgnu.assembler">
+ </tool>
+ </toolChain>
+ </configuration>
+ <configuration
+ name="Release"
+ cleanCommand="rm -rf"
+ artifactExtension="so"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ id="cdt.managedbuild.config.testgnu.so.release">
+ <toolChain
+ id="cdt.managedbuild.toolchain.testgnu.so.release"
+ name="so Release ToolChain"
+ scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ <targetPlatform
+ id="cdt.managedbuild.target.testgnu.platform.so.release"
+ name="so Release Platform"
+ binaryParser="org.eclipse.cdt.core.ELF"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ </targetPlatform>
+ <builder
+ id="cdt.managedbuild.target.testgnu.builder.so.release"
+ name="so Release Builder"
+ command="make"
+ arguments="-k">
+ </builder>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.compiler.so.release"
+ superClass="cdt.managedbuild.tool.testgnu.c.compiler">
+ <option
+ id="testgnu.c.compiler.so.release.option.optimization.level"
+ defaultValue="testgnu.c.optimization.level.most"
+ superClass="testgnu.c.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.c.compiler.so.release.option.debugging.level"
+ defaultValue="testgnu.c.debugging.level.none"
+ superClass="testgnu.c.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.compiler.so.release"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
+ <option
+ id="testgnu.cpp.compiler.so.release.option.optimization.level"
+ defaultValue="testgnu.cpp.compiler.optimization.level.most"
+ superClass="testgnu.cpp.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.cpp.compiler.so.release.option.debugging.level"
+ defaultValue="testgnu.cpp.compiler.debugging.level.none"
+ superClass="testgnu.cpp.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.linker.so.release"
+ outputs="so"
+ outputPrefix="lib"
+ superClass="cdt.managedbuild.tool.testgnu.c.linker">
+ <option
+ id="testgnu.c.link.so.release.option.shared"
+ defaultValue="true"
+ superClass="testgnu.c.link.option.shared">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.linker.so.release"
+ outputs="so"
+ outputPrefix="lib"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.linker">
+ <option
+ id="testgnu.cpp.link.so.release.option.shared"
+ defaultValue="true"
+ superClass="testgnu.cpp.link.option.shared">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.assembler.so.release"
+ superClass="cdt.managedbuild.tool.testgnu.assembler">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+ <projectType
+ isTest="true"
+ name="testgnu.lib"
+ isAbstract="false"
+ id="cdt.managedbuild.target.testgnu.lib">
+ <configuration
+ name="Dbg"
+ artifactExtension="a"
+ cleanCommand="rm -rf"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ id="cdt.managedbuild.config.testgnu.lib.debug">
+ <toolChain
+ id="cdt.managedbuild.toolchain.testgnu.lib.debug"
+ name="Dbg TC"
+ scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ <targetPlatform
+ id="cdt.managedbuild.target.testgnu.platform.lib.debug"
+ name="Dbg P"
+ binaryParser="org.eclipse.cdt.core.ELF"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ </targetPlatform>
+ <builder
+ id="cdt.managedbuild.target.testgnu.builder.lib.debug"
+ name="Dbg B"
+ command="make"
+ arguments="-k">
+ </builder>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.compiler.lib.debug"
+ superClass="cdt.managedbuild.tool.testgnu.c.compiler">
+ <option
+ id="testgnu.c.compiler.lib.debug.option.optimization.level"
+ defaultValue="testgnu.c.optimization.level.none"
+ superClass="testgnu.c.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.c.compiler.lib.debug.option.debugging.level"
+ defaultValue="testgnu.c.debugging.level.max"
+ superClass="testgnu.c.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.compiler.lib.debug"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
+ <option
+ id="testgnu.cpp.compiler.lib.debug.option.optimization.level"
+ defaultValue="testgnu.cpp.compiler.optimization.level.none"
+ superClass="testgnu.cpp.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.cpp.compiler.lib.debug.option.debugging.level"
+ defaultValue="testgnu.cpp.compiler.debugging.level.max"
+ superClass="testgnu.cpp.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.archiver.lib.debug"
+ outputs="a"
+ outputPrefix="lib"
+ superClass="cdt.managedbuild.tool.testgnu.archiver">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.assembler.lib.debug"
+ superClass="cdt.managedbuild.tool.testgnu.assembler">
+ </tool>
+ </toolChain>
+ </configuration>
+ <configuration
+ name="Rel"
+ artifactExtension="a"
+ cleanCommand="rm -rf"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser"
+ id="cdt.managedbuild.config.testgnu.lib.release">
+ <toolChain
+ id="cdt.managedbuild.toolchain.testgnu.lib.release"
+ name="Rel TC"
+ scannerInfoCollector="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ <targetPlatform
+ id="cdt.managedbuild.target.testgnu.platform.lib.release"
+ name="Rel P"
+ binaryParser="org.eclipse.cdt.core.ELF"
+ osList="solaris,linux,hpux,aix,qnx"
+ archList="all">
+ </targetPlatform>
+ <builder
+ id="cdt.managedbuild.target.testgnu.builder.lib.release"
+ name="Rel B"
+ command="make"
+ arguments="-k">
+ </builder>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.c.compiler.lib.release"
+ superClass="cdt.managedbuild.tool.testgnu.c.compiler">
+ <option
+ id="testgnu.c.compiler.lib.release.option.optimization.level"
+ defaultValue="testgnu.c.optimization.level.most"
+ superClass="testgnu.c.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.c.compiler.lib.release.option.debugging.level"
+ defaultValue="testgnu.c.debugging.level.none"
+ superClass="testgnu.c.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.cpp.compiler.lib.release"
+ superClass="cdt.managedbuild.tool.testgnu.cpp.compiler">
+ <option
+ id="testgnu.cpp.compiler.lib.release.option.optimization.level"
+ defaultValue="testgnu.cpp.compiler.optimization.level.most"
+ superClass="testgnu.cpp.compiler.option.optimization.level">
+ </option>
+ <option
+ id="testgnu.cpp.compiler.lib.release.option.debugging.level"
+ defaultValue="testgnu.cpp.compiler.debugging.level.none"
+ superClass="testgnu.cpp.compiler.option.debugging.level">
+ </option>
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.archiver.lib.release"
+ outputs="a"
+ outputPrefix="lib"
+ superClass="cdt.managedbuild.tool.testgnu.archiver">
+ </tool>
+ <tool
+ id="cdt.managedbuild.tool.testgnu.assembler.lib.release"
+ superClass="cdt.managedbuild.tool.testgnu.assembler">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+ <projectType
+ isTest="true"
+ name="Test Java Attributes"
+ isAbstract="false"
+ id="cdt.managedbuild.test.java.attrs">
+ <configuration
+ name="The One and Only"
+ artifactName="Testme"
+ artifactExtension="xyz"
+ id="cdt.managedbuild.test.java.attrs.config">
+ <toolChain
+ id="cdt.managedbuild.test.java.attrs.toolchain"
+ name="The Tool-Chain">
+ <tool
+ id="cdt.managedbuild.test.java.attrs.tool"
+ superClass="cdt.managedbuild.tool.testgnu.c.compiler"
+ commandLineGenerator="org.eclipse.cdt.managedbuild.core.tests.ManagedBuildCommandLineGenerator">
+ <option
+ id="testgnu.c.compiler.option.preprocessor.def.symbols.test"
+ superClass="testgnu.c.compiler.option.preprocessor.def.symbols">
+ <listOptionValue
+ value="foo">
+ </listOptionValue>
+ <listOptionValue
+ value="bar">
+ </listOptionValue>
+ </option>
+ </tool>
+ <builder
+ id="cdt.managedbuild.test.java.attrs.builder"
+ name="Test Builder"
+ command="makeMe"
+ arguments="-k"
+ buildfileGenerator="org.eclipse.cdt.managedbuild.core.tests.BuildFileGenerator">
+ </builder>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+ </extension>
+
+</plugin>
Index: D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java
===================================================================
--- D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java (revision 11)
+++ D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/core/ITargetPlatform.java (working copy)
@@ -1,130 +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 <code>ITargetPlatform</code> that is the superclass of this
- * target platform, or <code>null</code> if the attribute was not specified.
- *
- * @return ITargetPlatform
- */
- public ITargetPlatform getSuperClass();
-
- /**
- * Returns whether this element is abstract. Returns <code>false</code>
- * 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 <code>true</code> if this element has changes that need to
- * be saved in the project file, else <code>false</code>.
- *
- * @return boolean
- */
- public boolean isDirty();
-
- /**
- * Sets the element's "dirty" (have I been modified?) flag.
- *
- * @param isDirty
- */
- public void setDirty(boolean isDirty);
-
- /**
- * Returns <code>true</code> if this target platform was loaded from a manifest file,
- * and <code>false</code> if it was loaded from a project (.cdtbuild) file.
- *
- * @return boolean
- */
- public boolean isExtensionElement();
-
-}
+/**********************************************************************
+ * 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 <code>ITargetPlatform</code> that is the superclass of this
+ * target platform, or <code>null</code> if the attribute was not specified.
+ *
+ * @return ITargetPlatform
+ */
+ public ITargetPlatform getSuperClass();
+
+ /**
+ * Returns whether this element is abstract. Returns <code>false</code>
+ * 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 IDs of the binary parsers associated with the target platform.
+ *
+ * @return String
+ */
+ public String[] getBinaryParserList();
+
+ /**
+ * Sets the string ids of the binary parsers for this target platform.
+ *
+ * @param id
+ */
+ public void setBinaryParserList(String[] ids);
+
+ /**
+ * Returns <code>true</code> if this element has changes that need to
+ * be saved in the project file, else <code>false</code>.
+ *
+ * @return boolean
+ */
+ public boolean isDirty();
+
+ /**
+ * Sets the element's "dirty" (have I been modified?) flag.
+ *
+ * @param isDirty
+ */
+ public void setDirty(boolean isDirty);
+
+ /**
+ * Returns <code>true</code> if this target platform was loaded from a manifest file,
+ * and <code>false</code> if it was loaded from a project (.cdtbuild) file.
+ *
+ * @return boolean
+ */
+ public boolean isExtensionElement();
+
+}
Index: D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/Target.java
===================================================================
--- D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/Target.java (revision 11)
+++ D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/Target.java (working copy)
@@ -1,1147 +1,1148 @@
-/**********************************************************************
- * 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.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 java.util.Vector;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-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.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Platform;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class Target extends BuildObject implements ITarget {
- private static final String EMPTY_STRING = new String();
- private static final IConfigurationV2[] emptyConfigs = new IConfigurationV2[0];
- private String artifactName;
- private String binaryParserId;
- private String cleanCommand;
- private List configList;
- private Map configMap;
- private String defaultExtension;
- private Map depCalculatorsMap;
- private String errorParserIds;
- private String extension;
- private boolean isAbstract = false;
- private boolean isDirty = false;
- private boolean isTest = false;
- private String makeArguments;
- private String makeCommand;
- private IResource owner;
- private ITarget parent;
- private boolean resolved = true;
- private List targetArchList;
- private List targetOSList;
- private List toolList;
- private Map toolMap;
- private List toolReferences;
- private ProjectType createdProjectType;
-
- /**
- * This constructor is called to create a target defined by an extension point in
- * a plugin manifest file.
- *
- * @param element
- */
- public Target(IManagedConfigElement element) {
- // setup for resolving
- ManagedBuildManager.putConfigElement(this, element);
- resolved = false;
-
- // id
- setId(element.getAttribute(ID));
-
- // hook me up
- ManagedBuildManager.addExtensionTarget(this);
-
- // Get the target name
- setName(element.getAttribute(NAME));
-
- // Get the name of the build artifact associated with target (usually
- // in the plugin specification).
- artifactName = element.getAttribute(ARTIFACT_NAME);
-
- // Get the ID of the binary parser
- binaryParserId = element.getAttribute(BINARY_PARSER);
-
- // Get the semicolon separated list of IDs of the error parsers
- errorParserIds = element.getAttribute(ERROR_PARSERS);
-
- // Get the default extension
- defaultExtension = element.getAttribute(DEFAULT_EXTENSION);
-
- // isAbstract
- isAbstract = ("true".equals(element.getAttribute(IS_ABSTRACT))); //$NON-NLS-1$
-
- // Is this a test target
- isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
-
- // Get the clean command
- cleanCommand = element.getAttribute(CLEAN_COMMAND);
-
- // Get the make command
- makeCommand = element.getAttribute(MAKE_COMMAND);
-
- // Get the make arguments
- makeArguments = element.getAttribute(MAKE_ARGS);
-
- // Get the comma-separated list of valid OS
- String os = element.getAttribute(OS_LIST);
- if (os != null) {
- targetOSList = new ArrayList();
- String[] osTokens = os.split(","); //$NON-NLS-1$
- for (int i = 0; i < osTokens.length; ++i) {
- targetOSList.add(osTokens[i].trim());
- }
- }
-
- // Get the comma-separated list of valid Architectures
- String arch = element.getAttribute(ARCH_LIST);
- if (arch != null) {
- targetArchList = new ArrayList();
- String[] archTokens = arch.split(","); //$NON-NLS-1$
- for (int j = 0; j < archTokens.length; ++j) {
- targetArchList.add(archTokens[j].trim());
- }
- }
-
- // Load any tool references we might have
- IManagedConfigElement[] toolRefs = element.getChildren(IConfigurationV2.TOOLREF_ELEMENT_NAME);
- for (int k = 0; k < toolRefs.length; ++k) {
- new ToolReference(this, toolRefs[k]);
- }
- // Then load any tools defined for the target
- IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
- for (int m = 0; m < tools.length; ++m) {
- ITool newTool = new Tool(this, tools[m]);
- // Add this tool to the target, as this is not done in the constructor
- this.addTool(newTool);
- }
- // Then load the configurations which may have tool references
- IManagedConfigElement[] configs = element.getChildren(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
- for (int n = 0; n < configs.length; ++n) {
- new ConfigurationV2(this, configs[n]);
- }
- }
-
- /* (non-Javadoc)
- * Set the resource that owns the target.
- *
- * @param owner
- */
- protected Target(IResource owner) {
- this.owner = owner;
- }
-
- /**
- * Create a copy of the target specified in the argument,
- * that is owned by the owned by the specified resource.
- *
- * @param owner
- * @param parent
- */
- public Target(IResource owner, ITarget parent) {
- // Make the owner of the target the project resource
- this(owner);
-
- // Copy the parent's identity
- this.parent = parent;
- int id = ManagedBuildManager.getRandomNumber();
- setId(owner.getName() + "." + parent.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
- setName(parent.getName());
- setArtifactName(parent.getArtifactName());
- this.binaryParserId = parent.getBinaryParserId();
- this.errorParserIds = parent.getErrorParserIds();
- this.defaultExtension = parent.getArtifactExtension();
- this.isTest = parent.isTestTarget();
- this.cleanCommand = parent.getCleanCommand();
-
- // Hook me up
- IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
- buildInfo.addTarget(this);
- }
-
- /**
- * Create target from project file.
- *
- * @param buildInfo
- * @param element
- */
- public Target(ManagedBuildInfo buildInfo, Element element) {
- this(buildInfo.getOwner());
-
- // id
- setId(element.getAttribute(ID));
-
- // hook me up
- buildInfo.addTarget(this);
-
- // name
- setName(element.getAttribute(NAME));
-
- // Get the name of the build artifact associated with target (should
- // contain what the user entered in the UI).
- artifactName = element.getAttribute(ARTIFACT_NAME);
-
- // Get the overridden extension
- if (element.hasAttribute(EXTENSION)) {
- extension = element.getAttribute(EXTENSION);
- }
-
- // parent
- String parentId = element.getAttribute(PARENT);
- if (parentId != null)
- parent = ManagedBuildManager.getTarget(null, parentId);
-
- // isAbstract
- if ("true".equals(element.getAttribute(IS_ABSTRACT))) //$NON-NLS-1$
- isAbstract = true;
-
- // Is this a test target
- isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
-
- // Get the clean command
- if (element.hasAttribute(CLEAN_COMMAND)) {
- cleanCommand = element.getAttribute(CLEAN_COMMAND);
- }
-
- // Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(ERROR_PARSERS)) {
- errorParserIds = element.getAttribute(ERROR_PARSERS);
- }
-
- // Get the make command and arguments
- if (element.hasAttribute(MAKE_COMMAND)) {
- makeCommand = element.getAttribute(MAKE_COMMAND);
- }
- if(element.hasAttribute(MAKE_ARGS)) {
- makeArguments = element.getAttribute(MAKE_ARGS);
- }
-
- Node child = element.getFirstChild();
- while (child != null) {
- if (child.getNodeName().equals(IConfigurationV2.CONFIGURATION_ELEMENT_NAME)) {
- new ConfigurationV2(this, (Element)child);
- }
- child = child.getNextSibling();
- }
- }
-
- /**
- * @param configuration
- */
- public void addConfiguration(IConfigurationV2 configuration) {
- getConfigurationList().add(configuration);
- getConfigurationMap().put(configuration.getId(), configuration);
- }
-
- /**
- * Adds a tool specification to the receiver. This tool is defined
- * only for the receiver, and cannot be shared by other targets.
- *
- * @param tool
- */
- public void addTool(ITool tool) {
- getToolList().add(tool);
- getToolMap().put(tool.getId(), tool);
- }
-
- /**
- * Adds a tool reference to the receiver.
- *
- * @param toolRef
- */
- public void addToolReference(ToolReference toolRef) {
- getLocalToolReferences().add(toolRef);
- }
-
-
- /* (non-Javadoc)
- * Tail-recursion method that creates a lits of tools and tool reference
- * walking the receiver's parent hierarchy.
- *
- * @param toolArray
- */
- private void addToolsToArray(Vector toolArray) {
- if (parent != null) {
- ((Target)parent).addToolsToArray(toolArray);
- }
-
- // Add the tools from out own list
- toolArray.addAll(getToolList());
-
- // Add local tool references
- toolArray.addAll(getLocalToolReferences());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration(org.eclipse.cdt.core.build.managed.IConfigurationV2)
- */
- public IConfigurationV2 createConfiguration(IConfigurationV2 parent, String id) {
- isDirty = true;
- return new ConfigurationV2(this, parent, id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration()
- */
- public IConfigurationV2 createConfiguration(String id) {
- return new ConfigurationV2(this, id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getArtifactExtension()
- */
- public String getArtifactExtension() {
- // Has the user changed the extension for this target
- if (extension != null) {
- return extension;
- }
- // If not, then go through the default extension lookup
- if (defaultExtension == null) {
- // Ask my parent first
- if (parent != null) {
- return parent.getArtifactExtension();
- } else {
- return EMPTY_STRING;
- }
- } else {
- return defaultExtension;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#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.managedbuilder.core.ITarget#getBinaryParserId()
- */
- public String getBinaryParserId() {
- if (binaryParserId == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getBinaryParserId();
- } else {
- // I'm it and this is not good!
- return EMPTY_STRING;
- }
- }
- return binaryParserId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#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.core.build.managed.ITarget#getConfiguration()
- */
- public IConfigurationV2 getConfiguration(String id) {
- return (IConfigurationV2)getConfigurationMap().get(id);
- }
-
- /* (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;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getConfigurations()
- */
- public IConfigurationV2[] getConfigurations() {
- return (IConfigurationV2[])getConfigurationList().toArray(new IConfigurationV2[getConfigurationList().size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getDefaultExtension()
- */
- public String getDefaultExtension() {
- return defaultExtension == null ? EMPTY_STRING : defaultExtension;
- }
-
- private Map getDepCalcMap() {
- if (depCalculatorsMap == null) {
- depCalculatorsMap = new HashMap();
- }
- return depCalculatorsMap;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserIds()
- */
- public String getErrorParserIds() {
- if (errorParserIds == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getErrorParserIds();
- }
- }
- return errorParserIds;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#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 {
- // If no error parsers are specified by the target, the default is
- // all error parsers
- errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
- }
- return errorParsers;
- }
-
- /* (non-javadoc)
- * A safe accesor method. It answers the tool reference list in the
- * receiver.
- *
- * @return List
- */
- protected List getLocalToolReferences() {
- if (toolReferences == null) {
- toolReferences = new ArrayList();
- }
- return toolReferences;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getMakeArguments()
- */
- public String getMakeArguments() {
- if (makeArguments == null) {
- // See if it is defined in my parent
- if (parent != null) {
- return parent.getMakeArguments();
- } else {
- // No parent and no user setting
- return new String(""); //$NON-NLS-1$
- }
- }
- return makeArguments;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getMakeCommand()
- */
- public String getMakeCommand() {
- // Return the name of the make utility
- if (makeCommand == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getMakeCommand();
- } else {
- // The user has forgotten to specify a command in the plugin manifest
- return new String("make"); //$NON-NLS-1$
- }
- } else {
- return makeCommand;
- }
- }
-
- /* (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 (parent != null) {
- return parent.getName();
- } else {
- return new String(""); //$NON-NLS-1$
- }
- } else {
- return name;
- }
- }
-
- /* (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
- ToolReference 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 = ((Target)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.ITarget#getOwner()
- */
- public IResource getOwner() {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getParent()
- */
- public ITarget getParent() {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetArchList()
- */
- public String[] getTargetArchList() {
- if (targetArchList == null) {
- // Ask parent for its list
- if (parent != null) {
- return parent.getTargetArchList();
- } else {
- // I have no parent and no defined list
- return new String[] {"all"}; //$NON-NLS-1$
- }
- }
- return (String[]) targetArchList.toArray(new String[targetArchList.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetOSList()
- */
- public String[] getTargetOSList() {
- if (targetOSList == null) {
- // Ask parent for its list
- if (parent != null) {
- return parent.getTargetOSList();
- } else {
- // I have no parent and no defined filter list
- return new String[] {"all"}; //$NON-NLS-1$
- }
- }
- return (String[]) targetOSList.toArray(new String[targetOSList.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTool(java.lang.String)
- */
- public ITool getTool(String id) {
- ITool result = null;
-
- // See if receiver has it in list
- result = (ITool) getToolMap().get(id);
-
- // If not, check if parent has it
- if (result == null && parent != null) {
- result = ((Target)parent).getTool(id);
- }
-
- // If not defined in parents, check if defined at all
- if (result == null) {
- result = ManagedBuildManager.getExtensionTool(id);
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- * A safe accessor method for the list of tools maintained by the
- * target
- *
- */
- private List getToolList() {
- if (toolList == null) {
- toolList = new ArrayList();
- }
- return toolList;
- }
-
- /* (non-Javadoc)
- * A safe accessor for the tool map
- *
- */
- private Map getToolMap() {
- if (toolMap == null) {
- toolMap = new HashMap();
- }
- return toolMap;
- }
-
- /* (non-Javadoc)
- * Returns the reference for a given tool or <code>null</code> if one is not
- * found.
- *
- * @param tool
- * @return ToolReference
- */
- private ToolReference getToolReference(ITool tool) {
- // See if the receiver has a reference to the tool
- ToolReference ref = null;
- if (tool == null) return ref;
- Iterator iter = getLocalToolReferences().listIterator();
- while (iter.hasNext()) {
- ToolReference temp = (ToolReference)iter.next();
- if (temp.references(tool)) {
- ref = temp;
- break;
- }
- }
- return ref;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTools()
- */
- public ITool[] getTools() {
- Vector toolArray = new Vector();
- addToolsToArray(toolArray);
- return (ITool[]) toolArray.toArray(new ITool[toolArray.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#hasMakeCommandOverride()
- */
- public boolean hasOverridenMakeCommand() {
- // We answer true if the make command or the flags are different
- return ((makeCommand != null && !makeCommand.equals(parent.getMakeCommand()))
- || (makeArguments != null && !makeArguments.equals(parent.getMakeArguments())));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#isAbstract()
- */
- public boolean isAbstract() {
- return isAbstract;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#isDirty()
- */
- public boolean isDirty() {
- // If I need saving, just say yes
- if (isDirty) {
- return true;
- }
-
- // Iterate over the configurations and ask them if they need saving
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- if (((IConfigurationV2)iter.next()).isDirty()) {
- return true;
- }
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#isTestTarget()
- */
- public boolean isTestTarget() {
- return isTest;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#needsRebuild()
- */
- public boolean needsRebuild(){
- // Iterate over the configurations and ask them if they need saving
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- if (((IConfigurationV2)iter.next()).needsRebuild()) {
- return true;
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#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()) {
- IConfigurationV2 config = (IConfigurationV2)iter.next();
- if (config.getId().equals(id)) {
- getConfigurationList().remove(config);
- getConfigurationMap().remove(id);
- isDirty = true;
- break;
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#resetMakeCommand()
- */
- public void resetMakeCommand() {
- // Flag target as dirty if the reset actually changes something
- if (makeCommand != null) {
- setDirty(true);
- }
- makeCommand = null;
- makeArguments = null;
- }
-
- /**
- *
- */
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- // parent
- String parentId = element.getAttribute(PARENT);
- if (parentId != null) {
- parent = ManagedBuildManager.getTarget(null, parentId);
- // should resolve before calling methods on it
- ((Target)parent).resolveReferences();
- // copy over the parents configs
- IConfigurationV2[] parentConfigs = parent.getConfigurations();
- for (int i = 0; i < parentConfigs.length; ++i)
- addConfiguration(parentConfigs[i]);
- }
-
- // call resolve references on any children
- Iterator toolIter = getToolList().iterator();
- while (toolIter.hasNext()) {
- Tool current = (Tool)toolIter.next();
- current.resolveReferences();
- }
- Iterator refIter = getLocalToolReferences().iterator();
- while (refIter.hasNext()) {
- ToolReference current = (ToolReference)refIter.next();
- current.resolveReferences();
- }
- Iterator configIter = getConfigurationList().iterator();
- while (configIter.hasNext()) {
- ConfigurationV2 current = (ConfigurationV2)configIter.next();
- current.resolveReferences();
- }
- }
- }
-
- /**
- * Persist receiver to project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- element.setAttribute(ID, getId());
- element.setAttribute(NAME, getName());
- if (parent != null)
- element.setAttribute(PARENT, parent.getId());
- element.setAttribute(IS_ABSTRACT, isAbstract ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
- element.setAttribute(ARTIFACT_NAME, getArtifactName());
- if (extension != null) {
- element.setAttribute(EXTENSION, extension);
- }
- element.setAttribute(IS_TEST, isTest ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (makeCommand != null) {
- element.setAttribute(MAKE_COMMAND, makeCommand);
- } else {
- // Make sure we use the default
- }
-
- if (makeArguments != null) {
- element.setAttribute(MAKE_ARGS, makeArguments);
- }
- if (errorParserIds != null) {
- element.setAttribute(ERROR_PARSERS, errorParserIds);
- }
-
- // Serialize the configuration settings
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- ConfigurationV2 config = (ConfigurationV2) iter.next();
- Element configElement = doc.createElement(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
- element.appendChild(configElement);
- config.serialize(doc, configElement);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setArtifactExtension(java.lang.String)
- */
- public void setArtifactExtension(String extension) {
- if (extension != null) {
- this.extension = extension;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#setArtifactName(java.lang.String)
- */
- public void setArtifactName(String name) {
- if (name != null) {
- artifactName = name;
- setRebuildState(true);
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- // Override the dirty flag here
- this.isDirty = isDirty;
- // and in the configurations
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- IConfigurationV2 config = (IConfigurationV2)iter.next();
- config.setDirty(isDirty);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setErrorParserIds()
- */
- public void setErrorParserIds(String ids) {
- if (ids == null) return;
- String currentIds = getErrorParserIds();
- if (currentIds == null || !(currentIds.equals(ids))) {
- errorParserIds = ids;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeArguments(java.lang.String)
- */
- public void setMakeArguments(String makeArgs) {
- if (makeArgs != null && !getMakeArguments().equals(makeArgs)) {
- makeArguments = makeArgs;
- setRebuildState(true);
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeCommand(java.lang.String)
- */
- public void setMakeCommand(String command) {
- if (command != null && !getMakeCommand().equals(command)) {
- makeCommand = command;
- setRebuildState(true);
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setRebuildState(boolean)
- */
- public void setRebuildState(boolean rebuild) {
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- ((IConfigurationV2)iter.next()).setRebuildState(rebuild);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#updateOwner(org.eclipse.core.resources.IResource)
- */
- public void updateOwner(IResource resource) {
- if (!resource.equals(owner)) {
- // Set the owner correctly
- owner = resource;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#convertToProjectType()
- */
- public void convertToProjectType() {
- // Create a ProjectType + Configuration + Toolchain + Builder + TargetPlatform
- // from the Target
-
- // The "parent" needs to have been converted already.
- // Do it now if necessary.
- ProjectType parentProj = null;
- if (parent != null) {
- parentProj = parent.getCreatedProjectType();
- if (parentProj == null) {
- parent.convertToProjectType();
- parentProj = parent.getCreatedProjectType();
- }
- }
- ProjectType projectType = new ProjectType(parentProj, getId(), getName());
- createdProjectType = projectType;
- // Set the project type attributes
- projectType.setIsAbstract(isAbstract);
- projectType.setIsTest(isTest);
- // Add children
- // Add configurations (Configuration -> ToolChain -> Builder -> TargetPlatform)
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- IConfigurationV2 configV2 = (IConfigurationV2)iter.next();
- if (configV2.getCreatedConfig() != null) continue;
- // The new config's superClass needs to be the
- // Configuration created from the ConfigurationV2 parent...
- IConfiguration configSuperClass = null;
- IConfigurationV2 parentV2 = configV2.getParent();
- if (parentV2 != null) {
- configSuperClass = parentV2.getCreatedConfig();
- }
- String id = configV2.getId();
- String name = configV2.getName();
- IConfiguration config = projectType.createConfiguration(configSuperClass, id, name);
- configV2.setCreatedConfig(config);
- // Set the configuration attributes
- config.setArtifactName(getArtifactName());
- config.setArtifactExtension(getArtifactExtension());
- config.setCleanCommand(getCleanCommand());
- config.setErrorParserIds(getErrorParserIds());
- // Create the Tool-chain
- String subId;
- String subName;
- subId = id + ".toolchain"; //$NON-NLS-1$
- subName = name + ".toolchain"; //$NON-NLS-1$
- IToolChain toolChain = config.createToolChain(null, subId, subName, true);
- // Set the tool chain attributes
- toolChain.setIsAbstract(isAbstract);
- toolChain.setOSList(getTargetOSList());
- toolChain.setArchList(getTargetArchList());
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- if (element instanceof DefaultManagedConfigElement) {
- toolChain.setScannerInfoCollectorElement(((DefaultManagedConfigElement)element).getConfigurationElement());
- }
- // Create the Builder
- subId = id + ".builder"; //$NON-NLS-1$
- subName = name + ".builder"; //$NON-NLS-1$
- IBuilder builder = toolChain.createBuilder(null, subId, subName, true);
- // Set the builder attributes
- builder.setIsAbstract(isAbstract);
- builder.setCommand(getMakeCommand());
- builder.setArguments(getMakeArguments());
- if (element instanceof DefaultManagedConfigElement) {
- builder.setBuildFileGeneratorElement(((DefaultManagedConfigElement)element).getConfigurationElement());
- }
- // Create the TargetPlatform
- subId = id + ".targetplatform"; //$NON-NLS-1$
- subName = name + ".targetplatform"; //$NON-NLS-1$
- ITargetPlatform targetPlatform = toolChain.createTargetPlatform(null, subId, subName, true);
- // Set the target platform attributes
- targetPlatform.setIsAbstract(isAbstract);
- targetPlatform.setOSList(getTargetOSList());
- targetPlatform.setArchList(getTargetArchList());
- targetPlatform.setBinaryParserId(getBinaryParserId());
-
- // Handle ConfigurationV2 children (ToolReference)
- // The tools references fetched here are strictly local to the configuration,
- // so additional work is required to fetch the tool references from the target
- IToolReference[] configToolRefs = configV2.getToolReferences();
- // Add the "local" tool references (they are direct children of the target and
- // its parent targets)
- Vector targetToolRefs = new Vector();
- addTargetToolReferences(targetToolRefs);
- IToolReference[] toolRefs;
- if (targetToolRefs.size() > 0) {
- toolRefs = new IToolReference[targetToolRefs.size() + configToolRefs.length];
- int i;
- for (i = 0; i < configToolRefs.length; ++i) {
- toolRefs[i] = configToolRefs[i];
- }
- Iterator localToolRefIter = targetToolRefs.iterator();
- while (localToolRefIter.hasNext()) {
- toolRefs[i++] = (IToolReference)localToolRefIter.next();
- }
- } else {
- toolRefs = configToolRefs;
- }
- for (int i = 0; i < toolRefs.length; ++i) {
- IToolReference toolRef = toolRefs[i];
- subId = id + "." + toolRef.getId(); //$NON-NLS-1$
- // The ToolReference's Tool becomes the newTool's SuperClass
- ITool newTool = toolChain.createTool(toolRef.getTool(), subId, toolRef.getName(), true);
- // Set the tool attributes
- newTool.setToolCommand(toolRef.getRawToolCommand());
- newTool.setOutputPrefix(toolRef.getRawOutputPrefix());
- newTool.setOutputFlag(toolRef.getRawOutputFlag());
- newTool.setOutputExtensions(toolRef.getRawOutputExtensions());
- // Handle ToolReference children (OptionReference)
- Iterator optRefIter = toolRef.getOptionReferenceList().listIterator();
- while (optRefIter.hasNext()) {
- OptionReference optRef = (OptionReference)optRefIter.next();
- subId = id + "." + optRef.getId(); //$NON-NLS-1$
- IOption newOption = newTool.createOption(optRef.getOption(), subId, optRef.getName(), true);
- // Set the option attributes
- newOption.setValue(optRef.getValue());
- newOption.setValueType(optRef.getValueType());
- }
- }
-
- // Process the tools in the configuration, adding them to the toolchain
- // Tools for a configuration are stored in the enclosing target, so getting
- // the tools for the configuration ultimately gets them from the enclosing target
- ITool[] configTools = configV2.getTools();
- for (int i = 0; i < configTools.length; ++i) {
- ITool tool = configTools[i];
- // If tool references encountered, they have already been processed, above,
- // so ignore them now
- if (!(tool instanceof ToolReference)) {
- // See if the toolchain already has a tool with a SuperClass that has an id
- // equal to the tool that we are considering adding to the toolchain; if so,
- // don't add it
- // This case arises when we have added a tool to the toolchain because
- // we processed a ToolReference (above) that references this tool
- // The original tool referenced in the ToolReference becomes the SuperClass
- // of the tool that is created because of the ToolReference
- boolean found = false;
- ITool[] tools = toolChain.getTools();
- ITool currentTool;
- ITool supercurrentTool;
- for (int j = 0; j < tools.length; ++j) {
- currentTool = tools[j];
- supercurrentTool = currentTool.getSuperClass();
- if (supercurrentTool != null) {
- if (supercurrentTool.getId() == tool.getId()) {
- found = true;
- // If this tool was already added to the toolchain because of a
- // ToolReference, then we disconnent this redundant
- // tool from the target by setting the parent to null
- ((Tool)tool).setToolParent(null);
- break;
- }
- }
- }
-
- if (!found)
- // This tool is not in the toolchain yet, so add it to the toolchain
- ((ToolChain)toolChain).addTool((Tool)tool);
-
- }
- }
- // Normalize the outputextensions list by adding an empty string for each tool
- // which did not have an explicit output file extension specified
- ((ToolChain)toolChain).normalizeOutputExtensions();
- }
- }
-
- /*
- * A target element may contain toolReference elements. These get applied to all of the configurations
- * of the target. The method adds the list of this target's local tool references to the passed in vector.
- */
- public void addTargetToolReferences(Vector toolRefs) {
- toolRefs.addAll(getLocalToolReferences());
- if (parent != null) {
- Target targetParent = (Target)parent;
- targetParent.addTargetToolReferences(toolRefs);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getCreatedProjectType()
- */
- public ProjectType getCreatedProjectType() {
- return createdProjectType;
- }
-
-}
+/**********************************************************************
+ * 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.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 java.util.Vector;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+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.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Platform;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class Target extends BuildObject implements ITarget {
+ private static final String EMPTY_STRING = new String();
+ private static final IConfigurationV2[] emptyConfigs = new IConfigurationV2[0];
+ private String artifactName;
+ private String binaryParserId;
+ private String cleanCommand;
+ private List configList;
+ private Map configMap;
+ private String defaultExtension;
+ private Map depCalculatorsMap;
+ private String errorParserIds;
+ private String extension;
+ private boolean isAbstract = false;
+ private boolean isDirty = false;
+ private boolean isTest = false;
+ private String makeArguments;
+ private String makeCommand;
+ private IResource owner;
+ private ITarget parent;
+ private boolean resolved = true;
+ private List targetArchList;
+ private List targetOSList;
+ private List toolList;
+ private Map toolMap;
+ private List toolReferences;
+ private ProjectType createdProjectType;
+
+ /**
+ * This constructor is called to create a target defined by an extension point in
+ * a plugin manifest file.
+ *
+ * @param element
+ */
+ public Target(IManagedConfigElement element) {
+ // setup for resolving
+ ManagedBuildManager.putConfigElement(this, element);
+ resolved = false;
+
+ // id
+ setId(element.getAttribute(ID));
+
+ // hook me up
+ ManagedBuildManager.addExtensionTarget(this);
+
+ // Get the target name
+ setName(element.getAttribute(NAME));
+
+ // Get the name of the build artifact associated with target (usually
+ // in the plugin specification).
+ artifactName = element.getAttribute(ARTIFACT_NAME);
+
+ // Get the ID of the binary parser
+ binaryParserId = element.getAttribute(BINARY_PARSER);
+
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+
+ // Get the default extension
+ defaultExtension = element.getAttribute(DEFAULT_EXTENSION);
+
+ // isAbstract
+ isAbstract = ("true".equals(element.getAttribute(IS_ABSTRACT))); //$NON-NLS-1$
+
+ // Is this a test target
+ isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
+
+ // Get the clean command
+ cleanCommand = element.getAttribute(CLEAN_COMMAND);
+
+ // Get the make command
+ makeCommand = element.getAttribute(MAKE_COMMAND);
+
+ // Get the make arguments
+ makeArguments = element.getAttribute(MAKE_ARGS);
+
+ // Get the comma-separated list of valid OS
+ String os = element.getAttribute(OS_LIST);
+ if (os != null) {
+ targetOSList = new ArrayList();
+ String[] osTokens = os.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osTokens.length; ++i) {
+ targetOSList.add(osTokens[i].trim());
+ }
+ }
+
+ // Get the comma-separated list of valid Architectures
+ String arch = element.getAttribute(ARCH_LIST);
+ if (arch != null) {
+ targetArchList = new ArrayList();
+ String[] archTokens = arch.split(","); //$NON-NLS-1$
+ for (int j = 0; j < archTokens.length; ++j) {
+ targetArchList.add(archTokens[j].trim());
+ }
+ }
+
+ // Load any tool references we might have
+ IManagedConfigElement[] toolRefs = element.getChildren(IConfigurationV2.TOOLREF_ELEMENT_NAME);
+ for (int k = 0; k < toolRefs.length; ++k) {
+ new ToolReference(this, toolRefs[k]);
+ }
+ // Then load any tools defined for the target
+ IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
+ for (int m = 0; m < tools.length; ++m) {
+ ITool newTool = new Tool(this, tools[m]);
+ // Add this tool to the target, as this is not done in the constructor
+ this.addTool(newTool);
+ }
+ // Then load the configurations which may have tool references
+ IManagedConfigElement[] configs = element.getChildren(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
+ for (int n = 0; n < configs.length; ++n) {
+ new ConfigurationV2(this, configs[n]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Set the resource that owns the target.
+ *
+ * @param owner
+ */
+ protected Target(IResource owner) {
+ this.owner = owner;
+ }
+
+ /**
+ * Create a copy of the target specified in the argument,
+ * that is owned by the owned by the specified resource.
+ *
+ * @param owner
+ * @param parent
+ */
+ public Target(IResource owner, ITarget parent) {
+ // Make the owner of the target the project resource
+ this(owner);
+
+ // Copy the parent's identity
+ this.parent = parent;
+ int id = ManagedBuildManager.getRandomNumber();
+ setId(owner.getName() + "." + parent.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
+ setName(parent.getName());
+ setArtifactName(parent.getArtifactName());
+ this.binaryParserId = parent.getBinaryParserId();
+ this.errorParserIds = parent.getErrorParserIds();
+ this.defaultExtension = parent.getArtifactExtension();
+ this.isTest = parent.isTestTarget();
+ this.cleanCommand = parent.getCleanCommand();
+
+ // Hook me up
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
+ buildInfo.addTarget(this);
+ }
+
+ /**
+ * Create target from project file.
+ *
+ * @param buildInfo
+ * @param element
+ */
+ public Target(ManagedBuildInfo buildInfo, Element element) {
+ this(buildInfo.getOwner());
+
+ // id
+ setId(element.getAttribute(ID));
+
+ // hook me up
+ buildInfo.addTarget(this);
+
+ // name
+ setName(element.getAttribute(NAME));
+
+ // Get the name of the build artifact associated with target (should
+ // contain what the user entered in the UI).
+ artifactName = element.getAttribute(ARTIFACT_NAME);
+
+ // Get the overridden extension
+ if (element.hasAttribute(EXTENSION)) {
+ extension = element.getAttribute(EXTENSION);
+ }
+
+ // parent
+ String parentId = element.getAttribute(PARENT);
+ if (parentId != null)
+ parent = ManagedBuildManager.getTarget(null, parentId);
+
+ // isAbstract
+ if ("true".equals(element.getAttribute(IS_ABSTRACT))) //$NON-NLS-1$
+ isAbstract = true;
+
+ // Is this a test target
+ isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
+
+ // Get the clean command
+ if (element.hasAttribute(CLEAN_COMMAND)) {
+ cleanCommand = element.getAttribute(CLEAN_COMMAND);
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+ }
+
+ // Get the make command and arguments
+ if (element.hasAttribute(MAKE_COMMAND)) {
+ makeCommand = element.getAttribute(MAKE_COMMAND);
+ }
+ if(element.hasAttribute(MAKE_ARGS)) {
+ makeArguments = element.getAttribute(MAKE_ARGS);
+ }
+
+ Node child = element.getFirstChild();
+ while (child != null) {
+ if (child.getNodeName().equals(IConfigurationV2.CONFIGURATION_ELEMENT_NAME)) {
+ new ConfigurationV2(this, (Element)child);
+ }
+ child = child.getNextSibling();
+ }
+ }
+
+ /**
+ * @param configuration
+ */
+ public void addConfiguration(IConfigurationV2 configuration) {
+ getConfigurationList().add(configuration);
+ getConfigurationMap().put(configuration.getId(), configuration);
+ }
+
+ /**
+ * Adds a tool specification to the receiver. This tool is defined
+ * only for the receiver, and cannot be shared by other targets.
+ *
+ * @param tool
+ */
+ public void addTool(ITool tool) {
+ getToolList().add(tool);
+ getToolMap().put(tool.getId(), tool);
+ }
+
+ /**
+ * Adds a tool reference to the receiver.
+ *
+ * @param toolRef
+ */
+ public void addToolReference(ToolReference toolRef) {
+ getLocalToolReferences().add(toolRef);
+ }
+
+
+ /* (non-Javadoc)
+ * Tail-recursion method that creates a lits of tools and tool reference
+ * walking the receiver's parent hierarchy.
+ *
+ * @param toolArray
+ */
+ private void addToolsToArray(Vector toolArray) {
+ if (parent != null) {
+ ((Target)parent).addToolsToArray(toolArray);
+ }
+
+ // Add the tools from out own list
+ toolArray.addAll(getToolList());
+
+ // Add local tool references
+ toolArray.addAll(getLocalToolReferences());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration(org.eclipse.cdt.core.build.managed.IConfigurationV2)
+ */
+ public IConfigurationV2 createConfiguration(IConfigurationV2 parent, String id) {
+ isDirty = true;
+ return new ConfigurationV2(this, parent, id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration()
+ */
+ public IConfigurationV2 createConfiguration(String id) {
+ return new ConfigurationV2(this, id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getArtifactExtension()
+ */
+ public String getArtifactExtension() {
+ // Has the user changed the extension for this target
+ if (extension != null) {
+ return extension;
+ }
+ // If not, then go through the default extension lookup
+ if (defaultExtension == null) {
+ // Ask my parent first
+ if (parent != null) {
+ return parent.getArtifactExtension();
+ } else {
+ return EMPTY_STRING;
+ }
+ } else {
+ return defaultExtension;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#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.managedbuilder.core.ITarget#getBinaryParserId()
+ */
+ public String getBinaryParserId() {
+ if (binaryParserId == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getBinaryParserId();
+ } else {
+ // I'm it and this is not good!
+ return EMPTY_STRING;
+ }
+ }
+ return binaryParserId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#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.core.build.managed.ITarget#getConfiguration()
+ */
+ public IConfigurationV2 getConfiguration(String id) {
+ return (IConfigurationV2)getConfigurationMap().get(id);
+ }
+
+ /* (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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getConfigurations()
+ */
+ public IConfigurationV2[] getConfigurations() {
+ return (IConfigurationV2[])getConfigurationList().toArray(new IConfigurationV2[getConfigurationList().size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getDefaultExtension()
+ */
+ public String getDefaultExtension() {
+ return defaultExtension == null ? EMPTY_STRING : defaultExtension;
+ }
+
+ private Map getDepCalcMap() {
+ if (depCalculatorsMap == null) {
+ depCalculatorsMap = new HashMap();
+ }
+ return depCalculatorsMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ if (errorParserIds == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getErrorParserIds();
+ }
+ }
+ return errorParserIds;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#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 {
+ // If no error parsers are specified by the target, the default is
+ // all error parsers
+ errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
+ }
+ return errorParsers;
+ }
+
+ /* (non-javadoc)
+ * A safe accesor method. It answers the tool reference list in the
+ * receiver.
+ *
+ * @return List
+ */
+ protected List getLocalToolReferences() {
+ if (toolReferences == null) {
+ toolReferences = new ArrayList();
+ }
+ return toolReferences;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getMakeArguments()
+ */
+ public String getMakeArguments() {
+ if (makeArguments == null) {
+ // See if it is defined in my parent
+ if (parent != null) {
+ return parent.getMakeArguments();
+ } else {
+ // No parent and no user setting
+ return new String(""); //$NON-NLS-1$
+ }
+ }
+ return makeArguments;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getMakeCommand()
+ */
+ public String getMakeCommand() {
+ // Return the name of the make utility
+ if (makeCommand == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getMakeCommand();
+ } else {
+ // The user has forgotten to specify a command in the plugin manifest
+ return new String("make"); //$NON-NLS-1$
+ }
+ } else {
+ return makeCommand;
+ }
+ }
+
+ /* (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 (parent != null) {
+ return parent.getName();
+ } else {
+ return new String(""); //$NON-NLS-1$
+ }
+ } else {
+ return name;
+ }
+ }
+
+ /* (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
+ ToolReference 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 = ((Target)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.ITarget#getOwner()
+ */
+ public IResource getOwner() {
+ return owner;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getParent()
+ */
+ public ITarget getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetArchList()
+ */
+ public String[] getTargetArchList() {
+ if (targetArchList == null) {
+ // Ask parent for its list
+ if (parent != null) {
+ return parent.getTargetArchList();
+ } else {
+ // I have no parent and no defined list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) targetArchList.toArray(new String[targetArchList.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetOSList()
+ */
+ public String[] getTargetOSList() {
+ if (targetOSList == null) {
+ // Ask parent for its list
+ if (parent != null) {
+ return parent.getTargetOSList();
+ } else {
+ // I have no parent and no defined filter list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) targetOSList.toArray(new String[targetOSList.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTool(java.lang.String)
+ */
+ public ITool getTool(String id) {
+ ITool result = null;
+
+ // See if receiver has it in list
+ result = (ITool) getToolMap().get(id);
+
+ // If not, check if parent has it
+ if (result == null && parent != null) {
+ result = ((Target)parent).getTool(id);
+ }
+
+ // If not defined in parents, check if defined at all
+ if (result == null) {
+ result = ManagedBuildManager.getExtensionTool(id);
+ }
+
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * A safe accessor method for the list of tools maintained by the
+ * target
+ *
+ */
+ private List getToolList() {
+ if (toolList == null) {
+ toolList = new ArrayList();
+ }
+ return toolList;
+ }
+
+ /* (non-Javadoc)
+ * A safe accessor for the tool map
+ *
+ */
+ private Map getToolMap() {
+ if (toolMap == null) {
+ toolMap = new HashMap();
+ }
+ return toolMap;
+ }
+
+ /* (non-Javadoc)
+ * Returns the reference for a given tool or <code>null</code> if one is not
+ * found.
+ *
+ * @param tool
+ * @return ToolReference
+ */
+ private ToolReference getToolReference(ITool tool) {
+ // See if the receiver has a reference to the tool
+ ToolReference ref = null;
+ if (tool == null) return ref;
+ Iterator iter = getLocalToolReferences().listIterator();
+ while (iter.hasNext()) {
+ ToolReference temp = (ToolReference)iter.next();
+ if (temp.references(tool)) {
+ ref = temp;
+ break;
+ }
+ }
+ return ref;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTools()
+ */
+ public ITool[] getTools() {
+ Vector toolArray = new Vector();
+ addToolsToArray(toolArray);
+ return (ITool[]) toolArray.toArray(new ITool[toolArray.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#hasMakeCommandOverride()
+ */
+ public boolean hasOverridenMakeCommand() {
+ // We answer true if the make command or the flags are different
+ return ((makeCommand != null && !makeCommand.equals(parent.getMakeCommand()))
+ || (makeArguments != null && !makeArguments.equals(parent.getMakeArguments())));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#isAbstract()
+ */
+ public boolean isAbstract() {
+ return isAbstract;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#isDirty()
+ */
+ public boolean isDirty() {
+ // If I need saving, just say yes
+ if (isDirty) {
+ return true;
+ }
+
+ // Iterate over the configurations and ask them if they need saving
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ if (((IConfigurationV2)iter.next()).isDirty()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#isTestTarget()
+ */
+ public boolean isTestTarget() {
+ return isTest;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#needsRebuild()
+ */
+ public boolean needsRebuild(){
+ // Iterate over the configurations and ask them if they need saving
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ if (((IConfigurationV2)iter.next()).needsRebuild()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#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()) {
+ IConfigurationV2 config = (IConfigurationV2)iter.next();
+ if (config.getId().equals(id)) {
+ getConfigurationList().remove(config);
+ getConfigurationMap().remove(id);
+ isDirty = true;
+ break;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#resetMakeCommand()
+ */
+ public void resetMakeCommand() {
+ // Flag target as dirty if the reset actually changes something
+ if (makeCommand != null) {
+ setDirty(true);
+ }
+ makeCommand = null;
+ makeArguments = null;
+ }
+
+ /**
+ *
+ */
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ // parent
+ String parentId = element.getAttribute(PARENT);
+ if (parentId != null) {
+ parent = ManagedBuildManager.getTarget(null, parentId);
+ // should resolve before calling methods on it
+ ((Target)parent).resolveReferences();
+ // copy over the parents configs
+ IConfigurationV2[] parentConfigs = parent.getConfigurations();
+ for (int i = 0; i < parentConfigs.length; ++i)
+ addConfiguration(parentConfigs[i]);
+ }
+
+ // call resolve references on any children
+ Iterator toolIter = getToolList().iterator();
+ while (toolIter.hasNext()) {
+ Tool current = (Tool)toolIter.next();
+ current.resolveReferences();
+ }
+ Iterator refIter = getLocalToolReferences().iterator();
+ while (refIter.hasNext()) {
+ ToolReference current = (ToolReference)refIter.next();
+ current.resolveReferences();
+ }
+ Iterator configIter = getConfigurationList().iterator();
+ while (configIter.hasNext()) {
+ ConfigurationV2 current = (ConfigurationV2)configIter.next();
+ current.resolveReferences();
+ }
+ }
+ }
+
+ /**
+ * Persist receiver to project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ element.setAttribute(ID, getId());
+ element.setAttribute(NAME, getName());
+ if (parent != null)
+ element.setAttribute(PARENT, parent.getId());
+ element.setAttribute(IS_ABSTRACT, isAbstract ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ element.setAttribute(ARTIFACT_NAME, getArtifactName());
+ if (extension != null) {
+ element.setAttribute(EXTENSION, extension);
+ }
+ element.setAttribute(IS_TEST, isTest ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (makeCommand != null) {
+ element.setAttribute(MAKE_COMMAND, makeCommand);
+ } else {
+ // Make sure we use the default
+ }
+
+ if (makeArguments != null) {
+ element.setAttribute(MAKE_ARGS, makeArguments);
+ }
+ if (errorParserIds != null) {
+ element.setAttribute(ERROR_PARSERS, errorParserIds);
+ }
+
+ // Serialize the configuration settings
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ ConfigurationV2 config = (ConfigurationV2) iter.next();
+ Element configElement = doc.createElement(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
+ element.appendChild(configElement);
+ config.serialize(doc, configElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setArtifactExtension(java.lang.String)
+ */
+ public void setArtifactExtension(String extension) {
+ if (extension != null) {
+ this.extension = extension;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#setArtifactName(java.lang.String)
+ */
+ public void setArtifactName(String name) {
+ if (name != null) {
+ artifactName = name;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ // Override the dirty flag here
+ this.isDirty = isDirty;
+ // and in the configurations
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ IConfigurationV2 config = (IConfigurationV2)iter.next();
+ config.setDirty(isDirty);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ if (ids == null) return;
+ String currentIds = getErrorParserIds();
+ if (currentIds == null || !(currentIds.equals(ids))) {
+ errorParserIds = ids;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeArguments(java.lang.String)
+ */
+ public void setMakeArguments(String makeArgs) {
+ if (makeArgs != null && !getMakeArguments().equals(makeArgs)) {
+ makeArguments = makeArgs;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeCommand(java.lang.String)
+ */
+ public void setMakeCommand(String command) {
+ if (command != null && !getMakeCommand().equals(command)) {
+ makeCommand = command;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setRebuildState(boolean)
+ */
+ public void setRebuildState(boolean rebuild) {
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ ((IConfigurationV2)iter.next()).setRebuildState(rebuild);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#updateOwner(org.eclipse.core.resources.IResource)
+ */
+ public void updateOwner(IResource resource) {
+ if (!resource.equals(owner)) {
+ // Set the owner correctly
+ owner = resource;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#convertToProjectType()
+ */
+ public void convertToProjectType() {
+ // Create a ProjectType + Configuration + Toolchain + Builder + TargetPlatform
+ // from the Target
+
+ // The "parent" needs to have been converted already.
+ // Do it now if necessary.
+ ProjectType parentProj = null;
+ if (parent != null) {
+ parentProj = parent.getCreatedProjectType();
+ if (parentProj == null) {
+ parent.convertToProjectType();
+ parentProj = parent.getCreatedProjectType();
+ }
+ }
+ ProjectType projectType = new ProjectType(parentProj, getId(), getName());
+ createdProjectType = projectType;
+ // Set the project type attributes
+ projectType.setIsAbstract(isAbstract);
+ projectType.setIsTest(isTest);
+ // Add children
+ // Add configurations (Configuration -> ToolChain -> Builder -> TargetPlatform)
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ IConfigurationV2 configV2 = (IConfigurationV2)iter.next();
+ if (configV2.getCreatedConfig() != null) continue;
+ // The new config's superClass needs to be the
+ // Configuration created from the ConfigurationV2 parent...
+ IConfiguration configSuperClass = null;
+ IConfigurationV2 parentV2 = configV2.getParent();
+ if (parentV2 != null) {
+ configSuperClass = parentV2.getCreatedConfig();
+ }
+ String id = configV2.getId();
+ String name = configV2.getName();
+ IConfiguration config = projectType.createConfiguration(configSuperClass, id, name);
+ configV2.setCreatedConfig(config);
+ // Set the configuration attributes
+ config.setArtifactName(getArtifactName());
+ config.setArtifactExtension(getArtifactExtension());
+ config.setCleanCommand(getCleanCommand());
+ config.setErrorParserIds(getErrorParserIds());
+ // Create the Tool-chain
+ String subId;
+ String subName;
+ subId = id + ".toolchain"; //$NON-NLS-1$
+ subName = name + ".toolchain"; //$NON-NLS-1$
+ IToolChain toolChain = config.createToolChain(null, subId, subName, true);
+ // Set the tool chain attributes
+ toolChain.setIsAbstract(isAbstract);
+ toolChain.setOSList(getTargetOSList());
+ toolChain.setArchList(getTargetArchList());
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ if (element instanceof DefaultManagedConfigElement) {
+ toolChain.setScannerInfoCollectorElement(((DefaultManagedConfigElement)element).getConfigurationElement());
+ }
+ // Create the Builder
+ subId = id + ".builder"; //$NON-NLS-1$
+ subName = name + ".builder"; //$NON-NLS-1$
+ IBuilder builder = toolChain.createBuilder(null, subId, subName, true);
+ // Set the builder attributes
+ builder.setIsAbstract(isAbstract);
+ builder.setCommand(getMakeCommand());
+ builder.setArguments(getMakeArguments());
+ if (element instanceof DefaultManagedConfigElement) {
+ builder.setBuildFileGeneratorElement(((DefaultManagedConfigElement)element).getConfigurationElement());
+ }
+ // Create the TargetPlatform
+ subId = id + ".targetplatform"; //$NON-NLS-1$
+ subName = name + ".targetplatform"; //$NON-NLS-1$
+ ITargetPlatform targetPlatform = toolChain.createTargetPlatform(null, subId, subName, true);
+ // Set the target platform attributes
+ targetPlatform.setIsAbstract(isAbstract);
+ targetPlatform.setOSList(getTargetOSList());
+ targetPlatform.setArchList(getTargetArchList());
+ // This method is concerned with converting from older project types --> there will be only 0..1 binary parsers to read.
+ targetPlatform.setBinaryParserList(new String[]{getBinaryParserId()});
+
+ // Handle ConfigurationV2 children (ToolReference)
+ // The tools references fetched here are strictly local to the configuration,
+ // so additional work is required to fetch the tool references from the target
+ IToolReference[] configToolRefs = configV2.getToolReferences();
+ // Add the "local" tool references (they are direct children of the target and
+ // its parent targets)
+ Vector targetToolRefs = new Vector();
+ addTargetToolReferences(targetToolRefs);
+ IToolReference[] toolRefs;
+ if (targetToolRefs.size() > 0) {
+ toolRefs = new IToolReference[targetToolRefs.size() + configToolRefs.length];
+ int i;
+ for (i = 0; i < configToolRefs.length; ++i) {
+ toolRefs[i] = configToolRefs[i];
+ }
+ Iterator localToolRefIter = targetToolRefs.iterator();
+ while (localToolRefIter.hasNext()) {
+ toolRefs[i++] = (IToolReference)localToolRefIter.next();
+ }
+ } else {
+ toolRefs = configToolRefs;
+ }
+ for (int i = 0; i < toolRefs.length; ++i) {
+ IToolReference toolRef = toolRefs[i];
+ subId = id + "." + toolRef.getId(); //$NON-NLS-1$
+ // The ToolReference's Tool becomes the newTool's SuperClass
+ ITool newTool = toolChain.createTool(toolRef.getTool(), subId, toolRef.getName(), true);
+ // Set the tool attributes
+ newTool.setToolCommand(toolRef.getRawToolCommand());
+ newTool.setOutputPrefix(toolRef.getRawOutputPrefix());
+ newTool.setOutputFlag(toolRef.getRawOutputFlag());
+ newTool.setOutputExtensions(toolRef.getRawOutputExtensions());
+ // Handle ToolReference children (OptionReference)
+ Iterator optRefIter = toolRef.getOptionReferenceList().listIterator();
+ while (optRefIter.hasNext()) {
+ OptionReference optRef = (OptionReference)optRefIter.next();
+ subId = id + "." + optRef.getId(); //$NON-NLS-1$
+ IOption newOption = newTool.createOption(optRef.getOption(), subId, optRef.getName(), true);
+ // Set the option attributes
+ newOption.setValue(optRef.getValue());
+ newOption.setValueType(optRef.getValueType());
+ }
+ }
+
+ // Process the tools in the configuration, adding them to the toolchain
+ // Tools for a configuration are stored in the enclosing target, so getting
+ // the tools for the configuration ultimately gets them from the enclosing target
+ ITool[] configTools = configV2.getTools();
+ for (int i = 0; i < configTools.length; ++i) {
+ ITool tool = configTools[i];
+ // If tool references encountered, they have already been processed, above,
+ // so ignore them now
+ if (!(tool instanceof ToolReference)) {
+ // See if the toolchain already has a tool with a SuperClass that has an id
+ // equal to the tool that we are considering adding to the toolchain; if so,
+ // don't add it
+ // This case arises when we have added a tool to the toolchain because
+ // we processed a ToolReference (above) that references this tool
+ // The original tool referenced in the ToolReference becomes the SuperClass
+ // of the tool that is created because of the ToolReference
+ boolean found = false;
+ ITool[] tools = toolChain.getTools();
+ ITool currentTool;
+ ITool supercurrentTool;
+ for (int j = 0; j < tools.length; ++j) {
+ currentTool = tools[j];
+ supercurrentTool = currentTool.getSuperClass();
+ if (supercurrentTool != null) {
+ if (supercurrentTool.getId() == tool.getId()) {
+ found = true;
+ // If this tool was already added to the toolchain because of a
+ // ToolReference, then we disconnent this redundant
+ // tool from the target by setting the parent to null
+ ((Tool)tool).setToolParent(null);
+ break;
+ }
+ }
+ }
+
+ if (!found)
+ // This tool is not in the toolchain yet, so add it to the toolchain
+ ((ToolChain)toolChain).addTool((Tool)tool);
+
+ }
+ }
+ // Normalize the outputextensions list by adding an empty string for each tool
+ // which did not have an explicit output file extension specified
+ ((ToolChain)toolChain).normalizeOutputExtensions();
+ }
+ }
+
+ /*
+ * A target element may contain toolReference elements. These get applied to all of the configurations
+ * of the target. The method adds the list of this target's local tool references to the passed in vector.
+ */
+ public void addTargetToolReferences(Vector toolRefs) {
+ toolRefs.addAll(getLocalToolReferences());
+ if (parent != null) {
+ Target targetParent = (Target)parent;
+ targetParent.addTargetToolReferences(toolRefs);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getCreatedProjectType()
+ */
+ public ProjectType getCreatedProjectType() {
+ return createdProjectType;
+ }
+
+}
Index: D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java
===================================================================
--- D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java (revision 11)
+++ D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/internal/core/TargetPlatform.java (working copy)
@@ -1,536 +1,565 @@
-/**********************************************************************
- * 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.Iterator;
-import java.util.List;
-
-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.ITargetPlatform;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class TargetPlatform extends BuildObject implements ITargetPlatform {
-
- private static final String EMPTY_STRING = new String();
-
- // Superclass
- private ITargetPlatform superClass;
- private String superClassId;
- // Parent and children
- private IToolChain parent;
- // Managed Build model attributes
- private String unusedChildren;
- private String errorParserIds;
- private Boolean isAbstract;
- private List osList;
- private List archList;
- private String binaryParserId;
- // Miscellaneous
- private boolean isExtensionTargetPlatform = 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 TargetPlatform defined by an
- * extension point in a plugin manifest file, or returned by a dynamic element provider
- *
- * @param parent The IToolChain parent of this TargetPlatform, or <code>null</code> 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 <code>TargetPlatform</code> based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param parent The <code>IToolChain</code> 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 <code>TargetPlatform</code> based upon an existing TargetPlatform.
- *
- * @param parent The <code>IToolChain</code> 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) {
- // Report error
- ManagedBuildManager.OutputResolveError(
- "superClass", //$NON-NLS-1$
- superClassId,
- "targetPlatform", //$NON-NLS-1$
- getId());
- }
- }
- }
- }
-
-}
+/**********************************************************************
+ * 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.Iterator;
+import java.util.List;
+
+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.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class TargetPlatform extends BuildObject implements ITargetPlatform {
+
+ private static final String EMPTY_STRING = new String();
+
+ // Superclass
+ private ITargetPlatform superClass;
+ private String superClassId;
+ // Parent and children
+ private IToolChain parent;
+ // Managed Build model attributes
+ private String unusedChildren;
+ private String errorParserIds;
+ private Boolean isAbstract;
+ private List osList;
+ private List archList;
+ private List binaryParserList;
+ // Miscellaneous
+ private boolean isExtensionTargetPlatform = 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 TargetPlatform defined by an
+ * extension point in a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The IToolChain parent of this TargetPlatform, or <code>null</code> 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 <code>TargetPlatform</code> based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The <code>IToolChain</code> 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 <code>TargetPlatform</code> based upon an existing TargetPlatform.
+ *
+ * @param parent The <code>IToolChain</code> 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.binaryParserList != null) {
+ binaryParserList = new ArrayList(targetPlatform.binaryParserList); // A shallow copy is O.K. since String is immutable.
+ }
+
+ 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 from a comma-separated list.
+ String bpars = element.getAttribute(BINARY_PARSER);
+ if (bpars!=null) {
+ binaryParserList = new ArrayList();
+ String[] bparsTokens = bpars.split(","); //$NON-NLS-1$
+ for (int j = 0; j < bparsTokens.length; ++j) {
+ binaryParserList.add(bparsTokens[j].trim());
+ }
+ }
+ }
+
+ /* (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());
+ }
+ }
+ }
+
+ // Get the comma-separated list of binaryParserIds
+ if (element.hasAttribute(BINARY_PARSER)) {
+ // Get binary parser Ids from a comma-separated list.
+ String bpars = element.getAttribute(BINARY_PARSER);
+ if (bpars != null) {
+ binaryParserList = new ArrayList();
+ String[] bparsTokens = bpars.split(","); //$NON-NLS-1$
+ for (int j = 0; j < bparsTokens.length; ++j) {
+ binaryParserList.add(bparsTokens[j].trim());
+ }
+ }
+ }
+
+ }
+
+ /**
+ * 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 (binaryParserList != null) {
+ // Create comma-separated list from array ids
+ Iterator bparsIter = osList.listIterator();
+ String listValue = EMPTY_STRING;
+ while (bparsIter.hasNext()) {
+ String current = (String) bparsIter.next();
+ listValue += current;
+ if ((bparsIter.hasNext())) {
+ listValue += ","; //$NON-NLS-1$
+ }
+ }
+ element.setAttribute(OS_LIST, listValue);
+ }
+
+ 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[] getBinaryParserList() {
+ if (binaryParserList == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getBinaryParserList();
+ } else {
+ return new String[0];
+ }
+ }
+ return (String[]) binaryParserList.toArray(new String[binaryParserList.size()]);
+ }
+
+ /* (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 setBinaryParserList(String[] ids) {
+ if (binaryParserList == null) {
+ binaryParserList = new ArrayList();
+ } else {
+ binaryParserList.clear();
+ }
+ for (int i = 0; i < ids.length; i++) {
+ binaryParserList.add(ids[i]);
+ }
+ 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) {
+ // Report error
+ ManagedBuildManager.OutputResolveError(
+ "superClass", //$NON-NLS-1$
+ superClassId,
+ "targetPlatform", //$NON-NLS-1$
+ getId());
+ }
+ }
+ }
+ }
+
+}
Index: D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java
===================================================================
--- D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java (revision 11)
+++ D:/Projekt/RTP/Work/org.eclipse.cdt.managedbuilder.core/src-mngbuildcore/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java (working copy)
@@ -1,423 +1,424 @@
-/**********************************************************************
- * 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 <code>IProject</code> 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());
- info.setValid(true);
- }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();
-
- while (parent != null) {
- String parentId = parent.getId();
- if(parentId.equals(toolId))
- break;
- parent = parent.getSuperClass();
- }
- if(parent == null)
- 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) { // Ignore options that don't have a match
- 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$
- }
- }
- }
-}
-
+/**********************************************************************
+ * 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 <code>IProject</code> 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());
+ info.setValid(true);
+ }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);
+ }
+ // This method is concerned with updating from older (2.0) project types --> there will be only a single binary parser.
+ targetPlatform.setBinaryParserList(new String[]{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();
+
+ while (parent != null) {
+ String parentId = parent.getId();
+ if(parentId.equals(toolId))
+ break;
+ parent = parent.getSuperClass();
+ }
+ if(parent == null)
+ 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) { // Ignore options that don't have a match
+ 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$
+ }
+ }
+ }
+}
+