diff --git a/scripts/azure-pipelines/windows/azure-pipelines.yml b/scripts/azure-pipelines/windows/azure-pipelines.yml index a76b6afdf0d..1d18c0339f3 100644 --- a/scripts/azure-pipelines/windows/azure-pipelines.yml +++ b/scripts/azure-pipelines/windows/azure-pipelines.yml @@ -20,6 +20,12 @@ jobs: condition: always() inputs: filePath: 'scripts/azure-pipelines/windows/disk-space.ps1' + - task: Powershell@2 + displayName: 'Check C++ Formatting' + condition: eq('${{ parameters.triplet }}', 'x86-windows') + inputs: + filePath: 'scripts/azure-pipelines/windows/check-formatting.ps1' + arguments: '-Toolsrc ./toolsrc' # Note: D: is the Azure machines' temporary disk. - task: CmdLine@2 displayName: 'Build vcpkg' diff --git a/scripts/azure-pipelines/windows/check-formatting.ps1 b/scripts/azure-pipelines/windows/check-formatting.ps1 new file mode 100644 index 00000000000..e3c3d213eaf --- /dev/null +++ b/scripts/azure-pipelines/windows/check-formatting.ps1 @@ -0,0 +1,54 @@ +[CmdletBinding()] +Param( + [Parameter(Mandatory=$True)] + [string]$Toolsrc, + [Parameter()] + [switch]$IgnoreErrors # allows one to just format +) + +$clangFormat = 'C:\Program Files\LLVM\bin\clang-format.exe' +if (-not (Test-Path $clangFormat)) +{ + Write-Error "clang-format not found; is it installed in the CI machines?" + throw +} + +$Toolsrc = Get-Item $Toolsrc +Push-Location $Toolsrc + +try +{ + $files = Get-ChildItem -Recurse -LiteralPath "$Toolsrc/src" -Filter '*.cpp' + $files += Get-ChildItem -Recurse -LiteralPath "$Toolsrc/include/vcpkg" -Filter '*.h' + $files += Get-ChildItem -Recurse -LiteralPath "$Toolsrc/include/vcpkg-test" -Filter '*.h' + $files += Get-Item "$Toolsrc/include/pch.h" + $fileNames = $files.FullName + + & $clangFormat -style=file -i @fileNames + + $changedFiles = git status --porcelain $Toolsrc | ForEach-Object { + (-split $_)[1] + } + + if (-not $IgnoreErrors -and $null -ne $changedFiles) + { + $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:" + ) + $msg += " $(& $clangFormat -version)" + $msg += " $changedFiles" + $msg += "" + + $msg += "clang-format should produce the following diff:" + $msg += git diff $Toolsrc + + Write-Error ($msg -join "`n") + throw + } +} +finally +{ + Pop-Location +} diff --git a/scripts/azure-pipelines/windows/provision-image.txt b/scripts/azure-pipelines/windows/provision-image.txt index 2d2790ec73a..798b96e9a13 100644 --- a/scripts/azure-pipelines/windows/provision-image.txt +++ b/scripts/azure-pipelines/windows/provision-image.txt @@ -391,6 +391,30 @@ Function InstallLLVM { } } +<# +.SYNOPSIS +Installs LLVM. + +.DESCRIPTION +InstallLLVM installs LLVM from the supplied URL. + +.PARAMETER Url +The URL of the LLVM installer. +#> +Function InstallLLVM { + try { + Write-Host 'Downloading LLVM...' + [string]$installerPath = Get-TempFilePath -Extension 'exe' + curl.exe -L -o $installerPath -s -S $Url + Write-Host 'Installing LLVM...' + $proc = Start-Process -FilePath $installerPath -ArgumentList @('/S') -NoNewWindow -Wait -PassThru + PrintMsiExitCodeMessage $proc.ExitCode + } + catch { + Write-Error "Failed to install LLVM! $($_.Exception.Message)" + } +} + <# .SYNOPSIS Installs MPI diff --git a/toolsrc/.clang-format b/toolsrc/.clang-format index d19c4472a06..4b2e83422bd 100644 --- a/toolsrc/.clang-format +++ b/toolsrc/.clang-format @@ -1,4 +1,3 @@ ---- BasedOnStyle: WebKit Language: Cpp Standard: Cpp11 @@ -32,6 +31,19 @@ ForEachMacros: [TEST_CASE, SECTION] PenaltyReturnTypeOnItsOwnLine: 1000 SpaceAfterTemplateKeyword: false SpaceBeforeCpp11BracedList: false +UseCRLF: false -IncludeBlocks: Preserve -SortIncludes: false +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^(|"pch\.h")$' + Priority: -1 + - Regex: '^$' + Priority: 1 + - Regex: '^$' + Priority: 2 + - Regex: '^$' + Priority: 3 + - Regex: '^<[a-z0-9_]*\.h>$' + Priority: 4 + - Regex: '^<[a-z0-9_]*>$' # C++ standard library + Priority: 5 diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h index 46ba6fa37f8..f92792411c9 100644 --- a/toolsrc/include/pch.h +++ b/toolsrc/include/pch.h @@ -1,8 +1,9 @@ #pragma once -#include #include +#include + #if defined(_WIN32) #include #include @@ -49,9 +50,10 @@ #include #endif +#include + #include #include -#include #include #include #include diff --git a/toolsrc/include/vcpkg-test/util.h b/toolsrc/include/vcpkg-test/util.h index 9321f3fd2ec..f7d2f2a500c 100644 --- a/toolsrc/include/vcpkg-test/util.h +++ b/toolsrc/include/vcpkg-test/util.h @@ -1,13 +1,13 @@ #include #include -#include - -#include -#include #include +#include +#include +#include + #define CHECK_EC(ec) \ do \ { \ @@ -54,7 +54,7 @@ namespace vcpkg::Test { std::unordered_map map; Triplet triplet; - PackageSpecMap(Triplet t = Triplet::X86_WINDOWS) noexcept : triplet(t) {} + PackageSpecMap(Triplet t = Triplet::X86_WINDOWS) noexcept : triplet(t) { } PackageSpec emplace(const char* name, const char* depends = "", @@ -86,9 +86,9 @@ namespace vcpkg::Test Yes = true, } tag; - constexpr AllowSymlinks(Tag tag) noexcept : tag(tag) {} + constexpr AllowSymlinks(Tag tag) noexcept : tag(tag) { } - constexpr explicit AllowSymlinks(bool b) noexcept : tag(b ? Yes : No) {} + constexpr explicit AllowSymlinks(bool b) noexcept : tag(b ? Yes : No) { } constexpr operator bool() const noexcept { return tag == Yes; } }; diff --git a/toolsrc/include/vcpkg/base/chrono.h b/toolsrc/include/vcpkg/base/chrono.h index 118e9c382dc..b2865476a59 100644 --- a/toolsrc/include/vcpkg/base/chrono.h +++ b/toolsrc/include/vcpkg/base/chrono.h @@ -1,11 +1,11 @@ #pragma once -#include -#include - #include #include +#include +#include + namespace vcpkg::Chrono { class ElapsedTime @@ -13,8 +13,8 @@ namespace vcpkg::Chrono using duration = std::chrono::high_resolution_clock::time_point::duration; public: - constexpr ElapsedTime() noexcept : m_duration() {} - constexpr ElapsedTime(duration d) noexcept : m_duration(d) {} + constexpr ElapsedTime() noexcept : m_duration() { } + constexpr ElapsedTime(duration d) noexcept : m_duration(d) { } template TimeUnit as() const @@ -34,7 +34,7 @@ namespace vcpkg::Chrono public: static ElapsedTimer create_started(); - constexpr ElapsedTimer() noexcept : m_start_tick() {} + constexpr ElapsedTimer() noexcept : m_start_tick() { } ElapsedTime elapsed() const { @@ -56,8 +56,8 @@ namespace vcpkg::Chrono static Optional get_current_date_time(); static Optional parse(CStringView str); - constexpr CTime() noexcept : m_tm{} {} - explicit constexpr CTime(tm t) noexcept : m_tm{t} {} + constexpr CTime() noexcept : m_tm{} { } + explicit constexpr CTime(tm t) noexcept : m_tm{t} { } CTime add_hours(const int hours) const; diff --git a/toolsrc/include/vcpkg/base/cofffilereader.h b/toolsrc/include/vcpkg/base/cofffilereader.h index e0ad69b3362..a135ba02823 100644 --- a/toolsrc/include/vcpkg/base/cofffilereader.h +++ b/toolsrc/include/vcpkg/base/cofffilereader.h @@ -1,10 +1,10 @@ #pragma once +#include + #include #include -#include - namespace vcpkg::CoffFileReader { struct DllInfo diff --git a/toolsrc/include/vcpkg/base/cstringview.h b/toolsrc/include/vcpkg/base/cstringview.h index d49bfc82ffe..7d46ecf2e4c 100644 --- a/toolsrc/include/vcpkg/base/cstringview.h +++ b/toolsrc/include/vcpkg/base/cstringview.h @@ -7,10 +7,10 @@ namespace vcpkg { struct CStringView { - constexpr CStringView() noexcept : cstr(nullptr) {} - constexpr CStringView(const char* cstr) : cstr(cstr) {} + constexpr CStringView() noexcept : cstr(nullptr) { } + constexpr CStringView(const char* cstr) : cstr(cstr) { } constexpr CStringView(const CStringView&) = default; - CStringView(const std::string& str) : cstr(str.c_str()) {} + CStringView(const std::string& str) : cstr(str.c_str()) { } constexpr const char* c_str() const { return cstr; } diff --git a/toolsrc/include/vcpkg/base/enums.h b/toolsrc/include/vcpkg/base/enums.h index 6eca2cfe16e..77ca7194f4f 100644 --- a/toolsrc/include/vcpkg/base/enums.h +++ b/toolsrc/include/vcpkg/base/enums.h @@ -1,9 +1,9 @@ #pragma once -#include - #include +#include + namespace vcpkg::Enums { std::string nullvalue_to_string(const CStringView enum_name); diff --git a/toolsrc/include/vcpkg/base/expected.h b/toolsrc/include/vcpkg/base/expected.h index 40f5af40f2d..6381f1e8989 100644 --- a/toolsrc/include/vcpkg/base/expected.h +++ b/toolsrc/include/vcpkg/base/expected.h @@ -1,16 +1,16 @@ #pragma once +#include + #include #include -#include - namespace vcpkg { template struct ErrorHolder { - ErrorHolder() : m_is_error(false), m_err{} {} + ErrorHolder() : m_is_error(false), m_err{} { } template ErrorHolder(U&& err) : m_is_error(true), m_err(std::forward(err)) { diff --git a/toolsrc/include/vcpkg/base/graphs.h b/toolsrc/include/vcpkg/base/graphs.h index f368a872d72..957af0fba19 100644 --- a/toolsrc/include/vcpkg/base/graphs.h +++ b/toolsrc/include/vcpkg/base/graphs.h @@ -34,7 +34,7 @@ namespace vcpkg::Graphs virtual int random(int max_exclusive) = 0; protected: - ~Randomizer() {} + ~Randomizer() { } }; namespace details diff --git a/toolsrc/include/vcpkg/base/hash.h b/toolsrc/include/vcpkg/base/hash.h index d62fd392164..2878807d42b 100644 --- a/toolsrc/include/vcpkg/base/hash.h +++ b/toolsrc/include/vcpkg/base/hash.h @@ -1,9 +1,9 @@ #pragma once -#include - #include +#include + namespace vcpkg::Hash { enum class Algorithm diff --git a/toolsrc/include/vcpkg/base/json.h b/toolsrc/include/vcpkg/base/json.h index ecb96cde141..97c8be91fe5 100644 --- a/toolsrc/include/vcpkg/base/json.h +++ b/toolsrc/include/vcpkg/base/json.h @@ -1,17 +1,18 @@ #pragma once +#include +#include + +#include +#include +#include +#include + #include #include #include #include -#include -#include -#include -#include -#include -#include - namespace vcpkg::Json { struct JsonStyle diff --git a/toolsrc/include/vcpkg/base/lazy.h b/toolsrc/include/vcpkg/base/lazy.h index 58c11c002fd..d0afdaeb26c 100644 --- a/toolsrc/include/vcpkg/base/lazy.h +++ b/toolsrc/include/vcpkg/base/lazy.h @@ -6,7 +6,7 @@ namespace vcpkg class Lazy { public: - Lazy() : value(T()), initialized(false) {} + Lazy() : value(T()), initialized(false) { } template T const& get_lazy(const F& f) const diff --git a/toolsrc/include/vcpkg/base/lineinfo.h b/toolsrc/include/vcpkg/base/lineinfo.h index 2f03fef1623..b90b6fac3e4 100644 --- a/toolsrc/include/vcpkg/base/lineinfo.h +++ b/toolsrc/include/vcpkg/base/lineinfo.h @@ -6,8 +6,8 @@ namespace vcpkg { struct LineInfo { - constexpr LineInfo() noexcept : m_line_number(0), m_file_name("") {} - constexpr LineInfo(const int lineno, const char* filename) : m_line_number(lineno), m_file_name(filename) {} + constexpr LineInfo() noexcept : m_line_number(0), m_file_name("") { } + constexpr LineInfo(const int lineno, const char* filename) : m_line_number(lineno), m_file_name(filename) { } std::string to_string() const; void to_string(std::string& out) const; diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h index 0d77f4b0362..842f72f95d9 100644 --- a/toolsrc/include/vcpkg/base/optional.h +++ b/toolsrc/include/vcpkg/base/optional.h @@ -1,17 +1,16 @@ #pragma once -#include - -#include - #include #include +#include +#include + namespace vcpkg { struct NullOpt { - explicit constexpr NullOpt(int) {} + explicit constexpr NullOpt(int) { } }; const static constexpr NullOpt nullopt{0}; @@ -22,9 +21,9 @@ namespace vcpkg struct OptionalStorage { VCPKG_MSVC_WARNING(suppress : 26495) - constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {} - constexpr OptionalStorage(const T& t) : m_is_present(true), m_t(t) {} - constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {} + constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() { } + constexpr OptionalStorage(const T& t) : m_is_present(true), m_t(t) { } + constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) { } ~OptionalStorage() noexcept { @@ -96,7 +95,8 @@ namespace vcpkg } bool m_is_present; - union { + union + { char m_inactive; T m_t; }; @@ -106,8 +106,8 @@ namespace vcpkg struct OptionalStorage { VCPKG_MSVC_WARNING(suppress : 26495) - constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {} - constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {} + constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() { } + constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) { } ~OptionalStorage() noexcept { @@ -155,7 +155,8 @@ namespace vcpkg } bool m_is_present; - union { + union + { char m_inactive; T m_t; }; @@ -164,8 +165,8 @@ namespace vcpkg template struct OptionalStorage { - constexpr OptionalStorage() noexcept : m_t(nullptr) {} - constexpr OptionalStorage(T& t) : m_t(&t) {} + constexpr OptionalStorage() noexcept : m_t(nullptr) { } + constexpr OptionalStorage(T& t) : m_t(&t) { } constexpr bool has_value() const { return m_t != nullptr; } @@ -182,10 +183,10 @@ namespace vcpkg template struct Optional { - constexpr Optional() noexcept {} + constexpr Optional() noexcept { } // Constructors are intentionally implicit - constexpr Optional(NullOpt) {} + constexpr Optional(NullOpt) { } template, Optional>::value>> constexpr Optional(U&& t) : m_base(std::forward(t)) diff --git a/toolsrc/include/vcpkg/base/parse.h b/toolsrc/include/vcpkg/base/parse.h index c5044865ed2..d63cf1ced54 100644 --- a/toolsrc/include/vcpkg/base/parse.h +++ b/toolsrc/include/vcpkg/base/parse.h @@ -1,14 +1,14 @@ #pragma once +#include +#include + #include #include #include #include #include -#include -#include - namespace vcpkg::Parse { struct IParseError diff --git a/toolsrc/include/vcpkg/base/sortedvector.h b/toolsrc/include/vcpkg/base/sortedvector.h index fbb7e5a5aeb..33379676e83 100644 --- a/toolsrc/include/vcpkg/base/sortedvector.h +++ b/toolsrc/include/vcpkg/base/sortedvector.h @@ -13,7 +13,7 @@ namespace vcpkg using size_type = typename std::vector::size_type; using iterator = typename std::vector::const_iterator; - SortedVector() : m_data() {} + SortedVector() : m_data() { } explicit SortedVector(std::vector v) : m_data(std::move(v)) { diff --git a/toolsrc/include/vcpkg/base/span.h b/toolsrc/include/vcpkg/base/span.h index a5ba884aff4..482fe1b003c 100644 --- a/toolsrc/include/vcpkg/base/span.h +++ b/toolsrc/include/vcpkg/base/span.h @@ -19,10 +19,10 @@ namespace vcpkg using reference = std::add_lvalue_reference_t; using iterator = pointer; - constexpr Span() noexcept : m_ptr(nullptr), m_count(0) {} - constexpr Span(std::nullptr_t) noexcept : m_ptr(nullptr), m_count(0) {} - constexpr Span(pointer ptr, size_t count) noexcept : m_ptr(ptr), m_count(count) {} - constexpr Span(pointer ptr_begin, pointer ptr_end) noexcept : m_ptr(ptr_begin), m_count(ptr_end - ptr_begin) {} + constexpr Span() noexcept : m_ptr(nullptr), m_count(0) { } + constexpr Span(std::nullptr_t) noexcept : m_ptr(nullptr), m_count(0) { } + constexpr Span(pointer ptr, size_t count) noexcept : m_ptr(ptr), m_count(count) { } + constexpr Span(pointer ptr_begin, pointer ptr_end) noexcept : m_ptr(ptr_begin), m_count(ptr_end - ptr_begin) { } template constexpr Span(T (&arr)[N]) noexcept : m_ptr(arr), m_count(N) diff --git a/toolsrc/include/vcpkg/base/stringliteral.h b/toolsrc/include/vcpkg/base/stringliteral.h index 602e0bfd231..d0d5dc1246b 100644 --- a/toolsrc/include/vcpkg/base/stringliteral.h +++ b/toolsrc/include/vcpkg/base/stringliteral.h @@ -1,6 +1,7 @@ #pragma once #include + #include namespace vcpkg diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index e88d1074fde..229bedb65c3 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -1,19 +1,18 @@ #pragma once -#include - -#include -#include -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include +#include +#include + namespace vcpkg::Strings::details { template diff --git a/toolsrc/include/vcpkg/base/stringview.h b/toolsrc/include/vcpkg/base/stringview.h index 6a5503e1c3e..a442964f84f 100644 --- a/toolsrc/include/vcpkg/base/stringview.h +++ b/toolsrc/include/vcpkg/base/stringview.h @@ -1,11 +1,11 @@ #pragma once -#include - #include #include #include +#include + namespace vcpkg { struct StringView diff --git a/toolsrc/include/vcpkg/base/system.debug.h b/toolsrc/include/vcpkg/base/system.debug.h index d9c50ac8ea5..c1f98a9e144 100644 --- a/toolsrc/include/vcpkg/base/system.debug.h +++ b/toolsrc/include/vcpkg/base/system.debug.h @@ -1,10 +1,10 @@ #pragma once +#include + #include #include -#include - namespace vcpkg::Debug { extern std::atomic g_debugging; diff --git a/toolsrc/include/vcpkg/base/system.process.h b/toolsrc/include/vcpkg/base/system.process.h index 91faa59854b..9dbb5d069c2 100644 --- a/toolsrc/include/vcpkg/base/system.process.h +++ b/toolsrc/include/vcpkg/base/system.process.h @@ -1,13 +1,13 @@ #pragma once -#include -#include - #include #include #include #include +#include +#include + namespace vcpkg::System { struct CMakeVariable diff --git a/toolsrc/include/vcpkg/base/system_headers.h b/toolsrc/include/vcpkg/base/system_headers.h index 9af5bfd922d..858cf58cca0 100644 --- a/toolsrc/include/vcpkg/base/system_headers.h +++ b/toolsrc/include/vcpkg/base/system_headers.h @@ -17,7 +17,8 @@ // ctermid is not behind an `extern "C"` barrier, so it's linked incorrectly. // This has been reported; remove it after 2023-05-19 #if __APPLE__ -extern "C" { +extern "C" +{ #endif #include @@ -32,4 +33,3 @@ extern "C" { // glibc defines major and minor in sys/types.h, and should not #undef major #undef minor - diff --git a/toolsrc/include/vcpkg/base/uint128.h b/toolsrc/include/vcpkg/base/uint128.h index 6b7816760f2..feac68bb7a7 100644 --- a/toolsrc/include/vcpkg/base/uint128.h +++ b/toolsrc/include/vcpkg/base/uint128.h @@ -2,25 +2,23 @@ #include -namespace vcpkg { +namespace vcpkg +{ + struct UInt128 + { + UInt128() = default; + UInt128(uint64_t value) : bottom(value), top(0) { } -struct UInt128 { - UInt128() = default; - UInt128(uint64_t value) : bottom(value), top(0) {} + UInt128& operator<<=(int by) noexcept; + UInt128& operator>>=(int by) noexcept; + UInt128& operator+=(uint64_t lhs) noexcept; - UInt128& operator<<=(int by) noexcept; - UInt128& operator>>=(int by) noexcept; - UInt128& operator+=(uint64_t lhs) noexcept; + uint64_t bottom_64_bits() const noexcept { return bottom; } + uint64_t top_64_bits() const noexcept { return top; } - uint64_t bottom_64_bits() const noexcept { - return bottom; - } - uint64_t top_64_bits() const noexcept { - return top; - } -private: - uint64_t bottom; - uint64_t top; -}; + private: + uint64_t bottom; + uint64_t top; + }; } diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index a5b56028ba6..a6d8781b057 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -218,7 +218,7 @@ namespace vcpkg::Util T* get() { return &m_ptr; } - LockGuardPtr(LockGuarded& sync) : m_lock(sync.m_mutex), m_ptr(sync.m_t) {} + LockGuardPtr(LockGuarded& sync) : m_lock(sync.m_mutex), m_ptr(sync.m_t) { } private: std::unique_lock m_lock; diff --git a/toolsrc/include/vcpkg/base/work_queue.h b/toolsrc/include/vcpkg/base/work_queue.h index a60613a3c90..ba622361ab6 100644 --- a/toolsrc/include/vcpkg/base/work_queue.h +++ b/toolsrc/include/vcpkg/base/work_queue.h @@ -1,17 +1,17 @@ #pragma once -#include - #include #include #include +#include + namespace vcpkg { template struct WorkQueue { - WorkQueue(LineInfo li) : m_line_info(li) {} + WorkQueue(LineInfo li) : m_line_info(li) { } WorkQueue(const WorkQueue&) = delete; ~WorkQueue() diff --git a/toolsrc/include/vcpkg/base/zstringview.h b/toolsrc/include/vcpkg/base/zstringview.h index 7f80bf726df..8aa0dbdaf90 100644 --- a/toolsrc/include/vcpkg/base/zstringview.h +++ b/toolsrc/include/vcpkg/base/zstringview.h @@ -14,7 +14,7 @@ namespace vcpkg { using value_type = char; - constexpr ZStringView() : m_size(0), m_cstr("") {} + constexpr ZStringView() : m_size(0), m_cstr("") { } template constexpr ZStringView(const char (&str)[N]) @@ -22,8 +22,8 @@ namespace vcpkg { } - ZStringView(const std::string& s) : m_size(s.size()), m_cstr(s.c_str()) {} - constexpr ZStringView(const char* str, size_t sz) : m_size(sz), m_cstr(str) {} + ZStringView(const std::string& s) : m_size(s.size()), m_cstr(s.c_str()) { } + constexpr ZStringView(const char* str, size_t sz) : m_size(sz), m_cstr(str) { } constexpr const char* data() const { return m_cstr; } constexpr size_t size() const { return m_size; } diff --git a/toolsrc/include/vcpkg/binarycaching.private.h b/toolsrc/include/vcpkg/binarycaching.private.h index f20a0db1212..6f2fda9c037 100644 --- a/toolsrc/include/vcpkg/binarycaching.private.h +++ b/toolsrc/include/vcpkg/binarycaching.private.h @@ -1,6 +1,7 @@ #pragma once #include + #include #include #include diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index ea9f86fefd0..9d4e17eaee6 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -1,5 +1,14 @@ #pragma once +#include +#include +#include +#include + +#include +#include +#include +#include #include #include #include @@ -7,16 +16,6 @@ #include #include -#include -#include -#include -#include - -#include -#include -#include -#include - namespace vcpkg { struct IBinaryProvider; diff --git a/toolsrc/include/vcpkg/buildenvironment.h b/toolsrc/include/vcpkg/buildenvironment.h index 4505f497263..fe5bbeaf744 100644 --- a/toolsrc/include/vcpkg/buildenvironment.h +++ b/toolsrc/include/vcpkg/buildenvironment.h @@ -1,9 +1,9 @@ -#include -#include - #include #include +#include +#include + namespace vcpkg { std::string make_cmake_cmd(const VcpkgPaths& paths, diff --git a/toolsrc/include/vcpkg/cmakevars.h b/toolsrc/include/vcpkg/cmakevars.h index 1c02376b9ff..e2f1df5228e 100644 --- a/toolsrc/include/vcpkg/cmakevars.h +++ b/toolsrc/include/vcpkg/cmakevars.h @@ -1,7 +1,6 @@ #pragma once #include - #include #include diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h index cec9237f573..2a8d883200d 100644 --- a/toolsrc/include/vcpkg/commands.h +++ b/toolsrc/include/vcpkg/commands.h @@ -1,15 +1,15 @@ #pragma once +#include +#include +#include + #include #include #include #include #include -#include -#include -#include - namespace vcpkg::Commands { using CommandTypeA = void (*)(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet); diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 5e1c9f657a6..9e11d1c414e 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include + #include #include #include @@ -9,10 +13,6 @@ #include #include -#include -#include -#include - namespace vcpkg::Graphs { struct Randomizer; diff --git a/toolsrc/include/vcpkg/export.chocolatey.h b/toolsrc/include/vcpkg/export.chocolatey.h index 7804108fd1a..a6dde36dbb6 100644 --- a/toolsrc/include/vcpkg/export.chocolatey.h +++ b/toolsrc/include/vcpkg/export.chocolatey.h @@ -1,10 +1,10 @@ #pragma once +#include + #include #include -#include - namespace vcpkg::Export::Chocolatey { struct Options diff --git a/toolsrc/include/vcpkg/export.ifw.h b/toolsrc/include/vcpkg/export.ifw.h index b1573924ed9..ec01511aadc 100644 --- a/toolsrc/include/vcpkg/export.ifw.h +++ b/toolsrc/include/vcpkg/export.ifw.h @@ -1,11 +1,11 @@ #pragma once -#include -#include - #include #include +#include +#include + namespace vcpkg::Export::IFW { struct Options diff --git a/toolsrc/include/vcpkg/export.prefab.h b/toolsrc/include/vcpkg/export.prefab.h index cf9f940f92d..cfd99bec715 100644 --- a/toolsrc/include/vcpkg/export.prefab.h +++ b/toolsrc/include/vcpkg/export.prefab.h @@ -1,12 +1,11 @@ #pragma once +#include + #include #include #include - -#include - namespace vcpkg::Export::Prefab { constexpr int kFragmentSize = 3; @@ -23,17 +22,14 @@ namespace vcpkg::Export::Prefab }; struct NdkVersion { - NdkVersion(int _major, int _minor, int _patch) : m_major{_major}, - m_minor{_minor}, - m_patch{_patch}{ - } - int major() { return this->m_major; } - int minor() { return this->m_minor; } - int patch() { return this->m_patch; } + NdkVersion(int _major, int _minor, int _patch) : m_major{_major}, m_minor{_minor}, m_patch{_patch} { } + int major() { return this->m_major; } + int minor() { return this->m_minor; } + int patch() { return this->m_patch; } std::string to_string(); void to_string(std::string& out); - private: + private: int m_major; int m_minor; int m_patch; @@ -72,11 +68,10 @@ namespace vcpkg::Export::Prefab std::string to_json(); }; - - void do_export(const std::vector& export_plan, const VcpkgPaths& paths, - const Options& prefab_options, const Triplet& triplet); - Optional find_ndk_version(const std::string &content); - Optional to_version(const std::string &version); + const Options& prefab_options, + const Triplet& triplet); + Optional find_ndk_version(const std::string& content); + Optional to_version(const std::string& version); } diff --git a/toolsrc/include/vcpkg/globalstate.h b/toolsrc/include/vcpkg/globalstate.h index 35ca71dbba2..a5bc46ec5dd 100644 --- a/toolsrc/include/vcpkg/globalstate.h +++ b/toolsrc/include/vcpkg/globalstate.h @@ -1,11 +1,11 @@ #pragma once -#include -#include - #include #include +#include +#include + namespace vcpkg { struct GlobalState diff --git a/toolsrc/include/vcpkg/help.h b/toolsrc/include/vcpkg/help.h index 97bc1186409..bebf91c646b 100644 --- a/toolsrc/include/vcpkg/help.h +++ b/toolsrc/include/vcpkg/help.h @@ -1,10 +1,10 @@ #pragma once +#include + #include #include -#include - namespace vcpkg::Help { extern const CommandStructure COMMAND_STRUCTURE; diff --git a/toolsrc/include/vcpkg/install.h b/toolsrc/include/vcpkg/install.h index 2700ac3a88e..81beb8a15bf 100644 --- a/toolsrc/include/vcpkg/install.h +++ b/toolsrc/include/vcpkg/install.h @@ -1,13 +1,13 @@ #pragma once +#include + #include #include #include #include #include -#include - namespace vcpkg::Install { enum class KeepGoing diff --git a/toolsrc/include/vcpkg/metrics.h b/toolsrc/include/vcpkg/metrics.h index 89fb8a92f97..67fbfc00fa7 100644 --- a/toolsrc/include/vcpkg/metrics.h +++ b/toolsrc/include/vcpkg/metrics.h @@ -1,10 +1,10 @@ #pragma once -#include -#include - #include +#include +#include + namespace vcpkg::Metrics { struct Metrics : Util::ResourceBase diff --git a/toolsrc/include/vcpkg/packagespec.h b/toolsrc/include/vcpkg/packagespec.h index ae771f20c3f..014c1318d2f 100644 --- a/toolsrc/include/vcpkg/packagespec.h +++ b/toolsrc/include/vcpkg/packagespec.h @@ -21,7 +21,7 @@ namespace vcpkg struct PackageSpec { PackageSpec() = default; - PackageSpec(std::string name, Triplet triplet) : m_name(std::move(name)), m_triplet(triplet) {} + PackageSpec(std::string name, Triplet triplet) : m_name(std::move(name)), m_triplet(triplet) { } static std::vector to_package_specs(const std::vector& ports, Triplet triplet); @@ -54,7 +54,7 @@ namespace vcpkg /// struct FeatureSpec { - FeatureSpec(const PackageSpec& spec, const std::string& feature) : m_spec(spec), m_feature(feature) {} + FeatureSpec(const PackageSpec& spec, const std::string& feature) : m_spec(spec), m_feature(feature) { } const std::string& name() const { return m_spec.name(); } const std::string& feature() const { return m_feature; } diff --git a/toolsrc/include/vcpkg/paragraphparser.h b/toolsrc/include/vcpkg/paragraphparser.h index 71d11ddd032..1f48a720f28 100644 --- a/toolsrc/include/vcpkg/paragraphparser.h +++ b/toolsrc/include/vcpkg/paragraphparser.h @@ -1,15 +1,15 @@ #pragma once -#include -#include -#include - #include #include #include #include #include +#include +#include +#include + namespace vcpkg::Parse { struct ParseControlErrorInfo diff --git a/toolsrc/include/vcpkg/paragraphs.h b/toolsrc/include/vcpkg/paragraphs.h index 8f1c09c5b02..67077f6c2c9 100644 --- a/toolsrc/include/vcpkg/paragraphs.h +++ b/toolsrc/include/vcpkg/paragraphs.h @@ -1,11 +1,10 @@ #pragma once +#include #include #include #include -#include - namespace vcpkg::Paragraphs { using Paragraph = Parse::Paragraph; @@ -17,7 +16,10 @@ namespace vcpkg::Paragraphs bool is_port_directory(const Files::Filesystem& fs, const fs::path& path); - Parse::ParseExpected try_load_manifest(const Files::Filesystem& fs, const std::string& port_name, const fs::path& path_to_manifest, std::error_code& ec); + Parse::ParseExpected try_load_manifest(const Files::Filesystem& fs, + const std::string& port_name, + const fs::path& path_to_manifest, + std::error_code& ec); Parse::ParseExpected try_load_port(const Files::Filesystem& fs, const fs::path& path); diff --git a/toolsrc/include/vcpkg/platform-expression.h b/toolsrc/include/vcpkg/platform-expression.h index d857d75dc62..8beb5d1d9b2 100644 --- a/toolsrc/include/vcpkg/platform-expression.h +++ b/toolsrc/include/vcpkg/platform-expression.h @@ -2,6 +2,7 @@ #include #include + #include #include diff --git a/toolsrc/include/vcpkg/postbuildlint.buildtype.h b/toolsrc/include/vcpkg/postbuildlint.buildtype.h index 0b469d9a0d3..c99fe6084f9 100644 --- a/toolsrc/include/vcpkg/postbuildlint.buildtype.h +++ b/toolsrc/include/vcpkg/postbuildlint.buildtype.h @@ -1,11 +1,11 @@ #pragma once -#include -#include - #include #include +#include +#include + namespace vcpkg::PostBuildLint { struct BuildType diff --git a/toolsrc/include/vcpkg/sourceparagraph.h b/toolsrc/include/vcpkg/sourceparagraph.h index 4212258ab48..00b847e64e0 100644 --- a/toolsrc/include/vcpkg/sourceparagraph.h +++ b/toolsrc/include/vcpkg/sourceparagraph.h @@ -5,9 +5,9 @@ #include #include #include -#include #include #include +#include namespace vcpkg { diff --git a/toolsrc/include/vcpkg/statusparagraph.h b/toolsrc/include/vcpkg/statusparagraph.h index fdcb5337d8c..5228e296486 100644 --- a/toolsrc/include/vcpkg/statusparagraph.h +++ b/toolsrc/include/vcpkg/statusparagraph.h @@ -1,9 +1,9 @@ #pragma once -#include - #include +#include + namespace vcpkg { enum class InstallState @@ -47,7 +47,7 @@ namespace vcpkg struct InstalledPackageView { - InstalledPackageView() noexcept : core(nullptr) {} + InstalledPackageView() noexcept : core(nullptr) { } InstalledPackageView(const StatusParagraph* c, std::vector&& fs) : core(c), features(std::move(fs)) diff --git a/toolsrc/include/vcpkg/statusparagraphs.h b/toolsrc/include/vcpkg/statusparagraphs.h index 8fd85b4e05f..bebb4a3e035 100644 --- a/toolsrc/include/vcpkg/statusparagraphs.h +++ b/toolsrc/include/vcpkg/statusparagraphs.h @@ -1,9 +1,9 @@ #pragma once -#include - #include #include +#include + namespace vcpkg { /// Status paragraphs diff --git a/toolsrc/include/vcpkg/tools.h b/toolsrc/include/vcpkg/tools.h index 6a096c32185..7c5ad0480f1 100644 --- a/toolsrc/include/vcpkg/tools.h +++ b/toolsrc/include/vcpkg/tools.h @@ -1,17 +1,17 @@ #pragma once -#include - #include #include +#include + namespace vcpkg { struct VcpkgPaths; struct ToolCache { - virtual ~ToolCache() {} + virtual ~ToolCache() { } virtual const fs::path& get_tool_path(const VcpkgPaths& paths, const std::string& tool) const = 0; virtual const std::string& get_tool_version(const VcpkgPaths& paths, const std::string& tool) const = 0; diff --git a/toolsrc/include/vcpkg/triplet.h b/toolsrc/include/vcpkg/triplet.h index 4a88f5708b6..d23887b47e1 100644 --- a/toolsrc/include/vcpkg/triplet.h +++ b/toolsrc/include/vcpkg/triplet.h @@ -1,9 +1,9 @@ #pragma once #include -#include -#include +#include +#include #include namespace vcpkg diff --git a/toolsrc/include/vcpkg/userconfig.h b/toolsrc/include/vcpkg/userconfig.h index d044f43ef7f..4a93472e2e8 100644 --- a/toolsrc/include/vcpkg/userconfig.h +++ b/toolsrc/include/vcpkg/userconfig.h @@ -1,6 +1,7 @@ #pragma once #include + #include namespace vcpkg diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index d8dc94a3776..0ab5917b56b 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -1,15 +1,15 @@ #pragma once -#include -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include + namespace vcpkg { struct ParsedArguments diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 296b6a31429..ba7b01e0e5c 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -1,15 +1,14 @@ #pragma once -#include -#include -#include -#include - #include #include #include #include #include +#include +#include +#include +#include namespace vcpkg { diff --git a/toolsrc/src/vcpkg-fuzz/main.cpp b/toolsrc/src/vcpkg-fuzz/main.cpp index bbff0d98d9d..af482fb56c0 100644 --- a/toolsrc/src/vcpkg-fuzz/main.cpp +++ b/toolsrc/src/vcpkg-fuzz/main.cpp @@ -1,16 +1,16 @@ +#include + +#include +#include +#include + #include #include #include #include #include - #include -#include -#include -#include -#include - using namespace vcpkg; namespace @@ -86,9 +86,12 @@ namespace { auto first = std::find_if(arg.begin(), arg.end(), [](char c) { return c != '-'; }); auto division = std::find(first, arg.end(), '='); - if (division == arg.end()) { + if (division == arg.end()) + { return {StringView(first, arg.end()), StringView(arg.end(), arg.end())}; - } else { + } + else + { return {StringView(first, division), StringView(division + 1, arg.end())}; } } @@ -152,8 +155,10 @@ Options: [[noreturn]] void fuzz_platform_expr_and_exit(StringView text) { - auto res1 = PlatformExpression::parse_platform_expression(text, PlatformExpression::MultipleBinaryOperators::Deny); - auto res2 = PlatformExpression::parse_platform_expression(text, PlatformExpression::MultipleBinaryOperators::Allow); + auto res1 = + PlatformExpression::parse_platform_expression(text, PlatformExpression::MultipleBinaryOperators::Deny); + auto res2 = + PlatformExpression::parse_platform_expression(text, PlatformExpression::MultipleBinaryOperators::Allow); if (!res1) { diff --git a/toolsrc/src/vcpkg-test/arguments.cpp b/toolsrc/src/vcpkg-test/arguments.cpp index 3ce4c5a9bf5..a40edc945fa 100644 --- a/toolsrc/src/vcpkg-test/arguments.cpp +++ b/toolsrc/src/vcpkg-test/arguments.cpp @@ -1,9 +1,9 @@ #include -#include - #include +#include + using vcpkg::CommandSetting; using vcpkg::CommandStructure; using vcpkg::CommandSwitch; diff --git a/toolsrc/src/vcpkg-test/binarycaching.cpp b/toolsrc/src/vcpkg-test/binarycaching.cpp index b220b5ccba0..49386b52940 100644 --- a/toolsrc/src/vcpkg-test/binarycaching.cpp +++ b/toolsrc/src/vcpkg-test/binarycaching.cpp @@ -1,13 +1,15 @@ #include -#include -#include -#include -#include -#include -#include -#include + #include +#include +#include +#include +#include +#include +#include +#include + using namespace vcpkg; TEST_CASE ("reformat_version semver-ish", "[reformat_version]") diff --git a/toolsrc/src/vcpkg-test/binaryconfigparser.cpp b/toolsrc/src/vcpkg-test/binaryconfigparser.cpp index 11ed3290069..1fd15844658 100644 --- a/toolsrc/src/vcpkg-test/binaryconfigparser.cpp +++ b/toolsrc/src/vcpkg-test/binaryconfigparser.cpp @@ -1,4 +1,5 @@ #include + #include using namespace vcpkg; diff --git a/toolsrc/src/vcpkg-test/commands.build.cpp b/toolsrc/src/vcpkg-test/commands.build.cpp index bc0dc5b4ef0..573d217e4e7 100644 --- a/toolsrc/src/vcpkg-test/commands.build.cpp +++ b/toolsrc/src/vcpkg-test/commands.build.cpp @@ -1,12 +1,13 @@ #include -#include #include +#include + +#include #include #include #include #include -#include using namespace vcpkg; diff --git a/toolsrc/src/vcpkg-test/commands.create.cpp b/toolsrc/src/vcpkg-test/commands.create.cpp index 4a89d079955..345527cca7e 100644 --- a/toolsrc/src/vcpkg-test/commands.create.cpp +++ b/toolsrc/src/vcpkg-test/commands.create.cpp @@ -1,7 +1,8 @@ #include -#include #include +#include + #include #include #include @@ -11,7 +12,7 @@ TEST_CASE ("create smoke test", "[commands-create]") { using namespace vcpkg; static const std::string argsRaw[] = {"create", "zlib2", "http://zlib.net/zlib-1.2.11.tar.gz", "zlib-1.2.11.zip"}; - + auto& fsWrapper = Files::get_real_filesystem(); VcpkgCmdArguments args = VcpkgCmdArguments::create_from_arg_sequence(std::begin(argsRaw), std::end(argsRaw)); VcpkgPaths paths(fsWrapper, args); diff --git a/toolsrc/src/vcpkg-test/dependencies.cpp b/toolsrc/src/vcpkg-test/dependencies.cpp index 4a4b1ac06e2..ad4fff9e44c 100644 --- a/toolsrc/src/vcpkg-test/dependencies.cpp +++ b/toolsrc/src/vcpkg-test/dependencies.cpp @@ -1,4 +1,5 @@ #include + #include #include #include diff --git a/toolsrc/src/vcpkg-test/files.cpp b/toolsrc/src/vcpkg-test/files.cpp index cbe1e81c3c3..0a8362a51a4 100644 --- a/toolsrc/src/vcpkg-test/files.cpp +++ b/toolsrc/src/vcpkg-test/files.cpp @@ -1,14 +1,13 @@ #include -#include - -#include -#include #include #include - #include +#include +#include +#include + using vcpkg::Test::AllowSymlinks; using vcpkg::Test::base_temporary_directory; using vcpkg::Test::can_create_symlinks; @@ -38,21 +37,21 @@ namespace struct MaxDepth { std::uint64_t i; - explicit MaxDepth(std::uint64_t i) : i(i) {} + explicit MaxDepth(std::uint64_t i) : i(i) { } operator uint64_t() const { return i; } }; struct Width { std::uint64_t i; - explicit Width(std::uint64_t i) : i(i) {} + explicit Width(std::uint64_t i) : i(i) { } operator uint64_t() const { return i; } }; struct CurrentDepth { std::uint64_t i; - explicit CurrentDepth(std::uint64_t i) : i(i) {} + explicit CurrentDepth(std::uint64_t i) : i(i) { } operator uint64_t() const { return i; } CurrentDepth incremented() const { return CurrentDepth{i + 1}; } }; diff --git a/toolsrc/src/vcpkg-test/hash.cpp b/toolsrc/src/vcpkg-test/hash.cpp index 9f3ccc25e95..88c7bd7b079 100644 --- a/toolsrc/src/vcpkg-test/hash.cpp +++ b/toolsrc/src/vcpkg-test/hash.cpp @@ -1,12 +1,12 @@ #include -#include - #include #include #include #include +#include + namespace Hash = vcpkg::Hash; using vcpkg::StringView; diff --git a/toolsrc/src/vcpkg-test/json.cpp b/toolsrc/src/vcpkg-test/json.cpp index 86335d468aa..19aaaa6fe41 100644 --- a/toolsrc/src/vcpkg-test/json.cpp +++ b/toolsrc/src/vcpkg-test/json.cpp @@ -1,10 +1,10 @@ #include #include -#include -#include #include "math.h" +#include +#include // TODO: remove this once we switch to C++20 completely // This is the worst, but we also can't really deal with it any other way. @@ -178,7 +178,8 @@ TEST_CASE ("JSON parse full file", "[json]") ; auto res = Json::parse(json); - if (!res) { + if (!res) + { std::cerr << res.error()->format() << '\n'; } REQUIRE(res); diff --git a/toolsrc/src/vcpkg-test/manifests.cpp b/toolsrc/src/vcpkg-test/manifests.cpp index a6c661301c3..bfe15cd2a94 100644 --- a/toolsrc/src/vcpkg-test/manifests.cpp +++ b/toolsrc/src/vcpkg-test/manifests.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include @@ -108,9 +108,12 @@ TEST_CASE ("manifest construct maximum", "[manifests]") REQUIRE(pgh.feature_paragraphs[0]->dependencies[2].name == "order.white-lotus"); REQUIRE(pgh.feature_paragraphs[0]->dependencies[2].features.size() == 1); REQUIRE(pgh.feature_paragraphs[0]->dependencies[2].features[0] == "the-ancient-ways"); - REQUIRE_FALSE(pgh.feature_paragraphs[0]->dependencies[2].platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}, {"VCPKG_TARGET_ARCHITECTURE", "arm"}})); - REQUIRE(pgh.feature_paragraphs[0]->dependencies[2].platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}, {"VCPKG_TARGET_ARCHITECTURE", "x86"}})); - REQUIRE(pgh.feature_paragraphs[0]->dependencies[2].platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}, {"VCPKG_TARGET_ARCHITECTURE", "x86"}})); + REQUIRE_FALSE(pgh.feature_paragraphs[0]->dependencies[2].platform.evaluate( + {{"VCPKG_CMAKE_SYSTEM_NAME", ""}, {"VCPKG_TARGET_ARCHITECTURE", "arm"}})); + REQUIRE(pgh.feature_paragraphs[0]->dependencies[2].platform.evaluate( + {{"VCPKG_CMAKE_SYSTEM_NAME", ""}, {"VCPKG_TARGET_ARCHITECTURE", "x86"}})); + REQUIRE(pgh.feature_paragraphs[0]->dependencies[2].platform.evaluate( + {{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}, {"VCPKG_TARGET_ARCHITECTURE", "x86"}})); REQUIRE(pgh.feature_paragraphs[1]->name == "zuko"); REQUIRE(pgh.feature_paragraphs[1]->description.size() == 2); @@ -230,6 +233,7 @@ TEST_CASE ("SourceParagraph manifest empty supports", "[manifests]") "name": "a", "version-string": "1.0", "supports": "" - })json", true); + })json", + true); REQUIRE_FALSE(m_pgh.has_value()); } diff --git a/toolsrc/src/vcpkg-test/optional.cpp b/toolsrc/src/vcpkg-test/optional.cpp index c2348c5c615..f7b2770b8a7 100644 --- a/toolsrc/src/vcpkg-test/optional.cpp +++ b/toolsrc/src/vcpkg-test/optional.cpp @@ -1,7 +1,9 @@ #include -#include + #include +#include + namespace { struct identity_projection diff --git a/toolsrc/src/vcpkg-test/paragraph.cpp b/toolsrc/src/vcpkg-test/paragraph.cpp index 6c2103d5f37..e4b2cf0e22e 100644 --- a/toolsrc/src/vcpkg-test/paragraph.cpp +++ b/toolsrc/src/vcpkg-test/paragraph.cpp @@ -1,8 +1,7 @@ #include + #include - #include - #include namespace Strings = vcpkg::Strings; diff --git a/toolsrc/src/vcpkg-test/plan.cpp b/toolsrc/src/vcpkg-test/plan.cpp index b93ec54ce59..a6c9a54ec56 100644 --- a/toolsrc/src/vcpkg-test/plan.cpp +++ b/toolsrc/src/vcpkg-test/plan.cpp @@ -1,17 +1,17 @@ #include + +#include +#include +#include + #include #include - #include #include #include #include #include -#include -#include -#include - using namespace vcpkg; using Test::make_control_file; diff --git a/toolsrc/src/vcpkg-test/statusparagraphs.cpp b/toolsrc/src/vcpkg-test/statusparagraphs.cpp index acb8b333c01..f2d8ba37cf0 100644 --- a/toolsrc/src/vcpkg-test/statusparagraphs.cpp +++ b/toolsrc/src/vcpkg-test/statusparagraphs.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include diff --git a/toolsrc/src/vcpkg-test/strings.cpp b/toolsrc/src/vcpkg-test/strings.cpp index 3172b557f09..da319897657 100644 --- a/toolsrc/src/vcpkg-test/strings.cpp +++ b/toolsrc/src/vcpkg-test/strings.cpp @@ -1,11 +1,12 @@ #include -#include - #include + +#include #include #include -#include + +#include TEST_CASE ("b32 encoding", "[strings]") { diff --git a/toolsrc/src/vcpkg-test/stringview.cpp b/toolsrc/src/vcpkg-test/stringview.cpp index 4df8e6be567..953a7de9960 100644 --- a/toolsrc/src/vcpkg-test/stringview.cpp +++ b/toolsrc/src/vcpkg-test/stringview.cpp @@ -2,16 +2,18 @@ #include -template -static vcpkg::StringView sv(const char (&cstr)[N]) { - return cstr; +template +static vcpkg::StringView sv(const char (&cstr)[N]) +{ + return cstr; } -TEST_CASE("string view operator==", "[stringview]") { - // these are due to a bug in operator== - // see commit 782723959399a1a0725ac49 - REQUIRE(sv("hey") != sv("heys")); - REQUIRE(sv("heys") != sv("hey")); - REQUIRE(sv("hey") == sv("hey")); - REQUIRE(sv("hey") != sv("hex")); +TEST_CASE ("string view operator==", "[stringview]") +{ + // these are due to a bug in operator== + // see commit 782723959399a1a0725ac49 + REQUIRE(sv("hey") != sv("heys")); + REQUIRE(sv("heys") != sv("hey")); + REQUIRE(sv("hey") == sv("hey")); + REQUIRE(sv("hey") != sv("hex")); } diff --git a/toolsrc/src/vcpkg-test/system.cpp b/toolsrc/src/vcpkg-test/system.cpp index 8b44f8f24fd..596b569a71a 100644 --- a/toolsrc/src/vcpkg-test/system.cpp +++ b/toolsrc/src/vcpkg-test/system.cpp @@ -1,13 +1,15 @@ #include + #include #include + #include -#include -#include #include +#include #include #include +#include using vcpkg::nullopt; using vcpkg::Optional; diff --git a/toolsrc/src/vcpkg-test/uint128.cpp b/toolsrc/src/vcpkg-test/uint128.cpp index 57d0169afc1..a13b25e4f96 100644 --- a/toolsrc/src/vcpkg-test/uint128.cpp +++ b/toolsrc/src/vcpkg-test/uint128.cpp @@ -2,63 +2,67 @@ #include -TEST_CASE ("uint128 constructor and assign", "[uint128]") { - vcpkg::UInt128 x = 120; - REQUIRE(x.bottom_64_bits() == 120); - REQUIRE(x.top_64_bits() == 0); +TEST_CASE ("uint128 constructor and assign", "[uint128]") +{ + vcpkg::UInt128 x = 120; + REQUIRE(x.bottom_64_bits() == 120); + REQUIRE(x.top_64_bits() == 0); - x = 3201; - REQUIRE(x.bottom_64_bits() == 3201); - REQUIRE(x.top_64_bits() == 0); - - x = 0xFFFF'FFFF'FFFF'FFFF; - REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'FFFF'FFFF); - REQUIRE(x.top_64_bits() == 0); + x = 3201; + REQUIRE(x.bottom_64_bits() == 3201); + REQUIRE(x.top_64_bits() == 0); + + x = 0xFFFF'FFFF'FFFF'FFFF; + REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'FFFF'FFFF); + REQUIRE(x.top_64_bits() == 0); } -TEST_CASE ("uint128 add-assign", "[uint128]") { - vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF; - x += 1; - REQUIRE(x.bottom_64_bits() == 0); - REQUIRE(x.top_64_bits() == 1); +TEST_CASE ("uint128 add-assign", "[uint128]") +{ + vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF; + x += 1; + REQUIRE(x.bottom_64_bits() == 0); + REQUIRE(x.top_64_bits() == 1); } -TEST_CASE ("uint128 shl-assign", "[uint128]") { - vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF; - x <<= 32; - REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'0000'0000); - REQUIRE(x.top_64_bits() == 0x0000'0000'FFFF'FFFF); - - x <<= 60; - REQUIRE(x.bottom_64_bits() == 0); - REQUIRE(x.top_64_bits() == 0xFFFF'FFFF'F000'0000); +TEST_CASE ("uint128 shl-assign", "[uint128]") +{ + vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF; + x <<= 32; + REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'0000'0000); + REQUIRE(x.top_64_bits() == 0x0000'0000'FFFF'FFFF); - x = 1; - x <<= 96; - REQUIRE(x.bottom_64_bits() == 0); - REQUIRE(x.top_64_bits() == (uint64_t(1) << 32)); + x <<= 60; + REQUIRE(x.bottom_64_bits() == 0); + REQUIRE(x.top_64_bits() == 0xFFFF'FFFF'F000'0000); + + x = 1; + x <<= 96; + REQUIRE(x.bottom_64_bits() == 0); + REQUIRE(x.top_64_bits() == (uint64_t(1) << 32)); } -TEST_CASE ("uint128 shr-assign", "[uint128]") { - vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF; - x <<= 64; - REQUIRE(x.bottom_64_bits() == 0x0000'0000'0000'0000); - REQUIRE(x.top_64_bits() == 0xFFFF'FFFF'FFFF'FFFF); +TEST_CASE ("uint128 shr-assign", "[uint128]") +{ + vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF; + x <<= 64; + REQUIRE(x.bottom_64_bits() == 0x0000'0000'0000'0000); + REQUIRE(x.top_64_bits() == 0xFFFF'FFFF'FFFF'FFFF); - x >>= 32; - REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'0000'0000); - REQUIRE(x.top_64_bits() == 0x0000'0000'FFFF'FFFF); - - x >>= 60; - REQUIRE(x.bottom_64_bits() == 0x0000'000F'FFFF'FFFF); - REQUIRE(x.top_64_bits() == 0x0000'0000'0000'0000); + x >>= 32; + REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'0000'0000); + REQUIRE(x.top_64_bits() == 0x0000'0000'FFFF'FFFF); - x = 0x8000'0000'0000'0000; - x <<= 64; - REQUIRE(x.bottom_64_bits() == 0); - REQUIRE(x.top_64_bits() == 0x8000'0000'0000'0000); + x >>= 60; + REQUIRE(x.bottom_64_bits() == 0x0000'000F'FFFF'FFFF); + REQUIRE(x.top_64_bits() == 0x0000'0000'0000'0000); - x >>= 96; - REQUIRE(x.bottom_64_bits() == (uint64_t(1) << 31)); - REQUIRE(x.top_64_bits() == 0); + x = 0x8000'0000'0000'0000; + x <<= 64; + REQUIRE(x.bottom_64_bits() == 0); + REQUIRE(x.top_64_bits() == 0x8000'0000'0000'0000); + + x >>= 96; + REQUIRE(x.bottom_64_bits() == (uint64_t(1) << 31)); + REQUIRE(x.top_64_bits() == 0); } diff --git a/toolsrc/src/vcpkg-test/update.cpp b/toolsrc/src/vcpkg-test/update.cpp index 5370a842160..0ae89385561 100644 --- a/toolsrc/src/vcpkg-test/update.cpp +++ b/toolsrc/src/vcpkg-test/update.cpp @@ -1,8 +1,7 @@ #include + #include - #include - #include using namespace vcpkg; diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp index c0b8981455f..c857db5b212 100644 --- a/toolsrc/src/vcpkg-test/util.cpp +++ b/toolsrc/src/vcpkg-test/util.cpp @@ -1,8 +1,8 @@ #include #include -#include +#include #include #include #include @@ -10,7 +10,6 @@ // used to get the implementation specific compiler flags (i.e., __cpp_lib_filesystem) #include - #include #include @@ -114,18 +113,20 @@ namespace vcpkg::Test #elif !defined(_WIN32) // FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD return AllowSymlinks::Yes; #else - constexpr static const wchar_t regkey[] = - LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock)"; + constexpr static const wchar_t regkey[] = LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock)"; constexpr static const wchar_t regkey_member[] = LR"(AllowDevelopmentWithoutDevLicense)"; DWORD data; DWORD dataSize = sizeof(data); - const auto status = RegGetValueW( - HKEY_LOCAL_MACHINE, regkey, regkey_member, RRF_RT_DWORD, nullptr, &data, &dataSize); + const auto status = + RegGetValueW(HKEY_LOCAL_MACHINE, regkey, regkey_member, RRF_RT_DWORD, nullptr, &data, &dataSize); - if (status == ERROR_SUCCESS && data == 1) { + if (status == ERROR_SUCCESS && data == 1) + { return AllowSymlinks::Yes; - } else { + } + else + { std::cout << "Symlinks are not allowed on this system\n"; return AllowSymlinks::No; } @@ -155,7 +156,6 @@ namespace vcpkg::Test #endif } - const fs::path& base_temporary_directory() noexcept { const static fs::path BASE_TEMPORARY_DIRECTORY = internal_base_temporary_directory(); diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 9cd9640675b..b6f0782fa6d 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -1,9 +1,13 @@ -#include - #include +#include +#include +#include +#include + #include #include +#include #include #include #include @@ -17,11 +21,6 @@ #include #include -#include -#include -#include -#include - #if defined(_WIN32) #pragma comment(lib, "ole32") #pragma comment(lib, "shell32") diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index 32a3821548f..55193899099 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -10,6 +10,7 @@ #if !defined(_WIN32) #include + #include #include #endif diff --git a/toolsrc/src/vcpkg/base/hash.cpp b/toolsrc/src/vcpkg/base/hash.cpp index 45ce43cdd29..58e17e1ad47 100644 --- a/toolsrc/src/vcpkg/base/hash.cpp +++ b/toolsrc/src/vcpkg/base/hash.cpp @@ -1,11 +1,10 @@ #include "pch.h" -#include - #include -#include +#include #include #include +#include #include #if defined(_WIN32) @@ -51,12 +50,14 @@ namespace vcpkg::Hash } } - template - auto top_bits(UIntTy x) -> std::enable_if_t::value, uchar> { + template + auto top_bits(UIntTy x) -> std::enable_if_t::value, uchar> + { return static_cast(x >> ((sizeof(x) - 1) * 8)); } - template - auto top_bits(UIntTy x) -> decltype(top_bits(x.top_64_bits())) { + template + auto top_bits(UIntTy x) -> decltype(top_bits(x.top_64_bits())) + { return top_bits(x.top_64_bits()); } diff --git a/toolsrc/src/vcpkg/base/json.cpp b/toolsrc/src/vcpkg/base/json.cpp index 0972915eba2..1e9b413c908 100644 --- a/toolsrc/src/vcpkg/base/json.cpp +++ b/toolsrc/src/vcpkg/base/json.cpp @@ -1,12 +1,12 @@ #include "pch.h" +#include + #include #include #include #include -#include - namespace vcpkg::Json { using VK = ValueKind; @@ -154,10 +154,7 @@ namespace vcpkg::Json vcpkg::Checks::check_exit(VCPKG_LINE_INFO, is_array()); return underlying_->array; } - Array&& Value::array() && noexcept - { - return std::move(this->array()); - } + Array&& Value::array() && noexcept { return std::move(this->array()); } const Object& Value::object() const& noexcept { @@ -169,10 +166,7 @@ namespace vcpkg::Json vcpkg::Checks::check_exit(VCPKG_LINE_INFO, is_object()); return underlying_->object; } - Object&& Value::object() && noexcept - { - return std::move(this->object()); - } + Object&& Value::object() && noexcept { return std::move(this->object()); } Value::Value() noexcept = default; Value::Value(Value&&) noexcept = default; diff --git a/toolsrc/src/vcpkg/base/parse.cpp b/toolsrc/src/vcpkg/base/parse.cpp index 8e6b767d79a..026b58b7332 100644 --- a/toolsrc/src/vcpkg/base/parse.cpp +++ b/toolsrc/src/vcpkg/base/parse.cpp @@ -1,8 +1,8 @@ #include "pch.h" -#include - #include + +#include #include #include #include diff --git a/toolsrc/src/vcpkg/base/stringview.cpp b/toolsrc/src/vcpkg/base/stringview.cpp index 34798219898..1528cdf4592 100644 --- a/toolsrc/src/vcpkg/base/stringview.cpp +++ b/toolsrc/src/vcpkg/base/stringview.cpp @@ -1,11 +1,11 @@ #include "pch.h" +#include + #include #include #include -#include - namespace vcpkg { std::vector StringView::find_all_enclosed(const StringView& input, @@ -71,7 +71,7 @@ namespace vcpkg return result.front(); } - StringView::StringView(const std::string& s) : m_ptr(s.data()), m_size(s.size()) {} + StringView::StringView(const std::string& s) : m_ptr(s.data()), m_size(s.size()) { } std::string StringView::to_string() const { return std::string(m_ptr, m_size); } void StringView::to_string(std::string& s) const { s.append(m_ptr, m_size); } diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index 6fdfeb6a754..d02c7ae4b8f 100644 --- a/toolsrc/src/vcpkg/base/system.cpp +++ b/toolsrc/src/vcpkg/base/system.cpp @@ -1,13 +1,13 @@ #include "pch.h" +#include + #include #include #include #include #include -#include - using namespace vcpkg::System; namespace vcpkg diff --git a/toolsrc/src/vcpkg/base/system.process.cpp b/toolsrc/src/vcpkg/base/system.process.cpp index 96b4a9b4ae8..d709fdb607c 100644 --- a/toolsrc/src/vcpkg/base/system.process.cpp +++ b/toolsrc/src/vcpkg/base/system.process.cpp @@ -1,5 +1,7 @@ #include "pch.h" +#include + #include #include #include @@ -7,8 +9,6 @@ #include #include -#include - #if defined(__APPLE__) #include #endif @@ -30,7 +30,7 @@ namespace vcpkg { struct CtrlCStateMachine { - CtrlCStateMachine() : m_number_of_external_processes(0), m_global_job(NULL), m_in_interactive(0) {} + CtrlCStateMachine() : m_number_of_external_processes(0), m_global_job(NULL), m_in_interactive(0) { } void transition_to_spawn_process() noexcept { @@ -382,7 +382,7 @@ namespace vcpkg #if defined(_WIN32) struct ProcessInfo { - constexpr ProcessInfo() noexcept : proc_info{} {} + constexpr ProcessInfo() noexcept : proc_info{} { } ProcessInfo(ProcessInfo&& other) noexcept : proc_info(other.proc_info) { other.proc_info.hProcess = nullptr; @@ -724,6 +724,6 @@ namespace vcpkg SetConsoleCtrlHandler(reinterpret_cast(ctrl_handler), TRUE); } #else - void System::register_console_ctrl_handler() {} + void System::register_console_ctrl_handler() { } #endif } diff --git a/toolsrc/src/vcpkg/base/uint128.cpp b/toolsrc/src/vcpkg/base/uint128.cpp index e0256075e09..e5c872e4539 100644 --- a/toolsrc/src/vcpkg/base/uint128.cpp +++ b/toolsrc/src/vcpkg/base/uint128.cpp @@ -1,55 +1,66 @@ -#include - #include -namespace vcpkg { +#include -UInt128& UInt128::operator<<=(int by) noexcept { - if (by == 0) { - return *this; - } - - if (by < 64) { - top <<= by; - const auto shift_up = bottom >> (64 - by); - top |= shift_up; - bottom <<= by; - } else { - top = bottom; - top <<= (by - 64); - bottom = 0; - } - - return *this; -} - -UInt128& UInt128::operator>>=(int by) noexcept { - if (by == 0) { - return *this; - } - - if (by < 64) { - bottom >>= by; - const auto shift_down = top << (64 - by); - bottom |= shift_down; - top >>= by; - } else { - bottom = top; - bottom >>= (by - 64); - top = 0; - } - - return *this; -} - -UInt128& UInt128::operator+=(uint64_t rhs) noexcept { - // bottom + lhs > uint64::max - if (bottom > std::numeric_limits::max() - rhs) +namespace vcpkg +{ + UInt128& UInt128::operator<<=(int by) noexcept { - top += 1; + if (by == 0) + { + return *this; + } + + if (by < 64) + { + top <<= by; + const auto shift_up = bottom >> (64 - by); + top |= shift_up; + bottom <<= by; + } + else + { + top = bottom; + top <<= (by - 64); + bottom = 0; + } + + return *this; + } + + UInt128& UInt128::operator>>=(int by) noexcept + { + if (by == 0) + { + return *this; + } + + if (by < 64) + { + bottom >>= by; + const auto shift_down = top << (64 - by); + bottom |= shift_down; + top >>= by; + } + else + { + bottom = top; + bottom >>= (by - 64); + top = 0; + } + + return *this; + } + + UInt128& UInt128::operator+=(uint64_t rhs) noexcept + { + // bottom + lhs > uint64::max + if (bottom > std::numeric_limits::max() - rhs) + { + top += 1; + } + bottom += rhs; + return *this; } - bottom += rhs; - return *this; -} } diff --git a/toolsrc/src/vcpkg/base/unicode.cpp b/toolsrc/src/vcpkg/base/unicode.cpp index 41f996cdd5b..149bad20f91 100644 --- a/toolsrc/src/vcpkg/base/unicode.cpp +++ b/toolsrc/src/vcpkg/base/unicode.cpp @@ -1,8 +1,7 @@ #include "pch.h" -#include - #include +#include namespace vcpkg::Unicode { diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp index 21ef7094a0b..fbff12833d0 100644 --- a/toolsrc/src/vcpkg/binarycaching.cpp +++ b/toolsrc/src/vcpkg/binarycaching.cpp @@ -68,7 +68,7 @@ namespace { } ~ArchivesBinaryProvider() = default; - void prefetch(const VcpkgPaths&, const Dependencies::ActionPlan&) override {} + void prefetch(const VcpkgPaths&, const Dependencies::ActionPlan&) override { } RestoreResult try_restore(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) override { const auto& abi_tag = action.abi_info.value_or_exit(VCPKG_LINE_INFO).package_abi; @@ -522,12 +522,12 @@ namespace struct NullBinaryProvider : IBinaryProvider { - void prefetch(const VcpkgPaths&, const Dependencies::ActionPlan&) override {} + void prefetch(const VcpkgPaths&, const Dependencies::ActionPlan&) override { } RestoreResult try_restore(const VcpkgPaths&, const Dependencies::InstallPlanAction&) override { return RestoreResult::missing; } - void push_success(const VcpkgPaths&, const Dependencies::InstallPlanAction&) override {} + void push_success(const VcpkgPaths&, const Dependencies::InstallPlanAction&) override { } RestoreResult precheck(const VcpkgPaths&, const Dependencies::InstallPlanAction&) override { return RestoreResult::missing; diff --git a/toolsrc/src/vcpkg/binaryparagraph.cpp b/toolsrc/src/vcpkg/binaryparagraph.cpp index 0b0819fd718..871a1ed6294 100644 --- a/toolsrc/src/vcpkg/binaryparagraph.cpp +++ b/toolsrc/src/vcpkg/binaryparagraph.cpp @@ -3,7 +3,6 @@ #include #include #include - #include #include #include diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 37bf8c780c7..8ae4531cc80 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -11,7 +11,6 @@ #include #include #include - #include #include #include diff --git a/toolsrc/src/vcpkg/cmakevars.cpp b/toolsrc/src/vcpkg/cmakevars.cpp index de3b0204bee..d9ce1f48115 100644 --- a/toolsrc/src/vcpkg/cmakevars.cpp +++ b/toolsrc/src/vcpkg/cmakevars.cpp @@ -5,9 +5,8 @@ #include #include #include - -#include #include +#include #include using namespace vcpkg; @@ -31,7 +30,7 @@ namespace vcpkg::CMakeVars { struct TripletCMakeVarProvider : Util::ResourceBase, CMakeVarProvider { - explicit TripletCMakeVarProvider(const vcpkg::VcpkgPaths& paths) : paths(paths) {} + explicit TripletCMakeVarProvider(const vcpkg::VcpkgPaths& paths) : paths(paths) { } void load_generic_triplet_vars(Triplet triplet) const override; diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp index 8453d7af65f..41bc7458ee9 100644 --- a/toolsrc/src/vcpkg/commands.ci.cpp +++ b/toolsrc/src/vcpkg/commands.ci.cpp @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include using namespace vcpkg; @@ -32,7 +32,7 @@ namespace fs::path base_path; public: - CiBuildLogsRecorder(const fs::path& base_path_) : base_path(base_path_) {} + CiBuildLogsRecorder(const fs::path& base_path_) : base_path(base_path_) { } virtual void record_build_result(const VcpkgPaths& paths, const PackageSpec& spec, diff --git a/toolsrc/src/vcpkg/commands.ciclean.cpp b/toolsrc/src/vcpkg/commands.ciclean.cpp index 74b9b35ab53..33b7bf1c8cd 100644 --- a/toolsrc/src/vcpkg/commands.ciclean.cpp +++ b/toolsrc/src/vcpkg/commands.ciclean.cpp @@ -8,7 +8,8 @@ using namespace vcpkg; -namespace { +namespace +{ void clear_directory(Files::Filesystem& fs, const fs::path& target) { using vcpkg::System::print2; diff --git a/toolsrc/src/vcpkg/commands.cpp b/toolsrc/src/vcpkg/commands.cpp index be6d553047c..6f17e2d7b0a 100644 --- a/toolsrc/src/vcpkg/commands.cpp +++ b/toolsrc/src/vcpkg/commands.cpp @@ -2,7 +2,6 @@ #include #include - #include #include #include diff --git a/toolsrc/src/vcpkg/commands.dependinfo.cpp b/toolsrc/src/vcpkg/commands.dependinfo.cpp index c78c694f637..22e20c197bc 100644 --- a/toolsrc/src/vcpkg/commands.dependinfo.cpp +++ b/toolsrc/src/vcpkg/commands.dependinfo.cpp @@ -1,5 +1,7 @@ #include "pch.h" +#include + #include #include #include @@ -9,7 +11,6 @@ #include #include #include -#include using vcpkg::Dependencies::ActionPlan; using vcpkg::Dependencies::InstallPlanAction; diff --git a/toolsrc/src/vcpkg/commands.edit.cpp b/toolsrc/src/vcpkg/commands.edit.cpp index 1f00a929e79..9d9dfee8122 100644 --- a/toolsrc/src/vcpkg/commands.edit.cpp +++ b/toolsrc/src/vcpkg/commands.edit.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include + #include #include #include diff --git a/toolsrc/src/vcpkg/commands.env.cpp b/toolsrc/src/vcpkg/commands.env.cpp index 8cf264d1735..c6f0657c67c 100644 --- a/toolsrc/src/vcpkg/commands.env.cpp +++ b/toolsrc/src/vcpkg/commands.env.cpp @@ -2,7 +2,6 @@ #include #include - #include #include #include diff --git a/toolsrc/src/vcpkg/commands.format-manifest.cpp b/toolsrc/src/vcpkg/commands.format-manifest.cpp index 62e03dbcf17..c1dd3b6763a 100644 --- a/toolsrc/src/vcpkg/commands.format-manifest.cpp +++ b/toolsrc/src/vcpkg/commands.format-manifest.cpp @@ -9,22 +9,15 @@ namespace vcpkg::Commands::FormatManifest { - static constexpr StringLiteral OPTION_ALL = "--all"; - const CommandSwitch FORMAT_SWITCHES[] = { - { OPTION_ALL, "Format all ports' manifest files." } - }; + const CommandSwitch FORMAT_SWITCHES[] = {{OPTION_ALL, "Format all ports' manifest files."}}; const CommandStructure COMMAND_STRUCTURE = { create_example_string(R"###(x-format-manifest --all)###"), 0, SIZE_MAX, - { - FORMAT_SWITCHES, - {}, - {} - }, + {FORMAT_SWITCHES, {}, {}}, nullptr, }; @@ -76,7 +69,10 @@ namespace vcpkg::Commands::FormatManifest } else { - System::printf(System::Color::error, "Failed to parse %s: %s\n", path.u8string(), parsed_json_opt.error()->format()); + System::printf(System::Color::error, + "Failed to parse %s: %s\n", + path.u8string(), + parsed_json_opt.error()->format()); has_error = true; } diff --git a/toolsrc/src/vcpkg/commands.owns.cpp b/toolsrc/src/vcpkg/commands.owns.cpp index 98d571df572..680ab292e28 100644 --- a/toolsrc/src/vcpkg/commands.owns.cpp +++ b/toolsrc/src/vcpkg/commands.owns.cpp @@ -24,8 +24,7 @@ namespace vcpkg::Commands::Owns } } const CommandStructure COMMAND_STRUCTURE = { - Strings::format("The argument should be a pattern to search for. %s", - create_example_string("owns zlib.dll")), + Strings::format("The argument should be a pattern to search for. %s", create_example_string("owns zlib.dll")), 1, 1, {}, diff --git a/toolsrc/src/vcpkg/commands.porthistory.cpp b/toolsrc/src/vcpkg/commands.porthistory.cpp index 086c9d358dc..0f4d9716f47 100644 --- a/toolsrc/src/vcpkg/commands.porthistory.cpp +++ b/toolsrc/src/vcpkg/commands.porthistory.cpp @@ -1,11 +1,10 @@ #include "pch.h" -#include -#include - #include #include #include +#include +#include namespace vcpkg::Commands::PortHistory { diff --git a/toolsrc/src/vcpkg/commands.portsdiff.cpp b/toolsrc/src/vcpkg/commands.portsdiff.cpp index 2ed05cb606d..ed5044a6018 100644 --- a/toolsrc/src/vcpkg/commands.portsdiff.cpp +++ b/toolsrc/src/vcpkg/commands.portsdiff.cpp @@ -1,14 +1,13 @@ #include "pch.h" -#include -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include namespace vcpkg::Commands::PortsDiff { diff --git a/toolsrc/src/vcpkg/commands.upgrade.cpp b/toolsrc/src/vcpkg/commands.upgrade.cpp index 32071259bd5..f3e0ca23385 100644 --- a/toolsrc/src/vcpkg/commands.upgrade.cpp +++ b/toolsrc/src/vcpkg/commands.upgrade.cpp @@ -1,5 +1,7 @@ #include "pch.h" +#include +#include #include #include #include @@ -11,9 +13,6 @@ #include #include -#include -#include - namespace vcpkg::Commands::Upgrade { using Install::KeepGoing; diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 3819584f944..73d83e3c881 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -1,5 +1,9 @@ #include "pch.h" +#include +#include +#include +#include #include #include #include @@ -12,11 +16,6 @@ #include #include -#include -#include -#include -#include - namespace vcpkg::Export { using Dependencies::ExportPlanAction; diff --git a/toolsrc/src/vcpkg/export.prefab.cpp b/toolsrc/src/vcpkg/export.prefab.cpp index 84a099edd85..b88d57638a8 100644 --- a/toolsrc/src/vcpkg/export.prefab.cpp +++ b/toolsrc/src/vcpkg/export.prefab.cpp @@ -436,7 +436,8 @@ namespace vcpkg::Export::Prefab utils.create_directories(meta_dir, error_code); - const fs::path share_root = paths.packages / fs::u8path(Strings::format("%s_%s", name, action.spec.triplet())); + const fs::path share_root = + paths.packages / fs::u8path(Strings::format("%s_%s", name, action.spec.triplet())); utils.copy_file(share_root / "share" / name / "copyright", meta_dir / "LICENSE", @@ -518,7 +519,8 @@ namespace vcpkg::Export::Prefab for (const auto& triplet : triplets) { const fs::path listfile = - paths.vcpkg_dir_info / fs::u8path(Strings::format("%s_%s_%s", name, norm_version, triplet) + ".list"); + paths.vcpkg_dir_info / + fs::u8path(Strings::format("%s_%s_%s", name, norm_version, triplet) + ".list"); const fs::path installed_dir = paths.packages / fs::u8path(Strings::format("%s_%s", name, triplet)); Checks::check_exit(VCPKG_LINE_INFO, utils.exists(listfile), @@ -704,10 +706,9 @@ namespace vcpkg::Export::Prefab )"); } } - System::print2(System::Color::success, - Strings::format("Successfuly exported %s. Checkout %s \n", - name, - paths.prefab.generic_u8string())); + System::print2( + System::Color::success, + Strings::format("Successfuly exported %s. Checkout %s \n", name, paths.prefab.generic_u8string())); } } } diff --git a/toolsrc/src/vcpkg/help.cpp b/toolsrc/src/vcpkg/help.cpp index 46fac622b5e..f9018526688 100644 --- a/toolsrc/src/vcpkg/help.cpp +++ b/toolsrc/src/vcpkg/help.cpp @@ -14,7 +14,7 @@ namespace vcpkg::Help { using topic_function = void (*)(const VcpkgPaths& paths); - constexpr Topic(CStringView n, topic_function fn) : name(n), print(fn) {} + constexpr Topic(CStringView n, topic_function fn) : name(n), print(fn) { } CStringView name; topic_function print; diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index 842a7a7faf5..b5024e0a51d 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -434,7 +434,9 @@ namespace vcpkg::Install SpecSummary* current_summary = nullptr; Chrono::ElapsedTimer build_timer = Chrono::ElapsedTimer::create_started(); - TrackedPackageInstallGuard(const size_t package_count, std::vector& results, const PackageSpec& spec) + TrackedPackageInstallGuard(const size_t package_count, + std::vector& results, + const PackageSpec& spec) { results.emplace_back(spec, nullptr); current_summary = &results.back(); diff --git a/toolsrc/src/vcpkg/metrics.cpp b/toolsrc/src/vcpkg/metrics.cpp index 7920cd7a5dc..d1f8f6fe8ce 100644 --- a/toolsrc/src/vcpkg/metrics.cpp +++ b/toolsrc/src/vcpkg/metrics.cpp @@ -1,14 +1,13 @@ #include "pch.h" -#include -#include - #include #include #include #include #include #include +#include +#include #if defined(_WIN32) #pragma comment(lib, "version") @@ -30,9 +29,11 @@ namespace vcpkg::Metrics return ""; } - struct append_hexits { + struct append_hexits + { constexpr static char hex[17] = "0123456789abcdef"; - void operator()(std::string& res, std::uint8_t bits) const { + void operator()(std::string& res, std::uint8_t bits) const + { res.push_back(hex[(bits >> 4) & 0x0F]); res.push_back(hex[(bits >> 0) & 0x0F]); } diff --git a/toolsrc/src/vcpkg/packagespec.cpp b/toolsrc/src/vcpkg/packagespec.cpp index f8280687951..99b6a79d65e 100644 --- a/toolsrc/src/vcpkg/packagespec.cpp +++ b/toolsrc/src/vcpkg/packagespec.cpp @@ -244,7 +244,8 @@ namespace vcpkg return nullopt; } platform_string.append((++loc.it).pointer_to_current(), parser.it().pointer_to_current()); - auto platform_opt = PlatformExpression::parse_platform_expression(platform_string, PlatformExpression::MultipleBinaryOperators::Allow); + auto platform_opt = PlatformExpression::parse_platform_expression( + platform_string, PlatformExpression::MultipleBinaryOperators::Allow); if (auto platform = platform_opt.get()) { ret.platform = std::move(*platform); diff --git a/toolsrc/src/vcpkg/paragraphs.cpp b/toolsrc/src/vcpkg/paragraphs.cpp index 458950eead8..94a5a8442e8 100644 --- a/toolsrc/src/vcpkg/paragraphs.cpp +++ b/toolsrc/src/vcpkg/paragraphs.cpp @@ -133,7 +133,10 @@ namespace vcpkg::Paragraphs return fs.exists(path / fs::u8path("CONTROL")) || fs.exists(path / fs::u8path("vcpkg.json")); } - ParseExpected try_load_manifest(const Files::Filesystem& fs, const std::string& port_name, const fs::path& path_to_manifest, std::error_code& ec) + ParseExpected try_load_manifest(const Files::Filesystem& fs, + const std::string& port_name, + const fs::path& path_to_manifest, + std::error_code& ec) { auto error_info = std::make_unique(); auto res = Json::parse_file(fs, path_to_manifest, ec); @@ -164,12 +167,12 @@ namespace vcpkg::Paragraphs { const auto path_to_manifest = path / fs::u8path("vcpkg.json"); const auto path_to_control = path / fs::u8path("CONTROL"); - if (fs.exists(path_to_manifest)) { - vcpkg::Checks::check_exit( - VCPKG_LINE_INFO, - !fs.exists(path_to_control), - "Found both manifest and CONTROL file in port %s; please rename one or the other", - path.u8string()); + if (fs.exists(path_to_manifest)) + { + vcpkg::Checks::check_exit(VCPKG_LINE_INFO, + !fs.exists(path_to_control), + "Found both manifest and CONTROL file in port %s; please rename one or the other", + path.u8string()); std::error_code ec; auto res = try_load_manifest(fs, path.filename().u8string(), path_to_manifest, ec); @@ -177,7 +180,8 @@ namespace vcpkg::Paragraphs { auto error_info = std::make_unique(); error_info->name = path.filename().u8string(); - error_info->error = Strings::format("Failed to load manifest file for port: %s\n", path_to_manifest.u8string(), ec.message()); + error_info->error = Strings::format( + "Failed to load manifest file for port: %s\n", path_to_manifest.u8string(), ec.message()); } return res; diff --git a/toolsrc/src/vcpkg/platform-expression.cpp b/toolsrc/src/vcpkg/platform-expression.cpp index 9b83372e1ae..bbc0a253e79 100644 --- a/toolsrc/src/vcpkg/platform-expression.cpp +++ b/toolsrc/src/vcpkg/platform-expression.cpp @@ -1,14 +1,14 @@ #include "pch.h" +#include +#include + #include #include #include #include #include -#include -#include - namespace vcpkg::PlatformExpression { using vcpkg::Parse::ParseError; @@ -76,9 +76,9 @@ namespace vcpkg::PlatformExpression { } - ExprImpl(ExprKind k, std::string i) : kind(k), identifier(std::move(i)) {} + ExprImpl(ExprKind k, std::string i) : kind(k), identifier(std::move(i)) { } ExprImpl(ExprKind k, std::unique_ptr a) : kind(k) { exprs.push_back(std::move(a)); } - ExprImpl(ExprKind k, std::vector> es) : kind(k), exprs(std::move(es)) {} + ExprImpl(ExprKind k, std::vector> es) : kind(k), exprs(std::move(es)) { } ExprKind kind; std::string identifier; @@ -258,7 +258,7 @@ namespace vcpkg::PlatformExpression return *this; } - Expr::Expr(std::unique_ptr&& e) : underlying_(std::move(e)) {} + Expr::Expr(std::unique_ptr&& e) : underlying_(std::move(e)) { } Expr::~Expr() = default; Expr Expr::Identifier(StringView id) diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index a50736e9be7..30b9d0224a6 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -347,13 +347,14 @@ namespace vcpkg::PostBuildLint // if there is only one candidate, provide the cmake lines needed to place it in the proper location const fs::path found_file = potential_copyright_files[0]; auto found_relative_native = found_file.native(); - found_relative_native.erase(current_buildtrees_dir.native().size() + 1); // The +1 is needed to remove the "/" + found_relative_native.erase(current_buildtrees_dir.native().size() + + 1); // The +1 is needed to remove the "/" const fs::path relative_path = found_relative_native; - System::printf( - "\n configure_file(\"${CURRENT_BUILDTREES_DIR}/%s/%s\" \"${CURRENT_PACKAGES_DIR}/share/%s/copyright\" COPYONLY)\n", - relative_path.generic_string(), - found_file.filename().generic_string(), - spec.name()); + System::printf("\n configure_file(\"${CURRENT_BUILDTREES_DIR}/%s/%s\" " + "\"${CURRENT_PACKAGES_DIR}/share/%s/copyright\" COPYONLY)\n", + relative_path.generic_string(), + found_file.filename().generic_string(), + spec.name()); } else if (potential_copyright_files.size() > 1) { diff --git a/toolsrc/src/vcpkg/remove.cpp b/toolsrc/src/vcpkg/remove.cpp index 23f9d0097c2..7afa81c7cbf 100644 --- a/toolsrc/src/vcpkg/remove.cpp +++ b/toolsrc/src/vcpkg/remove.cpp @@ -217,7 +217,9 @@ namespace vcpkg::Remove { if (paths.manifest_mode_enabled()) { - Checks::exit_with_message(VCPKG_LINE_INFO, "vcpkg remove does not support manifest mode. In order to remove dependencies, you will need to edit your manifest (vcpkg.json)."); + Checks::exit_with_message(VCPKG_LINE_INFO, + "vcpkg remove does not support manifest mode. In order to remove dependencies, " + "you will need to edit your manifest (vcpkg.json)."); } const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE); diff --git a/toolsrc/src/vcpkg/sourceparagraph.cpp b/toolsrc/src/vcpkg/sourceparagraph.cpp index 467a1236ae1..f887456d8fc 100644 --- a/toolsrc/src/vcpkg/sourceparagraph.cpp +++ b/toolsrc/src/vcpkg/sourceparagraph.cpp @@ -1,16 +1,15 @@ #include "pch.h" -#include -#include -#include -#include - #include #include #include #include #include #include +#include +#include +#include +#include namespace vcpkg { @@ -186,14 +185,8 @@ namespace vcpkg return Type{Type::UNKNOWN}; } - bool operator==(const Type& lhs, const Type& rhs) - { - return lhs.type == rhs.type; - } - bool operator!=(const Type& lhs, const Type& rhs) - { - return !(lhs == rhs); - } + bool operator==(const Type& lhs, const Type& rhs) { return lhs.type == rhs.type; } + bool operator!=(const Type& lhs, const Type& rhs) { return !(lhs == rhs); } static void trim_all(std::vector& arr) { @@ -246,7 +239,8 @@ namespace vcpkg auto supports_expr = parser.optional_field(SourceParagraphFields::SUPPORTS); if (!supports_expr.empty()) { - auto maybe_expr = PlatformExpression::parse_platform_expression(supports_expr, PlatformExpression::MultipleBinaryOperators::Allow); + auto maybe_expr = PlatformExpression::parse_platform_expression( + supports_expr, PlatformExpression::MultipleBinaryOperators::Allow); if (auto expr = maybe_expr.get()) { spgh->supports_expression = std::move(*expr); @@ -377,7 +371,10 @@ namespace vcpkg StringView type_name() { return type_name_; } - ArrayField(StringView type_name_, AllowEmpty allow_empty, T&& t = {}) : type_name_(type_name_), underlying_visitor_(static_cast(t)), allow_empty_(allow_empty) { } + ArrayField(StringView type_name_, AllowEmpty allow_empty, T&& t = {}) + : type_name_(type_name_), underlying_visitor_(static_cast(t)), allow_empty_(allow_empty) + { + } Optional visit_array(Json::Reader& r, StringView key, const Json::Array& arr) { @@ -634,7 +631,8 @@ namespace vcpkg Optional visit_string(Json::Reader&, StringView, StringView sv) { - auto opt = PlatformExpression::parse_platform_expression(sv, PlatformExpression::MultipleBinaryOperators::Deny); + auto opt = + PlatformExpression::parse_platform_expression(sv, PlatformExpression::MultipleBinaryOperators::Deny); if (auto res = opt.get()) { return std::move(*res); diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp index 0407cc60be7..f2787000459 100644 --- a/toolsrc/src/vcpkg/tools.cpp +++ b/toolsrc/src/vcpkg/tools.cpp @@ -1,9 +1,6 @@ #include "pch.h" #include -#include -#include - #include #include #include @@ -13,6 +10,8 @@ #include #include #include +#include +#include namespace vcpkg { diff --git a/toolsrc/src/vcpkg/userconfig.cpp b/toolsrc/src/vcpkg/userconfig.cpp index 5d2dfa26c34..1bf2b047b41 100644 --- a/toolsrc/src/vcpkg/userconfig.cpp +++ b/toolsrc/src/vcpkg/userconfig.cpp @@ -2,9 +2,9 @@ #include #include +#include #include #include -#include namespace vcpkg { diff --git a/toolsrc/src/vcpkg/vcpkgcmdarguments.cpp b/toolsrc/src/vcpkg/vcpkgcmdarguments.cpp index 934b375a3b8..75632541dc8 100644 --- a/toolsrc/src/vcpkg/vcpkgcmdarguments.cpp +++ b/toolsrc/src/vcpkg/vcpkgcmdarguments.cpp @@ -1,7 +1,7 @@ #include "pch.h" -#include #include +#include #include #include #include diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index 30f7367bfcd..a957cb27c99 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -2,10 +2,9 @@ #include #include -#include -#include #include #include +#include #include #include #include diff --git a/toolsrc/src/vcpkg/versiont.cpp b/toolsrc/src/vcpkg/versiont.cpp index 2c025fa1dbe..209a473c66b 100644 --- a/toolsrc/src/vcpkg/versiont.cpp +++ b/toolsrc/src/vcpkg/versiont.cpp @@ -5,15 +5,15 @@ namespace vcpkg { - VersionT::VersionT() noexcept : value("0.0.0") {} - VersionT::VersionT(std::string&& value) : value(std::move(value)) {} - VersionT::VersionT(const std::string& value) : value(value) {} + VersionT::VersionT() noexcept : value("0.0.0") { } + VersionT::VersionT(std::string&& value) : value(std::move(value)) { } + VersionT::VersionT(const std::string& value) : value(value) { } const std::string& VersionT::to_string() const { return value; } bool operator==(const VersionT& left, const VersionT& right) { return left.to_string() == right.to_string(); } bool operator!=(const VersionT& left, const VersionT& right) { return left.to_string() != right.to_string(); } - VersionDiff::VersionDiff() noexcept : left(), right() {} - VersionDiff::VersionDiff(const VersionT& left, const VersionT& right) : left(left), right(right) {} + VersionDiff::VersionDiff() noexcept : left(), right() { } + VersionDiff::VersionDiff(const VersionT& left, const VersionT& right) : left(left), right(right) { } std::string VersionDiff::to_string() const { diff --git a/toolsrc/src/vcpkgmetricsuploader.cpp b/toolsrc/src/vcpkgmetricsuploader.cpp index 95195b3be28..a773f1aeefd 100644 --- a/toolsrc/src/vcpkgmetricsuploader.cpp +++ b/toolsrc/src/vcpkgmetricsuploader.cpp @@ -1,10 +1,10 @@ -#include +#include + +#include #include #include - -#include -#include +#include using namespace vcpkg;