clang-power-tools
clang-power-tools copied to clipboard
clang-build.ps1: append command line args to clang-flags from cpt.config
Hi,
We use cpt.config to pre-set some parameters. This includes a number of clang-flags
.
Now we encountered a use case where in some situations we want to add some flags to that list from the command line.
As far as I can see, a command line parameter is replaced with the setting from cpt.config, not combined (even when the parameter is an array, as is the case with clang-flags
).
Any ideas how to handle this use case?
Hello @gerboengels
Right now there is no support for this, and no workaround, but is something we should definitely support.
I think we could properly support that by adding an XML attribute append="true"
that can be specified for elements inside cpt.config
. Would that work for you?
Hi @hero101111,
That sounds like a great solution.
I didn't realize until I looked at the source code (and now your suggestion reinforces it) that the settings in cpt.config
seem to overwrite the settings from the command line (or append to it with your suggestion, making the cpt.config
flags come last).
Intuitively I'd think the settings in cpt.config
are the defaults, which you can overwrite (or append to) from the command line.
In most cases which appends to which shouldn't matter (like for file-ignore
and proj-ignore
). But for clang-flags
, the order might be important. Say, for example, that cpt.config
contains -Werror
and on the command line I add -Wno-error
. The order of these flags matter, with the first one being ignored.
Any thoughts on that? Changing this behaviour might be a breaking change for some users. Maybe cpt.config
could get an attribute, stating whether the settings are overwriting or defaults?
Thank you for your input. Indeed, changing the precedence of cpt.config
and command line arguments would be a breaking-change in regard to some use cases. I think a new attribute for the root XML element of the cpt.config
file would be most suitable for the job, letting the precedence be configurable.