Hi GN folks-
We're supporting 4-5 different hardware platforms in our single GN build; they're configured via templates and targets but share a single GN toolchain since they all use the same MCU and vendor C toolchain. This involves building the same .c files multiple times with different configs, making sure they're output to non-overlapping locations, etc. All of the targets for a specific platform "abc" will have the text "_abc_" in their labels, and "_abc_" is globally unique for this purpose. Sometimes these .c files are also compiled on the default (host) toolchain for unit testing.
We generate the compile_commands.json file via a naive "export_compile_commands = [ "//*" ]" line in our .gn file.
As you'd expect, the generated json file has multiple entries for each .c file that gets recompiled per hardware platform. This confuses our LSP clients, since some files are "disabled" based on hardware platforms, and the entire body of the file is unhelpfully greyed out. Which one gets picked is probably an implementation detail of the LSP server. Either way, it's generally not the one I want, because I can't control which one is picked :)
Ideally, we'd have the non-platform-specific targets explicitly listed in our export_compile_commands list in our .gn file, and then have some way for users to say "I'm explicitly working with _abc_ right now" and have the generated compile_commands.json file be the common files plus only the compilation lines for the _abc_ targets.
The build reference for "label patterns" doesn't have anything for internal globs- my naive attempt would be to tack "--add-export-compile-commands=//*_abc_*" onto our gn gen invocation, but of course that doesn't work.
Has anyone encountered and navigated this problem before? Any thoughts + advice are very welcome. Thanks in advance for reading!
Best,
Charles