Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg formatting] Turn off DeriveLineEnding #12368

Merged
merged 5 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions toolsrc/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ForEachMacros: [TEST_CASE, SECTION]
PenaltyReturnTypeOnItsOwnLine: 1000
SpaceAfterTemplateKeyword: false
SpaceBeforeCpp11BracedList: false
DeriveLineEnding: false
UseCRLF: false

IncludeBlocks: Regroup
Expand Down
76 changes: 38 additions & 38 deletions toolsrc/include/vcpkg-test/mockcmakevarprovider.h
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
#pragma once
#include <vcpkg/cmakevars.h>
namespace vcpkg::Test
{
struct MockCMakeVarProvider : CMakeVars::CMakeVarProvider
{
void load_generic_triplet_vars(Triplet triplet) const override { generic_triplet_vars[triplet] = {}; }
void load_dep_info_vars(Span<const PackageSpec> specs) const override
{
for (auto&& spec : specs)
dep_info_vars[spec] = {};
}
void load_tag_vars(Span<const FullPackageSpec> specs,
const PortFileProvider::PortFileProvider& port_provider) const override
{
for (auto&& spec : specs)
tag_vars[spec.package_spec] = {};
Util::unused(port_provider);
}
Optional<const std::unordered_map<std::string, std::string>&> get_generic_triplet_vars(
Triplet triplet) const override;
Optional<const std::unordered_map<std::string, std::string>&> get_dep_info_vars(
const PackageSpec& spec) const override;
Optional<const std::unordered_map<std::string, std::string>&> get_tag_vars(
const PackageSpec& spec) const override;
mutable std::unordered_map<PackageSpec, std::unordered_map<std::string, std::string>> dep_info_vars;
mutable std::unordered_map<PackageSpec, std::unordered_map<std::string, std::string>> tag_vars;
mutable std::unordered_map<Triplet, std::unordered_map<std::string, std::string>> generic_triplet_vars;
};
}
#pragma once

#include <vcpkg/cmakevars.h>

namespace vcpkg::Test
{
struct MockCMakeVarProvider : CMakeVars::CMakeVarProvider
{
void load_generic_triplet_vars(Triplet triplet) const override { generic_triplet_vars[triplet] = {}; }

void load_dep_info_vars(Span<const PackageSpec> specs) const override
{
for (auto&& spec : specs)
dep_info_vars[spec] = {};
}

void load_tag_vars(Span<const FullPackageSpec> specs,
const PortFileProvider::PortFileProvider& port_provider) const override
{
for (auto&& spec : specs)
tag_vars[spec.package_spec] = {};
Util::unused(port_provider);
}

Optional<const std::unordered_map<std::string, std::string>&> get_generic_triplet_vars(
Triplet triplet) const override;

Optional<const std::unordered_map<std::string, std::string>&> get_dep_info_vars(
const PackageSpec& spec) const override;

Optional<const std::unordered_map<std::string, std::string>&> get_tag_vars(
const PackageSpec& spec) const override;

mutable std::unordered_map<PackageSpec, std::unordered_map<std::string, std::string>> dep_info_vars;
mutable std::unordered_map<PackageSpec, std::unordered_map<std::string, std::string>> tag_vars;
mutable std::unordered_map<Triplet, std::unordered_map<std::string, std::string>> generic_triplet_vars;
};
}
42 changes: 21 additions & 21 deletions toolsrc/include/vcpkg/base/cache.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#pragma once
#include <map>
namespace vcpkg
{
template<class Key, class Value>
struct Cache
{
template<class F>
Value const& get_lazy(const Key& k, const F& f) const
{
auto it = m_cache.find(k);
if (it != m_cache.end()) return it->second;
return m_cache.emplace(k, f()).first->second;
}
private:
mutable std::map<Key, Value> m_cache;
};
}
#pragma once

#include <map>

namespace vcpkg
{
template<class Key, class Value>
struct Cache
{
template<class F>
Value const& get_lazy(const Key& k, const F& f) const
{
auto it = m_cache.find(k);
if (it != m_cache.end()) return it->second;
return m_cache.emplace(k, f()).first->second;
}

private:
mutable std::map<Key, Value> m_cache;
};
}
20 changes: 10 additions & 10 deletions toolsrc/include/vcpkg/base/ignore_errors.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once
namespace vcpkg
{
struct ignore_errors_t
{
};
constexpr ignore_errors_t ignore_errors;
}
#pragma once

namespace vcpkg
{
struct ignore_errors_t
{
};

constexpr ignore_errors_t ignore_errors;
}
114 changes: 57 additions & 57 deletions toolsrc/include/vcpkg/base/span.h
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
#pragma once
#include <array>
#include <cstddef>
#include <initializer_list>
#include <vector>
namespace vcpkg
{
template<class T>
struct Span
{
public:
static_assert(std::is_object<T>::value, "Span<non-object-type> is illegal");
using value_type = std::decay_t<T>;
using element_type = T;
using pointer = std::add_pointer_t<T>;
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) { }
template<size_t N>
constexpr Span(T (&arr)[N]) noexcept : m_ptr(arr), m_count(N)
{
}
template<size_t N, class = std::enable_if_t<std::is_const_v<T>>>
constexpr Span(std::remove_const_t<T> (&arr)[N]) noexcept : m_ptr(arr), m_count(N)
{
}
template<class Range,
class = decltype(std::declval<Range>().data()),
class = std::enable_if_t<!std::is_same<std::decay_t<Range>, Span>::value>>
constexpr Span(Range&& v) noexcept : Span(v.data(), v.size())
{
static_assert(std::is_same<typename std::decay_t<Range>::value_type, value_type>::value,
"Cannot convert incompatible ranges");
}
constexpr iterator begin() const { return m_ptr; }
constexpr iterator end() const { return m_ptr + m_count; }
constexpr reference operator[](size_t i) const { return m_ptr[i]; }
constexpr pointer data() const { return m_ptr; }
constexpr size_t size() const { return m_count; }
private:
pointer m_ptr;
size_t m_count;
};
}
#pragma once

