Git Product home page Git Product logo

autocfg's Introduction

autocfg

autocfg crate autocfg documentation minimum rustc 1.0 Travis Status

A Rust library for build scripts to automatically configure code based on compiler support. Code snippets are dynamically tested to see if the rustc will accept them, rather than hard-coding specific version support.

Usage

Add this to your Cargo.toml:

[build-dependencies]
autocfg = "0.1"

Then use it in your build.rs script to detect compiler features. For example, to test for 128-bit integer support, it might look like:

extern crate autocfg;

fn main() {
    let ac = autocfg::new();
    ac.emit_has_type("i128");

    // (optional) We don't need to rerun for anything external.
    autocfg::rerun_path(file!());
}

If the type test succeeds, this will write a cargo:rustc-cfg=has_i128 line for Cargo, which translates to Rust arguments --cfg has_i128. Then in the rest of your Rust code, you can add #[cfg(has_i128)] conditions on code that should only be used when the compiler supports it.

Release Notes

  • 0.1.6 (2019-08-19)

    • Add probe/emit_sysroot_crate, by @leo60228
  • 0.1.5 (2019-07-16)

    • Mask some warnings from newer rustc.
  • 0.1.4 (2019-05-22)

    • Relax std/no_std probing to a warning instead of an error.
    • Improve rustc bootstrap compatibility.
  • 0.1.3 (2019-05-21)

    • Auto-detects if #![no_std] is needed for the $TARGET
  • 0.1.2 (2019-01-16)

    • Add rerun_env(ENV) to print cargo:rerun-if-env-changed=ENV
    • Add rerun_path(PATH) to print cargo:rerun-if-changed=PATH

Minimum Rust version policy

This crate's minimum supported rustc version is 1.0.0. Compatibility is its entire reason for existence, so this crate will be extremely conservative about raising this requirement. If this is ever deemed necessary, it will be treated as a major breaking change for semver purposes.

License

This project is licensed under either of

at your option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.