[vcpkg] Format the C++ in CI (#11655)

* [vcpkg] Format the C++ in the CI

* format the C++

* CR
This commit is contained in:
nicole mazzuca 2020-07-06 16:45:34 -07:00 committed by GitHub
parent ae4968fad4
commit 6a41626eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
119 changed files with 634 additions and 513 deletions

View File

@ -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'

View File

@ -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
}

View File

@ -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

View File

@ -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: '^(<vcpkg/base/system_headers\.h>|"pch\.h")$'
Priority: -1
- Regex: '^<catch2/catch\.hpp>$'
Priority: 1
- Regex: '^<vcpkg/base/*\.h>$'
Priority: 2
- Regex: '^<vcpkg/*\.h>$'
Priority: 3
- Regex: '^<[a-z0-9_]*\.h>$'
Priority: 4
- Regex: '^<[a-z0-9_]*>$' # C++ standard library
Priority: 5

View File

@ -1,8 +1,9 @@
#pragma once
#include <vcpkg/base/pragmas.h>
#include <vcpkg/base/system_headers.h>
#include <vcpkg/base/pragmas.h>
#if defined(_WIN32)
#include <process.h>
#include <shellapi.h>
@ -49,9 +50,10 @@
#include <sys/time.h>
#endif
#include <time.h>
#include <system_error>
#include <thread>
#include <time.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

View File

@ -1,13 +1,13 @@
#include <vcpkg/base/system_headers.h>
#include <catch2/catch.hpp>
#include <vcpkg/base/pragmas.h>
#include <vcpkg/base/files.h>
#include <vcpkg/statusparagraph.h>
#include <memory>
#include <vcpkg/base/files.h>
#include <vcpkg/base/pragmas.h>
#include <vcpkg/statusparagraph.h>
#define CHECK_EC(ec) \
do \
{ \
@ -54,7 +54,7 @@ namespace vcpkg::Test
{
std::unordered_map<std::string, SourceControlFileLocation> 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; }
};

View File

@ -1,11 +1,11 @@
#pragma once
#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>
#include <chrono>
#include <string>
#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>
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<class TimeUnit>
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<CTime> get_current_date_time();
static Optional<CTime> 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;

View File

@ -1,10 +1,10 @@
#pragma once
#include <vector>
#include <vcpkg/base/files.h>
#include <vcpkg/base/machinetype.h>
#include <vector>
namespace vcpkg::CoffFileReader
{
struct DllInfo

View File

@ -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; }

View File

@ -1,9 +1,9 @@
#pragma once
#include <vcpkg/base/lineinfo.h>
#include <string>
#include <vcpkg/base/lineinfo.h>
namespace vcpkg::Enums
{
std::string nullvalue_to_string(const CStringView enum_name);

View File

@ -1,16 +1,16 @@
#pragma once
#include <system_error>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/stringliteral.h>
#include <system_error>
namespace vcpkg
{
template<class Err>
struct ErrorHolder
{
ErrorHolder() : m_is_error(false), m_err{} {}
ErrorHolder() : m_is_error(false), m_err{} { }
template<class U>
ErrorHolder(U&& err) : m_is_error(true), m_err(std::forward<U>(err))
{

View File

@ -34,7 +34,7 @@ namespace vcpkg::Graphs
virtual int random(int max_exclusive) = 0;
protected:
~Randomizer() {}
~Randomizer() { }
};
namespace details

View File

@ -1,9 +1,9 @@
#pragma once
#include <vcpkg/base/files.h>
#include <string>
#include <vcpkg/base/files.h>
namespace vcpkg::Hash
{
enum class Algorithm

View File

@ -1,17 +1,18 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/parse.h>
#include <vcpkg/base/stringview.h>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
namespace vcpkg::Json
{
struct JsonStyle

View File

@ -6,7 +6,7 @@ namespace vcpkg
class Lazy
{
public:
Lazy() : value(T()), initialized(false) {}
Lazy() : value(T()), initialized(false) { }
template<class F>
T const& get_lazy(const F& f) const

View File

@ -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;

View File

@ -1,17 +1,16 @@
#pragma once
#include <vcpkg/base/pragmas.h>
#include <vcpkg/base/lineinfo.h>
#include <type_traits>
#include <utility>
#include <vcpkg/base/lineinfo.h>
#include <vcpkg/base/pragmas.h>
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<T, false>
{
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<class T, bool B>
struct OptionalStorage<T&, B>
{
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<class T>
struct Optional
{
constexpr Optional() noexcept {}
constexpr Optional() noexcept { }
// Constructors are intentionally implicit
constexpr Optional(NullOpt) {}
constexpr Optional(NullOpt) { }
template<class U, class = std::enable_if_t<!std::is_same<std::decay_t<U>, Optional>::value>>
constexpr Optional(U&& t) : m_base(std::forward<U>(t))

View File

@ -1,14 +1,14 @@
#pragma once
#include <memory>
#include <string>
#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/stringview.h>
#include <vcpkg/base/unicode.h>
#include <vcpkg/textrowcol.h>
#include <memory>
#include <string>
namespace vcpkg::Parse
{
struct IParseError

View File

@ -13,7 +13,7 @@ namespace vcpkg
using size_type = typename std::vector<T>::size_type;
using iterator = typename std::vector<T>::const_iterator;
SortedVector() : m_data() {}
SortedVector() : m_data() { }
explicit SortedVector(std::vector<T> v) : m_data(std::move(v))
{

View File

@ -19,10 +19,10 @@ namespace vcpkg
using reference = std::add_lvalue_reference_t<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<size_t N>
constexpr Span(T (&arr)[N]) noexcept : m_ptr(arr), m_count(N)

View File

@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <vcpkg/base/zstringview.h>
namespace vcpkg

View File

@ -1,19 +1,18 @@
#pragma once
#include <vcpkg/base/pragmas.h>
#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/stringliteral.h>
#include <vcpkg/base/stringview.h>
#include <vcpkg/base/view.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <vector>
#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/pragmas.h>
#include <vcpkg/base/stringliteral.h>
#include <vcpkg/base/stringview.h>
#include <vcpkg/base/view.h>
namespace vcpkg::Strings::details
{
template<class T>

View File

@ -1,11 +1,11 @@
#pragma once
#include <vcpkg/base/optional.h>
#include <limits>
#include <string>
#include <vector>
#include <vcpkg/base/optional.h>
namespace vcpkg
{
struct StringView

View File

@ -1,10 +1,10 @@
#pragma once
#include <atomic>
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/system.print.h>
#include <atomic>
namespace vcpkg::Debug
{
extern std::atomic<bool> g_debugging;

View File

@ -1,13 +1,13 @@
#pragma once
#include <vcpkg/base/files.h>
#include <vcpkg/base/zstringview.h>
#include <functional>
#include <string>
#include <unordered_map>
#include <vector>
#include <vcpkg/base/files.h>
#include <vcpkg/base/zstringview.h>
namespace vcpkg::System
{
struct CMakeVariable

View File

@ -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 <unistd.h>
@ -32,4 +33,3 @@ extern "C" {
// glibc defines major and minor in sys/types.h, and should not
#undef major
#undef minor

View File

@ -2,25 +2,23 @@
#include <stdint.h>
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;
};
}

View File

@ -218,7 +218,7 @@ namespace vcpkg::Util
T* get() { return &m_ptr; }
LockGuardPtr(LockGuarded<T>& sync) : m_lock(sync.m_mutex), m_ptr(sync.m_t) {}
LockGuardPtr(LockGuarded<T>& sync) : m_lock(sync.m_mutex), m_ptr(sync.m_t) { }
private:
std::unique_lock<std::mutex> m_lock;

View File

@ -1,17 +1,17 @@
#pragma once
#include <vcpkg/base/checks.h>
#include <condition_variable>
#include <memory>
#include <vector>
#include <vcpkg/base/checks.h>
namespace vcpkg
{
template<class Action>
struct WorkQueue
{
WorkQueue(LineInfo li) : m_line_info(li) {}
WorkQueue(LineInfo li) : m_line_info(li) { }
WorkQueue(const WorkQueue&) = delete;
~WorkQueue()

View File

@ -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<int N>
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; }

View File

@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <vcpkg/dependencies.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/vcpkgpaths.h>

View File

@ -1,5 +1,14 @@
#pragma once
#include <array>
#include <map>
#include <set>
#include <vector>
#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/cmakevars.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/statusparagraphs.h>
@ -7,16 +16,6 @@
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkgpaths.h>
#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/system.process.h>
#include <array>
#include <map>
#include <set>
#include <vector>
namespace vcpkg
{
struct IBinaryProvider;

View File

@ -1,9 +1,9 @@
#include <vcpkg/base/system.process.h>
#include <vcpkg/vcpkgpaths.h>
#include <string>
#include <vector>
#include <vcpkg/base/system.process.h>
#include <vcpkg/vcpkgpaths.h>
namespace vcpkg
{
std::string make_cmake_cmd(const VcpkgPaths& paths,

View File

@ -1,7 +1,6 @@
#pragma once
#include <vcpkg/base/optional.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/vcpkgpaths.h>

View File

@ -1,15 +1,15 @@
#pragma once
#include <array>
#include <map>
#include <vector>
#include <vcpkg/build.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkgpaths.h>
#include <array>
#include <map>
#include <vector>
namespace vcpkg::Commands
{
using CommandTypeA = void (*)(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet);

View File

@ -1,5 +1,9 @@
#pragma once
#include <functional>
#include <map>
#include <vector>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/util.h>
#include <vcpkg/build.h>
@ -9,10 +13,6 @@
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgpaths.h>
#include <functional>
#include <map>
#include <vector>
namespace vcpkg::Graphs
{
struct Randomizer;

View File

@ -1,10 +1,10 @@
#pragma once
#include <vector>
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgpaths.h>
#include <vector>
namespace vcpkg::Export::Chocolatey
{
struct Options

View File

@ -1,11 +1,11 @@
#pragma once
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgpaths.h>
#include <string>
#include <vector>
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgpaths.h>
namespace vcpkg::Export::IFW
{
struct Options

View File

@ -1,12 +1,11 @@
#pragma once
#include <vector>
#include <vcpkg/base/system.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgpaths.h>
#include <vector>
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<Dependencies::ExportPlanAction>& export_plan,
const VcpkgPaths& paths,
const Options& prefab_options, const Triplet& triplet);
Optional<std::string> find_ndk_version(const std::string &content);
Optional<NdkVersion> to_version(const std::string &version);
const Options& prefab_options,
const Triplet& triplet);
Optional<std::string> find_ndk_version(const std::string& content);
Optional<NdkVersion> to_version(const std::string& version);
}

View File

@ -1,11 +1,11 @@
#pragma once
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/util.h>
#include <atomic>
#include <string>
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/util.h>
namespace vcpkg
{
struct GlobalState

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkgpaths.h>
#include <string>
namespace vcpkg::Help
{
extern const CommandStructure COMMAND_STRUCTURE;

View File

@ -1,13 +1,13 @@
#pragma once
#include <vector>
#include <vcpkg/base/chrono.h>
#include <vcpkg/build.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkgpaths.h>
#include <vector>
namespace vcpkg::Install
{
enum class KeepGoing

View File

@ -1,10 +1,10 @@
#pragma once
#include <vcpkg/base/util.h>
#include <vcpkg/base/files.h>
#include <string>
#include <vcpkg/base/files.h>
#include <vcpkg/base/util.h>
namespace vcpkg::Metrics
{
struct Metrics : Util::ResourceBase

View File

@ -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<PackageSpec> to_package_specs(const std::vector<std::string>& 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; }

View File

@ -1,15 +1,15 @@
#pragma once
#include <vcpkg/base/expected.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/textrowcol.h>
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include <vcpkg/base/expected.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/textrowcol.h>
namespace vcpkg::Parse
{
struct ParseControlErrorInfo

View File

@ -1,11 +1,10 @@
#pragma once
#include <vcpkg/base/expected.h>
#include <vcpkg/binaryparagraph.h>
#include <vcpkg/paragraphparser.h>
#include <vcpkg/vcpkgpaths.h>
#include <vcpkg/base/expected.h>
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<SourceControlFile> try_load_manifest(const Files::Filesystem& fs, const std::string& port_name, const fs::path& path_to_manifest, std::error_code& ec);
Parse::ParseExpected<SourceControlFile> try_load_manifest(const Files::Filesystem& fs,
const std::string& port_name,
const fs::path& path_to_manifest,
std::error_code& ec);
Parse::ParseExpected<SourceControlFile> try_load_port(const Files::Filesystem& fs, const fs::path& path);

View File

@ -2,6 +2,7 @@
#include <string>
#include <unordered_map>
#include <vcpkg/base/expected.h>
#include <vcpkg/base/stringview.h>

View File

@ -1,11 +1,11 @@
#pragma once
#include <vcpkg/base/cstringview.h>
#include <vcpkg/build.h>
#include <array>
#include <regex>
#include <vcpkg/base/cstringview.h>
#include <vcpkg/build.h>
namespace vcpkg::PostBuildLint
{
struct BuildType

View File

@ -5,9 +5,9 @@
#include <vcpkg/base/span.h>
#include <vcpkg/base/system.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/platform-expression.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/paragraphparser.h>
#include <vcpkg/platform-expression.h>
namespace vcpkg
{

View File

@ -1,9 +1,9 @@
#pragma once
#include <vcpkg/binaryparagraph.h>
#include <map>
#include <vcpkg/binaryparagraph.h>
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<const StatusParagraph*>&& fs)
: core(c), features(std::move(fs))

View File

@ -1,9 +1,9 @@
#pragma once
#include <vcpkg/statusparagraph.h>
#include <iterator>
#include <memory>
#include <vcpkg/statusparagraph.h>
namespace vcpkg
{
/// <summary>Status paragraphs</summary>

View File

@ -1,17 +1,17 @@
#pragma once
#include <vcpkg/base/files.h>
#include <string>
#include <utility>
#include <vcpkg/base/files.h>
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;

View File

@ -1,9 +1,9 @@
#pragma once
#include <string>
#include <vcpkg/base/system.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/system.h>
#include <vcpkg/vcpkgcmdarguments.h>
namespace vcpkg

View File

@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <vcpkg/base/files.h>
namespace vcpkg

View File

@ -1,15 +1,15 @@
#pragma once
#include <vcpkg/base/optional.h>
#include <vcpkg/base/span.h>
#include <vcpkg/base/stringliteral.h>
#include <vcpkg/base/files.h>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <vcpkg/base/files.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/span.h>
#include <vcpkg/base/stringliteral.h>
namespace vcpkg
{
struct ParsedArguments

View File

@ -1,15 +1,14 @@
#pragma once
#include <vcpkg/binaryparagraph.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/base/cache.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/lazy.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/util.h>
#include <vcpkg/binaryparagraph.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgcmdarguments.h>
namespace vcpkg
{

View File

@ -1,16 +1,16 @@
#include <string.h>
#include <iostream>
#include <sstream>
#include <utility>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/json.h>
#include <vcpkg/base/stringview.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/unicode.h>
#include <vcpkg/platform-expression.h>
#include <iostream>
#include <sstream>
#include <string.h>
#include <utility>
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)
{

View File

@ -1,9 +1,9 @@
#include <catch2/catch.hpp>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vector>
#include <vcpkg/vcpkgcmdarguments.h>
using vcpkg::CommandSetting;
using vcpkg::CommandStructure;
using vcpkg::CommandSwitch;

View File

@ -1,13 +1,15 @@
#include <catch2/catch.hpp>
#include <vcpkg/binarycaching.private.h>
#include <vcpkg/binarycaching.h>
#include <vcpkg/base/files.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/sourceparagraph.h>
#include <vcpkg/paragraphs.h>
#include <string>
#include <vcpkg/base/files.h>
#include <vcpkg/binarycaching.h>
#include <vcpkg/binarycaching.private.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/sourceparagraph.h>
#include <vcpkg/vcpkgcmdarguments.h>
using namespace vcpkg;
TEST_CASE ("reformat_version semver-ish", "[reformat_version]")

View File

@ -1,4 +1,5 @@
#include <catch2/catch.hpp>
#include <vcpkg/binarycaching.h>
using namespace vcpkg;

View File

@ -1,12 +1,13 @@
#include <catch2/catch.hpp>
#include <string>
#include <iterator>
#include <string>
#include <vcpkg-test/util.h>
#include <vcpkg/base/files.h>
#include <vcpkg/commands.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkgpaths.h>
#include <vcpkg-test/util.h>
using namespace vcpkg;

View File

@ -1,7 +1,8 @@
#include <catch2/catch.hpp>
#include <string>
#include <iterator>
#include <string>
#include <vcpkg/base/files.h>
#include <vcpkg/commands.h>
#include <vcpkg/vcpkgcmdarguments.h>
@ -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);

View File

@ -1,4 +1,5 @@
#include <catch2/catch.hpp>
#include <vcpkg-test/mockcmakevarprovider.h>
#include <vcpkg-test/util.h>
#include <vcpkg/dependencies.h>

View File

@ -1,14 +1,13 @@
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/strings.h>
#include <iostream>
#include <random>
#include <vector>
#include <vcpkg-test/util.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/strings.h>
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}; }
};

View File

@ -1,12 +1,12 @@
#include <catch2/catch.hpp>
#include <vcpkg/base/hash.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
#include <vcpkg/base/hash.h>
namespace Hash = vcpkg::Hash;
using vcpkg::StringView;

View File

@ -1,10 +1,10 @@
#include <catch2/catch.hpp>
#include <iostream>
#include <vcpkg/base/json.h>
#include <vcpkg/base/unicode.h>
#include "math.h"
#include <vcpkg/base/json.h>
#include <vcpkg/base/unicode.h>
// 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);

View File

@ -1,6 +1,6 @@
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg-test/util.h>
#include <vcpkg/base/json.h>
#include <vcpkg/base/util.h>
#include <vcpkg/paragraphs.h>
@ -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());
}

View File

@ -1,7 +1,9 @@
#include <catch2/catch.hpp>
#include <vcpkg/base/optional.h>
#include <vector>
#include <vcpkg/base/optional.h>
namespace
{
struct identity_projection

View File

@ -1,8 +1,7 @@
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/paragraphs.h>
namespace Strings = vcpkg::Strings;

View File

@ -1,17 +1,17 @@
#include <catch2/catch.hpp>
#include <memory>
#include <unordered_map>
#include <vector>
#include <vcpkg-test/mockcmakevarprovider.h>
#include <vcpkg-test/util.h>
#include <vcpkg/base/graphs.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/sourceparagraph.h>
#include <vcpkg/triplet.h>
#include <memory>
#include <unordered_map>
#include <vector>
using namespace vcpkg;
using Test::make_control_file;

View File

@ -1,6 +1,6 @@
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg-test/util.h>
#include <vcpkg/base/util.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/statusparagraphs.h>

View File

@ -1,11 +1,12 @@
#include <catch2/catch.hpp>
#include <vcpkg/base/strings.h>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include <string>
#include <vcpkg/base/strings.h>
TEST_CASE ("b32 encoding", "[strings]")
{

View File

@ -2,16 +2,18 @@
#include <vcpkg/base/stringview.h>
template <std::size_t N>
static vcpkg::StringView sv(const char (&cstr)[N]) {
return cstr;
template<std::size_t N>
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"));
}

View File

@ -1,13 +1,15 @@
#include <vcpkg/base/system_headers.h>
#include <catch2/catch.hpp>
#include <string>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/stringview.h>
#include <vcpkg/base/zstringview.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/stringview.h>
#include <vcpkg/base/system.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/base/zstringview.h>
using vcpkg::nullopt;
using vcpkg::Optional;

View File

@ -2,63 +2,67 @@
#include <vcpkg/base/uint128.h>
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);
}

View File

@ -1,8 +1,7 @@
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/base/sortedvector.h>
#include <vcpkg/update.h>
using namespace vcpkg;

View File

@ -1,8 +1,8 @@
#include <vcpkg/base/system_headers.h>
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg-test/util.h>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/util.h>
@ -10,7 +10,6 @@
// used to get the implementation specific compiler flags (i.e., __cpp_lib_filesystem)
#include <ciso646>
#include <iostream>
#include <memory>
@ -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();

View File

@ -1,9 +1,13 @@
#include <vcpkg/base/pragmas.h>
#include <vcpkg/base/system_headers.h>
#include <cassert>
#include <fstream>
#include <memory>
#include <random>
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/pragmas.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.print.h>
@ -17,11 +21,6 @@
#include <vcpkg/userconfig.h>
#include <vcpkg/vcpkglib.h>
#include <cassert>
#include <fstream>
#include <memory>
#include <random>
#if defined(_WIN32)
#pragma comment(lib, "ole32")
#pragma comment(lib, "shell32")

View File

@ -10,6 +10,7 @@
#if !defined(_WIN32)
#include <fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
#endif

View File

@ -1,11 +1,10 @@
#include "pch.h"
#include <vcpkg/base/hash.h>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/uint128.h>
#include <vcpkg/base/hash.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/base/uint128.h>
#include <vcpkg/base/util.h>
#if defined(_WIN32)
@ -51,12 +50,14 @@ namespace vcpkg::Hash
}
}
template <class UIntTy>
auto top_bits(UIntTy x) -> std::enable_if_t<std::is_unsigned<UIntTy>::value, uchar> {
template<class UIntTy>
auto top_bits(UIntTy x) -> std::enable_if_t<std::is_unsigned<UIntTy>::value, uchar>
{
return static_cast<uchar>(x >> ((sizeof(x) - 1) * 8));
}
template <class UIntTy>
auto top_bits(UIntTy x) -> decltype(top_bits(x.top_64_bits())) {
template<class UIntTy>
auto top_bits(UIntTy x) -> decltype(top_bits(x.top_64_bits()))
{
return top_bits(x.top_64_bits());
}

View File

@ -1,12 +1,12 @@
#include "pch.h"
#include <inttypes.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/json.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/unicode.h>
#include <inttypes.h>
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;

View File

@ -1,8 +1,8 @@
#include "pch.h"
#include <vcpkg/base/parse.h>
#include <utility>
#include <vcpkg/base/parse.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>
#include <vcpkg/packagespec.h>

View File

@ -1,11 +1,11 @@
#include "pch.h"
#include <cstring>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/lineinfo.h>
#include <vcpkg/base/stringview.h>
#include <cstring>
namespace vcpkg
{
std::vector<StringView> 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); }

View File

@ -1,13 +1,13 @@
#include "pch.h"
#include <ctime>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.h>
#include <vcpkg/base/util.h>
#include <ctime>
using namespace vcpkg::System;
namespace vcpkg

View File

@ -1,5 +1,7 @@
#include "pch.h"
#include <ctime>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/system.debug.h>
@ -7,8 +9,6 @@
#include <vcpkg/base/system.process.h>
#include <vcpkg/base/util.h>
#include <ctime>
#if defined(__APPLE__)
#include <mach-o/dyld.h>
#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<PHANDLER_ROUTINE>(ctrl_handler), TRUE);
}
#else
void System::register_console_ctrl_handler() {}
void System::register_console_ctrl_handler() { }
#endif
}

View File

@ -1,55 +1,66 @@
#include <vcpkg/base/uint128.h>
#include <limits>
namespace vcpkg {
#include <vcpkg/base/uint128.h>
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<uint64_t>::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<uint64_t>::max() - rhs)
{
top += 1;
}
bottom += rhs;
return *this;
}
bottom += rhs;
return *this;
}
}

View File

@ -1,8 +1,7 @@
#include "pch.h"
#include <vcpkg/base/unicode.h>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/unicode.h>
namespace vcpkg::Unicode
{

View File

@ -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;

View File

@ -3,7 +3,6 @@
#include <vcpkg/base/checks.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>
#include <vcpkg/binaryparagraph.h>
#include <vcpkg/paragraphparser.h>
#include <vcpkg/paragraphs.h>

View File

@ -11,7 +11,6 @@
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/base/util.h>
#include <vcpkg/binarycaching.h>
#include <vcpkg/build.h>
#include <vcpkg/buildenvironment.h>

View File

@ -5,9 +5,8 @@
#include <vcpkg/base/span.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/base/util.h>
#include <vcpkg/cmakevars.h>
#include <vcpkg/buildenvironment.h>
#include <vcpkg/cmakevars.h>
#include <vcpkg/dependencies.h>
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;

View File

@ -14,8 +14,8 @@
#include <vcpkg/help.h>
#include <vcpkg/input.h>
#include <vcpkg/install.h>
#include <vcpkg/platform-expression.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/platform-expression.h>
#include <vcpkg/vcpkglib.h>
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,

View File

@ -8,7 +8,8 @@
using namespace vcpkg;
namespace {
namespace
{
void clear_directory(Files::Filesystem& fs, const fs::path& target)
{
using vcpkg::System::print2;

View File

@ -2,7 +2,6 @@
#include <vcpkg/base/hash.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/build.h>
#include <vcpkg/commands.h>
#include <vcpkg/export.h>

View File

@ -1,5 +1,7 @@
#include "pch.h"
#include <vector>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>
@ -9,7 +11,6 @@
#include <vcpkg/input.h>
#include <vcpkg/install.h>
#include <vcpkg/packagespec.h>
#include <vector>
using vcpkg::Dependencies::ActionPlan;
using vcpkg::Dependencies::InstallPlanAction;

View File

@ -1,6 +1,7 @@
#include "pch.h"
#include <limits.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>

View File

@ -2,7 +2,6 @@
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/build.h>
#include <vcpkg/cmakevars.h>
#include <vcpkg/commands.h>

View File

@ -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;
}

View File

@ -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,
{},

View File

@ -1,11 +1,10 @@
#include "pch.h"
#include <vcpkg/commands.h>
#include <vcpkg/help.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/base/util.h>
#include <vcpkg/commands.h>
#include <vcpkg/help.h>
namespace vcpkg::Commands::PortHistory
{

Some files were not shown because too many files have changed in this diff Show More