From 348d82addb6e8c2279175fa0f375762f1fbfad72 Mon Sep 17 00:00:00 2001 From: Thomas1664 <46387399+Thomas1664@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:35:03 +0000 Subject: [PATCH 1/6] More expressive checks in triplet/port --- include/vcpkg/sourceparagraph.h | 4 ++++ include/vcpkg/triplet.h | 4 ++++ src/vcpkg/commands.build.cpp | 6 +++--- src/vcpkg/triplet.cpp | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/vcpkg/sourceparagraph.h b/include/vcpkg/sourceparagraph.h index 05dd520571..6080bb57c1 100644 --- a/include/vcpkg/sourceparagraph.h +++ b/include/vcpkg/sourceparagraph.h @@ -209,6 +209,10 @@ namespace vcpkg 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(); } + bool is_overlay_port(const Path& default_port_dir) const + { + return !Strings::starts_with(control_path, default_port_dir); + } std::unique_ptr source_control_file; Path control_path; diff --git a/include/vcpkg/triplet.h b/include/vcpkg/triplet.h index 1f24d7088a..f947151481 100644 --- a/include/vcpkg/triplet.h +++ b/include/vcpkg/triplet.h @@ -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; }; } diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 402e7bdfcd..c620b943a9 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -916,7 +916,7 @@ 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(": ") @@ -924,7 +924,7 @@ namespace vcpkg .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(": ") @@ -933,7 +933,7 @@ namespace vcpkg .append_raw('\n')); } - if (!Strings::starts_with(scfl.control_path, paths.builtin_ports_directory())) + if (scfl.is_overlay_port(paths.builtin_ports_directory())) { msg::print(LocalizedString::from_raw(scfl.port_directory()) .append_raw(": ") diff --git a/src/vcpkg/triplet.cpp b/src/vcpkg/triplet.cpp index ba5060eccd..29d1117c6a 100644 --- a/src/vcpkg/triplet.cpp +++ b/src/vcpkg/triplet.cpp @@ -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; }); From d39e2069b942c5d325f69f72855707cf976dbd81 Mon Sep 17 00:00:00 2001 From: Thomas1664 <46387399+Thomas1664@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:07:20 +0000 Subject: [PATCH 2/6] add missing include --- include/vcpkg/sourceparagraph.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/vcpkg/sourceparagraph.h b/include/vcpkg/sourceparagraph.h index 6080bb57c1..7ebd49f4c5 100644 --- a/include/vcpkg/sourceparagraph.h +++ b/include/vcpkg/sourceparagraph.h @@ -9,6 +9,7 @@ #include #include +#include #include #include From a7f61989eeaeeb91e626e322f4a0ee00746d572f Mon Sep 17 00:00:00 2001 From: Thomas1664 <46387399+Thomas1664@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:19:14 +0200 Subject: [PATCH 3/6] Fix overlay port detection --- include/vcpkg/sourceparagraph.h | 5 ----- include/vcpkg/vcpkgpaths.h | 2 ++ src/vcpkg/commands.build.cpp | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/vcpkg/sourceparagraph.h b/include/vcpkg/sourceparagraph.h index 7ebd49f4c5..05dd520571 100644 --- a/include/vcpkg/sourceparagraph.h +++ b/include/vcpkg/sourceparagraph.h @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -210,10 +209,6 @@ namespace vcpkg 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(); } - bool is_overlay_port(const Path& default_port_dir) const - { - return !Strings::starts_with(control_path, default_port_dir); - } std::unique_ptr source_control_file; Path control_path; diff --git a/include/vcpkg/vcpkgpaths.h b/include/vcpkg/vcpkgpaths.h index 90fd4d093c..2da53b05e1 100644 --- a/include/vcpkg/vcpkgpaths.h +++ b/include/vcpkg/vcpkgpaths.h @@ -103,6 +103,8 @@ namespace vcpkg public: std::vector overlay_ports; + bool is_overlay_port(const std::string& port_name) const { return Util::contains(overlay_ports, port_name); } + std::string get_toolver_diagnostics() const; const Filesystem& get_filesystem() const; diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index c620b943a9..f16c54e16d 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -933,7 +933,7 @@ namespace vcpkg .append_raw('\n')); } - if (scfl.is_overlay_port(paths.builtin_ports_directory())) + if (paths.is_overlay_port(action.spec.name())) { msg::print(LocalizedString::from_raw(scfl.port_directory()) .append_raw(": ") From b36a1d52491c49282a09b8f99ce19aa5b1509083 Mon Sep 17 00:00:00 2001 From: Thomas1664 <46387399+Thomas1664@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:25:13 +0200 Subject: [PATCH 4/6] fix build --- include/vcpkg/vcpkgpaths.h | 2 +- src/vcpkg/vcpkgpaths.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/vcpkg/vcpkgpaths.h b/include/vcpkg/vcpkgpaths.h index 2da53b05e1..089ff726cc 100644 --- a/include/vcpkg/vcpkgpaths.h +++ b/include/vcpkg/vcpkgpaths.h @@ -103,7 +103,7 @@ namespace vcpkg public: std::vector overlay_ports; - bool is_overlay_port(const std::string& port_name) const { return Util::contains(overlay_ports, port_name); } + bool is_overlay_port(const std::string& port_name) const; std::string get_toolver_diagnostics() const; diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 7d48e87932..58c3453c06 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -834,6 +834,11 @@ namespace vcpkg .map([](Path&& dot_git_parent) { return std::move(dot_git_parent) / ".git"; }); } + bool VcpkgPaths::is_overlay_port(const std::string& port_name) const + { + return Util::contains(overlay_ports, port_name); + } + std::string VcpkgPaths::get_toolver_diagnostics() const { std::string ret; From 442a6760be77533660e6754e855f0ca6ab37a21a Mon Sep 17 00:00:00 2001 From: Thomas1664 <46387399+Thomas1664@users.noreply.github.com> Date: Wed, 15 May 2024 09:13:05 +0200 Subject: [PATCH 5/6] overlay_ports are actually paths --- include/vcpkg/vcpkgpaths.h | 2 +- src/vcpkg/vcpkgpaths.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/vcpkg/vcpkgpaths.h b/include/vcpkg/vcpkgpaths.h index 089ff726cc..5353c67df0 100644 --- a/include/vcpkg/vcpkgpaths.h +++ b/include/vcpkg/vcpkgpaths.h @@ -103,7 +103,7 @@ namespace vcpkg public: std::vector overlay_ports; - bool is_overlay_port(const std::string& port_name) const; + bool is_overlay_port(StringView port_name) const; std::string get_toolver_diagnostics() const; diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 58c3453c06..a79e02af11 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -834,9 +834,11 @@ namespace vcpkg .map([](Path&& dot_git_parent) { return std::move(dot_git_parent) / ".git"; }); } - bool VcpkgPaths::is_overlay_port(const std::string& port_name) const + bool VcpkgPaths::is_overlay_port(StringView port_name) const { - return Util::contains(overlay_ports, port_name); + return std::find_if(overlay_ports.begin(), overlay_ports.end(), [&port_name](StringView port_dir) { + return Strings::ends_with(port_dir, port_name); + }) != overlay_ports.end(); } std::string VcpkgPaths::get_toolver_diagnostics() const From 44fd69648e894cb426cf81e9a610dd271cde633c Mon Sep 17 00:00:00 2001 From: Thomas1664 <46387399+Thomas1664@users.noreply.github.com> Date: Sun, 8 Dec 2024 16:39:25 +0000 Subject: [PATCH 6/6] revert is_overlay_port --- include/vcpkg/vcpkgpaths.h | 2 -- src/vcpkg/commands.build.cpp | 2 +- src/vcpkg/vcpkgpaths.cpp | 7 ------- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/include/vcpkg/vcpkgpaths.h b/include/vcpkg/vcpkgpaths.h index 5353c67df0..90fd4d093c 100644 --- a/include/vcpkg/vcpkgpaths.h +++ b/include/vcpkg/vcpkgpaths.h @@ -103,8 +103,6 @@ namespace vcpkg public: std::vector overlay_ports; - bool is_overlay_port(StringView port_name) const; - std::string get_toolver_diagnostics() const; const Filesystem& get_filesystem() const; diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index f16c54e16d..71de84686c 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -933,7 +933,7 @@ namespace vcpkg .append_raw('\n')); } - if (paths.is_overlay_port(action.spec.name())) + if (!Strings::starts_with(scfl.control_path, paths.builtin_ports_directory())) { msg::print(LocalizedString::from_raw(scfl.port_directory()) .append_raw(": ") diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index a79e02af11..7d48e87932 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -834,13 +834,6 @@ 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) { - return Strings::ends_with(port_dir, port_name); - }) != overlay_ports.end(); - } - std::string VcpkgPaths::get_toolver_diagnostics() const { std::string ret;