Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Accessing Builder-level Option from Tool-level Option

I'm developing a plugin for Eclipse that extends CDT with a few templates and configuration
options. I have a question regarding the option management in the managed builder.

I need to store one global option applicable to every tool in the toolchain. I also need to access
this option from "local" tool option. Here is how options are defined:

<toolChain
    superClass="cdt.managedbuild.toolchain.gnu.cross.base"
    id="com.plugin.defaultToolchain"
    name="Custom Toolchain">

    <builder
        name="GNU Make builder for Custom Toolchain"
        id="com.plugin.cross.builder"
        superClass="cdt.managedbuild.target.gnu.builder">

        <option
            isAbstract="false"
            id="com.plugin.cross.builder.option.deviceId"
            valueType="string">
        </option>
    </builder>

    <tool
        id="com.plugin.cross.c.compiler"
        isAbstract="false"
        name="Custom GCC Compiler"
        superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">

        <optionCategory
            name="Inferred platform options"
            id="com.plugin.cross.optionGroup.inferredSoftwarePlatformOptions">
        </optionCategory>

        <option
            name="Device-specific flags"
            isAbstract="false"
            category="com.plugin.cross.optionGroup.inferredSoftwarePlatformOptions"
            commandGenerator="com.plugin.builder.PlatformCommandGenerator"
            valueType="string"
            fieldEditor="com.plugin.cross.readonlyFieldEditor"
            id="com.plugin.cross.option.softwarePlatformFlags">
        </option>
    </tool>
</toolChain>

I wanted to keep the option in the builder because it applies to every tool in the toolchain.
Now, every tool has its own command line generator (implementing IOptionCommandGenerator).
>From generateCommand(IOption option), it's possible to access toolchain and builder, because
it is known that the option holder of the option argument is the tool defined earlier. Based on the
value of the builder option, tool-specific command line is generated.

ITool tool = (ITool) option.getParent();
IToolChain toolchain = (IToolChain) tool.getParent();
IBuilder builder = toolchain.getBuilder();

IOption deviceIdOption = builder.getOptionBySuperClassId(Activator.PROP_DEVICE_ID);

And here lies the problem: while the option itself exists and is not null, it has no value.
This certainly isn't the case when I access the same option from other places, such as
from a class extending AbstractCBuildPropertyTab.

What can be done to implement such an arrangement? The only alternative I see is to keep
as many copies of the option as there are tools, but I'd like to avoid doing that.

Regards,

Vlad Ivanov


Back to the top