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

Add option to enforce build-time code analysis for VS projects #2190

Merged
merged 1 commit into from
Feb 28, 2024
Merged

Add option to enforce build-time code analysis for VS projects #2190

merged 1 commit into from
Feb 28, 2024

Conversation

theComputeKid
Copy link
Contributor

What does this PR do?

This is a follow up to a previous PR: #2187

After enabling clang-tidy as an option in the VS IDE (#2187), this patch allows us to enforce it at build time. This can significantly increase build time, as you would expect from any static analysis tool. When building VS projects using this option, along with #2187, the log will show:

     2>ClangTidy:
         C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\x64\bin\clang-tidy.exe -p="..\myProj.ClangTidy"
         Suppressed 3 warnings (3 in non-user code).
         Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

A few people have asked for compile_command.json generation. On Linux/Macos, tools exist to generate this (e.g. bear etc). This is tricky on windows. As an extra side-benefit of this change, as seen in the log above, a compile_commands.json file is generated in the location specified with the -p flag. However, while useful, this is a side-effect of this change and not its primary purpose.

How does this PR change Premake's behavior?

Add configuration-scoped option runcodeanalysis for Visual Studio 2019 and above.

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

@Jarod42
Copy link
Contributor

Jarod42 commented Feb 28, 2024

A few people have asked for compile_command.json generation.

There is 2 (external) premake modules which should do that:

Copy link
Member

@nickclark2016 nickclark2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing the API entry in sidebars.js

@theComputeKid
Copy link
Contributor Author

@nickclark2016 : If you don't mind, could you also review the addition of clangtidy to the sidebar, as it is related to this change. I was unaware of the need to add this and I missed it in #2187. In any case, I will make the addition you requested. Thank you.

Copy link
Member

@nickclark2016 nickclark2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nickclark2016 nickclark2016 merged commit 16c2d6a into premake:master Feb 28, 2024
14 checks passed
@theComputeKid theComputeKid deleted the patch-1 branch February 28, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants