aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorThomas Fussell <thomas.fussell@gmail.com>2017-03-12 17:44:06 -0400
committerThomas Fussell <thomas.fussell@gmail.com>2017-03-12 17:44:06 -0400
commit2f42035ab43dd50cd863b51944aa099a99ae60f0 (patch)
tree4b6cfd43955e946721c58028fd8564c861d5c331 /toolsrc/include
parente02e85626f3206feda86a6f5757009005e0cfe3e (diff)
parent1c9873a0daf625f67474aaf3e163c592c27ecb65 (diff)
downloadvcpkg-2f42035ab43dd50cd863b51944aa099a99ae60f0.tar.gz
vcpkg-2f42035ab43dd50cd863b51944aa099a99ae60f0.zip
Merge branch 'master' of git://github.com/Microsoft/vcpkg
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/BuildInfo.h129
-rw-r--r--toolsrc/include/ImmutableSortedVector.h48
-rw-r--r--toolsrc/include/Paragraphs.h17
-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/StatusParagraphs.h11
-rw-r--r--toolsrc/include/Stopwatch.h40
-rw-r--r--toolsrc/include/coff_file_reader.h4
-rw-r--r--toolsrc/include/lazy.h26
-rw-r--r--toolsrc/include/opt_bool.h32
-rw-r--r--toolsrc/include/package_spec.h7
-rw-r--r--toolsrc/include/pch.h43
-rw-r--r--toolsrc/include/post_build_lint.h8
-rw-r--r--toolsrc/include/vcpkg.h30
-rw-r--r--toolsrc/include/vcpkg_Checks.h6
-rw-r--r--toolsrc/include/vcpkg_Chrono.h31
-rw-r--r--toolsrc/include/vcpkg_Commands.h151
-rw-r--r--toolsrc/include/vcpkg_Dependencies.h59
-rw-r--r--toolsrc/include/vcpkg_Enums.h11
-rw-r--r--toolsrc/include/vcpkg_Environment.h22
-rw-r--r--toolsrc/include/vcpkg_Files.h4
-rw-r--r--toolsrc/include/vcpkg_Graphs.h4
-rw-r--r--toolsrc/include/vcpkg_Input.h6
-rw-r--r--toolsrc/include/vcpkg_Maps.h4
-rw-r--r--toolsrc/include/vcpkg_Sets.h6
-rw-r--r--toolsrc/include/vcpkg_Strings.h64
-rw-r--r--toolsrc/include/vcpkg_System.h30
-rw-r--r--toolsrc/include/vcpkg_cmd_arguments.h7
-rw-r--r--toolsrc/include/vcpkg_info.h10
-rw-r--r--toolsrc/include/vcpkg_optional.h5
-rw-r--r--toolsrc/include/vcpkg_paths.h11
-rw-r--r--toolsrc/include/vcpkglib.h34
-rw-r--r--toolsrc/include/vcpkglib_helpers.h4
37 files changed, 730 insertions, 315 deletions
diff --git a/toolsrc/include/BuildInfo.h b/toolsrc/include/BuildInfo.h
deleted file mode 100644
index 49811d521..000000000
--- a/toolsrc/include/BuildInfo.h
+++ /dev/null
@@ -1,129 +0,0 @@
-#pragma once
-
-#include <unordered_map>
-#include "Paragraphs.h"
-#include <regex>
-
-namespace vcpkg { namespace PostBuildLint
-{
- enum class LinkageType
- {
- DYNAMIC,
- STATIC,
- UNKNOWN
- };
-
- LinkageType linkage_type_value_of(const std::string& as_string);
-
- std::string to_string(const LinkageType& build_info);
-
- enum class ConfigurationType
- {
- DEBUG = 1,
- RELEASE = 2
- };
-
- std::string to_string(const ConfigurationType& conf);
-
- struct BuildType
- {
- static BuildType value_of(const ConfigurationType& config, const LinkageType& linkage);
-
- static const BuildType DEBUG_STATIC;
- static const BuildType DEBUG_DYNAMIC;
- static const BuildType RELEASE_STATIC;
- static const BuildType RELEASE_DYNAMIC;
-
- static const std::vector<BuildType>& values()
- {
- static const std::vector<BuildType> v = {DEBUG_STATIC, DEBUG_DYNAMIC, RELEASE_STATIC, RELEASE_DYNAMIC};
- return v;
- }
-
- BuildType() = delete;
-
- const ConfigurationType& config() const;
- const LinkageType& linkage() const;
- std::regex crt_regex() const;
- std::string toString() const;
-
- private:
- BuildType(const ConfigurationType& config, const LinkageType& linkage, const std::string& crt_regex_as_string)
- : m_config(config), m_linkage(linkage), m_crt_regex_as_string(crt_regex_as_string)
- {
- }
-
- ConfigurationType m_config;
- LinkageType m_linkage;
- std::string m_crt_regex_as_string;
- };
-
- bool operator ==(const BuildType& lhs, const BuildType& rhs);
-
- bool operator !=(const BuildType& lhs, const BuildType& rhs);
-
- struct OutdatedDynamicCrt
- {
- // Old CPP
- static const OutdatedDynamicCrt MSVCP100_DLL;
- static const OutdatedDynamicCrt MSVCP100D_DLL;
- static const OutdatedDynamicCrt MSVCP110_DLL;
- static const OutdatedDynamicCrt MSVCP110_WIN_DLL;
- static const OutdatedDynamicCrt MSVCP120_DLL;
- static const OutdatedDynamicCrt MSVCP120_CLR0400_DLL;
- static const OutdatedDynamicCrt MSVCP60_DLL;
- static const OutdatedDynamicCrt MSVCP_WIN_DLL;
-
- // Old C
- static const OutdatedDynamicCrt MSVCR100_DLL;
- static const OutdatedDynamicCrt MSVCR100D_DLL;
- static const OutdatedDynamicCrt MSVCR100_CLR0400_DLL;
- static const OutdatedDynamicCrt MSVCR110_DLL;
- static const OutdatedDynamicCrt MSVCR120_DLL;
- static const OutdatedDynamicCrt MSVCR120_CLR0400_DLL;
- static const OutdatedDynamicCrt MSVCRT_DLL;
- static const OutdatedDynamicCrt MSVCRT20_DLL;
- static const OutdatedDynamicCrt MSVCRT40_DLL;
-
- static const std::vector<OutdatedDynamicCrt>& values()
- {
- static const std::vector<OutdatedDynamicCrt> v = {
- MSVCP100_DLL, MSVCP100D_DLL,
- MSVCP110_DLL,MSVCP110_WIN_DLL,
- MSVCP120_DLL, MSVCP120_CLR0400_DLL,
- MSVCP60_DLL,
- MSVCP_WIN_DLL,
-
- MSVCR100_DLL, MSVCR100D_DLL, MSVCR100_CLR0400_DLL,
- MSVCR110_DLL,
- MSVCR120_DLL, MSVCR120_CLR0400_DLL,
- MSVCRT_DLL, MSVCRT20_DLL,MSVCRT40_DLL
- };
- return v;
- }
-
- OutdatedDynamicCrt() = delete;
-
- std::regex crt_regex() const;
- const std::string& toString() const;
-
- private:
- explicit OutdatedDynamicCrt(const std::string& dll_name, const std::string& crt_regex_as_string)
- : m_dll_name(dll_name), m_crt_regex_as_string(crt_regex_as_string)
- {
- }
-
- std::string m_dll_name;
- std::string m_crt_regex_as_string;
- };
-
- struct BuildInfo
- {
- static BuildInfo create(const std::unordered_map<std::string, std::string>& pgh);
-
- std::string crt_linkage;
- std::string library_linkage;
- };
-
- BuildInfo read_build_info(const fs::path& filepath);
-}}
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/Paragraphs.h b/toolsrc/include/Paragraphs.h
index 9e9fafe49..79b66a67f 100644
--- a/toolsrc/include/Paragraphs.h
+++ b/toolsrc/include/Paragraphs.h
@@ -1,10 +1,21 @@
#pragma once
#include "filesystem_fs.h"
-#include <unordered_map>
+#include <map>
+#include "expected.h"
+#include "BinaryParagraph.h"
+#include "vcpkg_paths.h"
-namespace vcpkg { namespace Paragraphs
+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/StatusParagraphs.h b/toolsrc/include/StatusParagraphs.h
index 7a0f2177d..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
{
@@ -19,28 +20,28 @@ namespace vcpkg
}
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/Stopwatch.h b/toolsrc/include/Stopwatch.h
deleted file mode 100644
index 105a4b1ee..000000000
--- a/toolsrc/include/Stopwatch.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#pragma once
-
-#include <chrono>
-#include <string>
-
-namespace vcpkg
-{
- class Stopwatch
- {
- public:
- static Stopwatch createUnstarted();
-
- static Stopwatch createStarted();
-
- bool isRunning() const;
-
- const Stopwatch& start();
-
- const Stopwatch& stop();
-
- Stopwatch& reset();
-
- template <class TimeUnit>
- TimeUnit elapsed() const
- {
- return std::chrono::duration_cast<TimeUnit>(elapsedNanos());
- }
-
- std::string toString() const;
-
- private:
- Stopwatch();
-
- std::chrono::nanoseconds elapsedNanos() const;
-
- bool m_isRunning;
- std::chrono::nanoseconds m_elapsedNanos;
- std::chrono::steady_clock::time_point m_startTick;
- };
-}
diff --git a/toolsrc/include/coff_file_reader.h b/toolsrc/include/coff_file_reader.h
index edf6910a5..24fbf4576 100644
--- a/toolsrc/include/coff_file_reader.h
+++ b/toolsrc/include/coff_file_reader.h
@@ -3,7 +3,7 @@
#include "MachineType.h"
#include "filesystem_fs.h"
-namespace vcpkg {namespace COFFFileReader
+namespace vcpkg::COFFFileReader
{
struct dll_info
{
@@ -18,4 +18,4 @@ namespace vcpkg {namespace COFFFileReader
dll_info read_dll(const fs::path& path);
lib_info read_lib(const fs::path& path);
-}}
+}
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/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 30dfca5c7..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"
@@ -16,15 +15,17 @@ namespace vcpkg
const triplet& target_triplet() const;
+ std::string display_name() const;
+
std::string dir() const;
+ std::string toString() const;
+
private:
std::string m_name;
triplet m_target_triplet;
};
- std::string to_string(const package_spec& spec);
-
std::string to_printf_arg(const package_spec& spec);
bool operator==(const package_spec& left, const package_spec& right);
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 a5fb9149f..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 {namespace PostBuildLint
-{
- void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths);
-}}
diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h
deleted file mode 100644
index 75dc40b43..000000000
--- a/toolsrc/include/vcpkg.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-#include "package_spec.h"
-#include "BinaryParagraph.h"
-#include "StatusParagraphs.h"
-#include "vcpkg_paths.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;
- std::vector<std::string> files;
- };
-
- std::vector<StatusParagraph_and_associated_files> get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db);
-
- expected<SourceParagraph> try_load_port(const fs::path& control_path);
-
- inline expected<SourceParagraph> try_load_port(const vcpkg_paths& paths, const std::string& name)
- {
- return try_load_port(paths.ports / name);
- }
-
- expected<BinaryParagraph> try_load_cached_package(const vcpkg_paths& paths, const package_spec& spec);
-} // namespace vcpkg
diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h
index 9d9b21ed6..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();
@@ -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 fd427fd40..544dffe72 100644
--- a/toolsrc/include/vcpkg_Commands.h
+++ b/toolsrc/include/vcpkg_Commands.h
@@ -2,46 +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 std::string& command_and_arguments);
- std::string create_example_string(const std::string& 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
+ };
+
+ static constexpr std::array<BuildResult, 4> BuildResult_values = { BuildResult::SUCCEEDED, BuildResult::BUILD_FAILED, BuildResult::POST_BUILD_CHECKS_FAILED, BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES };
+
+ 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);
+
+ 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 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);
+ namespace BuildExternal
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
- void edit_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void create_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 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);
+ namespace CI
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
+
+ namespace Remove
+ {
+ 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 Update
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
- void integrate_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ namespace Create
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
- void portsdiff_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ namespace Edit
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
- void help_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void help_topic_valid_triplet(const vcpkg_paths& paths);
+ namespace Search
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
- void version_command(const vcpkg_cmd_arguments& args);
- void contact_command(const vcpkg_cmd_arguments& args);
- void hash_command(const vcpkg_cmd_arguments& args);
+ namespace List
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
- 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 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
@@ -55,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 3616e6be9..dca824ee9 100644
--- a/toolsrc/include/vcpkg_Dependencies.h
+++ b/toolsrc/include/vcpkg_Dependencies.h
@@ -3,11 +3,20 @@
#include "package_spec.h"
#include "StatusParagraphs.h"
#include "vcpkg_paths.h"
+#include "vcpkg_optional.h"
-namespace vcpkg {namespace Dependencies
+namespace vcpkg::Dependencies
{
+ enum class request_type
+ {
+ UNKNOWN,
+ USER_REQUESTED,
+ AUTO_SELECTED
+ };
+
enum class install_plan_type
{
+ UNKNOWN,
BUILD_AND_INSTALL,
INSTALL,
ALREADY_INSTALLED
@@ -15,16 +24,56 @@ namespace vcpkg {namespace Dependencies
struct install_plan_action
{
- install_plan_type type;
- std::unique_ptr<BinaryParagraph> bpgh;
- std::unique_ptr<SourceParagraph> spgh;
+ 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 6c9d0d365..3f9570946 100644
--- a/toolsrc/include/vcpkg_Files.h
+++ b/toolsrc/include/vcpkg_Files.h
@@ -4,7 +4,7 @@
#include "filesystem_fs.h"
#include <iterator>
-namespace vcpkg {namespace Files
+namespace vcpkg::Files
{
static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)";
@@ -53,4 +53,4 @@ namespace vcpkg {namespace Files
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 9444ac45b..933d9ac67 100644
--- a/toolsrc/include/vcpkg_Graphs.h
+++ b/toolsrc/include/vcpkg_Graphs.h
@@ -3,7 +3,7 @@
#include <unordered_map>
#include <unordered_set>
-namespace vcpkg { namespace Graphs
+namespace vcpkg::Graphs
{
enum class ExplorationStatus
{
@@ -117,4 +117,4 @@ namespace vcpkg { namespace Graphs
private:
std::unordered_map<V, std::unordered_set<V>> vertices;
};
-}}
+}
diff --git a/toolsrc/include/vcpkg_Input.h b/toolsrc/include/vcpkg_Input.h
index 5ce90e3b9..96cbeecc3 100644
--- a/toolsrc/include/vcpkg_Input.h
+++ b/toolsrc/include/vcpkg_Input.h
@@ -3,7 +3,7 @@
#include "package_spec.h"
#include "vcpkg_paths.h"
-namespace vcpkg {namespace Input
+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);
@@ -11,5 +11,5 @@ namespace vcpkg {namespace Input
void check_triplet(const triplet& t, const vcpkg_paths& paths);
- void check_triplets(std::vector<package_spec> triplets, 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 c67462a39..5e2f92f55 100644
--- a/toolsrc/include/vcpkg_Maps.h
+++ b/toolsrc/include/vcpkg_Maps.h
@@ -4,7 +4,7 @@
#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)
@@ -38,4 +38,4 @@ namespace vcpkg { namespace Maps
}
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 a117a1a81..abf3651e5 100644
--- a/toolsrc/include/vcpkg_Strings.h
+++ b/toolsrc/include/vcpkg_Strings.h
@@ -2,7 +2,7 @@
#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,11 @@ 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;
@@ -42,9 +47,9 @@ namespace vcpkg {namespace Strings {namespace details
}
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)
@@ -68,11 +73,60 @@ namespace vcpkg {namespace Strings
std::string ascii_to_lowercase(const std::string& input);
- std::string join(const std::vector<std::string>& v, const std::string& delimiter);
+ 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 1101c9b27..71caeed5e 100644
--- a/toolsrc/include/vcpkg_System.h
+++ b/toolsrc/include/vcpkg_System.h
@@ -1,10 +1,14 @@
#pragma once
+#include <Windows.h>
#include "vcpkg_Strings.h"
#include "filesystem_fs.h"
+#include "vcpkg_optional.h"
-namespace vcpkg {namespace System
+namespace vcpkg::System
{
+ 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
@@ -13,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)
@@ -27,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,
@@ -83,14 +98,7 @@ namespace vcpkg {namespace System
return println(c, Strings::format(messageTemplate, messageArgs...).c_str());
}
- struct Stopwatch2
- {
- 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 2194e6d2c..91f7de8ac 100644
--- a/toolsrc/include/vcpkg_cmd_arguments.h
+++ b/toolsrc/include/vcpkg_cmd_arguments.h
@@ -4,7 +4,6 @@
#include <vector>
#include <unordered_set>
#include "opt_bool.h"
-#include "vcpkg_paths.h"
namespace vcpkg
{
@@ -15,9 +14,9 @@ namespace vcpkg
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;
diff --git a/toolsrc/include/vcpkg_info.h b/toolsrc/include/vcpkg_info.h
deleted file mode 100644
index 01da06307..000000000
--- a/toolsrc/include/vcpkg_info.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-
-#include <string>
-
-namespace vcpkg { namespace Info
-{
- const std::string& version();
-
- const std::string& email();
-}}
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 a2932070d..99fd14905 100644
--- a/toolsrc/include/vcpkg_paths.h
+++ b/toolsrc/include/vcpkg_paths.h
@@ -3,6 +3,7 @@
#include "expected.h"
#include "package_spec.h"
#include "BinaryParagraph.h"
+#include "lazy.h"
namespace vcpkg
{
@@ -24,6 +25,7 @@ namespace vcpkg
fs::path ports;
fs::path installed;
fs::path triplets;
+ fs::path scripts;
fs::path buildsystems;
fs::path buildsystems_msbuild_targets;
@@ -34,5 +36,14 @@ namespace vcpkg
fs::path vcpkg_dir_updates;
fs::path ports_cmake;
+
+ const fs::path& get_cmake_exe() const;
+ const fs::path& get_git_exe() const;
+ const fs::path& get_nuget_exe() const;
+
+ 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 019bb8c39..8a08513f3 100644
--- a/toolsrc/include/vcpkglib_helpers.h
+++ b/toolsrc/include/vcpkglib_helpers.h
@@ -2,7 +2,7 @@
#include <unordered_map>
-namespace vcpkg {namespace details
+namespace vcpkg::details
{
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);
@@ -11,4 +11,4 @@ namespace vcpkg {namespace details
std::string remove_required_field(std::unordered_map<std::string, std::string>* fields, const std::string& fieldname);
std::string shorten_description(const std::string& desc);
-}}
+}