mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-24 09:49:07 +08:00
[vcpkg] Improve format check failure message (#12460)
* [docs] Add format document * improve the error message * Check the error message * Finish test * restore file list
This commit is contained in:
parent
b93fa7a1b4
commit
d367c4c0b8
@ -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
|
||||
|
@ -32,9 +32,9 @@ 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 += "File list:"
|
||||
$msg += " $changedFiles"
|
||||
$msg += ""
|
||||
|
||||
|
@ -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:"
|
||||
|
Loading…
Reference in New Issue
Block a user