Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Programatically create CDT project

Alternatively, have you seend the Project Template Engine? You can find docs in the CDT SDK.

Andrew Gvozdev wrote:
Hi Stephen,

On Fri, Dec 19, 2008 at 1:19 PM, Kennedy, Stephen M (Steve) <stevekennedy@xxxxxxxxxxxxxxxxxx <mailto:stevekennedy@xxxxxxxxxxxxxxxxxx>> wrote:

    We have a plug-in that relies on the code-browsing capabilities of
    CDT.  Currently we have a perl script that pre-creates/populates a
    directory in the workspace and we tell the users to go to the C++
    Project wizard, type the project, select our project type and hit
    Finish.  The users, of course, would like the project creation to be
    part of the magic script also.

    Our project type/tool chain is a stripped down version of the gcc
    toolchain and simply provides an alternative implementation of the
    scannerInfoCollector (reads the settings from a file created by the
    magic script).  We currently don't support "building" with our

    I can create a CDT project but have had no luck in figuring out how
to set the project type/toolchain/configuration to our custom one. I think I need to do what MBSWizardHandler.createProject() does but
    there seems to be several internal classes used in that method.

    Any ideas or pointers would be welcome.

I just posted a few days ago an example of creating Standard Make <> Here is an example for Managed project.
import org.eclipse.cdt.managedbuilder.testplugin.BuildSystemTestHelper;
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;

CoreModel coreModel = CoreModel.getDefault();
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();

String pluginProjectTypeId = "";
String projectName = "testExecutableCygwinGcc";

// Create model project and accompanied descriptions
IProject project = BuildSystemTestHelper.createProject(projectName);
// Create project description
ICProjectDescription des = coreModel.createProjectDescription(project, false);
Assert.assertNotNull("createDescription returned null!", des);

// Create one configuration description
ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
IProjectType type = ManagedBuildManager.getProjectType(pluginProjectTypeId);
Assert.assertNotNull("project type not found", type);

ManagedProject mProj = new ManagedProject(project, type);

IConfiguration cfgs[] = type.getConfigurations();
Assert.assertNotNull("configurations not found", cfgs);
Assert.assertTrue("no configurations found in the project type",cfgs.length>0);

for (IConfiguration configuration : cfgs) {
String id = ManagedBuildManager.calculateChildId(configuration.getId(), null); Configuration config = new Configuration(mProj, (Configuration)configuration, id, false, true, false);
CConfigurationData data = config.getConfigurationData();
Assert.assertNotNull("data is null for created configuration", data);
ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
Assert.assertEquals(2, des.getConfigurations().length);

// Persist project description.
coreModel.setProjectDescription(project, des);


I hope you'll find that instructive.


    Steve Kennedy

    cdt-dev mailing list
    cdt-dev@xxxxxxxxxxx <mailto:cdt-dev@xxxxxxxxxxx>


cdt-dev mailing list


Back to the top