{"id":26360,"date":"2020-08-13T15:00:42","date_gmt":"2020-08-13T15:00:42","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=26360"},"modified":"2020-09-11T22:11:28","modified_gmt":"2020-09-11T22:11:28","slug":"introducing-source-dependency-reporting-with-msvc-in-visual-studio-2019-version-16-7","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/introducing-source-dependency-reporting-with-msvc-in-visual-studio-2019-version-16-7\/","title":{"rendered":"Introducing source dependency reporting with MSVC in Visual Studio 2019 version 16.7"},"content":{"rendered":"<p>C++20 demands a lot more from the ecosystem than ever before. With C++20 Modules on the horizon the compiler needs to work closely with project systems in order to provide rich information for build dependency gathering and making iterative builds faster for inner-loop development. The compiler and project teams have acknowledged the new relationship and collaborated together to bring a new switch to the compiler toolset which can provide useful information to the build system: <code>\/sourceDependencies<\/code>.<\/p>\n<h4><span id=\"source-dependencies\">Source Dependency Reporting<\/span><\/h4>\n<p>The new switch for the compiler toolset enables the compiler to generate a source-level dependency report for any given translation unit it compiles. This report is output as a JSON file and you can produce it like this:<\/p>\n<p><code>$ cl \/Yupch.pch \/FIpch.h \/std:c++latest \/experimental:module \/module:reference m=m.ifc \/headerUnit other.h=other.h.ifc \/sourceDependencies main.json main.cpp<\/code><\/p>\n<p>Notice the use of <code>\/sourceDependencies main.json<\/code>.<\/p>\n<p>Given the following program:<\/p>\n<pre class=\"\">\/\/ main.cpp\r\n#include \"header.h\"\r\nimport m;\r\nimport \"other.h\";\r\n\r\nint main() { }<\/pre>\n<p>The dependency report generated to <code>main.json<\/code> might look something like:<\/p>\n<pre class=\"\">{\r\n    \"Version\": \"1.0\",\r\n    \"Data\": {\r\n        \"Source\": \"C:\\\\...\\\\main.cpp\",\r\n        \"PCH\": \"C:\\\\...\\\\pch.pch\",\r\n        \"Includes\": [\r\n            \"C:\\\\...\\\\header.h\"\r\n        ],\r\n        \"Modules\": [\r\n            \"C:\\\\...\\\\m.ifc\",\r\n            \"C:\\\\...\\\\other.h.ifc\"\r\n        ]\r\n    }\r\n}<\/pre>\n<p>Additionally, the use of <code>\/sourceDependencies<\/code> is not limited only to C++, it can also be used in translation units compiled as C! Moreover, the switch is designed to be used with multiple files and scenarios under <code>\/MP<\/code>. Please see the <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/reference\/sourcedependencies?view=vs-2019\">documentation page<\/a> for more information regarding these scenarios.<\/p>\n<h4><span id=\"stay-tuned\">Stay Tuned<\/span><\/h4>\n<p>The <code>\/sourceDependencies<\/code> output is subject to change and will evolve based on needs of the C++ build system ecosystem. The intent is to collect feedback from deployment in the field in order to provide feedback to the WG21\/SG15 Study Group and to refine the proposal <a href=\"https:\/\/wg21.link\/p1689\">P1689<\/a>. The documentation will be updated to reflect necessary future changes. We encourage users to leverage the <code>Version<\/code> field to account for the evolving nature, and to ensure that information contained in the dependency output are appropriately interpreted.<\/p>\n<p>We urge you to go out and try using MSVC&#8217;s new <code>\/sourceDependencies<\/code> switch. Visual Studio 2019 version 16.7 is available right now through the <a href=\"https:\/\/visualstudio.microsoft.com\/downloads\/\">Visual Studio 2019 downloads<\/a> page.<\/p>\n<p>As always, we welcome your feedback. Feel free to send any comments through e-mail at <a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a> or through <a href=\"https:\/\/twitter.com\/visualc\">Twitter @visualc<\/a>. Also, feel free to follow me on Twitter <a href=\"https:\/\/twitter.com\/starfreakclone\">@starfreakclone<\/a>.<\/p>\n<p>If you encounter other problems with MSVC in VS 2019 please let us know via the <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio?view=vs-2019\">Report a Problem<\/a> option, either from the installer or the Visual Studio IDE itself. For suggestions or bug reports, let us know through <a href=\"https:\/\/developercommunity.visualstudio.com\/\">DevComm.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C++20 demands a lot more from the ecosystem than ever before. With C++20 Modules on the horizon the compiler needs to work closely with project systems in order to provide rich information for build dependency gathering and making iterative builds faster for inner-loop development. The compiler and project teams have acknowledged the new relationship and [&hellip;]<\/p>\n","protected":false},"author":39620,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[270,1],"tags":[8,3882,140,2064,219],"class_list":["post-26360","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-cplusplus","tag-announcement","tag-buildsystem","tag-c","tag-c20","tag-dependency"],"acf":[],"blog_post_summary":"<p>C++20 demands a lot more from the ecosystem than ever before. With C++20 Modules on the horizon the compiler needs to work closely with project systems in order to provide rich information for build dependency gathering and making iterative builds faster for inner-loop development. The compiler and project teams have acknowledged the new relationship and [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/26360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/39620"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=26360"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/26360\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=26360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=26360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=26360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}