Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: [cdt-dev] How to programmatically setup a preprocessor symbol ?

Hi Dmitry,

I really, really appreciate your help. Now I got my symbols applied to the project.
Again thanks for the help.

With friendly regards

Daniel Kasmeroglu


-----Ursprüngliche Nachricht-----
Von: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] Im Auftrag von Dmitry Smirnov
Gesendet: Mittwoch, 5. November 2008 14:39
An: CDT General developers list.
Betreff: Re: [cdt-dev] How to programmatically setup a preprocessor symbol ?

Here is the code I'm using for this (based on posts in this maillist,
CDT newsgroup and unofficial wiki):

	private void configureProject() throws CoreException {
		ICProjectDescriptionManager mngr =
CoreModel.getDefault().getProjectDescriptionManager();
		ICProjectDescription des = mngr.getProjectDescription(project, true);
		ICConfigurationDescription confDes = des.getDefaultSettingConfiguration();

		// Configure include paths
		ICFolderDescription folderDescription =
confDes.getRootFolderDescription(); // or use
getResourceDescription(IResource), or pick one from
getFolderDescriptions()
		ICLanguageSetting[] languageSettings =
folderDescription.getLanguageSettings();

		ICLanguageSettingEntry[] projectDefines = getDefines();

		for(int idx = 0; idx < languageSettings.length; idx++)
		{
			ICLanguageSetting lang = languageSettings[idx];
			lang.setSettingEntries(ICSettingEntry.MACRO, projectDefines);
		}

		des.setActiveConfiguration(confDes);
		des.setCdtProjectCreated();
		mngr.setProjectDescription(project, des, true, null);

    }

	private ICLanguageSettingEntry[] getModelDefines() {
		ArrayList<ICLanguageSettingEntry> defines = new
ArrayList<ICLanguageSettingEntry>();
		Map<String, String> includeList = getComponentDefines();  // This
method returns a map of key/values
		Iterator<Entry<String, String>> iter = includeList.entrySet().iterator();
		while(iter.hasNext())
		{
			Entry<String, String> def = iter.next();
			ICMacroEntry entry =
				(ICMacroEntry)CDataUtil.createEntry(ICLanguageSettingEntry.MACRO,
					def.getKey(), def.getValue(), null, 0);
			defines.add(entry);
		}
		return defines.toArray(new ICLanguageSettingEntry[0]);
	}
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top