Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] How programatically add/set/change options to amanagedbuild project?

Hi Oliver,

The problem in your code is that you are using the
option.getOptionHolder() to obtain the option holder:

ManagedBuildManager.setOption(conf, ->option.getOptionHolder()<-,
option, value);

which is not correct in all cases.
The set of options that the holder contains is composed of the holder's
options and the non-overloaded options of all holder's super-classes.
The call to the option.getOptionHolder() for the latter options will
return the holder's supper-class that actually contains that option
rather than the holder that your configuration contains.

You should change your code in the following way:

IHoldsOptions holder = getHolder(conf, "GCC C++ Compiler"); //obtain the
required holder the configuration contains
IOption option  = getOption(holder, "Include paths(-I)"); //obtain the
required option the given holder contains

ManagedBuildManager.setOption(conf, holder, option, value);

Also note that the ManagedBuildManager.get/setSelectedConfiguration()
methods specify the configuration currently selected in UI rather than
the one used in the project build.
To specify the configuration to be used for building use the
ManagedBuildManager.getBuildInfo(project).get/setDefaultConfiguration()
methods.

Regards,
Mikhail


-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
On Behalf Of Olivier Corbun
Sent: Friday, November 11, 2005 12:12 AM
To: cdt-dev@xxxxxxxxxxx
Subject: RE: [cdt-dev] How programatically add/set/change options to
amanagedbuild project?

Hi there,

I have tried to do the same with mixed success. It works perfectly if
the .cdtbuild file has already been edited with a <listOptionValue .../>
under <option>. But if I take a brand new Managed C++ project with an
untouched .cdtbuild file, then the following code stops working.
Instead,
I can see two lists of "Include paths (-I)" in the Properties GUI for
ALL
managed CDT projects and the .cdtbuild file remains unchanged!
weird.

IConfiguration conf =
ManagedBuildManager.getSelectedConfiguration(project);
IOption option  = getOption(conf, "GCC C++ Compiler", "Include paths
(-I)"); // my stuff
ManagedBuildManager.setOption(conf, option.getOptionHolder(), option,
value);
ManagedBuildManager.saveBuildInfo(project, true);

Regards
Olivier


-----Original Message-----
Hi Fredrik,

You should use the ManagedBuildManager.setOption() or
IConfiguration/IResourceConfiguration.setOption() methods for setting
the option values. For more information on how the set option
functionality is implemented see the implementation of those methods.

Use the ManagedBuildManager.saveBuildInfo() method for the build info
serialization in order to avoid the loss of the modifications you made.

Regards,
Mikhail

-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
On Behalf Of Fredrik Attebrant
Sent: Thursday, November 10, 2005 7:45 PM
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] How programatically add/set/change options to a
managedbuild project?

Hi,

I'm working with a plugin that is updating the include paths for a
managed C++ project when some configuration files (external to CDT)
changes.

So far, it has been possible to add include paths that appear in the
project while Eclipse is running, and gets passed down to the compiler
when building, but they are lost when I exit out of Eclipse.

One more funny thing, is that if I have multiple managed C++ projects in

my workspace, then the settings apply to all those projects.

This leads me to suspect that I'm changing something in the default
configurations, which then is shared between all projects, eg. the
include paths for the Debug configuration.

What steps are necessary to make sure that the options changes are
applied only to the selected project?

For options, there is the method isExtensionElement(), but although I
tried creating an option with IHoldsOptions.createOption() with
isExtensionElement=false, I still can't get the option to be
persistantly stored in .cdtbuild for my project.

Any examples on how to do this?

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


Back to the top