[SERVER-59503] Regenerate files with ninja when MONGO_VERSION changes Created: 23/Aug/21  Updated: 27/Oct/23  Resolved: 26/Aug/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Xuerui Fa Assignee: Ryan Egesdahl (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Sprint: Dev Platform 2021-09-06
Participants:

 Description   

If we update MONGO_VERSION and attempt to rebuild using ninja, auto-generated files that use MONGO_VERSION will not automatically regenerate. Sample repro:

$ git checkout r5.0.2~1
$ scons ... --ninja generate-ninja
$ ninja build/.../mongo/util/version_constants.h
$ git checkout r5.0.2
$ ninja build/.../mongo/util/version_constants.h

The second build should not return "ninja: no work to do"

The files are regenerated correctly when using plain SCons.



 Comments   
Comment by Ryan Egesdahl (Inactive) [ 26/Aug/21 ]

xuerui.fa The behavior you're seeing isn't directly related to MONGO_VERSION except that version_constants.h is generated from it, which actually part of the generated-sources target. The generated-sources target has no declared dependency on the value of MONGO_VERSION - nor can we easily make SCons aware of such a dependency, in fact, which means we also can't represent it in build.ninja, either.

What you're really asking for here is for Ninja to be aware of changes to the state of your worktree. Ninja is a tool that depends on a snapshot of the current state of the worktree in order to optimize the task. The only way we could make it aware of changes to the state of your worktree is to have it always run SCons to generate a new snapshot, which would be slow enough that it defeats the reason you probably wanted to use Ninja in the first place.

Unfortunately, this is just a limitation of Ninja. Whenever you change branches or do a git pull or do anything else that changes your worktree in a way that Ninja can't be aware of (anything operated on by the generated-sources target is a likely candidate), you will need to generate your build.ninja over again.

Generated at Thu Feb 08 05:47:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.