Ensure spdx_location is not dropped when loading ports. (#1237)
This commit is contained in:
Родитель
dfb60db5b9
Коммит
365d419c00
|
@ -3,6 +3,13 @@
|
|||
namespace vcpkg
|
||||
{
|
||||
struct ManifestAndPath;
|
||||
struct DependencyConstraint;
|
||||
struct DependencyRequestedFeature;
|
||||
struct Dependency;
|
||||
struct DependencyOverride;
|
||||
struct FeatureParagraph;
|
||||
struct SourceParagraph;
|
||||
struct PortLocation;
|
||||
struct SourceControlFile;
|
||||
struct SourceControlFileAndLocation;
|
||||
}
|
|
@ -27,22 +27,19 @@ namespace vcpkg::Paragraphs
|
|||
bool is_port_directory(const ReadOnlyFilesystem& fs, const Path& maybe_directory);
|
||||
|
||||
// If an error occurs, the Expected will be in the error state.
|
||||
// Otherwise, if the port is known, the unique_ptr contains the loaded port information.
|
||||
// Otherwise, the unique_ptr is nullptr.
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_port(const ReadOnlyFilesystem& fs,
|
||||
StringView port_name,
|
||||
const Path& port_directory);
|
||||
// Otherwise, if the port is known, result->source_control_file contains the loaded port information.
|
||||
// Otherwise, result->source_control_file is nullptr.
|
||||
ExpectedL<SourceControlFileAndLocation> try_load_port(const ReadOnlyFilesystem& fs,
|
||||
StringView port_name,
|
||||
const PortLocation& port_location);
|
||||
// Identical to try_load_port, but the port unknown condition is mapped to an error.
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_port_required(const ReadOnlyFilesystem& fs,
|
||||
StringView port_name,
|
||||
const Path& port_directory);
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_project_manifest_text(StringView text,
|
||||
StringView origin,
|
||||
MessageSink& warning_sink);
|
||||
ExpectedL<SourceControlFileAndLocation> try_load_port_required(const ReadOnlyFilesystem& fs,
|
||||
StringView port_name,
|
||||
const PortLocation& port_location);
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_port_manifest_text(StringView text,
|
||||
StringView origin,
|
||||
StringView control_path,
|
||||
MessageSink& warning_sink);
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_control_file_text(StringView text, StringView origin);
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_control_file_text(StringView text, StringView control_path);
|
||||
|
||||
ExpectedL<BinaryControlFile> try_load_cached_package(const ReadOnlyFilesystem& fs,
|
||||
const Path& package_dir,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <vcpkg/fwd/configuration.h>
|
||||
#include <vcpkg/fwd/registries.h>
|
||||
#include <vcpkg/fwd/sourceparagraph.h>
|
||||
#include <vcpkg/fwd/vcpkgpaths.h>
|
||||
|
||||
#include <vcpkg/base/path.h>
|
||||
|
@ -53,20 +54,11 @@ namespace vcpkg
|
|||
bool modified = false;
|
||||
};
|
||||
|
||||
struct PathAndLocation
|
||||
{
|
||||
Path path;
|
||||
|
||||
/// Should model SPDX PackageDownloadLocation. Empty implies NOASSERTION.
|
||||
/// See https://spdx.github.io/spdx-spec/package-information/#77-package-download-location-field
|
||||
std::string location;
|
||||
};
|
||||
|
||||
struct RegistryEntry
|
||||
{
|
||||
virtual ExpectedL<View<Version>> get_port_versions() const = 0;
|
||||
|
||||
virtual ExpectedL<PathAndLocation> get_version(const Version& version) const = 0;
|
||||
virtual ExpectedL<PortLocation> get_version(const Version& version) const = 0;
|
||||
|
||||
virtual ~RegistryEntry() = default;
|
||||
};
|
||||
|
|
|
@ -138,6 +138,15 @@ namespace vcpkg
|
|||
friend bool operator!=(const SourceParagraph& lhs, const SourceParagraph& rhs) { return !(lhs == rhs); }
|
||||
};
|
||||
|
||||
struct PortLocation
|
||||
{
|
||||
Path port_directory;
|
||||
|
||||
/// Should model SPDX PackageDownloadLocation. Empty implies NOASSERTION.
|
||||
/// See https://spdx.github.io/spdx-spec/package-information/#77-package-download-location-field
|
||||
std::string spdx_location;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Full metadata of a package: core and other features.
|
||||
/// </summary>
|
||||
|
@ -168,7 +177,9 @@ namespace vcpkg
|
|||
const FeatureFlagSettings& flags,
|
||||
bool is_default_builtin_registry = true) const;
|
||||
|
||||
const Version& to_version() const { return core_paragraph->version; }
|
||||
const std::string& to_name() const noexcept { return core_paragraph->name; }
|
||||
VersionScheme to_version_scheme() const noexcept { return core_paragraph->version_scheme; }
|
||||
const Version& to_version() const noexcept { return core_paragraph->version; }
|
||||
SchemedVersion to_schemed_version() const
|
||||
{
|
||||
return SchemedVersion{core_paragraph->version_scheme, core_paragraph->version};
|
||||
|
@ -190,15 +201,19 @@ namespace vcpkg
|
|||
/// </summary>
|
||||
struct SourceControlFileAndLocation
|
||||
{
|
||||
const std::string& to_name() const noexcept { return source_control_file->to_name(); }
|
||||
const Version& to_version() const { return source_control_file->to_version(); }
|
||||
VersionScheme scheme() const { return source_control_file->core_paragraph->version_scheme; }
|
||||
SchemedVersion schemed_version() const { return {scheme(), to_version()}; }
|
||||
VersionSpec to_version_spec() const { return source_control_file->to_version_spec(); }
|
||||
Path port_directory() const { return control_path.parent_path(); }
|
||||
|
||||
std::unique_ptr<SourceControlFile> source_control_file;
|
||||
Path source_location;
|
||||
Path control_path;
|
||||
|
||||
/// Should model SPDX PackageDownloadLocation. Empty implies NOASSERTION.
|
||||
/// See https://spdx.github.io/spdx-spec/package-information/#77-package-download-location-field
|
||||
std::string registry_location;
|
||||
std::string spdx_location;
|
||||
};
|
||||
|
||||
void print_error_message(const LocalizedString& message);
|
||||
|
@ -208,6 +223,6 @@ namespace vcpkg
|
|||
|
||||
// Exposed for testing
|
||||
ExpectedL<std::vector<Dependency>> parse_dependencies_list(const std::string& str,
|
||||
StringView origin = "<unknown>",
|
||||
StringView origin,
|
||||
TextRowCol textrowcol = {});
|
||||
}
|
||||
|
|
|
@ -67,7 +67,10 @@ struct MockVersionedPortfileProvider : IVersionedPortfileProvider
|
|||
core->version_scheme = scheme;
|
||||
core->version = version;
|
||||
scf->core_paragraph = std::move(core);
|
||||
it2 = version_map.emplace(std::move(version), SourceControlFileAndLocation{std::move(scf), name}).first;
|
||||
it2 = version_map
|
||||
.emplace(std::move(version),
|
||||
SourceControlFileAndLocation{std::move(scf), Path(std::move(name)) / "vcpkg.json"})
|
||||
.first;
|
||||
}
|
||||
|
||||
return it2->second;
|
||||
|
|
|
@ -93,9 +93,9 @@ TEST_CASE ("manifest construct minimum", "[manifests]")
|
|||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "zlib");
|
||||
REQUIRE(pgh.core_paragraph->version_scheme == VersionScheme::String);
|
||||
REQUIRE(pgh.core_paragraph->version == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.to_name() == "zlib");
|
||||
REQUIRE(pgh.to_version_scheme() == VersionScheme::String);
|
||||
REQUIRE(pgh.to_version() == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.core_paragraph->maintainers.empty());
|
||||
REQUIRE(pgh.core_paragraph->contacts.is_empty());
|
||||
REQUIRE(pgh.core_paragraph->summary.empty());
|
||||
|
@ -126,9 +126,9 @@ TEST_CASE ("project manifest construct minimum", "[manifests]")
|
|||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name.empty());
|
||||
REQUIRE(pgh.core_paragraph->version_scheme == VersionScheme::Missing);
|
||||
REQUIRE(pgh.core_paragraph->version == Version{});
|
||||
REQUIRE(pgh.to_name().empty());
|
||||
REQUIRE(pgh.to_version_scheme() == VersionScheme::Missing);
|
||||
REQUIRE(pgh.to_version() == Version{});
|
||||
REQUIRE(pgh.core_paragraph->maintainers.empty());
|
||||
REQUIRE(pgh.core_paragraph->contacts.is_empty());
|
||||
REQUIRE(pgh.core_paragraph->summary.empty());
|
||||
|
@ -904,9 +904,9 @@ TEST_CASE ("manifest construct maximum", "[manifests]")
|
|||
REQUIRE(*res.get() != nullptr);
|
||||
auto& pgh = **res.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "s");
|
||||
REQUIRE(pgh.core_paragraph->version_scheme == VersionScheme::String);
|
||||
REQUIRE(pgh.core_paragraph->version == Version{"v", 0});
|
||||
REQUIRE(pgh.to_name() == "s");
|
||||
REQUIRE(pgh.to_version_scheme() == VersionScheme::String);
|
||||
REQUIRE(pgh.to_version() == Version{"v", 0});
|
||||
REQUIRE(pgh.core_paragraph->maintainers.size() == 1);
|
||||
REQUIRE(pgh.core_paragraph->maintainers[0] == "m");
|
||||
REQUIRE(pgh.core_paragraph->contacts.size() == 1);
|
||||
|
@ -1028,9 +1028,9 @@ TEST_CASE ("SourceParagraph manifest construct qualified dependencies", "[manife
|
|||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "zlib");
|
||||
REQUIRE(pgh.core_paragraph->version_scheme == VersionScheme::String);
|
||||
REQUIRE(pgh.core_paragraph->version == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.to_name() == "zlib");
|
||||
REQUIRE(pgh.to_version_scheme() == VersionScheme::String);
|
||||
REQUIRE(pgh.to_version() == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.core_paragraph->maintainers.empty());
|
||||
REQUIRE(pgh.core_paragraph->description.empty());
|
||||
REQUIRE(pgh.core_paragraph->dependencies.size() == 2);
|
||||
|
@ -1058,9 +1058,9 @@ TEST_CASE ("SourceParagraph manifest construct host dependencies", "[manifests]"
|
|||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "zlib");
|
||||
REQUIRE(pgh.core_paragraph->version_scheme == VersionScheme::String);
|
||||
REQUIRE(pgh.core_paragraph->version == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.to_name() == "zlib");
|
||||
REQUIRE(pgh.to_version_scheme() == VersionScheme::String);
|
||||
REQUIRE(pgh.to_version() == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.core_paragraph->maintainers.empty());
|
||||
REQUIRE(pgh.core_paragraph->description.empty());
|
||||
REQUIRE(pgh.core_paragraph->dependencies.size() == 2);
|
||||
|
|
|
@ -41,8 +41,9 @@ TEST_CASE ("SourceParagraph construct minimum", "[paragraph]")
|
|||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "zlib");
|
||||
REQUIRE(pgh.core_paragraph->version == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.to_name() == "zlib");
|
||||
REQUIRE(pgh.to_version_scheme() == VersionScheme::String);
|
||||
REQUIRE(pgh.to_version() == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.core_paragraph->maintainers.empty());
|
||||
REQUIRE(pgh.core_paragraph->description.empty());
|
||||
REQUIRE(pgh.core_paragraph->dependencies.size() == 0);
|
||||
|
@ -105,8 +106,9 @@ TEST_CASE ("SourceParagraph construct maximum", "[paragraph]")
|
|||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "s");
|
||||
REQUIRE(pgh.core_paragraph->version == Version{"v", 0});
|
||||
REQUIRE(pgh.to_name() == "s");
|
||||
REQUIRE(pgh.to_version_scheme() == VersionScheme::String);
|
||||
REQUIRE(pgh.to_version() == Version{"v", 0});
|
||||
REQUIRE(pgh.core_paragraph->maintainers.size() == 1);
|
||||
REQUIRE(pgh.core_paragraph->maintainers[0] == "m");
|
||||
REQUIRE(pgh.core_paragraph->description.size() == 1);
|
||||
|
@ -179,8 +181,9 @@ TEST_CASE ("SourceParagraph construct qualified dependencies", "[paragraph]")
|
|||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "zlib");
|
||||
REQUIRE(pgh.core_paragraph->version == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.to_name() == "zlib");
|
||||
REQUIRE(pgh.to_version_scheme() == VersionScheme::String);
|
||||
REQUIRE(pgh.to_version() == Version{"1.2.8", 0});
|
||||
REQUIRE(pgh.core_paragraph->maintainers.empty());
|
||||
REQUIRE(pgh.core_paragraph->description.empty());
|
||||
REQUIRE(pgh.core_paragraph->dependencies.size() == 2);
|
||||
|
|
|
@ -9,7 +9,7 @@ TEST_CASE ("spdx maximum serialization", "[spdx]")
|
|||
{
|
||||
PackageSpec spec{"zlib", Test::ARM_UWP};
|
||||
SourceControlFileAndLocation scfl;
|
||||
scfl.registry_location = "git://some-vcs-url";
|
||||
scfl.spdx_location = "git://some-vcs-url";
|
||||
auto& scf = *(scfl.source_control_file = std::make_unique<SourceControlFile>());
|
||||
auto& cpgh = *(scf.core_paragraph = std::make_unique<SourceParagraph>());
|
||||
cpgh.name = "zlib";
|
||||
|
|
|
@ -107,7 +107,8 @@ namespace vcpkg::Test
|
|||
|
||||
PackageSpec PackageSpecMap::emplace(vcpkg::SourceControlFileAndLocation&& scfl)
|
||||
{
|
||||
const auto& name = scfl.source_control_file->core_paragraph->name;
|
||||
// copy name before moving scfl
|
||||
auto name = scfl.to_name();
|
||||
REQUIRE(!Util::Maps::contains(map, name));
|
||||
map.emplace(name, std::move(scfl));
|
||||
return {name, triplet};
|
||||
|
|
|
@ -11,7 +11,7 @@ using namespace vcpkg;
|
|||
|
||||
TEST_CASE ("parse depends", "[dependencies]")
|
||||
{
|
||||
auto w = parse_dependencies_list("liba (windows)");
|
||||
auto w = parse_dependencies_list("liba (windows)", "<test>");
|
||||
REQUIRE(w);
|
||||
auto& v = *w.get();
|
||||
REQUIRE(v.size() == 1);
|
||||
|
@ -30,7 +30,7 @@ TEST_CASE ("filter depends", "[dependencies]")
|
|||
|
||||
const std::unordered_map<std::string, std::string> arm_uwp_cmake_vars{{"VCPKG_TARGET_ARCHITECTURE", "arm"},
|
||||
{"VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"}};
|
||||
auto deps_ = parse_dependencies_list("liba (!uwp), libb, libc (uwp)");
|
||||
auto deps_ = parse_dependencies_list("liba (!uwp), libb, libc (uwp)", "<test>");
|
||||
REQUIRE(deps_);
|
||||
auto& deps = *deps_.get();
|
||||
SECTION ("x64-windows")
|
||||
|
@ -57,7 +57,8 @@ TEST_CASE ("filter depends", "[dependencies]")
|
|||
TEST_CASE ("parse feature depends", "[dependencies]")
|
||||
{
|
||||
auto u_ = parse_dependencies_list("libwebp[anim, gif2webp, img2webp, info, mux, nearlossless, "
|
||||
"simd, cwebp, dwebp], libwebp[vwebp-sdl, extras] (!osx)");
|
||||
"simd, cwebp, dwebp], libwebp[vwebp-sdl, extras] (!osx)",
|
||||
"<test>");
|
||||
REQUIRE(u_);
|
||||
auto& v = *u_.get();
|
||||
REQUIRE(v.size() == 2);
|
||||
|
|
|
@ -365,7 +365,7 @@ endfunction()
|
|||
for (const auto& install_action : action_plan.install_actions)
|
||||
{
|
||||
auto& scfl = install_action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO);
|
||||
const auto override_path = scfl.source_location / "vcpkg-abi-settings.cmake";
|
||||
const auto override_path = scfl.port_directory() / "vcpkg-abi-settings.cmake";
|
||||
spec_abi_settings.emplace_back(FullPackageSpec{install_action.spec, install_action.feature_list},
|
||||
override_path.generic_u8string());
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <vcpkg/base/git.h>
|
||||
#include <vcpkg/base/json.h>
|
||||
#include <vcpkg/base/strings.h>
|
||||
#include <vcpkg/base/system.process.h>
|
||||
#include <vcpkg/base/util.h>
|
||||
|
||||
#include <vcpkg/commands.add-version.h>
|
||||
|
@ -386,7 +387,7 @@ namespace vcpkg
|
|||
auto maybe_git_tree_map = paths.git_get_local_port_treeish_map();
|
||||
auto& git_tree_map = maybe_git_tree_map.value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
// Find ports with uncommited changes
|
||||
// Find ports with uncommitted changes
|
||||
std::set<std::string> changed_ports;
|
||||
auto git_config = paths.git_builtin_config();
|
||||
auto maybe_changes = git_ports_with_uncommitted_changes(git_config);
|
||||
|
@ -403,20 +404,13 @@ namespace vcpkg
|
|||
{
|
||||
auto port_dir = paths.builtin_ports_directory() / port_name;
|
||||
|
||||
if (!fs.exists(port_dir, IgnoreErrors{}))
|
||||
{
|
||||
msg::println_error(msgPortDoesNotExist, msg::package_name = port_name);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !add_all);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto maybe_scf =
|
||||
Paragraphs::try_load_port_required(fs, port_name, paths.builtin_ports_directory() / port_name);
|
||||
auto scf = maybe_scf.get();
|
||||
if (!scf)
|
||||
auto maybe_scfl = Paragraphs::try_load_port_required(
|
||||
fs, port_name, PortLocation{paths.builtin_ports_directory() / port_name});
|
||||
auto scfl = maybe_scfl.get();
|
||||
if (!scfl)
|
||||
{
|
||||
msg::println_error(msgAddVersionLoadPortFailed, msg::package_name = port_name);
|
||||
msg::println(Color::error, maybe_scf.error());
|
||||
msg::println(Color::error, maybe_scfl.error());
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !add_all);
|
||||
continue;
|
||||
}
|
||||
|
@ -424,15 +418,16 @@ namespace vcpkg
|
|||
if (!skip_formatting_check)
|
||||
{
|
||||
// check if manifest file is property formatted
|
||||
const auto path_to_manifest = paths.builtin_ports_directory() / port_name / "vcpkg.json";
|
||||
if (fs.exists(path_to_manifest, IgnoreErrors{}))
|
||||
|
||||
if (scfl->control_path.filename() == "vcpkg.json")
|
||||
{
|
||||
const auto current_file_content = fs.read_contents(path_to_manifest, VCPKG_LINE_INFO);
|
||||
const auto json = serialize_manifest(**scf);
|
||||
const auto current_file_content = fs.read_contents(scfl->control_path, VCPKG_LINE_INFO);
|
||||
const auto json = serialize_manifest(*scfl->source_control_file);
|
||||
const auto formatted_content = Json::stringify(json);
|
||||
if (current_file_content != formatted_content)
|
||||
{
|
||||
auto command_line = fmt::format("vcpkg format-manifest ports/{}/vcpkg.json", port_name);
|
||||
std::string command_line = "vcpkg format-manifest ";
|
||||
append_shell_escaped(command_line, scfl->control_path);
|
||||
msg::println_error(
|
||||
msg::format(msgAddVersionPortHasImproperFormat, msg::package_name = port_name)
|
||||
.append_raw('\n')
|
||||
|
@ -452,8 +447,7 @@ namespace vcpkg
|
|||
msg::println_warning(msgAddVersionUncommittedChanges, msg::package_name = port_name);
|
||||
}
|
||||
|
||||
const auto& schemed_version = (*scf)->to_schemed_version();
|
||||
|
||||
auto schemed_version = scfl->source_control_file->to_schemed_version();
|
||||
auto git_tree_it = git_tree_map.find(port_name);
|
||||
if (git_tree_it == git_tree_map.end())
|
||||
{
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace vcpkg
|
|||
StringView triplet_prefix{colon + 1, last_arg.end()};
|
||||
// TODO: Support autocomplete for ports in --overlay-ports
|
||||
auto maybe_port = Paragraphs::try_load_port_required(
|
||||
paths.get_filesystem(), port_name, paths.builtin_ports_directory() / port_name);
|
||||
paths.get_filesystem(), port_name, PortLocation{paths.builtin_ports_directory() / port_name});
|
||||
if (!maybe_port)
|
||||
{
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace vcpkg
|
|||
ASSUME(action != nullptr);
|
||||
auto& scf = *action->source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_control_file;
|
||||
const auto& spec_name = spec.name();
|
||||
const auto& core_paragraph_name = scf.core_paragraph->name;
|
||||
const auto& core_paragraph_name = scf.to_name();
|
||||
if (spec_name != core_paragraph_name)
|
||||
{
|
||||
Checks::msg_exit_with_error(VCPKG_LINE_INFO,
|
||||
|
@ -744,6 +744,7 @@ namespace vcpkg
|
|||
{
|
||||
auto& scfl = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO);
|
||||
auto& scf = *scfl.source_control_file;
|
||||
auto& port_name = scf.to_name();
|
||||
|
||||
std::string all_features;
|
||||
for (auto& feature : scf.feature_paragraphs)
|
||||
|
@ -753,11 +754,11 @@ namespace vcpkg
|
|||
|
||||
std::vector<CMakeVariable> variables{
|
||||
{"ALL_FEATURES", all_features},
|
||||
{"CURRENT_PORT_DIR", scfl.source_location},
|
||||
{"CURRENT_PORT_DIR", scfl.port_directory()},
|
||||
{"_HOST_TRIPLET", action.host_triplet.canonical_name()},
|
||||
{"FEATURES", Strings::join(";", action.feature_list)},
|
||||
{"PORT", scf.core_paragraph->name},
|
||||
{"VERSION", scf.core_paragraph->version.text},
|
||||
{"PORT", port_name},
|
||||
{"VERSION", scf.to_version().text},
|
||||
{"VCPKG_USE_HEAD_VERSION", Util::Enum::to_bool(action.build_options.use_head_version) ? "1" : "0"},
|
||||
{"_VCPKG_DOWNLOAD_TOOL", to_string_view(action.build_options.download_tool)},
|
||||
{"_VCPKG_EDITABLE", Util::Enum::to_bool(action.build_options.editable) ? "1" : "0"},
|
||||
|
@ -772,7 +773,7 @@ namespace vcpkg
|
|||
|
||||
if (auto cmake_debug = args.cmake_debug.get())
|
||||
{
|
||||
if (cmake_debug->is_port_affected(scf.core_paragraph->name))
|
||||
if (cmake_debug->is_port_affected(port_name))
|
||||
{
|
||||
variables.emplace_back("--debugger");
|
||||
variables.emplace_back(fmt::format("--debugger-pipe={}", cmake_debug->value));
|
||||
|
@ -781,7 +782,7 @@ namespace vcpkg
|
|||
|
||||
if (auto cmake_configure_debug = args.cmake_configure_debug.get())
|
||||
{
|
||||
if (cmake_configure_debug->is_port_affected(scf.core_paragraph->name))
|
||||
if (cmake_configure_debug->is_port_affected(port_name))
|
||||
{
|
||||
variables.emplace_back(fmt::format("-DVCPKG_CMAKE_CONFIGURE_OPTIONS=--debugger;--debugger-pipe={}",
|
||||
cmake_configure_debug->value));
|
||||
|
@ -900,7 +901,7 @@ namespace vcpkg
|
|||
const auto& scf = *scfl.source_control_file;
|
||||
|
||||
auto doc_ns = Strings::concat("https://spdx.org/spdxdocs/",
|
||||
scf.core_paragraph->name,
|
||||
scf.to_name(),
|
||||
'-',
|
||||
action.spec.triplet(),
|
||||
'-',
|
||||
|
@ -944,9 +945,9 @@ namespace vcpkg
|
|||
msg::println(msgLoadingOverlayTriplet, msg::path = triplet_file_path);
|
||||
}
|
||||
|
||||
if (!Strings::starts_with(scfl.source_location, paths.builtin_ports_directory()))
|
||||
if (!Strings::starts_with(scfl.control_path, paths.builtin_ports_directory()))
|
||||
{
|
||||
msg::println(msgInstallingFromLocation, msg::path = scfl.source_location);
|
||||
msg::println(msgInstallingFromLocation, msg::path = scfl.port_directory());
|
||||
}
|
||||
|
||||
const ElapsedTimer timer;
|
||||
|
@ -1023,7 +1024,7 @@ namespace vcpkg
|
|||
FileSink file_sink{fs, stdoutlog, Append::YES};
|
||||
CombiningSink combo_sink{stdout_sink, file_sink};
|
||||
error_count = perform_post_build_lint_checks(
|
||||
action.spec, paths, pre_build_info, build_info, scfl.source_location, combo_sink);
|
||||
action.spec, paths, pre_build_info, build_info, scfl.port_directory(), combo_sink);
|
||||
};
|
||||
if (error_count != 0 && action.build_options.backcompat_features == BackcompatFeatures::PROHIBIT)
|
||||
{
|
||||
|
@ -1167,7 +1168,8 @@ namespace vcpkg
|
|||
constexpr int max_port_file_count = 100;
|
||||
|
||||
std::string portfile_cmake_contents;
|
||||
auto&& port_dir = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_location;
|
||||
auto&& scfl = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO);
|
||||
auto port_dir = scfl.port_directory();
|
||||
auto raw_files = fs.get_regular_files_recursive_lexically_proximate(port_dir, VCPKG_LINE_INFO);
|
||||
if (raw_files.size() > max_port_file_count)
|
||||
{
|
||||
|
@ -1266,8 +1268,7 @@ namespace vcpkg
|
|||
abi_file_path /= triplet_canonical_name + ".vcpkg_abi_info.txt";
|
||||
fs.write_contents(abi_file_path, full_abi_info, VCPKG_LINE_INFO);
|
||||
|
||||
auto& scf = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_control_file;
|
||||
|
||||
auto& scf = scfl.source_control_file;
|
||||
abi_info.package_abi = Hash::get_string_sha256(full_abi_info);
|
||||
abi_info.abi_tag_file.emplace(std::move(abi_file_path));
|
||||
abi_info.relative_port_files = std::move(files);
|
||||
|
@ -1335,8 +1336,7 @@ namespace vcpkg
|
|||
{
|
||||
auto& filesystem = paths.get_filesystem();
|
||||
auto& spec = action.spec;
|
||||
const std::string& name = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO)
|
||||
.source_control_file->core_paragraph->name;
|
||||
const std::string& name = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).to_name();
|
||||
|
||||
std::vector<FeatureSpec> missing_fspecs;
|
||||
for (const auto& kv : action.feature_dependencies)
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace
|
|||
expected_right_tag};
|
||||
}
|
||||
|
||||
auto&& git_tree_version = (*scf)->to_schemed_version();
|
||||
auto&& git_tree_version = (**scf).to_schemed_version();
|
||||
if (version_entry.version.version != git_tree_version.version)
|
||||
{
|
||||
return {
|
||||
|
@ -121,17 +121,18 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
auto maybe_scf = Paragraphs::try_load_port_required(paths.get_filesystem(), port_name, port_path);
|
||||
auto scf = maybe_scf.get();
|
||||
if (!scf)
|
||||
auto maybe_scfl =
|
||||
Paragraphs::try_load_port_required(paths.get_filesystem(), port_name, PortLocation{port_path});
|
||||
auto scfl = maybe_scfl.get();
|
||||
if (!scfl)
|
||||
{
|
||||
return {msg::format_error(msgWhileLoadingLocalPort, msg::package_name = port_name)
|
||||
.append_raw('\n')
|
||||
.append(maybe_scf.error()),
|
||||
.append(maybe_scfl.error()),
|
||||
expected_right_tag};
|
||||
}
|
||||
|
||||
const auto local_port_version = (*scf)->to_schemed_version();
|
||||
const auto local_port_version = scfl->source_control_file->to_schemed_version();
|
||||
|
||||
auto versions_end = versions->end();
|
||||
auto it = std::find_if(versions->begin(), versions_end, [&](const GitVersionDbEntry& entry) {
|
||||
|
|
|
@ -389,9 +389,8 @@ namespace vcpkg
|
|||
std::vector<FullPackageSpec> all_default_full_specs;
|
||||
for (auto scfl : provider.load_all_control_files())
|
||||
{
|
||||
all_default_full_specs.emplace_back(
|
||||
PackageSpec{scfl->source_control_file->core_paragraph->name, target_triplet},
|
||||
InternalFeatureSet{"core", "default"});
|
||||
all_default_full_specs.emplace_back(PackageSpec{scfl->to_name(), target_triplet},
|
||||
InternalFeatureSet{"core", "default"});
|
||||
}
|
||||
|
||||
CreateInstallPlanOptions serialize_options(host_triplet, paths.packages(), UnsupportedPortAction::Warn);
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace vcpkg
|
|||
do_print(*source_control_file->core_paragraph, full_description);
|
||||
for (auto&& feature_paragraph : source_control_file->feature_paragraphs)
|
||||
{
|
||||
do_print(source_control_file->core_paragraph->name, *feature_paragraph, full_description);
|
||||
do_print(source_control_file->to_name(), *feature_paragraph, full_description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -440,10 +440,11 @@ namespace vcpkg
|
|||
}
|
||||
if (auto scfl = action.source_control_file_and_location.get())
|
||||
{
|
||||
auto port_directory = scfl->port_directory();
|
||||
if (!builtin_ports_dir.empty() &&
|
||||
!Strings::case_insensitive_ascii_starts_with(scfl->source_location, builtin_ports_dir))
|
||||
!Strings::case_insensitive_ascii_starts_with(port_directory, builtin_ports_dir))
|
||||
{
|
||||
out.append_raw(" -- ").append_raw(scfl->source_location);
|
||||
out.append_raw(" -- ").append_raw(port_directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,65 +380,48 @@ namespace vcpkg::Paragraphs
|
|||
return fs.exists(maybe_directory / "CONTROL", IgnoreErrors{}) ||
|
||||
fs.exists(maybe_directory / "vcpkg.json", IgnoreErrors{});
|
||||
}
|
||||
} // namespace vcpkg::Paragraphs
|
||||
|
||||
namespace
|
||||
{
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_any_manifest_text(
|
||||
StringView text,
|
||||
StringView origin,
|
||||
MessageSink& warning_sink,
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> (*do_parse)(StringView, const Json::Object&, MessageSink&))
|
||||
{
|
||||
StatsTimer timer(g_load_ports_stats);
|
||||
return Json::parse_object(text, origin).then([&](Json::Object&& object) {
|
||||
return do_parse(origin, std::move(object), warning_sink);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace vcpkg::Paragraphs
|
||||
{
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_project_manifest_text(StringView text,
|
||||
StringView origin,
|
||||
MessageSink& warning_sink)
|
||||
{
|
||||
return try_load_any_manifest_text(text, origin, warning_sink, SourceControlFile::parse_project_manifest_object);
|
||||
}
|
||||
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_port_manifest_text(StringView text,
|
||||
StringView origin,
|
||||
StringView control_path,
|
||||
MessageSink& warning_sink)
|
||||
{
|
||||
return try_load_any_manifest_text(text, origin, warning_sink, SourceControlFile::parse_port_manifest_object);
|
||||
}
|
||||
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_control_file_text(StringView text, StringView origin)
|
||||
{
|
||||
StatsTimer timer(g_load_ports_stats);
|
||||
return parse_paragraphs(text, origin).then([&](std::vector<Paragraph>&& vector_pghs) {
|
||||
return SourceControlFile::parse_control_file(origin, std::move(vector_pghs)).map_error(ToLocalizedString);
|
||||
return Json::parse_object(text, control_path).then([&](Json::Object&& object) {
|
||||
return SourceControlFile::parse_port_manifest_object(control_path, std::move(object), warning_sink);
|
||||
});
|
||||
}
|
||||
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_port(const ReadOnlyFilesystem& fs,
|
||||
StringView port_name,
|
||||
const Path& port_directory)
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_control_file_text(StringView text, StringView control_path)
|
||||
{
|
||||
StatsTimer timer(g_load_ports_stats);
|
||||
return parse_paragraphs(text, control_path).then([&](std::vector<Paragraph>&& vector_pghs) {
|
||||
return SourceControlFile::parse_control_file(control_path, std::move(vector_pghs))
|
||||
.map_error(ToLocalizedString);
|
||||
});
|
||||
}
|
||||
|
||||
ExpectedL<SourceControlFileAndLocation> try_load_port(const ReadOnlyFilesystem& fs,
|
||||
StringView port_name,
|
||||
const PortLocation& port_location)
|
||||
{
|
||||
StatsTimer timer(g_load_ports_stats);
|
||||
|
||||
const auto manifest_path = port_directory / "vcpkg.json";
|
||||
const auto control_path = port_directory / "CONTROL";
|
||||
auto manifest_path = port_location.port_directory / "vcpkg.json";
|
||||
auto control_path = port_location.port_directory / "CONTROL";
|
||||
std::error_code ec;
|
||||
auto manifest_contents = fs.read_contents(manifest_path, ec);
|
||||
if (!ec)
|
||||
{
|
||||
if (fs.exists(control_path, IgnoreErrors{}))
|
||||
{
|
||||
return msg::format_error(msgManifestConflict, msg::path = port_directory);
|
||||
return msg::format_error(msgManifestConflict, msg::path = port_location.port_directory);
|
||||
}
|
||||
|
||||
return try_load_port_manifest_text(manifest_contents, manifest_path, stdout_sink);
|
||||
return try_load_port_manifest_text(manifest_contents, manifest_path, stdout_sink)
|
||||
.map([&](std::unique_ptr<SourceControlFile>&& scf) {
|
||||
return SourceControlFileAndLocation{
|
||||
std::move(scf), std::move(manifest_path), port_location.spdx_location};
|
||||
});
|
||||
}
|
||||
|
||||
auto manifest_exists = ec != std::errc::no_such_file_or_directory;
|
||||
|
@ -452,43 +435,50 @@ namespace vcpkg::Paragraphs
|
|||
auto control_contents = fs.read_contents(control_path, ec);
|
||||
if (!ec)
|
||||
{
|
||||
return try_load_control_file_text(control_contents, control_path);
|
||||
return try_load_control_file_text(control_contents, control_path)
|
||||
.map([&](std::unique_ptr<SourceControlFile>&& scf) {
|
||||
return SourceControlFileAndLocation{
|
||||
std::move(scf), std::move(control_path), port_location.spdx_location};
|
||||
});
|
||||
}
|
||||
|
||||
if (ec != std::errc::no_such_file_or_directory)
|
||||
{
|
||||
return LocalizedString::from_raw(port_directory)
|
||||
return LocalizedString::from_raw(port_location.port_directory)
|
||||
.append_raw(": ")
|
||||
.append(format_filesystem_call_error(ec, "read_contents", {control_path}));
|
||||
}
|
||||
|
||||
if (fs.exists(port_directory, IgnoreErrors{}))
|
||||
if (fs.exists(port_location.port_directory, IgnoreErrors{}))
|
||||
{
|
||||
return LocalizedString::from_raw(port_directory)
|
||||
return LocalizedString::from_raw(port_location.port_directory)
|
||||
.append_raw(": ")
|
||||
.append_raw(ErrorPrefix)
|
||||
.append(msgPortMissingManifest2, msg::package_name = port_name);
|
||||
}
|
||||
|
||||
return LocalizedString::from_raw(port_directory)
|
||||
return LocalizedString::from_raw(port_location.port_directory)
|
||||
.append_raw(": ")
|
||||
.append_raw(ErrorPrefix)
|
||||
.append(msgPortDoesNotExist, msg::package_name = port_name);
|
||||
}
|
||||
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> try_load_port_required(const ReadOnlyFilesystem& fs,
|
||||
StringView port_name,
|
||||
const Path& port_directory)
|
||||
ExpectedL<SourceControlFileAndLocation> try_load_port_required(const ReadOnlyFilesystem& fs,
|
||||
StringView port_name,
|
||||
const PortLocation& port_location)
|
||||
{
|
||||
return try_load_port(fs, port_name, port_directory)
|
||||
.then([&](std::unique_ptr<SourceControlFile>&& loaded) -> ExpectedL<std::unique_ptr<SourceControlFile>> {
|
||||
if (!loaded)
|
||||
{
|
||||
return msg::format_error(msgPortDoesNotExist, msg::package_name = port_name);
|
||||
}
|
||||
auto load_result = try_load_port(fs, port_name, port_location);
|
||||
auto maybe_res = load_result.get();
|
||||
if (maybe_res)
|
||||
{
|
||||
auto res = maybe_res->source_control_file.get();
|
||||
if (!res)
|
||||
{
|
||||
load_result = msg::format_error(msgPortDoesNotExist, msg::package_name = port_name);
|
||||
}
|
||||
}
|
||||
|
||||
return std::move(loaded);
|
||||
});
|
||||
return load_result;
|
||||
}
|
||||
|
||||
ExpectedL<BinaryControlFile> try_load_cached_package(const ReadOnlyFilesystem& fs,
|
||||
|
@ -548,20 +538,16 @@ namespace vcpkg::Paragraphs
|
|||
auto maybe_port_location = (*port_entry)->get_version(*baseline_version);
|
||||
const auto port_location = maybe_port_location.get();
|
||||
if (!port_location) continue; // baseline version was not in version db (registry consistency issue)
|
||||
auto maybe_spgh = try_load_port_required(fs, port_name, port_location->path);
|
||||
if (const auto spgh = maybe_spgh.get())
|
||||
auto maybe_scfl = try_load_port_required(fs, port_name, *port_location);
|
||||
if (const auto scfl = maybe_scfl.get())
|
||||
{
|
||||
ret.paragraphs.push_back({
|
||||
std::move(*spgh),
|
||||
std::move(port_location->path),
|
||||
std::move(port_location->location),
|
||||
});
|
||||
ret.paragraphs.push_back(std::move(*scfl));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.errors.emplace_back(std::piecewise_construct,
|
||||
std::forward_as_tuple(port_name.data(), port_name.size()),
|
||||
std::forward_as_tuple(std::move(maybe_spgh).error()));
|
||||
std::forward_as_tuple(std::move(maybe_scfl).error()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -614,10 +600,10 @@ namespace vcpkg::Paragraphs
|
|||
for (auto&& path : port_dirs)
|
||||
{
|
||||
auto port_name = path.filename();
|
||||
auto maybe_spgh = try_load_port_required(fs, port_name, path);
|
||||
auto maybe_spgh = try_load_port_required(fs, port_name, PortLocation{path});
|
||||
if (const auto spgh = maybe_spgh.get())
|
||||
{
|
||||
ret.paragraphs.push_back({std::move(*spgh), std::move(path)});
|
||||
ret.paragraphs.push_back(std::move(*spgh));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -19,11 +19,11 @@ namespace
|
|||
OverlayRegistryEntry(Path&& p, Version&& v) : root(p), version(v) { }
|
||||
|
||||
ExpectedL<View<Version>> get_port_versions() const override { return View<Version>{&version, 1}; }
|
||||
ExpectedL<PathAndLocation> get_version(const Version& v) const override
|
||||
ExpectedL<PortLocation> get_version(const Version& v) const override
|
||||
{
|
||||
if (v == version)
|
||||
{
|
||||
return PathAndLocation{root, ""};
|
||||
return PortLocation{root};
|
||||
}
|
||||
return msg::format(msgVersionNotFound, msg::expected = v, msg::actual = version);
|
||||
}
|
||||
|
@ -176,8 +176,7 @@ namespace vcpkg
|
|||
.value_or_exit(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
ExpectedL<std::unique_ptr<SourceControlFileAndLocation>> load_control_file(
|
||||
const VersionSpec& version_spec) const
|
||||
ExpectedL<SourceControlFileAndLocation> load_control_file(const VersionSpec& version_spec) const
|
||||
{
|
||||
const auto& maybe_ent = entry(version_spec.port_name);
|
||||
if (auto ent = maybe_ent.get())
|
||||
|
@ -185,23 +184,18 @@ namespace vcpkg
|
|||
auto maybe_path = ent->get()->get_version(version_spec.version);
|
||||
if (auto path = maybe_path.get())
|
||||
{
|
||||
auto maybe_control_file =
|
||||
Paragraphs::try_load_port_required(m_fs, version_spec.port_name, path->path);
|
||||
if (auto scf = maybe_control_file.get())
|
||||
auto maybe_scfl = Paragraphs::try_load_port_required(m_fs, version_spec.port_name, *path);
|
||||
if (auto scfl = maybe_scfl.get())
|
||||
{
|
||||
auto scf_vspec = scf->get()->to_version_spec();
|
||||
auto scf_vspec = scfl->source_control_file->to_version_spec();
|
||||
if (scf_vspec == version_spec)
|
||||
{
|
||||
return std::make_unique<SourceControlFileAndLocation>(SourceControlFileAndLocation{
|
||||
std::move(*scf),
|
||||
std::move(path->path),
|
||||
std::move(path->location),
|
||||
});
|
||||
return std::move(*scfl);
|
||||
}
|
||||
else
|
||||
{
|
||||
return msg::format_error(msgVersionSpecMismatch,
|
||||
msg::path = path->path,
|
||||
msg::path = path->port_directory,
|
||||
msg::expected_version = version_spec,
|
||||
msg::actual_version = scf_vspec);
|
||||
}
|
||||
|
@ -209,11 +203,11 @@ namespace vcpkg
|
|||
else
|
||||
{
|
||||
// This should change to a soft error when ParseExpected is eliminated.
|
||||
print_error_message(maybe_control_file.error());
|
||||
print_error_message(maybe_scfl.error());
|
||||
Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
msgFailedToLoadPort,
|
||||
msg::package_name = version_spec.port_name,
|
||||
msg::path = path->path);
|
||||
msg::path = path->port_directory);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -234,7 +228,9 @@ namespace vcpkg
|
|||
{
|
||||
it = m_control_cache.emplace(version_spec, load_control_file(version_spec)).first;
|
||||
}
|
||||
return it->second.map([](const auto& x) -> const SourceControlFileAndLocation& { return *x.get(); });
|
||||
|
||||
return it->second.map(
|
||||
[](const SourceControlFileAndLocation& x) -> const SourceControlFileAndLocation& { return x; });
|
||||
}
|
||||
|
||||
virtual void load_all_control_files(
|
||||
|
@ -243,22 +239,16 @@ namespace vcpkg
|
|||
auto all_ports = Paragraphs::load_all_registry_ports(m_fs, m_registry_set);
|
||||
for (auto&& scfl : all_ports)
|
||||
{
|
||||
// make version spec before moving from scfl
|
||||
auto version_spec = scfl.source_control_file->to_version_spec();
|
||||
auto it = m_control_cache
|
||||
.emplace(std::move(version_spec),
|
||||
std::make_unique<SourceControlFileAndLocation>(std::move(scfl)))
|
||||
.first;
|
||||
out.emplace(it->first.port_name, it->second.value_or_exit(VCPKG_LINE_INFO).get());
|
||||
auto it = m_control_cache.emplace(scfl.to_version_spec(), std::move(scfl)).first;
|
||||
out.emplace(it->first.port_name, &it->second.value_or_exit(VCPKG_LINE_INFO));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const ReadOnlyFilesystem& m_fs;
|
||||
const RegistrySet& m_registry_set;
|
||||
mutable std::
|
||||
unordered_map<VersionSpec, ExpectedL<std::unique_ptr<SourceControlFileAndLocation>>, VersionSpecHasher>
|
||||
m_control_cache;
|
||||
mutable std::unordered_map<VersionSpec, ExpectedL<SourceControlFileAndLocation>, VersionSpecHasher>
|
||||
m_control_cache;
|
||||
mutable std::map<std::string, ExpectedL<std::unique_ptr<RegistryEntry>>, std::less<>> m_entry_cache;
|
||||
};
|
||||
|
||||
|
@ -292,18 +282,17 @@ namespace vcpkg
|
|||
// Try loading individual port
|
||||
if (Paragraphs::is_port_directory(m_fs, ports_dir))
|
||||
{
|
||||
auto maybe_scf = Paragraphs::try_load_port_required(m_fs, port_name, ports_dir);
|
||||
if (auto scfp = maybe_scf.get())
|
||||
auto maybe_scfl = Paragraphs::try_load_port_required(m_fs, port_name, PortLocation{ports_dir});
|
||||
if (auto scfl = maybe_scfl.get())
|
||||
{
|
||||
auto& scf = *scfp;
|
||||
if (scf->core_paragraph->name == port_name)
|
||||
if (scfl->to_name() == port_name)
|
||||
{
|
||||
return SourceControlFileAndLocation{std::move(scf), ports_dir};
|
||||
return std::move(*scfl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_error_message(maybe_scf.error());
|
||||
print_error_message(maybe_scfl.error());
|
||||
Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
msgFailedToLoadPort,
|
||||
msg::package_name = port_name,
|
||||
|
@ -316,26 +305,25 @@ namespace vcpkg
|
|||
auto ports_spec = ports_dir / port_name;
|
||||
if (Paragraphs::is_port_directory(m_fs, ports_spec))
|
||||
{
|
||||
auto found_scf = Paragraphs::try_load_port_required(m_fs, port_name, ports_spec);
|
||||
if (auto scfp = found_scf.get())
|
||||
auto found_scfl = Paragraphs::try_load_port_required(m_fs, port_name, PortLocation{ports_spec});
|
||||
if (auto scfl = found_scfl.get())
|
||||
{
|
||||
auto& scf = *scfp;
|
||||
if (scf->core_paragraph->name == port_name)
|
||||
auto& scfl_name = scfl->to_name();
|
||||
if (scfl_name == port_name)
|
||||
{
|
||||
return SourceControlFileAndLocation{std::move(scf), std::move(ports_spec)};
|
||||
return std::move(*scfl);
|
||||
}
|
||||
|
||||
Checks::msg_exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
msg::format(msgFailedToLoadPort, msg::package_name = port_name, msg::path = ports_spec)
|
||||
.append_raw('\n')
|
||||
.append(msgMismatchedNames,
|
||||
msg::package_name = port_name,
|
||||
msg::actual = scf->core_paragraph->name));
|
||||
.append(
|
||||
msgMismatchedNames, msg::package_name = port_name, msg::actual = scfl_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
print_error_message(found_scf.error());
|
||||
print_error_message(found_scfl.error());
|
||||
Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
msgFailedToLoadPort,
|
||||
msg::package_name = port_name,
|
||||
|
@ -367,18 +355,19 @@ namespace vcpkg
|
|||
// Try loading individual port
|
||||
if (Paragraphs::is_port_directory(m_fs, ports_dir))
|
||||
{
|
||||
auto maybe_scf = Paragraphs::try_load_port_required(m_fs, ports_dir.filename(), ports_dir);
|
||||
if (auto scfp = maybe_scf.get())
|
||||
auto maybe_scfl =
|
||||
Paragraphs::try_load_port_required(m_fs, ports_dir.filename(), PortLocation{ports_dir});
|
||||
if (auto scfl = maybe_scfl.get())
|
||||
{
|
||||
SourceControlFileAndLocation scfl{std::move(*scfp), ports_dir};
|
||||
auto name = scfl.source_control_file->core_paragraph->name;
|
||||
auto it = m_overlay_cache.emplace(std::move(name), std::move(scfl)).first;
|
||||
// copy name before moving *scfl
|
||||
auto name = scfl->to_name();
|
||||
auto it = m_overlay_cache.emplace(std::move(name), std::move(*scfl)).first;
|
||||
Checks::check_exit(VCPKG_LINE_INFO, it->second.get());
|
||||
out.emplace(it->first, it->second.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
print_error_message(maybe_scf.error());
|
||||
print_error_message(maybe_scfl.error());
|
||||
Checks::msg_exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, msgFailedToLoadUnnamedPortFromPath, msg::path = ports_dir);
|
||||
}
|
||||
|
@ -390,7 +379,7 @@ namespace vcpkg
|
|||
auto found_scfls = Paragraphs::load_overlay_ports(m_fs, ports_dir);
|
||||
for (auto&& scfl : found_scfls)
|
||||
{
|
||||
auto name = scfl.source_control_file->core_paragraph->name;
|
||||
auto name = scfl.to_name();
|
||||
auto it = m_overlay_cache.emplace(std::move(name), std::move(scfl)).first;
|
||||
Checks::check_exit(VCPKG_LINE_INFO, it->second.get());
|
||||
out.emplace(it->first, it->second.get());
|
||||
|
@ -418,7 +407,7 @@ namespace vcpkg
|
|||
|
||||
virtual Optional<const SourceControlFileAndLocation&> get_control_file(StringView port_name) const override
|
||||
{
|
||||
if (port_name == m_manifest_scf_and_location.source_control_file->core_paragraph->name)
|
||||
if (port_name == m_manifest_scf_and_location.to_name())
|
||||
{
|
||||
return m_manifest_scf_and_location;
|
||||
}
|
||||
|
@ -430,10 +419,9 @@ namespace vcpkg
|
|||
std::map<std::string, const SourceControlFileAndLocation*>& out) const override
|
||||
{
|
||||
m_overlay_ports.load_all_control_files(out);
|
||||
out.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(m_manifest_scf_and_location.source_control_file->core_paragraph->name),
|
||||
std::forward_as_tuple(&m_manifest_scf_and_location));
|
||||
out.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(m_manifest_scf_and_location.to_name()),
|
||||
std::forward_as_tuple(&m_manifest_scf_and_location));
|
||||
}
|
||||
|
||||
OverlayProviderImpl m_overlay_ports;
|
||||
|
|
|
@ -251,7 +251,7 @@ namespace
|
|||
std::vector<GitVersionDbEntry>&& version_entries);
|
||||
|
||||
ExpectedL<View<Version>> get_port_versions() const override;
|
||||
ExpectedL<PathAndLocation> get_version(const Version& version) const override;
|
||||
ExpectedL<PortLocation> get_version(const Version& version) const override;
|
||||
|
||||
private:
|
||||
ExpectedL<Unit> ensure_not_stale() const;
|
||||
|
@ -412,11 +412,11 @@ namespace
|
|||
}
|
||||
|
||||
ExpectedL<View<Version>> get_port_versions() const override { return View<Version>{&version, 1}; }
|
||||
ExpectedL<PathAndLocation> get_version(const Version& v) const override
|
||||
ExpectedL<PortLocation> get_version(const Version& v) const override
|
||||
{
|
||||
if (v == version)
|
||||
{
|
||||
return PathAndLocation{root, "git+https://github.com/Microsoft/vcpkg#ports/" + name};
|
||||
return PortLocation{root, "git+https://github.com/Microsoft/vcpkg#ports/" + name};
|
||||
}
|
||||
|
||||
return msg::format_error(msgVersionBuiltinPortTreeEntryMissing,
|
||||
|
@ -438,7 +438,7 @@ namespace
|
|||
{
|
||||
return View<Version>{port_versions_soa.port_versions()};
|
||||
}
|
||||
ExpectedL<PathAndLocation> get_version(const Version& version) const override;
|
||||
ExpectedL<PortLocation> get_version(const Version& version) const override;
|
||||
|
||||
const VcpkgPaths& m_paths;
|
||||
|
||||
|
@ -453,7 +453,7 @@ namespace
|
|||
|
||||
ExpectedL<View<Version>> get_port_versions() const override { return View<Version>{port_versions}; }
|
||||
|
||||
ExpectedL<PathAndLocation> get_version(const Version& version) const override;
|
||||
ExpectedL<PortLocation> get_version(const Version& version) const override;
|
||||
|
||||
std::string port_name;
|
||||
// these two map port versions to paths
|
||||
|
@ -488,14 +488,15 @@ namespace
|
|||
DelayedInit<Baseline> m_baseline;
|
||||
|
||||
private:
|
||||
const ExpectedL<std::unique_ptr<SourceControlFile>>& get_scf(StringView port_name, const Path& path) const
|
||||
const ExpectedL<SourceControlFileAndLocation>& get_scfl(StringView port_name, const Path& path) const
|
||||
{
|
||||
return m_scfs.get_lazy(path, [&, this]() { return Paragraphs::try_load_port(m_fs, port_name, path); });
|
||||
return m_scfls.get_lazy(
|
||||
path, [&, this]() { return Paragraphs::try_load_port(m_fs, port_name, PortLocation{path}); });
|
||||
}
|
||||
|
||||
const ReadOnlyFilesystem& m_fs;
|
||||
const Path m_builtin_ports_directory;
|
||||
Cache<Path, ExpectedL<std::unique_ptr<SourceControlFile>>> m_scfs;
|
||||
Cache<Path, ExpectedL<SourceControlFileAndLocation>> m_scfls;
|
||||
};
|
||||
constexpr StringLiteral BuiltinFilesRegistry::s_kind;
|
||||
|
||||
|
@ -713,14 +714,14 @@ namespace
|
|||
ExpectedL<std::unique_ptr<RegistryEntry>> BuiltinFilesRegistry::get_port_entry(StringView port_name) const
|
||||
{
|
||||
auto port_directory = m_builtin_ports_directory / port_name;
|
||||
const auto& maybe_maybe_scf = get_scf(port_name, port_directory);
|
||||
const auto maybe_scf = maybe_maybe_scf.get();
|
||||
if (!maybe_scf)
|
||||
const auto& maybe_maybe_scfl = get_scfl(port_name, port_directory);
|
||||
const auto maybe_scfl = maybe_maybe_scfl.get();
|
||||
if (!maybe_scfl)
|
||||
{
|
||||
return maybe_maybe_scf.error();
|
||||
return maybe_maybe_scfl.error();
|
||||
}
|
||||
|
||||
auto scf = maybe_scf->get();
|
||||
auto scf = maybe_scfl->source_control_file.get();
|
||||
if (!scf)
|
||||
{
|
||||
return std::unique_ptr<RegistryEntry>();
|
||||
|
@ -741,14 +742,14 @@ namespace
|
|||
ExpectedL<Optional<Version>> BuiltinFilesRegistry::get_baseline_version(StringView port_name) const
|
||||
{
|
||||
// if a baseline is not specified, use the ports directory version
|
||||
const auto& maybe_maybe_scf = get_scf(port_name, m_builtin_ports_directory / port_name);
|
||||
auto maybe_scf = maybe_maybe_scf.get();
|
||||
if (!maybe_scf)
|
||||
const auto& maybe_maybe_scfl = get_scfl(port_name, m_builtin_ports_directory / port_name);
|
||||
auto maybe_scfl = maybe_maybe_scfl.get();
|
||||
if (!maybe_scfl)
|
||||
{
|
||||
return maybe_maybe_scf.error();
|
||||
return maybe_maybe_scfl.error();
|
||||
}
|
||||
|
||||
auto scf = maybe_scf->get();
|
||||
auto scf = maybe_scfl->source_control_file.get();
|
||||
if (!scf)
|
||||
{
|
||||
return Optional<Version>();
|
||||
|
@ -1118,7 +1119,7 @@ namespace
|
|||
// { RegistryEntry
|
||||
|
||||
// { BuiltinRegistryEntry::RegistryEntry
|
||||
ExpectedL<PathAndLocation> BuiltinGitRegistryEntry::get_version(const Version& version) const
|
||||
ExpectedL<PortLocation> BuiltinGitRegistryEntry::get_version(const Version& version) const
|
||||
{
|
||||
auto& port_versions = port_versions_soa.port_versions();
|
||||
auto it = std::find(port_versions.begin(), port_versions.end(), version);
|
||||
|
@ -1133,7 +1134,7 @@ namespace
|
|||
const auto& git_tree = port_versions_soa.git_trees()[it - port_versions.begin()];
|
||||
return m_paths.versions_dot_git_dir()
|
||||
.then([&, this](Path&& dot_git) { return m_paths.git_checkout_port(port_name, git_tree, dot_git); })
|
||||
.map([&git_tree](Path&& p) -> PathAndLocation {
|
||||
.map([&git_tree](Path&& p) -> PortLocation {
|
||||
return {
|
||||
std::move(p),
|
||||
"git+https://github.com/Microsoft/vcpkg@" + git_tree,
|
||||
|
@ -1143,7 +1144,7 @@ namespace
|
|||
// } BuiltinRegistryEntry::RegistryEntry
|
||||
|
||||
// { FilesystemRegistryEntry::RegistryEntry
|
||||
ExpectedL<PathAndLocation> FilesystemRegistryEntry::get_version(const Version& version) const
|
||||
ExpectedL<PortLocation> FilesystemRegistryEntry::get_version(const Version& version) const
|
||||
{
|
||||
auto it = std::find(port_versions.begin(), port_versions.end(), version);
|
||||
if (it == port_versions.end())
|
||||
|
@ -1151,10 +1152,8 @@ namespace
|
|||
return msg::format_error(
|
||||
msgVersionDatabaseEntryMissing, msg::package_name = port_name, msg::version = version);
|
||||
}
|
||||
return PathAndLocation{
|
||||
version_paths[it - port_versions.begin()],
|
||||
"",
|
||||
};
|
||||
|
||||
return PortLocation{version_paths[it - port_versions.begin()]};
|
||||
}
|
||||
// } FilesystemRegistryEntry::RegistryEntry
|
||||
|
||||
|
@ -1206,7 +1205,7 @@ namespace
|
|||
return std::move(maybe_not_stale).error();
|
||||
}
|
||||
|
||||
ExpectedL<PathAndLocation> GitRegistryEntry::get_version(const Version& version) const
|
||||
ExpectedL<PortLocation> GitRegistryEntry::get_version(const Version& version) const
|
||||
{
|
||||
auto it = std::find(last_loaded.port_versions().begin(), last_loaded.port_versions().end(), version);
|
||||
if (it == last_loaded.port_versions().end() && stale)
|
||||
|
@ -1228,7 +1227,7 @@ namespace
|
|||
|
||||
const auto& git_tree = last_loaded.git_trees()[it - last_loaded.port_versions().begin()];
|
||||
return parent.m_paths.git_extract_tree_from_remote_registry(git_tree).map(
|
||||
[this, &git_tree](Path&& p) -> PathAndLocation {
|
||||
[this, &git_tree](Path&& p) -> PortLocation {
|
||||
return {
|
||||
std::move(p),
|
||||
Strings::concat("git+", parent.m_repo, "@", git_tree),
|
||||
|
|
|
@ -302,10 +302,9 @@ namespace vcpkg
|
|||
if (adjacent_equal != scf.feature_paragraphs.end())
|
||||
{
|
||||
auto error_info = std::make_unique<ParseControlErrorInfo>();
|
||||
error_info->name = scf.core_paragraph->name;
|
||||
error_info->error = msg::format_error(msgMultipleFeatures,
|
||||
msg::package_name = scf.core_paragraph->name,
|
||||
msg::feature = (*adjacent_equal)->name);
|
||||
error_info->name = scf.to_name();
|
||||
error_info->error = msg::format_error(
|
||||
msgMultipleFeatures, msg::package_name = scf.to_name(), msg::feature = (*adjacent_equal)->name);
|
||||
return error_info;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -1426,7 +1425,7 @@ namespace vcpkg
|
|||
}
|
||||
|
||||
template<class ManifestDeserializerType>
|
||||
static ExpectedL<std::unique_ptr<SourceControlFile>> parse_manifest_object_impl(StringView origin,
|
||||
static ExpectedL<std::unique_ptr<SourceControlFile>> parse_manifest_object_impl(StringView control_path,
|
||||
const Json::Object& manifest,
|
||||
MessageSink& warnings_sink)
|
||||
{
|
||||
|
@ -1436,13 +1435,14 @@ namespace vcpkg
|
|||
|
||||
for (auto&& w : reader.warnings())
|
||||
{
|
||||
warnings_sink.print(Color::warning, LocalizedString::from_raw(Strings::concat(origin, ": ", w, '\n')));
|
||||
warnings_sink.print(Color::warning,
|
||||
LocalizedString::from_raw(Strings::concat(control_path, ": ", w, '\n')));
|
||||
}
|
||||
|
||||
if (!reader.errors().empty())
|
||||
{
|
||||
ParseControlErrorInfo err;
|
||||
err.name = origin.to_string();
|
||||
err.name = control_path.to_string();
|
||||
err.other_errors = std::move(reader.errors());
|
||||
return LocalizedString::from_raw(err.to_string());
|
||||
}
|
||||
|
@ -1457,15 +1457,15 @@ namespace vcpkg
|
|||
}
|
||||
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> SourceControlFile::parse_project_manifest_object(
|
||||
StringView origin, const Json::Object& manifest, MessageSink& warnings_sink)
|
||||
StringView control_path, const Json::Object& manifest, MessageSink& warnings_sink)
|
||||
{
|
||||
return parse_manifest_object_impl<ProjectManifestDeserializer>(origin, manifest, warnings_sink);
|
||||
return parse_manifest_object_impl<ProjectManifestDeserializer>(control_path, manifest, warnings_sink);
|
||||
}
|
||||
|
||||
ExpectedL<std::unique_ptr<SourceControlFile>> SourceControlFile::parse_port_manifest_object(
|
||||
StringView origin, const Json::Object& manifest, MessageSink& warnings_sink)
|
||||
StringView control_path, const Json::Object& manifest, MessageSink& warnings_sink)
|
||||
{
|
||||
return parse_manifest_object_impl<PortManifestDeserializer>(origin, manifest, warnings_sink);
|
||||
return parse_manifest_object_impl<PortManifestDeserializer>(control_path, manifest, warnings_sink);
|
||||
}
|
||||
|
||||
ExpectedL<Unit> SourceControlFile::check_against_feature_flags(const Path& origin,
|
||||
|
@ -1822,11 +1822,12 @@ namespace vcpkg
|
|||
maybe_configuration.value_or_exit(VCPKG_LINE_INFO).serialize());
|
||||
}
|
||||
|
||||
serialize_optional_string(obj, ManifestDeserializer::NAME, scf.core_paragraph->name);
|
||||
serialize_optional_string(obj, ManifestDeserializer::NAME, scf.to_name());
|
||||
|
||||
if (scf.core_paragraph->version_scheme != VersionScheme::Missing)
|
||||
auto version_scheme = scf.to_version_scheme();
|
||||
if (version_scheme != VersionScheme::Missing)
|
||||
{
|
||||
serialize_schemed_version(obj, scf.core_paragraph->version_scheme, scf.core_paragraph->version);
|
||||
serialize_schemed_version(obj, version_scheme, scf.to_version());
|
||||
}
|
||||
|
||||
serialize_paragraph(obj, ManifestDeserializer::MAINTAINERS, scf.core_paragraph->maintainers);
|
||||
|
|
|
@ -167,7 +167,7 @@ std::string vcpkg::create_spdx_sbom(const InstallPlanAction& action,
|
|||
obj.insert("name", action.spec.name());
|
||||
obj.insert("SPDXID", "SPDXRef-port");
|
||||
obj.insert("versionInfo", cpgh.version.to_string());
|
||||
obj.insert("downloadLocation", scfl.registry_location.empty() ? noassert : scfl.registry_location);
|
||||
obj.insert("downloadLocation", scfl.spdx_location.empty() ? noassert : scfl.spdx_location);
|
||||
if (!cpgh.homepage.empty())
|
||||
{
|
||||
obj.insert("homepage", cpgh.homepage);
|
||||
|
|
Загрузка…
Ссылка в новой задаче