Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Common toolchain options

> thank you for your responses. I've had a play around, but I'm still not 
> getting this.
> 
> In my example toolchain (attached) I have compiler and link tools. In 
> each there is a string option, Option1, which when I alter in one of the 
> tools, say the compiler, I would like the same Option1 in the other 
> tool, the linker, to reflect this value.
> 
> It seems that this would be a common thing to want to do, although the 
> GNU toolchain doesn't seem to have any shared options.
> 
> So in the EVENT_APPLY part of my ExToolManagedOptionValueHandler() I 
> want to read the changed option value from one tool and apply it to the 
> twin option in the other tool. I imagine there must be a simple approach 
> to this???

In my opinion you should prevent having the same option in multiple
places, might be confusing. That's at least for us the reason we do
not use any shared options in the GUI, instead when for instance the
linker needs a certain compiler setting you can add it in the linkers
command line generator. Another solution might be to make the option
part of the toolchain and refer to that from both compiler as well as
linker.

However, with a bit of guessing you also might try something like:

    public boolean handleValue(IBuildObject buildObj,
            IHoldsOptions holder, IOption option, String extraArgument,
            int event) {
        if ( (event == APPLY) && "compileroption1".equals(extraArgument) ) {
            IConfiguration config = ((IFolderInfo)buildObj).getParent();
            for ( ITool tool : ((IFolderInfo)buildObj).getTools() ) {
                IOption linkeroption = tool.getOptionBySuperClassId("linker.option1");
                if ( linkeroption != null ) {
                    ManagedBuildManager.setOption(config, tool, linkeroption, option.getStringValue());
            }
        }
    }


Back to the top