Skip to main content

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

I set a option with following code for a single configuration(other tools you can get with its id):

    /**
     * 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@xxxxxxxxxxxxx> 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@xxxxxx>
> Subject: RE: [cdt-dev] Problems with programmatically setting the
>         compiler        and linker options
> To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
> Message-ID:
>         <0554BEF07D437848AF01B9C9B5F0BC5D93BFF5C7@xxxxxxxxxxxxxxxxx>
> 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@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev

Back to the top