I’m working on a very large code base. I’m trying to integrate the GCC dependency generation (gcc -MM ...
) into the build process (Makefile based) to support safe, incremental building. The challenge that is that building/updating the dependencies take lot of time.
Approximately 25K files + 5000 header files, in 20 folders. Whenever a user modifies a “.h” file, almost all “.d” files have to be rebuilt – takes forever.
In past projects, I used the “makedepend” utilities – standalone scanner that was capable of creating fast dependency trees. The tool assumes that the same invocation of a header file will result in the same dependencies – eliminating the “nested” #include processing needed to process each source files with gcc. Unfortunately, the tool is not maintained – and is not able to handle recent C23 feature (“dynamic” includes, etc.). Also, it is not aware of many predefined GCC macros.
Does anyone know if it’s possible to use the “GCC -MM” dependency generation in such a way that every header file will be scanned only once, and the result will be used to identify dependencies of any “c” source file. For my projects – this will be a big time saver.
Example: assuming
file1.c: #include "shared.h"
file2.c: #include "shared.h"
shared.h: #include "1.h", include "2.h", include "3.h"
Looking for a tool that will read shared.h only once, and “inject” the dependencies of 1.h, 2.h and 3.h into file1.o and file2.o – WITHOUT scanning the shared.h twice.