#build #target #build-script #json #target-triple #env-var #triple

deprecated build target_build_utils

DEPRECATED: Use Cargo environment variables CARGO_CFG_TARGET_*

7 releases

Uses old Rust 2015

0.3.1 May 2, 2017
0.3.0 Feb 10, 2017
0.2.1 Feb 3, 2017
0.2.0 Jan 18, 2017
0.1.1 Jul 29, 2016

#12 in #target-triple

Download history 14979/week @ 2024-04-09 14031/week @ 2024-04-16 13936/week @ 2024-04-23 12898/week @ 2024-04-30 10073/week @ 2024-05-07 8818/week @ 2024-05-14 8084/week @ 2024-05-21 8191/week @ 2024-05-28 7262/week @ 2024-06-04 6558/week @ 2024-06-11 6638/week @ 2024-06-18 7449/week @ 2024-06-25 8163/week @ 2024-07-02 6959/week @ 2024-07-09 6212/week @ 2024-07-16 5556/week @ 2024-07-23

28,136 downloads per month
Used in 136 crates (3 directly)

ISC/Apache-2.0

31KB
518 lines

DEPRECATED

Use environment variables set by cargo from 1.14.0 onwards.

They look like this: CARGO_CFG_TARGET_OS, CARGO_CFG_TARGET_ENV


Travis CI Appveyor CI

Utility crate to handle the TARGET environment variable passed into build.rs scripts.

Unlike rust’s #[cfg(target…)] attributes, build.rs-scripts do not expose a convenient way to detect the system the code will be built for in a way which would properly support cross-compilation.

This crate exposes target_arch, target_vendor, target_os and target_abi very much in the same manner as the corresponding cfg attributes in Rust do, thus allowing build.rs script to adjust the output depending on the target the crate is being built for..

Custom target json files are also supported.

Using target_build_utils

This crate is only useful if you’re using a build script (build.rs). Add dependency to this crate to your Cargo.toml via:

[package]
# ...
build = "build.rs"

[build-dependencies]
target_build_utils = "0.1"

Then write your build.rs like this:

extern crate target_build_utils;
use target_build_utils::TargetInfo;

fn main() {
    let target = TargetInfo::new().expect("could not get target info");
    if target.target_os() == "windows" {
        // conditional stuff for windows
    }
}

Now, when running cargo build, your build.rs should be aware of the properties of the target system when your crate is being cross-compiled.

License

llvm_build_utils is distributed under ISC (MIT-like) or Apache (version 2.0) license at your choice.

Dependencies

~1.5MB
~32K SLoC