#include <array>
#include <cstddef>
#include <initializer_list>
#include <vector>

namespace vcpkg
{
template<class T>
struct Span
{
public:
static_assert(std::is_object<T>::value, "Span<non-object-type> is illegal");

using value_type = std::decay_t<T>;
using element_type = T;
using pointer = std::add_pointer_t<T>;
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) { }

template<size_t N>
constexpr Span(T (&arr)[N]) noexcept : m_ptr(arr), m_count(N)
{
}

template<size_t N, class = std::enable_if_t<std::is_const_v<T>>>
constexpr Span(std::remove_const_t<T> (&arr)[N]) noexcept : m_ptr(arr), m_count(N)
{
}

template<class Range,
class = decltype(std::declval<Range>().data()),
class = std::enable_if_t<!std::is_same<std::decay_t<Range>, Span>::value>>
constexpr Span(Range&& v) noexcept : Span(v.data(), v.size())
{
static_assert(std::is_same<typename std::decay_t<Range>::value_type, value_type>::value,
"Cannot convert incompatible ranges");
}

constexpr iterator begin() const { return m_ptr; }
constexpr iterator end() const { return m_ptr + m_count; }

constexpr reference operator[](size_t i) const { return m_ptr[i]; }
constexpr pointer data() const { return m_ptr; }
constexpr size_t size() const { return m_count; }

private:
pointer m_ptr;
size_t m_count;
};
}
18 changes: 9 additions & 9 deletions toolsrc/include/vcpkg/base/view.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#include <vcpkg/base/span.h>
namespace vcpkg
{
template<class T>
using View = Span<const T>;
}
#pragma once

#include <vcpkg/base/span.h>

namespace vcpkg
{
template<class T>
using View = Span<const T>;
}
106 changes: 53 additions & 53 deletions toolsrc/include/vcpkg/binarycaching.h
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
#pragma once
#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/vcpkgpaths.h>
namespace vcpkg::Dependencies
{
struct InstallPlanAction;
struct ActionPlan;
}
namespace vcpkg::Build
{
struct AbiTagAndFile;
struct BuildPackageOptions;
}
namespace vcpkg
{
enum class RestoreResult
{
missing,
success,
build_failed,
};
struct IBinaryProvider
{
virtual ~IBinaryProvider() = default;
/// Gives the BinaryProvider an opportunity to batch any downloading or server communication for executing
/// `plan`.
virtual void prefetch(const VcpkgPaths& paths, const Dependencies::ActionPlan& plan) = 0;
/// Attempts to restore the package referenced by `action` into the packages directory.
virtual RestoreResult try_restore(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
/// Called upon a successful build of `action`
virtual void push_success(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
/// Requests the result of `try_restore()` without actually downloading the package. Used by CI to determine
/// missing packages.
virtual RestoreResult precheck(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
};
IBinaryProvider& null_binary_provider();
ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs(View<std::string> args);
ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs_pure(const std::string& env_string,
View<std::string> args);
std::string generate_nuget_packages_config(const Dependencies::ActionPlan& action);
void help_topic_binary_caching(const VcpkgPaths& paths);
}
#pragma once

#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>

#include <vcpkg/packagespec.h>
#include <vcpkg/vcpkgpaths.h>

namespace vcpkg::Dependencies
{
struct InstallPlanAction;
struct ActionPlan;
}
namespace vcpkg::Build
{
struct AbiTagAndFile;
struct BuildPackageOptions;
}

namespace vcpkg
{
enum class RestoreResult
{
missing,
success,
build_failed,
};

struct IBinaryProvider
{
virtual ~IBinaryProvider() = default;
/// Gives the BinaryProvider an opportunity to batch any downloading or server communication for executing
/// `plan`.
virtual void prefetch(const VcpkgPaths& paths, const Dependencies::ActionPlan& plan) = 0;
/// Attempts to restore the package referenced by `action` into the packages directory.
virtual RestoreResult try_restore(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
/// Called upon a successful build of `action`
virtual void push_success(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
/// Requests the result of `try_restore()` without actually downloading the package. Used by CI to determine
/// missing packages.
virtual RestoreResult precheck(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
};

IBinaryProvider& null_binary_provider();

ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs(View<std::string> args);
ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs_pure(const std::string& env_string,
View<std::string> args);

std::string generate_nuget_packages_config(const Dependencies::ActionPlan& action);

void help_topic_binary_caching(const VcpkgPaths& paths);
}
Loading