aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorJan HrubĂ˝ <jhruby.web@gmail.com>2017-03-13 08:56:05 +0100
committerGitHub <noreply@github.com>2017-03-13 08:56:05 +0100
commit665f4118f603c5858217ed7a2f2f824b18ff4fc5 (patch)
treef0167041edf71e90f2331b5025f603392a8de67a /toolsrc/include
parent1bec0fcb73073b5b1719f454c368a63f1bff625e (diff)
parent1c9873a0daf625f67474aaf3e163c592c27ecb65 (diff)
downloadvcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.tar.gz
vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.zip
Merge pull request #1 from Microsoft/master
pull
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/BinaryParagraph.h7
-rw-r--r--toolsrc/include/ImmutableSortedVector.h48
-rw-r--r--toolsrc/include/MachineType.h36
-rw-r--r--toolsrc/include/Paragraphs.h21
-rw-r--r--toolsrc/include/PostBuildLint.h8
-rw-r--r--toolsrc/include/PostBuildLint_BuildInfo.h21
-rw-r--r--toolsrc/include/PostBuildLint_BuildPolicies.h38
-rw-r--r--toolsrc/include/PostBuildLint_BuildType.h47
-rw-r--r--toolsrc/include/PostBuildLint_ConfigurationType.h33
-rw-r--r--toolsrc/include/PostBuildLint_LinkageType.h34
-rw-r--r--toolsrc/include/SourceParagraph.h19
-rw-r--r--toolsrc/include/StatusParagraphs.h15
-rw-r--r--toolsrc/include/coff_file_reader.h21
-rw-r--r--toolsrc/include/expected.h1
-rw-r--r--toolsrc/include/filesystem_fs.h5
-rw-r--r--toolsrc/include/lazy.h26
-rw-r--r--toolsrc/include/metrics.h1
-rw-r--r--toolsrc/include/opt_bool.h32
-rw-r--r--toolsrc/include/package_spec.h24
-rw-r--r--toolsrc/include/package_spec_parse_result.h8
-rw-r--r--toolsrc/include/pch.h43
-rw-r--r--toolsrc/include/post_build_lint.h8
-rw-r--r--toolsrc/include/triplet.h11
-rw-r--r--toolsrc/include/vcpkg.h33
-rw-r--r--toolsrc/include/vcpkg_Checks.h8
-rw-r--r--toolsrc/include/vcpkg_Chrono.h31
-rw-r--r--toolsrc/include/vcpkg_Commands.h149
-rw-r--r--toolsrc/include/vcpkg_Dependencies.h76
-rw-r--r--toolsrc/include/vcpkg_Enums.h11
-rw-r--r--toolsrc/include/vcpkg_Environment.h22
-rw-r--r--toolsrc/include/vcpkg_Files.h53
-rw-r--r--toolsrc/include/vcpkg_Graphs.h13
-rw-r--r--toolsrc/include/vcpkg_Input.h15
-rw-r--r--toolsrc/include/vcpkg_Maps.h27
-rw-r--r--toolsrc/include/vcpkg_Sets.h6
-rw-r--r--toolsrc/include/vcpkg_Strings.h92
-rw-r--r--toolsrc/include/vcpkg_System.h63
-rw-r--r--toolsrc/include/vcpkg_cmd_arguments.h18
-rw-r--r--toolsrc/include/vcpkg_optional.h5
-rw-r--r--toolsrc/include/vcpkg_paths.h50
-rw-r--r--toolsrc/include/vcpkglib.h34
-rw-r--r--toolsrc/include/vcpkglib_helpers.h12
42 files changed, 1031 insertions, 194 deletions
diff --git a/toolsrc/include/BinaryParagraph.h b/toolsrc/include/BinaryParagraph.h
index 88d6e84b1..3d9cfb9fb 100644
--- a/toolsrc/include/BinaryParagraph.h
+++ b/toolsrc/include/BinaryParagraph.h
@@ -2,14 +2,14 @@
#include <unordered_map>
#include "SourceParagraph.h"
-#include "triplet.h"
+#include "package_spec.h"
namespace vcpkg
{
struct BinaryParagraph
{
BinaryParagraph();
- explicit BinaryParagraph(const std::unordered_map<std::string, std::string>& fields);
+ explicit BinaryParagraph(std::unordered_map<std::string, std::string> fields);
BinaryParagraph(const SourceParagraph& spgh, const triplet& target_triplet);
std::string displayname() const;
@@ -18,11 +18,10 @@ namespace vcpkg
std::string dir() const;
- std::string name;
+ package_spec spec;
std::string version;
std::string description;
std::string maintainer;
- triplet target_triplet;
std::vector<std::string> depends;
};
diff --git a/toolsrc/include/ImmutableSortedVector.h b/toolsrc/include/ImmutableSortedVector.h
new file mode 100644
index 000000000..681f9fd4d
--- /dev/null
+++ b/toolsrc/include/ImmutableSortedVector.h
@@ -0,0 +1,48 @@
+#pragma once
+
+#include <vector>
+#include <algorithm>
+
+// Add more forwarding functions to the delegate std::vector as needed.
+namespace vcpkg
+{
+ template <class T>
+ class ImmutableSortedVector
+ {
+ public:
+ static ImmutableSortedVector<T> create(std::vector<T> vector)
+ {
+ ImmutableSortedVector out;
+ out.delegate = std::move(vector);
+ if (!std::is_sorted(out.delegate.cbegin(), out.delegate.cend()))
+ {
+ std::sort(out.delegate.begin(), out.delegate.end());
+ }
+
+ return out;
+ }
+
+ typename std::vector<T>::const_iterator begin() const
+ {
+ return this->delegate.cbegin();
+ }
+
+ typename std::vector<T>::const_iterator end() const
+ {
+ return this->delegate.cend();
+ }
+
+ typename std::vector<T>::const_iterator cbegin() const
+ {
+ return this->delegate.cbegin();
+ }
+
+ typename std::vector<T>::const_iterator cend() const
+ {
+ return this->delegate.cend();
+ }
+
+ private:
+ std::vector<T> delegate;
+ };
+}
diff --git a/toolsrc/include/MachineType.h b/toolsrc/include/MachineType.h
new file mode 100644
index 000000000..86efb85c5
--- /dev/null
+++ b/toolsrc/include/MachineType.h
@@ -0,0 +1,36 @@
+#pragma once
+#include <cstdint>
+
+namespace vcpkg
+{
+ enum class MachineType : uint16_t
+ {
+ UNKNOWN = 0x0, // The contents of this field are assumed to be applicable to any machine type
+ AM33=0x1d3,//Matsushita AM33
+ AMD64=0x8664,//x64
+ ARM=0x1c0,//ARM little endian
+ ARM64=0xaa64,//ARM64 little endian
+ ARMNT=0x1c4,//ARM Thumb-2 little endian
+ EBC=0xebc,//EFI byte code
+ I386=0x14c,//Intel 386 or later processors and compatible processors
+ IA64=0x200,//Intel Itanium processor family
+ M32R=0x9041,//Mitsubishi M32R little endian
+ MIPS16=0x266,//MIPS16
+ MIPSFPU=0x366,//MIPS with FPU
+ MIPSFPU16=0x466,//MIPS16 with FPU
+ POWERPC=0x1f0,//Power PC little endian
+ POWERPCFP=0x1f1,//Power PC with floating point support
+ R4000=0x166,//MIPS little endian
+ RISCV32=0x5032,//RISC-V 32-bit address space
+ RISCV64=0x5064,//RISC-V 64-bit address space
+ RISCV128=0x5128,//RISC-V 128-bit address space
+ SH3=0x1a2,//Hitachi SH3
+ SH3DSP=0x1a3,//Hitachi SH3 DSP
+ SH4=0x1a6,//Hitachi SH4
+ SH5=0x1a8,//Hitachi SH5
+ THUMB=0x1c2,//Thumb
+ WCEMIPSV2=0x169,//MIPS little-endian WCE v2
+ };
+
+ MachineType getMachineType(const uint16_t value);
+}
diff --git a/toolsrc/include/Paragraphs.h b/toolsrc/include/Paragraphs.h
new file mode 100644
index 000000000..79b66a67f
--- /dev/null
+++ b/toolsrc/include/Paragraphs.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "filesystem_fs.h"
+#include <map>
+#include "expected.h"
+#include "BinaryParagraph.h"
+#include "vcpkg_paths.h"
+
+namespace vcpkg::Paragraphs
+{
+ std::vector<std::unordered_map<std::string, std::string>> get_paragraphs(const fs::path& control_path);
+ std::vector<std::unordered_map<std::string, std::string>> parse_paragraphs(const std::string& str);
+
+ expected<SourceParagraph> try_load_port(const fs::path& control_path);
+
+ expected<BinaryParagraph> try_load_cached_package(const vcpkg_paths& paths, const package_spec& spec);
+
+ std::vector<SourceParagraph> load_all_ports(const fs::path& ports_dir);
+
+ std::map<std::string, std::string> extract_port_names_and_versions(const std::vector<SourceParagraph>& source_paragraphs);
+}
diff --git a/toolsrc/include/PostBuildLint.h b/toolsrc/include/PostBuildLint.h
new file mode 100644
index 000000000..73c8ec54b
--- /dev/null
+++ b/toolsrc/include/PostBuildLint.h
@@ -0,0 +1,8 @@
+#pragma once
+#include "package_spec.h"
+#include "vcpkg_paths.h"
+
+namespace vcpkg::PostBuildLint
+{
+ size_t perform_all_checks(const package_spec& spec, const vcpkg_paths& paths);
+}
diff --git a/toolsrc/include/PostBuildLint_BuildInfo.h b/toolsrc/include/PostBuildLint_BuildInfo.h
new file mode 100644
index 000000000..bac024e01
--- /dev/null
+++ b/toolsrc/include/PostBuildLint_BuildInfo.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "filesystem_fs.h"
+#include "PostBuildLint_BuildPolicies.h"
+#include "opt_bool.h"
+#include "PostBuildLint_LinkageType.h"
+
+namespace vcpkg::PostBuildLint
+{
+ struct BuildInfo
+ {
+ static BuildInfo create(std::unordered_map<std::string, std::string> pgh);
+
+ LinkageType::type crt_linkage;
+ LinkageType::type library_linkage;
+
+ std::map<BuildPolicies::type, opt_bool_t> policies;
+ };
+
+ BuildInfo read_build_info(const fs::path& filepath);
+}
diff --git a/toolsrc/include/PostBuildLint_BuildPolicies.h b/toolsrc/include/PostBuildLint_BuildPolicies.h
new file mode 100644
index 000000000..d815c6d27
--- /dev/null
+++ b/toolsrc/include/PostBuildLint_BuildPolicies.h
@@ -0,0 +1,38 @@
+#pragma once
+#include <string>
+#include <array>
+
+namespace vcpkg::PostBuildLint::BuildPolicies
+{
+ enum class backing_enum_t
+ {
+ NULLVALUE = 0,
+ EMPTY_PACKAGE,
+ DLLS_WITHOUT_LIBS,
+ ONLY_RELEASE_CRT
+ };
+
+ struct type
+ {
+ constexpr type() : backing_enum(backing_enum_t::NULLVALUE) {}
+ constexpr explicit type(backing_enum_t backing_enum) : backing_enum(backing_enum) { }
+ constexpr operator backing_enum_t() const { return backing_enum; }
+
+ const std::string& toString() const;
+ const std::string& cmake_variable() const;
+
+ private:
+ backing_enum_t backing_enum;
+ };
+
+ static const std::string ENUM_NAME = "vcpkg::PostBuildLint::BuildPolicies";
+
+ static constexpr type NULLVALUE(backing_enum_t::NULLVALUE);
+ static constexpr type EMPTY_PACKAGE(backing_enum_t::EMPTY_PACKAGE);
+ static constexpr type DLLS_WITHOUT_LIBS(backing_enum_t::DLLS_WITHOUT_LIBS);
+ static constexpr type ONLY_RELEASE_CRT(backing_enum_t::ONLY_RELEASE_CRT);
+
+ static constexpr std::array<type, 3> values = { EMPTY_PACKAGE, DLLS_WITHOUT_LIBS, ONLY_RELEASE_CRT };
+
+ type parse(const std::string& s);
+}
diff --git a/toolsrc/include/PostBuildLint_BuildType.h b/toolsrc/include/PostBuildLint_BuildType.h
new file mode 100644
index 000000000..31fbb11c9
--- /dev/null
+++ b/toolsrc/include/PostBuildLint_BuildType.h
@@ -0,0 +1,47 @@
+#pragma once
+#include "PostBuildLint_ConfigurationType.h"
+#include "PostBuildLint_LinkageType.h"
+#include <array>
+#include <regex>
+
+namespace vcpkg::PostBuildLint::BuildType
+{
+ enum class backing_enum_t
+ {
+ DEBUG_STATIC = 1,
+ DEBUG_DYNAMIC,
+ RELEASE_STATIC,
+ RELEASE_DYNAMIC
+ };
+
+ struct type
+ {
+ type() = delete;
+
+ constexpr explicit type(const backing_enum_t backing_enum, const ConfigurationType::type config, const LinkageType::type linkage) :
+ backing_enum(backing_enum), m_config(config), m_linkage(linkage) { }
+
+ constexpr operator backing_enum_t() const { return backing_enum; }
+
+ const ConfigurationType::type& config() const;
+ const LinkageType::type& linkage() const;
+ const std::regex& crt_regex() const;
+ const std::string& toString() const;
+
+ private:
+ backing_enum_t backing_enum;
+ ConfigurationType::type m_config;
+ LinkageType::type m_linkage;
+ };
+
+ static const std::string ENUM_NAME = "vcpkg::PostBuildLint::BuildType";
+
+ static constexpr type DEBUG_STATIC = type(backing_enum_t::DEBUG_STATIC, ConfigurationType::DEBUG, LinkageType::STATIC);
+ static constexpr type DEBUG_DYNAMIC = type(backing_enum_t::DEBUG_DYNAMIC, ConfigurationType::DEBUG, LinkageType::DYNAMIC);
+ static constexpr type RELEASE_STATIC = type(backing_enum_t::RELEASE_STATIC, ConfigurationType::RELEASE, LinkageType::STATIC);
+ static constexpr type RELEASE_DYNAMIC = type(backing_enum_t::RELEASE_DYNAMIC, ConfigurationType::RELEASE, LinkageType::DYNAMIC);
+
+ static constexpr std::array<type, 4> values = { DEBUG_STATIC, DEBUG_DYNAMIC, RELEASE_STATIC, RELEASE_DYNAMIC };
+
+ type value_of(const ConfigurationType::type& config, const LinkageType::type& linkage);
+}
diff --git a/toolsrc/include/PostBuildLint_ConfigurationType.h b/toolsrc/include/PostBuildLint_ConfigurationType.h
new file mode 100644
index 000000000..7245d2932
--- /dev/null
+++ b/toolsrc/include/PostBuildLint_ConfigurationType.h
@@ -0,0 +1,33 @@
+#pragma once
+#pragma once
+#include <string>
+
+namespace vcpkg::PostBuildLint::ConfigurationType
+{
+ enum class backing_enum_t
+ {
+ NULLVALUE = 0,
+ DEBUG = 1,
+ RELEASE = 2
+ };
+
+ struct type
+ {
+ constexpr type() : backing_enum(backing_enum_t::NULLVALUE) {}
+ constexpr explicit type(backing_enum_t backing_enum) : backing_enum(backing_enum) { }
+ constexpr operator backing_enum_t() const { return backing_enum; }
+
+ const std::string& toString() const;
+
+ private:
+ backing_enum_t backing_enum;
+ };
+
+ static const std::string ENUM_NAME = "vcpkg::PostBuildLint::ConfigurationType";
+
+ static constexpr type NULLVALUE(backing_enum_t::NULLVALUE);
+ static constexpr type DEBUG(backing_enum_t::DEBUG);
+ static constexpr type RELEASE(backing_enum_t::RELEASE);
+
+ static constexpr std::array<type, 2> values = { DEBUG, RELEASE };
+}
diff --git a/toolsrc/include/PostBuildLint_LinkageType.h b/toolsrc/include/PostBuildLint_LinkageType.h
new file mode 100644
index 000000000..0cecc8c9f
--- /dev/null
+++ b/toolsrc/include/PostBuildLint_LinkageType.h
@@ -0,0 +1,34 @@
+#pragma once
+#include <string>
+
+namespace vcpkg::PostBuildLint::LinkageType
+{
+ enum class backing_enum_t
+ {
+ NULLVALUE = 0,
+ DYNAMIC,
+ STATIC
+ };
+
+ struct type
+ {
+ constexpr type() : backing_enum(backing_enum_t::NULLVALUE) {}
+ constexpr explicit type(backing_enum_t backing_enum) : backing_enum(backing_enum) { }
+ constexpr operator backing_enum_t() const { return backing_enum; }
+
+ const std::string& toString() const;
+
+ private:
+ backing_enum_t backing_enum;
+ };
+
+ static const std::string ENUM_NAME = "vcpkg::PostBuildLint::LinkageType";
+
+ static constexpr type NULLVALUE(backing_enum_t::NULLVALUE);
+ static constexpr type DYNAMIC(backing_enum_t::DYNAMIC);
+ static constexpr type STATIC(backing_enum_t::STATIC);
+
+ static constexpr std::array<type, 2> values = { DYNAMIC, STATIC };
+
+ type value_of(const std::string& as_string);
+}
diff --git a/toolsrc/include/SourceParagraph.h b/toolsrc/include/SourceParagraph.h
index 72dca8324..5ae9b38b8 100644
--- a/toolsrc/include/SourceParagraph.h
+++ b/toolsrc/include/SourceParagraph.h
@@ -5,16 +5,31 @@
namespace vcpkg
{
+ struct triplet;
+
+ struct dependency
+ {
+ std::string name;
+ std::string qualifier;
+ };
+
+ std::ostream& operator<<(std::ostream& os, const dependency& p);
+
struct SourceParagraph
{
SourceParagraph();
- explicit SourceParagraph(const std::unordered_map<std::string, std::string>& fields);
+ explicit SourceParagraph(std::unordered_map<std::string, std::string> fields);
std::string name;
std::string version;
std::string description;
std::string maintainer;
- std::vector<std::string> depends;
+ std::vector<dependency> depends;
};
+
+ std::vector<std::string> filter_dependencies(const std::vector<vcpkg::dependency>& deps, const triplet& t);
+
+ std::vector<vcpkg::dependency> expand_qualified_dependencies(const std::vector<std::string>& depends);
+ std::vector<std::string> parse_depends(const std::string& depends_string);
}
diff --git a/toolsrc/include/StatusParagraphs.h b/toolsrc/include/StatusParagraphs.h
index 9446d432c..3c5d35183 100644
--- a/toolsrc/include/StatusParagraphs.h
+++ b/toolsrc/include/StatusParagraphs.h
@@ -1,6 +1,7 @@
#pragma once
#include "StatusParagraph.h"
#include <memory>
+#include <iterator>
namespace vcpkg
{
@@ -13,30 +14,34 @@ namespace vcpkg
using iterator = container::reverse_iterator;
using const_iterator = container::const_reverse_iterator;
+ const_iterator find(const package_spec& spec) const
+ {
+ return find(spec.name(), spec.target_triplet());
+ }
const_iterator find(const std::string& name, const triplet& target_triplet) const;
iterator find(const std::string& name, const triplet& target_triplet);
- iterator find_installed(const std::string& name, const triplet& target_triplet);
+ const_iterator find_installed(const std::string& name, const triplet& target_triplet) const;
iterator insert(std::unique_ptr<StatusParagraph>);
friend std::ostream& operator<<(std::ostream&, const StatusParagraphs&);
- auto end()
+ iterator end()
{
return paragraphs.rend();
}
- auto end() const
+ const_iterator end() const
{
return paragraphs.rend();
}
- auto begin()
+ iterator begin()
{
return paragraphs.rbegin();
}
- auto begin() const
+ const_iterator begin() const
{
return paragraphs.rbegin();
}
diff --git a/toolsrc/include/coff_file_reader.h b/toolsrc/include/coff_file_reader.h
new file mode 100644
index 000000000..24fbf4576
--- /dev/null
+++ b/toolsrc/include/coff_file_reader.h
@@ -0,0 +1,21 @@
+#pragma once
+#include <vector>
+#include "MachineType.h"
+#include "filesystem_fs.h"
+
+namespace vcpkg::COFFFileReader
+{
+ struct dll_info
+ {
+ MachineType machine_type;
+ };
+
+ struct lib_info
+ {
+ std::vector<MachineType> machine_types;
+ };
+
+ dll_info read_dll(const fs::path& path);
+
+ lib_info read_lib(const fs::path& path);
+}
diff --git a/toolsrc/include/expected.h b/toolsrc/include/expected.h
index affabcc02..cbb513b22 100644
--- a/toolsrc/include/expected.h
+++ b/toolsrc/include/expected.h
@@ -1,5 +1,6 @@
#pragma once
+#include <system_error>
#include "vcpkg_Checks.h"
namespace vcpkg
diff --git a/toolsrc/include/filesystem_fs.h b/toolsrc/include/filesystem_fs.h
new file mode 100644
index 000000000..ece485c23
--- /dev/null
+++ b/toolsrc/include/filesystem_fs.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include <filesystem>
+
+namespace fs = std::tr2::sys; \ No newline at end of file
diff --git a/toolsrc/include/lazy.h b/toolsrc/include/lazy.h
new file mode 100644
index 000000000..f9dbd8dc7
--- /dev/null
+++ b/toolsrc/include/lazy.h
@@ -0,0 +1,26 @@
+#pragma once
+
+namespace vcpkg
+{
+ template <typename T>
+ class lazy
+ {
+ public:
+ lazy() : value(T()), initialized(false) {}
+
+ template <class F>
+ T const& get_lazy(F& f) const
+ {
+ if (!initialized)
+ {
+ value = f();
+ initialized = true;
+ }
+ return value;
+ }
+
+ private:
+ mutable T value;
+ mutable bool initialized;
+ };
+}
diff --git a/toolsrc/include/metrics.h b/toolsrc/include/metrics.h
index 52662cd97..a0f4fc61d 100644
--- a/toolsrc/include/metrics.h
+++ b/toolsrc/include/metrics.h
@@ -13,6 +13,7 @@ namespace vcpkg
void TrackProperty(const std::string& name, const std::string& value);
void TrackProperty(const std::string& name, const std::wstring& value);
bool GetCompiledMetricsEnabled();
+ std::wstring GetSQMUser();
void Upload(const std::string& payload);
void Flush();
diff --git a/toolsrc/include/opt_bool.h b/toolsrc/include/opt_bool.h
index 3856366c8..06642a399 100644
--- a/toolsrc/include/opt_bool.h
+++ b/toolsrc/include/opt_bool.h
@@ -1,11 +1,33 @@
#pragma once
-namespace vcpkg
+#include <string>
+#include <map>
+
+namespace vcpkg::opt_bool
{
- enum class opt_bool
+ enum class type
{
- unspecified,
- enabled,
- disabled
+ UNSPECIFIED = 0,
+ ENABLED,
+ DISABLED
};
+
+ type parse(const std::string& s);
+
+ template <class T>
+ type from_map(const std::map<T, std::string>& map, const T& key)
+ {
+ auto it = map.find(key);
+ if (it == map.cend())
+ {
+ return type::UNSPECIFIED;
+ }
+
+ return parse(*it);
+ }
}
+
+namespace vcpkg
+{
+ using opt_bool_t = opt_bool::type;
+} \ No newline at end of file
diff --git a/toolsrc/include/package_spec.h b/toolsrc/include/package_spec.h
index 942b34adc..1bc493756 100644
--- a/toolsrc/include/package_spec.h
+++ b/toolsrc/include/package_spec.h
@@ -1,5 +1,4 @@
#pragma once
-#include <string>
#include "package_spec_parse_result.h"
#include "triplet.h"
#include "expected.h"
@@ -8,15 +7,24 @@ namespace vcpkg
{
struct package_spec
{
- static expected<package_spec> from_string(const std::string& spec, const triplet& default_target_triplet);
+ static expected<package_spec> from_string(const std::string& spec_as_string, const triplet& default_target_triplet);
- std::string name;
- triplet target_triplet;
+ static expected<package_spec> from_name_and_triplet(const std::string& name, const triplet& target_triplet);
+
+ const std::string& name() const;
+
+ const triplet& target_triplet() const;
+
+ std::string display_name() const;
std::string dir() const;
- };
- std::string to_string(const package_spec& spec);
+ std::string toString() const;
+
+ private:
+ std::string m_name;
+ triplet m_target_triplet;
+ };
std::string to_printf_arg(const package_spec& spec);
@@ -33,8 +41,8 @@ namespace std
size_t operator()(const vcpkg::package_spec& value) const
{
size_t hash = 17;
- hash = hash * 31 + std::hash<std::string>()(value.name);
- hash = hash * 31 + std::hash<vcpkg::triplet>()(value.target_triplet);
+ hash = hash * 31 + std::hash<std::string>()(value.name());
+ hash = hash * 31 + std::hash<vcpkg::triplet>()(value.target_triplet());
return hash;
}
};
diff --git a/toolsrc/include/package_spec_parse_result.h b/toolsrc/include/package_spec_parse_result.h
index e59622951..5735c4f4c 100644
--- a/toolsrc/include/package_spec_parse_result.h
+++ b/toolsrc/include/package_spec_parse_result.h
@@ -5,8 +5,9 @@ namespace vcpkg
{
enum class package_spec_parse_result
{
- success = 0,
- too_many_colons
+ SUCCESS = 0,
+ TOO_MANY_COLONS,
+ INVALID_CHARACTERS
};
struct package_spec_parse_result_category_impl final : std::error_category
@@ -30,5 +31,6 @@ namespace std
{
template <>
struct is_error_code_enum<vcpkg::package_spec_parse_result> : ::std::true_type
- {};
+ {
+ };
}
diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h
new file mode 100644
index 000000000..e78f17237
--- /dev/null
+++ b/toolsrc/include/pch.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include <Windows.h>
+#include <shellapi.h>
+#include <Shlobj.h>
+#include <winhttp.h>
+#include <process.h>
+
+#include <cassert>
+#include <stdexcept>
+#include <system_error>
+
+#include <array>
+#include <vector>
+#include <set>
+#include <map>
+#include <unordered_set>
+#include <unordered_map>
+
+#include <string>
+#include <regex>
+
+#include <filesystem>
+#include <iostream>
+#include <fstream>
+#include <memory>
+#include <iomanip>
+
+#include <algorithm>
+#include <functional>
+#include <iterator>
+#include <utility>
+
+#include <cstdarg>
+#include <codecvt>
+#include <cctype>
+#include <cstdint>
+
+#include <sys/timeb.h>
+#include <time.h>
+#include <chrono>
diff --git a/toolsrc/include/post_build_lint.h b/toolsrc/include/post_build_lint.h
deleted file mode 100644
index bc916a7af..000000000
--- a/toolsrc/include/post_build_lint.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-#include "package_spec.h"
-#include "vcpkg_paths.h"
-
-namespace vcpkg
-{
- void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths);
-}
diff --git a/toolsrc/include/triplet.h b/toolsrc/include/triplet.h
index 0c42f2ec7..32ea2e711 100644
--- a/toolsrc/include/triplet.h
+++ b/toolsrc/include/triplet.h
@@ -4,23 +4,24 @@
namespace vcpkg
{
- struct vcpkg_paths;
-
struct triplet
{
+ static triplet from_canonical_name(const std::string& triplet_as_string);
+
static const triplet X86_WINDOWS;
static const triplet X64_WINDOWS;
static const triplet X86_UWP;
static const triplet X64_UWP;
static const triplet ARM_UWP;
- std::string value;
+ const std::string& canonical_name() const;
std::string architecture() const;
std::string system() const;
- bool validate(const vcpkg_paths& paths);
+ private:
+ std::string m_canonical_name;
};
bool operator==(const triplet& left, const triplet& right);
@@ -43,7 +44,7 @@ namespace std
{
std::hash<std::string> hasher;
size_t hash = 17;
- hash = hash * 31 + hasher(t.value);
+ hash = hash * 31 + hasher(t.canonical_name());
return hash;
}
};
diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h
deleted file mode 100644
index a4a0682cf..000000000
--- a/toolsrc/include/vcpkg.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#pragma once
-
-#include <filesystem>
-#include <vector>
-#include <unordered_map>
-#include "package_spec.h"
-#include "BinaryParagraph.h"
-#include "StatusParagraphs.h"
-#include "vcpkg_paths.h"
-
-namespace vcpkg
-{
- namespace fs = std::tr2::sys;
-
- extern bool g_do_dry_run;
-
- std::vector<std::unordered_map<std::string, std::string>> get_paragraphs(const fs::path& control_path);
- std::vector<std::unordered_map<std::string, std::string>> parse_paragraphs(const std::string& str);
- std::string shorten_description(const std::string& desc);
-
- StatusParagraphs database_load_check(const vcpkg_paths& paths);
-
- std::vector<std::string> get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db);
-
- void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db);
- void deinstall_package(const vcpkg_paths& paths, const package_spec& spec, StatusParagraphs& status_db);
-
- void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db);
-
- void binary_import(const vcpkg_paths& paths, const fs::path& include_directory, const fs::path& project_directory, const BinaryParagraph& control_file_data);
-
- const std::string& version();
-} // namespace vcpkg
diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h
index 05bd0e729..23869f35f 100644
--- a/toolsrc/include/vcpkg_Checks.h
+++ b/toolsrc/include/vcpkg_Checks.h
@@ -2,7 +2,7 @@
#include "vcpkg_Strings.h"
-namespace vcpkg {namespace Checks
+namespace vcpkg::Checks
{
__declspec(noreturn) void unreachable();
@@ -20,7 +20,7 @@ namespace vcpkg {namespace Checks
template <class...Args>
_declspec(noreturn) void throw_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs)
{
- throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...));
+ throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
}
void check_throw(bool expression, const char* errorMessage);
@@ -35,6 +35,8 @@ namespace vcpkg {namespace Checks
}
}
+ void check_exit(bool expression);
+
void check_exit(bool expression, const char* errorMessage);
template <class...Args>
@@ -46,4 +48,4 @@ namespace vcpkg {namespace Checks
exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
}
}
-}}
+}
diff --git a/toolsrc/include/vcpkg_Chrono.h b/toolsrc/include/vcpkg_Chrono.h
new file mode 100644
index 000000000..a9d1bbbed
--- /dev/null
+++ b/toolsrc/include/vcpkg_Chrono.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <chrono>
+#include <string>
+
+namespace vcpkg
+{
+ class ElapsedTime
+ {
+ public:
+ static ElapsedTime createStarted();
+
+ constexpr ElapsedTime() : m_startTick() {}
+
+ template <class TimeUnit>
+ TimeUnit elapsed() const
+ {
+ return std::chrono::duration_cast<TimeUnit>(std::chrono::high_resolution_clock::now() - this->m_startTick);
+ }
+
+ double microseconds() const
+ {
+ return elapsed<std::chrono::duration<double, std::micro>>().count();
+ }
+
+ std::string toString() const;
+
+ private:
+ std::chrono::high_resolution_clock::time_point m_startTick;
+ };
+}
diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h
index c706c131c..544dffe72 100644
--- a/toolsrc/include/vcpkg_Commands.h
+++ b/toolsrc/include/vcpkg_Commands.h
@@ -2,42 +2,139 @@
#include "vcpkg_cmd_arguments.h"
#include "vcpkg_paths.h"
+#include "StatusParagraphs.h"
+#include <array>
-namespace vcpkg
+namespace vcpkg::Commands
{
- extern const char*const INTEGRATE_COMMAND_HELPSTRING;
+ using command_type_a = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ using command_type_b = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ using command_type_c = void(*)(const vcpkg_cmd_arguments& args);
- void print_usage();
- void print_example(const char* command_and_arguments);
- void update_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ namespace Build
+ {
+ enum class BuildResult
+ {
+ NULLVALUE = 0,
+ SUCCEEDED,
+ BUILD_FAILED,
+ POST_BUILD_CHECKS_FAILED,
+ CASCADED_DUE_TO_MISSING_DEPENDENCIES
+ };
- void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
- void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
- void install_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
- void remove_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ static constexpr std::array<BuildResult, 4> BuildResult_values = { BuildResult::SUCCEEDED, BuildResult::BUILD_FAILED, BuildResult::POST_BUILD_CHECKS_FAILED, BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES };
- void edit_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
- void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ const std::string& to_string(const BuildResult build_result);
+ std::string create_error_message(const BuildResult build_result, const package_spec& spec);
+ std::string create_user_troubleshooting_message(const package_spec& spec);
- void search_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void list_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void owns_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void internal_test_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ BuildResult build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir, const StatusParagraphs& status_db);
+ void perform_and_exit(const package_spec& spec, const fs::path& port_dir, const std::unordered_set<std::string>& options, const vcpkg_paths& paths);
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
- void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ namespace BuildExternal
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
- void integrate_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ namespace Install
+ {
+ void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs* status_db);
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
- void help_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void help_topic_valid_triplet(const vcpkg_paths& paths);
+ namespace CI
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
- void version_command(const vcpkg_cmd_arguments& args);
- void contact_command(const vcpkg_cmd_arguments& args);
+ namespace Remove
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
- using command_type_a = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
- using command_type_b = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- using command_type_c = void(*)(const vcpkg_cmd_arguments& args);
+ namespace Update
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Create
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Edit
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Search
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace List
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Owns
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Cache
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Import
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Integrate
+ {
+ extern const char*const INTEGRATE_COMMAND_HELPSTRING;
+
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace PortsDiff
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Help
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+
+ void help_topic_valid_triplet(const vcpkg_paths& paths);
+
+ void print_usage();
+
+ void print_example(const std::string& command_and_arguments);
+
+ std::string create_example_string(const std::string& command_and_arguments);
+ }
+
+ namespace Version
+ {
+ const std::string& version();
+ void perform_and_exit(const vcpkg_cmd_arguments& args);
+ }
+
+ namespace Contact
+ {
+ const std::string& email();
+ void perform_and_exit(const vcpkg_cmd_arguments& args);
+ }
+
+ namespace Hash
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args);
+ }
template <class T>
struct package_name_and_function
@@ -51,7 +148,7 @@ namespace vcpkg
const std::vector<package_name_and_function<command_type_c>>& get_available_commands_type_c();
template <typename T>
- T find_command(const std::string& command_name, const std::vector<package_name_and_function<T>> available_commands)
+ T find(const std::string& command_name, const std::vector<package_name_and_function<T>> available_commands)
{
for (const package_name_and_function<T>& cmd : available_commands)
{
diff --git a/toolsrc/include/vcpkg_Dependencies.h b/toolsrc/include/vcpkg_Dependencies.h
index 9dc32fc41..dca824ee9 100644
--- a/toolsrc/include/vcpkg_Dependencies.h
+++ b/toolsrc/include/vcpkg_Dependencies.h
@@ -2,12 +2,78 @@
#include <vector>
#include "package_spec.h"
#include "StatusParagraphs.h"
-#include <unordered_set>
#include "vcpkg_paths.h"
+#include "vcpkg_optional.h"
-namespace vcpkg {namespace Dependencies
+namespace vcpkg::Dependencies
{
- std::vector<package_spec> create_dependency_ordered_install_plan(const vcpkg_paths& paths, const std::vector<package_spec>& specs, const StatusParagraphs& status_db);
+ enum class request_type
+ {
+ UNKNOWN,
+ USER_REQUESTED,
+ AUTO_SELECTED
+ };
- std::unordered_set<package_spec> find_unmet_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db);
-}}
+ enum class install_plan_type
+ {
+ UNKNOWN,
+ BUILD_AND_INSTALL,
+ INSTALL,
+ ALREADY_INSTALLED
+ };
+
+ struct install_plan_action
+ {
+ install_plan_action();
+ install_plan_action(const install_plan_type& plan_type, optional<BinaryParagraph> binary_pgh, optional<SourceParagraph> source_pgh);
+ install_plan_action(const install_plan_action&) = delete;
+ install_plan_action(install_plan_action&&) = default;
+ install_plan_action& operator=(const install_plan_action&) = delete;
+ install_plan_action& operator=(install_plan_action&&) = default;
+
+ install_plan_type plan_type;
+ optional<BinaryParagraph> binary_pgh;
+ optional<SourceParagraph> source_pgh;
+ };
+
+ struct package_spec_with_install_plan
+ {
+ package_spec_with_install_plan(const package_spec& spec, install_plan_action&& plan);
+
+ package_spec spec;
+ install_plan_action plan;
+ };
+
+ enum class remove_plan_type
+ {
+ UNKNOWN,
+ NOT_INSTALLED,
+ REMOVE
+ };
+
+ struct remove_plan_action
+ {
+ remove_plan_action();
+ remove_plan_action(const remove_plan_type& plan_type, const request_type& request_type);
+ remove_plan_action(const remove_plan_action&) = delete;
+ remove_plan_action(remove_plan_action&&) = default;
+ remove_plan_action& operator=(const remove_plan_action&) = delete;
+ remove_plan_action& operator=(remove_plan_action&&) = default;
+
+
+ remove_plan_type plan_type;
+ request_type request_type;
+ };
+
+ struct package_spec_with_remove_plan
+ {
+ package_spec_with_remove_plan(const package_spec& spec, remove_plan_action&& plan);
+
+ package_spec spec;
+ remove_plan_action plan;
+ };
+
+ std::vector<package_spec_with_install_plan> create_install_plan(const vcpkg_paths& paths, const std::vector<package_spec>& specs, const StatusParagraphs& status_db);
+
+ std::vector<package_spec_with_remove_plan> create_remove_plan(const std::vector<package_spec>& specs, const StatusParagraphs& status_db);
+}
diff --git a/toolsrc/include/vcpkg_Enums.h b/toolsrc/include/vcpkg_Enums.h
new file mode 100644
index 000000000..5c4dc8b06
--- /dev/null
+++ b/toolsrc/include/vcpkg_Enums.h
@@ -0,0 +1,11 @@
+#pragma once
+#include <string>
+
+namespace vcpkg::Enums
+{
+ std::string nullvalue_toString(const std::string& enum_name);
+
+ __declspec(noreturn) void nullvalue_used(const std::string& enum_name);
+
+ __declspec(noreturn) void unreachable(const std::string& enum_name);
+}
diff --git a/toolsrc/include/vcpkg_Environment.h b/toolsrc/include/vcpkg_Environment.h
index 877ac7deb..5d12c8f6c 100644
--- a/toolsrc/include/vcpkg_Environment.h
+++ b/toolsrc/include/vcpkg_Environment.h
@@ -1,17 +1,19 @@
#pragma once
#include "vcpkg_paths.h"
-namespace vcpkg {namespace Environment
+namespace vcpkg::Environment
{
- void ensure_nuget_on_path(const vcpkg_paths& paths);
+ const fs::path& get_dumpbin_exe(const vcpkg_paths& paths);
- void ensure_git_on_path(const vcpkg_paths& paths);
+ struct vcvarsall_and_platform_toolset
+ {
+ fs::path path;
+ std::wstring platform_toolset;
+ };
- void ensure_cmake_on_path(const vcpkg_paths& paths);
+ const vcvarsall_and_platform_toolset& get_vcvarsall_bat(const vcpkg_paths& paths);
- inline void ensure_utilities_on_path(const vcpkg_paths& paths)
- {
- ensure_cmake_on_path(paths);
- ensure_git_on_path(paths);
- }
-}}
+ const fs::path& get_ProgramFiles_32_bit();
+
+ const fs::path& get_ProgramFiles_platform_bitness();
+}
diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h
index 445713965..3f9570946 100644
--- a/toolsrc/include/vcpkg_Files.h
+++ b/toolsrc/include/vcpkg_Files.h
@@ -1,17 +1,56 @@
#pragma once
#include "expected.h"
-#include <filesystem>
+#include "filesystem_fs.h"
+#include <iterator>
-namespace vcpkg {namespace Files
+namespace vcpkg::Files
{
static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)";
- void check_is_directory(const std::tr2::sys::path& dirpath);
+ void check_is_directory(const fs::path& dirpath);
- bool has_invalid_chars_for_filesystem(const std::string s);
+ bool has_invalid_chars_for_filesystem(const std::string& s);
- expected<std::string> get_contents(const std::tr2::sys::path& file_path) noexcept;
+ expected<std::string> read_contents(const fs::path& file_path) noexcept;
- std::tr2::sys::path find_file_recursively_up(const std::tr2::sys::path& starting_dir, const std::string& filename);
-}}
+ expected<std::vector<std::string>> read_all_lines(const fs::path& file_path);
+
+ void write_all_lines(const fs::path& file_path, const std::vector<std::string>& lines);
+
+ fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename);
+
+ template <class Pred>
+ void non_recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector<fs::path>* output)
+ {
+ std::copy_if(fs::directory_iterator(dir), fs::directory_iterator(), std::back_inserter(*output), predicate);
+ }
+
+ template <class Pred>
+ void recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector<fs::path>* output)
+ {
+ std::copy_if(fs::recursive_directory_iterator(dir), fs::recursive_directory_iterator(), std::back_inserter(*output), predicate);
+ }
+
+ template <class Pred>
+ std::vector<fs::path> recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate)
+ {
+ std::vector<fs::path> v;
+ recursive_find_matching_paths_in_dir(dir, predicate, &v);
+ return v;
+ }
+
+ void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector<fs::path>* output);
+
+ std::vector<fs::path> recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension);
+
+ void recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output);
+
+ std::vector<fs::path> recursive_find_all_files_in_dir(const fs::path& dir);
+
+ void non_recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output);
+
+ std::vector<fs::path> non_recursive_find_all_files_in_dir(const fs::path& dir);
+
+ void print_paths(const std::vector<fs::path>& paths);
+}
diff --git a/toolsrc/include/vcpkg_Graphs.h b/toolsrc/include/vcpkg_Graphs.h
index 81b189f0e..933d9ac67 100644
--- a/toolsrc/include/vcpkg_Graphs.h
+++ b/toolsrc/include/vcpkg_Graphs.h
@@ -1,8 +1,9 @@
#pragma once
#include <unordered_map>
+#include <unordered_set>
-namespace vcpkg { namespace Graphs
+namespace vcpkg::Graphs
{
enum class ExplorationStatus
{
@@ -21,7 +22,7 @@ namespace vcpkg { namespace Graphs
{
static void find_topological_sort_internal(V vertex,
ExplorationStatus& status,
- const std::unordered_map<V, std::vector<V>>& adjacency_list,
+ const std::unordered_map<V, std::unordered_set<V>>& adjacency_list,
std::unordered_map<V, ExplorationStatus>& exploration_status,
std::vector<V>& sorted)
{
@@ -63,7 +64,7 @@ namespace vcpkg { namespace Graphs
void add_edge(V u, V v)
{
this->vertices[v];
- this->vertices[u].push_back(v);
+ this->vertices[u].insert(v);
}
std::vector<V> find_topological_sort() const
@@ -108,12 +109,12 @@ namespace vcpkg { namespace Graphs
return indegrees;
}
- const std::unordered_map<V, std::vector<V>>& adjacency_list() const
+ const std::unordered_map<V, std::unordered_set<V>>& adjacency_list() const
{
return this->vertices;
}
private:
- std::unordered_map<V, std::vector<V>> vertices;
+ std::unordered_map<V, std::unordered_set<V>> vertices;
};
-}}
+}
diff --git a/toolsrc/include/vcpkg_Input.h b/toolsrc/include/vcpkg_Input.h
new file mode 100644
index 000000000..96cbeecc3
--- /dev/null
+++ b/toolsrc/include/vcpkg_Input.h
@@ -0,0 +1,15 @@
+#pragma once
+#include <vector>
+#include "package_spec.h"
+#include "vcpkg_paths.h"
+
+namespace vcpkg::Input
+{
+ package_spec check_and_get_package_spec(const std::string& package_spec_as_string, const triplet& default_target_triplet, const std::string& example_text);
+
+ std::vector<package_spec> check_and_get_package_specs(const std::vector<std::string>& package_specs_as_strings, const triplet& default_target_triplet, const std::string& example_text);
+
+ void check_triplet(const triplet& t, const vcpkg_paths& paths);
+
+ void check_triplets(const std::vector<package_spec>& triplets, const vcpkg_paths& paths);
+}
diff --git a/toolsrc/include/vcpkg_Maps.h b/toolsrc/include/vcpkg_Maps.h
index 5b7b8ed46..5e2f92f55 100644
--- a/toolsrc/include/vcpkg_Maps.h
+++ b/toolsrc/include/vcpkg_Maps.h
@@ -2,8 +2,9 @@
#include <unordered_map>
#include <unordered_set>
+#include <map>
-namespace vcpkg { namespace Maps
+namespace vcpkg::Maps
{
template <typename K, typename V>
std::unordered_set<K> extract_key_set(const std::unordered_map<K, V>& input_map)
@@ -15,4 +16,26 @@ namespace vcpkg { namespace Maps
}
return key_set;
}
-}}
+
+ template <typename K, typename V>
+ std::vector<K> extract_keys(const std::unordered_map<K, V>& input_map)
+ {
+ std::vector<K> key_set;
+ for (auto const& element : input_map)
+ {
+ key_set.push_back(element.first);
+ }
+ return key_set;
+ }
+
+ template <typename K, typename V>
+ std::vector<K> extract_keys(const std::map<K, V>& input_map)
+ {
+ std::vector<K> key_set;
+ for (auto const& element : input_map)
+ {
+ key_set.push_back(element.first);
+ }
+ return key_set;
+ }
+}
diff --git a/toolsrc/include/vcpkg_Sets.h b/toolsrc/include/vcpkg_Sets.h
index 7b330f31c..ec4800864 100644
--- a/toolsrc/include/vcpkg_Sets.h
+++ b/toolsrc/include/vcpkg_Sets.h
@@ -3,15 +3,15 @@
#include "vcpkg_Checks.h"
#include <unordered_set>
-namespace vcpkg { namespace Sets
+namespace vcpkg::Sets
{
template <typename T, typename Container>
void remove_all(std::unordered_set<T>* input_set, Container remove_these)
{
- Checks::check_throw(input_set != nullptr, "Input set cannot be null");
+ Checks::check_exit(input_set != nullptr, "Input set cannot be null");
for (const T& r : remove_these)
{
input_set->erase(r);
}
}
-}}
+}
diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h
index f4b989292..abf3651e5 100644
--- a/toolsrc/include/vcpkg_Strings.h
+++ b/toolsrc/include/vcpkg_Strings.h
@@ -1,8 +1,8 @@
#pragma once
-#include <string>
+#include <vector>
-namespace vcpkg {namespace Strings {namespace details
+namespace vcpkg::Strings::details
{
inline const char* to_printf_arg(const std::string& s)
{
@@ -19,6 +19,21 @@ namespace vcpkg {namespace Strings {namespace details
return s;
}
+ inline long long to_printf_arg(const long long s)
+ {
+ return s;
+ }
+
+ inline double to_printf_arg(const double s)
+ {
+ return s;
+ }
+
+ inline size_t to_printf_arg(const size_t s)
+ {
+ return s;
+ }
+
std::string format_internal(const char* fmtstr, ...);
inline const wchar_t* to_wprintf_arg(const std::wstring& s)
@@ -31,10 +46,10 @@ namespace vcpkg {namespace Strings {namespace details
return s;
}
- std::wstring format_internal(const wchar_t* fmtstr, ...);
-}}}
+ std::wstring wformat_internal(const wchar_t* fmtstr, ...);
+}
-namespace vcpkg {namespace Strings
+namespace vcpkg::Strings
{
template <class...Args>
std::string format(const char* fmtstr, const Args&...args)
@@ -44,15 +59,74 @@ namespace vcpkg {namespace Strings
}
template <class...Args>
- std::wstring format(const wchar_t* fmtstr, const Args&...args)
+ std::wstring wformat(const wchar_t* fmtstr, const Args&...args)
{
using vcpkg::Strings::details::to_wprintf_arg;
- return details::format_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...);
+ return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...);
}
std::wstring utf8_to_utf16(const std::string& s);
std::string utf16_to_utf8(const std::wstring& w);
- std::string::const_iterator case_insensitive_find(const std::string& s, const std::string& pattern);
-}}
+ std::string::const_iterator case_insensitive_ascii_find(const std::string& s, const std::string& pattern);
+
+ std::string ascii_to_lowercase(const std::string& input);
+
+ template <class T, class Transformer>
+ std::string join(const std::string& delimiter, const std::vector<T>& v, Transformer transformer)
+ {
+ if (v.empty())
+ {
+ return std::string();
+ }
+
+ std::string output;
+ size_t size = v.size();
+
+ output.append(transformer(v.at(0)));
+
+ for (size_t i = 1; i < size; ++i)
+ {
+ output.append(delimiter);
+ output.append(transformer(v.at(i)));
+ }
+
+ return output;
+ }
+
+ std::string join(const std::string& delimiter, const std::vector<std::string>& v);
+
+ template <class T, class Transformer>
+ std::wstring wjoin(const std::wstring& delimiter, const std::vector<T>& v, Transformer transformer)
+ {
+ if (v.empty())
+ {
+ return std::wstring();
+ }
+
+ std::wstring output;
+ size_t size = v.size();
+
+ output.append(transformer(v.at(0)));
+
+ for (size_t i = 1; i < size; ++i)
+ {
+ output.append(delimiter);
+ output.append(transformer(v.at(i)));
+ }
+
+ return output;
+ }
+
+ std::wstring wjoin(const std::wstring& delimiter, const std::vector<std::wstring>& v);
+
+
+ void trim(std::string* s);
+
+ std::string trimmed(const std::string& s);
+
+ void trim_all_and_remove_whitespace_strings(std::vector<std::string>* strings);
+
+ std::vector<std::string> split(const std::string& s, const std::string& delimiter);
+}
diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h
index f47fc9aab..71caeed5e 100644
--- a/toolsrc/include/vcpkg_System.h
+++ b/toolsrc/include/vcpkg_System.h
@@ -1,12 +1,15 @@
#pragma once
+#include <Windows.h>
#include "vcpkg_Strings.h"
+#include "filesystem_fs.h"
+#include "vcpkg_optional.h"
-#include <filesystem>
-
-namespace vcpkg {namespace System
+namespace vcpkg::System
{
- std::tr2::sys::path get_exe_path_of_current_process();
+ optional<std::wstring> get_registry_string(HKEY base, const wchar_t* subkey, const wchar_t* valuename);
+
+ fs::path get_exe_path_of_current_process();
struct exit_code_and_output
{
@@ -14,6 +17,13 @@ namespace vcpkg {namespace System
std::string output;
};
+ int cmd_execute_clean(const wchar_t* cmd_line);
+
+ inline int cmd_execute_clean(const std::wstring& cmd_line)
+ {
+ return cmd_execute_clean(cmd_line.c_str());
+ }
+
int cmd_execute(const wchar_t* cmd_line);
inline int cmd_execute(const std::wstring& cmd_line)
@@ -28,6 +38,10 @@ namespace vcpkg {namespace System
return cmd_execute_and_capture_output(cmd_line.c_str());
}
+ std::wstring create_powershell_script_cmd(const fs::path& script_path);
+
+ std::wstring create_powershell_script_cmd(const fs::path& script_path, const std::wstring& args);
+
enum class color
{
success = 10,
@@ -37,8 +51,28 @@ namespace vcpkg {namespace System
void print(const char* message);
void println(const char* message);
- void print(color c, const char* message);
- void println(color c, const char* message);
+ void print(const color c, const char* message);
+ void println(const color c, const char* message);
+
+ inline void print(const std::string& message)
+ {
+ return print(message.c_str());
+ }
+
+ inline void println(const std::string& message)
+ {
+ return println(message.c_str());
+ }
+
+ inline void print(const color c, const std::string& message)
+ {
+ return print(c, message.c_str());
+ }
+
+ inline void println(const color c, const std::string& message)
+ {
+ return println(c, message.c_str());
+ }
template <class...Args>
void print(const char* messageTemplate, const Args&... messageArgs)
@@ -47,7 +81,7 @@ namespace vcpkg {namespace System
}
template <class...Args>
- void print(color c, const char* messageTemplate, const Args&... messageArgs)
+ void print(const color c, const char* messageTemplate, const Args&... messageArgs)
{
return print(c, Strings::format(messageTemplate, messageArgs...).c_str());
}
@@ -59,19 +93,12 @@ namespace vcpkg {namespace System
}
template <class...Args>
- void println(color c, const char* messageTemplate, const Args&... messageArgs)
+ void println(const color c, const char* messageTemplate, const Args&... messageArgs)
{
return println(c, Strings::format(messageTemplate, messageArgs...).c_str());
}
- struct Stopwatch
- {
- int64_t start_time, end_time, freq;
-
- void start();
- void stop();
- double microseconds() const;
- };
+ optional<std::wstring> get_environmental_variable(const wchar_t* varname) noexcept;
- std::wstring wdupenv_str(const wchar_t* varname) noexcept;
-}}
+ void set_environmental_variable(const wchar_t* varname, const wchar_t* varvalue) noexcept;
+}
diff --git a/toolsrc/include/vcpkg_cmd_arguments.h b/toolsrc/include/vcpkg_cmd_arguments.h
index 7df3d64b1..91f7de8ac 100644
--- a/toolsrc/include/vcpkg_cmd_arguments.h
+++ b/toolsrc/include/vcpkg_cmd_arguments.h
@@ -4,30 +4,30 @@
#include <vector>
#include <unordered_set>
#include "opt_bool.h"
-#include "package_spec.h"
-#include "vcpkg_paths.h"
-#include "StatusParagraphs.h"
namespace vcpkg
{
struct vcpkg_cmd_arguments
{
static vcpkg_cmd_arguments create_from_command_line(const int argc, const wchar_t* const* const argv);
-
static vcpkg_cmd_arguments create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end);
std::unique_ptr<std::string> vcpkg_root_dir;
std::unique_ptr<std::string> target_triplet;
- opt_bool debug = opt_bool::unspecified;
- opt_bool sendmetrics = opt_bool::unspecified;
- opt_bool printmetrics = opt_bool::unspecified;
+ opt_bool_t debug = opt_bool_t::UNSPECIFIED;
+ opt_bool_t sendmetrics = opt_bool_t::UNSPECIFIED;
+ opt_bool_t printmetrics = opt_bool_t::UNSPECIFIED;
std::string command;
std::vector<std::string> command_arguments;
std::unordered_set<std::string> check_and_get_optional_command_arguments(const std::vector<std::string>& valid_options) const;
- void check_max_args(size_t arg_count, const char* example_text = nullptr) const;
- std::vector<package_spec> parse_all_arguments_as_package_specs(const triplet& default_target_triplet, const char* example_text = nullptr) const;
+ void check_max_arg_count(const size_t expected_arg_count) const;
+ void check_max_arg_count(const size_t expected_arg_count, const std::string& example_text) const;
+ void check_min_arg_count(const size_t expected_arg_count) const;
+ void check_min_arg_count(const size_t expected_arg_count, const std::string& example_text) const;
+ void check_exact_arg_count(const size_t expected_arg_count) const;
+ void check_exact_arg_count(const size_t expected_arg_count, const std::string& example_text) const;
private:
std::unordered_set<std::string> optional_command_arguments;
diff --git a/toolsrc/include/vcpkg_optional.h b/toolsrc/include/vcpkg_optional.h
new file mode 100644
index 000000000..7b935bea9
--- /dev/null
+++ b/toolsrc/include/vcpkg_optional.h
@@ -0,0 +1,5 @@
+#pragma once
+#include <memory>
+
+template<class T>
+using optional = std::unique_ptr<T>;
diff --git a/toolsrc/include/vcpkg_paths.h b/toolsrc/include/vcpkg_paths.h
index 72cba01b7..99fd14905 100644
--- a/toolsrc/include/vcpkg_paths.h
+++ b/toolsrc/include/vcpkg_paths.h
@@ -1,35 +1,49 @@
#pragma once
-#include <filesystem>
+#include "filesystem_fs.h"
#include "expected.h"
#include "package_spec.h"
+#include "BinaryParagraph.h"
+#include "lazy.h"
namespace vcpkg
{
- namespace fs = std::tr2::sys;
-
struct vcpkg_paths
{
- static expected<vcpkg_paths> create(const std::tr2::sys::path& vcpkg_root_dir);
+ static expected<vcpkg_paths> create(const fs::path& vcpkg_root_dir);
fs::path package_dir(const package_spec& spec) const;
fs::path port_dir(const package_spec& spec) const;
+ fs::path build_info_file_path(const package_spec& spec) const;
+ fs::path listfile_path(const BinaryParagraph& pgh) const;
+
+ bool is_valid_triplet(const triplet& t) const;
+
+ fs::path root;
+ fs::path packages;
+ fs::path buildtrees;
+ fs::path downloads;
+ fs::path ports;
+ fs::path installed;
+ fs::path triplets;
+ fs::path scripts;
+
+ fs::path buildsystems;
+ fs::path buildsystems_msbuild_targets;
- std::tr2::sys::path root;
- std::tr2::sys::path packages;
- std::tr2::sys::path buildtrees;
- std::tr2::sys::path downloads;
- std::tr2::sys::path ports;
- std::tr2::sys::path installed;
- std::tr2::sys::path triplets;
+ fs::path vcpkg_dir;
+ fs::path vcpkg_dir_status_file;
+ fs::path vcpkg_dir_info;
+ fs::path vcpkg_dir_updates;
- std::tr2::sys::path buildsystems;
- std::tr2::sys::path buildsystems_msbuild_targets;
+ fs::path ports_cmake;
- std::tr2::sys::path vcpkg_dir;
- std::tr2::sys::path vcpkg_dir_status_file;
- std::tr2::sys::path vcpkg_dir_info;
- std::tr2::sys::path vcpkg_dir_updates;
+ const fs::path& get_cmake_exe() const;
+ const fs::path& get_git_exe() const;
+ const fs::path& get_nuget_exe() const;
- std::tr2::sys::path ports_cmake;
+ private:
+ lazy<fs::path> cmake_exe;
+ lazy<fs::path> git_exe;
+ lazy<fs::path> nuget_exe;
};
}
diff --git a/toolsrc/include/vcpkglib.h b/toolsrc/include/vcpkglib.h
new file mode 100644
index 000000000..353bfb0a0
--- /dev/null
+++ b/toolsrc/include/vcpkglib.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "StatusParagraphs.h"
+#include "vcpkg_paths.h"
+#include "ImmutableSortedVector.h"
+
+namespace vcpkg
+{
+ StatusParagraphs database_load_check(const vcpkg_paths& paths);
+
+ void write_update(const vcpkg_paths& paths, const StatusParagraph& p);
+
+ struct StatusParagraph_and_associated_files
+ {
+ StatusParagraph pgh;
+ ImmutableSortedVector<std::string> files;
+ };
+
+ std::vector<StatusParagraph_and_associated_files> get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db);
+
+
+ struct CMakeVariable
+ {
+ CMakeVariable(const std::wstring& varname, const wchar_t* varvalue);
+ CMakeVariable(const std::wstring& varname, const std::string& varvalue);
+ CMakeVariable(const std::wstring& varname, const std::wstring& varvalue);
+ CMakeVariable(const std::wstring& varname, const fs::path& path);
+
+ std::wstring s;
+ };
+
+ std::wstring make_cmake_cmd(const fs::path& cmake_exe, const fs::path& cmake_script, const std::vector<CMakeVariable>& pass_variables);
+
+} // namespace vcpkg
diff --git a/toolsrc/include/vcpkglib_helpers.h b/toolsrc/include/vcpkglib_helpers.h
index e15b59b0b..8a08513f3 100644
--- a/toolsrc/include/vcpkglib_helpers.h
+++ b/toolsrc/include/vcpkglib_helpers.h
@@ -2,11 +2,13 @@
#include <unordered_map>
-namespace vcpkg {namespace details
+namespace vcpkg::details
{
- void optional_field(const std::unordered_map<std::string, std::string>& fields, std::string& out, const std::string& fieldname);
+ std::string optional_field(const std::unordered_map<std::string, std::string>& fields, const std::string& fieldname);
+ std::string remove_optional_field(std::unordered_map<std::string, std::string>* fields, const std::string& fieldname);
- void required_field(const std::unordered_map<std::string, std::string>& fields, std::string& out, const std::string& fieldname);
+ std::string required_field(const std::unordered_map<std::string, std::string>& fields, const std::string& fieldname);
+ std::string remove_required_field(std::unordered_map<std::string, std::string>* fields, const std::string& fieldname);
- void parse_depends(const std::string& depends_string, std::vector<std::string>& out);
-}}
+ std::string shorten_description(const std::string& desc);
+}