[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [cdt-dev] How to programmatically setup a preprocessor symbol ?
|
- From: "Dmitry Smirnov" <divis1969@xxxxxxxxx>
- Date: Wed, 5 Nov 2008 16:39:03 +0300
- Delivered-to: cdt-dev@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=ni2ye/wzh0Y1R7YQfjDH627kaPYKDbjXiZw+yFXUgV8=; b=pahXM+IfZsvSV4ONYZrOHFgwVt2c2gy8bONEz09FN2UucdRBrIqGE4kpJSL13LcyVL BdNqnxgHxjTBVpu0zx6mrJLdvEgy0gjfn1h0LSd00keCCecu95XrUpfkSDhgeT9VNkvH DlHvgfmCRwPbutPWeBkkATX9a2vUqUwR4gzaQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=gi7T1kUBTjQv4aCdgniRiVYJq2NOIL7wKglBw0OOQFzW9maur1Cqm7CbxM2+8XeTV+ NsZLD/nYfMCimlfAE/wzHYEB+0BBKX0psk8vAFRhOlDgZ0dvv7UCAcRY22qr/Bsf83Px B7tJnw9nWsH19XNz/4hk6pKaB74DoAzoGKREM=
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]);
}