Skip to content

Commit

Permalink
Community Triplets 🀝 (microsoft#7976)
Browse files Browse the repository at this point in the history
* Move untested triplets to Community Triplets

* Document community triplets

* Load community triplets by default and alert when using one

* [triplets] Merge documentation of community triplets

* Bump version
  • Loading branch information
vicroms authored Jan 17, 2020
1 parent bf3e071 commit f56645c
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 45 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions docs/users/triplets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"2019.09.12"
"2020.01.17"
14 changes: 12 additions & 2 deletions toolsrc/include/vcpkg/vcpkgpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<VcpkgPaths> create(const fs::path& vcpkg_root_dir,
const Optional<fs::path>& vcpkg_scripts_root_dir,
const std::string& default_vs_path,
Expand All @@ -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<std::string>& get_available_triplets() const;
const std::vector<std::string> get_available_triplets_names() const;
const std::vector<TripletFile>& get_available_triplets() const;
const fs::path get_triplet_file_path(const Triplet& triplet) const;

fs::path root;
Expand All @@ -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;
Expand All @@ -92,7 +102,7 @@ namespace vcpkg
Files::Filesystem& get_filesystem() const;

private:
Lazy<std::vector<std::string>> available_triplets;
Lazy<std::vector<TripletFile>> available_triplets;
Lazy<std::vector<Toolset>> toolsets;
Lazy<std::vector<Toolset>> toolsets_vs2013;

Expand Down
23 changes: 0 additions & 23 deletions toolsrc/src/vcpkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down
12 changes: 10 additions & 2 deletions toolsrc/src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions toolsrc/src/vcpkg/commands.autocomplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace vcpkg::Commands::Autocomplete
Checks::exit_success(VCPKG_LINE_INFO);
}

std::vector<std::string> triplets = paths.get_available_triplets();
std::vector<std::string> 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);
});
Expand Down Expand Up @@ -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);
}

Expand Down
32 changes: 29 additions & 3 deletions toolsrc/src/vcpkg/help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::vector<const VcpkgPaths::TripletFile*>> 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->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(" ", triplet, '\n');
System::print2("\nOverlay triplets from ", kv_pair.first, ":\n");
for (auto* triplet : kv_pair.second)
{
System::print2(" ", triplet->name, '\n');
}
}
}

Expand Down
27 changes: 19 additions & 8 deletions toolsrc/src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -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<std::string>& VcpkgPaths::get_available_triplets() const
const std::vector<std::string> VcpkgPaths::get_available_triplets_names() const
{
return this->available_triplets.get_lazy([this]() -> std::vector<std::string> {
std::vector<std::string> output;
return vcpkg::Util::fmap(this->get_available_triplets(),
[](auto&& triplet_file) -> std::string { return triplet_file.name; });
}

const std::vector<VcpkgPaths::TripletFile>& VcpkgPaths::get_available_triplets() const
{
return this->available_triplets.get_lazy([this]() -> std::vector<TripletFile> {
std::vector<TripletFile> 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;
});
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f56645c

Please sign in to comment.