aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/jsonreader.h3
-rw-r--r--toolsrc/include/vcpkg/portfileprovider.h45
-rw-r--r--toolsrc/include/vcpkg/vcpkgpaths.h27
-rw-r--r--toolsrc/include/vcpkg/versiondeserializers.h37
-rw-r--r--toolsrc/include/vcpkg/versions.h21
5 files changed, 132 insertions, 1 deletions
diff --git a/toolsrc/include/vcpkg/base/jsonreader.h b/toolsrc/include/vcpkg/base/jsonreader.h
index cdd0299d2..02c1936e2 100644
--- a/toolsrc/include/vcpkg/base/jsonreader.h
+++ b/toolsrc/include/vcpkg/base/jsonreader.h
@@ -23,7 +23,7 @@ namespace vcpkg::Json
Optional<Type> visit(Reader&, const Value&);
Optional<Type> visit(Reader&, const Object&);
- protected:
+ public:
virtual Optional<Type> visit_null(Reader&);
virtual Optional<Type> visit_boolean(Reader&, bool);
virtual Optional<Type> visit_integer(Reader& r, int64_t i);
@@ -33,6 +33,7 @@ namespace vcpkg::Json
virtual Optional<Type> visit_object(Reader&, const Object&);
virtual View<StringView> valid_fields() const;
+ protected:
IDeserializer() = default;
IDeserializer(const IDeserializer&) = default;
IDeserializer& operator=(const IDeserializer&) = default;
diff --git a/toolsrc/include/vcpkg/portfileprovider.h b/toolsrc/include/vcpkg/portfileprovider.h
index c127aed40..610ecb735 100644
--- a/toolsrc/include/vcpkg/portfileprovider.h
+++ b/toolsrc/include/vcpkg/portfileprovider.h
@@ -6,6 +6,7 @@
#include <vcpkg/base/util.h>
#include <vcpkg/sourceparagraph.h>
+#include <vcpkg/versions.h>
namespace vcpkg::PortFileProvider
{
@@ -36,4 +37,48 @@ namespace vcpkg::PortFileProvider
std::vector<fs::path> overlay_ports;
mutable std::unordered_map<std::string, SourceControlFileLocation> cache;
};
+
+ struct IVersionedPortfileProvider
+ {
+ virtual const std::vector<vcpkg::Versions::VersionSpec>& get_port_versions(StringView port_name) const = 0;
+
+ virtual ExpectedS<const SourceControlFileLocation&> get_control_file(
+ const vcpkg::Versions::VersionSpec& version_spec) const = 0;
+ };
+
+ struct IBaselineProvider
+ {
+ virtual Optional<VersionT> get_baseline_version(StringView port_name) const = 0;
+ };
+
+ namespace details
+ {
+ struct BaselineProviderImpl;
+ struct VersionedPortfileProviderImpl;
+ }
+
+ struct VersionedPortfileProvider : IVersionedPortfileProvider, Util::ResourceBase
+ {
+ explicit VersionedPortfileProvider(const vcpkg::VcpkgPaths& paths);
+ ~VersionedPortfileProvider();
+
+ const std::vector<vcpkg::Versions::VersionSpec>& get_port_versions(StringView port_name) const override;
+
+ ExpectedS<const SourceControlFileLocation&> get_control_file(
+ const vcpkg::Versions::VersionSpec& version_spec) const override;
+
+ private:
+ std::unique_ptr<details::VersionedPortfileProviderImpl> m_impl;
+ };
+
+ struct BaselineProvider : IBaselineProvider, Util::ResourceBase
+ {
+ explicit BaselineProvider(const vcpkg::VcpkgPaths& paths, const std::string& baseline);
+ ~BaselineProvider();
+
+ Optional<VersionT> get_baseline_version(StringView port_name) const override;
+
+ private:
+ std::unique_ptr<details::BaselineProviderImpl> m_impl;
+ };
}
diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h
index def874e7c..c85eff0ca 100644
--- a/toolsrc/include/vcpkg/vcpkgpaths.h
+++ b/toolsrc/include/vcpkg/vcpkgpaths.h
@@ -102,11 +102,23 @@ namespace vcpkg
fs::path vcpkg_dir_info;
fs::path vcpkg_dir_updates;
+ fs::path baselines_dot_git_dir;
+ fs::path baselines_work_tree;
+ fs::path baselines_output;
+
+ fs::path versions_dot_git_dir;
+ fs::path versions_work_tree;
+ fs::path versions_output;
+
fs::path ports_cmake;
const fs::path& get_tool_exe(const std::string& tool) const;
const std::string& get_tool_version(const std::string& tool) const;
+ // Git manipulation
+ fs::path git_checkout_baseline(Files::Filesystem& filesystem, StringView commit_sha) const;
+ fs::path git_checkout_port(Files::Filesystem& filesystem, StringView port_name, StringView git_tree) const;
+
Optional<const Json::Object&> get_manifest() const;
Optional<const fs::path&> get_manifest_path() const;
const Configuration& get_configuration() const;
@@ -133,5 +145,20 @@ namespace vcpkg
private:
std::unique_ptr<details::VcpkgPathsImpl> m_pimpl;
+
+ static void git_checkout_subpath(const VcpkgPaths& paths,
+ StringView commit_sha,
+ const fs::path& subpath,
+ const fs::path& local_repo,
+ const fs::path& destination,
+ const fs::path& dot_git_dir,
+ const fs::path& work_tree);
+
+ static void git_checkout_object(const VcpkgPaths& paths,
+ StringView git_object,
+ const fs::path& local_repo,
+ const fs::path& destination,
+ const fs::path& dot_git_dir,
+ const fs::path& work_tree);
};
}
diff --git a/toolsrc/include/vcpkg/versiondeserializers.h b/toolsrc/include/vcpkg/versiondeserializers.h
new file mode 100644
index 000000000..f5ffda101
--- /dev/null
+++ b/toolsrc/include/vcpkg/versiondeserializers.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <vcpkg/base/fwd/stringview.h>
+
+#include <vcpkg/base/jsonreader.h>
+#include <vcpkg/base/stringliteral.h>
+
+#include <vcpkg/versions.h>
+#include <vcpkg/versiont.h>
+
+namespace vcpkg
+{
+ struct VersionDbEntry
+ {
+ VersionT version;
+ Versions::Scheme scheme;
+ std::string git_tree;
+
+ VersionDbEntry(const std::string& version_string,
+ int port_version,
+ Versions::Scheme scheme,
+ const std::string& git_tree)
+ : version(VersionT(version_string, port_version)), scheme(scheme), git_tree(git_tree)
+ {
+ }
+ };
+
+ Json::IDeserializer<VersionT>& get_versiont_deserializer_instance();
+
+ ExpectedS<std::map<std::string, VersionT, std::less<>>> parse_baseline_file(Files::Filesystem& fs,
+ StringView baseline_name,
+ const fs::path& baseline_file_path);
+
+ ExpectedS<std::vector<VersionDbEntry>> parse_versions_file(Files::Filesystem& fs,
+ StringView port_name,
+ const fs::path& versions_file_path);
+} \ No newline at end of file
diff --git a/toolsrc/include/vcpkg/versions.h b/toolsrc/include/vcpkg/versions.h
index 55586ddcc..7d5b573c2 100644
--- a/toolsrc/include/vcpkg/versions.h
+++ b/toolsrc/include/vcpkg/versions.h
@@ -1,5 +1,7 @@
#pragma once
+#include <vcpkg/versiont.h>
+
namespace vcpkg::Versions
{
enum class Scheme
@@ -10,6 +12,25 @@ namespace vcpkg::Versions
String
};
+ struct VersionSpec
+ {
+ std::string port_name;
+ VersionT version;
+ Scheme scheme;
+
+ VersionSpec(const std::string& port_name, const VersionT& version, Scheme scheme);
+
+ VersionSpec(const std::string& port_name, const std::string& version_string, int port_version, Scheme scheme);
+
+ friend bool operator==(const VersionSpec& lhs, const VersionSpec& rhs);
+ friend bool operator!=(const VersionSpec& lhs, const VersionSpec& rhs);
+ };
+
+ struct VersionSpecHasher
+ {
+ std::size_t operator()(const VersionSpec& key) const;
+ };
+
struct Constraint
{
enum class Type