|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Problems with programmatically setting the compiler and linker optionsHi, 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 _______________________________________________ cdt-dev mailing list cdt-dev@... https://dev.eclipse.org/mailman/listinfo/cdt-dev |
|
|
RE: Problems with programmatically setting the compiler and linker optionsI 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@... [mailto:cdt-dev-bounces@...] On Behalf Of Mary Ann Belarmino Sent: Wednesday, November 04, 2009 11:25 AM To: cdt-dev@... 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 _______________________________________________ cdt-dev mailing list cdt-dev@... https://dev.eclipse.org/mailman/listinfo/cdt-dev |
|
|
|
|
|
Re: RE: Problems with programmatically setting the compiler and linker options/** * Adds a library file via IOption interface for gnu linker * @param cf the config holding the option * @param libName the name of the library (should be w/o file extension) */ private void addLinkerLib(IConfiguration cf, String libName) { String ext = "o"; ITool cfTool = cf.getToolFromInputExtension(ext); // add to -l (libraries) String optLibsID = "gnu.c.link.option.libs"; IOption libOption = cfTool.getOptionById(optLibsID); String[] libraries = null; try { libraries = libOption.getLibraries(); } catch (BuildException be) { } // add library int len = libraries.length; String newLibraries[] = new String[len + 1]; System.arraycopy(libraries, 0, newLibraries, 0, len); newLibraries[len] = libName; ManagedBuildManager.setOption(cf, cfTool, libOption, newLibraries); } // --------------------------------------------------------------------- // --------------------------------------------------------------------- // --------------------------------------------------------------------- Cheers! Mary Ann Belarmino <MaryAnn.Belarmino@...> hat am 4. November 2009 um 19:34 geschrieben: > Thanks, I tried this and the behavior is still the same. > > >> use the cCompiler itself as the option-holder. > > I think the problem is cCompiler still is the tool object. Can you recommend a way for me to get the tool instance for the given project? > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 4 Nov 2009 11:14:58 -0600 > From: "Belyavsky, Baltasar" <bbelyavsky@...> > Subject: RE: [cdt-dev] Problems with programmatically setting the > compiler and linker options > To: "CDT General developers list." <cdt-dev@...> > Message-ID: > <0554BEF07D437848AF01B9C9B5F0BC5D93BFF5C7@...> > Content-Type: text/plain; charset="us-ascii" > > 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 > > > _______________________________________________ > cdt-dev mailing list > cdt-dev@... > https://dev.eclipse.org/mailman/listinfo/cdt-dev _______________________________________________ cdt-dev mailing list cdt-dev@... https://dev.eclipse.org/mailman/listinfo/cdt-dev |
| Free embeddable forum powered by Nabble | Forum Help |