Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] CoreModel.setProjectDescription() vs ManagedBuildManager.saveBuildInfo()

Title: Change CDT Project Configuration programmatically

Hi all,

 

Oleg recently posted some code fragment on how to set the build command in a project. It used CoreModel.setProjectDescription to save the changes. I just stumbled upon ManagedBuildManager.saveBuildInfo() which seems to work as well, and is more straightforward. Which one is the preferred way, and how are they different?

 

Using ManagedBuildManager:

 

IProject project = ...;
IConfiguration configuration = ManagedBuildManager.getBuildInfo(project).getDefaultConfiguration();
configuration.setBuildCommand("gmake");
configuration.setBuildArguments("-f Makefile.mine");
ManagedBuildManager.saveBuildInfo(project, true);

 

It appears that I can go via projectdescriptions as well, at least the following works too:

 

IProject project = ...;

ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(project);

IConfiguration configuration = ManagedBuildManager.getConfigurationForDescription(projectDescription.getActiveConfiguration());

configuration.setBuildCommand("gmake");

configuration.setBuildArguments("-f Makefile.mine");

CoreModel.getDefault().setProjectDescription(project, projectDescription);

 

Can someone cast some light please how these two ways differ, and which one is better / preferred?

 

Regards,

Andras

 

------

Andras Varga

CTO Simulcraft Inc

www.omnest.com / www.omnetpp.org

 

 

 

 

 


From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Krasilnikov, Oleg
Sent: Wednesday, December 12, 2007 3:39 PM
To: CDT General developers list.
Subject: RE: [cdt-dev] Change CDT Project Configuration programmatically

 

Marko,

 

In brief, procedure looks like follows:

 

IProject project = ...; // I hope you have it 

ICProjectDescription prjd = ...; // I hope you have it 

ICConfigurationDescription cfgd = ...; // I hope you have it 

 

// change your fields

IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgd);

IBuilder bldr = cfg.getEditableBuilder();

String command = ...; // command without parameters

String arguments = ...; // in Property page, user's line is split to cmd and args.

boolean cleanState = ...;

 

bldr.setCommand(command);

bldr.setArguments(arguments);

bldr.setCleanBuildEnable(cleanState);

 

// to save your changes, you need do this (normally called when <OK>/<Apply> pressed) :

 

CoreModel.getDefault().setProjectDescription(project, prjd);


You can find some samples of config setting in CDT Property pages UI.

 

They are located in 2 places:

org.eclipse.cdt.managedbuilder.ui.properties (for MBS-specific settings)

org.eclipse.cdt.ui.newui (for CDT core settings).

 

All classes representing Property pages context have "*Tab" name (ex.: ErrorParsTab.java)

 

In your case, changing build command is performed in

org.eclipse.cdt.managedbuilder.ui.properties/BuilderSettingsTab.java,

and clean build enabling is made on neighbour tab:

org.eclipse.cdt.managedbuilder.ui.properties/BuildBehaviourTab.java,

 

 

 

-----------------------------------
With best regards, Oleg Krasilnikov

 

 

 


From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Tomljenovic Marko (G2/PJ-PMT2)
Sent: Wednesday, December 12, 2007 4:40 PM
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] Change CDT Project Configuration programmatically

Hello guys,

I am trying to configure a Standard Make CDT (4.0.2) project programmatically. I have managed to create a new configuration but now I am stuck on setting the different settings (e.g. build command, enable clean build, ...)

I am really searching for quite a while and I cannot find the solution!

Pls hlp

Greetings Marko T.

--------------------------------------------------------------------
Closed Joint Stock Company Intel A/O
Registered legal address: 125252, Moscow, Russian Federation, 
Chapayevsky Per, 14.
 
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Back to the top