This repository has been archived by the owner. It is now read-only.
Utility crate to handle the `TARGET` environment variable passed into scripts
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Use environment variables set by cargo from 1.14.0 onwards.


Travis CI Appveyor CI

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

Unlike rust’s #[cfg(target…)] attributes, 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 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 ( Add dependency to this crate to your Cargo.toml via:

# ...
build = ""

target_build_utils = "0.1"

Then write your 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 should be aware of the properties of the target system when your crate is being cross-compiled.


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