5 releases
Uses old Rust 2015
0.1.4 | Aug 24, 2024 |
---|---|
0.1.3 | Sep 22, 2021 |
0.1.2 | Apr 1, 2020 |
0.1.1 | Mar 26, 2020 |
0.1.0 | Apr 25, 2018 |
#145 in Operating systems
29,868 downloads per month
Used in 14 crates
(6 directly)
28KB
652 lines
guess_host_triple: Guess which Rust-supported platform is running the current code
Repository: https://gitlab.com/Screwtapello/guess_host_triple
Documentation: https://docs.rs/guess_host_triple
lib.rs
:
Guess which Rust-supported platform is running the current code.
Introduction
In the world of compilers, for both Rust and other languages, the "host" is the computer where the compiler runs and produces an executable, and the "target" is the computer where the resulting executable runs. Usually they are the same, but they don't have to be; for example, you can use a powerful desktop computer to compile code for a tiny microcontroller that wouldn't have the resources to compile a program on its own.
For compilers that can target many different kinds of computers, each target is given a unique name according to the "target triple" convention. If we describe the computer that the compiler runs on with a "triple", that's a "host triple".
Before you can install a copy of the Rust compiler on a given computer, you need to know the host triple Rust uses to describe computer, so you can choose a compatible one. This crate provides a function that guesses the host triple for the computer that it runs on, which you can look up in the Rust release channel metadata to find the URLs of the packages you'll need to download.
The code in this crate was originally extracted from the official rustup tool.
Example
extern crate guess_host_triple;
guess_host_triple::guess_host_triple()
.map(|triple| println!("This computer's triple: {}", triple))
.unwrap_or_else(|| println!("Can't guess this computer's triple"));
// Prints something like:
//
// This computer's triple: x86_64-unknown-linux-gnu
Dependencies
~61–320KB