[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] Creating a CDT project with your own wizard
|
Hi
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
jantje
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
*/
@SuppressWarnings("restriction")
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);
info.setManagedProject(mProj);
monitor.worked(20);
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();
bld.setBuildPath(null);
}
bld.setManagedBuildOn(isManagedBuild);
} else {
System.out.println("Messages.StdProjectTypeHandler_3");
}
cfg.setArtifactName(mProj.getDefaultArtifactName());
CConfigurationData data = cfg.getConfigurationData();
ICConfigurationDescription cfgDes =
des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project,
cfg, cfgDes);
monitor.worked(50);
mngr.setProjectDescription(project, des);
}