-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure spdx_location is not dropped when loading ports. #1237
Conversation
1. Change try_load_port and friends to accept the spdx location and return SourceControlFileAndLocation rather than requiring all callers to staple that on. 2. PathAndLocation => PortLocation 3. Fix confusion in SourceControlFileAndLocation due to some parts of the codebase using source_location as the port_directory. 4. Rename all "registry_location"s to "spdx_location" to avoid it sounding like this is the spdx location of the registry. 5. Require origin to be provided in all the places.
# Conflicts: # src/vcpkg/portfileprovider.cpp # src/vcpkg/spdx.cpp
src/vcpkg/commands.add-version.cpp
Outdated
|
||
auto maybe_scf = | ||
Paragraphs::try_load_port_required(fs, port_name, paths.builtin_ports_directory() / port_name); | ||
auto maybe_scf = Paragraphs::try_load_port_required( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto maybe_scf = Paragraphs::try_load_port_required( | |
auto maybe_scfl = Paragraphs::try_load_port_required( |
scf
== SourceControlFile
src/vcpkg/commands.add-version.cpp
Outdated
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); | ||
auto command_line = fmt::format("vcpkg format-manifest {}", scf->control_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be shell escaped? For example, if the user has a space in their path.
src/vcpkg/commands.build.cpp
Outdated
{ | ||
msg::println(msgInstallingFromLocation, msg::path = scfl.source_location); | ||
msg::println(msgInstallingFromLocation, msg::path = scfl.control_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be port_directory()
or control_path
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did intend this change but I guess technically it's also referring to patches and stuff in there.
src/vcpkg/paragraphs.cpp
Outdated
const auto manifest_path = port_location.port_directory / "vcpkg.json"; | ||
const auto control_path = port_location.port_directory / "CONTROL"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be non-const so they can be moved into the return?
@@ -549,20 +537,16 @@ namespace vcpkg::Paragraphs | |||
auto maybe_port_location = (*port_entry)->get_version(*baseline_version); | |||
const auto port_location = maybe_port_location.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove const
so this can be moved into try_load_port_required
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pointer so there's no benefit to be had for moving it. Also, try_load_port_required
accepts by const&
because the data in question is normally owned by the registry...
src/vcpkg/portfileprovider.cpp
Outdated
{ | ||
auto scf_vspec = scf->get()->to_version_spec(); | ||
auto scf_vspec = scfl->source_control_file.get()->to_version_spec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto scf_vspec = scfl->source_control_file.get()->to_version_spec(); | |
auto scf_vspec = scfl->source_control_file->to_version_spec(); |
Additionally, consider lifting to_version_spec()
up to SourceControlFileAndLocation
.
src/vcpkg/portfileprovider.cpp
Outdated
auto port_name = scfl.source_control_file->core_paragraph->name; | ||
auto it = m_control_cache.emplace(VersionSpec{port_name, scfl.to_version()}, std::move(scfl)).first; | ||
out.emplace(std::move(port_name), &it->second.value_or_exit(VCPKG_LINE_INFO)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is calling scfl.to_version()
while also moving from scfl
before the next sequence point.
auto port_name = scfl.source_control_file->core_paragraph->name; | |
auto it = m_control_cache.emplace(VersionSpec{port_name, scfl.to_version()}, std::move(scfl)).first; | |
out.emplace(std::move(port_name), &it->second.value_or_exit(VCPKG_LINE_INFO)); | |
auto vspec = scfl.source_control_file->to_version_spec(); | |
auto it = m_control_cache.emplace(std::move(vspec), std::move(scfl)).first; | |
out.emplace(it->first.port_name, &it->second.value_or_exit(VCPKG_LINE_INFO)); |
src/vcpkg/portfileprovider.cpp
Outdated
{ | ||
auto& scf = *scfp; | ||
if (scf->core_paragraph->name == port_name) | ||
if (scfl->source_control_file->core_paragraph->name == port_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be very nice to expose .name()
on SCF/SCFL
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}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some duplicate work between is_port_directory
and try_load_port_required
that can be removed without much contortion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but not in this extraction :)
The next extraction from #1210