Primary source file omitted from output of "ninja -t deps"

54 views
Skip to first unread message

Andy Goth

unread,
Jan 14, 2022, 1:00:00 PMJan 14
to ninja-build
For a large CMake/Ninja C/C++/etc. project we have, running "ninja -t deps" is omitting the primary source file and listing only the targets and their included header files. This problem is happening only on Windows, not Linux. Why might this be, and what can we do about it? We have static code analysis support scripts that need to parse the full dependency graph. Other than this omission, Ninja appears to be working correctly.

Windows 10 Enterprise LTSC SHB 10.5.0
Visual Studio Professional 2019 16.11.7
Ninja 1.10.2
CMake 3.20.21032501-MSVC_2 (Kitware)

Oh, one other thing. I also noticed that on Windows, "ninja -t deps" shows the dependencies using relative paths, whereas on Linux, it uses absolute paths. What is the reason for this discrepancy?

Andy Goth

unread,
Jan 15, 2022, 4:35:41 AMJan 15
to ninja-build
Follow-up: it turns out the primary source files are being listed correctly in the output of "ninja -t graph" even on systems/projects for which "ninja -t deps" is skipping them.

For now our solution will be to parse the "ninja -t graph" output when on Windows, though this will require significantly more effort than our existing deps parser. Also my parser's output will have to skip over the compilers (nodes with "shape=ellipse") and directly connect primary sources and headers to the object files they go into, since for our needs we don't need to know which compilers are being used.

If group discussion can tell me how we're using "ninja -t deps" incorrectly on Windows (I mean, that's literally our command line...) or if there's something we might be doing wrong in our CMake generation, then I'll be happy to explore correcting that and discarding the "ninja -t graphs" parser. But until then, we need to move forward with what we have.

Andy Goth

unread,
Jan 23, 2022, 8:36:27 AMJan 23
to ninja-build
I have succeeded in correlating the outputs of "ninja -t deps" and "ninja -t graph" so as to overcome this problem. The "graph" output lists primary source files and generated header files (though oddly not non-generated header files), whereas the "deps" output lists only non-generated header files. They both show them feeding into object files (though "graph" has the intermediate compiler nodes), which is how I'm able to tie everything together. This may have taken a week of work on my part to implement, but it's done now, and it seems to be a satisfactory workaround.

If a future version of ninja becomes available for Windows that lists the primary source files as well as the header files, then I'll be happy to jump to it and remove all my extra code. But I needed to get this working in terms of the versions we've already got.

Reply all
Reply to author
Forward
0 new messages