#build #target #env #utilities

build build-target

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

7 unstable releases (3 breaking)

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

#186 in Build Utils

Download history 22671/week @ 2024-07-27 26009/week @ 2024-08-03 21719/week @ 2024-08-10 23770/week @ 2024-08-17 25629/week @ 2024-08-24 23900/week @ 2024-08-31 28980/week @ 2024-09-07 24604/week @ 2024-09-14 27738/week @ 2024-09-21 24136/week @ 2024-09-28 22477/week @ 2024-10-05 22727/week @ 2024-10-12 21680/week @ 2024-10-19 20197/week @ 2024-10-26 26265/week @ 2024-11-02 16989/week @ 2024-11-09

89,008 downloads per month
Used in 44 crates (21 directly)

MIT license

22KB
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