Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Add a custom toolchain to the Autotools CDT plugin

Hello Jeff,

Le 04/03/2013 19:22, Jeff Johnston a écrit :
The code in AutotoolsBuildWizard is specificially looking for the
Autotools core toolchain id and skipping if it is not found.  Perhaps,
you can extend the code to work for other toolchain ids such as yours or
at least confirm if adding a check for your id solves the problem.

Thanks for your fast reply!

I changed a little bit the code of the AutotoolsBuildWizard class in order to be able to see my new Autotools toolchain[1][2]. See the attached patch for details.

So now I am able to create an Autotools project with my toolchain, but as you can see on the screenshot[3] I did, I see the "Invoke Autotools" menu but all the items in this menu are disabled (Invoke aclocal, Invoke autoconf, etc.)

Do you have an idea, why these menus are not active ?

Thanks for your help,
Mélanie

[1]http://bit.ly/Z737CO
[2]http://bit.ly/YZ2pc2
[3]http://bit.ly/Zd8F22
>From 495f28e8360ea8d014bdf3ffd1e6787c613944b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A9lanie=20Bats?= <melanie.bats@xxxxxxx>
Date: Wed, 6 Mar 2013 22:00:05 +0100
Subject: [PATCH] Update AutotoolsBuildWizard to show other Autotools
 toolchains

---
 .../autotools/ui/wizards/AutotoolsBuildWizard.java |   74 +++++++++++++++++---
 1 file changed, 63 insertions(+), 11 deletions(-)

diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java
index 60de20c..c4b02a5 100644
--- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java
+++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java
@@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.autotools.ui.wizards;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.SortedMap;
 
@@ -20,9 +21,12 @@ import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyManager;
 import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
 import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
 import org.eclipse.cdt.managedbuilder.core.BuildListComparator;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.cdt.managedbuilder.core.IProjectType;
 import org.eclipse.cdt.managedbuilder.core.IToolChain;
 import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.ProjectType;
 import org.eclipse.cdt.managedbuilder.ui.wizards.AbstractCWizard;
 import org.eclipse.cdt.managedbuilder.ui.wizards.MBSWizardHandler;
 import org.eclipse.cdt.ui.newui.CDTPrefUtil;
@@ -32,6 +36,7 @@ import org.eclipse.jface.wizard.IWizard;
 /**
  *
  */
+@SuppressWarnings("restriction")
 public class AutotoolsBuildWizard extends AbstractCWizard {
 	public static final String OTHERS_LABEL = AutotoolsWizardMessages.getResourceString("AutotoolsBuildWizard.1"); //$NON-NLS-1$
 	public static final String AUTOTOOLS_PROJECTTYPE_ID = "org.eclipse.linuxtools.cdt.autotools.core.projectType"; //$NON-NLS-1$
@@ -43,8 +48,22 @@ public class AutotoolsBuildWizard extends AbstractCWizard {
 	public static final String AUTOTOOLS_TOOLCHAIN_ID = "org.eclipse.linuxtools.cdt.autotools.core.toolChain"; //$NON-NLS-1$
 	
 	/**
+	 * Get all the project types that extends the autotools project type.
+	 */
+	private Map<IProjectType, AutotoolsBuildWizardHandler> autotoolsProjectTypes = new HashMap<IProjectType, AutotoolsBuildWizardHandler>();
+	/**
+	 * The autotools build wizard handler.
+	 */
+	private AutotoolsBuildWizardHandler autotoolsBuildWizardHandler;
+	/**
+	 * The autotools project type.
+	 */
+	private IProjectType autotoolsProjectType;
+	 
+	/**
 	 * Creates and returns an array of items to be displayed 
 	 */
+	@SuppressWarnings("restriction")
 	public EntryDescriptor[] createItems(boolean supportedOnly, IWizard wizard) {
 		IBuildPropertyManager bpm = ManagedBuildManager.getBuildPropertyManager();
 		IBuildPropertyType bpt = bpm.getPropertyType(MBSWizardHandler.ARTIFACT);
@@ -80,20 +99,53 @@ public class AutotoolsBuildWizard extends AbstractCWizard {
 				h.addTc(t);
 			}
 
-			String pId = null;
-			if (CDTPrefUtil.getBool(CDTPrefUtil.KEY_OTHERS)) {
-				if (oldsRoot == null) {
-					oldsRoot = new EntryDescriptor(OTHERS_LABEL, null, OTHERS_LABEL, true, null, null);
-					items.add(oldsRoot);
+			// Get the autotools project type and build wizard handler
+			if (AUTOTOOLS_PROJECTTYPE_ID.equals(pt.getId())) {
+				autotoolsBuildWizardHandler = h;
+				autotoolsProjectType = pt;
+			} else {
+				// Keep the other autotools toolchains in order to register them
+				// into the default autotools project type later
+				autotoolsProjectTypes.put(pt, h);
+			}
+		}
+		
+		// Register all the autotools toolchains in the default autotools project type
+		for (IProjectType projectType : autotoolsProjectTypes.keySet()) {
+			AutotoolsBuildWizardHandler h = autotoolsProjectTypes
+					.get(projectType);
+			for (IToolChain tc : h.getToolChains().values()) {
+				IConfiguration tcConfig = null;
+				for (IConfiguration config : projectType.getConfigurations()) {
+					if (tc.equals(config.getToolChain()))
+						tcConfig = config;
 				}
-				pId = oldsRoot.getId();
-			} else { // do not group to <Others>
-			pId = null;
+				// Add the new configurations
+				if (autotoolsProjectType instanceof ProjectType
+						&& tcConfig instanceof Configuration)
+					((ProjectType) autotoolsProjectType)
+							.addConfiguration((Configuration) tcConfig);
+				// Add the new toolchain
+				autotoolsBuildWizardHandler.addTc(tc);
 			}
-
-			if (h.getToolChainsCount() > 0)
-				items.add(new EntryDescriptor(pt.getId(), pId, pt.getName(), true, h, null));
 		}
+		
+		String pId = null;
+		if (CDTPrefUtil.getBool(CDTPrefUtil.KEY_OTHERS)) {
+			if (oldsRoot == null) {
+				oldsRoot = new EntryDescriptor(OTHERS_LABEL, null,
+						OTHERS_LABEL, true, null, null);
+				items.add(oldsRoot);
+			}
+			pId = oldsRoot.getId();
+		} else { // do not group to <Others>
+			pId = null;
+		}
+
+		// Add the autotools project type
+		items.add(new EntryDescriptor(autotoolsProjectType.getId(), pId,
+				autotoolsProjectType.getName(), true,
+				autotoolsBuildWizardHandler, null));
 
 		return (EntryDescriptor[])items.toArray(new EntryDescriptor[items.size()]);
 	}
-- 
1.7.9.5


Back to the top