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.

94
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
1 use rustc_version::{version_meta, Channel};
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
2
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
3 fn main() {
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
4 // Tell rust that nightly flag exists
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
5 println!("cargo::rustc-check-cfg=cfg(nightly)");
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
6 if version_meta().unwrap().channel == Channel::Nightly {
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
7 // … and set it for nightly.
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
8 println!("cargo:rustc-cfg=nightly");
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
9 }
1f19c6bbf07b Fix build with stable rust.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
10 }

mercurial