diff --git a/docs/maintainers/maintainer-guide.md b/docs/maintainers/maintainer-guide.md index 0b653225802bfd..e0fde7e6885c63 100644 --- a/docs/maintainers/maintainer-guide.md +++ b/docs/maintainers/maintainer-guide.md @@ -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 diff --git a/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 b/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 index 7f300164f6b060..2adeeae45cdb19 100644 --- a/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 +++ b/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 @@ -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 += "" diff --git a/scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1 b/scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1 index e4f52ae7b44627..e6e29068f06bed 100644 --- a/scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1 +++ b/scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1 @@ -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:"