2017-01-28 04:49:09 +08:00
|
|
|
#include "pch.h"
|
2016-09-19 11:50:08 +08:00
|
|
|
#include "expected.h"
|
|
|
|
#include "vcpkg_paths.h"
|
|
|
|
#include "metrics.h"
|
|
|
|
#include "vcpkg_System.h"
|
2016-09-24 05:25:17 +08:00
|
|
|
#include "package_spec.h"
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
|
|
|
expected<vcpkg_paths> vcpkg_paths::create(const fs::path& vcpkg_root_dir)
|
|
|
|
{
|
|
|
|
std::error_code ec;
|
|
|
|
const fs::path canonical_vcpkg_root_dir = fs::canonical(vcpkg_root_dir, ec);
|
|
|
|
if (ec)
|
|
|
|
{
|
|
|
|
return ec;
|
|
|
|
}
|
|
|
|
|
|
|
|
vcpkg_paths paths;
|
|
|
|
paths.root = canonical_vcpkg_root_dir;
|
|
|
|
|
|
|
|
if (paths.root.empty())
|
|
|
|
{
|
|
|
|
System::println(System::color::error, "Invalid vcpkg root directory: %s", paths.root.string());
|
|
|
|
TrackProperty("error", "Invalid vcpkg root directory");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
paths.packages = paths.root / "packages";
|
|
|
|
paths.buildtrees = paths.root / "buildtrees";
|
|
|
|
paths.downloads = paths.root / "downloads";
|
|
|
|
paths.ports = paths.root / "ports";
|
|
|
|
paths.installed = paths.root / "installed";
|
|
|
|
paths.triplets = paths.root / "triplets";
|
2017-01-24 07:12:43 +08:00
|
|
|
paths.scripts = paths.root / "scripts";
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-01-24 07:12:43 +08:00
|
|
|
paths.buildsystems = paths.scripts / "buildsystems";
|
2016-09-19 11:50:08 +08:00
|
|
|
paths.buildsystems_msbuild_targets = paths.buildsystems / "msbuild" / "vcpkg.targets";
|
|
|
|
|
|
|
|
paths.vcpkg_dir = paths.installed / "vcpkg";
|
|
|
|
paths.vcpkg_dir_status_file = paths.vcpkg_dir / "status";
|
|
|
|
paths.vcpkg_dir_info = paths.vcpkg_dir / "info";
|
|
|
|
paths.vcpkg_dir_updates = paths.vcpkg_dir / "updates";
|
|
|
|
|
2017-01-24 07:12:43 +08:00
|
|
|
paths.ports_cmake = paths.scripts / "ports.cmake";
|
2016-09-19 11:50:08 +08:00
|
|
|
return paths;
|
|
|
|
}
|
2016-09-24 05:25:17 +08:00
|
|
|
|
2016-09-24 05:32:56 +08:00
|
|
|
fs::path vcpkg_paths::package_dir(const package_spec& spec) const
|
2016-09-24 05:25:17 +08:00
|
|
|
{
|
2016-09-24 05:32:56 +08:00
|
|
|
return this->packages / spec.dir();
|
2016-09-24 05:25:17 +08:00
|
|
|
}
|
|
|
|
|
2016-09-24 05:32:56 +08:00
|
|
|
fs::path vcpkg_paths::port_dir(const package_spec& spec) const
|
2016-09-24 05:25:17 +08:00
|
|
|
{
|
2016-10-04 08:45:01 +08:00
|
|
|
return this->ports / spec.name();
|
2016-09-24 05:25:17 +08:00
|
|
|
}
|
2016-09-29 03:39:05 +08:00
|
|
|
|
2016-11-09 06:12:49 +08:00
|
|
|
fs::path vcpkg_paths::build_info_file_path(const package_spec& spec) const
|
|
|
|
{
|
|
|
|
return this->package_dir(spec) / "BUILD_INFO";
|
|
|
|
}
|
|
|
|
|
2016-11-08 09:54:23 +08:00
|
|
|
fs::path vcpkg_paths::listfile_path(const BinaryParagraph& pgh) const
|
|
|
|
{
|
|
|
|
return this->vcpkg_dir_info / (pgh.fullstem() + ".list");
|
|
|
|
}
|
|
|
|
|
2016-09-30 03:35:27 +08:00
|
|
|
bool vcpkg_paths::is_valid_triplet(const triplet& t) const
|
2016-09-29 03:39:05 +08:00
|
|
|
{
|
|
|
|
auto it = fs::directory_iterator(this->triplets);
|
|
|
|
for (; it != fs::directory_iterator(); ++it)
|
|
|
|
{
|
|
|
|
std::string triplet_file_name = it->path().stem().generic_u8string();
|
2016-10-04 08:20:52 +08:00
|
|
|
if (t.canonical_name() == triplet_file_name) // TODO: fuzzy compare
|
2016-09-29 03:39:05 +08:00
|
|
|
{
|
|
|
|
//t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|