diff --git a/.gitignore b/.gitignore index dbc801901..5b28596b8 100644 --- a/.gitignore +++ b/.gitignore @@ -294,15 +294,15 @@ __pycache__/ #ignore custom triplets /triplets/* #add vcpkg-designed triplets back in +!triplets/community/arm64-uwp.cmake +!triplets/community/arm-windows.cmake +!triplets/community/x86-uwp.cmake +!triplets/community/x86-windows-static.cmake !triplets/arm-uwp.cmake -!triplets/arm-windows.cmake !triplets/x64-uwp.cmake !triplets/x64-windows.cmake !triplets/x64-windows-static.cmake -!triplets/x86-uwp.cmake !triplets/x86-windows.cmake -!triplets/x86-windows-static.cmake -!triplets/arm64-uwp.cmake !triplets/arm64-windows.cmake !triplets/x64-linux.cmake !triplets/x64-osx.cmake diff --git a/docs/users/triplets.md b/docs/users/triplets.md index 7b75956e8..6e52d347d 100644 --- a/docs/users/triplets.md +++ b/docs/users/triplets.md @@ -8,6 +8,26 @@ We currently provide many triplets by default (run `vcpkg help triplet`). Howeve To change the triplet used by your project, such as to enable static linking, see our [Integration Document](integration.md#triplet-selection). + +## Community triplets + +Triplets contained in the `triplets\community` folder are not tested by continuous integration. + +These triplets contain configurations commonly requested by the community, but for which we lack the resources to properly test. + +Port updates may break compatibility with community triplets, such regressions won't get caught by our testing pipelines. Because of this, community involvement is paramount! + +We will gladly accept and review contributions that aim to solve issues with these triplets. + +### Usage + +Community Triplets are enabled by default, when using a community triplet a message like the following one will be printed during a package install: + +```bash +-- Using community triplet x86-uwp. This triplet configuration is not guaranteed to succeed. +-- [COMMUNITY] Loading triplet configuration from: D:\src\viromer\vcpkg\triplets\community\x86-uwp.cmake +``` + ## Variables ### VCPKG_TARGET_ARCHITECTURE Specifies the target machine architecture. diff --git a/toolsrc/VERSION.txt b/toolsrc/VERSION.txt index 4d402b96c..80548a819 100644 --- a/toolsrc/VERSION.txt +++ b/toolsrc/VERSION.txt @@ -1 +1 @@ -"2019.09.12" +"2020.01.17" diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 8107b8201..52d77d283 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -47,6 +47,14 @@ namespace vcpkg struct VcpkgPaths { + struct TripletFile + { + std::string name; + fs::path location; + + TripletFile(const std::string& name, const fs::path& location) : name(name), location(location){} + }; + static Expected create(const fs::path& vcpkg_root_dir, const Optional& vcpkg_scripts_root_dir, const std::string& default_vs_path, @@ -57,7 +65,8 @@ namespace vcpkg fs::path listfile_path(const BinaryParagraph& pgh) const; bool is_valid_triplet(const Triplet& t) const; - const std::vector& get_available_triplets() const; + const std::vector get_available_triplets_names() const; + const std::vector& get_available_triplets() const; const fs::path get_triplet_file_path(const Triplet& triplet) const; fs::path root; @@ -67,6 +76,7 @@ namespace vcpkg fs::path ports; fs::path installed; fs::path triplets; + fs::path community_triplets; fs::path scripts; fs::path tools; @@ -92,7 +102,7 @@ namespace vcpkg Files::Filesystem& get_filesystem() const; private: - Lazy> available_triplets; + Lazy> available_triplets; Lazy> toolsets; Lazy> toolsets_vs2013; diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index c336d2f63..2dd13f43d 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -261,29 +261,6 @@ static void load_config() } } -#if defined(_WIN32) -static std::string trim_path_from_command_line(const std::string& full_command_line) -{ - Checks::check_exit( - VCPKG_LINE_INFO, !full_command_line.empty(), "Internal failure - cannot have empty command line"); - - if (full_command_line[0] == '"') - { - auto it = std::find(full_command_line.cbegin() + 1, full_command_line.cend(), '"'); - if (it != full_command_line.cend()) // Skip over the quote - ++it; - while (it != full_command_line.cend() && *it == ' ') // Skip over a space - ++it; - return std::string(it, full_command_line.cend()); - } - - auto it = std::find(full_command_line.cbegin(), full_command_line.cend(), ' '); - while (it != full_command_line.cend() && *it == ' ') - ++it; - return std::string(it, full_command_line.cend()); -} -#endif - #if defined(_WIN32) // note: this prevents a false positive for -Wmissing-prototypes on clang-cl int wmain(int, const wchar_t* const*); diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index f13dd2a25..654142696 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -497,6 +497,8 @@ namespace vcpkg::Build else { const auto algo = Hash::Algorithm::Sha1; + // TODO: Use file path as part of hash. + // REASON: Copying a triplet file without modifying it produces the same hash as the original. hash = Hash::get_file_hash(VCPKG_LINE_INFO, fs, triplet_file_path, algo); if (auto p = pre_build_info.external_toolchain_file.get()) @@ -550,10 +552,16 @@ namespace vcpkg::Build const Triplet& triplet = spec.triplet(); const auto& triplet_file_path = paths.get_triplet_file_path(spec.triplet()).u8string(); - if (!Strings::case_insensitive_ascii_starts_with(triplet_file_path, paths.triplets.u8string())) + if (Strings::case_insensitive_ascii_starts_with(triplet_file_path, paths.community_triplets.u8string())) { - System::printf("-- Loading triplet configuration from: %s\n", triplet_file_path); + System::printf(vcpkg::System::Color::warning, "-- Using community triplet %s. This triplet configuration is not guaranteed to succeed.\n", triplet.canonical_name()); + System::printf("-- [COMMUNITY] Loading triplet configuration from: %s\n", triplet_file_path); } + else if (!Strings::case_insensitive_ascii_starts_with(triplet_file_path, paths.triplets.u8string())) + { + System::printf("-- [OVERLAY] Loading triplet configuration from: %s\n", triplet_file_path); + } + if (!Strings::case_insensitive_ascii_starts_with(config.port_dir.u8string(), paths.ports.u8string())) { System::printf("-- Installing port from location: %s\n", config.port_dir.u8string()); diff --git a/toolsrc/src/vcpkg/commands.autocomplete.cpp b/toolsrc/src/vcpkg/commands.autocomplete.cpp index 8449b7096..d4149ae6d 100644 --- a/toolsrc/src/vcpkg/commands.autocomplete.cpp +++ b/toolsrc/src/vcpkg/commands.autocomplete.cpp @@ -97,7 +97,7 @@ namespace vcpkg::Commands::Autocomplete Checks::exit_success(VCPKG_LINE_INFO); } - std::vector triplets = paths.get_available_triplets(); + std::vector triplets = paths.get_available_triplets_names(); Util::erase_remove_if(triplets, [&](const std::string& s) { return !Strings::case_insensitive_ascii_starts_with(s, triplet_prefix); }); @@ -158,7 +158,7 @@ namespace vcpkg::Commands::Autocomplete if (command.name == "install" && results.size() == 1 && !is_option) { const auto port_at_each_triplet = - combine_port_with_triplets(results[0], paths.get_available_triplets()); + combine_port_with_triplets(results[0], paths.get_available_triplets_names()); Util::Vectors::concatenate(&results, port_at_each_triplet); } diff --git a/toolsrc/src/vcpkg/help.cpp b/toolsrc/src/vcpkg/help.cpp index a4908e02e..78bc43539 100644 --- a/toolsrc/src/vcpkg/help.cpp +++ b/toolsrc/src/vcpkg/help.cpp @@ -74,10 +74,36 @@ namespace vcpkg::Help void help_topic_valid_triplet(const VcpkgPaths& paths) { - System::print2("Available architecture triplets:\n"); - for (auto&& triplet : paths.get_available_triplets()) + std::map> triplets_per_location; + vcpkg::Util::group_by(paths.get_available_triplets(), + &triplets_per_location, + [](const VcpkgPaths::TripletFile& triplet_file) -> std::string { + return triplet_file.location.u8string(); + }); + + System::print2("Available architecture triplets\n"); + + System::print2("VCPKG built-in triplets:\n"); + for (auto* triplet : triplets_per_location[paths.triplets.u8string()]) { - System::print2(" ", triplet, '\n'); + System::print2(" ", triplet->name, '\n'); + } + triplets_per_location.erase(paths.triplets.u8string()); + + System::print2("\nVCPKG community triplets:\n"); + for (auto* triplet : triplets_per_location[paths.community_triplets.u8string()]) + { + System::print2(" ", triplet->name, '\n'); + } + triplets_per_location.erase(paths.community_triplets.u8string()); + + for (auto&& kv_pair : triplets_per_location) + { + System::print2("\nOverlay triplets from ", kv_pair.first, ":\n"); + for (auto* triplet : kv_pair.second) + { + System::print2(" ", triplet->name, '\n'); + } } } diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index 078121fcc..692cf1634 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -67,6 +67,7 @@ namespace vcpkg paths.ports = paths.root / "ports"; paths.installed = paths.root / "installed"; paths.triplets = paths.root / "triplets"; + paths.community_triplets = paths.triplets / "community"; if (auto scripts_dir = vcpkg_scripts_root_dir.get()) { @@ -110,7 +111,8 @@ namespace vcpkg paths.triplets_dirs.emplace_back(fs::stdfs::canonical(path)); } } - paths.triplets_dirs.emplace_back(fs::stdfs::canonical(paths.root / "triplets")); + paths.triplets_dirs.emplace_back(fs::stdfs::canonical(paths.triplets)); + paths.triplets_dirs.emplace_back(fs::stdfs::canonical(paths.community_triplets)); return paths; } @@ -130,23 +132,32 @@ namespace vcpkg bool VcpkgPaths::is_valid_triplet(const Triplet& t) const { const auto it = Util::find_if(this->get_available_triplets(), [&](auto&& available_triplet) { - return t.canonical_name() == available_triplet; + return t.canonical_name() == available_triplet.name; }); return it != this->get_available_triplets().cend(); } - const std::vector& VcpkgPaths::get_available_triplets() const + const std::vector VcpkgPaths::get_available_triplets_names() const { - return this->available_triplets.get_lazy([this]() -> std::vector { - std::vector output; + return vcpkg::Util::fmap(this->get_available_triplets(), + [](auto&& triplet_file) -> std::string { return triplet_file.name; }); + } + + const std::vector& VcpkgPaths::get_available_triplets() const + { + return this->available_triplets.get_lazy([this]() -> std::vector { + std::vector output; + Files::Filesystem& fs = this->get_filesystem(); for (auto&& triplets_dir : triplets_dirs) { - for (auto&& path : this->get_filesystem().get_files_non_recursive(triplets_dir)) + for (auto&& path : fs.get_files_non_recursive(triplets_dir)) { - output.push_back(path.stem().filename().string()); + if (fs::is_regular_file(fs.status(VCPKG_LINE_INFO, path))) + { + output.emplace_back(TripletFile(path.stem().filename().u8string(), triplets_dir)); + } } } - Util::sort_unique_erase(output); return output; }); } diff --git a/triplets/arm-windows.cmake b/triplets/community/arm-windows.cmake similarity index 100% rename from triplets/arm-windows.cmake rename to triplets/community/arm-windows.cmake diff --git a/triplets/arm64-uwp.cmake b/triplets/community/arm64-uwp.cmake similarity index 100% rename from triplets/arm64-uwp.cmake rename to triplets/community/arm64-uwp.cmake diff --git a/triplets/x86-uwp.cmake b/triplets/community/x86-uwp.cmake similarity index 100% rename from triplets/x86-uwp.cmake rename to triplets/community/x86-uwp.cmake diff --git a/triplets/x86-windows-static.cmake b/triplets/community/x86-windows-static.cmake similarity index 100% rename from triplets/x86-windows-static.cmake rename to triplets/community/x86-windows-static.cmake