[RFC] Make gendeclarations.lua more friendly to incremental builds

Modify gendeclarations.lua to check if the generated non-static declaration header changed before rewriting it with a new version. This is to prevent unnecessary rebuilds of modules that depend on the public interface of modules that suffered private changes.