build.rs

Sun, 27 Apr 2025 20:29:43 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 27 Apr 2025 20:29:43 -0500
changeset 94
1f19c6bbf07b
permissions
-rw-r--r--

Fix build with stable rust.

For optimisations, build.rs now automatically sets a nightly cfg flag,
so problems with the nightly feature are avoided. It is still used for
required for additional nightly-only features.

use rustc_version::{version_meta, Channel};

fn main() {
    // Tell rust that nightly flag exists
    println!("cargo::rustc-check-cfg=cfg(nightly)");
    if version_meta().unwrap().channel == Channel::Nightly {
        // … and set it for nightly.
        println!("cargo:rustc-cfg=nightly");
    }
}

mercurial