Heya GN folks-
Sometimes I want to check in built artifacts. For example, our GN build sets up python virtual environments, does third-party package installations, etc, and for reproducibility it would be very helpful to have a GN target run a tool that "freezes" a package version manifest into the source tree. We'd check that manifest in so that when we later revisit that particular tag, we can build with the exact third-party package versions from that time.
I'm curious what patterns people use for accomplishing this- of course GN will only allow outputs under the build directory and not in the source tree. There are at least these options:
1. Go behind GN's back and have my tool "tee" the file both to $target_gen_dir and also to the in-source location. Obviously not great: it hurts determinism, gets missed by ninja -t clean, is a build-system antipattern, etc.
2. Wrap ninja in a tool that does the manual copy fix-up (really step 1 but without "cheating" inside of GN). This is cumbersome and adds overall complexity; it's simplest to just use the native "gn" and "ninja" tools. Though, we already do this to copy compile_commands.json from whichever configuration subdirectory that was most recently built into a known location for IDE / LSP support.
3. Require users to invoke a "copy this manifest from $target_gen_dir to the source tree" script manually when they want to update the manifest. This is the most explicit + simplest solution, but it requires that human diligence replace robot tooling, which never scales. Also, we always want the most recent + updated manifest; there's no reason not to update it.
4. Don't burden users at all and instead run step 3 from CI, and do this from the CI clean room build. This is nice and "free" but slows our CI down (each job clone takes ~2-3 minutes) and costs more $ on builds.
I should note that this file isn't used in the build after generation; it's either used from a clean build via a GN arg (rebuilding a historical SHA) or it's an output (generated + checked-in). It's never both in one build.
If any GN users out there do anything like this, I'd love to hear your thoughts. We strive to not lie to GN, but option #1 is looking like the simplest solution for this case, so I figured I'd ask.
Best,
Charles