Struct target_build_utils::TargetInfo [] [src]

pub struct TargetInfo { /* fields omitted */ }

Methods

impl TargetInfo
[src]

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");

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]

Architecture of the targeted machine

Corresponds to the #[cfg(target_arch = {})] in Rust code.

OS of the targeted machine

Corresponds to the #[cfg(target_os = {})] in Rust code.

Environment (ABI) of the targeted machine

Corresponds to the #[cfg(target_env = {})] in Rust code.

Endianess of the targeted machine

Valid values are: little and big.

Corresponds to the #[cfg(target_endian = {})] in Rust code.

Pointer width of the targeted machine

Corresponds to the #[cfg(target_pointer_width = {})] in Rust code.

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.

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");

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for TargetInfo
[src]

Formats the value using the given formatter.