Skip to content

Commit

Permalink
build: configure min const generics
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Apr 24, 2021
1 parent 7814c2a commit 5cfea26
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,17 @@ fn configure(interpreter_config: &InterpreterConfig) -> Result<()> {
println!("cargo:rustc-cfg=Py_3_{}", i);
}

configure_min_const_generics();

Ok(())
}

fn configure_min_const_generics() {
if rustc_minor_version().unwrap_or(0) >= 51 {
println!("cargo:rustc-cfg=min_const_generics");
}
}

fn check_target_architecture(interpreter_config: &InterpreterConfig) -> Result<()> {
// Try to check whether the target architecture matches the python library
let rust_target = match cargo_env_var("CARGO_CFG_TARGET_POINTER_WIDTH")
Expand Down Expand Up @@ -922,7 +930,7 @@ fn configure_abi3_without_interpreter() {
}

fn rustc_minor_version() -> Option<u32> {
let rustc = env::var_os("RUSTC")?;
let rustc = env_var("RUSTC")?;
let output = Command::new(rustc).arg("--version").output().ok()?;
let version = core::str::from_utf8(&output.stdout).ok()?;
let mut pieces = version.split('.');
Expand All @@ -932,12 +940,6 @@ fn rustc_minor_version() -> Option<u32> {
pieces.next()?.parse().ok()
}

fn manage_min_const_generics() {
if rustc_minor_version().unwrap_or(0) >= 51 {
println!("cargo:rustc-cfg=min_const_generics");
}
}

fn main_impl() -> Result<()> {
// If PYO3_NO_PYTHON is set with abi3, we can build PyO3 without calling Python.
// We only check for the abi3-py3{ABI3_MAX_MINOR} because lower versions depend on it.
Expand Down Expand Up @@ -974,8 +976,6 @@ fn main_impl() -> Result<()> {
println!("cargo:rustc-cfg={}=\"{}\"", CFG_KEY, flag)
}

manage_min_const_generics();

Ok(())
}

Expand Down

0 comments on commit 5cfea26

Please sign in to comment.