Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new cl.exe dependency report files #1806

Open
jgoshi opened this issue Jun 24, 2020 · 10 comments
Open

Support new cl.exe dependency report files #1806

jgoshi opened this issue Jun 24, 2020 · 10 comments
Labels

Comments

@jgoshi
Copy link

jgoshi commented Jun 24, 2020

In the cl.exe compiler shipped with Visual Studio 16.7 Preview 3, cl.exe will have a new switch /sourceDependencies [json file name].

Which produces a json file in the following format
{
“Version”: “1.0”
“Data”: [
{
"Source": "c:\Full\Path\To\SourceFile1.cpp",
"Includes": [
" c:\Full\Path\To\Header1.h",
" c:\Full\Path\To\Header2.h"
]
“TlbImports”: [] // #imports
“Modules” : [] // used ifcs
}
]
}

This would be an alternative to the /showIncludes flag currently used for dependency checking.

@jhasse we would like to contribute a PR for this. Does this sound like something that would be accepted?

@jonesmz

This comment was marked as abuse.

@jgoshi
Copy link
Author

jgoshi commented Jun 24, 2020

Thank you. I'm open to suggestions for which json library we want to take a dependency on.

@jonesmz

This comment was marked as abuse.

@jhasse
Copy link
Collaborator

jhasse commented Jun 25, 2020

Sounds good, although I'm not sure if going through the filesystem won't actually be slower than the current solution.

Why should the json parsing infect any of the existing code inside of ninja?

Since you're on Windows, you might try https://docs.microsoft.com/en-us/dotnet/api/system.web.script.serialization.javascriptserializer?view=netframework-4.8, but good luck coming up with the boilerplate code for calling C# from C++.

@jhasse jhasse added the windows label Jun 25, 2020
@jonesmz

This comment was marked as abuse.

@tristanlabelle
Copy link

The Visual C++ team is also interested in this because it would fix #1766 . I'm not familiar with json parsing options for C++ but we would look for a minimalist library as much as possible when implementing this, in the spirit of the ninja project.

@jonesmz

This comment was marked as abuse.

@digit-google
Copy link
Contributor

I would argue that it is not difficult to write a simple and fast limited JSON parser in C++ for a fixed schema like this one, that could be integrated directly into Ninja, with an option to link to another library like SIMDJson for performance if this really matters (I doubt it would). As long as the exact implementation details are hidden from the rest of the Ninja source code, support for external JSON libraries could be added as a build option. Just be sure to have an extensive unit-test suite that could be checked against any implementation.

@digit-google
Copy link
Contributor

I also notice that /sourceDependencies seems to generate a JSON file whose schema is not officially specified. Unlike /scanDependencies which uses standard schema P1689r3.

Anyone knows where to find a schema for /sourceDependencies then?

@cpsauer
Copy link

cpsauer commented Mar 14, 2023

If useful: I think that the last time I checked these flags out they were only for module dependencies, rather than the normal header inclusion you'd need for #1766 and #613?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants