The Mongodb build may want a more specific list of dependencies to determine when to regenerate the ninja file.
In SERVER-49493, the ninja tool made use of a depfile to push the SConstruct and SConscript files into a ninja depfile. This allowed the SConscripts to be removed (e.g removing the enterprise symlink) and still have a valid ninja file that could regenerate itself with the new changes.
However the creation of the depfile for the build.ninja file were generic and mongodb build may want something more specific. A list from the old ninja modules captures some interesting points: https://github.com/RedBeard0531/mongo_module_ninja/blob/master/build.py#L1336-L1362 but may be unnecessary. Look through that list and create new custom REGENERATE rule in the SConstruct that captures necessary items from the list and also consider if there are other files which we would want to cause a regeneration of the build.ninja file from.
Note that it's not known or tested if overwriting a hardcoded rule such as REGENERATE with the NinjaRule custom rule generator will work and may need some tweaking in ninja_next.py to support this.