Skip to content
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

More expressive checks in triplet #1379

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/vcpkg/triplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ namespace vcpkg

Path get_triplet_file_path(Triplet triplet) const;
bool is_valid_triplet_name(StringView name) const;
bool is_community_triplet_path(const Path& triplet_dir) const;
bool is_community_triplet(Triplet triplet) const;
bool is_overlay_triplet_path(const Path& triplet_dir) const;
bool is_overlay_triplet(Triplet triplet) const;
bool is_valid_triplet_canonical_name(StringView name) const;
};
}
2 changes: 2 additions & 0 deletions include/vcpkg/vcpkgpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ namespace vcpkg
public:
std::vector<std::string> overlay_ports;

bool is_overlay_port(StringView port_name) const;

std::string get_toolver_diagnostics() const;

const Filesystem& get_filesystem() const;
Expand Down
6 changes: 3 additions & 3 deletions src/vcpkg/commands.build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,15 +916,15 @@ namespace vcpkg
const auto& triplet_db = paths.get_triplet_db();
const auto& triplet_file_path = triplet_db.get_triplet_file_path(triplet);

if (Strings::starts_with(triplet_file_path, triplet_db.community_triplet_directory))
if (triplet_db.is_community_triplet_path(triplet_file_path))
{
msg::print(LocalizedString::from_raw(triplet_file_path)
.append_raw(": ")
.append_raw(InfoPrefix)
.append(msgLoadedCommunityTriplet)
.append_raw('\n'));
}
else if (!Strings::starts_with(triplet_file_path, triplet_db.default_triplet_directory))
else if (triplet_db.is_overlay_triplet_path(triplet_file_path))
{
msg::print(LocalizedString::from_raw(triplet_file_path)
.append_raw(": ")
Expand All @@ -933,7 +933,7 @@ namespace vcpkg
.append_raw('\n'));
}

if (!Strings::starts_with(scfl.control_path, paths.builtin_ports_directory()))
if (paths.is_overlay_port(action.spec.name()))
{
msg::print(LocalizedString::from_raw(scfl.port_directory())
.append_raw(": ")
Expand Down
20 changes: 20 additions & 0 deletions src/vcpkg/triplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@ namespace vcpkg
return is_valid_triplet_canonical_name(Strings::ascii_to_lowercase(name));
}

bool TripletDatabase::is_community_triplet_path(const Path& path) const
{
return Strings::starts_with(path, community_triplet_directory);
}

bool TripletDatabase::is_community_triplet(Triplet triplet) const
{
return is_community_triplet_path(get_triplet_file_path(triplet));
}

bool TripletDatabase::is_overlay_triplet_path(const Path& path) const
{
return !Strings::starts_with(path, default_triplet_directory) && !is_community_triplet_path(path);
}

bool TripletDatabase::is_overlay_triplet(Triplet triplet) const
{
return is_overlay_triplet_path(get_triplet_file_path(triplet));
}

bool TripletDatabase::is_valid_triplet_canonical_name(StringView name) const
{
return Util::any_of(available_triplets, [=](const TripletFile& tf) { return tf.name == name; });
Expand Down
7 changes: 7 additions & 0 deletions src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,13 @@ namespace vcpkg
.map([](Path&& dot_git_parent) { return std::move(dot_git_parent) / ".git"; });
}

bool VcpkgPaths::is_overlay_port(StringView port_name) const
{
return std::find_if(overlay_ports.begin(), overlay_ports.end(), [&port_name](StringView port_dir) {
Thomas1664 marked this conversation as resolved.
Show resolved Hide resolved
return Strings::ends_with(port_dir, port_name);
}) != overlay_ports.end();
}

std::string VcpkgPaths::get_toolver_diagnostics() const
{
std::string ret;
Expand Down
Loading