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