Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] Problems with programmatically setting the compiler and linker options

I think what you're doing is setting the value on the tool's extension meta-object, instead of the tool instance.
 
Try to skip the step where you get the optionHolder for your option...and use the cCompiler itself as the option-holder.
 
- Baltasar
 


From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Mary Ann Belarmino
Sent: Wednesday, November 04, 2009 11:25 AM
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] Problems with programmatically setting the compiler and linker options

Hi,

 

I want to programmatically set the compiler and linker options for a specific project. Below is the code I am using:

 

                               // Compiler option to set: e.g. symbols

                                String[] symbolList = getSymbolsToDefine();

 

            IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(proj);

            IConfiguration defaultConfiguration = buildInfo.getDefaultConfiguration();

            IToolChain toolChain = defaultConfiguration.getToolChain();

ITool[] cCompilers = toolChain.getToolsBySuperClassId("cdt.managedbuild.tool.gnu.c.compiler.mingw.base");

ITool cCompiler = … // obtain from cCompilers

 

            cCompilerSymbolDefOption = cCompiler.getOptionBySuperClassId();

            cCompilerSymbolDefOptionHolder = cCompilerSymbolDefOption.getOptionHolder("gnu.c.compiler.option.preprocessor.def.symbols");

 

ManagedBuildManager.setOption(defaultConfiguration,

                                    cToolListOptionHolder, cToolListOption, symbolList);

               

            ManagedBuildManager.setDefaultConfiguration(proj, defaultConfiguration);

            ManagedBuildManager.saveBuildInfo(proj, true);

 

I do the same thing, i.e. use setOption(), for setting optimization level, debugging level, libraries, … (all compiler & linker options).

 

Problems I see:

 

1.       The options I set are inherited by all open projects, instead of just being applied to the specific project. Worst, new projects I create from then on inherits these options by default.

2.       At the properties GUI, I see the options I have set under “All options”. However, I do not see the values reflected on the individual widgets (e.g. nothing in the Symbols window).

 

Can someone help me with these 2 issues? Is there a different way of doing this?

 

Thanks a lot,

Mary Ann


Back to the top