#build #target #env #utils

build-target

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

7 unstable releases (3 breaking)

Uses new Rust 2021

0.4.0 Apr 29, 2022
0.3.1 Oct 14, 2021
0.2.1 Oct 14, 2021
0.2.0 Sep 6, 2021
0.1.1 Aug 1, 2021

#59 in Build Utils

Download history 107/week @ 2022-01-28 21/week @ 2022-02-04 20/week @ 2022-02-11 12/week @ 2022-02-18 11/week @ 2022-02-25 6/week @ 2022-03-04 19/week @ 2022-03-11 29/week @ 2022-03-18 24/week @ 2022-03-25 5/week @ 2022-04-01 42/week @ 2022-04-08 300/week @ 2022-04-15 114/week @ 2022-04-22 497/week @ 2022-04-29 79/week @ 2022-05-06 133/week @ 2022-05-13

974 downloads per month
Used in 3 crates (2 directly)

MIT license

21KB
398 lines

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)

No runtime deps