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
    toolchain.

    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 http://www.eclipse.org/newsportal/article.php?id=17773&group=eclipse.tools.cdt#17773 <http://www.eclipse.org/newsportal/article.php?id=17773&group=eclipse.tools.cdt#17773> 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 = "cdt.managedbuild.target.gnu.cygwin.exe";
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);
info.setManagedProject(mProj);

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);

project.close(null);
}

I hope you'll find that instructive.

Thanks,
Andrew

    Thanks,
    Steve Kennedy


    _______________________________________________
    cdt-dev mailing list
    cdt-dev@xxxxxxxxxxx <mailto:cdt-dev@xxxxxxxxxxx>
    https://dev.eclipse.org/mailman/listinfo/cdt-dev



------------------------------------------------------------------------

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


--
Subs


Back to the top