Path: blob/main/py-polars/runtime/polars-runtime-compat/build.rs
7884 views
use rustflags::Flag;12fn main() {3println!("cargo::rustc-check-cfg=cfg(allocator, values(\"default\", \"mimalloc\"))");4println!(5"cargo:rustc-env=TARGET={}",6std::env::var("TARGET").unwrap()7);89// Write out feature flags for runtime compatibility checks.10// We don't use OUT_DIR for this because maturin only includes files in the11// source directory. Since we generate a Python file and nothing the Rust12// compiler expects this should be fine.13let mut target_feats = String::new();14for flag in rustflags::from_env() {15if let Flag::Codegen {16opt,17value: Some(value),18} = flag19{20if opt == "target-feature" {21if !target_feats.is_empty() {22target_feats.push(',');23}24target_feats.push_str(&value);25}26}27}2829let runtime_folder = std::fs::read_dir(".")30.unwrap()31.filter_map(|entry| entry.ok())32.find(|entry| {33entry34.file_name()35.to_string_lossy()36.starts_with("_polars_runtime")37})38.unwrap();3940std::fs::write(41runtime_folder.path().join("build_feature_flags.py"),42format!("BUILD_FEATURE_FLAGS = \"{target_feats}\"\n"),43)44.unwrap();45}464748