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 db1b21c772..c8ba287f02 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -963,7 +963,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(": ") @@ -971,7 +971,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(": ") 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; });