I’ve been working with CDT for a long time now, but this is the
first time I’ve ever had to integrate a new toolchain. There are some options
that are shared between the compiler and linker in this toolchain. Rather than
showing the setting in the UI for each tool, I created a category containing
these options under the toolchain itself. So far so good. Now I need to read
the options from the toolchain and have each tool generate the proper command
line for it (the syntax is slightly different between the tools).
I could create my own IManagedCommandLineGenerator for each
tool, but that seems like overkill. The default implementation is fine, and it’s
internal so I’d rather not extend it for this.
I’ve tried two other approaches but have problems either way. I
feel like I must be missing something simple. I’ve searched and seen a couple
others with similar problems but no clear resolution. Hopefully someone on the
list can help.
The first approach was to create a ‘hidden’ option in each tool
to mirror the shared options. Then I specify my own IOptionCommandGenerator
for those ‘hidden’ options. Inside generateCommand I’d read the value of the
shared option and return the appropriate command. The problem there is I only
have the IOption. From there I can get back to the parent toolchain, but the
values are not set, so when I do a getValue I just get back the default
values. There are actually two toolchain instances. The one that has the
modified values from the UI (with the random number appended to the end), and
the one from the extension. I can only seem to get the latter from the IOption,
so I can’t get the current values.
The second approach was to specify my own IManagedOptionValueHandler
for the shared options. When they change (APPLY in handleValue) I’d get the
options in the tools and set them to the current shared value. That works fine
as the IHoldsOptions passed in is the toolchain with the modified values. The
problem there is that you get an APPLY event as soon as you change anything in
the UI. You get another when they click OK. So they change the shared value,
I set the values in the tools to match, then they click cancel instead of OK.
The changed toolchain value is somehow thrown away, but the tool values that I
set are persisted. So the next time they open the build settings (or do a
build) they’ll get the wrong command line for the tools.
Anyway, I hope someone can provide some suggestions.
Thanks,
Warren