build-target

Crates.iobuild-target
lib.rsbuild-target
version0.4.0
sourcesrc
created_at2021-08-01 14:19:46.736078
updated_at2022-04-29 21:26:07.549995
descriptionA crate that provides programmatic access to information about the current build target.
homepagehttps://github.com/OpenByteDev/build-target
repositoryhttps://github.com/OpenByteDev/build-target
max_upload_size
id430023
size25,107
OpenByte (OpenByteDev)

documentation

https://docs.rs/build-target

README

build-target

CI crates.io Documentation dependency status MIT

A crate that provides programmatic access to information about the current build target inside build.rs.

Examples

Prints all available information about the current build target.

// inside build.rs

fn main() {
    // The panic is just used to print the information to the console.
    panic!("current build target: {:#?}",
        build_target::target().unwrap()
    );
}

Gets the parts of the current build target individually.

// inside build.rs

fn main() {
    let arch   = build_target::target_arch().unwrap();   // eg. "x86_64", "aarch64", ...
    let env    = build_target::target_env().unwrap();    // eg. "gnu", "msvc", ...
    let family = build_target::target_family().unwrap(); // eg. "windows", "unix", ...
    let os     = build_target::target_os().unwrap();     // eg. "android", "linux", ...
    let triple = build_target::target_triple().unwrap(); // eg. "x86_64-unknown-linux-gnu", ...
}

Attribution

This crate is inspired by and partially based on platforms.

License

Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT)

Commit count: 62

cargo fmt