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

[vcpkg] Improve format check failure message #12460

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/maintainers/maintainer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,34 @@ Note that if a library generates CMake integration files (`foo-config.cmake`), r

Finally, DLL files on Windows should never be renamed post-build because it breaks the generated LIBs.

## Code format

### Vcpkg internal code

We require the c/c++ code inside vcpkg to follow the clang-format, if you change them. Please perform the following steps after modification:

- Use Visual Studio:
1. Configure your [clang-format tools](https://devblogs.microsoft.com/cppblog/clangformat-support-in-visual-studio-2017-15-7-preview-1/).
2. Open the modified file.
3. Use shortcut keys Ctrl+K, Ctrl+D to format the current file.

- Use tools:
1. Install [llvm clang-format](https://releases.llvm.org/download.html#10.0.0)
2. Run command:
```cmd
> LLVM_PATH/bin/clang-format.exe -style=file -i changed_file.cpp
```

### Manifest

We require that the manifest file needs to be formatted, perform the following steps to solve this issue:

1. Format all changed manifest files.
```cmd
> vcpkg x-format-manifest --all
```
2. Commit changes to your branch.

## Useful implementation notes

### Portfiles are run in Script Mode
Expand Down
4 changes: 1 addition & 3 deletions scripts/azure-pipelines/windows/Check-CxxFormatting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ try
$msg = @(
"",
"The formatting of the C++ files didn't match our expectation.",
"If your build fails here, you need to format the following files with:"
"See https://github.com/microsoft/vcpkg/blob/master/docs/maintainers/maintainer-guide.md#vcpkg-internal-code for solution."
)
$msg += " $(& $clangFormat -version)"
$msg += " $changedFiles"
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
$msg += ""

$msg += "clang-format should produce the following diff:"
Expand Down
3 changes: 1 addition & 2 deletions scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ if (-not $IgnoreErrors -and $null -ne $changedFiles)
$msg = @(
"",
"The formatting of the manifest files didn't match our expectation.",
"If your build fails here, you need to run:"
"See https://github.com/microsoft/vcpkg/blob/master/docs/maintainers/maintainer-guide.md#manifest for solution."
)
$msg += " vcpkg x-format-manifest --all"
$msg += ""

$msg += "vcpkg should produce the following diff:"
Expand Down