From 7084ecd2ee449e201c552204469db417aab8432a Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 16 Jul 2020 23:27:40 -0700 Subject: [PATCH 1/5] [docs] Add format document --- docs/maintainers/maintainer-guide.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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 From 726f5f4332640c8b5c2d86fa2e17b3a64f29bbf6 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 16 Jul 2020 23:29:10 -0700 Subject: [PATCH 2/5] improve the error message --- scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 | 4 +--- scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1 | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 b/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 index 7f300164f6b060..20aedd77ff5fca 100644 --- a/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 +++ b/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 @@ -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" $msg += "" $msg += "clang-format should produce the following diff:" 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:" From 61b102b891128d62798b279a637580c669497e63 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 16 Jul 2020 23:34:25 -0700 Subject: [PATCH 3/5] Check the error message --- ports/libb2/vcpkg.json | 12 ++++++------ toolsrc/src/vcpkg.cpp | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ports/libb2/vcpkg.json b/ports/libb2/vcpkg.json index 1d2f19db823e96..9200d7511ee651 100644 --- a/ports/libb2/vcpkg.json +++ b/ports/libb2/vcpkg.json @@ -1,8 +1,8 @@ { - "name": "libb2", - "version-string": "0.98.1", - "port-version": 3, - "description": "C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp", - "homepage": "https://github.com/BLAKE2/libb2", - "supports": "!windows" + "name": "libb2", + "version-string": "0.98.1", + "port-version": 4, + "description": "C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp", + "homepage": "https://github.com/BLAKE2/libb2", + "supports": "!windows" } diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 40ccb1668470ee..64e1a5f575499e 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -15,6 +15,7 @@ #include #include #include + #include #include From 537707d534c813285b28e79de151e3cac1fedac2 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Sun, 19 Jul 2020 22:52:21 -0700 Subject: [PATCH 4/5] Finish test --- ports/libb2/vcpkg.json | 12 ++++++------ toolsrc/src/vcpkg.cpp | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ports/libb2/vcpkg.json b/ports/libb2/vcpkg.json index 9200d7511ee651..1d2f19db823e96 100644 --- a/ports/libb2/vcpkg.json +++ b/ports/libb2/vcpkg.json @@ -1,8 +1,8 @@ { - "name": "libb2", - "version-string": "0.98.1", - "port-version": 4, - "description": "C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp", - "homepage": "https://github.com/BLAKE2/libb2", - "supports": "!windows" + "name": "libb2", + "version-string": "0.98.1", + "port-version": 3, + "description": "C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp", + "homepage": "https://github.com/BLAKE2/libb2", + "supports": "!windows" } diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 64e1a5f575499e..40ccb1668470ee 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -15,7 +15,6 @@ #include #include #include - #include #include From 3fce3af06c8f52528c749afe56c9eee202b79452 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 21 Jul 2020 19:12:47 -0700 Subject: [PATCH 5/5] restore file list --- scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 b/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 index 20aedd77ff5fca..2adeeae45cdb19 100644 --- a/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 +++ b/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 @@ -34,6 +34,8 @@ try "The formatting of the C++ files didn't match our expectation.", "See https://github.com/microsoft/vcpkg/blob/master/docs/maintainers/maintainer-guide.md#vcpkg-internal-code for solution." ) + $msg += "File list:" + $msg += " $changedFiles" $msg += "" $msg += "clang-format should produce the following diff:"