Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] adding a toolchain with common options to tools

You can use command line generators for the tools in the toolchain that used the shared options.  You can then read the toolchain option value and not have to create these invisible copies in each tool.

@Override

protected String getFlags(ITool tool, String[] flags, String outputName) {

IToolChain toolchain = null;

IBuildObject parent = tool.getParent();

if (parent instanceof IToolChain){

toolchain = (IToolChain)parent;

} else if (parent instanceof ResourceConfiguration) {

toolchain = ((ResourceConfiguration)parent).getBaseToolChain();

}


// get the memory model from the common toolchain options

IOption model = toolchain.getOptionBySuperClassId("my.toolchain.general.model");




From: Ashutosh <ashutoshpal2006@xxxxxxxxx>
Reply-To: "CDT list." <cdt-dev@xxxxxxxxxxx>
Date: Thursday, September 17, 2015 at 2:55 AM
To: "CDT list." <cdt-dev@xxxxxxxxxxx>
Subject: [cdt-dev] adding a toolchain with common options to tools

Hi All,

 

I am adding a toolchain to CDT using the buildDefinitions extension point of the Managed Builder. My toolchain has a few common options that need to be passed to all the downstream tools (i.e. compiler, linker, archiver etc), for example:

 

mycc   --model <MODEL_NAME>

mylink --model <MODEL_NAME>

myar --model <MODEL_NAME>

 

So, here ‘—model’ is such an option. I want to take the input of this option only at a single place in the UI. To achieve this, I added one option (with id my.toolchain.general.model) at the tool-chain level and a corresponding “invisible” option (with id my.toolchain.compiler.model) at the tool level, as you can see in the snippet of the plugin.xml:

      <toolChain

            id="my.toolchain.toolchain"

            isAbstract="true"

            name="my tool chain"

            osList="linux"

            targetTool="my.toolchain.linker">

         <option

               category="my.toolchain.general_options"

               id="my.toolchain.general.model"

               isAbstract="false"

               name="Model Name"

               resourceFilter="all"

               valueHandler="my.build.toolchain.HierarchicalOptionsValueHandler"

               valueType="string">

         </option>

      </toolChain>

      <tool

            command="mycc -c"

           id="my.toolchain.compiler"

            isAbstract="true"

            name="My Compiler"

            natureFilter="both"

            outputFlag="-o">     

         <option

               category="my.toolchain.compiler.compiler_options"

               command="--model"

               commandGenerator="my.build.toolchain.HierarchicalOptionsCommandGenerator"

               id="my.toolchain.compiler.model"

               isAbstract="false"

               name="Model Name"

               resourceFilter="all"

               valueType="string">

            <enablement

                  type="CMD_USAGE">

            </enablement>

            <enablement

                  type="UI_VISIBILITY">

               <false>

                  false body text

               </false>

            </enablement>

         </option>

      </tool>

 

 

The idea here was to take the input from UI using the toolchain-level option, while use the invisible option during the generation of the command. For this, I needed to copy the input value from UI to the invisible option's value. I achieved this by attaching OptionsValueHandler to the toolchain-level option (as can be seen in plugin.xml also) and in there I implemented the copying. With this, things started working if I always open the "Build Settings" dialog before issuing the build, but in other cases, the option value was not available in the command. I tried fixing this using the commandGenerator hook in the invisible option, but then saw some other issues.


Could someone please suggest/comment that the approach I have taken is in the right direction or if there are other better/simpler approaches to tackle such options that need to passed to a number of tools in CDT Managed build mechanism?

 

Thanks and Regards,

Ashutosh


Back to the top