Struct target_build_utils::TargetInfo
[−]
[src]
pub struct TargetInfo { /* fields omitted */ }
Methods
impl TargetInfo
[src]
fn new() -> Result<TargetInfo, Error>
Parse the target info from TARGET
environment variable
TARGET
environment variable is usually set for you in build.rs scripts, therefore this
function is all that’s necessary in majority of cases.
Example
use target_build_utils::TargetInfo; let target = TargetInfo::new().expect("could not get target");
fn from_str(s: &str) -> Result<TargetInfo, Error>
Calculate the target info from the provided target value
String may contain a triple or path to the json file.
Example
use target_build_utils::TargetInfo; let target = TargetInfo::from_str("x86_64-unknown-linux-gnu") .expect("could not get target");
impl TargetInfo
[src]
fn target_arch(&self) -> &str
Architecture of the targeted machine
Corresponds to the #[cfg(target_arch = {})]
in Rust code.
fn target_os(&self) -> &str
OS of the targeted machine
Corresponds to the #[cfg(target_os = {})]
in Rust code.
fn target_env(&self) -> &str
Environment (ABI) of the targeted machine
Corresponds to the #[cfg(target_env = {})]
in Rust code.
fn target_endian(&self) -> &str
Endianess of the targeted machine
Valid values are: little
and big
.
Corresponds to the #[cfg(target_endian = {})]
in Rust code.
fn target_pointer_width(&self) -> &str
Pointer width of the targeted machine
Corresponds to the #[cfg(target_pointer_width = {})]
in Rust code.
fn target_vendor(&self) -> Option<&str>
Vendor of the targeted machine
Corresponds to the #[cfg(target_vendor = {})]
in Rust code.
This currently returns Some
only when when targetting nightly rustc version as well as
for custom JSON targets.
fn target_cfg(&self, key: &str) -> bool
Check if the configuration switch is set for target
Corresponds to the #[cfg({key} = {})]
in Rust code.
This function behaves specially in regard to custom JSON targets and will always return
false
for them currently.
Examples
use target_build_utils::TargetInfo; let info = TargetInfo::new().expect("target info"); let is_unix = info.target_cfg("unix");
fn target_cfg_value<'a>(&'a self, key: &str) -> Option<&'a str>
Return the value of an arbitrary configuration key
This function behaves specially in regard to custom JSON targets and will rarely return any extra target information.
Examples
use target_build_utils::TargetInfo; let info = TargetInfo::new().expect("target info"); assert_eq!(info.target_cfg_value("target_os"), Some(info.target_os())); assert_eq!(info.target_cfg_value("target_banana"), None);
Trait Implementations
impl Clone for TargetInfo
[src]
fn clone(&self) -> TargetInfo
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more