Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » adding toolchain to c project created by plugin(Unable to add toolchain to c project created by plugin)
adding toolchain to c project created by plugin [message #872701] Wed, 16 May 2012 16:21
tony burton is currently offline tony burtonFriend
Messages: 26
Registered: April 2012
Location: France
Junior Member
I am trying to create a cproject programmatically and my plugin works, except that I cannot specify the toolchain to be used. My code is the following:

public static IProject createCDTProject(String projectName, String pathInWorkspace, String[] configurationIds) throws OperationCanceledException, CoreException {
		CCorePlugin cdtCorePlugin = CCorePlugin.getDefault();
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		IWorkspaceRoot root = workspace.getRoot();

		IProject project = root.getProject(projectName);
		IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);

		IProjectDescription prjDescription = workspace.newProjectDescription(projectName);
		IPath absoluteLocation = root.getLocation().append(pathInWorkspace);
		//IPath absoluteLocation = URIUtil.toPath(pathInWorkspace);
		if (configurationIds!=null && configurationIds.length>0) {
			ICProjectDescriptionManager prjDescManager = cdtCorePlugin.getProjectDescriptionManager();


			ICProjectDescription icPrjDescription = prjDescManager.createProjectDescription(project, false);
			ICConfigurationDescription baseConfiguration = cdtCorePlugin.getPreferenceConfiguration("org.eclipse.cdt.managedbuilder.core.configurationDataProvider");
			for (String cfgId : configurationIds) {
				icPrjDescription.createConfiguration(cfgId, cfgId+" Name", baseConfiguration);
			prjDescManager.setProjectDescription(project, icPrjDescription);
		project = cdtCorePlugin.createCDTProject(prjDescription, project, new NullProgressMonitor());
		IToolChain[] tcs = ManagedBuildManager.getRealToolChains();
		ToolChain tc=null;
		for (int i=0; i<tcs.length; i++) {
			String str = tcs[i].getName();
			if(str.contains("Cross GCC")) {
				tc = (ToolChain) tcs[i];
		 // Create configuration description
		ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
		IProjectType type = ManagedBuildManager.getProjectType("");

		ManagedProject mProj = new ManagedProject(project, type);
//here I try to specify the toolchain:
		IConfiguration cfg = new Configuration(mProj, tc, "cdt.managedbuild.config.gnu.cross.exe", "GNU Toolchain");
		// add C Nature...
    CProjectNature.addCNature(project, null);
    ICProjectDescription des = CoreModel.getDefault().createProjectDescription(project, false);

		return project;

Could anybody please point out what is going wrong?

Thanks in advance,

Previous Topic:HELP: Debugger often unresponsive - came from nowhere
Next Topic:Need Eclipse CDT to Implement Interface
Goto Forum:

Current Time: Sat Jun 23 06:44:20 GMT 2018

Powered by FUDForum. Page generated in 0.01840 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top