There was a discussion I'd started about this off-list, but moving it here to gn-dev@ to allow for others to participate or view.
`gn gen` currently has a number of flags that control things like IDE settings, compilation database generation, and so forth. For example, --export-compile-commands was added back in 2018. At the time, there was some discussion here (
https://groups.google.com/a/chromium.org/g/gn-dev/c/uzQJX4-zKXo) about how these settings should be provided. That discussion landed on the command line arguments to gen that we have today, but alternatives like globally scoped GN arguments that could be set in
args.gn or improved variants of that were also raised.
There is one major downside with the command line arguments today because of a bug (or, at least, unfortunate interaction) between GN and ninja. These arguments are only persisted in the `gn gen` command line that GN generates and drops in build.ninja, since ninja is what initiates regeneration as build inputs change. This is generally fine, but it is much too easy to cause ninja to delete build.ninja - and those settings along with it - today simply by interrupting (e.g. with Ctrl-C) regeneration. This forces the user to manually run `gn gen` again. In the case of GN-using projects like Pigweed, devloper tools like `pw watch` have adapted to automatically run gen if this happens. Unfortunately, the user may not remember what flags they used in the past, and `pw watch` for example doesn't make any attempt to preserve flags. This results in potentially surprising loss of settings and, if you use `pw watch`, poor behavior like your compilation database suddenly not regenerating anymore.