1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! A command line tool to print the current default Clang/LLVM target triple.
//!
//! The LLVM ecosystem names compiler targets as [**target triples**][1],
//! made up of three to five parameters describing the target system.
//!
//! This crate is a small binary program that returns the *default*
//! target triple for your current Rust installation. This program
//! is useful if you want to write shell scripts or other simple
//! programs that are aware of your Rust installation's default target.
//!
//! You can find default-target's crate metadata on [crates.io][2],
//! documentation on [docs.rs][3], and source code on [GitHub][4].
//!
//! # Installation
//! Run this command in your shell to install default-target.
//! ```
//! cargo install default-target
//! ```
//! # Usage
//! Once default-target has been installed in your path, you can run:
//! ```
//! default-target
//! ```
//! and it should return your target. Something like: `x86_64-apple-darwin`
//! or `x86_64-unknown-linux-gnu`.
//!
//! [1]: https://clang.llvm.org/docs/CrossCompilation.html#target-triple
//! [2]: https://crates.io/crates/default-target
//! [3]: https://docs.rs/default-target
//! [4]: https://github.com/neocrym/default-target
use ;
use ;
use str;
/// The [`rustc`][1] output field name that shows the target.
///
/// [1]: https://doc.rust-lang.org/rustc/what-is-rustc.html
const TARGET_FIELD: &str = "host: ";
/// The custom error type for this crate.
/// Calls rustc in a subprocess and returns the default Clang target triple.
///
/// This method is based on [this StackOverflow answer][2].
///
/// # Arguments:
/// - `rustc_path`: The path to a [`rustc`][1] executable. We call this
/// rustc executable in a subprocess to discover its default
/// target triple.
///
/// [1]: https://doc.rust-lang.org/rustc/what-is-rustc.html
/// [2]: https://stackoverflow.com/a/66955420