Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Creating a CDT project with your own wizard

I have been looking for code on how to create a CDT project using a "custom wizard". I have not found any code to create the .cproject file. So I created a static method (code below) based on the "standard creation wizard" that I would like to become part of the CDT project.
What is the best way to do "deliver" this code?
Best regards

PS I understand that a static method is probably not the way to go from a CDT point of view so adoptions in any way are acceptable to me.I'm only interested int he functionality not the form.

     * This method creates the .cProject file in your project.
* it is intended to be used with newly created projects. Using this method with project that have existed for some time is unknown
* @param project The newly created project that needs a .cproject file.
     * @param toolChain The toolchain to be used with this project
* @param configurationlist The configurations you want to use with this project ("Release", "debug", ...) * @param isManagedBuild When true the project is managed build. Else the project is not (read you have to maintain the makefiles yourself)
     * @param monitor The monitor to follow the process
     * @throws CoreException
public static void setCProjectDescription(IProject project, IToolChain toolChain, String configuration, boolean isManagedBuild, IProgressMonitor monitor) throws CoreException {

ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); ICProjectDescription des = mngr.createProjectDescription(project, false, false); ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
        ManagedProject mProj = new ManagedProject(des);

        String s = "it.baeyens.arduino.core.toolChain.release";
        IToolChain tcs = ManagedBuildManager.getExtensionToolChain(s);

Configuration cfg = new Configuration(mProj, (ToolChain) tcs, ManagedBuildManager.calculateChildId(s, null), configuration);
        IBuilder bld = cfg.getEditableBuilder();
        if (bld != null) {
            if (bld.isInternalBuilder()) {
IConfiguration prefCfg = ManagedBuildManager.getPreferenceConfiguration(false);
                IBuilder prefBuilder = prefCfg.getBuilder();
cfg.changeBuilder(prefBuilder, ManagedBuildManager.calculateChildId(cfg.getId(), null), prefBuilder.getName());
                bld = cfg.getEditableBuilder();
        } else {
        CConfigurationData data = cfg.getConfigurationData();
ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);

ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, cfg, cfgDes);

        mngr.setProjectDescription(project, des);


Back to the top