[vcpkg] Move find_available_package, find_available_port_file into vcpkg_paths.
`vcpkg_paths` is responsible for binding the concrete filesystem representation to the abstract `package_spec`.
This commit is contained in:
Родитель
e31eed92ce
Коммит
2f2f7dca3d
|
@ -18,10 +18,6 @@ namespace vcpkg
|
|||
std::vector<std::unordered_map<std::string, std::string>> parse_paragraphs(const std::string& str);
|
||||
std::string shorten_description(const std::string& desc);
|
||||
|
||||
fs::path find_available_package(const vcpkg_paths& paths, const package_spec& spec);
|
||||
fs::path find_available_port_file(const vcpkg_paths& paths, const package_spec& spec);
|
||||
fs::path control_file_for_package(const fs::path& package_path);
|
||||
|
||||
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);
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
#pragma once
|
||||
#include <filesystem>
|
||||
#include "expected.h"
|
||||
#include "package_spec.h"
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
namespace fs = std::tr2::sys;
|
||||
|
||||
struct vcpkg_paths
|
||||
{
|
||||
static expected<vcpkg_paths> create(const std::tr2::sys::path& vcpkg_root_dir);
|
||||
|
||||
fs::path find_available_package(const package_spec& spec) const;
|
||||
fs::path find_available_port_file(const package_spec& spec) const;
|
||||
|
||||
std::tr2::sys::path root;
|
||||
std::tr2::sys::path packages;
|
||||
std::tr2::sys::path buildtrees;
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace vcpkg
|
|||
continue;
|
||||
}
|
||||
|
||||
fs::path package_path = find_available_package(paths, spec);
|
||||
fs::path package_path = paths.find_available_package(spec);
|
||||
|
||||
expected<std::string> file_contents = Files::get_contents(package_path / "CONTROL");
|
||||
|
||||
|
|
21
src/lib.cpp
21
src/lib.cpp
|
@ -133,24 +133,9 @@ static std::string get_fullpkgname_from_listfile(const fs::path& path)
|
|||
return ret;
|
||||
}
|
||||
|
||||
fs::path vcpkg::control_file_for_package(const fs::path& package)
|
||||
{
|
||||
return package / "CONTROL";
|
||||
}
|
||||
|
||||
fs::path vcpkg::find_available_package(const vcpkg_paths& paths, const package_spec& spec)
|
||||
{
|
||||
return paths.packages / Strings::format("%s_%s", spec.name, spec.target_triplet);
|
||||
}
|
||||
|
||||
fs::path vcpkg::find_available_port_file(const vcpkg_paths& paths, const package_spec& spec)
|
||||
{
|
||||
return paths.ports / spec.name;
|
||||
}
|
||||
|
||||
static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh)
|
||||
{
|
||||
return find_available_package(paths, {pgh.name, pgh.target_triplet});
|
||||
return paths.find_available_package({pgh.name, pgh.target_triplet});
|
||||
}
|
||||
|
||||
static void write_update(const vcpkg_paths& paths, const StatusParagraph& p)
|
||||
|
@ -228,7 +213,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar
|
|||
std::vector<std::string> vcpkg::get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db)
|
||||
{
|
||||
std::vector<std::unordered_map<std::string, std::string>> pghs;
|
||||
const fs::path packages_dir_control_file_path = find_available_package(paths, spec) / "CONTROL";
|
||||
const fs::path packages_dir_control_file_path = paths.find_available_package(spec) / "CONTROL";
|
||||
|
||||
if (fs::exists(packages_dir_control_file_path))
|
||||
{
|
||||
|
@ -245,7 +230,7 @@ std::vector<std::string> vcpkg::get_unmet_package_dependencies(const vcpkg_paths
|
|||
return BinaryParagraph(pghs[0]).depends;
|
||||
}
|
||||
|
||||
const fs::path ports_dir_control_file_path = find_available_port_file(paths, spec) / "CONTROL";
|
||||
const fs::path ports_dir_control_file_path = paths.find_available_port_file(spec) / "CONTROL";
|
||||
try
|
||||
{
|
||||
pghs = get_paragraphs(ports_dir_control_file_path);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "vcpkg_paths.h"
|
||||
#include "metrics.h"
|
||||
#include "vcpkg_System.h"
|
||||
#include "package_spec.h"
|
||||
|
||||
namespace fs = std::tr2::sys;
|
||||
|
||||
|
@ -45,4 +46,14 @@ namespace vcpkg
|
|||
paths.ports_cmake = paths.root / "scripts" / "ports.cmake";
|
||||
return paths;
|
||||
}
|
||||
|
||||
fs::path vcpkg_paths::find_available_package(const package_spec& spec) const
|
||||
{
|
||||
return this->packages / Strings::format("%s_%s", spec.name, spec.target_triplet);
|
||||
}
|
||||
|
||||
fs::path vcpkg_paths::find_available_port_file(const package_spec& spec) const
|
||||
{
|
||||
return this->ports / spec.name;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче