carbidesdk/com.nokia.carbide.cpp.sdk.doc.user/html/tasks/sdk_getprojinfo.htm
author Deepak Modgil <Deepak.Modgil@Nokia.com>
Fri, 03 Apr 2009 23:33:03 +0100
changeset 0 fb279309251b
child 130 825355d51766
permissions -rw-r--r--
DP tools release version Revision: 200912
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     2
<html xmlns="http://www.w3.org/1999/xhtml">
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     3
<head>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     4
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     5
<title>Getting Carbide Project Information</title>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     6
<link rel="StyleSheet" href="../../book.css" type="text/css"/>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     7
</head>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     8
<body bgcolor="#FFFFFF">
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     9
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    10
<h2>Getting Carbide Project Information</h2>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    11
<p>The following example code fragment demonstrates the use of Carbide.c++ APIs to access Carbide project information.</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    12
<p class="note"><strong>NOTE</strong> There are two perspective IDs that may be useful when using the Carbide APIs. The perspective ID for  the Carbide.c++ perspective is <strong>com.nokia.carbide.cpp.CarbideCppPerspective</strong> and for the Debug view it is <strong>org.eclipse.debug.ui.DebugPerspective</strong>.</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    13
<p>Retrieving Carbide.c++ project information starts with knowing your org.eclipse.core.resources.<STRONG>IProject</STRONG> resource and retrieving the com.nokia.carbide.cdt.builder.<STRONG>ICarbideBuildManager</STRONG> instance:</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    14
<p class="listing">ICarbideBuildManager buildMgr = ICarbideBuilderPlugin.getBuildManager();</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    15
<p>Now with your IProject resource you can grab the actual Carbide   project in com.nokia.carbide.cdt.builder.<STRONG>ICarbideProjectInfo</STRONG>:</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    16
<p class="listing">// Assumes IProject (project) is known.<br>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    17
  ICarbideProjectInfo cpi = null;<br>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    18
  if (buildMgr.isCarbideProject(project)){<br>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    19
  &nbsp;&nbsp;// check to make sure this is a Carbide project<br>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    20
  &nbsp;&nbsp;cpi = buildMgr.getProjectInfo(project);<br>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    21
}</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    22
<p>Once you get the ICarbideProjectInfo object you can   access all the project data, such as environment variables and SIS builder   information via the com.nokia.carbide.cdt.builder.<STRONG>ICarbideBuildConfiguration</STRONG> interface. You can retrieve either the default configuration or the full   list:</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    23
<p class="listing">// Get the default build configuration<br>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    24
  ICarbideBuildConfiguration defaultConfig = cpi.getDefaultConfiguration();<br>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    25
// Get all configurations for this project.<br>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    26
List&lt;ICarbideBuildConfiguration&gt; configList = cpi.getBuildConfigurations();</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    27
<p>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. </p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    28
<h3>Retrieving INF/MMP Project Information</h3>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    29
<p>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 things like setting up the source indexer   and displaying the visual INF and MMP editors. The com.nokia.carbide.cdt.builder.<STRONG>EpocEngineHelper</STRONG> class is a good first stop to retrieve this information. For example, if you want   to get all the source files in the first MMP file:</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    30
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    31
<PRE>// ...assumes ICarbideProjectInformation (cpi) is known.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    32
List&lt;IPath&gt; mmpPaths = EpocEngineHelper.getMMPFilesForProject(cpi);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    33
// array length check omitted for brevity....
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    34
List&lt;IPath&gt; srcFilesTest = EpocEngineHelper.getSourceFilesForConfiguration(defultConfig, mmpPaths.get(0));</PRE>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    35
<h3>SDK Management</h3>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    36
<p>Each SDK entry in devices.xml is analogous to a   com.nokia.carbide.cpp.sdk.core.<STRONG>ISymbianSDK</STRONG> object. If you want to get the entire list of ISymbianSDK   objects (same list and properties from the SDK Preferences page) you   simply invoke:</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    37
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    38
<PRE>ISDKManager sdkMgr = SDKCorePlugin.getSDKManager();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    39
List&lt;ISymbianSDK&gt; sdkList = sdkMgr.getSDKList();</PRE>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    40
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    41
<p>Now you can iterate the list and get whatever information you want out of the   installed SDKs. For example, using Java 5 iterators we can get the EPOCROOT   values of all the SDKs:</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    42
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    43
<PRE>for (ISymbianSDK currSDK : sdkList){
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    44
   String epocRootStr = currSDK.getEPOCROOT();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    45
}</PRE>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    46
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    47
<h3>Reading MMP Statements with the EpocEngine and IMMPData</h3>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    48
<p>This topic demonstrates how you can read the MMP data for any build   configuration (ICarbideBuildConfiguration). The main interface for retrieving   MMP data is <strong>com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPData</strong>. Once you get   access to this interface you can learn anything you want about a particular MMP file.</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    49
<p><strong>Prerequisite:</strong> All MMP and bld.inf parsing requires a dependency to the plugin   <strong>com.nokia.carbide.cpp.epoc.engine</strong>.</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    50
<p>Typically most keywords of interest are either single string settings   (<span class="code">TARGETTYPE</span>, <span class="code">TARGET</span>, <span class="code">EPOCSTACKSIZE</span>) or list of settings (<span class="code">MACRO</span>, <span class="code">CAPABILITY</span>,   <span class="code">LANG</span>). Other types can be directly retrieved from IMMPData routines. Check the   API documentation for specifics.</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    51
<p>The example provided simply iterates through all the MMP files of a   particular build configuration and grabs a list value and single item setting.   You'll need to get the particular MMP file you are interested in. Play around   with the IMMPData object in the run method and you can quickly get the idea.</p>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    52
<PRE class="listing">// Assumes buildConfig (ICarbideBuildConfiguration) is known
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    53
for (IPath mmpPath : EpocEngineHelper.getMMPFilesForBuildConfiguration(buildConfig)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    54
     Object data = EpocEnginePlugin.runWithMMPData(mmpPath,  new
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    55
                              DefaultMMPViewConfiguration(buildConfig.getCarbideProject().getProject(),
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    56
                              buildConfig, new AcceptedNodesViewFilter()),  new MMPDataRunnableAdapter() {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    57
                        public Object run(IMMPData mmpData) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    58
                          // Example, getting a keyword as a list of strings
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    59
                          List macros = mmpData.getListArgumentSettings().get(EMMPStatement.MACRO);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    60
                          // The real return value, getting a single argument setting
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    61
                         return mmpData.getSingleArgumentSettings().get(EMMPStatement.TARGETTYPE);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    62
		  	                }   
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    63
      });
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    64
// Make sure to test for and cast to proper Object type!
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    65
String mmpStatement = (String)data;  // Now we should have the TARGETTYPE
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    66
}</PRE>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    67
<div id="footer">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. <br>License: <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></div></div>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    68
</body>
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    69
</html>