Old blogs

A Quick Tour of the Carbide.c++ SDK APIs

Carbide Plug-Ins - March 16th, 2008 - Written by Tim Kelly

Starting with Carbide.c++ release 1.2 we’ve introduced public APIs for Carbide 3rd party Carbide development. These APIs are also being used by internal Nokia tools teams and other Symbian OS licensees. However, I do occasionally get a technical question from plug-in developers that don’t even know there are APIs to access Carbide project info. So in those cases, a quick start might help to ease into Carbide development.

Help and Examples

The Help is accessed under Carbide Help book topic Carbide.c++ Plug-in Developer Guide. There are a couple of working examples including the leavscan plug-in that come with full sources to get you a quick look at some working code.

Getting Carbide Project Information

Retrieval of Carbide project information starts with knowing your org.eclipse.core.resources.IProject resource and retrieving the com.nokia.carbide.cdt.builder.ICarbideBuildManager instance:

    ICarbideBuildManager buildMgr = ICarbideBuilderPlugin.getBuildManager();

Now with your IProject resource you can grab the actual Carbide project in com.nokia.carbide.cdt.builder.ICarbideProjectInfo:

     // Assumes IProject (project) is known.
ICarbideProjectInfo cpi = null;
if (buildMgr.isCarbideProject(project)){
 // check to make sure this is a Carbide project
cpi = buildMgr.getProjectInfo(project);
}

Once you get ICarbideProjectInfo object you can access all the project data, such as environment variables and SIS builder information via the com.nokia.carbide.cdt.builder.ICarbideBuildConfiguration interface. You can retrieve either the default configuration or the full list:

     // Get the default build configuration
ICarbideBuildConfiguration defultConfig = cpi.getDefaultConfiguration();
// Get all configurations for this project.
List<ICarbideBuildConfiguration> configList = cpi.getBuildConfigurations();

It is important to note that the data retrieved by the ICarbideBuildConfiguration object is what you see in the project properties pages under the Carbide.c++ group. This is separate from the data in the INF and MMP files
which we will discuss next.

Retrieving INF/MMP Project Information

All Carbide build stages, with the exception of the post-link SIS Builder stage get their data from INF and MMP files.
So naturally Carbide needs a way to retrieve and store this data for doing stuff like setting up the source indexer
and displaying the visual INF and MMP editors. The com.nokia.carbide.cdt.builder.EpocEngineHelper class is a good first stop to retrieve this information. For example, if I want to get all the source files in the first MMP file:

    // ...assumes ICarbideProjectInformation (cpi) is known.
List<IPath> mmpPaths = EpocEngineHelper.getMMPFilesForProject(cpi);
// array length check omitted for brevity....
List<IPath> srcFilesTest = EpocEngineHelper.getSourceFilesForConfiguration(defultConfig, mmpPaths.get(0)); 

SDK Management

Each SDK entry in devices.xml is analogous to a com.nokia.carbide.cpp.sdk.core.ISymbianSDK object. If we want to get the entire list of ISymbianSDK objects (same list and properties from the SDK Preferences page) we simply invoke:


ISDKManager sdkMgr = SDKCorePlugin.getSDKManager();
List<ISymbianSDK> sdkList = sdkMgr.getSDKList();

Now we can iterate the list and get whatever information we want out of the installed SDKs.
For example, using Java 5 iterators we can get the EPOCROOT values of all the SDKs:

     for (ISymbianSDK currSDK : sdkList){
String epocRootStr = currSDK.getEPOCROOT();
} 

The Carbide.c++ Plug-in SDK Help is also full of examples for generating your own custom project templates and even UI Designer components. I’ll leave that topic for another time.

About the author Tim Kelly

  • Number of posts: 14

Comments(3)

  1. grajesh wrote

    Hi,
    It is really very useful to me.
    I got the IProject object but isCarbideProject is returning false.How can i convert it to carbide project.
    So that i can access/use all other APIs.

    Thank you..

  2. Anonymous wrote

    Are there any APIs to get IProject or ICarbideProjectInfo using with bld.inf or s60 project path.

  3. Tim Kelly wrote

    @grajesh - You don’t really convert a project to a Carbide project, you need to import it first as a Carbide project. So it sounds like your project is not a Carbide project to begin with.

    @Anonymous - No I don’t think so, if you have the bld.inf path then you can iterate all the projects and get the bld.inf file from the carbide project info and check if the defined project info bld.inf file path is the same.