aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorWimok Nupphiboon <wimok.mok@gmail.com>2018-04-13 09:48:50 +0700
committerWimok Nupphiboon <wimok.mok@gmail.com>2018-04-13 09:48:50 +0700
commit00cdc0b10a089c6c3763f8e3c7847efac909e3fd (patch)
treedbe3d517060d68a06e7b0ac58104b0d7ea8547b6 /toolsrc/include
parent30b56c86148babd61eb6c7c2807421bdcd8d3c13 (diff)
parentdc207a2c891fe6deb2710ccde0abf48078f64fcd (diff)
downloadvcpkg-00cdc0b10a089c6c3763f8e3c7847efac909e3fd.tar.gz
vcpkg-00cdc0b10a089c6c3763f8e3c7847efac909e3fd.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/checks.h4
-rw-r--r--toolsrc/include/vcpkg/base/chrono.h11
-rw-r--r--toolsrc/include/vcpkg/base/cstringview.h15
-rw-r--r--toolsrc/include/vcpkg/base/files.h2
-rw-r--r--toolsrc/include/vcpkg/base/lineinfo.h2
-rw-r--r--toolsrc/include/vcpkg/base/optional.h12
-rw-r--r--toolsrc/include/vcpkg/base/span.h7
-rw-r--r--toolsrc/include/vcpkg/base/strings.h2
-rw-r--r--toolsrc/include/vcpkg/binaryparagraph.h2
-rw-r--r--toolsrc/include/vcpkg/build.h6
-rw-r--r--toolsrc/include/vcpkg/commands.h11
-rw-r--r--toolsrc/include/vcpkg/dependencies.h9
-rw-r--r--toolsrc/include/vcpkg/export.ifw.h2
-rw-r--r--toolsrc/include/vcpkg/packagespecparseresult.h2
-rw-r--r--toolsrc/include/vcpkg/paragraphs.h3
-rw-r--r--toolsrc/include/vcpkg/statusparagraph.h5
-rw-r--r--toolsrc/include/vcpkg/triplet.h4
-rw-r--r--toolsrc/include/vcpkg/vcpkgcmdarguments.h1
-rw-r--r--toolsrc/include/vcpkg/vcpkglib.h2
-rw-r--r--toolsrc/include/vcpkg/vcpkgpaths.h31
-rw-r--r--toolsrc/include/vcpkg/versiont.h4
21 files changed, 66 insertions, 71 deletions
diff --git a/toolsrc/include/vcpkg/base/checks.h b/toolsrc/include/vcpkg/base/checks.h
index fb162c897..bceee3428 100644
--- a/toolsrc/include/vcpkg/base/checks.h
+++ b/toolsrc/include/vcpkg/base/checks.h
@@ -27,7 +27,7 @@ namespace vcpkg::Checks
// Display an error message to the user and exit the tool.
[[noreturn]] void exit_with_message(const LineInfo& line_info,
const char* error_message_template,
- const Arg1 error_message_arg1,
+ const Arg1& error_message_arg1,
const Args&... error_message_args)
{
exit_with_message(line_info,
@@ -42,7 +42,7 @@ namespace vcpkg::Checks
void check_exit(const LineInfo& line_info,
Conditional&& expression,
const char* error_message_template,
- const Arg1 error_message_arg1,
+ const Arg1& error_message_arg1,
const Args&... error_message_args)
{
if (!expression)
diff --git a/toolsrc/include/vcpkg/base/chrono.h b/toolsrc/include/vcpkg/base/chrono.h
index 4291115f7..aa764a597 100644
--- a/toolsrc/include/vcpkg/base/chrono.h
+++ b/toolsrc/include/vcpkg/base/chrono.h
@@ -2,7 +2,6 @@
#include <chrono>
#include <string>
-#include <time.h>
#include <vcpkg/base/optional.h>
namespace vcpkg::Chrono
@@ -12,8 +11,8 @@ namespace vcpkg::Chrono
using duration = std::chrono::high_resolution_clock::time_point::duration;
public:
- constexpr ElapsedTime() : m_duration() {}
- constexpr ElapsedTime(duration d) : m_duration(d) {}
+ constexpr ElapsedTime() noexcept : m_duration() {}
+ constexpr ElapsedTime(duration d) noexcept : m_duration(d) {}
template<class TimeUnit>
TimeUnit as() const
@@ -32,7 +31,7 @@ namespace vcpkg::Chrono
public:
static ElapsedTimer create_started();
- constexpr ElapsedTimer() : m_start_tick() {}
+ constexpr ElapsedTimer() noexcept : m_start_tick() {}
ElapsedTime elapsed() const
{
@@ -53,8 +52,8 @@ namespace vcpkg::Chrono
static Optional<CTime> get_current_date_time();
static Optional<CTime> parse(CStringView str);
- constexpr CTime() : m_tm{0} {}
- explicit constexpr CTime(tm t) : m_tm{t} {}
+ constexpr CTime() noexcept : m_tm{0} {}
+ explicit constexpr CTime(tm t) noexcept : m_tm{t} {}
std::string to_string() const;
diff --git a/toolsrc/include/vcpkg/base/cstringview.h b/toolsrc/include/vcpkg/base/cstringview.h
index 0441bc573..f285aa36c 100644
--- a/toolsrc/include/vcpkg/base/cstringview.h
+++ b/toolsrc/include/vcpkg/base/cstringview.h
@@ -7,7 +7,7 @@ namespace vcpkg
{
struct CStringView
{
- constexpr CStringView() : cstr(nullptr) {}
+ 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()) {}
@@ -18,19 +18,6 @@ namespace vcpkg
const char* cstr;
};
- struct CWStringView
- {
- constexpr CWStringView() : cstr(nullptr) {}
- constexpr CWStringView(const wchar_t* cstr) : cstr(cstr) {}
- constexpr CWStringView(const CWStringView&) = default;
- CWStringView(const std::wstring& str) : cstr(str.c_str()) {}
-
- constexpr const wchar_t* c_str() const { return cstr; }
-
- private:
- const wchar_t* cstr;
- };
-
namespace details
{
inline bool vcpkg_strcmp(const char* l, const char* r) { return strcmp(l, r) == 0; }
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h
index ac1f192ae..f16805d0a 100644
--- a/toolsrc/include/vcpkg/base/files.h
+++ b/toolsrc/include/vcpkg/base/files.h
@@ -64,7 +64,7 @@ namespace vcpkg::Files
Filesystem& get_real_filesystem();
- static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)";
+ static constexpr const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)";
bool has_invalid_chars_for_filesystem(const std::string& s);
diff --git a/toolsrc/include/vcpkg/base/lineinfo.h b/toolsrc/include/vcpkg/base/lineinfo.h
index e7e8c3031..e0eb8bec9 100644
--- a/toolsrc/include/vcpkg/base/lineinfo.h
+++ b/toolsrc/include/vcpkg/base/lineinfo.h
@@ -9,7 +9,7 @@ namespace vcpkg
int line_number;
const char* file_name;
- constexpr LineInfo() : line_number(0), file_name("") {}
+ constexpr LineInfo() noexcept : line_number(0), file_name("") {}
constexpr LineInfo(const int lineno, const char* filename) : line_number(lineno), file_name(filename) {}
std::string to_string() const;
diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h
index af2d297a6..6b84b10aa 100644
--- a/toolsrc/include/vcpkg/base/optional.h
+++ b/toolsrc/include/vcpkg/base/optional.h
@@ -16,7 +16,7 @@ namespace vcpkg
template<class T>
struct OptionalStorage
{
- constexpr OptionalStorage() : m_is_present(false), m_t() {}
+ constexpr OptionalStorage() noexcept : m_is_present(false), m_t() {}
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)) {}
@@ -33,7 +33,7 @@ namespace vcpkg
template<class T>
struct OptionalStorage<T&>
{
- constexpr OptionalStorage() : m_t(nullptr) {}
+ constexpr OptionalStorage() noexcept : m_t(nullptr) {}
constexpr OptionalStorage(T& t) : m_t(&t) {}
constexpr bool has_value() const { return m_t != nullptr; }
@@ -48,7 +48,7 @@ namespace vcpkg
template<class T>
struct Optional
{
- constexpr Optional() {}
+ constexpr Optional() noexcept {}
// Constructors are intentionally implicit
constexpr Optional(NullOpt) {}
@@ -64,6 +64,12 @@ namespace vcpkg
return std::move(this->m_base.value());
}
+ T& value_or_exit(const LineInfo& line_info) &
+ {
+ this->exit_if_null(line_info);
+ return this->m_base.value();
+ }
+
const T& value_or_exit(const LineInfo& line_info) const&
{
this->exit_if_null(line_info);
diff --git a/toolsrc/include/vcpkg/base/span.h b/toolsrc/include/vcpkg/base/span.h
index c9ac18afe..2b067d0ac 100644
--- a/toolsrc/include/vcpkg/base/span.h
+++ b/toolsrc/include/vcpkg/base/span.h
@@ -19,18 +19,19 @@ namespace vcpkg
using iterator = pointer;
constexpr Span() noexcept : m_ptr(nullptr), m_count(0) {}
- constexpr Span(std::nullptr_t) noexcept : Span() {}
+ 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(std::initializer_list<T> l) noexcept : m_ptr(l.begin()), m_count(l.size()) {}
template<size_t N>
- constexpr Span(T (&arr)[N]) noexcept : Span(arr, N)
+ constexpr Span(T (&arr)[N]) noexcept : m_ptr(arr), m_count(N)
{
}
template<size_t N>
- constexpr Span(const std::array<std::remove_const_t<T>, N>& arr) noexcept : Span(arr.data(), arr.size())
+ constexpr Span(const std::array<std::remove_const_t<T>, N>& arr) noexcept
+ : m_ptr(arr.data()), m_count(arr.size())
{
}
diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h
index c32e81ac2..4cc17bcf4 100644
--- a/toolsrc/include/vcpkg/base/strings.h
+++ b/toolsrc/include/vcpkg/base/strings.h
@@ -36,7 +36,7 @@ namespace vcpkg::Strings
std::wstring to_utf16(const CStringView& s);
- std::string to_utf8(const CWStringView& w);
+ std::string to_utf8(const wchar_t* w);
std::string escape_string(const CStringView& s, char char_to_escape, char escape_char);
diff --git a/toolsrc/include/vcpkg/binaryparagraph.h b/toolsrc/include/vcpkg/binaryparagraph.h
index 3315151c6..5ba2fbde3 100644
--- a/toolsrc/include/vcpkg/binaryparagraph.h
+++ b/toolsrc/include/vcpkg/binaryparagraph.h
@@ -12,7 +12,7 @@ namespace vcpkg
/// </summary>
struct BinaryParagraph
{
- BinaryParagraph();
+ BinaryParagraph() noexcept;
explicit BinaryParagraph(std::unordered_map<std::string, std::string> fields);
BinaryParagraph(const SourceParagraph& spgh, const Triplet& triplet, const std::string& abi_tag);
BinaryParagraph(const SourceParagraph& spgh, const FeatureParagraph& fpgh, const Triplet& triplet);
diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h
index a86245ccf..c5e7e8d88 100644
--- a/toolsrc/include/vcpkg/build.h
+++ b/toolsrc/include/vcpkg/build.h
@@ -62,7 +62,7 @@ namespace vcpkg::Build
BUILT_IN,
ARIA2,
};
- const std::string& to_string(DownloadTool tool);
+ const std::string& to_string(DownloadTool tool);
struct BuildPackageOptions
{
@@ -203,8 +203,8 @@ namespace vcpkg::Build
struct BuildInfo
{
- LinkageType crt_linkage;
- LinkageType library_linkage;
+ LinkageType crt_linkage = LinkageType::DYNAMIC;
+ LinkageType library_linkage = LinkageType::DYNAMIC;
Optional<std::string> version;
diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h
index 7369b8206..6d29b7960 100644
--- a/toolsrc/include/vcpkg/commands.h
+++ b/toolsrc/include/vcpkg/commands.h
@@ -131,8 +131,17 @@ namespace vcpkg::Commands
namespace Hash
{
+ std::string get_string_hash(const std::string& s, const std::string& hash_type);
+ std::string get_file_hash(const VcpkgPaths& paths, const fs::path& path, const std::string& hash_type);
+
+ void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
+ }
+
+ namespace Fetch
+ {
+ std::vector<Toolset> find_toolset_instances(const VcpkgPaths& paths);
+ fs::path get_tool_path(const VcpkgPaths& paths, const std::string& tool);
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
- std::string get_file_hash(const VcpkgPaths& paths, fs::path const& path, std::string const& hash_type);
}
template<class T>
diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h
index fea0d88a9..3c3b8f267 100644
--- a/toolsrc/include/vcpkg/dependencies.h
+++ b/toolsrc/include/vcpkg/dependencies.h
@@ -35,10 +35,9 @@ namespace vcpkg::Dependencies
{
static bool compare_by_name(const InstallPlanAction* left, const InstallPlanAction* right);
- InstallPlanAction();
+ InstallPlanAction() noexcept;
- InstallPlanAction(const PackageSpec& spec,
- InstalledPackageView&& spghs,
+ InstallPlanAction(InstalledPackageView&& spghs,
const std::set<std::string>& features,
const RequestType& request_type);
@@ -74,7 +73,7 @@ namespace vcpkg::Dependencies
{
static bool compare_by_name(const RemovePlanAction* left, const RemovePlanAction* right);
- RemovePlanAction();
+ RemovePlanAction() noexcept;
RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type);
PackageSpec spec;
@@ -104,7 +103,7 @@ namespace vcpkg::Dependencies
{
static bool compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right);
- ExportPlanAction();
+ ExportPlanAction() noexcept;
ExportPlanAction(const PackageSpec& spec,
InstalledPackageView&& installed_package,
const RequestType& request_type);
diff --git a/toolsrc/include/vcpkg/export.ifw.h b/toolsrc/include/vcpkg/export.ifw.h
index d28a4436d..b1573924e 100644
--- a/toolsrc/include/vcpkg/export.ifw.h
+++ b/toolsrc/include/vcpkg/export.ifw.h
@@ -3,8 +3,6 @@
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgpaths.h>
-#include <vcpkg/base/files.h>
-
#include <string>
#include <vector>
diff --git a/toolsrc/include/vcpkg/packagespecparseresult.h b/toolsrc/include/vcpkg/packagespecparseresult.h
index dd91c9a67..be3497152 100644
--- a/toolsrc/include/vcpkg/packagespecparseresult.h
+++ b/toolsrc/include/vcpkg/packagespecparseresult.h
@@ -17,7 +17,7 @@ namespace vcpkg
template<>
struct ErrorHolder<PackageSpecParseResult>
{
- ErrorHolder() : m_err(PackageSpecParseResult::SUCCESS) {}
+ ErrorHolder() noexcept : m_err(PackageSpecParseResult::SUCCESS) {}
ErrorHolder(PackageSpecParseResult err) : m_err(err) {}
bool has_error() const { return m_err != PackageSpecParseResult::SUCCESS; }
diff --git a/toolsrc/include/vcpkg/paragraphs.h b/toolsrc/include/vcpkg/paragraphs.h
index fa0265b75..56f09387a 100644
--- a/toolsrc/include/vcpkg/paragraphs.h
+++ b/toolsrc/include/vcpkg/paragraphs.h
@@ -3,12 +3,9 @@
#include <vcpkg/binaryparagraph.h>
#include <vcpkg/parse.h>
#include <vcpkg/vcpkgpaths.h>
-#include <vcpkg/versiont.h>
#include <vcpkg/base/expected.h>
-#include <map>
-
namespace vcpkg::Paragraphs
{
using RawParagraph = Parse::RawParagraph;
diff --git a/toolsrc/include/vcpkg/statusparagraph.h b/toolsrc/include/vcpkg/statusparagraph.h
index 0802de530..e79c946cc 100644
--- a/toolsrc/include/vcpkg/statusparagraph.h
+++ b/toolsrc/include/vcpkg/statusparagraph.h
@@ -29,7 +29,7 @@ namespace vcpkg
/// </summary>
struct StatusParagraph
{
- StatusParagraph();
+ StatusParagraph() noexcept;
explicit StatusParagraph(std::unordered_map<std::string, std::string>&& fields);
bool is_installed() const { return want == Want::INSTALL && state == InstallState::INSTALLED; }
@@ -47,13 +47,14 @@ namespace vcpkg
struct InstalledPackageView
{
- InstalledPackageView() : core(nullptr) {}
+ InstalledPackageView() noexcept : core(nullptr) {}
InstalledPackageView(const StatusParagraph* c, std::vector<const StatusParagraph*>&& fs)
: core(c), features(std::move(fs))
{
}
+ const PackageSpec& spec() const { return core->package.spec; }
std::vector<PackageSpec> dependencies() const;
const StatusParagraph* core;
diff --git a/toolsrc/include/vcpkg/triplet.h b/toolsrc/include/vcpkg/triplet.h
index 10464dc2c..334960e49 100644
--- a/toolsrc/include/vcpkg/triplet.h
+++ b/toolsrc/include/vcpkg/triplet.h
@@ -9,7 +9,7 @@ namespace vcpkg
struct Triplet
{
public:
- constexpr Triplet() : m_instance(&DEFAULT_INSTANCE) {}
+ constexpr Triplet() noexcept : m_instance(&DEFAULT_INSTANCE) {}
static Triplet from_canonical_name(const std::string& triplet_as_string);
@@ -47,4 +47,4 @@ namespace std
{
size_t operator()(const vcpkg::Triplet& t) const { return t.hash_code(); }
};
-} \ No newline at end of file
+}
diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
index f449887f1..de65eec28 100644
--- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h
+++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
@@ -1,6 +1,5 @@
#pragma once
-#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/span.h>
#include <vcpkg/base/stringliteral.h>
diff --git a/toolsrc/include/vcpkg/vcpkglib.h b/toolsrc/include/vcpkg/vcpkglib.h
index 3c8e676bf..5674d30db 100644
--- a/toolsrc/include/vcpkg/vcpkglib.h
+++ b/toolsrc/include/vcpkg/vcpkglib.h
@@ -16,7 +16,7 @@ namespace vcpkg
SortedVector<std::string> files;
};
- std::vector<StatusParagraph*> get_installed_ports(const StatusParagraphs& status_db);
+ std::vector<InstalledPackageView> get_installed_ports(const StatusParagraphs& status_db);
std::vector<StatusParagraphAndAssociatedFiles> get_installed_files(const VcpkgPaths& paths,
const StatusParagraphs& status_db);
diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h
index b3f24fb89..9c8f2911a 100644
--- a/toolsrc/include/vcpkg/vcpkgpaths.h
+++ b/toolsrc/include/vcpkg/vcpkgpaths.h
@@ -3,12 +3,25 @@
#include <vcpkg/binaryparagraph.h>
#include <vcpkg/packagespec.h>
+#include <vcpkg/base/cache.h>
#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/lazy.h>
namespace vcpkg
{
+ namespace Tools
+ {
+ static const std::string SEVEN_ZIP = "7zip";
+ static const std::string CMAKE = "cmake";
+ static const std::string GIT = "git";
+ static const std::string NINJA = "ninja";
+ static const std::string NUGET = "nuget";
+ static const std::string IFW_INSTALLER_BASE = "ifw_installerbase";
+ static const std::string IFW_BINARYCREATOR = "ifw_binarycreator";
+ static const std::string IFW_REPOGEN = "ifw_repogen";
+ }
+
struct ToolsetArchOption
{
CStringView name;
@@ -63,14 +76,7 @@ namespace vcpkg
fs::path ports_cmake;
- const fs::path& get_7za_exe() const;
- const fs::path& get_cmake_exe() const;
- const fs::path& get_git_exe() const;
- const fs::path& get_ninja_exe() const;
- const fs::path& get_nuget_exe() const;
- const fs::path& get_ifw_installerbase_exe() const;
- const fs::path& get_ifw_binarycreator_exe() const;
- const fs::path& get_ifw_repogen_exe() const;
+ const fs::path& get_tool_exe(const std::string& tool) const;
/// <summary>Retrieve a toolset matching a VS version</summary>
/// <remarks>
@@ -82,14 +88,7 @@ namespace vcpkg
private:
Lazy<std::vector<std::string>> available_triplets;
- Lazy<fs::path> _7za_exe;
- Lazy<fs::path> cmake_exe;
- Lazy<fs::path> git_exe;
- Lazy<fs::path> ninja_exe;
- Lazy<fs::path> nuget_exe;
- Lazy<fs::path> ifw_installerbase_exe;
- Lazy<fs::path> ifw_binarycreator_exe;
- Lazy<fs::path> ifw_repogen_exe;
+ Cache<std::string, fs::path> tool_paths;
Lazy<std::vector<Toolset>> toolsets;
Lazy<std::vector<Toolset>> toolsets_vs2013;
diff --git a/toolsrc/include/vcpkg/versiont.h b/toolsrc/include/vcpkg/versiont.h
index 8427dfe3b..e893f1abc 100644
--- a/toolsrc/include/vcpkg/versiont.h
+++ b/toolsrc/include/vcpkg/versiont.h
@@ -5,7 +5,7 @@ namespace vcpkg
{
struct VersionT
{
- VersionT();
+ VersionT() noexcept;
VersionT(std::string&& value);
VersionT(const std::string& value);
@@ -23,7 +23,7 @@ namespace vcpkg
VersionT left;
VersionT right;
- VersionDiff();
+ VersionDiff() noexcept;
VersionDiff(const VersionT& left, const VersionT& right);
std::string to_string() const;